es-grid-template 1.8.71 → 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 (235) 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/body/TableBodyCell.js +49 -40
  98. package/es/table-component/body/TableBodyRow.js +4 -1
  99. package/es/table-component/hook/utils.d.ts +1 -0
  100. package/es/table-component/hook/utils.js +15 -7
  101. package/es/table-component/style.js +1 -1
  102. package/es/table-component/table/Grid.js +3 -0
  103. package/es/table-component/useContext.d.ts +5 -0
  104. package/es/table-virtuoso/InternalTable.js +2 -2
  105. package/es/table-virtuoso/body/TableBodyCell.js +2 -7
  106. package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  107. package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
  108. package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  109. package/es/table-virtuoso/body/TableBodyRow.js +43 -1
  110. package/es/table-virtuoso/hook/utils.d.ts +1 -0
  111. package/es/table-virtuoso/hook/utils.js +29 -0
  112. package/es/table-virtuoso/style.js +3 -1
  113. package/es/table-virtuoso/table/Grid.js +2 -2
  114. package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
  115. package/es/table-virtuoso/table/TableWrapper.js +24 -5
  116. package/es/table-virtuoso/useContext.d.ts +6 -3
  117. package/es/table-virtuoso/useContext.js +18 -0
  118. package/lib/grid-component/TempTable.js +2 -1
  119. package/lib/group-component/ColumnsChoose.d.ts +13 -0
  120. package/lib/group-component/ColumnsChoose.js +221 -0
  121. package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  122. package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
  123. package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
  124. package/lib/group-component/ColumnsGroup/index.js +16 -0
  125. package/lib/group-component/ContextMenu.d.ts +19 -0
  126. package/lib/group-component/ContextMenu.js +83 -0
  127. package/lib/group-component/InternalTable.d.ts +8 -0
  128. package/lib/group-component/InternalTable.js +233 -0
  129. package/lib/group-component/TableContainer.d.ts +49 -0
  130. package/lib/group-component/TableContainer.js +382 -0
  131. package/lib/group-component/TableContainerEdit.d.ts +48 -0
  132. package/lib/group-component/TableContainerEdit.js +2075 -0
  133. package/lib/group-component/body/EditableCell.d.ts +16 -0
  134. package/lib/group-component/body/EditableCell.js +1075 -0
  135. package/lib/group-component/body/TableBody.d.ts +14 -0
  136. package/lib/group-component/body/TableBody.js +91 -0
  137. package/lib/group-component/body/TableBodyCell.d.ts +12 -0
  138. package/lib/group-component/body/TableBodyCell.js +595 -0
  139. package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
  140. package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
  141. package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  142. package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
  143. package/lib/group-component/body/TableBodyRow.d.ts +21 -0
  144. package/lib/group-component/body/TableBodyRow.js +206 -0
  145. package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  146. package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
  147. package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
  148. package/lib/group-component/components/ControlCheckbox.js +92 -0
  149. package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
  150. package/lib/group-component/components/EditForm/EditForm.js +404 -0
  151. package/lib/group-component/components/EditForm/index.d.ts +1 -0
  152. package/lib/group-component/components/EditForm/index.js +16 -0
  153. package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
  154. package/lib/group-component/components/InputControl/InputControl.js +127 -0
  155. package/lib/group-component/components/InputControl/index.d.ts +1 -0
  156. package/lib/group-component/components/InputControl/index.js +16 -0
  157. package/lib/group-component/components/async-select/index.d.ts +11 -0
  158. package/lib/group-component/components/async-select/index.js +47 -0
  159. package/lib/group-component/components/async-table-select/index.d.ts +11 -0
  160. package/lib/group-component/components/async-table-select/index.js +49 -0
  161. package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
  162. package/lib/group-component/components/checkbox-control/index.js +48 -0
  163. package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  164. package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
  165. package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  166. package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
  167. package/lib/group-component/components/command/Command.d.ts +10 -0
  168. package/lib/group-component/components/command/Command.js +44 -0
  169. package/lib/group-component/components/number/index.d.ts +12 -0
  170. package/lib/group-component/components/number/index.js +50 -0
  171. package/lib/group-component/components/number-range/index.d.ts +13 -0
  172. package/lib/group-component/components/number-range/index.js +87 -0
  173. package/lib/group-component/features/operator.d.ts +24 -0
  174. package/lib/group-component/features/operator.js +67 -0
  175. package/lib/group-component/footer/TableFooter.d.ts +7 -0
  176. package/lib/group-component/footer/TableFooter.js +44 -0
  177. package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
  178. package/lib/group-component/footer/TableFooterCell.js +75 -0
  179. package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
  180. package/lib/group-component/footer/TableFooterRow.js +37 -0
  181. package/lib/group-component/header/TableHead.d.ts +15 -0
  182. package/lib/group-component/header/TableHead.js +107 -0
  183. package/lib/group-component/header/TableHeadCell.d.ts +15 -0
  184. package/lib/group-component/header/TableHeadCell.js +319 -0
  185. package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
  186. package/lib/group-component/header/TableHeadCell2.js +330 -0
  187. package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
  188. package/lib/group-component/header/TableHeadGroupCell.js +103 -0
  189. package/lib/group-component/header/TableHeadRow.d.ts +15 -0
  190. package/lib/group-component/header/TableHeadRow.js +59 -0
  191. package/lib/group-component/header/renderFilter.d.ts +20 -0
  192. package/lib/group-component/header/renderFilter.js +301 -0
  193. package/lib/group-component/hook/convert.d.ts +1 -0
  194. package/lib/group-component/hook/convert.js +34 -0
  195. package/lib/group-component/hook/useColumns.d.ts +28 -0
  196. package/lib/group-component/hook/useColumns.js +318 -0
  197. package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
  198. package/lib/group-component/hook/useFilterOperator.js +40 -0
  199. package/lib/group-component/hook/utils.d.ts +220 -0
  200. package/lib/group-component/hook/utils.js +2468 -0
  201. package/lib/group-component/index.d.ts +2 -0
  202. package/lib/group-component/index.js +9 -0
  203. package/lib/group-component/style.d.ts +22 -0
  204. package/lib/group-component/style.js +55 -0
  205. package/lib/group-component/style.scss +1438 -0
  206. package/lib/group-component/table/Grid.d.ts +33 -0
  207. package/lib/group-component/table/Grid.js +443 -0
  208. package/lib/group-component/table/TableWrapper.d.ts +33 -0
  209. package/lib/group-component/table/TableWrapper.js +259 -0
  210. package/lib/group-component/useContext.d.ts +100 -0
  211. package/lib/group-component/useContext.js +27 -0
  212. package/lib/table-component/InternalTable.js +6 -1
  213. package/lib/table-component/TableContainer.js +4 -2
  214. package/lib/table-component/body/TableBodyCell.js +49 -40
  215. package/lib/table-component/body/TableBodyRow.js +4 -1
  216. package/lib/table-component/hook/utils.d.ts +1 -0
  217. package/lib/table-component/hook/utils.js +16 -7
  218. package/lib/table-component/style.js +1 -1
  219. package/lib/table-component/table/Grid.js +3 -0
  220. package/lib/table-component/useContext.d.ts +5 -0
  221. package/lib/table-virtuoso/InternalTable.js +2 -2
  222. package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
  223. package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  224. package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
  225. package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  226. package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
  227. package/lib/table-virtuoso/hook/utils.d.ts +1 -0
  228. package/lib/table-virtuoso/hook/utils.js +32 -1
  229. package/lib/table-virtuoso/style.js +3 -1
  230. package/lib/table-virtuoso/table/Grid.js +2 -2
  231. package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
  232. package/lib/table-virtuoso/table/TableWrapper.js +24 -5
  233. package/lib/table-virtuoso/useContext.d.ts +6 -3
  234. package/lib/table-virtuoso/useContext.js +18 -0
  235. package/package.json +1 -1
@@ -0,0 +1,14 @@
1
+ import { type Table } from "@tanstack/react-table";
2
+ import type { CommandClick } from "../../grid-component/type";
3
+ import React from "react";
4
+ interface TableBodyProps<T> {
5
+ table: Table<T>;
6
+ tableContainerRef: React.RefObject<HTMLDivElement>;
7
+ commandClick?: (args: CommandClick<T>) => void;
8
+ editAble?: boolean;
9
+ tableId: string;
10
+ showEmptyText?: boolean;
11
+ [key: string]: any;
12
+ }
13
+ declare const TableBody: <RecordType extends object>({ columnVirtualizer, table, tableContainerRef, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, tableId, showEmptyText, ...rest }: TableBodyProps<RecordType>) => React.JSX.Element;
14
+ export default TableBody;
@@ -0,0 +1,82 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import TableBodyRow from "./TableBodyRow";
3
+ import { useVirtualizer } from "@tanstack/react-virtual";
4
+ import React, { Fragment } from "react";
5
+ import { TableContext } from "../useContext";
6
+ import { Empty } from "rc-master-ui";
7
+ const TableBody = ({
8
+ columnVirtualizer,
9
+ table,
10
+ tableContainerRef,
11
+ virtualPaddingLeft,
12
+ virtualPaddingRight,
13
+ fixedLeftColumns,
14
+ fixedRightColumns,
15
+ tableId,
16
+ showEmptyText,
17
+ ...rest
18
+ }) => {
19
+ const {
20
+ rows
21
+ } = table.getRowModel();
22
+ const {
23
+ editingKey,
24
+ prefix,
25
+ locale
26
+ } = React.useContext(TableContext);
27
+
28
+ //dynamic row height virtualization - alternatively you could use a simpler fixed row height strategy without the need for `measureElement`
29
+ const rowVirtualizer = useVirtualizer({
30
+ count: rows.length,
31
+ estimateSize: () => 36,
32
+ //estimate row height for accurate scrollbar dragging
33
+ getScrollElement: () => tableContainerRef.current,
34
+ //measure dynamic row height, except in firefox because it measures table border height incorrectly
35
+ measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
36
+ overscan: 1
37
+ });
38
+ const virtualRows = rowVirtualizer.getVirtualItems();
39
+ return /*#__PURE__*/React.createElement("div", {
40
+ className: `${prefix}-grid-tbody`,
41
+ style: {
42
+ display: 'grid',
43
+ // height: `${rowVirtualizer.getTotalSize()}px`, //tells scrollbar how big the table is
44
+ height: showEmptyText && rows.length === 0 ? `140px` : `${rowVirtualizer.getTotalSize()}px`,
45
+ //tells scrollbar how big the table is
46
+ position: 'relative' //needed for absolute positioning of rows
47
+ }
48
+ }, showEmptyText && rows.length === 0 ? /*#__PURE__*/React.createElement("tr", {
49
+ style: {
50
+ // transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll
51
+ }
52
+ }, /*#__PURE__*/React.createElement("td", {
53
+ // colSpan={30}
54
+ style: {
55
+ position: "sticky",
56
+ left: 0,
57
+ width: tableContainerRef.current?.clientWidth,
58
+ overflow: 'hidden'
59
+ }
60
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Empty, {
61
+ image: Empty.PRESENTED_IMAGE_SIMPLE,
62
+ description: locale?.emptyText
63
+ })))) : /*#__PURE__*/React.createElement(Fragment, null, virtualRows.map(virtualRow => {
64
+ const row = rows[virtualRow.index];
65
+ const isEditing = row.id === editingKey;
66
+ return /*#__PURE__*/React.createElement(TableBodyRow, _extends({}, rest, {
67
+ table: table,
68
+ tableId: tableId,
69
+ key: row.id,
70
+ row: row,
71
+ columnVirtualizer: columnVirtualizer,
72
+ rowVirtualizer: rowVirtualizer,
73
+ virtualPaddingLeft: virtualPaddingLeft,
74
+ virtualPaddingRight: virtualPaddingRight,
75
+ virtualRow: virtualRow,
76
+ fixedLeftColumns: fixedLeftColumns,
77
+ fixedRightColumns: fixedRightColumns,
78
+ isEditing: isEditing
79
+ }));
80
+ })));
81
+ };
82
+ export default TableBody;
@@ -0,0 +1,12 @@
1
+ import type { Cell, Table } from "@tanstack/react-table";
2
+ import type { CommandClick } from "../../grid-component/type";
3
+ import React from "react";
4
+ interface TableBodyCellProps<T> {
5
+ table: Table<T>;
6
+ tableId: string;
7
+ cell: Cell<T, unknown>;
8
+ commandClick?: (args: CommandClick<T>) => void;
9
+ [key: string]: any;
10
+ }
11
+ declare const TableBodyCell: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
12
+ export default TableBodyCell;
@@ -0,0 +1,587 @@
1
+ import { flexRender } from "@tanstack/react-table";
2
+ import Space from "rc-master-ui/es/space";
3
+ import Command from "../components/command/Command";
4
+ import ReactDOMServer from 'react-dom/server';
5
+ import { getCommonPinningStyles, getSelectedCellMatrix } from "../hook/utils";
6
+ import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
7
+ import classNames from "classnames";
8
+ import React from "react";
9
+ import { TableContext } from "../useContext";
10
+ // import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
11
+ import { toggleRowSelection } from "../hook/useColumns";
12
+ import { checkDecimalSeparator, checkThousandSeparator, getFormat, isObjEqual } from "../../table-component/hook/utils";
13
+ import { sumByField } from "../../grid-component/hooks";
14
+ import { numericFormatter } from "react-numeric-component";
15
+ const renderCellIndex = props => {
16
+ const {
17
+ parrents,
18
+ cell,
19
+ pagination
20
+ } = props;
21
+ if (parrents && parrents.length > 0) {
22
+ return /*#__PURE__*/React.createElement("span", {
23
+ className: "ui-rc_cell-content"
24
+ }, parrents.map(pr => {
25
+ return `${pr.index + 1}.`;
26
+ }), cell.row.index + 1);
27
+ }
28
+ if (pagination && pagination.onChange) {
29
+ return /*#__PURE__*/React.createElement("span", {
30
+ className: "ui-rc_cell-content"
31
+ }, cell.row.index + (pagination ? ((pagination.currentPage ?? 1) - 1) * (pagination?.pageSize ?? 0) : 0) + 1);
32
+ }
33
+ return /*#__PURE__*/React.createElement("span", {
34
+ className: "ui-rc_cell-content"
35
+ }, cell.row.index + 1);
36
+ };
37
+ const renderCommand = args => {
38
+ const {
39
+ cell,
40
+ commandClick,
41
+ id,
42
+ data
43
+ } = args;
44
+ const col = cell.column.columnDef.meta ?? {};
45
+ const record = cell.row.original;
46
+
47
+ // const commandItems = args.cell.column.columnDef?.meta?.commandItems ?? []
48
+
49
+ const commands = col.commandItems ? col.commandItems.map(it => {
50
+ return {
51
+ ...it,
52
+ visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
53
+ };
54
+ }) : [];
55
+ return /*#__PURE__*/React.createElement("div", {
56
+ className: "ui-rc_cell-content"
57
+ }, /*#__PURE__*/React.createElement(Space, null, commands.filter(it => it.visible !== false).map(item => {
58
+ return /*#__PURE__*/React.createElement(Command, {
59
+ id: id,
60
+ key: item.id,
61
+ item: item,
62
+ record: record,
63
+ onClick: () => {
64
+ commandClick?.({
65
+ id: item.id,
66
+ // rowId: getRowKey(record, index) as any,
67
+ rowId: record.rowId,
68
+ rowData: record,
69
+ index: cell.row.index,
70
+ rows: [...data]
71
+ });
72
+ }
73
+ });
74
+ })));
75
+ };
76
+ const renderSelection = args => {
77
+ const {
78
+ row
79
+ } = args.cell;
80
+ const {
81
+ cell,
82
+ expandIconColumnIndex,
83
+ isDataTree,
84
+ expanded,
85
+ setExpanded
86
+ } = args;
87
+ const {
88
+ selectionSettings,
89
+ setIsSelectionChange,
90
+ isSelectionChange
91
+ } = args;
92
+ const checked = selectionSettings?.checkStrictly ? row.getIsSelected() : row.getIsSelected() || row.getIsAllSubRowsSelected();
93
+ const indeterminate = selectionSettings?.type === 'single' || selectionSettings?.checkStrictly ? false : row.getIsSomeSelected() && selectionSettings && selectionSettings.mode === 'checkbox' || row.getIsSomeSelected();
94
+ return /*#__PURE__*/React.createElement("div", {
95
+ style: {}
96
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
97
+ className: "ui-rc-table-row-expand-trigger",
98
+ style: {
99
+ paddingLeft: `${cell.row.depth * 25}px`
100
+ }
101
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
102
+ // onClick: row.getToggleExpandedHandler(),
103
+ onClick: e => {
104
+ e.stopPropagation();
105
+ const keys = Object.keys(expanded);
106
+ // @ts-ignore
107
+ const tmp = {
108
+ ...expanded
109
+ };
110
+ if (keys.includes(cell.row.id)) {
111
+ delete tmp[cell.row.id];
112
+ setExpanded(tmp);
113
+ } else {
114
+ setExpanded(old => ({
115
+ ...old,
116
+ [cell.row.id]: true
117
+ }));
118
+ }
119
+ },
120
+ style: {
121
+ cursor: "pointer"
122
+ },
123
+ className: "ui-rc-table-row-expand"
124
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
125
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
126
+ }) : /*#__PURE__*/React.createElement("span", {
127
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
128
+ })) : /*#__PURE__*/React.createElement("span", {
129
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
130
+ }))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Checkbox, {
131
+ checked: checked,
132
+ indeterminate: indeterminate,
133
+ onChange: e => {
134
+ toggleRowSelection({
135
+ e,
136
+ cell,
137
+ setIsSelectionChange,
138
+ isSelectionChange,
139
+ selectionSettings
140
+ });
141
+ },
142
+ disabled: !row.getCanSelect()
143
+ })));
144
+ };
145
+ const TableBodyCell = props => {
146
+ const {
147
+ cell,
148
+ commandClick,
149
+ // tableId,
150
+ table,
151
+ isEditing,
152
+ row,
153
+ colSpan
154
+ // rowSpan
155
+ } = props;
156
+ const {
157
+ id,
158
+ prefix,
159
+ focusedCell,
160
+ setFocusedCell,
161
+ // endCell,
162
+ // startCell,
163
+ originData,
164
+ expanded,
165
+ setExpanded,
166
+ expandable,
167
+ isDataTree,
168
+ setIsSelectionChange,
169
+ isSelectionChange,
170
+ selectionSettings,
171
+ wrapSettings,
172
+ pagination,
173
+ setIsSelecting,
174
+ setIsPasting,
175
+ setEndCell,
176
+ setStartCell,
177
+ setRangeState,
178
+ setEditingKey,
179
+ format,
180
+ rangeState,
181
+ startCell,
182
+ endCell,
183
+ endPasteCell,
184
+ // startPasteCell,
185
+ isPasting
186
+ // dataSource
187
+ } = React.useContext(TableContext);
188
+ const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
189
+ const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
190
+ const record = cell.row.original;
191
+ const columnMeta = cell.column.columnDef.meta ?? {};
192
+ const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
193
+ const originCol = cell.column.columnDef.meta ?? {};
194
+
195
+ // const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
196
+ const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
197
+ value: cell.getValue(),
198
+ record
199
+ }) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
200
+ const allRows = table.getRowModel().flatRows;
201
+ const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
202
+ const colIndex = cell.column.getIndex();
203
+ const isPinned = cell.column.getIsPinned();
204
+ const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
205
+ const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
206
+ const enableClick = typeof columnMeta.allowSelection === 'function' ? columnMeta.allowSelection(record) : columnMeta.allowSelection;
207
+ const parrents = cell.row.getParentRows();
208
+ if (cell.column.id === "#") {
209
+ return /*#__PURE__*/React.createElement("div", {
210
+ key: cell.id,
211
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-index`, {
212
+ [`${prefix}-grid-cell-ellipsis`]: true,
213
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
214
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
215
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
216
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
217
+ }),
218
+ style: {
219
+ ...cellStyles,
220
+ display: 'flex',
221
+ userSelect: 'none',
222
+ width: cell.column.getSize(),
223
+ minWidth: cell.column.getSize(),
224
+ ...getCommonPinningStyles(cell.column)
225
+ },
226
+ onClick: e => {
227
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
228
+ toggleRowSelection({
229
+ e,
230
+ cell,
231
+ setIsSelectionChange,
232
+ isSelectionChange,
233
+ selectionSettings
234
+ });
235
+ }
236
+ }
237
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
238
+ className: "ui-rc-table-row-expand-trigger",
239
+ style: {
240
+ paddingLeft: `${cell.row.depth * 25}px`
241
+ }
242
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
243
+ // onClick: row.getToggleExpandedHandler(),
244
+ onClick: e => {
245
+ e.stopPropagation();
246
+ const keys = Object.keys(expanded);
247
+ // @ts-ignore
248
+ const tmp = {
249
+ ...expanded
250
+ };
251
+ if (keys.includes(cell.row.id)) {
252
+ delete tmp[cell.row.id];
253
+ setExpanded(tmp);
254
+ } else {
255
+ setExpanded(old => ({
256
+ ...old,
257
+ [cell.row.id]: true
258
+ }));
259
+ }
260
+ },
261
+ style: {
262
+ cursor: "pointer"
263
+ },
264
+ className: "ui-rc-table-row-expand"
265
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
266
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
267
+ }) : /*#__PURE__*/React.createElement("span", {
268
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
269
+ })) : /*#__PURE__*/React.createElement("span", {
270
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
271
+ }))), renderCellIndex({
272
+ parrents,
273
+ cell,
274
+ pagination
275
+ }));
276
+ }
277
+ if (cell.column.id === "command") {
278
+ return /*#__PURE__*/React.createElement("div", {
279
+ key: cell.id,
280
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-command`, {
281
+ [`${prefix}-grid-cell-ellipsis`]: true,
282
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
283
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
284
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
285
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
286
+ }),
287
+ style: {
288
+ ...cellStyles,
289
+ display: 'flex',
290
+ width: cell.column.getSize(),
291
+ minWidth: cell.column.getSize(),
292
+ ...getCommonPinningStyles(cell.column)
293
+ }
294
+ }, renderCommand({
295
+ cell,
296
+ commandClick,
297
+ id,
298
+ data: originData
299
+ }));
300
+ }
301
+ if (cell.column.id === "selection_column") {
302
+ return /*#__PURE__*/React.createElement("div", {
303
+ key: cell.id,
304
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-selection`, {
305
+ [`${prefix}-grid-cell-ellipsis`]: true,
306
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
307
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
308
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
309
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
310
+ }),
311
+ style: {
312
+ ...cellStyles,
313
+ display: 'flex',
314
+ minHeight: 36,
315
+ width: cell.column.getSize(),
316
+ minWidth: cell.column.getSize(),
317
+ ...getCommonPinningStyles(cell.column)
318
+ }
319
+ }, /*#__PURE__*/React.createElement("div", {
320
+ className: classNames('ui-rc_cell-content', {})
321
+ }, cell.column.id === "selection_column" && renderSelection({
322
+ cell,
323
+ table,
324
+ selectionSettings,
325
+ setIsSelectionChange,
326
+ expanded,
327
+ isDataTree,
328
+ setExpanded,
329
+ expandIconColumnIndex,
330
+ isSelectionChange
331
+ })));
332
+ }
333
+ if (row.subRows.length > 0 && originCol.sumGroup === true && originCol.type === 'number') {
334
+ const colFormat = typeof originCol.format === 'function' ? originCol.format({}) : originCol.format;
335
+ const cellFormat = getFormat(colFormat, format);
336
+ const thousandSeparator = cellFormat?.thousandSeparator;
337
+ const decimalSeparator = cellFormat?.decimalSeparator;
338
+ const dec = cellFormat?.decimalScale;
339
+ const numericFormatProps = {
340
+ thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
341
+ decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
342
+ allowNegative: cellFormat?.allowNegative ?? true,
343
+ prefix: cellFormat?.prefix,
344
+ suffix: cellFormat?.suffix,
345
+ decimalScale: dec,
346
+ fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
347
+ };
348
+
349
+ // const childrenData = row.subRows.map((it) => it.original)
350
+ const childrenData = record?.children ?? [];
351
+ const sumValue = sumByField(childrenData, cell.column.id);
352
+ const sumValueFormat = numericFormatter(sumValue.toString(), numericFormatProps);
353
+ return /*#__PURE__*/React.createElement("div", {
354
+ key: cell.id,
355
+ className: classNames(`${prefix}-grid-cell`, {
356
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
357
+ [`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
358
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
359
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
360
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
361
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
362
+ }),
363
+ style: {
364
+ ...cellStyles,
365
+ display: 'flex',
366
+ userSelect: 'none',
367
+ width: cell.column.getSize(),
368
+ minWidth: cell.column.getSize(),
369
+ ...getCommonPinningStyles(cell.column)
370
+ },
371
+ onClick: e => {
372
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
373
+ toggleRowSelection({
374
+ e,
375
+ cell,
376
+ setIsSelectionChange,
377
+ isSelectionChange,
378
+ selectionSettings
379
+ });
380
+ }
381
+ }
382
+ }, sumValueFormat);
383
+ }
384
+ return /*#__PURE__*/React.createElement("div", {
385
+ key: cell.id,
386
+ ref: el => {
387
+ if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
388
+ el?.focus();
389
+ }
390
+ },
391
+ tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
392
+ "data-col-index": colIndex,
393
+ "data-row-index": rowNumber,
394
+ "data-col-key": cell.column.id
395
+ // data-row-key={cell.row.id}
396
+ ,
397
+ "data-tooltip-id": `${id}-tooltip-content`,
398
+ "data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent))
399
+ // data-tooltip-delay-show={500}
400
+ ,
401
+
402
+ className: classNames(`${prefix}-grid-cell`, {
403
+ // [`${prefix}-grid-cell-ellipsis`]: true,
404
+
405
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
406
+ [`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
407
+ // [`${prefix}-grid-cell-selected`]: isCellSelected,
408
+
409
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
410
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
411
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
412
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
413
+ }),
414
+ style: {
415
+ ...cellStyles,
416
+ display: 'flex',
417
+ width: cell.column.getSize(),
418
+ minWidth: cell.column.getSize(),
419
+ minHeight: 36,
420
+ gridColumn: `span ${colSpan} / span ${colSpan}`,
421
+ ...getCommonPinningStyles(cell.column)
422
+ },
423
+ onMouseDown: () => {
424
+ // setEditingKey?.('')
425
+ // setEndCell?.(undefined)
426
+ // setStartCell?.(undefined)
427
+ // setFocusedCell?.(undefined)
428
+ // setRangeState?.(undefined)
429
+ },
430
+ onMouseEnter: e => {
431
+ if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
432
+ setIsOpenTooltip(true);
433
+ }
434
+ setIsSelecting?.(false);
435
+ setIsPasting?.(false);
436
+ const selectState = getSelectedCellMatrix(table, startCell, endCell);
437
+ // const selectPasteState = getSelectedCellMatrix(table, startPasteCell, endPasteCell)
438
+
439
+ if (endPasteCell && endCell?.rowId !== endPasteCell?.rowId && isPasting) {
440
+ // triggerDragPaste(selectPasteState, e.ctrlKey)
441
+ } else {
442
+ // if ( endCell?.rowId !== rowId || endCell?.colId !== colId) {
443
+ // setRangeState?.(selectState)
444
+ // }
445
+
446
+ if (!isObjEqual(rangeState, selectState)) {
447
+ setRangeState?.(selectState);
448
+ }
449
+ }
450
+ },
451
+ onKeyDown: e => {
452
+ const flatRows = table.getRowModel().flatRows;
453
+ if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
454
+ const nextIndex = cell.row.index + 1;
455
+ // const nextIndex = rowNumber + 1
456
+
457
+ const nextId = flatRows[nextIndex].id;
458
+ setFocusedCell?.({
459
+ colId: cell.column.id,
460
+ rowId: nextId
461
+ });
462
+ const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
463
+ const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
464
+ if (cellFocus) {
465
+ cellFocus.focus();
466
+ }
467
+ }
468
+ if (e.key === 'ArrowUp' && rowNumber > 0) {
469
+ const prevIndex = cell.row.index - 1;
470
+ const nextId = flatRows[prevIndex].id;
471
+ setFocusedCell?.({
472
+ colId: cell.column.id,
473
+ rowId: nextId
474
+ });
475
+ const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
476
+ const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
477
+ if (cellFocus) {
478
+ cellFocus.focus();
479
+ }
480
+ }
481
+ if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
482
+ toggleRowSelection({
483
+ e,
484
+ cell,
485
+ setIsSelectionChange,
486
+ isSelectionChange,
487
+ selectionSettings
488
+ });
489
+ cell.row.getToggleSelectedHandler()(e);
490
+
491
+ // if (cell.row.getIsSelected()) { // nếu đã chọn
492
+
493
+ // const aaa = isSelectionChange?.rowsData.filter((it) => it.id !== cell.row.id)
494
+
495
+ // setIsSelectionChange({
496
+ // isChange: true,
497
+ // type: 'rowSelected',
498
+ // rowData: cell.row.original,
499
+ // rowsData: aaa ?? []
500
+ // })
501
+
502
+ // } else {
503
+
504
+ // const { rowsData } = isSelectionChange ?? {}
505
+
506
+ // const abc = rowsData && rowsData.length > 0 ? [...rowsData] : []
507
+
508
+ // abc.push(cell.row)
509
+
510
+ // setIsSelectionChange({
511
+ // isChange: true,
512
+ // type: 'rowSelected',
513
+ // rowData: cell.row.original,
514
+ // rowsData: abc
515
+ // })
516
+ // }
517
+ }
518
+ }
519
+
520
+ // onKeyUp={() => {
521
+
522
+ // }}
523
+ ,
524
+
525
+ onClick: e => {
526
+ const selection = window.getSelection();
527
+ const text = selection ? selection.toString() : "";
528
+ if (text.length > 0 || enableClick === false) {} else {
529
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
530
+ toggleRowSelection({
531
+ e,
532
+ cell,
533
+ setIsSelectionChange,
534
+ isSelectionChange,
535
+ selectionSettings
536
+ });
537
+ setFocusedCell?.({
538
+ colId: cell.column.id,
539
+ rowId: cell.row.id
540
+ });
541
+ setEditingKey?.('');
542
+ setEndCell?.(undefined);
543
+ setStartCell?.(undefined);
544
+ // setFocusedCell?.(undefined)
545
+ setRangeState?.(undefined);
546
+ }
547
+ }
548
+ }
549
+ }, /*#__PURE__*/React.createElement("div", {
550
+ className: classNames('ui-rc_cell-content', {})
551
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
552
+ className: "ui-rc-table-row-expand-trigger",
553
+ style: {
554
+ paddingLeft: `${cell.row.depth * 25}px`
555
+ }
556
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
557
+ // onClick: row.getToggleExpandedHandler(),
558
+ onClick: e => {
559
+ e.stopPropagation();
560
+ const keys = Object.keys(expanded);
561
+ // @ts-ignore
562
+ const tmp = {
563
+ ...expanded
564
+ };
565
+ if (keys.includes(cell.row.id)) {
566
+ delete tmp[cell.row.id];
567
+ setExpanded(tmp);
568
+ } else {
569
+ setExpanded(old => ({
570
+ ...old,
571
+ [cell.row.id]: true
572
+ }));
573
+ }
574
+ },
575
+ style: {
576
+ cursor: "pointer"
577
+ },
578
+ className: "ui-rc-table-row-expand"
579
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
580
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
581
+ }) : /*#__PURE__*/React.createElement("span", {
582
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
583
+ })) : /*#__PURE__*/React.createElement("span", {
584
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
585
+ }))), flexRender(cell.column.columnDef.cell, cell.getContext())));
586
+ };
587
+ export default TableBodyCell;