es-grid-template 1.8.71 → 1.8.73

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 (251) hide show
  1. package/es/grid-component/TempTable.js +2 -1
  2. package/es/grid-component/type.d.ts +1 -3
  3. package/es/group-component/ColumnsChoose.d.ts +13 -0
  4. package/es/group-component/ColumnsChoose.js +211 -0
  5. package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  6. package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
  7. package/es/group-component/ColumnsGroup/index.d.ts +1 -0
  8. package/es/group-component/ColumnsGroup/index.js +1 -0
  9. package/es/group-component/ContextMenu.d.ts +19 -0
  10. package/es/group-component/ContextMenu.js +74 -0
  11. package/es/group-component/InternalTable.d.ts +8 -0
  12. package/es/group-component/InternalTable.js +224 -0
  13. package/es/group-component/TableContainer.d.ts +49 -0
  14. package/es/group-component/TableContainer.js +375 -0
  15. package/es/group-component/TableContainerEdit.d.ts +48 -0
  16. package/es/group-component/TableContainerEdit.js +2068 -0
  17. package/es/group-component/body/EditableCell.d.ts +16 -0
  18. package/es/group-component/body/EditableCell.js +1066 -0
  19. package/es/group-component/body/TableBody.d.ts +14 -0
  20. package/es/group-component/body/TableBody.js +82 -0
  21. package/es/group-component/body/TableBodyCell.d.ts +12 -0
  22. package/es/group-component/body/TableBodyCell.js +587 -0
  23. package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
  24. package/es/group-component/body/TableBodyCellEdit.js +1398 -0
  25. package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  26. package/es/group-component/body/TableBodyCellEmpty.js +149 -0
  27. package/es/group-component/body/TableBodyRow.d.ts +21 -0
  28. package/es/group-component/body/TableBodyRow.js +199 -0
  29. package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  30. package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
  31. package/es/group-component/components/ControlCheckbox.d.ts +13 -0
  32. package/es/group-component/components/ControlCheckbox.js +84 -0
  33. package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
  34. package/es/group-component/components/EditForm/EditForm.js +394 -0
  35. package/es/group-component/components/EditForm/index.d.ts +1 -0
  36. package/es/group-component/components/EditForm/index.js +1 -0
  37. package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
  38. package/es/group-component/components/InputControl/InputControl.js +118 -0
  39. package/es/group-component/components/InputControl/index.d.ts +1 -0
  40. package/es/group-component/components/InputControl/index.js +1 -0
  41. package/es/group-component/components/async-select/index.d.ts +11 -0
  42. package/es/group-component/components/async-select/index.js +38 -0
  43. package/es/group-component/components/async-table-select/index.d.ts +11 -0
  44. package/es/group-component/components/async-table-select/index.js +40 -0
  45. package/es/group-component/components/checkbox-control/index.d.ts +13 -0
  46. package/es/group-component/components/checkbox-control/index.js +40 -0
  47. package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  48. package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
  49. package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  50. package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
  51. package/es/group-component/components/command/Command.d.ts +10 -0
  52. package/es/group-component/components/command/Command.js +35 -0
  53. package/es/group-component/components/number/index.d.ts +12 -0
  54. package/es/group-component/components/number/index.js +42 -0
  55. package/es/group-component/components/number-range/index.d.ts +13 -0
  56. package/es/group-component/components/number-range/index.js +79 -0
  57. package/es/group-component/features/operator.d.ts +24 -0
  58. package/es/group-component/features/operator.js +62 -0
  59. package/es/group-component/footer/TableFooter.d.ts +7 -0
  60. package/es/group-component/footer/TableFooter.js +34 -0
  61. package/es/group-component/footer/TableFooterCell.d.ts +7 -0
  62. package/es/group-component/footer/TableFooterCell.js +66 -0
  63. package/es/group-component/footer/TableFooterRow.d.ts +8 -0
  64. package/es/group-component/footer/TableFooterRow.js +30 -0
  65. package/es/group-component/header/TableHead.d.ts +15 -0
  66. package/es/group-component/header/TableHead.js +98 -0
  67. package/es/group-component/header/TableHeadCell.d.ts +15 -0
  68. package/es/group-component/header/TableHeadCell.js +310 -0
  69. package/es/group-component/header/TableHeadCell2.d.ts +17 -0
  70. package/es/group-component/header/TableHeadCell2.js +321 -0
  71. package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
  72. package/es/group-component/header/TableHeadGroupCell.js +94 -0
  73. package/es/group-component/header/TableHeadRow.d.ts +15 -0
  74. package/es/group-component/header/TableHeadRow.js +52 -0
  75. package/es/group-component/header/renderFilter.d.ts +20 -0
  76. package/es/group-component/header/renderFilter.js +291 -0
  77. package/es/group-component/hook/convert.d.ts +1 -0
  78. package/es/group-component/hook/convert.js +28 -0
  79. package/es/group-component/hook/useColumns.d.ts +28 -0
  80. package/es/group-component/hook/useColumns.js +306 -0
  81. package/es/group-component/hook/useFilterOperator.d.ts +7 -0
  82. package/es/group-component/hook/useFilterOperator.js +33 -0
  83. package/es/group-component/hook/utils.d.ts +220 -0
  84. package/es/group-component/hook/utils.js +2340 -0
  85. package/es/group-component/index.d.ts +2 -0
  86. package/es/group-component/index.js +2 -0
  87. package/es/group-component/style.d.ts +22 -0
  88. package/es/group-component/style.js +48 -0
  89. package/es/group-component/style.scss +1438 -0
  90. package/es/group-component/table/Grid.d.ts +33 -0
  91. package/es/group-component/table/Grid.js +439 -0
  92. package/es/group-component/table/TableWrapper.d.ts +33 -0
  93. package/es/group-component/table/TableWrapper.js +250 -0
  94. package/es/group-component/useContext.d.ts +100 -0
  95. package/es/group-component/useContext.js +21 -0
  96. package/es/table-component/InternalTable.js +9 -2
  97. package/es/table-component/TableContainer.d.ts +1 -0
  98. package/es/table-component/TableContainer.js +6 -2
  99. package/es/table-component/TableContainerEdit.d.ts +1 -0
  100. package/es/table-component/TableContainerEdit.js +4 -2
  101. package/es/table-component/body/TableBodyCell.js +49 -40
  102. package/es/table-component/body/TableBodyCellEdit.js +9 -6
  103. package/es/table-component/body/TableBodyRow.js +4 -1
  104. package/es/table-component/header/TableHeadCell2.js +39 -3
  105. package/es/table-component/hook/utils.d.ts +1 -0
  106. package/es/table-component/hook/utils.js +15 -7
  107. package/es/table-component/style.js +1 -1
  108. package/es/table-component/table/Grid.d.ts +1 -0
  109. package/es/table-component/table/Grid.js +10 -3
  110. package/es/table-component/useContext.d.ts +6 -0
  111. package/es/table-component/useContext.js +2 -1
  112. package/es/table-virtuoso/InternalTable.js +2 -2
  113. package/es/table-virtuoso/body/TableBodyCell.js +2 -7
  114. package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  115. package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
  116. package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  117. package/es/table-virtuoso/body/TableBodyRow.js +43 -1
  118. package/es/table-virtuoso/hook/utils.d.ts +1 -0
  119. package/es/table-virtuoso/hook/utils.js +29 -0
  120. package/es/table-virtuoso/style.js +3 -1
  121. package/es/table-virtuoso/table/Grid.js +2 -2
  122. package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
  123. package/es/table-virtuoso/table/TableWrapper.js +24 -5
  124. package/es/table-virtuoso/useContext.d.ts +6 -3
  125. package/es/table-virtuoso/useContext.js +18 -0
  126. package/lib/grid-component/TempTable.js +2 -1
  127. package/lib/grid-component/type.d.ts +1 -3
  128. package/lib/group-component/ColumnsChoose.d.ts +13 -0
  129. package/lib/group-component/ColumnsChoose.js +221 -0
  130. package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  131. package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
  132. package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
  133. package/lib/group-component/ColumnsGroup/index.js +16 -0
  134. package/lib/group-component/ContextMenu.d.ts +19 -0
  135. package/lib/group-component/ContextMenu.js +83 -0
  136. package/lib/group-component/InternalTable.d.ts +8 -0
  137. package/lib/group-component/InternalTable.js +233 -0
  138. package/lib/group-component/TableContainer.d.ts +49 -0
  139. package/lib/group-component/TableContainer.js +382 -0
  140. package/lib/group-component/TableContainerEdit.d.ts +48 -0
  141. package/lib/group-component/TableContainerEdit.js +2075 -0
  142. package/lib/group-component/body/EditableCell.d.ts +16 -0
  143. package/lib/group-component/body/EditableCell.js +1075 -0
  144. package/lib/group-component/body/TableBody.d.ts +14 -0
  145. package/lib/group-component/body/TableBody.js +91 -0
  146. package/lib/group-component/body/TableBodyCell.d.ts +12 -0
  147. package/lib/group-component/body/TableBodyCell.js +595 -0
  148. package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
  149. package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
  150. package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  151. package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
  152. package/lib/group-component/body/TableBodyRow.d.ts +21 -0
  153. package/lib/group-component/body/TableBodyRow.js +206 -0
  154. package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  155. package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
  156. package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
  157. package/lib/group-component/components/ControlCheckbox.js +92 -0
  158. package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
  159. package/lib/group-component/components/EditForm/EditForm.js +404 -0
  160. package/lib/group-component/components/EditForm/index.d.ts +1 -0
  161. package/lib/group-component/components/EditForm/index.js +16 -0
  162. package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
  163. package/lib/group-component/components/InputControl/InputControl.js +127 -0
  164. package/lib/group-component/components/InputControl/index.d.ts +1 -0
  165. package/lib/group-component/components/InputControl/index.js +16 -0
  166. package/lib/group-component/components/async-select/index.d.ts +11 -0
  167. package/lib/group-component/components/async-select/index.js +47 -0
  168. package/lib/group-component/components/async-table-select/index.d.ts +11 -0
  169. package/lib/group-component/components/async-table-select/index.js +49 -0
  170. package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
  171. package/lib/group-component/components/checkbox-control/index.js +48 -0
  172. package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  173. package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
  174. package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  175. package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
  176. package/lib/group-component/components/command/Command.d.ts +10 -0
  177. package/lib/group-component/components/command/Command.js +44 -0
  178. package/lib/group-component/components/number/index.d.ts +12 -0
  179. package/lib/group-component/components/number/index.js +50 -0
  180. package/lib/group-component/components/number-range/index.d.ts +13 -0
  181. package/lib/group-component/components/number-range/index.js +87 -0
  182. package/lib/group-component/features/operator.d.ts +24 -0
  183. package/lib/group-component/features/operator.js +67 -0
  184. package/lib/group-component/footer/TableFooter.d.ts +7 -0
  185. package/lib/group-component/footer/TableFooter.js +44 -0
  186. package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
  187. package/lib/group-component/footer/TableFooterCell.js +75 -0
  188. package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
  189. package/lib/group-component/footer/TableFooterRow.js +37 -0
  190. package/lib/group-component/header/TableHead.d.ts +15 -0
  191. package/lib/group-component/header/TableHead.js +107 -0
  192. package/lib/group-component/header/TableHeadCell.d.ts +15 -0
  193. package/lib/group-component/header/TableHeadCell.js +319 -0
  194. package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
  195. package/lib/group-component/header/TableHeadCell2.js +330 -0
  196. package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
  197. package/lib/group-component/header/TableHeadGroupCell.js +103 -0
  198. package/lib/group-component/header/TableHeadRow.d.ts +15 -0
  199. package/lib/group-component/header/TableHeadRow.js +59 -0
  200. package/lib/group-component/header/renderFilter.d.ts +20 -0
  201. package/lib/group-component/header/renderFilter.js +301 -0
  202. package/lib/group-component/hook/convert.d.ts +1 -0
  203. package/lib/group-component/hook/convert.js +34 -0
  204. package/lib/group-component/hook/useColumns.d.ts +28 -0
  205. package/lib/group-component/hook/useColumns.js +318 -0
  206. package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
  207. package/lib/group-component/hook/useFilterOperator.js +40 -0
  208. package/lib/group-component/hook/utils.d.ts +220 -0
  209. package/lib/group-component/hook/utils.js +2468 -0
  210. package/lib/group-component/index.d.ts +2 -0
  211. package/lib/group-component/index.js +9 -0
  212. package/lib/group-component/style.d.ts +22 -0
  213. package/lib/group-component/style.js +55 -0
  214. package/lib/group-component/style.scss +1438 -0
  215. package/lib/group-component/table/Grid.d.ts +33 -0
  216. package/lib/group-component/table/Grid.js +444 -0
  217. package/lib/group-component/table/TableWrapper.d.ts +33 -0
  218. package/lib/group-component/table/TableWrapper.js +259 -0
  219. package/lib/group-component/useContext.d.ts +100 -0
  220. package/lib/group-component/useContext.js +27 -0
  221. package/lib/table-component/InternalTable.js +9 -2
  222. package/lib/table-component/TableContainer.d.ts +1 -0
  223. package/lib/table-component/TableContainer.js +6 -2
  224. package/lib/table-component/TableContainerEdit.d.ts +1 -0
  225. package/lib/table-component/TableContainerEdit.js +4 -2
  226. package/lib/table-component/body/TableBodyCell.js +49 -40
  227. package/lib/table-component/body/TableBodyCellEdit.js +9 -6
  228. package/lib/table-component/body/TableBodyRow.js +4 -1
  229. package/lib/table-component/header/TableHeadCell2.js +38 -2
  230. package/lib/table-component/hook/utils.d.ts +1 -0
  231. package/lib/table-component/hook/utils.js +16 -7
  232. package/lib/table-component/style.js +1 -1
  233. package/lib/table-component/table/Grid.d.ts +1 -0
  234. package/lib/table-component/table/Grid.js +10 -3
  235. package/lib/table-component/useContext.d.ts +6 -0
  236. package/lib/table-component/useContext.js +2 -1
  237. package/lib/table-virtuoso/InternalTable.js +2 -2
  238. package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
  239. package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  240. package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
  241. package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  242. package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
  243. package/lib/table-virtuoso/hook/utils.d.ts +1 -0
  244. package/lib/table-virtuoso/hook/utils.js +32 -1
  245. package/lib/table-virtuoso/style.js +3 -1
  246. package/lib/table-virtuoso/table/Grid.js +2 -2
  247. package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
  248. package/lib/table-virtuoso/table/TableWrapper.js +24 -5
  249. package/lib/table-virtuoso/useContext.d.ts +6 -3
  250. package/lib/table-virtuoso/useContext.js +18 -0
  251. package/package.json +1 -1
@@ -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 TableBodyCellEmpty: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
12
+ export default TableBodyCellEmpty;
@@ -0,0 +1,149 @@
1
+ import ReactDOMServer from 'react-dom/server';
2
+ import { getCommonPinningStyles } from "../hook/utils";
3
+ import classNames from "classnames";
4
+ import React from "react";
5
+ import { TableContext } from "../useContext";
6
+ import { toggleRowSelection } from "../hook/useColumns";
7
+ const TableBodyCellEmpty = props => {
8
+ const {
9
+ cell,
10
+ table,
11
+ isEditing
12
+ } = props;
13
+ const {
14
+ id,
15
+ prefix,
16
+ focusedCell,
17
+ setFocusedCell,
18
+ setIsSelectionChange,
19
+ isSelectionChange,
20
+ selectionSettings,
21
+ wrapSettings,
22
+ setIsSelecting,
23
+ setIsPasting
24
+ } = React.useContext(TableContext);
25
+ const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
26
+ const record = cell.row.original;
27
+ const columnMeta = cell.column.columnDef.meta ?? {};
28
+ const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
29
+
30
+ // const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
31
+ const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
32
+ value: cell.getValue(),
33
+ record
34
+ }) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
35
+ const allRows = table.getRowModel().flatRows;
36
+ const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
37
+ const colIndex = cell.column.getIndex();
38
+ const isPinned = cell.column.getIsPinned();
39
+ const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
40
+ const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
41
+ const enableClick = typeof columnMeta.allowSelection === 'function' ? columnMeta.allowSelection(record) : columnMeta.allowSelection;
42
+ return /*#__PURE__*/React.createElement("div", {
43
+ key: cell.id,
44
+ ref: el => {
45
+ if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
46
+ el?.focus();
47
+ }
48
+ },
49
+ tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
50
+ "data-col-index": colIndex,
51
+ "data-row-index": rowNumber,
52
+ "data-col-key": cell.column.id
53
+ // data-row-key={cell.row.id}
54
+ ,
55
+ "data-tooltip-id": `${id}-tooltip-content`,
56
+ "data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent))
57
+ // data-tooltip-delay-show={500}
58
+ ,
59
+
60
+ className: classNames(`${prefix}-grid-cell`, {
61
+ // [`${prefix}-grid-cell-ellipsis`]: true,
62
+
63
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
64
+ [`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
65
+ // [`${prefix}-grid-cell-selected`]: isCellSelected,
66
+
67
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
68
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
69
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
70
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
71
+ }),
72
+ style: {
73
+ ...cellStyles,
74
+ display: 'flex',
75
+ width: cell.column.getSize(),
76
+ minWidth: cell.column.getSize(),
77
+ minHeight: 36,
78
+ ...getCommonPinningStyles(cell.column)
79
+ },
80
+ onMouseEnter: e => {
81
+ if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
82
+ setIsOpenTooltip(true);
83
+ }
84
+ setIsSelecting?.(false);
85
+ setIsPasting?.(false);
86
+ },
87
+ onKeyDown: e => {
88
+ const flatRows = table.getRowModel().flatRows;
89
+ if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
90
+ const nextIndex = cell.row.index + 1;
91
+ // const nextIndex = rowNumber + 1
92
+
93
+ const nextId = flatRows[nextIndex].id;
94
+ setFocusedCell?.({
95
+ colId: cell.column.id,
96
+ rowId: nextId
97
+ });
98
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
99
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
100
+ if (cellFocus) {
101
+ cellFocus.focus();
102
+ }
103
+ }
104
+ if (e.key === 'ArrowUp' && rowNumber > 0) {
105
+ const prevIndex = cell.row.index - 1;
106
+ const nextId = flatRows[prevIndex].id;
107
+ setFocusedCell?.({
108
+ colId: cell.column.id,
109
+ rowId: nextId
110
+ });
111
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
112
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
113
+ if (cellFocus) {
114
+ cellFocus.focus();
115
+ }
116
+ }
117
+ if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
118
+ toggleRowSelection({
119
+ e,
120
+ cell,
121
+ setIsSelectionChange,
122
+ isSelectionChange,
123
+ selectionSettings
124
+ });
125
+ cell.row.getToggleSelectedHandler()(e);
126
+ }
127
+ },
128
+ onClick: e => {
129
+ const selection = window.getSelection();
130
+ const text = selection ? selection.toString() : "";
131
+ if (text.length > 0 || enableClick === false) {} else {
132
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
133
+ toggleRowSelection({
134
+ e,
135
+ cell,
136
+ setIsSelectionChange,
137
+ isSelectionChange,
138
+ selectionSettings
139
+ });
140
+ setFocusedCell?.({
141
+ colId: cell.column.id,
142
+ rowId: cell.row.id
143
+ });
144
+ }
145
+ }
146
+ }
147
+ });
148
+ };
149
+ export default TableBodyCellEmpty;
@@ -0,0 +1,21 @@
1
+ import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
2
+ import { type Column, type Row, type Table } from "@tanstack/react-table";
3
+ import type { CommandClick } from "../../grid-component/type";
4
+ import React from "react";
5
+ interface TableBodyRowProps<T> {
6
+ tableId: string;
7
+ table: Table<T>;
8
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
9
+ row: Row<T>;
10
+ rowVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
11
+ virtualPaddingLeft: number | undefined;
12
+ virtualPaddingRight: number | undefined;
13
+ virtualRow: VirtualItem;
14
+ fixedLeftColumns: Column<T, unknown>[];
15
+ fixedRightColumns: Column<T, unknown>[];
16
+ commandClick?: (args: CommandClick<T>) => void;
17
+ editAble?: boolean;
18
+ [key: string]: any;
19
+ }
20
+ declare const TableBodyRow: <RecordType extends object>({ tableId, table, columnVirtualizer, row, rowVirtualizer, virtualPaddingLeft, virtualPaddingRight, virtualRow, fixedLeftColumns, fixedRightColumns, commandClick, editAble, isEditing, contextMenuItems, onContextMenu, ...rest }: TableBodyRowProps<RecordType>) => React.JSX.Element;
21
+ export default TableBodyRow;
@@ -0,0 +1,199 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import TableBodyCell from "./TableBodyCell";
3
+ import TableBodyCellEdit from "./TableBodyCellEdit";
4
+ import React from "react";
5
+ import { TableContext } from "../useContext";
6
+ import classNames from "classnames";
7
+ import TableBodyCellEmpty from "./TableBodyCellEmpty";
8
+ // import TableBodyCellEmpty from "./TableBodyCellEmpty"
9
+
10
+ const TableBodyRow = ({
11
+ tableId,
12
+ table,
13
+ columnVirtualizer,
14
+ row,
15
+ rowVirtualizer,
16
+ virtualPaddingLeft,
17
+ virtualPaddingRight,
18
+ virtualRow,
19
+ fixedLeftColumns,
20
+ fixedRightColumns,
21
+ commandClick,
22
+ editAble,
23
+ isEditing,
24
+ contextMenuItems,
25
+ onContextMenu,
26
+ ...rest
27
+ }) => {
28
+ const {
29
+ prefix,
30
+ recordDoubleClick,
31
+ focusedCell,
32
+ rowClassName,
33
+ rowEditable,
34
+ onRowStyles,
35
+ groupColumns
36
+ } = React.useContext(TableContext);
37
+ const visibleCells = row.getVisibleCells();
38
+ const virtualColumns = columnVirtualizer.getVirtualItems();
39
+ const centerCOlumns = virtualColumns.filter(vc => !(table.getState().columnPinning.left?.includes(visibleCells[vc.index].column.id) || table.getState().columnPinning.right?.includes(visibleCells[vc.index].column.id)));
40
+ const leftTemplate = fixedLeftColumns.length > 0 ? fixedLeftColumns.map(it => row.getVisibleCells().find(c => c.column.id === it.id).column.getSize()) : [];
41
+ const rightTemplate = fixedRightColumns.length > 0 ? fixedRightColumns.map(it => row.getVisibleCells().find(c => c.column.id === it.id).column.getSize()) : [];
42
+ const centerTemplate = centerCOlumns.map(it => it.size);
43
+ const virtualLeft = virtualPaddingLeft ? [virtualPaddingLeft] : [];
44
+ const virtualRight = virtualPaddingRight ? [virtualPaddingRight] : [];
45
+ const templateColumns = [...leftTemplate, ...virtualLeft, ...centerTemplate, ...virtualRight, ...rightTemplate];
46
+ const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
47
+ const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
48
+ const isRowEditable = rowEditable ? rowEditable(row.original) : true;
49
+ return /*#__PURE__*/React.createElement("div", {
50
+ "data-index": virtualRow.index //needed for dynamic row height measurement
51
+ ,
52
+ ref: node => rowVirtualizer.measureElement(node) //measure dynamic row height
53
+ ,
54
+ key: row.id,
55
+ "data-row-key": row.id,
56
+ className: classNames(`${prefix}-grid-row ${rowClass ?? ''}`, {
57
+ [`${prefix}-grid-row-selected`]: row.getIsSelected(),
58
+ [`${prefix}-grid-row-focus`]: row.id === focusedCell?.rowId && !editAble,
59
+ [`${prefix}-grid-row-parent`]: row.subRows && row.subRows.length > 0
60
+ }),
61
+ style: {
62
+ // display: 'flex',
63
+ display: 'grid',
64
+ // position: 'absolute',
65
+ transform: `translateY(${virtualRow.start}px)`,
66
+ //this should always be a `style` as it changes on scroll
67
+ // height: isEditing ? '36px' : undefined,
68
+ gridTemplateColumns: `${templateColumns.map(n => `${n}fr`).join(" ")}`,
69
+ height: isEditing ? virtualRow.size : undefined,
70
+ minHeight: isEditing ? undefined : virtualRow.size,
71
+ ...rowStyles
72
+ },
73
+ onDoubleClick: e => {
74
+ recordDoubleClick?.({
75
+ e,
76
+ rowData: row.original,
77
+ rowIndex: row.index
78
+ });
79
+ },
80
+ onContextMenu: e => {
81
+ if (contextMenuItems && contextMenuItems.length) {
82
+ onContextMenu?.(row.original)(e);
83
+ }
84
+ }
85
+ }, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
86
+ const cell = row.getVisibleCells().find(c => c.column.id === column.id);
87
+ if (row.subRows && row.subRows.length === 0 && groupColumns?.includes(cell.column.id)) {
88
+ return /*#__PURE__*/React.createElement(TableBodyCellEmpty, _extends({}, rest, {
89
+ table: table,
90
+ tableId: tableId,
91
+ key: cell.id,
92
+ cell: cell,
93
+ commandClick: commandClick,
94
+ virtualRow: virtualRow,
95
+ isEditing: isEditing,
96
+ isRowEditable: isRowEditable,
97
+ rowVirtualizer: rowVirtualizer,
98
+ columnVirtualizer: columnVirtualizer
99
+ }));
100
+ }
101
+ if (editAble && row.subRows && row.subRows.length === 0) {
102
+ return /*#__PURE__*/React.createElement(TableBodyCellEdit, _extends({}, rest, {
103
+ table: table,
104
+ tableId: tableId,
105
+ key: cell.id,
106
+ cell: cell,
107
+ commandClick: commandClick,
108
+ virtualRow: virtualRow,
109
+ isEditing: isEditing,
110
+ isRowEditable: isRowEditable,
111
+ rowVirtualizer: rowVirtualizer,
112
+ columnVirtualizer: columnVirtualizer
113
+ }));
114
+ }
115
+ return /*#__PURE__*/React.createElement(TableBodyCell, _extends({}, rest, {
116
+ table: table,
117
+ tableId: tableId,
118
+ key: cell.id,
119
+ cell: cell,
120
+ commandClick: commandClick,
121
+ virtualRow: virtualRow,
122
+ isEditing: false,
123
+ rowVirtualizer: rowVirtualizer,
124
+ columnVirtualizer: columnVirtualizer,
125
+ row: row
126
+ }));
127
+ }) : null, virtualPaddingLeft ? /*#__PURE__*/React.createElement("div", {
128
+ className: "",
129
+ style: {
130
+ display: "flex",
131
+ width: virtualPaddingLeft
132
+ }
133
+ }) : null, virtualColumns.map(vc => {
134
+ const cell = visibleCells[vc.index];
135
+ const isFixed = table.getState().columnPinning.left?.includes(cell.column.id) || table.getState().columnPinning.right?.includes(cell.column.id);
136
+ if (cell && !isFixed) {
137
+ if (editAble && row.subRows && row.subRows.length === 0) {
138
+ return /*#__PURE__*/React.createElement(TableBodyCellEdit, _extends({}, rest, {
139
+ table: table,
140
+ key: cell.id,
141
+ tableId: tableId,
142
+ cell: cell,
143
+ commandClick: commandClick,
144
+ isEditing: isEditing,
145
+ isRowEditable: isRowEditable,
146
+ rowVirtualizer: rowVirtualizer,
147
+ columnVirtualizer: columnVirtualizer,
148
+ virtualRow: virtualRow
149
+ }));
150
+ }
151
+ return /*#__PURE__*/React.createElement(TableBodyCell, _extends({}, rest, {
152
+ table: table,
153
+ key: cell.id,
154
+ tableId: tableId,
155
+ cell: cell,
156
+ commandClick: commandClick,
157
+ isEditing: false,
158
+ rowVirtualizer: rowVirtualizer,
159
+ columnVirtualizer: columnVirtualizer,
160
+ virtualRow: virtualRow,
161
+ row: row
162
+ }));
163
+ }
164
+ }), fixedRightColumns.length > 0 ? fixedRightColumns.map(column => {
165
+ if (editAble) {
166
+ return /*#__PURE__*/React.createElement(TableBodyCellEdit, _extends({}, rest, {
167
+ table: table,
168
+ key: column.id,
169
+ tableId: tableId,
170
+ cell: row.getVisibleCells().find(c => c.column.id === column.id),
171
+ commandClick: commandClick,
172
+ isEditing: isEditing,
173
+ isRowEditable: isRowEditable,
174
+ rowVirtualizer: rowVirtualizer,
175
+ columnVirtualizer: columnVirtualizer,
176
+ virtualRow: virtualRow
177
+ }));
178
+ }
179
+ return /*#__PURE__*/React.createElement(TableBodyCell, _extends({}, rest, {
180
+ table: table,
181
+ key: column.id,
182
+ tableId: tableId,
183
+ cell: row.getVisibleCells().find(c => c.column.id === column.id),
184
+ commandClick: commandClick,
185
+ isEditing: false,
186
+ rowVirtualizer: rowVirtualizer,
187
+ columnVirtualizer: columnVirtualizer,
188
+ virtualRow: virtualRow,
189
+ row: row
190
+ }));
191
+ }) : null, virtualPaddingRight ? /*#__PURE__*/React.createElement("div", {
192
+ className: "",
193
+ style: {
194
+ display: "flex",
195
+ width: virtualPaddingRight
196
+ }
197
+ }) : null);
198
+ };
199
+ export default TableBodyRow;
@@ -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;