es-grid-template 1.8.64 → 1.8.65

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 (125) hide show
  1. package/es/grid-component/ColumnsGroup/ColumnsGroup.js +4 -1
  2. package/es/grid-component/TempTable.js +2 -2
  3. package/es/grid-component/hooks/utils.d.ts +2 -8
  4. package/es/grid-component/hooks/utils.js +175 -144
  5. package/es/grid-component/index.d.ts +1 -1
  6. package/es/grid-component/index.js +0 -4
  7. package/es/grid-component/type.d.ts +7 -0
  8. package/es/table-component/type.d.ts +8 -0
  9. package/es/table-virtuoso/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  10. package/es/table-virtuoso/ColumnsGroup/ColumnsGroup.js +232 -0
  11. package/es/table-virtuoso/ColumnsGroup/index.d.ts +1 -0
  12. package/es/table-virtuoso/ColumnsGroup/index.js +1 -0
  13. package/es/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
  14. package/es/table-virtuoso/InternalTable.js +413 -0
  15. package/es/table-virtuoso/body/TableBody.d.ts +14 -0
  16. package/es/table-virtuoso/body/TableBody.js +84 -0
  17. package/es/table-virtuoso/body/TableBodyCell.d.ts +14 -0
  18. package/es/table-virtuoso/body/TableBodyCell.js +466 -0
  19. package/es/table-virtuoso/body/TableBodyRow.d.ts +13 -0
  20. package/es/table-virtuoso/body/TableBodyRow.js +116 -0
  21. package/es/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
  22. package/es/table-virtuoso/footer/TableFooterCell.js +54 -0
  23. package/es/table-virtuoso/header/TableHeadCell.d.ts +14 -0
  24. package/es/table-virtuoso/header/TableHeadCell.js +265 -0
  25. package/es/table-virtuoso/header/renderFilter.d.ts +20 -0
  26. package/es/table-virtuoso/header/renderFilter.js +289 -0
  27. package/es/table-virtuoso/hook/constant.d.ts +73 -0
  28. package/es/table-virtuoso/hook/constant.js +240 -0
  29. package/es/table-virtuoso/hook/convert.d.ts +1 -0
  30. package/es/table-virtuoso/hook/convert.js +28 -0
  31. package/es/table-virtuoso/hook/useColumns.d.ts +28 -0
  32. package/es/table-virtuoso/hook/useColumns.js +302 -0
  33. package/es/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
  34. package/es/table-virtuoso/hook/useFilterOperator.js +33 -0
  35. package/es/table-virtuoso/hook/utils.d.ts +159 -0
  36. package/es/table-virtuoso/hook/utils.js +2263 -0
  37. package/es/table-virtuoso/index.d.ts +2 -0
  38. package/es/table-virtuoso/index.js +2 -0
  39. package/es/table-virtuoso/style.d.ts +22 -0
  40. package/es/table-virtuoso/style.js +11 -0
  41. package/es/table-virtuoso/style.scss +1440 -0
  42. package/es/table-virtuoso/table/Grid.d.ts +37 -0
  43. package/es/table-virtuoso/table/Grid.js +302 -0
  44. package/es/table-virtuoso/table/TableContainer.d.ts +49 -0
  45. package/es/table-virtuoso/table/TableContainer.js +305 -0
  46. package/es/table-virtuoso/table/TableWrapper.d.ts +20 -0
  47. package/es/table-virtuoso/table/TableWrapper.js +158 -0
  48. package/es/table-virtuoso/type.d.ts +0 -0
  49. package/es/table-virtuoso/type.js +785 -0
  50. package/es/table-virtuoso/useContext.d.ts +97 -0
  51. package/es/table-virtuoso/useContext.js +21 -0
  52. package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +4 -1
  53. package/lib/grid-component/TempTable.js +2 -2
  54. package/lib/grid-component/hooks/utils.d.ts +2 -8
  55. package/lib/grid-component/hooks/utils.js +176 -152
  56. package/lib/grid-component/index.d.ts +1 -1
  57. package/lib/grid-component/index.js +0 -3
  58. package/lib/grid-component/type.d.ts +7 -0
  59. package/lib/table-component/type.d.ts +8 -0
  60. package/lib/table-virtuoso/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  61. package/lib/table-virtuoso/ColumnsGroup/ColumnsGroup.js +243 -0
  62. package/lib/table-virtuoso/ColumnsGroup/index.d.ts +1 -0
  63. package/lib/table-virtuoso/ColumnsGroup/index.js +16 -0
  64. package/lib/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
  65. package/lib/table-virtuoso/InternalTable.js +422 -0
  66. package/lib/table-virtuoso/body/TableBody.d.ts +14 -0
  67. package/lib/table-virtuoso/body/TableBody.js +95 -0
  68. package/lib/table-virtuoso/body/TableBodyCell.d.ts +14 -0
  69. package/lib/table-virtuoso/body/TableBodyCell.js +473 -0
  70. package/lib/table-virtuoso/body/TableBodyRow.d.ts +13 -0
  71. package/lib/table-virtuoso/body/TableBodyRow.js +124 -0
  72. package/lib/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
  73. package/lib/table-virtuoso/footer/TableFooterCell.js +63 -0
  74. package/lib/table-virtuoso/header/TableHeadCell.d.ts +14 -0
  75. package/lib/table-virtuoso/header/TableHeadCell.js +274 -0
  76. package/lib/table-virtuoso/header/renderFilter.d.ts +20 -0
  77. package/lib/table-virtuoso/header/renderFilter.js +299 -0
  78. package/lib/table-virtuoso/hook/constant.d.ts +73 -0
  79. package/lib/table-virtuoso/hook/constant.js +247 -0
  80. package/lib/table-virtuoso/hook/convert.d.ts +1 -0
  81. package/lib/table-virtuoso/hook/convert.js +34 -0
  82. package/lib/table-virtuoso/hook/useColumns.d.ts +28 -0
  83. package/lib/table-virtuoso/hook/useColumns.js +315 -0
  84. package/lib/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
  85. package/lib/table-virtuoso/hook/useFilterOperator.js +40 -0
  86. package/lib/table-virtuoso/hook/utils.d.ts +159 -0
  87. package/lib/table-virtuoso/hook/utils.js +2389 -0
  88. package/lib/table-virtuoso/index.d.ts +2 -0
  89. package/lib/table-virtuoso/index.js +9 -0
  90. package/lib/table-virtuoso/style.d.ts +22 -0
  91. package/lib/table-virtuoso/style.js +18 -0
  92. package/lib/table-virtuoso/style.scss +1440 -0
  93. package/lib/table-virtuoso/table/Grid.d.ts +37 -0
  94. package/lib/table-virtuoso/table/Grid.js +311 -0
  95. package/lib/table-virtuoso/table/TableContainer.d.ts +49 -0
  96. package/lib/table-virtuoso/table/TableContainer.js +313 -0
  97. package/lib/table-virtuoso/table/TableWrapper.d.ts +20 -0
  98. package/lib/table-virtuoso/table/TableWrapper.js +164 -0
  99. package/lib/table-virtuoso/type.d.ts +0 -0
  100. package/lib/table-virtuoso/type.js +786 -0
  101. package/lib/table-virtuoso/useContext.d.ts +97 -0
  102. package/lib/table-virtuoso/useContext.js +27 -0
  103. package/package.json +2 -1
  104. package/es/grid-component/ConvertColumnTable.d.ts +0 -7
  105. package/es/grid-component/ConvertColumnTable.js +0 -144
  106. package/es/grid-component/InternalTable.js +0 -1170
  107. package/es/grid-component/table/Grid.d.ts +0 -23
  108. package/es/grid-component/table/Grid.js +0 -49
  109. package/es/grid-component/table/GridEdit.d.ts +0 -23
  110. package/es/grid-component/table/GridEdit.js +0 -2726
  111. package/es/grid-component/table/Group.d.ts +0 -21
  112. package/es/grid-component/table/Group.js +0 -195
  113. package/es/grid-component/table/InfiniteTable.d.ts +0 -23
  114. package/es/grid-component/table/InfiniteTable.js +0 -101
  115. package/lib/grid-component/ConvertColumnTable.d.ts +0 -7
  116. package/lib/grid-component/ConvertColumnTable.js +0 -153
  117. package/lib/grid-component/InternalTable.js +0 -1178
  118. package/lib/grid-component/table/Grid.d.ts +0 -23
  119. package/lib/grid-component/table/Grid.js +0 -58
  120. package/lib/grid-component/table/GridEdit.d.ts +0 -23
  121. package/lib/grid-component/table/GridEdit.js +0 -2723
  122. package/lib/grid-component/table/Group.d.ts +0 -21
  123. package/lib/grid-component/table/Group.js +0 -204
  124. package/lib/grid-component/table/InfiniteTable.d.ts +0 -23
  125. package/lib/grid-component/table/InfiniteTable.js +0 -109
@@ -0,0 +1,84 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import TableBodyRow from "./TableBodyRow";
3
+ // import type { Virtualizer } from "@tanstack/react-virtual";
4
+ import { useVirtualizer } from "@tanstack/react-virtual";
5
+ // import type { Dispatch, SetStateAction } from "react";
6
+ import React, { Fragment } from "react";
7
+ import { TableContext } from "../useContext";
8
+ import { Empty } from "rc-master-ui";
9
+ const TableBody = ({
10
+ columnVirtualizer,
11
+ table,
12
+ tableContainerRef,
13
+ virtualPaddingLeft,
14
+ virtualPaddingRight,
15
+ fixedLeftColumns,
16
+ fixedRightColumns,
17
+ tableId,
18
+ showEmptyText,
19
+ ...rest
20
+ }) => {
21
+ const {
22
+ rows
23
+ } = table.getRowModel();
24
+ const {
25
+ editingKey,
26
+ prefix,
27
+ locale
28
+ } = React.useContext(TableContext);
29
+
30
+ //dynamic row height virtualization - alternatively you could use a simpler fixed row height strategy without the need for `measureElement`
31
+ const rowVirtualizer = useVirtualizer({
32
+ count: rows.length,
33
+ estimateSize: () => 36,
34
+ //estimate row height for accurate scrollbar dragging
35
+ getScrollElement: () => tableContainerRef.current,
36
+ //measure dynamic row height, except in firefox because it measures table border height incorrectly
37
+ measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
38
+ overscan: 1
39
+ });
40
+ const virtualRows = rowVirtualizer.getVirtualItems();
41
+ return /*#__PURE__*/React.createElement("div", {
42
+ className: `${prefix}-grid-tbody`,
43
+ style: {
44
+ display: 'grid',
45
+ // height: `${rowVirtualizer.getTotalSize()}px`, //tells scrollbar how big the table is
46
+ height: showEmptyText && rows.length === 0 ? `140px` : `${rowVirtualizer.getTotalSize()}px`,
47
+ //tells scrollbar how big the table is
48
+ position: 'relative' //needed for absolute positioning of rows
49
+ }
50
+ }, showEmptyText && rows.length === 0 ? /*#__PURE__*/React.createElement("tr", {
51
+ style: {
52
+ // transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll
53
+ }
54
+ }, /*#__PURE__*/React.createElement("td", {
55
+ // colSpan={30}
56
+ style: {
57
+ position: "sticky",
58
+ left: 0,
59
+ width: tableContainerRef.current?.clientWidth,
60
+ overflow: 'hidden'
61
+ }
62
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Empty, {
63
+ image: Empty.PRESENTED_IMAGE_SIMPLE,
64
+ description: locale?.emptyText
65
+ })))) : /*#__PURE__*/React.createElement(Fragment, null, virtualRows.map(virtualRow => {
66
+ const row = rows[virtualRow.index];
67
+ const isEditing = row.id === editingKey;
68
+ return /*#__PURE__*/React.createElement(TableBodyRow, _extends({}, rest, {
69
+ table: table,
70
+ tableId: tableId,
71
+ key: row.id,
72
+ row: row,
73
+ columnVirtualizer: columnVirtualizer,
74
+ rowVirtualizer: rowVirtualizer,
75
+ virtualPaddingLeft: virtualPaddingLeft,
76
+ virtualPaddingRight: virtualPaddingRight,
77
+ virtualRow: virtualRow,
78
+ fixedLeftColumns: fixedLeftColumns,
79
+ fixedRightColumns: fixedRightColumns,
80
+ isEditing: isEditing
81
+ }));
82
+ })));
83
+ };
84
+ export default TableBody;
@@ -0,0 +1,14 @@
1
+ import type { Cell, Table } from "@tanstack/react-table";
2
+ import type { CommandClick } from "../../table-component/type";
3
+ import React from "react";
4
+ import type { VirtualItem } from "@tanstack/react-virtual";
5
+ interface TableBodyCellProps<T> {
6
+ table: Table<T>;
7
+ tableId: string;
8
+ cell: Cell<T, unknown>;
9
+ commandClick?: (args: CommandClick<T>) => void;
10
+ virtualRow: VirtualItem;
11
+ [key: string]: any;
12
+ }
13
+ declare const TableBodyCell: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
14
+ export default TableBodyCell;
@@ -0,0 +1,466 @@
1
+ import { flexRender } from "@tanstack/react-table";
2
+ import Space from "rc-master-ui/es/space";
3
+ // import Command from "../components/command/Command";
4
+
5
+ import ReactDOMServer from 'react-dom/server';
6
+ import { getCommonPinningStyles } from "../hook/utils";
7
+ import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
8
+ import classNames from "classnames";
9
+ import React from "react";
10
+ import { TableContext } from "../useContext";
11
+ import { toggleRowSelection } from "../hook/useColumns";
12
+ import Command from "../../table-component/components/command/Command";
13
+ const renderCellIndex = props => {
14
+ const {
15
+ cell,
16
+ pagination
17
+ } = props;
18
+ const parrents = cell.row.getParentRows();
19
+ if (parrents && parrents.length > 0) {
20
+ return /*#__PURE__*/React.createElement("span", {
21
+ className: "ui-rc_cell-content"
22
+ }, parrents.map(pr => {
23
+ return `${pr.index + 1}.`;
24
+ }), cell.row.index + 1);
25
+ }
26
+ if (pagination && pagination.onChange) {
27
+ return /*#__PURE__*/React.createElement("span", {
28
+ className: "ui-rc_cell-content"
29
+ }, cell.row.index + (pagination ? ((pagination.currentPage ?? 1) - 1) * (pagination?.pageSize ?? 0) : 0) + 1);
30
+ }
31
+ return /*#__PURE__*/React.createElement("span", {
32
+ className: "ui-rc_cell-content"
33
+ }, cell.row.index + 1);
34
+ };
35
+ const renderCommand = args => {
36
+ const {
37
+ cell,
38
+ commandClick,
39
+ id,
40
+ data
41
+ } = args;
42
+ const col = cell.column.columnDef.meta ?? {};
43
+ const record = cell.row.original;
44
+
45
+ // const commandItems = args.cell.column.columnDef?.meta?.commandItems ?? []
46
+
47
+ const commands = col.commandItems ? col.commandItems.map(it => {
48
+ return {
49
+ ...it,
50
+ visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
51
+ };
52
+ }) : [];
53
+ return /*#__PURE__*/React.createElement("div", {
54
+ className: "ui-rc_cell-content"
55
+ }, /*#__PURE__*/React.createElement(Space, null, commands.filter(it => it.visible !== false).map(item => {
56
+ return /*#__PURE__*/React.createElement(Command, {
57
+ id: id,
58
+ key: item.id,
59
+ item: item,
60
+ record: record,
61
+ onClick: () => {
62
+ commandClick?.({
63
+ id: item.id,
64
+ // rowId: getRowKey(record, index) as any,
65
+ rowId: record.rowId,
66
+ rowData: record,
67
+ index: cell.row.index,
68
+ rows: [...data]
69
+ });
70
+ }
71
+ });
72
+ })));
73
+ };
74
+ const renderSelection = args => {
75
+ const {
76
+ row
77
+ } = args.cell;
78
+ const {
79
+ cell,
80
+ expandIconColumnIndex,
81
+ isDataTree,
82
+ expanded,
83
+ setExpanded
84
+ } = args;
85
+ const {
86
+ selectionSettings,
87
+ setIsSelectionChange,
88
+ isSelectionChange
89
+ } = args;
90
+ const checked = selectionSettings?.type === 'single' || selectionSettings?.checkStrictly ? row.getIsSelected() : row.getIsSelected() || row.getIsAllSubRowsSelected();
91
+ const indeterminate = selectionSettings?.type === 'single' || selectionSettings?.checkStrictly ? false : row.getIsSomeSelected() && selectionSettings && selectionSettings.mode === 'checkbox' || row.getIsSomeSelected();
92
+ return /*#__PURE__*/React.createElement("div", {
93
+ style: {}
94
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
95
+ className: "ui-rc-table-row-expand-trigger",
96
+ style: {
97
+ paddingLeft: `${cell.row.depth * 25}px`
98
+ }
99
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
100
+ // onClick: row.getToggleExpandedHandler(),
101
+ onClick: () => {
102
+ const keys = Object.keys(expanded);
103
+ // @ts-ignore
104
+ const tmp = {
105
+ ...expanded
106
+ };
107
+ if (keys.includes(cell.row.id)) {
108
+ delete tmp[cell.row.id];
109
+ setExpanded(tmp);
110
+ } else {
111
+ setExpanded(old => ({
112
+ ...old,
113
+ [cell.row.id]: true
114
+ }));
115
+ }
116
+ },
117
+ style: {
118
+ cursor: "pointer"
119
+ },
120
+ className: "ui-rc-table-row-expand"
121
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
122
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
123
+ }) : /*#__PURE__*/React.createElement("span", {
124
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
125
+ })) : /*#__PURE__*/React.createElement("span", {
126
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
127
+ }))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Checkbox, {
128
+ checked: checked,
129
+ indeterminate: indeterminate,
130
+ onChange: e => {
131
+ toggleRowSelection({
132
+ e,
133
+ cell,
134
+ setIsSelectionChange,
135
+ isSelectionChange,
136
+ selectionSettings
137
+ });
138
+ },
139
+ disabled: !row.getCanSelect()
140
+ })));
141
+ };
142
+ const TableBodyCell = props => {
143
+ const {
144
+ cell,
145
+ commandClick,
146
+ // tableId,
147
+ table,
148
+ isEditing,
149
+ colSpan,
150
+ groupValue
151
+ } = props;
152
+ const {
153
+ id,
154
+ prefix,
155
+ focusedCell,
156
+ setFocusedCell,
157
+ // endCell,
158
+ // startCell,
159
+ originData,
160
+ expanded,
161
+ setExpanded,
162
+ expandable,
163
+ isDataTree,
164
+ setIsSelectionChange,
165
+ isSelectionChange,
166
+ selectionSettings,
167
+ wrapSettings,
168
+ pagination
169
+ // dataSource
170
+ } = React.useContext(TableContext);
171
+ const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
172
+ const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
173
+ const record = cell.row.original;
174
+ const columnMeta = cell.column.columnDef.meta ?? {};
175
+ const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
176
+
177
+ // const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
178
+ const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
179
+ value: cell.getValue(),
180
+ record
181
+ }) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
182
+ const allRows = table.getRowModel().flatRows;
183
+ const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
184
+ const colIndex = cell.column.getIndex();
185
+ const isPinned = cell.column.getIsPinned();
186
+ const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
187
+ const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
188
+ const enableClick = typeof columnMeta.allowSelection === 'function' ? columnMeta.allowSelection(record) : columnMeta.allowSelection;
189
+
190
+ // const firstVisibleNormalColumn = table.getVisibleLeafColumns().filter(col => col.id !== 'selection' && col.id !== '#')[0];
191
+ // const firstVisibleNormalColumn = table.getVisibleLeafColumns().filter(col => col.id !== 'selection' && col.id !== '#')[0];
192
+
193
+ // const parrents = cell.row.getParentRows();
194
+
195
+ if (cell.column.id === "#") {
196
+ return /*#__PURE__*/React.createElement("td", {
197
+ key: cell.id,
198
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-index`, {
199
+ [`${prefix}-grid-cell-ellipsis`]: true,
200
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
201
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
202
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
203
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
204
+ }),
205
+ style: {
206
+ ...cellStyles,
207
+ // display: 'flex',
208
+ userSelect: 'none',
209
+ width: cell.column.getSize(),
210
+ minWidth: cell.column.getSize(),
211
+ ...getCommonPinningStyles(cell.column)
212
+ },
213
+ onClick: e => {
214
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
215
+ toggleRowSelection({
216
+ e,
217
+ cell,
218
+ setIsSelectionChange,
219
+ isSelectionChange,
220
+ selectionSettings
221
+ });
222
+ }
223
+ }
224
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
225
+ className: "ui-rc-table-row-expand-trigger",
226
+ style: {
227
+ paddingLeft: `${cell.row.depth * 25}px`
228
+ }
229
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
230
+ // onClick: cell.row.getToggleExpandedHandler(),
231
+ onClick: () => {
232
+ const keys = Object.keys(expanded);
233
+ // @ts-ignore
234
+ const tmp = {
235
+ ...expanded
236
+ };
237
+ if (keys.includes(cell.row.id)) {
238
+ delete tmp[cell.row.id];
239
+ setExpanded(tmp);
240
+ } else {
241
+ setExpanded(old => ({
242
+ ...old,
243
+ [cell.row.id]: true
244
+ }));
245
+ }
246
+ },
247
+ style: {
248
+ cursor: "pointer"
249
+ },
250
+ className: "ui-rc-table-row-expand"
251
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
252
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
253
+ }) : /*#__PURE__*/React.createElement("span", {
254
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
255
+ })) : /*#__PURE__*/React.createElement("span", {
256
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
257
+ }))), renderCellIndex({
258
+ cell,
259
+ pagination
260
+ }));
261
+ }
262
+ if (cell.column.id === "command") {
263
+ return /*#__PURE__*/React.createElement("td", {
264
+ key: cell.id,
265
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-command`, {
266
+ [`${prefix}-grid-cell-ellipsis`]: true,
267
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
268
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
269
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
270
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
271
+ }),
272
+ style: {
273
+ ...cellStyles,
274
+ // display: 'flex',
275
+ width: cell.column.getSize(),
276
+ minWidth: cell.column.getSize(),
277
+ ...getCommonPinningStyles(cell.column)
278
+ }
279
+ }, renderCommand({
280
+ cell,
281
+ commandClick,
282
+ id,
283
+ data: originData
284
+ }));
285
+ }
286
+ if (cell.column.id === "selection_column") {
287
+ return /*#__PURE__*/React.createElement("td", {
288
+ key: cell.id,
289
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-selection`, {
290
+ [`${prefix}-grid-cell-ellipsis`]: true,
291
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
292
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
293
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
294
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
295
+ }),
296
+ style: {
297
+ ...cellStyles,
298
+ // display: 'flex',
299
+ minHeight: 36,
300
+ width: cell.column.getSize(),
301
+ minWidth: cell.column.getSize(),
302
+ ...getCommonPinningStyles(cell.column)
303
+ }
304
+ }, /*#__PURE__*/React.createElement("div", {
305
+ className: classNames('ui-rc_cell-content', {})
306
+ }, cell.column.id === "selection_column" && renderSelection({
307
+ cell,
308
+ table,
309
+ selectionSettings,
310
+ setIsSelectionChange,
311
+ expanded,
312
+ isDataTree,
313
+ setExpanded,
314
+ expandIconColumnIndex,
315
+ isSelectionChange
316
+ })));
317
+ }
318
+ return /*#__PURE__*/React.createElement("td", {
319
+ key: cell.id,
320
+ colSpan: colSpan,
321
+ ref: el => {
322
+ if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
323
+ el?.focus();
324
+ }
325
+ },
326
+ tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
327
+ "data-col-index": colIndex,
328
+ "data-row-index": rowNumber,
329
+ "data-col-key": cell.column.id
330
+ // data-row-key={cell.row.id}
331
+ ,
332
+ "data-tooltip-id": `${id}-tooltip-content`,
333
+ "data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent))
334
+ // data-tooltip-delay-show={500}
335
+ ,
336
+
337
+ className: classNames(`${prefix}-grid-cell`, {
338
+ // [`${prefix}-grid-cell-ellipsis`]: true,
339
+
340
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
341
+ [`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
342
+ // [`${prefix}-grid-cell-selected`]: isCellSelected,
343
+
344
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
345
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
346
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
347
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
348
+ }),
349
+ style: {
350
+ ...cellStyles,
351
+ // display: 'flex',
352
+ width: cell.column.getSize(),
353
+ minWidth: cell.column.getSize(),
354
+ minHeight: 36,
355
+ ...getCommonPinningStyles(cell.column)
356
+ },
357
+ onMouseEnter: e => {
358
+ if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
359
+ setIsOpenTooltip(true);
360
+ }
361
+ },
362
+ onKeyDown: e => {
363
+ const flatRows = table.getRowModel().flatRows;
364
+ if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
365
+ const nextIndex = cell.row.index + 1;
366
+ // const nextIndex = rowNumber + 1
367
+
368
+ const nextId = flatRows[nextIndex].id;
369
+ setFocusedCell?.({
370
+ colId: cell.column.id,
371
+ rowId: nextId
372
+ });
373
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
374
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
375
+ if (cellFocus) {
376
+ cellFocus.focus();
377
+ }
378
+ }
379
+ if (e.key === 'ArrowUp' && rowNumber > 0) {
380
+ const prevIndex = cell.row.index - 1;
381
+ const nextId = flatRows[prevIndex].id;
382
+ setFocusedCell?.({
383
+ colId: cell.column.id,
384
+ rowId: nextId
385
+ });
386
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
387
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
388
+ if (cellFocus) {
389
+ cellFocus.focus();
390
+ }
391
+ }
392
+ if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
393
+ toggleRowSelection({
394
+ e,
395
+ cell,
396
+ setIsSelectionChange,
397
+ isSelectionChange,
398
+ selectionSettings
399
+ });
400
+ cell.row.getToggleSelectedHandler()(e);
401
+ }
402
+ },
403
+ onClick: e => {
404
+ const selection = window.getSelection();
405
+ const text = selection ? selection.toString() : "";
406
+ if (text.length > 0 || enableClick === false) {} else {
407
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
408
+ toggleRowSelection({
409
+ e,
410
+ cell,
411
+ setIsSelectionChange,
412
+ isSelectionChange,
413
+ selectionSettings
414
+ });
415
+ setFocusedCell?.({
416
+ colId: cell.column.id,
417
+ rowId: cell.row.id
418
+ });
419
+ }
420
+ }
421
+ }
422
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree ? /*#__PURE__*/React.createElement("div", {
423
+ className: classNames('ui-rc_cell-content', {})
424
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
425
+ className: "ui-rc-table-row-expand-trigger",
426
+ style: {
427
+ paddingLeft: `${cell.row.depth * 25}px`
428
+ }
429
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
430
+ // onClick: cell.row.getToggleExpandedHandler(),
431
+
432
+ // onClick: (e) => {
433
+ // e.stopPropagation()
434
+ // cell.row.toggleExpanded()
435
+ // },
436
+
437
+ onClick: e => {
438
+ e.stopPropagation();
439
+ const keys = Object.keys(expanded);
440
+ // @ts-ignore
441
+ const tmp = {
442
+ ...expanded
443
+ };
444
+ if (keys.includes(cell.row.id)) {
445
+ delete tmp[cell.row.id];
446
+ setExpanded(tmp);
447
+ } else {
448
+ setExpanded(old => ({
449
+ ...old,
450
+ [cell.row.id]: true
451
+ }));
452
+ }
453
+ },
454
+ style: {
455
+ cursor: "pointer"
456
+ },
457
+ className: "ui-rc-table-row-expand"
458
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
459
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
460
+ }) : /*#__PURE__*/React.createElement("span", {
461
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
462
+ })) : /*#__PURE__*/React.createElement("span", {
463
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
464
+ }))), groupValue ? groupValue : flexRender(cell.column.columnDef.cell, cell.getContext())) : /*#__PURE__*/React.createElement(React.Fragment, null, groupValue ? groupValue : flexRender(cell.column.columnDef.cell, cell.getContext())));
465
+ };
466
+ export default TableBodyCell;
@@ -0,0 +1,13 @@
1
+ import { type Row, type Table } from "@tanstack/react-table";
2
+ import type { CommandClick } from "../../table-component/type";
3
+ import React from "react";
4
+ interface TableBodyRowProps<T> {
5
+ tableId: string;
6
+ table: Table<T>;
7
+ row: Row<T>;
8
+ commandClick?: (args: CommandClick<T>) => void;
9
+ editAble?: boolean;
10
+ [key: string]: any;
11
+ }
12
+ declare const TableBodyRow: <RecordType extends object>({ tableId, table, row, virtualRow, commandClick, contextMenuItems, onContextMenu, ...rest }: TableBodyRowProps<RecordType>) => React.JSX.Element;
13
+ export default TableBodyRow;
@@ -0,0 +1,116 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ // import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual"
3
+ import TableBodyCell from "./TableBodyCell";
4
+ import { flexRender } from "@tanstack/react-table";
5
+ import React from "react";
6
+ import { TableContext } from "../useContext";
7
+ import classNames from "classnames";
8
+ const TableBodyRow = ({
9
+ tableId,
10
+ table,
11
+ row,
12
+ virtualRow,
13
+ commandClick,
14
+ contextMenuItems,
15
+ onContextMenu,
16
+ ...rest
17
+ }) => {
18
+ const {
19
+ prefix,
20
+ recordDoubleClick,
21
+ focusedCell,
22
+ rowClassName,
23
+ onRowStyles,
24
+ groupSetting
25
+ } = React.useContext(TableContext);
26
+ const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
27
+ const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
28
+ const visibleCells = row.getVisibleCells();
29
+ const allCells = row.getAllCells();
30
+ return /*#__PURE__*/React.createElement("tr", _extends({
31
+ key: row.id,
32
+ "data-row-key": row.id
33
+ }, rest, {
34
+ className: classNames(`${prefix}-grid-row ${rowClass ?? ''}`, {
35
+ [`${prefix}-grid-row-selected`]: row.getIsSelected(),
36
+ [`${prefix}-grid-row-focus`]: row.id === focusedCell?.rowId,
37
+ [`${prefix}-grid-row-parent`]: row.subRows && row.subRows.length > 0
38
+ }),
39
+ style: {
40
+ ...rowStyles
41
+ },
42
+ onDoubleClick: e => {
43
+ recordDoubleClick?.({
44
+ e,
45
+ rowData: row.original,
46
+ rowIndex: row.index
47
+ });
48
+ },
49
+ onContextMenu: e => {
50
+ if (contextMenuItems && contextMenuItems.length) {
51
+ onContextMenu?.(row.original)(e);
52
+ }
53
+ }
54
+ }), visibleCells.map(cell => {
55
+ const nonGroupColumns = visibleCells.filter(col => col.column.id !== 'selection_column' && col.column.id !== '#');
56
+ const firstNonGroupColumn = nonGroupColumns[0];
57
+
58
+ // const colSpan = row.subRows && cell.column.id === firstNonGroupColumn?.id ? (groupSetting?.groupColumnSpan ?? 2)
59
+ const colSpan = row.subRows && row.subRows.length > 0 && cell.column.id === firstNonGroupColumn?.column.id ? 2 : row.subRows && nonGroupColumns[1].column.id === cell.column.id ? 0 : 1;
60
+ if (row.subRows && row.subRows.length > 0 && colSpan === 0) {
61
+ return null;
62
+ }
63
+
64
+ // if (groupAble && column.field === firstNonGroupColumn?.field && row.subRows) {
65
+ if (cell.column.id === firstNonGroupColumn.column.id && row.subRows && row.subRows.length > 0) {
66
+ const {
67
+ field
68
+ } = row.original ?? {};
69
+ const cellGroup = allCells.find(it => it.column.id === field);
70
+
71
+ // const header = allColumns.find((it) => it.id === field)
72
+
73
+ const headerContext = cellGroup && groupSetting?.showHeaderColumn !== false ? {
74
+ table,
75
+ column: cellGroup.column,
76
+ header: {
77
+ id: cellGroup.column.id,
78
+ column: cellGroup.column,
79
+ depth: 0,
80
+ index: 0,
81
+ subHeaders: []
82
+ }
83
+ } : undefined;
84
+ const cellValue = cellGroup ? cellGroup.getValue() : '';
85
+ const headertext = headerContext && cellGroup ? flexRender(cellGroup.column.columnDef.header, headerContext) : '';
86
+ const cellContent = cellGroup ? flexRender(cellGroup.column.columnDef.cell, cellGroup.getContext()) : '';
87
+ const groupValue = typeof groupSetting?.groupTemplate === 'function' ? groupSetting?.groupTemplate({
88
+ column: cellGroup?.column.columnDef.meta,
89
+ rowData: row.original,
90
+ value: cellValue
91
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, headertext, headertext ? ': ' : '', " ", cellContent);
92
+ return /*#__PURE__*/React.createElement(TableBodyCell, {
93
+ table: table,
94
+ tableId: tableId,
95
+ key: cell.id,
96
+ cell: cell,
97
+ commandClick: commandClick,
98
+ virtualRow: virtualRow,
99
+ isEditing: false,
100
+ colSpan: colSpan ?? 1,
101
+ groupValue: groupValue
102
+ });
103
+ }
104
+ return /*#__PURE__*/React.createElement(TableBodyCell, {
105
+ table: table,
106
+ tableId: tableId,
107
+ key: cell.id,
108
+ cell: cell,
109
+ commandClick: commandClick,
110
+ virtualRow: virtualRow,
111
+ isEditing: false,
112
+ colSpan: colSpan ?? 1
113
+ });
114
+ }));
115
+ };
116
+ export default TableBodyRow;