es-grid-template 1.8.70 → 1.8.72

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 (239) hide show
  1. package/es/grid-component/TempTable.js +2 -1
  2. package/es/group-component/ColumnsChoose.d.ts +13 -0
  3. package/es/group-component/ColumnsChoose.js +211 -0
  4. package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  5. package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
  6. package/es/group-component/ColumnsGroup/index.d.ts +1 -0
  7. package/es/group-component/ColumnsGroup/index.js +1 -0
  8. package/es/group-component/ContextMenu.d.ts +19 -0
  9. package/es/group-component/ContextMenu.js +74 -0
  10. package/es/group-component/InternalTable.d.ts +8 -0
  11. package/es/group-component/InternalTable.js +224 -0
  12. package/es/group-component/TableContainer.d.ts +49 -0
  13. package/es/group-component/TableContainer.js +375 -0
  14. package/es/group-component/TableContainerEdit.d.ts +48 -0
  15. package/es/group-component/TableContainerEdit.js +2068 -0
  16. package/es/group-component/body/EditableCell.d.ts +16 -0
  17. package/es/group-component/body/EditableCell.js +1066 -0
  18. package/es/group-component/body/TableBody.d.ts +14 -0
  19. package/es/group-component/body/TableBody.js +82 -0
  20. package/es/group-component/body/TableBodyCell.d.ts +12 -0
  21. package/es/group-component/body/TableBodyCell.js +587 -0
  22. package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
  23. package/es/group-component/body/TableBodyCellEdit.js +1398 -0
  24. package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  25. package/es/group-component/body/TableBodyCellEmpty.js +149 -0
  26. package/es/group-component/body/TableBodyRow.d.ts +21 -0
  27. package/es/group-component/body/TableBodyRow.js +199 -0
  28. package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  29. package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
  30. package/es/group-component/components/ControlCheckbox.d.ts +13 -0
  31. package/es/group-component/components/ControlCheckbox.js +84 -0
  32. package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
  33. package/es/group-component/components/EditForm/EditForm.js +394 -0
  34. package/es/group-component/components/EditForm/index.d.ts +1 -0
  35. package/es/group-component/components/EditForm/index.js +1 -0
  36. package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
  37. package/es/group-component/components/InputControl/InputControl.js +118 -0
  38. package/es/group-component/components/InputControl/index.d.ts +1 -0
  39. package/es/group-component/components/InputControl/index.js +1 -0
  40. package/es/group-component/components/async-select/index.d.ts +11 -0
  41. package/es/group-component/components/async-select/index.js +38 -0
  42. package/es/group-component/components/async-table-select/index.d.ts +11 -0
  43. package/es/group-component/components/async-table-select/index.js +40 -0
  44. package/es/group-component/components/checkbox-control/index.d.ts +13 -0
  45. package/es/group-component/components/checkbox-control/index.js +40 -0
  46. package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  47. package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
  48. package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  49. package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
  50. package/es/group-component/components/command/Command.d.ts +10 -0
  51. package/es/group-component/components/command/Command.js +35 -0
  52. package/es/group-component/components/number/index.d.ts +12 -0
  53. package/es/group-component/components/number/index.js +42 -0
  54. package/es/group-component/components/number-range/index.d.ts +13 -0
  55. package/es/group-component/components/number-range/index.js +79 -0
  56. package/es/group-component/features/operator.d.ts +24 -0
  57. package/es/group-component/features/operator.js +62 -0
  58. package/es/group-component/footer/TableFooter.d.ts +7 -0
  59. package/es/group-component/footer/TableFooter.js +34 -0
  60. package/es/group-component/footer/TableFooterCell.d.ts +7 -0
  61. package/es/group-component/footer/TableFooterCell.js +66 -0
  62. package/es/group-component/footer/TableFooterRow.d.ts +8 -0
  63. package/es/group-component/footer/TableFooterRow.js +30 -0
  64. package/es/group-component/header/TableHead.d.ts +15 -0
  65. package/es/group-component/header/TableHead.js +98 -0
  66. package/es/group-component/header/TableHeadCell.d.ts +15 -0
  67. package/es/group-component/header/TableHeadCell.js +310 -0
  68. package/es/group-component/header/TableHeadCell2.d.ts +17 -0
  69. package/es/group-component/header/TableHeadCell2.js +321 -0
  70. package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
  71. package/es/group-component/header/TableHeadGroupCell.js +94 -0
  72. package/es/group-component/header/TableHeadRow.d.ts +15 -0
  73. package/es/group-component/header/TableHeadRow.js +52 -0
  74. package/es/group-component/header/renderFilter.d.ts +20 -0
  75. package/es/group-component/header/renderFilter.js +291 -0
  76. package/es/group-component/hook/convert.d.ts +1 -0
  77. package/es/group-component/hook/convert.js +28 -0
  78. package/es/group-component/hook/useColumns.d.ts +28 -0
  79. package/es/group-component/hook/useColumns.js +306 -0
  80. package/es/group-component/hook/useFilterOperator.d.ts +7 -0
  81. package/es/group-component/hook/useFilterOperator.js +33 -0
  82. package/es/group-component/hook/utils.d.ts +220 -0
  83. package/es/group-component/hook/utils.js +2340 -0
  84. package/es/group-component/index.d.ts +2 -0
  85. package/es/group-component/index.js +2 -0
  86. package/es/group-component/style.d.ts +22 -0
  87. package/es/group-component/style.js +48 -0
  88. package/es/group-component/style.scss +1438 -0
  89. package/es/group-component/table/Grid.d.ts +33 -0
  90. package/es/group-component/table/Grid.js +438 -0
  91. package/es/group-component/table/TableWrapper.d.ts +33 -0
  92. package/es/group-component/table/TableWrapper.js +250 -0
  93. package/es/group-component/useContext.d.ts +100 -0
  94. package/es/group-component/useContext.js +21 -0
  95. package/es/table-component/InternalTable.js +6 -1
  96. package/es/table-component/TableContainer.js +4 -2
  97. package/es/table-component/TableContainerEdit.js +2 -2
  98. package/es/table-component/body/TableBodyCell.js +49 -40
  99. package/es/table-component/body/TableBodyCellEdit.js +9 -3
  100. package/es/table-component/body/TableBodyRow.js +4 -1
  101. package/es/table-component/hook/utils.d.ts +1 -0
  102. package/es/table-component/hook/utils.js +15 -7
  103. package/es/table-component/style.js +1 -1
  104. package/es/table-component/table/Grid.js +3 -0
  105. package/es/table-component/useContext.d.ts +5 -0
  106. package/es/table-virtuoso/InternalTable.js +2 -2
  107. package/es/table-virtuoso/body/TableBodyCell.js +2 -7
  108. package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  109. package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
  110. package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  111. package/es/table-virtuoso/body/TableBodyRow.js +43 -1
  112. package/es/table-virtuoso/hook/utils.d.ts +1 -0
  113. package/es/table-virtuoso/hook/utils.js +29 -0
  114. package/es/table-virtuoso/style.js +3 -1
  115. package/es/table-virtuoso/table/Grid.js +2 -2
  116. package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
  117. package/es/table-virtuoso/table/TableWrapper.js +24 -5
  118. package/es/table-virtuoso/useContext.d.ts +6 -3
  119. package/es/table-virtuoso/useContext.js +18 -0
  120. package/lib/grid-component/TempTable.js +2 -1
  121. package/lib/group-component/ColumnsChoose.d.ts +13 -0
  122. package/lib/group-component/ColumnsChoose.js +221 -0
  123. package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  124. package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
  125. package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
  126. package/lib/group-component/ColumnsGroup/index.js +16 -0
  127. package/lib/group-component/ContextMenu.d.ts +19 -0
  128. package/lib/group-component/ContextMenu.js +83 -0
  129. package/lib/group-component/InternalTable.d.ts +8 -0
  130. package/lib/group-component/InternalTable.js +233 -0
  131. package/lib/group-component/TableContainer.d.ts +49 -0
  132. package/lib/group-component/TableContainer.js +382 -0
  133. package/lib/group-component/TableContainerEdit.d.ts +48 -0
  134. package/lib/group-component/TableContainerEdit.js +2075 -0
  135. package/lib/group-component/body/EditableCell.d.ts +16 -0
  136. package/lib/group-component/body/EditableCell.js +1075 -0
  137. package/lib/group-component/body/TableBody.d.ts +14 -0
  138. package/lib/group-component/body/TableBody.js +91 -0
  139. package/lib/group-component/body/TableBodyCell.d.ts +12 -0
  140. package/lib/group-component/body/TableBodyCell.js +595 -0
  141. package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
  142. package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
  143. package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  144. package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
  145. package/lib/group-component/body/TableBodyRow.d.ts +21 -0
  146. package/lib/group-component/body/TableBodyRow.js +206 -0
  147. package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  148. package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
  149. package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
  150. package/lib/group-component/components/ControlCheckbox.js +92 -0
  151. package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
  152. package/lib/group-component/components/EditForm/EditForm.js +404 -0
  153. package/lib/group-component/components/EditForm/index.d.ts +1 -0
  154. package/lib/group-component/components/EditForm/index.js +16 -0
  155. package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
  156. package/lib/group-component/components/InputControl/InputControl.js +127 -0
  157. package/lib/group-component/components/InputControl/index.d.ts +1 -0
  158. package/lib/group-component/components/InputControl/index.js +16 -0
  159. package/lib/group-component/components/async-select/index.d.ts +11 -0
  160. package/lib/group-component/components/async-select/index.js +47 -0
  161. package/lib/group-component/components/async-table-select/index.d.ts +11 -0
  162. package/lib/group-component/components/async-table-select/index.js +49 -0
  163. package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
  164. package/lib/group-component/components/checkbox-control/index.js +48 -0
  165. package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  166. package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
  167. package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  168. package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
  169. package/lib/group-component/components/command/Command.d.ts +10 -0
  170. package/lib/group-component/components/command/Command.js +44 -0
  171. package/lib/group-component/components/number/index.d.ts +12 -0
  172. package/lib/group-component/components/number/index.js +50 -0
  173. package/lib/group-component/components/number-range/index.d.ts +13 -0
  174. package/lib/group-component/components/number-range/index.js +87 -0
  175. package/lib/group-component/features/operator.d.ts +24 -0
  176. package/lib/group-component/features/operator.js +67 -0
  177. package/lib/group-component/footer/TableFooter.d.ts +7 -0
  178. package/lib/group-component/footer/TableFooter.js +44 -0
  179. package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
  180. package/lib/group-component/footer/TableFooterCell.js +75 -0
  181. package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
  182. package/lib/group-component/footer/TableFooterRow.js +37 -0
  183. package/lib/group-component/header/TableHead.d.ts +15 -0
  184. package/lib/group-component/header/TableHead.js +107 -0
  185. package/lib/group-component/header/TableHeadCell.d.ts +15 -0
  186. package/lib/group-component/header/TableHeadCell.js +319 -0
  187. package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
  188. package/lib/group-component/header/TableHeadCell2.js +330 -0
  189. package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
  190. package/lib/group-component/header/TableHeadGroupCell.js +103 -0
  191. package/lib/group-component/header/TableHeadRow.d.ts +15 -0
  192. package/lib/group-component/header/TableHeadRow.js +59 -0
  193. package/lib/group-component/header/renderFilter.d.ts +20 -0
  194. package/lib/group-component/header/renderFilter.js +301 -0
  195. package/lib/group-component/hook/convert.d.ts +1 -0
  196. package/lib/group-component/hook/convert.js +34 -0
  197. package/lib/group-component/hook/useColumns.d.ts +28 -0
  198. package/lib/group-component/hook/useColumns.js +318 -0
  199. package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
  200. package/lib/group-component/hook/useFilterOperator.js +40 -0
  201. package/lib/group-component/hook/utils.d.ts +220 -0
  202. package/lib/group-component/hook/utils.js +2468 -0
  203. package/lib/group-component/index.d.ts +2 -0
  204. package/lib/group-component/index.js +9 -0
  205. package/lib/group-component/style.d.ts +22 -0
  206. package/lib/group-component/style.js +55 -0
  207. package/lib/group-component/style.scss +1438 -0
  208. package/lib/group-component/table/Grid.d.ts +33 -0
  209. package/lib/group-component/table/Grid.js +443 -0
  210. package/lib/group-component/table/TableWrapper.d.ts +33 -0
  211. package/lib/group-component/table/TableWrapper.js +259 -0
  212. package/lib/group-component/useContext.d.ts +100 -0
  213. package/lib/group-component/useContext.js +27 -0
  214. package/lib/table-component/InternalTable.js +6 -1
  215. package/lib/table-component/TableContainer.js +4 -2
  216. package/lib/table-component/TableContainerEdit.js +2 -2
  217. package/lib/table-component/body/TableBodyCell.js +49 -40
  218. package/lib/table-component/body/TableBodyCellEdit.js +9 -3
  219. package/lib/table-component/body/TableBodyRow.js +4 -1
  220. package/lib/table-component/hook/utils.d.ts +1 -0
  221. package/lib/table-component/hook/utils.js +16 -7
  222. package/lib/table-component/style.js +1 -1
  223. package/lib/table-component/table/Grid.js +3 -0
  224. package/lib/table-component/useContext.d.ts +5 -0
  225. package/lib/table-virtuoso/InternalTable.js +2 -2
  226. package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
  227. package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  228. package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
  229. package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  230. package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
  231. package/lib/table-virtuoso/hook/utils.d.ts +1 -0
  232. package/lib/table-virtuoso/hook/utils.js +32 -1
  233. package/lib/table-virtuoso/style.js +3 -1
  234. package/lib/table-virtuoso/table/Grid.js +2 -2
  235. package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
  236. package/lib/table-virtuoso/table/TableWrapper.js +24 -5
  237. package/lib/table-virtuoso/useContext.d.ts +6 -3
  238. package/lib/table-virtuoso/useContext.js +18 -0
  239. package/package.json +1 -1
@@ -0,0 +1,33 @@
1
+ import type { ColumnDef, ColumnPinningState, ExpandedState, VisibilityState } from '@tanstack/react-table';
2
+ import type { ColumnsTable, Sorter, TableProps } from '../../grid-component/type';
3
+ import type { Dispatch, Key, SetStateAction } from 'react';
4
+ import React from 'react';
5
+ type Props<T> = Omit<TableProps<T>, 'columns'> & {
6
+ id: string;
7
+ rowKey: string;
8
+ prefix: string;
9
+ columns: ColumnDef<T>[];
10
+ propsColumns: ColumnsTable<T>;
11
+ setColumns: Dispatch<SetStateAction<ColumnsTable<T>>>;
12
+ columnHidden: VisibilityState;
13
+ expanded: ExpandedState;
14
+ setExpanded: any;
15
+ columnPinning: ColumnPinningState;
16
+ setColumnPinning: Dispatch<SetStateAction<ColumnPinningState>>;
17
+ originData: T[];
18
+ mergedFilterKeys: any;
19
+ setMergedFilterKeys: any;
20
+ isFullScreen: boolean;
21
+ setIsFullScreen: Dispatch<SetStateAction<boolean>>;
22
+ triggerFilter: Dispatch<SetStateAction<any>>;
23
+ triggerSorter: Dispatch<SetStateAction<Sorter[]>>;
24
+ onContextMenu?: (data: T) => (event: any) => void;
25
+ triggerChangeColumns?: (args: any, keys: any, type: string) => void;
26
+ windowSize: any;
27
+ isDataTree: boolean;
28
+ mergedSelectedKeys: Key[];
29
+ columnVisibility?: any;
30
+ setColumnVisibility?: Dispatch<SetStateAction<any>>;
31
+ };
32
+ declare const Grid: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
33
+ export default Grid;
@@ -0,0 +1,443 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _antd = require("antd");
10
+ var _faker = require("@faker-js/faker");
11
+ var _reactTable = require("@tanstack/react-table");
12
+ var _core = require("@dnd-kit/core");
13
+ var _modifiers = require("@dnd-kit/modifiers");
14
+ var _sortable = require("@dnd-kit/sortable");
15
+ var _react = _interopRequireWildcard(require("react"));
16
+ var _TableContainer = _interopRequireDefault(require("../TableContainer"));
17
+ var _operator = require("../features/operator");
18
+ var _utils = require("../hook/utils");
19
+ var _TableContainerEdit = _interopRequireDefault(require("../TableContainerEdit"));
20
+ var _classnames = _interopRequireDefault(require("classnames"));
21
+ var _style = require("../style");
22
+ var _utils2 = require("../../table-component/hook/utils");
23
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
24
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
+ // import { makeData } from "../default/makeData";
26
+
27
+ const Grid = props => {
28
+ const {
29
+ theme,
30
+ t,
31
+ id,
32
+ prefix,
33
+ dataSource,
34
+ originData,
35
+ columns,
36
+ propsColumns,
37
+ setColumns,
38
+ pagination,
39
+ expanded,
40
+ setExpanded,
41
+ columnHidden,
42
+ columnPinning,
43
+ setColumnPinning,
44
+ selectionSettings,
45
+ rowSelected,
46
+ sortMultiple,
47
+ triggerSorter,
48
+ triggerFilter,
49
+ setMergedFilterKeys,
50
+ onSorter,
51
+ onFilter,
52
+ allowFiltering,
53
+ allowSortering,
54
+ groupColumns,
55
+ // height= 700,
56
+ height,
57
+ minHeight,
58
+ editAble,
59
+ triggerChangeColumns,
60
+ infiniteScroll,
61
+ mergedSelectedKeys,
62
+ allowResizing,
63
+ windowSize,
64
+ fullScreenTitle,
65
+ className: tableClassNames,
66
+ groupSetting,
67
+ ...rest
68
+ } = props;
69
+ const [columnResizeMode] = _react.default.useState('onChange');
70
+ const [columnResizeDirection] = _react.default.useState('ltr');
71
+ const [paginationState, setPagination] = _react.default.useState({
72
+ pageIndex: pagination && pagination.currentPage ? pagination.currentPage - 1 : 0,
73
+ pageSize: pagination && pagination.pageSize ? pagination.pageSize : 20
74
+ });
75
+
76
+ // const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({})
77
+
78
+ // const [rowSelection, setRowSelection] = React.useState<RowSelectionState>(convertToObjTrue(selectionSettings?.selectedRowKeys ?? []))
79
+ const [rowSelection, setRowSelection] = _react.default.useState({});
80
+ // const [rowsSelected, setRowsSelected] = React.useState<RecordType[]>([])
81
+
82
+ const [grouping, setGrouping] = _react.default.useState([]);
83
+ const [columnSizing, setColumnSizing] = _react.default.useState({});
84
+ const [columnSizingInfo, setColumnSizingInfo] = _react.default.useState({});
85
+ // const [manualUpdate, setManualUpdate] = React.useState(false)
86
+ // const [manualResize, setManualResize] = React.useState(false)
87
+
88
+ const [columnFilters, setColumnFilters] = _react.default.useState([]);
89
+ const [operator, setOperator] = _react.default.useState([]);
90
+ const [sorting, setSorting] = _react.default.useState([]);
91
+ const [columnOrder, setColumnOrder] = _react.default.useState(() => columns.map(c => c.id));
92
+ const [isSelectionChange, setIsSelectionChange] = _react.default.useState({
93
+ isChange: false,
94
+ type: '',
95
+ rowData: {},
96
+ rowsData: []
97
+ });
98
+ const [sorterChange, setSorterChange] = _react.default.useState(false);
99
+ const [filterChange, setFilterChange] = _react.default.useState(false);
100
+ const [isFullScreen, setIsFullScreen] = _react.default.useState(false);
101
+ const table = (0, _reactTable.useReactTable)({
102
+ _features: [_operator.OperatorFeature],
103
+ data: dataSource,
104
+ columns: columns,
105
+ state: {
106
+ rowSelection,
107
+ expanded,
108
+ columnPinning,
109
+ columnVisibility: columnHidden,
110
+ pagination: pagination && !infiniteScroll ? paginationState : undefined,
111
+ grouping,
112
+ columnSizing,
113
+ columnOrder,
114
+ columnFilters,
115
+ operator,
116
+ sorting
117
+ },
118
+ getCoreRowModel: (0, _reactTable.getCoreRowModel)(),
119
+ getRowId(originalRow) {
120
+ return originalRow.rowId;
121
+ },
122
+ getSubRows: row => row.children,
123
+ // RowSelection
124
+ enableSubRowSelection: selectionSettings && selectionSettings.mode === 'checkbox' && selectionSettings.type !== 'single',
125
+ enableMultiRowSelection: selectionSettings && (selectionSettings.mode === 'checkbox' || selectionSettings.type !== 'single'),
126
+ // enableRowSelection: true,
127
+ enableRowSelection: row => {
128
+ if (selectionSettings?.getCheckboxProps) {
129
+ return !selectionSettings?.getCheckboxProps(row.original)?.disabled;
130
+ }
131
+ return true;
132
+ },
133
+ initialState: {
134
+ rowSelection: {}
135
+ },
136
+ onRowSelectionChange: setRowSelection,
137
+ // RowSelection
138
+
139
+ // ColumnSizing
140
+ enableColumnResizing: allowResizing !== false,
141
+ columnResizeMode,
142
+ columnResizeDirection,
143
+ onColumnSizingChange: setColumnSizing,
144
+ onColumnSizingInfoChange: setColumnSizingInfo,
145
+ // ColumnSizing
146
+
147
+ // ColumnSorting
148
+ // getSortedRowModel: getSortedRowModel(),
149
+ onSortingChange: setSorting,
150
+ enableMultiSort: sortMultiple !== false,
151
+ isMultiSortEvent: () => sortMultiple === false ? false : true,
152
+ enableSorting: allowSortering !== false,
153
+ // ColumnSorting
154
+
155
+ enableFilters: allowFiltering !== false,
156
+ onColumnFiltersChange: setColumnFilters,
157
+ onColumnOperatorChange: setOperator,
158
+ // getFilteredRowModel: getFilteredRowModel(),
159
+
160
+ onColumnOrderChange: setColumnOrder,
161
+ onGroupingChange: setGrouping,
162
+ getGroupedRowModel: (0, _reactTable.getGroupedRowModel)(),
163
+ // onExpandedChange: setExpanded,
164
+ getExpandedRowModel: (0, _reactTable.getExpandedRowModel)(),
165
+ getPaginationRowModel: pagination && !infiniteScroll ? (0, _reactTable.getPaginationRowModel)() : undefined,
166
+ onPaginationChange: setPagination,
167
+ // onColumnVisibilityChange: setColumnVisibility,
168
+ onColumnPinningChange: setColumnPinning
169
+
170
+ // debugTable: true
171
+ });
172
+ _react.default.useEffect(() => {
173
+ if (columnHidden) {
174
+ const abb = table.getVisibleLeafColumns()?.[0];
175
+ if (abb && Object.keys(columnSizingInfo).length === 0) {
176
+ setColumnSizing({
177
+ [abb.id]: abb.getSize()
178
+ });
179
+ }
180
+ }
181
+ }, [columnHidden, columnSizingInfo]);
182
+ _react.default.useEffect(() => {
183
+ const isEqual = (0, _utils.isObjEqual)((0, _utils.convertToObjTrue)(mergedSelectedKeys), rowSelection);
184
+ if (!isEqual) {
185
+ setRowSelection((0, _utils.convertToObjTrue)(mergedSelectedKeys));
186
+ }
187
+ }, [mergedSelectedKeys]);
188
+ _react.default.useEffect(() => {
189
+ if (isSelectionChange.isChange) {
190
+ const aa = table.getState().rowSelection;
191
+ const ids = Object.keys(aa);
192
+
193
+ // const ssss = dataTable.filter(it => ids.includes(it.id)) // lấy rowsData của trang hiện tại
194
+ const ssss = (0, _utils.filterByIds)(ids, isSelectionChange.rowsData ?? []); // lấy rowsData của trang hiện tại
195
+
196
+ const rs = ssss.map(it => it.original);
197
+ rowSelected?.({
198
+ type: isSelectionChange.type,
199
+ rowData: isSelectionChange.rowData,
200
+ selected: rs
201
+ });
202
+ }
203
+ }, [isSelectionChange, rowSelection, table.getState().rowSelection]);
204
+ _react.default.useEffect(() => {
205
+ if (sorterChange) {
206
+ const aa = table.getState().sorting;
207
+ const rs = aa.map(it => {
208
+ return {
209
+ columnKey: it.id,
210
+ field: it.id,
211
+ order: it.desc ? 'descend' : 'ascend'
212
+ };
213
+ });
214
+ if (onSorter) {
215
+ onSorter?.(rs);
216
+ } else {
217
+ triggerSorter(rs);
218
+ }
219
+ }
220
+ }, [sorterChange, sorting, table]);
221
+ _react.default.useEffect(() => {
222
+ if (filterChange) {
223
+ // const filterState = table.getState().columnFilters
224
+ const operatorState = table.getState().operator;
225
+ const merged = columnFilters.map(filter => {
226
+ const match = operatorState.find(op => op.id === filter.id);
227
+ const col = table.getVisibleFlatColumns().find(it => it.id === filter.id)?.columnDef.meta;
228
+ return {
229
+ field: filter.id,
230
+ key: filter.id,
231
+ column: col,
232
+ filteredKeys: filter.value,
233
+ operator: match ? match.operator : undefined
234
+ // ...(match && { operator: match.operator })
235
+ };
236
+ });
237
+ if (onFilter) {
238
+ onFilter?.((0, _utils.convertFilters)(merged));
239
+ } else {
240
+ triggerFilter((0, _utils.convertFilters)(merged));
241
+ const b = (0, _utils.filterDataByColumns)(originData, (0, _utils.convertFilters)(merged), [], []);
242
+ setMergedFilterKeys((0, _utils.getAllRowKey)(b));
243
+ }
244
+ }
245
+ }, [filterChange, onFilter, originData, setMergedFilterKeys, table, triggerFilter, columnFilters]);
246
+
247
+ // reorder columns after drag & drop
248
+ function handleDragEnd(event) {
249
+ const {
250
+ active,
251
+ over
252
+ } = event;
253
+ if (active && over && active.id !== over.id) {
254
+ setColumnOrder(cols => {
255
+ const oldIndex = cols.indexOf(active.id);
256
+ const newIndex = cols.indexOf(over.id);
257
+ return (0, _sortable.arrayMove)(cols, oldIndex, newIndex); //this is just a splice util
258
+ });
259
+ }
260
+ }
261
+ const triggerGroupColumns = groupedColumns => {
262
+ // const abcd = updateColumnsByGroup(columns, groupedColumns)
263
+
264
+ const aaa = (0, _utils.fixColumnsLeft)(propsColumns, groupedColumns);
265
+ const abc = (0, _utils.sortColumnsByField)(aaa, groupedColumns);
266
+
267
+ // const bcd = convertToObj(groupedColumns)
268
+
269
+ // const bbb = updateWidthsByOther(propsColumns, abc)
270
+
271
+ setColumns((0, _utils.sortByType)(abc));
272
+
273
+ // const a = getInvisibleColumns(columns)
274
+
275
+ // const prev = groupColumns ?? []
276
+
277
+ // const bbb = prev.filter(item => !groupedColumns.includes(item))
278
+
279
+ // const ccc = removeKeys(columnVisibility, bbb)
280
+
281
+ // const rs = { ...ccc, ...bcd }
282
+
283
+ // setColumnVisibility(rs)
284
+
285
+ // table.setColumnVisibility(rs)
286
+
287
+ if (groupSetting) {
288
+ if (groupSetting.onGroup) {
289
+ groupSetting.onGroup({
290
+ columnGrouped: groupedColumns,
291
+ columns: (0, _utils2.removeColumns)(columns, groupedColumns),
292
+ flattenColumns: (0, _utils2.flatColumns2)((0, _utils2.removeColumns)(columns, groupedColumns))
293
+ });
294
+ }
295
+ if (groupSetting.client === false) {
296
+
297
+ // group server => không xử lý gì
298
+ } else {
299
+ // group client
300
+
301
+ table.resetRowSelection();
302
+ table.resetExpanded();
303
+ setRowSelection({});
304
+ setExpanded({});
305
+ }
306
+ }
307
+ };
308
+ const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.MouseSensor, {}), (0, _core.useSensor)(_core.TouchSensor, {}), (0, _core.useSensor)(_core.KeyboardSensor, {}));
309
+ const ContainerComponent = editAble ? _TableContainerEdit.default : _TableContainer.default;
310
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_style.GridStyle, {
311
+ $prefix: prefix,
312
+ $theme: {
313
+ theme: theme?.theme,
314
+ ...theme
315
+ },
316
+ className: (0, _classnames.default)(`${prefix}-grid ${tableClassNames}`, {
317
+ [`${prefix}-grid-light`]: !theme || theme.theme === 'light',
318
+ [`${prefix}-grid-dark`]: theme?.theme === 'dark'
319
+ }),
320
+ style: {
321
+ minHeight: minHeight ?? undefined,
322
+ maxHeight: height ?? undefined,
323
+ backgroundColor: theme?.backgroundColor ?? undefined
324
+ }
325
+ }, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
326
+ collisionDetection: _core.closestCenter,
327
+ modifiers: [_modifiers.restrictToHorizontalAxis],
328
+ onDragEnd: handleDragEnd,
329
+ sensors: sensors
330
+ }, /*#__PURE__*/_react.default.createElement(ContainerComponent, (0, _extends2.default)({}, rest, {
331
+ id: id,
332
+ t: t,
333
+ windowSize: windowSize,
334
+ table: table,
335
+ editAble: editAble,
336
+ dataSource: dataSource,
337
+ originData: originData,
338
+ prefix: prefix,
339
+ selectionSettings: selectionSettings,
340
+ isSelectionChange: isSelectionChange,
341
+ setIsSelectionChange: setIsSelectionChange,
342
+ setSorterChange: setSorterChange,
343
+ setFilterChange: setFilterChange,
344
+ height: height ?? minHeight ?? 700,
345
+ minHeight: minHeight,
346
+ pagination: pagination,
347
+ columns: columns,
348
+ groupColumns: groupColumns,
349
+ propsColumns: propsColumns,
350
+ triggerChangeColumns: triggerChangeColumns,
351
+ columnHidden: columnHidden,
352
+ setExpanded: setExpanded,
353
+ expanded: expanded,
354
+ infiniteScroll: infiniteScroll,
355
+ setMergedFilterKeys: setMergedFilterKeys,
356
+ triggerGroupColumns: triggerGroupColumns,
357
+ setColumnSizing: setColumnSizing,
358
+ setColumns: setColumns,
359
+ columnSizing: columnSizing,
360
+ columnSizingInfo: columnSizingInfo,
361
+ isFullScreen: isFullScreen,
362
+ setIsFullScreen: setIsFullScreen
363
+ })))), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
364
+ open: isFullScreen,
365
+ footer: null,
366
+ centered: true,
367
+ closable: true,
368
+ width: '100%',
369
+ style: {
370
+ maxWidth: '100%',
371
+ height: '100%'
372
+ },
373
+ onCancel: () => setIsFullScreen(false)
374
+
375
+ // destroyOnClose
376
+ ,
377
+ styles: {
378
+ content: {
379
+ height: '100vh',
380
+ borderRadius: 0,
381
+ padding: '15px 10px'
382
+ },
383
+ wrapper: {
384
+ zIndex: 1050
385
+ }
386
+ },
387
+ title: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, " ", typeof fullScreenTitle === 'function' ? fullScreenTitle?.() : fullScreenTitle, " "),
388
+ destroyOnClose: true
389
+ }, /*#__PURE__*/_react.default.createElement("div", {
390
+ style: {}
391
+ }, /*#__PURE__*/_react.default.createElement(_style.GridStyle, {
392
+ $prefix: prefix,
393
+ $theme: {
394
+ theme: theme?.theme,
395
+ ...theme
396
+ },
397
+ className: (0, _classnames.default)(`${prefix}-grid ${tableClassNames}`, {
398
+ [`${prefix}-grid-light`]: !theme || theme.theme === 'light',
399
+ [`${prefix}-grid-dark`]: theme?.theme === 'dark'
400
+ }),
401
+ style: {
402
+ // minHeight: minHeight ?? undefined,
403
+ maxHeight: windowSize.innerHeight - 70
404
+ }
405
+ }, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
406
+ collisionDetection: _core.closestCenter,
407
+ modifiers: [_modifiers.restrictToHorizontalAxis],
408
+ onDragEnd: handleDragEnd,
409
+ sensors: sensors
410
+ }, /*#__PURE__*/_react.default.createElement(ContainerComponent, (0, _extends2.default)({}, rest, {
411
+ id: _faker.faker.string.alpha(20),
412
+ t: t,
413
+ table: table,
414
+ editAble: editAble,
415
+ dataSource: dataSource,
416
+ originData: originData,
417
+ prefix: prefix,
418
+ selectionSettings: selectionSettings,
419
+ isSelectionChange: isSelectionChange,
420
+ setIsSelectionChange: setIsSelectionChange,
421
+ setSorterChange: setSorterChange,
422
+ setFilterChange: setFilterChange,
423
+ height: windowSize.innerHeight - 70,
424
+ minHeight: minHeight,
425
+ pagination: pagination,
426
+ columns: columns,
427
+ windowSize: windowSize,
428
+ propsColumns: propsColumns,
429
+ triggerChangeColumns: triggerChangeColumns,
430
+ columnHidden: columnHidden,
431
+ setExpanded: setExpanded,
432
+ expanded: expanded,
433
+ infiniteScroll: infiniteScroll,
434
+ setMergedFilterKeys: setMergedFilterKeys,
435
+ setColumnSizing: setColumnSizing,
436
+ setColumns: setColumns,
437
+ columnSizing: columnSizing,
438
+ columnSizingInfo: columnSizingInfo,
439
+ isFullScreen: isFullScreen,
440
+ setIsFullScreen: setIsFullScreen
441
+ })))))));
442
+ };
443
+ var _default = exports.default = Grid;
@@ -0,0 +1,33 @@
1
+ import { type Table } from "@tanstack/react-table";
2
+ import type { CommandClick, ContextInfo, ContextMenuItem, PaginationConfig } from "../../grid-component/type";
3
+ import React from "react";
4
+ import type { Virtualizer } from "@tanstack/react-virtual";
5
+ import type { Column } from "@tanstack/react-table";
6
+ type Props<T> = {
7
+ prefix: string;
8
+ id: string;
9
+ tableContainerRef: React.RefObject<HTMLDivElement>;
10
+ height: number;
11
+ minHeight?: number;
12
+ table: Table<T>;
13
+ summary?: boolean;
14
+ loading?: boolean;
15
+ commandClick?: (args: Omit<CommandClick<T>, 'rows'>) => void;
16
+ editAble?: boolean;
17
+ contextMenuItems?: ContextMenuItem[];
18
+ showEmptyText?: boolean;
19
+ contextMenuClick?: any;
20
+ contextMenuOpen?: (args: Omit<ContextInfo<T>, 'item'>) => void;
21
+ contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<T>, 'item' | 'event'>) => string[]);
22
+ next?: () => void;
23
+ dataSource: T[];
24
+ pagination?: false | PaginationConfig;
25
+ infiniteScroll?: boolean;
26
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
27
+ virtualPaddingLeft: number | undefined;
28
+ virtualPaddingRight: number | undefined;
29
+ fixedLeftColumns: Column<T, unknown>[];
30
+ fixedRightColumns: Column<T, unknown>[];
31
+ };
32
+ declare const TableWrapper: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
33
+ export default TableWrapper;