es-grid-template 1.7.23 → 1.7.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/es/index.d.ts +1 -0
  2. package/es/index.js +3 -1
  3. package/es/table-component/ColumnsChoose.d.ts +10 -0
  4. package/es/table-component/ColumnsChoose.js +557 -0
  5. package/es/table-component/ContextMenu.d.ts +20 -0
  6. package/es/table-component/ContextMenu.js +75 -0
  7. package/es/table-component/InternalTable.d.ts +9 -0
  8. package/es/table-component/InternalTable.js +295 -0
  9. package/es/table-component/TableContainer.d.ts +22 -0
  10. package/es/table-component/TableContainer.js +130 -0
  11. package/es/table-component/TableContainerEdit.d.ts +28 -0
  12. package/es/table-component/TableContainerEdit.js +1211 -0
  13. package/es/table-component/body/EditableCell.d.ts +16 -0
  14. package/es/table-component/body/EditableCell.js +1036 -0
  15. package/es/table-component/body/TableBody.d.ts +19 -0
  16. package/es/table-component/body/TableBody.js +64 -0
  17. package/es/table-component/body/TableBodyCell.d.ts +10 -0
  18. package/es/table-component/body/TableBodyCell.js +139 -0
  19. package/es/table-component/body/TableBodyCellEdit.d.ts +15 -0
  20. package/es/table-component/body/TableBodyCellEdit.js +814 -0
  21. package/es/table-component/body/TableBodyRow.d.ts +21 -0
  22. package/es/table-component/body/TableBodyRow.js +146 -0
  23. package/es/table-component/components/ControlCheckbox.d.ts +13 -0
  24. package/es/table-component/components/ControlCheckbox.js +87 -0
  25. package/es/table-component/components/EditForm/EditForm.d.ts +27 -0
  26. package/es/table-component/components/EditForm/EditForm.js +395 -0
  27. package/es/table-component/components/EditForm/index.d.ts +1 -0
  28. package/es/table-component/components/EditForm/index.js +1 -0
  29. package/es/table-component/components/InputControl/InputControl.d.ts +27 -0
  30. package/es/table-component/components/InputControl/InputControl.js +121 -0
  31. package/es/table-component/components/InputControl/index.d.ts +1 -0
  32. package/es/table-component/components/InputControl/index.js +1 -0
  33. package/es/table-component/components/async-select/index.d.ts +11 -0
  34. package/es/table-component/components/async-select/index.js +41 -0
  35. package/es/table-component/components/async-table-select/index.d.ts +11 -0
  36. package/es/table-component/components/async-table-select/index.js +43 -0
  37. package/es/table-component/components/checkbox-control/index.d.ts +13 -0
  38. package/es/table-component/components/checkbox-control/index.js +40 -0
  39. package/es/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  40. package/es/table-component/components/checkbox-filter/CheckboxFilter.js +240 -0
  41. package/es/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  42. package/es/table-component/components/checkbox-filter/FilterSearch.js +36 -0
  43. package/es/table-component/components/command/Command.d.ts +9 -0
  44. package/es/table-component/components/command/Command.js +28 -0
  45. package/es/table-component/components/number/index.d.ts +10 -0
  46. package/es/table-component/components/number/index.js +42 -0
  47. package/es/table-component/components/number-range/index.d.ts +11 -0
  48. package/es/table-component/components/number-range/index.js +66 -0
  49. package/es/table-component/features/operator.d.ts +24 -0
  50. package/es/table-component/features/operator.js +62 -0
  51. package/es/table-component/footer/TableFooter.d.ts +13 -0
  52. package/es/table-component/footer/TableFooter.js +33 -0
  53. package/es/table-component/footer/TableFooterCell.d.ts +10 -0
  54. package/es/table-component/footer/TableFooterCell.js +24 -0
  55. package/es/table-component/footer/TableFooterRow.d.ts +14 -0
  56. package/es/table-component/footer/TableFooterRow.js +71 -0
  57. package/es/table-component/header/TableHead.d.ts +14 -0
  58. package/es/table-component/header/TableHead.js +60 -0
  59. package/es/table-component/header/TableHeadCell.d.ts +14 -0
  60. package/es/table-component/header/TableHeadCell.js +324 -0
  61. package/es/table-component/header/TableHeadRow.d.ts +16 -0
  62. package/es/table-component/header/TableHeadRow.js +86 -0
  63. package/es/table-component/header/renderFilter.d.ts +20 -0
  64. package/es/table-component/header/renderFilter.js +281 -0
  65. package/es/table-component/hook/constant.d.ts +73 -0
  66. package/es/table-component/hook/constant.js +240 -0
  67. package/es/table-component/hook/useColumns.d.ts +11 -0
  68. package/es/table-component/hook/useColumns.js +209 -0
  69. package/es/table-component/hook/useFilterOperator.d.ts +7 -0
  70. package/es/table-component/hook/useFilterOperator.js +33 -0
  71. package/es/table-component/hook/utils.d.ts +121 -0
  72. package/es/table-component/hook/utils.js +1727 -0
  73. package/es/table-component/index.d.ts +5 -0
  74. package/es/table-component/index.js +2 -0
  75. package/es/table-component/style.scss +1083 -0
  76. package/es/table-component/table/Grid.d.ts +23 -0
  77. package/es/table-component/table/Grid.js +310 -0
  78. package/es/table-component/table/GridEdit.d.ts +23 -0
  79. package/es/table-component/table/GridEdit.js +282 -0
  80. package/es/table-component/type.d.ts +482 -0
  81. package/es/table-component/type.js +1 -0
  82. package/es/table-component/useContext.d.ts +119 -0
  83. package/es/table-component/useContext.js +61 -0
  84. package/lib/index.d.ts +1 -0
  85. package/lib/index.js +8 -1
  86. package/lib/table-component/ColumnsChoose.d.ts +10 -0
  87. package/lib/table-component/ColumnsChoose.js +568 -0
  88. package/lib/table-component/ContextMenu.d.ts +20 -0
  89. package/lib/table-component/ContextMenu.js +85 -0
  90. package/lib/table-component/InternalTable.d.ts +9 -0
  91. package/lib/table-component/InternalTable.js +299 -0
  92. package/lib/table-component/TableContainer.d.ts +22 -0
  93. package/lib/table-component/TableContainer.js +137 -0
  94. package/lib/table-component/TableContainerEdit.d.ts +28 -0
  95. package/lib/table-component/TableContainerEdit.js +1220 -0
  96. package/lib/table-component/body/EditableCell.d.ts +16 -0
  97. package/lib/table-component/body/EditableCell.js +1038 -0
  98. package/lib/table-component/body/TableBody.d.ts +19 -0
  99. package/lib/table-component/body/TableBody.js +72 -0
  100. package/lib/table-component/body/TableBodyCell.d.ts +10 -0
  101. package/lib/table-component/body/TableBodyCell.js +148 -0
  102. package/lib/table-component/body/TableBodyCellEdit.d.ts +15 -0
  103. package/lib/table-component/body/TableBodyCellEdit.js +821 -0
  104. package/lib/table-component/body/TableBodyRow.d.ts +21 -0
  105. package/lib/table-component/body/TableBodyRow.js +153 -0
  106. package/lib/table-component/components/ControlCheckbox.d.ts +13 -0
  107. package/lib/table-component/components/ControlCheckbox.js +95 -0
  108. package/lib/table-component/components/EditForm/EditForm.d.ts +27 -0
  109. package/lib/table-component/components/EditForm/EditForm.js +406 -0
  110. package/lib/table-component/components/EditForm/index.d.ts +1 -0
  111. package/lib/table-component/components/EditForm/index.js +16 -0
  112. package/lib/table-component/components/InputControl/InputControl.d.ts +27 -0
  113. package/lib/table-component/components/InputControl/InputControl.js +131 -0
  114. package/lib/table-component/components/InputControl/index.d.ts +1 -0
  115. package/lib/table-component/components/InputControl/index.js +16 -0
  116. package/lib/table-component/components/async-select/index.d.ts +11 -0
  117. package/lib/table-component/components/async-select/index.js +49 -0
  118. package/lib/table-component/components/async-table-select/index.d.ts +11 -0
  119. package/lib/table-component/components/async-table-select/index.js +51 -0
  120. package/lib/table-component/components/checkbox-control/index.d.ts +13 -0
  121. package/lib/table-component/components/checkbox-control/index.js +48 -0
  122. package/lib/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  123. package/lib/table-component/components/checkbox-filter/CheckboxFilter.js +249 -0
  124. package/lib/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  125. package/lib/table-component/components/checkbox-filter/FilterSearch.js +44 -0
  126. package/lib/table-component/components/command/Command.d.ts +9 -0
  127. package/lib/table-component/components/command/Command.js +37 -0
  128. package/lib/table-component/components/number/index.d.ts +10 -0
  129. package/lib/table-component/components/number/index.js +50 -0
  130. package/lib/table-component/components/number-range/index.d.ts +11 -0
  131. package/lib/table-component/components/number-range/index.js +74 -0
  132. package/lib/table-component/features/operator.d.ts +24 -0
  133. package/lib/table-component/features/operator.js +67 -0
  134. package/lib/table-component/footer/TableFooter.d.ts +13 -0
  135. package/lib/table-component/footer/TableFooter.js +42 -0
  136. package/lib/table-component/footer/TableFooterCell.d.ts +10 -0
  137. package/lib/table-component/footer/TableFooterCell.js +32 -0
  138. package/lib/table-component/footer/TableFooterRow.d.ts +14 -0
  139. package/lib/table-component/footer/TableFooterRow.js +79 -0
  140. package/lib/table-component/header/TableHead.d.ts +14 -0
  141. package/lib/table-component/header/TableHead.js +69 -0
  142. package/lib/table-component/header/TableHeadCell.d.ts +14 -0
  143. package/lib/table-component/header/TableHeadCell.js +333 -0
  144. package/lib/table-component/header/TableHeadRow.d.ts +16 -0
  145. package/lib/table-component/header/TableHeadRow.js +94 -0
  146. package/lib/table-component/header/renderFilter.d.ts +20 -0
  147. package/lib/table-component/header/renderFilter.js +291 -0
  148. package/lib/table-component/hook/constant.d.ts +73 -0
  149. package/lib/table-component/hook/constant.js +247 -0
  150. package/lib/table-component/hook/useColumns.d.ts +11 -0
  151. package/lib/table-component/hook/useColumns.js +220 -0
  152. package/lib/table-component/hook/useFilterOperator.d.ts +7 -0
  153. package/lib/table-component/hook/useFilterOperator.js +40 -0
  154. package/lib/table-component/hook/utils.d.ts +121 -0
  155. package/lib/table-component/hook/utils.js +1817 -0
  156. package/lib/table-component/index.d.ts +5 -0
  157. package/lib/table-component/index.js +9 -0
  158. package/lib/table-component/style.scss +1083 -0
  159. package/lib/table-component/table/Grid.d.ts +23 -0
  160. package/lib/table-component/table/Grid.js +313 -0
  161. package/lib/table-component/table/GridEdit.d.ts +23 -0
  162. package/lib/table-component/table/GridEdit.js +284 -0
  163. package/lib/table-component/type.d.ts +482 -0
  164. package/lib/table-component/type.js +5 -0
  165. package/lib/table-component/useContext.d.ts +119 -0
  166. package/lib/table-component/useContext.js +67 -0
  167. package/package.json +3 -1
@@ -0,0 +1,482 @@
1
+ /// <reference types="date-fns" />
2
+ import type { CheckboxProps, TablePaginationConfig } from 'rc-master-ui';
3
+ import type { ItemType } from 'rc-master-ui/es/menu/interface';
4
+ import type { OnChangeFn } from '@tanstack/react-table';
5
+ import type { ReactElement, ReactNode } from 'react';
6
+ import type { IOperator } from './hook/constant';
7
+ import type { ColorPickerProps } from 'antd';
8
+ export type ExtendedColumnFilter = {
9
+ id: string;
10
+ value: string;
11
+ operator?: FilterOperator;
12
+ };
13
+ export type OpetorState = ColumnOperator[];
14
+ export interface OpetorTableState {
15
+ operator: OpetorState;
16
+ }
17
+ export interface ColumnOperator {
18
+ id: string;
19
+ operator: string;
20
+ }
21
+ export interface DensityOptions {
22
+ enableOperator?: boolean;
23
+ onOperatorChange?: OnChangeFn<OpetorState>;
24
+ }
25
+ export type Key = React.Key;
26
+ export type PaginationConfig = TablePaginationConfig & {
27
+ currentPage?: number;
28
+ };
29
+ export type AnyObject = Record<PropertyKey, any>;
30
+ export type IFormat = {
31
+ thousandSeparator?: string;
32
+ decimalSeparator?: string;
33
+ decimalScale?: number | undefined;
34
+ allowNegative?: boolean;
35
+ prefix?: string | undefined;
36
+ suffix?: string | undefined;
37
+ fixedDecimalScale?: boolean;
38
+ dateFormat?: string;
39
+ datetimeFormat?: string;
40
+ timeFormat?: string;
41
+ weekFormat?: string;
42
+ monthFormat?: string;
43
+ yearFormat?: string;
44
+ };
45
+ export type RowSelectMethod = 'all' | 'none' | 'invert' | 'single' | 'multiple';
46
+ export type EditType = 'text' | 'numeric' | 'asyncSelect' | 'date' | 'datetime' | 'time' | 'week' | 'month' | 'quarter' | 'year' | 'select' | 'checkbox' | 'currency' | 'image' | 'selectTable' | 'customSelect' | 'form' | 'color' | 'treeSelect' | 'file';
47
+ export type ITextAlign = 'center' | 'left' | 'right';
48
+ export type TypeFilter = 'Text' | 'Date' | 'Time' | 'Datetime' | 'DateRange' | 'Month' | 'Quarter' | 'Year' | 'Week' | 'Number' | 'NumberRange' | 'Dropdown' | 'DropTree' | 'Checkbox' | 'CheckboxTree' | 'CheckboxDropdown';
49
+ export type IColumnType = 'number' | 'time' | 'date' | 'week' | 'month' | 'file' | 'quarter' | 'year' | 'datetime' | 'string' | 'boolean' | 'checkbox' | 'color' | null | undefined;
50
+ export type FilterOperator = 'equal' | 'notEqual' | 'greaterThan' | 'greaterThanOrEqual' | 'lessThan' | 'lessThanOrEqual' | 'startsWith' | 'endsWith' | 'contains';
51
+ export type FixedType = 'left' | 'right' | boolean;
52
+ export type SelectMode = 'checkbox' | 'radio' | undefined;
53
+ type IGrid = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24;
54
+ export interface FieldNames {
55
+ value?: string;
56
+ label?: string;
57
+ groupLabel?: string;
58
+ options?: string;
59
+ }
60
+ export interface CommandItem {
61
+ id: string;
62
+ type?: string;
63
+ visible?: boolean | ((record: any) => boolean);
64
+ title: string;
65
+ color?: 'blue' | 'purple' | 'cyan' | 'green' | 'magenta' | 'pink' | 'red' | 'orange' | 'yellow' | 'volcano' | 'geekblue' | 'lime' | 'gold';
66
+ tooltip?: string;
67
+ icon?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
68
+ template?: ReactNode | ReactElement | ((record: any) => ReactNode | ReactElement);
69
+ client?: boolean;
70
+ confirmDialog?: boolean;
71
+ }
72
+ export type ColumnTemplate<RecordType> = {
73
+ value: any;
74
+ rowData: RecordType;
75
+ index: number;
76
+ field: string;
77
+ };
78
+ export type ColumnTable<RecordType = AnyObject> = {
79
+ field?: string;
80
+ width?: number;
81
+ maxWidth?: number;
82
+ minWidth?: number;
83
+ align?: ITextAlign;
84
+ type?: IColumnType;
85
+ haveSum?: boolean;
86
+ isSummary?: boolean;
87
+ summaryTemplate?: (data: number, key: string) => ReactElement | ReactNode;
88
+ format?: IFormat | ((rowData: any) => IFormat);
89
+ allowFiltering?: boolean;
90
+ /**
91
+ * @deprecated Please use `allowSorter` instead.
92
+ * @since 1.0.0
93
+ */
94
+ sorter?: boolean;
95
+ allowSorter?: boolean;
96
+ operator?: FilterOperator;
97
+ hideOperator?: boolean;
98
+ placeholder?: string;
99
+ showInColumnChoose?: boolean;
100
+ typeFilter?: TypeFilter;
101
+ source?: any[];
102
+ showFilterSearch?: boolean;
103
+ headerText?: string;
104
+ visible?: boolean;
105
+ headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
106
+ columnGroupText?: string;
107
+ textAlign?: ITextAlign;
108
+ headerTextAlign?: ITextAlign;
109
+ template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
110
+ showTooltip?: boolean;
111
+ tooltipDescription?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
112
+ headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnTable<RecordType>) => React.ReactNode | React.ReactElement);
113
+ commandItems?: CommandItem[];
114
+ children?: ColumnTable<RecordType>[];
115
+ editType?: EditType | ((rowData?: RecordType) => EditType);
116
+ disable?: boolean | ((rowData: any) => boolean);
117
+ editEnable?: boolean | ((rowData: any) => boolean);
118
+ isClearable?: boolean;
119
+ maxDate?: any;
120
+ minDate?: any;
121
+ maxTime?: any;
122
+ minTime?: any;
123
+ max?: number;
124
+ min?: number;
125
+ editSelectSettings?: IEditSelectSettings;
126
+ editFromSettings?: IEditFromSettings;
127
+ /**
128
+ * @deprecated Please use `fixed` instead.
129
+ * @since 1.6.5
130
+ */
131
+ fixedType?: FixedType;
132
+ fixed?: FixedType;
133
+ headerTextWrap?: boolean;
134
+ ellipsis?: boolean;
135
+ allowResizing?: boolean;
136
+ };
137
+ export type ColumnsTable<RecordType = AnyObject> = ColumnTable<RecordType>[];
138
+ export type TableProps<RecordType = AnyObject> = {
139
+ editAble?: boolean;
140
+ infiniteScroll?: boolean;
141
+ next?: () => void;
142
+ locale?: Locale;
143
+ groupAble?: boolean;
144
+ groupColumns?: string[];
145
+ groupSetting?: IGroupSetting;
146
+ onChooseColumns?: (props: IOnChooseColumns) => void;
147
+ pagination?: false | PaginationConfig;
148
+ showCustomTooltip?: boolean;
149
+ sortMultiple?: boolean;
150
+ dataSource: RecordType[];
151
+ columns: ColumnsTable<RecordType>;
152
+ height?: number;
153
+ format?: IFormat;
154
+ t?: any;
155
+ lang?: string;
156
+ contextMenuItems?: ContextMenuItem[];
157
+ showDefaultContext?: boolean;
158
+ contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<RecordType>, 'item' | 'event'>) => string[]);
159
+ contextMenuOpen?: (args: Omit<ContextInfo<RecordType>, 'item'>) => void;
160
+ contextMenuClick?: (args: ContextInfo<RecordType>) => void;
161
+ recordDoubleClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
162
+ toolbarItems?: ToolbarItem[];
163
+ showColumnChoose?: boolean;
164
+ showAdvanceFilter?: boolean;
165
+ onFilter?: (query: {
166
+ field: string;
167
+ key: string;
168
+ operator: IOperator;
169
+ predicate: 'and' | 'or';
170
+ value: any;
171
+ }[]) => void;
172
+ onSorter?: (args: Sorter[]) => void;
173
+ selectionSettings?: SelectionSettings;
174
+ rowSelection?: RowSelection<RecordType>;
175
+ rowSelected?: (args: {
176
+ type: string;
177
+ rowData: RecordType;
178
+ selected: RecordType | RecordType[];
179
+ }) => void;
180
+ dataSourceFilter?: SourceFilter[];
181
+ onFilterClick?: (column: ColumnTable<RecordType>, callback: (key: string, data: any) => void) => void;
182
+ loading?: boolean;
183
+ allowResizing?: boolean;
184
+ showToolbar?: boolean;
185
+ onDataChange?: (data: RecordType[]) => void;
186
+ defaultValue?: AnyObject | (() => AnyObject);
187
+ summary?: boolean | ((data: readonly RecordType[]) => React.ReactNode);
188
+ showEmptyText?: boolean;
189
+ commandSettings?: CommandSettings;
190
+ onCellPaste?: ICellPasteModel<RecordType>;
191
+ onCellChange?: (args: CellChangeArgs<RecordType>, handleCallback: (rowData: any, index: any, value?: any) => void) => void;
192
+ onCellClick?: (args: ICellClick, callback?: any) => void;
193
+ rowEditable?: (rowData: RecordType) => boolean;
194
+ validate?: any;
195
+ onBlur?: (data: RecordType[]) => void;
196
+ onExpandClick?: (args: {
197
+ expandedKeys: string[];
198
+ key: string;
199
+ rowData: any;
200
+ }) => void;
201
+ wrapSettings?: IWrapSettings;
202
+ actionTemplate?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
203
+ commandClick?: (args: CommandClick) => void;
204
+ expandable?: ExpandableConfig<RecordType>;
205
+ fullScreen?: boolean;
206
+ };
207
+ export type ExpandableConfig<RecordType> = {
208
+ expandedRowKeys?: readonly Key[];
209
+ defaultExpandedRowKeys?: readonly Key[];
210
+ expandedRowRender?: ExpandedRowRender<RecordType>;
211
+ columnTitle?: React.ReactNode;
212
+ expandRowByClick?: boolean;
213
+ expandIcon?: RenderExpandIcon<RecordType>;
214
+ onExpand?: (expanded: boolean, record: RecordType) => void;
215
+ onExpandedRowsChange?: (expandedKeys: readonly Key[]) => void;
216
+ defaultExpandAllRows?: boolean;
217
+ indentSize?: number;
218
+ expandIconColumnIndex?: number;
219
+ showExpandColumn?: boolean;
220
+ expandedRowClassName?: string | RowClassName<RecordType>;
221
+ childrenColumnName?: string;
222
+ rowExpandable?: (record: RecordType) => boolean;
223
+ columnWidth?: number | string;
224
+ fixed?: FixedType;
225
+ };
226
+ export type RenderExpandIcon<RecordType> = (props: RenderExpandIconProps<RecordType>) => React.ReactNode;
227
+ export interface RenderExpandIconProps<RecordType> {
228
+ prefixCls: string;
229
+ expanded: boolean;
230
+ record: RecordType;
231
+ expandable: boolean;
232
+ onExpand: TriggerEventHandler<RecordType>;
233
+ }
234
+ export type TriggerEventHandler<RecordType> = (record: RecordType, event: React.MouseEvent<HTMLElement>) => void;
235
+ export type RowClassName<RecordType> = (record: RecordType, index: number, indent: number) => string;
236
+ export type ExpandedRowRender<ValueType> = (record: ValueType, index: number, indent: number, expanded: boolean) => React.ReactNode;
237
+ export type CommandClick = {
238
+ id: string;
239
+ rowId: string;
240
+ rowData: any;
241
+ index: number;
242
+ rows?: any[];
243
+ };
244
+ export type IEditSelectSettings = {
245
+ fieldKey?: string;
246
+ options: any[] | ((rowData: any, field: string) => any[]);
247
+ /** get value form other field **/
248
+ fieldValue?: string;
249
+ /** get label form other field **/
250
+ fieldLabel?: string;
251
+ /** cho phép nhập giá trị - onBlur: giá trị search được set thành value **/
252
+ searchTextAsValue?: boolean;
253
+ inputKey?: string;
254
+ filterKey?: string[];
255
+ selectMode?: SelectMode;
256
+ getPasteValue?: (value: any) => Record<string, any> | null;
257
+ validateOption?: (rowData: any, field: string) => any[];
258
+ defaultOptions?: any[];
259
+ defaultValue?: (value: any, rowData: any) => {
260
+ value: any;
261
+ label: string;
262
+ [key: string]: string;
263
+ } | null;
264
+ formatOptionLabel?: (option: any) => ReactNode | ReactElement;
265
+ loadOptions?: (search: string, callback: (newOptions: any[]) => void, args?: LoadOptionsArgs) => void;
266
+ isMulti?: boolean;
267
+ closeMenuOnSelect?: boolean;
268
+ menuWidth?: number;
269
+ menuHeight?: number;
270
+ columns?: ColumnSelectTable[];
271
+ toolbarItems?: ToolbarItem[];
272
+ toolbarClick?: (props: ToolbarClick) => void;
273
+ toolbarHeight?: number;
274
+ hideSelectedOptions?: boolean;
275
+ showItems?: number;
276
+ isLengthSelected?: boolean;
277
+ fieldNames?: FieldNames;
278
+ filterOption?: boolean | FilterFunc<any>;
279
+ };
280
+ export type IEditFromSettings = {
281
+ fieldKey: string;
282
+ formOpen?: (props: IFormOpen) => void;
283
+ formClose?: (props: IFormOpen) => void;
284
+ formatLabel?: (value: any) => string;
285
+ menuWidth?: number;
286
+ menuHeight?: number;
287
+ labelWith?: number;
288
+ items: any[];
289
+ layout?: {
290
+ xl?: IGrid;
291
+ lg?: IGrid;
292
+ md?: IGrid;
293
+ sm?: IGrid;
294
+ xs?: IGrid;
295
+ };
296
+ defaultValues?: Record<string, any>;
297
+ schema?: any;
298
+ };
299
+ export type IFormOpen = {
300
+ value?: any;
301
+ setValue?: any;
302
+ getValues?: any;
303
+ reset?: any;
304
+ rowData?: any;
305
+ };
306
+ export type FilterFunc<OptionType> = (inputValue: string, option?: OptionType) => boolean;
307
+ export type ToolbarClick = {
308
+ item: any;
309
+ column: any;
310
+ };
311
+ export type ColumnSelectTable = {
312
+ field: string;
313
+ dataIndex?: string;
314
+ type?: IColumnType;
315
+ headerText?: string;
316
+ fixedType?: 'left' | 'right' | undefined;
317
+ width?: number | undefined;
318
+ minWidth?: number;
319
+ maxWidth?: number;
320
+ visible?: boolean;
321
+ textAlign?: ITextAlign;
322
+ headerTextAlign?: ITextAlign;
323
+ template?: (props: ITemplateColumn) => ReactNode | ReactElement;
324
+ headerTemplate?: any;
325
+ ellipsis?: boolean | undefined;
326
+ format?: IFormat;
327
+ tooltipDescription?: string | ((rowData: any) => string | ReactNode);
328
+ showTooltip?: boolean;
329
+ showTooltipHeader?: boolean;
330
+ };
331
+ export type ITemplateColumn = {
332
+ value: any;
333
+ column: any;
334
+ rowData: any;
335
+ field: number | string;
336
+ index: number;
337
+ };
338
+ export type RawValueType = string | number;
339
+ export type ToolbarItem = {
340
+ position?: 'Top' | 'Bottom';
341
+ align?: ITextAlign;
342
+ onClick?: (args: any) => void;
343
+ key?: React.Key;
344
+ value?: RawValueType;
345
+ label?: React.ReactNode;
346
+ template?: React.ReactNode | React.ReactElement | (() => React.ReactNode | React.ReactElement);
347
+ title?: React.ReactNode;
348
+ disabled?: boolean;
349
+ [key: string]: any;
350
+ };
351
+ export type LoadOptionsArgs = {
352
+ rowData?: any;
353
+ };
354
+ export type IGroupSetting = {
355
+ client?: boolean;
356
+ onGroup?: (props: IOnGroup) => void;
357
+ hiddenColumnGroup?: boolean;
358
+ showGroupIcon?: boolean;
359
+ unClearableLevel?: 1 | 2 | 3 | undefined;
360
+ sumGroup?: boolean;
361
+ };
362
+ type IOnGroup = {
363
+ columnGrouped: string[];
364
+ columns: ColumnsTable;
365
+ flattenColumns: ColumnsTable;
366
+ };
367
+ export type IOnChooseColumns = {
368
+ columns: ColumnsTable;
369
+ showColumns: ColumnsTable;
370
+ flattenColumns: ColumnsTable;
371
+ };
372
+ export type ContextMenuItem = ItemType;
373
+ export type CommandSettings = {
374
+ client?: boolean;
375
+ confirmDialog?: boolean;
376
+ };
377
+ export interface ICellPasteModel<RecordType = AnyObject> {
378
+ onPasted?: (args: IOnPastedProps, handleCallback: (callbackData: any[]) => void) => void;
379
+ dataChange?: (data: RecordType[]) => void;
380
+ getCallbackData?: (props: any) => void;
381
+ maxRowsPaste?: number;
382
+ }
383
+ export type IOnPastedProps = {
384
+ data: any[];
385
+ copyRows: any[];
386
+ pastedColumns: string[];
387
+ pasteData: any[];
388
+ type: 'onPaste' | 'onChange' | 'onCellPaste';
389
+ };
390
+ export type ICellClick = {
391
+ index: number;
392
+ indexCol?: number;
393
+ rowId: string | number;
394
+ type: 'Editing' | 'Default';
395
+ field: string;
396
+ cellValue: any;
397
+ rowData: any;
398
+ };
399
+ export type CellChangeArgs<T> = {
400
+ type: 'onPaste' | 'onChange' | 'onCellPaste';
401
+ value: any;
402
+ option: AnyObject;
403
+ rowData: T;
404
+ rowsData: T[];
405
+ indexRow: number;
406
+ rowId?: string;
407
+ field: string | undefined;
408
+ indexCol: any;
409
+ sumValue?: any[];
410
+ };
411
+ export type IWrapMode = 'Header' | 'Both' | 'Content';
412
+ export type IWrapSettings = {
413
+ wrapMode?: IWrapMode;
414
+ };
415
+ export type SelectionSettings<T = AnyObject> = {
416
+ mode?: 'checkbox' | 'radio';
417
+ type?: 'single' | 'multiple';
418
+ checkboxOnly?: boolean;
419
+ columnWidth?: number;
420
+ hideSelectAll?: boolean;
421
+ selectedRowKeys?: Key[];
422
+ defaultSelectedRowKeys?: Key[];
423
+ getCheckboxProps?: (record: T) => Partial<Omit<CheckboxProps, 'checked' | 'defaultChecked'>>;
424
+ };
425
+ export type SelectionSelectFn<T = AnyObject> = (record: T, selected: boolean, selectedRows: T[], nativeEvent: Event) => void;
426
+ export type RowSelection<T> = {
427
+ preserveSelectedRowKeys?: boolean;
428
+ selectedRowKeys?: Key[];
429
+ defaultSelectedRowKeys?: Key[];
430
+ onChange?: (selectedRowKeys: Key[], selectedRows: T[], info: {
431
+ type: RowSelectMethod;
432
+ }, selectedRow: T) => void;
433
+ getCheckboxProps?: (record: T) => Partial<Omit<CheckboxProps, 'checked' | 'defaultChecked'>>;
434
+ onSelect?: SelectionSelectFn<T>;
435
+ /** @deprecated This function is deprecated and should use `onChange` instead */
436
+ onSelectMultiple?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
437
+ /** @deprecated This function is deprecated and should use `onChange` instead */
438
+ onSelectAll?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
439
+ /** @deprecated This function is deprecated and should use `onChange` instead */
440
+ onSelectInvert?: (selectedRowKeys: Key[]) => void;
441
+ /** @deprecated This function is deprecated and should use `onChange` instead */
442
+ onSelectNone?: () => void;
443
+ fixed?: FixedType;
444
+ columnTitle?: React.ReactNode | ((checkboxNode: React.ReactNode) => React.ReactNode);
445
+ checkStrictly?: boolean;
446
+ checkboxOnly?: boolean;
447
+ arrowKey?: boolean;
448
+ };
449
+ export type RecordDoubleClickEventArgs<RecordType> = {
450
+ rowData: RecordType;
451
+ rowIndex: number | undefined;
452
+ e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>;
453
+ };
454
+ export type SourceFilter = {
455
+ key: string;
456
+ data: any[];
457
+ loadOptions?: (search: string, callback: (newOptions: any[]) => void) => void;
458
+ };
459
+ export type ContextInfo<RecordType> = {
460
+ rowInfo: {
461
+ rowData: RecordType | null;
462
+ };
463
+ event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>;
464
+ item: ItemType;
465
+ };
466
+ export type Presets = Required<ColorPickerProps>['presets'][number];
467
+ export type RangeState = {
468
+ rowRange: string[];
469
+ colRange: string[];
470
+ startRowIndex: number | undefined;
471
+ endRowIndex: number | undefined;
472
+ startColIndex: number | undefined;
473
+ endColIndex: number | undefined;
474
+ rowIds: string[];
475
+ colIds: string[];
476
+ };
477
+ export type Sorter = {
478
+ columnKey: string;
479
+ field: string;
480
+ order: 'ascend' | 'descend';
481
+ };
482
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,119 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ import type { ExpandableConfig, IFormat, IWrapSettings, RangeState, RecordDoubleClickEventArgs, SelectionSettings } from "./type";
3
+ import type { SubmitHandler } from "react-hook-form";
4
+ export type IPositionCell = {
5
+ rowId: string;
6
+ colId: string;
7
+ } | undefined;
8
+ export interface IContext<T> {
9
+ prefix: string;
10
+ id: string;
11
+ rowKey: string;
12
+ originData: any[];
13
+ dataSource: any[];
14
+ format?: IFormat;
15
+ expandable?: ExpandableConfig<T>;
16
+ wrapSettings?: IWrapSettings;
17
+ recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
18
+ selectionSettings?: SelectionSettings;
19
+ setIsSelectionChange: Dispatch<SetStateAction<{
20
+ isChange: boolean;
21
+ type: string;
22
+ rowData: T;
23
+ }>>;
24
+ setSorterChange: Dispatch<SetStateAction<boolean>>;
25
+ setFilterChange: Dispatch<SetStateAction<boolean>>;
26
+ onContextMenu?: (data: T) => (event: any) => void;
27
+ control?: any;
28
+ errors?: any;
29
+ handleSubmit?: any;
30
+ onSubmit?: SubmitHandler<any>;
31
+ getValues?: any;
32
+ reset?: any;
33
+ setValue?: any;
34
+ handleCellChange?: (args: ContextCellChange) => void;
35
+ editingKey?: string;
36
+ setEditingKey?: Dispatch<SetStateAction<string>>;
37
+ rangeState?: RangeState;
38
+ setRangeState?: Dispatch<SetStateAction<RangeState | undefined>>;
39
+ rangePasteState?: RangeState;
40
+ setRangePasteState?: Dispatch<SetStateAction<RangeState | undefined>>;
41
+ startCell?: IPositionCell;
42
+ setStartCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
43
+ endCell?: IPositionCell;
44
+ setEndCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
45
+ startPasteCell?: IPositionCell;
46
+ setStartPasteCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
47
+ endPasteCell?: IPositionCell;
48
+ setEndPasteCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
49
+ isSelecting?: boolean;
50
+ setIsSelecting?: Dispatch<SetStateAction<boolean>>;
51
+ isPasting?: boolean;
52
+ setIsPasting?: Dispatch<SetStateAction<boolean>>;
53
+ focusedCell?: IPositionCell;
54
+ setFocusedCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
55
+ triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
56
+ handleDeleteContent?: () => void;
57
+ handleAddMulti?: (item: any, n: number, id?: string) => void;
58
+ }
59
+ export interface IContextEdit<T> {
60
+ prefix: string;
61
+ searchValue?: any;
62
+ setSearchValue?: any;
63
+ open?: boolean;
64
+ setOpen?: any;
65
+ rowKey: string;
66
+ onSave?: any;
67
+ format?: IFormat;
68
+ control?: any;
69
+ errors?: any;
70
+ trigger?: any;
71
+ handleSubmit?: any;
72
+ onSubmit?: SubmitHandler<any>;
73
+ getValues?: any;
74
+ reset?: any;
75
+ setValue?: any;
76
+ handleCellChange?: (args: ContextCellChange) => void;
77
+ id: string;
78
+ startCell: IPositionCell;
79
+ setStartCell: Dispatch<SetStateAction<IPositionCell>>;
80
+ endCell: IPositionCell;
81
+ setEndCell: Dispatch<SetStateAction<IPositionCell>>;
82
+ startPasteCell: IPositionCell;
83
+ setStartPasteCell: Dispatch<SetStateAction<IPositionCell>>;
84
+ endPasteCell: IPositionCell;
85
+ setEndPasteCell: Dispatch<SetStateAction<IPositionCell>>;
86
+ isSelecting: boolean;
87
+ setIsSelecting: Dispatch<SetStateAction<boolean>>;
88
+ isPasting: boolean;
89
+ setIsPasting: Dispatch<SetStateAction<boolean>>;
90
+ editingKey: string;
91
+ setEditingKey: Dispatch<SetStateAction<string>>;
92
+ focusedCell: IPositionCell;
93
+ setFocusedCell: Dispatch<SetStateAction<IPositionCell>>;
94
+ rangeState: RangeState;
95
+ setRangeState: Dispatch<SetStateAction<RangeState>>;
96
+ rangePasteState: RangeState;
97
+ setRangePasteState: Dispatch<SetStateAction<RangeState>>;
98
+ originData: any[];
99
+ dataSource: any[];
100
+ triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
101
+ expandable?: ExpandableConfig<T>;
102
+ handleDeleteContent: () => void;
103
+ wrapSettings?: IWrapSettings;
104
+ handleAddMulti: (item: any, n: number, id?: string) => void;
105
+ recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
106
+ }
107
+ export declare const TableContext: import("react").Context<IContext<any>>;
108
+ export declare const TableContextEdit: import("react").Context<IContextEdit<any>>;
109
+ export type ContextCellChange = {
110
+ key: string;
111
+ record: any;
112
+ field: string | undefined;
113
+ option: any;
114
+ indexRow: number;
115
+ indexCol: number;
116
+ newState?: any;
117
+ prevState?: any;
118
+ type: 'enter' | 'blur' | 'outClick';
119
+ };
@@ -0,0 +1,61 @@
1
+ import { createContext } from 'react';
2
+ export const TableContext = /*#__PURE__*/createContext({
3
+ prefix: 'ui-rc',
4
+ id: '',
5
+ rowKey: 'rowId',
6
+ dataSource: [],
7
+ originData: [],
8
+ // triggerFilter: () => { },
9
+
10
+ setIsSelectionChange: () => {},
11
+ setSorterChange: () => {},
12
+ setFilterChange: () => {}
13
+ });
14
+ export const TableContextEdit = /*#__PURE__*/createContext({
15
+ prefix: 'ui-rc',
16
+ rowKey: 'rowId',
17
+ id: '',
18
+ dataSource: [],
19
+ originData: [],
20
+ focusedCell: undefined,
21
+ startCell: undefined,
22
+ endCell: undefined,
23
+ isSelecting: false,
24
+ isPasting: false,
25
+ startPasteCell: undefined,
26
+ endPasteCell: undefined,
27
+ editingKey: '',
28
+ rangeState: {
29
+ startRowIndex: undefined,
30
+ endRowIndex: undefined,
31
+ startColIndex: undefined,
32
+ endColIndex: undefined,
33
+ rowIds: [],
34
+ colIds: [],
35
+ colRange: [],
36
+ rowRange: []
37
+ },
38
+ rangePasteState: {
39
+ startRowIndex: undefined,
40
+ endRowIndex: undefined,
41
+ startColIndex: undefined,
42
+ endColIndex: undefined,
43
+ rowIds: [],
44
+ colIds: [],
45
+ colRange: [],
46
+ rowRange: []
47
+ },
48
+ setEditingKey: () => {},
49
+ setStartCell: () => {},
50
+ setIsSelecting: () => {},
51
+ setEndCell: () => {},
52
+ setFocusedCell: () => {},
53
+ setRangeState: () => {},
54
+ setRangePasteState: () => {},
55
+ setIsPasting: () => {},
56
+ setEndPasteCell: () => {},
57
+ setStartPasteCell: () => {},
58
+ handleDeleteContent: () => {},
59
+ // triggerFilter: () => { },
60
+ handleAddMulti: () => {}
61
+ });
package/lib/index.d.ts CHANGED
@@ -16,3 +16,4 @@ export { default as Splitter } from './splitter';
16
16
  export type { SplitterProps } from './splitter';
17
17
  export { default as Collapse } from './collapse';
18
18
  export type { CollapsePanelProps, CollapseProps } from './collapse';
19
+ export { default as TableComponent } from './table-component';
package/lib/index.js CHANGED
@@ -52,6 +52,12 @@ Object.defineProperty(exports, "Splitter", {
52
52
  return _splitter.default;
53
53
  }
54
54
  });
55
+ Object.defineProperty(exports, "TableComponent", {
56
+ enumerable: true,
57
+ get: function () {
58
+ return _tableComponent.default;
59
+ }
60
+ });
55
61
  Object.defineProperty(exports, "Tabs", {
56
62
  enumerable: true,
57
63
  get: function () {
@@ -66,4 +72,5 @@ var _select = _interopRequireDefault(require("./select"));
66
72
  var _dateRangePicker = _interopRequireDefault(require("./date-range-picker"));
67
73
  var _datepicker = _interopRequireDefault(require("./datepicker"));
68
74
  var _splitter = _interopRequireDefault(require("./splitter"));
69
- var _collapse = _interopRequireDefault(require("./collapse"));
75
+ var _collapse = _interopRequireDefault(require("./collapse"));
76
+ var _tableComponent = _interopRequireDefault(require("./table-component"));