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,34 @@
1
+ // import type { Virtualizer } from "@tanstack/react-virtual";
2
+ import TableFooterRow from "./TableFooterRow";
3
+ import { TableContext } from "../useContext";
4
+ import React, { useContext } from "react";
5
+ const TableFooter = ({
6
+ // columnVirtualizer,
7
+ table
8
+ // virtualPaddingLeft,
9
+ // virtualPaddingRight,
10
+ // ...rest
11
+ }) => {
12
+ const {
13
+ prefix
14
+ } = useContext(TableContext);
15
+ return /*#__PURE__*/React.createElement("div", {
16
+ className: `${prefix}-grid-tfoot`,
17
+ style: {
18
+ display: "grid",
19
+ position: "sticky",
20
+ bottom: 0,
21
+ zIndex: 1
22
+ }
23
+ }, /*#__PURE__*/React.createElement(TableFooterRow, {
24
+ table: table
25
+ // columnVirtualizer={columnVirtualizer}
26
+ ,
27
+ headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1]
28
+ // key={headerGroup.id}
29
+ // virtualPaddingLeft={virtualPaddingLeft}
30
+ // virtualPaddingRight={virtualPaddingRight}
31
+ // {...rest}
32
+ }));
33
+ };
34
+ export default TableFooter;
@@ -0,0 +1,7 @@
1
+ import type { Column } from "@tanstack/react-table";
2
+ import React from "react";
3
+ interface TableFooterCellProps<T> {
4
+ column: Column<T, any>;
5
+ }
6
+ declare const TableFooterCell: <RecordType extends object>({ column }: TableFooterCellProps<RecordType>) => React.JSX.Element;
7
+ export default TableFooterCell;
@@ -0,0 +1,66 @@
1
+ import React, { useContext } from "react";
2
+ import { checkDecimalSeparator, checkThousandSeparator, getCommonPinningStyles, getFormat, isEmpty } from "../hook/utils";
3
+ import { TableContext } from "../useContext";
4
+ import classNames from "classnames";
5
+ import { sumByField } from "../../grid-component/hooks";
6
+ import { numericFormatter } from "react-numeric-component";
7
+ const TableFooterCell = ({
8
+ column
9
+ }) => {
10
+ const isPinned = column.getIsPinned();
11
+ const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
12
+ const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
13
+ const {
14
+ prefix,
15
+ format,
16
+ dataSource
17
+ } = useContext(TableContext);
18
+ const col = column.columnDef.meta ?? {};
19
+ const colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
20
+ const cellFormat = getFormat(colFormat, format);
21
+ const thousandSeparator = cellFormat?.thousandSeparator;
22
+ const decimalSeparator = cellFormat?.decimalSeparator;
23
+
24
+ // const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
25
+ const dec = cellFormat?.decimalScale;
26
+
27
+ // const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
28
+ const sumValue = col.type === 'number' ? sumByField(dataSource, col?.field) : 0;
29
+ const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
30
+ const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
31
+ const numberValue = Number(value);
32
+ const numericFormatProps = {
33
+ thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
34
+ decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
35
+ allowNegative: cellFormat?.allowNegative ?? false,
36
+ prefix: cellFormat?.prefix,
37
+ suffix: cellFormat?.suffix,
38
+ decimalScale: dec,
39
+ fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
40
+ };
41
+ return /*#__PURE__*/React.createElement("div", {
42
+ // ref={el => {
43
+ // if (el) columnVirtualizer.measureElement(el)
44
+ // }}
45
+ // data-index={header.id}
46
+
47
+ className: classNames(`${prefix}-grid-cell`, {
48
+ // [`${prefix}-grid-cell-ellipsis`]:!wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
49
+ // [`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
50
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
51
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
52
+ [`${prefix}-grid-cell-text-right`]: true
53
+ }),
54
+ key: column.id
55
+ // colSpan={header.colSpan}
56
+ ,
57
+ style: {
58
+ display: 'flex',
59
+ ...getCommonPinningStyles(column),
60
+ // width: column?.getSize() ?? column.getSize(),
61
+ minWidth: column?.getSize()
62
+ // backgroundColor: "#fafafa",
63
+ }
64
+ }, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/React.createElement(React.Fragment, null, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : numericFormatter(cellValue, numericFormatProps)) : '');
65
+ };
66
+ export default TableFooterCell;
@@ -0,0 +1,8 @@
1
+ import type { HeaderGroup, Table } from "@tanstack/react-table";
2
+ import React from "react";
3
+ interface TableFooterRowProps<T> {
4
+ table: Table<T>;
5
+ headerGroup: HeaderGroup<T>;
6
+ }
7
+ declare const TableFooterRow: <RecordType extends object>({ table, headerGroup, }: TableFooterRowProps<RecordType>) => React.JSX.Element;
8
+ export default TableFooterRow;
@@ -0,0 +1,30 @@
1
+ import TableFooterCell from "./TableFooterCell";
2
+ import React from "react";
3
+ import { TableContext } from "../useContext";
4
+ const TableFooterRow = ({
5
+ table,
6
+ headerGroup
7
+ }) => {
8
+ const visibleColumns = table.getVisibleLeafColumns();
9
+ const {
10
+ onRowFooterStyles
11
+ } = React.useContext(TableContext);
12
+ const rowStyles = typeof onRowFooterStyles === 'function' ? onRowFooterStyles() : onRowFooterStyles;
13
+ return /*#__PURE__*/React.createElement("div", {
14
+ key: headerGroup.id,
15
+ style: {
16
+ ...rowStyles,
17
+ display: "grid",
18
+ width: "100%",
19
+ height: 37,
20
+ gridTemplateColumns: `${table.getVisibleLeafColumns().map(n => `${n.getSize()}fr`).join(" ")}`
21
+ },
22
+ className: "ui-rc-grid-footer-row"
23
+ }, visibleColumns.map(header => {
24
+ return /*#__PURE__*/React.createElement(TableFooterCell, {
25
+ key: header.id,
26
+ column: header
27
+ });
28
+ }));
29
+ };
30
+ export default TableFooterRow;
@@ -0,0 +1,15 @@
1
+ import type { Column } from '@tanstack/react-table';
2
+ import { type Table } from '@tanstack/react-table';
3
+ import { type Virtualizer } from '@tanstack/react-virtual';
4
+ import React from 'react';
5
+ interface TableHeadProps<T> {
6
+ tableContainerRef: React.RefObject<HTMLDivElement>;
7
+ table: Table<T>;
8
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
9
+ virtualPaddingLeft: number | undefined;
10
+ virtualPaddingRight: number | undefined;
11
+ fixedLeftColumns: Column<T, unknown>[];
12
+ fixedRightColumns: Column<T, unknown>[];
13
+ }
14
+ declare const TableHead: <RecordType extends object>({ columnVirtualizer, table, }: TableHeadProps<RecordType>) => React.JSX.Element;
15
+ export default TableHead;
@@ -0,0 +1,98 @@
1
+ import React, { useContext } from 'react';
2
+ import { TableContext } from "../useContext";
3
+ import TableHeadCell2 from "./TableHeadCell2";
4
+ import TableHeadGroupCell from "./TableHeadGroupCell";
5
+ const TableHead = ({
6
+ columnVirtualizer,
7
+ table
8
+ }) => {
9
+ const {
10
+ prefix,
11
+ onRowHeaderStyles
12
+ } = useContext(TableContext);
13
+ const headerGroups = table.getFlatHeaders();
14
+ const leafColumns = table.getVisibleFlatColumns();
15
+ const headerDepth = table.getHeaderGroups().length;
16
+ const rowStyles = typeof onRowHeaderStyles === 'function' ? onRowHeaderStyles() : onRowHeaderStyles;
17
+ return /*#__PURE__*/React.createElement("div", {
18
+ className: `${prefix}-grid-thead`,
19
+ style: {
20
+ ...rowStyles,
21
+ display: 'grid',
22
+ position: 'sticky',
23
+ top: 0,
24
+ zIndex: 1,
25
+ gridTemplateColumns: `${table.getVisibleLeafColumns().map(n => `${n.getSize()}fr`).join(" ")}`
26
+ }
27
+ }, leafColumns.map(column => {
28
+ const depth = column.depth ?? 0;
29
+
30
+ // const colSpan = column.columns.length || 1;
31
+ const colSpan = column.getFlatColumns().filter(col => col.getIsVisible() && col.columns.length < 1).length;
32
+ // const colSpan = getVisibleChildCount(column);
33
+
34
+ const rowSpan = column.columns?.length > 0 ? 1 : headerDepth - depth;
35
+ const header = headerGroups.find(it => it.id === column.id || it.column.id === column.id && it.subHeaders.length > 0);
36
+ // const groupHeader = headerGroups.find((it) => it.column.id === column.id && it.subHeaders.length >= 2)
37
+
38
+ if (header?.subHeaders && header.subHeaders.length >= 2) {
39
+ return /*#__PURE__*/React.createElement(TableHeadGroupCell, {
40
+ key: column.id,
41
+ depth: depth,
42
+ column: column,
43
+ header: header,
44
+ table: table,
45
+ columnVirtualizer: columnVirtualizer,
46
+ colSpan: colSpan,
47
+ rowSpan: rowSpan
48
+ });
49
+ } else {
50
+ return /*#__PURE__*/React.createElement(TableHeadCell2, {
51
+ key: column.id,
52
+ depth: depth,
53
+ column: column,
54
+ header: header,
55
+ table: table,
56
+ columnVirtualizer: columnVirtualizer
57
+ // rowHeaderVirtualizer={rowHeaderVirtualizer}
58
+ ,
59
+ colSpan: colSpan,
60
+ rowSpan: rowSpan
61
+ });
62
+ }
63
+
64
+ // if (header) {
65
+ // return (
66
+ // <TableHeadCell2
67
+ // key={column.id}
68
+ // depth={depth}
69
+ // column={column}
70
+ // header={header as any}
71
+ // table={table}
72
+ // columnVirtualizer={columnVirtualizer}
73
+ // // rowHeaderVirtualizer={rowHeaderVirtualizer}
74
+ // colSpan={colSpan}
75
+ // rowSpan={rowSpan}
76
+ // />
77
+ // )
78
+ // }
79
+
80
+ // return (
81
+ // <div
82
+ // key={col.id}
83
+ // className="th p-2 border font-bold flex items-center justify-center"
84
+ // style={{
85
+ // // width: col.getSize(),
86
+ // minWidth: col.getSize(),
87
+ // gridRow: `${depth + 1} / span ${rowSpan}`,
88
+
89
+ // gridColumn: `span ${colSpan}`,
90
+ // }}
91
+ // >
92
+ // aaaaa
93
+ // {/* {flexRender(col.columnDef.header, header.getContext())} */}
94
+ // </div>
95
+ // );
96
+ }));
97
+ };
98
+ export default TableHead;
@@ -0,0 +1,15 @@
1
+ import type { Table } from '@tanstack/react-table';
2
+ import { type Header } from '@tanstack/react-table';
3
+ import React from 'react';
4
+ import type { Virtualizer } from '@tanstack/react-virtual';
5
+ interface TableHeadCellProps<T> {
6
+ t?: any;
7
+ table: Table<T>;
8
+ header: Header<T, unknown>;
9
+ getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
10
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
11
+ colSpan: any;
12
+ rowSpan: any;
13
+ }
14
+ declare const TableHeadCell: <RecordType extends object>(props: TableHeadCellProps<RecordType>) => React.JSX.Element;
15
+ export default TableHeadCell;
@@ -0,0 +1,310 @@
1
+ import { flexRender } from '@tanstack/react-table';
2
+ import React, { useContext } from 'react';
3
+ import { Button, Space } from 'antd';
4
+ import { ArrowDown, ArrowUp, FilterFill, SortCancel } from 'becoxy-icons';
5
+ import classNames from 'classnames';
6
+ import { Checkbox, Dropdown, Select } from 'rc-master-ui';
7
+ import { booleanOperator, nonActionColumn, numberOperator, stringOperator, translateOption } from "../../grid-component/hooks";
8
+ import { extendsObject, getCommonPinningStyles, getDefaultOperator, getTypeFilter } from "../hook/utils";
9
+ import { TableContext } from "../useContext";
10
+ import { renderFilter } from "./renderFilter";
11
+ import ReactDOMServer from 'react-dom/server';
12
+ const TableHeadCell = props => {
13
+ const {
14
+ header,
15
+ getPopupContainer,
16
+ table
17
+ } = props;
18
+ const {
19
+ t,
20
+ prefix,
21
+ setSorterChange,
22
+ setFilterChange,
23
+ wrapSettings,
24
+ selectionSettings,
25
+ setIsSelectionChange,
26
+ id,
27
+ locale
28
+ } = useContext(TableContext);
29
+ const isPinned = header.column.getIsPinned();
30
+ const isLastLeftPinnedColumn = isPinned === 'left' && header.column.getIsLastColumn('left');
31
+ const isFirstRightPinnedColumn = isPinned === 'right' && header.column.getIsFirstColumn('right');
32
+ const [selectedKeys, setSelectedKeys] = React.useState([]);
33
+ const [visible, setVisible] = React.useState(false);
34
+ const {
35
+ filterIcon
36
+ } = header.column.columnDef.meta ?? {};
37
+
38
+ // const column = (header.column.columnDef ?? {}) as ColumnTable
39
+ const column = header.column.columnDef;
40
+ const originalColumn = header.column.columnDef.meta ?? {};
41
+ const filtered = (header.column.getFilterValue() ?? []).length > 0;
42
+ const cellContent = flexRender(header.column.columnDef.header, header.getContext());
43
+ const html = ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, cellContent));
44
+ const hasValue = html.trim().length > 0;
45
+
46
+ // const filtered = header.column.getIsFiltered()
47
+
48
+ // const { attributes, isDragging, listeners, setNodeRef, transform } =
49
+ // useSortable({
50
+ // id: header.column.id,
51
+ // })
52
+
53
+ const style = {
54
+ // opacity: isDragging ? 0.8 : 1,
55
+ // position: 'relative',
56
+ // transform: CSS.Translate.toString(transform), // translate instead of transform to avoid squishing
57
+ transition: 'width transform 0.2s ease-in-out',
58
+ whiteSpace: 'nowrap'
59
+ // width: header.column.getSize(),
60
+ // zIndex: isDragging ? 1 : 0,
61
+ };
62
+ const getDropdownTrigger = () => {
63
+ let iconFilter;
64
+ if (typeof filterIcon === 'function') {
65
+ iconFilter = filterIcon(filtered);
66
+ } else if (filterIcon) {
67
+ iconFilter = filterIcon;
68
+ } else {
69
+ iconFilter = /*#__PURE__*/React.createElement(FilterFill, {
70
+ style: {
71
+ color: filtered ? '#E3165B' : '#283046'
72
+ },
73
+ fontSize: 12
74
+ });
75
+ }
76
+ return /*#__PURE__*/React.createElement("span", {
77
+ role: "button",
78
+ tabIndex: -1,
79
+ className: classNames(`${prefix}-trigger`, {
80
+ active: filtered
81
+ }),
82
+ onClick: e => {
83
+ e.stopPropagation();
84
+ }
85
+ }, iconFilter);
86
+ };
87
+ const triggerVisible = newVisible => {
88
+ setVisible(newVisible);
89
+ };
90
+ const onVisibleChange = (newVisible, info) => {
91
+ if (info.source === 'trigger') {
92
+ if (newVisible) {
93
+ const filterValue = header.column.getFilterValue() ?? [];
94
+ const operatorValue = header.column.getFilterOperator() ?? getDefaultOperator(column?.meta ?? {});
95
+ setSelectedKeys(filterValue);
96
+ header.column.setFilterOperator?.(operatorValue);
97
+ } else {}
98
+ triggerVisible(newVisible);
99
+ }
100
+ };
101
+ const doFilter = type => {
102
+ if (type) {
103
+ header.column.setFilterValue(!originalColumn.typeFilter || originalColumn.typeFilter === 'Text' ? selectedKeys.length === 0 ? [''] : selectedKeys : selectedKeys);
104
+ } else {
105
+ header.column.setFilterValue(undefined);
106
+ setSelectedKeys([]);
107
+ }
108
+ setFilterChange(true);
109
+ triggerVisible(false);
110
+ setTimeout(() => {
111
+ setFilterChange(false);
112
+ }, 10);
113
+ };
114
+ const mergedDropdownProps = extendsObject({
115
+ trigger: ['click'],
116
+ placement: 'bottomRight',
117
+ // placement: direction === 'rtl' ? 'bottomLeft' : 'bottomRight',
118
+ children: getDropdownTrigger(),
119
+ getPopupContainer
120
+ }, {
121
+ // ...filterDropdownProps,
122
+ // rootClassName: classNames(rootClassName, filterDropdownProps.rootClassName),
123
+ open: visible,
124
+ onOpenChange: onVisibleChange,
125
+ destroyPopupOnHide: true,
126
+ dropdownRender: () => {
127
+ const type = getTypeFilter(originalColumn);
128
+ const operatorValue = header.column.getFilterOperator() ?? getDefaultOperator(originalColumn);
129
+ const operatorOptions = ['Checkbox', 'Dropdown', 'DropTree', 'CheckboxDropdown'].includes(type) ? booleanOperator : !type || type === 'Text' ? stringOperator : numberOperator;
130
+ return /*#__PURE__*/React.createElement("div", {
131
+ // className='ui-rc-table-filter-dropdown'
132
+
133
+ className: classNames(`${prefix}-grid-filter-dropdown`, {}),
134
+ style: {}
135
+ }, /*#__PURE__*/React.createElement("div", {
136
+ style: {
137
+ minWidth: 275,
138
+ padding: '8px'
139
+ }
140
+ }, /*#__PURE__*/React.createElement("div", null), column.meta?.hideOperator === true && column.meta?.typeFilter !== 'DateRange' && column.meta?.typeFilter !== 'NumberRange' && /*#__PURE__*/React.createElement("div", {
141
+ className: 'mb-1'
142
+ }, /*#__PURE__*/React.createElement(Select, {
143
+ options: translateOption(operatorOptions, t),
144
+ style: {
145
+ width: '100%',
146
+ marginBottom: 8
147
+ },
148
+ value: operatorValue,
149
+ onChange: val => {
150
+ header.column.setFilterOperator(val);
151
+ }
152
+ })), /*#__PURE__*/React.createElement("div", {
153
+ style: {
154
+ marginBottom: 8
155
+ }
156
+ }, renderFilter({
157
+ column: column,
158
+ selectedKeys,
159
+ setSelectedKeys
160
+ // selectedKeys: (header.column.getFilterValue() ?? []) as string[],
161
+ // setSelectedKeys: header.column.setFilterValue,
162
+ })), /*#__PURE__*/React.createElement(Space, {
163
+ style: {
164
+ justifyContent: 'end',
165
+ width: '100%'
166
+ }
167
+ }, /*#__PURE__*/React.createElement(Button, {
168
+ type: "primary",
169
+ onClick: () => {
170
+ // header.column.setFilterValue(selectedKeys)
171
+
172
+ doFilter(true);
173
+ },
174
+ size: "small",
175
+ style: {
176
+ width: 90
177
+ }
178
+ }, t ? t('Filter') : 'Filter'), /*#__PURE__*/React.createElement(Button, {
179
+ type: "link",
180
+ size: "small",
181
+ onClick: () => {
182
+ // header.column.setFilterValue([])
183
+ // header.column.setFilterOperator('')
184
+
185
+ setSelectedKeys([]);
186
+ doFilter(false);
187
+ }
188
+ }, t ? t('Clear') : 'Clear'))));
189
+
190
+ // if (typeof filterDropdownProps?.dropdownRender === 'function') {
191
+ // return filterDropdownProps.dropdownRender(dropdownContent);
192
+ // }
193
+ // return dropdownContent;
194
+ }
195
+ });
196
+ return /*#__PURE__*/React.createElement("div", {
197
+ // ref={setNodeRef}
198
+ className: classNames(`${prefix}-grid-cell`, {
199
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
200
+ [`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
201
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
202
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
203
+ [`${prefix}-grid-cell-text-center`]: (originalColumn?.headerTextAlign ?? originalColumn?.textAlign) === 'center',
204
+ [`${prefix}-grid-cell-text-right`]: (originalColumn?.headerTextAlign ?? originalColumn.textAlign) === 'right'
205
+ })
206
+ // colSpan={colSpan}
207
+ // rowSpan={rowSpan}
208
+ ,
209
+
210
+ key: header.id,
211
+ style: {
212
+ // display: 'flex',
213
+ width: header.getSize(),
214
+ minWidth: header.getSize(),
215
+ flex: 1,
216
+ gridColumn: `span ${header.colSpan}`,
217
+ gridRow: `span 2`,
218
+ // maxWidth: header.getSize(),
219
+ ...getCommonPinningStyles(header.column),
220
+ ...style
221
+ },
222
+ "data-tooltip-id": `${id}-tooltip-content`,
223
+ "data-tooltip-html": !hasValue ? '' : ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement("div", null, cellContent))
224
+ }, /*#__PURE__*/React.createElement("div", {
225
+ className: classNames('', {
226
+ [`${prefix}-grid-filter-column`]: header.column.id !== 'selection_column',
227
+ [`${prefix}-grid-selection-column`]: header.column.id === 'selection_column'
228
+ })
229
+ }, header.column.id === 'selection_column' && selectionSettings && selectionSettings.hideSelectAll !== false && selectionSettings.type !== 'single' && selectionSettings.mode !== 'radio' && /*#__PURE__*/React.createElement(Checkbox, {
230
+ checked: table.getIsAllRowsSelected(),
231
+ indeterminate: table.getIsSomeRowsSelected(),
232
+ onChange: e => {
233
+ setIsSelectionChange({
234
+ isChange: true,
235
+ type: 'all',
236
+ rowData: {},
237
+ rowsData: []
238
+ });
239
+ table.getToggleAllRowsSelectedHandler()(e);
240
+ }
241
+ }), header.column.id !== 'selection_column' && /*#__PURE__*/React.createElement("span", {
242
+ className: "ui-rc-table-column-title",
243
+ style: {
244
+ flex: 1
245
+ }
246
+ }, /*#__PURE__*/React.createElement("div", {
247
+ className: classNames('', {
248
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
249
+ [`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')
250
+ })
251
+ }, cellContent)), !nonActionColumn.includes(header.column.id) && header.subHeaders.length < 2 && /*#__PURE__*/React.createElement("span", {
252
+ className: "ui-rc-header-trigger"
253
+ }, header.column.getCanSort() && /*#__PURE__*/React.createElement("div", {
254
+ style: {
255
+ marginInlineEnd: 6,
256
+ cursor: 'pointer'
257
+ },
258
+ onClick: e => {
259
+ setSorterChange(true);
260
+ const toggleSortingHandler = header.column.getToggleSortingHandler();
261
+ if (typeof toggleSortingHandler === 'function') {
262
+ toggleSortingHandler(e);
263
+ }
264
+ }
265
+ }, header.column.getIsSorted() ? header.column.getIsSorted() === 'asc' ? /*#__PURE__*/React.createElement(ArrowUp, {
266
+ fontSize: 15,
267
+ color: '#000'
268
+ // data-tooltip-id={`${id}-tooltip-header-trigger`}
269
+ ,
270
+ "data-tooltip-id": `${id}-tooltip-content`
271
+ // data-tooltip-content='Nhấp để sắp xếp giảm dần'
272
+ ,
273
+ "data-tooltip-content": locale?.triggerDesc ?? 'Click to sort descending'
274
+ }) : /*#__PURE__*/React.createElement(ArrowDown, {
275
+ fontSize: 15,
276
+ color: '#000',
277
+ "data-tooltip-id": `${id}-tooltip-content`
278
+ // data-tooltip-id={`${id}-tooltip-header-trigger`}
279
+ // data-tooltip-content='Nhấp để hủy sắp xếp'
280
+ ,
281
+ "data-tooltip-content": locale?.cancelSort ?? 'Click to cancel sorting'
282
+ }) : /*#__PURE__*/React.createElement(SortCancel
283
+ // data-tooltip-id={`${id}-tooltip-header-trigger`}
284
+ , {
285
+ "data-tooltip-id": `${id}-tooltip-content`
286
+ // data-tooltip-content='Nhấp để sắp xếp tăng dần'
287
+ ,
288
+ "data-tooltip-content": locale?.triggerAsc ?? 'Click to sort ascending',
289
+ fontSize: 15,
290
+ style: {
291
+ display: 'flex'
292
+ },
293
+ className: classNames(`ui-rc-table-column-sorter-cancel`, {
294
+ active: true
295
+ })
296
+ })), header.column.getCanFilter() && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Dropdown, mergedDropdownProps)))), header.column.getCanResize() && /*#__PURE__*/React.createElement("div", {
297
+ onDoubleClick: () => header.column.resetSize(),
298
+ onMouseDown: header.getResizeHandler(),
299
+ onTouchStart: header.getResizeHandler(),
300
+ // onMouseUp: () => {
301
+ // requestAnimationFrame(() => {
302
+ // columnVirtualizer.measure()
303
+ // // rowHeaderVirtualizer.measure()
304
+ // })
305
+ // },
306
+
307
+ className: `resizer ${header.column.getIsResizing() ? 'isResizing' : ''}`
308
+ }));
309
+ };
310
+ export default TableHeadCell;
@@ -0,0 +1,17 @@
1
+ import type { Table } from '@tanstack/react-table';
2
+ import { type Header } from '@tanstack/react-table';
3
+ import React from 'react';
4
+ import type { Virtualizer } from '@tanstack/react-virtual';
5
+ interface TableHeadCellProps<T> {
6
+ t?: any;
7
+ table: Table<T>;
8
+ column: any;
9
+ header: Header<T, unknown>;
10
+ getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
11
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
12
+ colSpan: number;
13
+ rowSpan: number;
14
+ depth: number;
15
+ }
16
+ declare const TableHeadCell2: <RecordType extends object>(props: TableHeadCellProps<RecordType>) => React.JSX.Element;
17
+ export default TableHeadCell2;