components.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. declare namespace ContextMenu {
  2. interface IContextMenuComponent {
  3. // 隐藏
  4. Hide: () => void;
  5. }
  6. // 菜单项的每一个 item
  7. interface IMenuItem {
  8. text: (() => string) | string;
  9. icon?: string;
  10. hidden?: (() => boolean) | boolean;
  11. disable?: (() => Promise<boolean> | boolean) | boolean;
  12. callback?: (inputVal?: number | string) => void;
  13. submenu?: IMenuItem[][];
  14. }
  15. // 菜单项分组
  16. type MenuGroup = IMenuItem[];
  17. }
  18. declare namespace ResizableLayout {
  19. interface IDataParam {
  20. index: number;
  21. instance: any;
  22. minSize: number;
  23. }
  24. interface IMoveParam {
  25. index: number; // 当前layoutItem是父组件的第几个子组件
  26. distance: number; // 鼠标移动的距离,负数代表左移,正数代表右移
  27. moveId: symbol; // move事件的唯一标志
  28. }
  29. interface IResizableLayoutComponent {
  30. Refresh: () => void;
  31. }
  32. }
  33. type Renderer = (
  34. instance: Handsontable,
  35. TD: HTMLElement,
  36. row: number,
  37. col: number,
  38. prop: string | number,
  39. value: any,
  40. cellProperties: GridSettings
  41. ) => HTMLElement;
  42. declare namespace Hot {
  43. interface ICoords {
  44. startRow: number;
  45. startCol: number;
  46. endRow: number;
  47. endCol: number;
  48. }
  49. interface IColumnMeta {
  50. title: string;
  51. data: string;
  52. renderer?: | string | Renderer | ((
  53. instance: Handsontable,
  54. td: HTMLElement,
  55. row: number,
  56. col: number,
  57. prop: string | number,
  58. value: any,
  59. cellProperties: IColumnMeta
  60. ) => void);
  61. editor?: string;
  62. readOnly?: boolean;
  63. showButton?: boolean; // 默认readOnly为true时,右上角的按钮也不显示,对于readOnly为true,又要显示按钮的情况,这里也要设置为true
  64. width: number;
  65. // 小数位数,如果存在此项配置,搭配'wc.numeric' cellType后,会将数值string转换为number,并进行四舍五入
  66. decimal?: number | (() => number);
  67. // 允许输入空值,转换成null
  68. numberAllowEmpty?: boolean;
  69. type?: string;
  70. checkedTemplate?: any;
  71. uncheckedTemplate?: any;
  72. numericFormat?: { pattern?: string; zeroFormat?: string };
  73. source?: string[] | any[];
  74. className?: string;
  75. required?: boolean;
  76. isTemporary?: boolean;
  77. }
  78. type MouseKey = 'left' | 'middle' | 'right';
  79. type ClickPosition = 'outside' | 'barren' | 'content';
  80. interface IGroupHeaderCell {
  81. label: string;
  82. colspan?: number;
  83. rowspan?: number;
  84. }
  85. type GroupHeaderCell = IGroupHeaderCell | string;
  86. interface ISettings extends GridSettings {
  87. columnsMeta?: IColumnMeta[];
  88. /**
  89. * 获取鼠标点击的区域
  90. * @param isOutside 是否在表格外面
  91. * @param isBarren 是否在表格内部的空白区域
  92. * @param isContent 是否在表格内容的内同区域
  93. */
  94. onClickPosition?: (whichKey: MouseKey, clickPosition: ClickPosition) => void;
  95. // 表头分组
  96. groupingHeaders?: GroupHeaderCell[][];
  97. // contextMenu?: { callback: (...args: any) => void; items: any };
  98. }
  99. interface IHandsontableProps {
  100. data: any[];
  101. settings: ISettings;
  102. tree: boolean;
  103. readOnly: boolean;
  104. border: string;
  105. loading: boolean;
  106. }
  107. interface IRenderer {
  108. (
  109. instance: Handsontable,
  110. row: number,
  111. col: number,
  112. prop: string | number,
  113. value: any,
  114. cellProperties: GridSettings
  115. ): HTMLElement;
  116. }
  117. type CellChangeParam = [/* row */ number, /* prop */ string, /* oldValue */ any, /* newValue */ any];
  118. type RendererItem = [string, ComponentObjectPropsOptions | IRenderer];
  119. }