es-grid-template 1.7.26 → 1.7.28
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.
- package/es/grid-component/InternalTable.js +31 -36
- package/es/grid-component/TempTable.d.ts +4 -0
- package/es/grid-component/TempTable.js +21 -0
- package/es/grid-component/hooks/columns/index.js +3 -1
- package/es/grid-component/index.d.ts +2 -2
- package/es/grid-component/index.js +6 -4
- package/es/grid-component/styles.scss +0 -1
- package/es/grid-component/table/GridEdit.js +112 -96
- package/es/grid-component/type.d.ts +7 -1
- package/es/table-component/InternalTable.js +160 -122
- package/es/table-component/TableContainer.d.ts +6 -0
- package/es/table-component/TableContainer.js +74 -70
- package/es/table-component/TableContainerEdit.d.ts +6 -0
- package/es/table-component/TableContainerEdit.js +372 -92
- package/es/table-component/body/TableBody.d.ts +2 -8
- package/es/table-component/body/TableBody.js +28 -0
- package/es/table-component/body/TableBodyCell.d.ts +1 -1
- package/es/table-component/body/TableBodyCell.js +28 -14
- package/es/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/es/table-component/body/TableBodyCellEdit.js +44 -28
- package/es/table-component/body/TableBodyRow.d.ts +3 -3
- package/es/table-component/body/TableBodyRow.js +4 -6
- package/es/table-component/footer/TableFooter.d.ts +2 -8
- package/es/table-component/footer/TableFooter.js +14 -13
- package/es/table-component/footer/TableFooterCell.d.ts +3 -6
- package/es/table-component/footer/TableFooterCell.js +14 -11
- package/es/table-component/footer/TableFooterRow.d.ts +2 -8
- package/es/table-component/footer/TableFooterRow.js +23 -48
- package/es/table-component/header/TableHead.d.ts +4 -3
- package/es/table-component/header/TableHead.js +6 -28
- package/es/table-component/header/TableHeadCell.d.ts +2 -3
- package/es/table-component/header/TableHeadCell.js +25 -55
- package/es/table-component/header/TableHeadRow.d.ts +6 -7
- package/es/table-component/header/TableHeadRow.js +37 -62
- package/es/table-component/hook/convert.d.ts +1 -0
- package/es/table-component/hook/convert.js +28 -0
- package/es/table-component/hook/useColumns.js +1 -0
- package/es/table-component/hook/utils.js +3 -0
- package/es/table-component/style.scss +61 -50
- package/es/table-component/table/Grid.d.ts +3 -0
- package/es/table-component/table/Grid.js +9 -5
- package/es/table-component/table/TableWrapper.d.ts +32 -0
- package/es/table-component/table/TableWrapper.js +242 -0
- package/es/table-component/type.d.ts +9 -4
- package/es/table-component/useContext.d.ts +4 -0
- package/es/table-component/useContext.js +4 -0
- package/lib/grid-component/InternalTable.js +30 -35
- package/lib/grid-component/TempTable.d.ts +4 -0
- package/lib/grid-component/TempTable.js +30 -0
- package/lib/grid-component/hooks/columns/index.js +3 -1
- package/lib/grid-component/index.d.ts +2 -2
- package/lib/grid-component/index.js +5 -3
- package/lib/grid-component/styles.scss +0 -1
- package/lib/grid-component/table/GridEdit.js +112 -96
- package/lib/grid-component/type.d.ts +7 -1
- package/lib/table-component/InternalTable.js +161 -122
- package/lib/table-component/TableContainer.d.ts +6 -0
- package/lib/table-component/TableContainer.js +76 -70
- package/lib/table-component/TableContainerEdit.d.ts +6 -0
- package/lib/table-component/TableContainerEdit.js +368 -90
- package/lib/table-component/body/TableBody.d.ts +2 -8
- package/lib/table-component/body/TableBody.js +29 -0
- package/lib/table-component/body/TableBodyCell.d.ts +1 -1
- package/lib/table-component/body/TableBodyCell.js +28 -14
- package/lib/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/lib/table-component/body/TableBodyCellEdit.js +44 -28
- package/lib/table-component/body/TableBodyRow.d.ts +3 -3
- package/lib/table-component/body/TableBodyRow.js +4 -6
- package/lib/table-component/footer/TableFooter.d.ts +2 -8
- package/lib/table-component/footer/TableFooter.js +15 -13
- package/lib/table-component/footer/TableFooterCell.d.ts +3 -6
- package/lib/table-component/footer/TableFooterCell.js +15 -11
- package/lib/table-component/footer/TableFooterRow.d.ts +2 -8
- package/lib/table-component/footer/TableFooterRow.js +23 -48
- package/lib/table-component/header/TableHead.d.ts +4 -3
- package/lib/table-component/header/TableHead.js +6 -28
- package/lib/table-component/header/TableHeadCell.d.ts +2 -3
- package/lib/table-component/header/TableHeadCell.js +25 -54
- package/lib/table-component/header/TableHeadRow.d.ts +6 -7
- package/lib/table-component/header/TableHeadRow.js +37 -62
- package/lib/table-component/hook/convert.d.ts +1 -0
- package/lib/table-component/hook/convert.js +34 -0
- package/lib/table-component/hook/useColumns.js +1 -0
- package/lib/table-component/hook/utils.js +3 -0
- package/lib/table-component/style.scss +61 -50
- package/lib/table-component/table/Grid.d.ts +3 -0
- package/lib/table-component/table/Grid.js +9 -5
- package/lib/table-component/table/TableWrapper.d.ts +32 -0
- package/lib/table-component/table/TableWrapper.js +251 -0
- package/lib/table-component/type.d.ts +9 -4
- package/lib/table-component/useContext.d.ts +4 -0
- package/lib/table-component/useContext.js +4 -0
- package/package.json +1 -1
|
@@ -13,7 +13,9 @@ const renderCellIndex = props => {
|
|
|
13
13
|
parrents,
|
|
14
14
|
cell
|
|
15
15
|
} = props;
|
|
16
|
-
return /*#__PURE__*/React.createElement("span",
|
|
16
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
17
|
+
className: "ui-rc_cell-content"
|
|
18
|
+
}, parrents.map(pr => {
|
|
17
19
|
return `${pr.index + 1}.`;
|
|
18
20
|
}), cell.row.index + 1);
|
|
19
21
|
};
|
|
@@ -21,7 +23,8 @@ const renderCommand = args => {
|
|
|
21
23
|
const {
|
|
22
24
|
cell,
|
|
23
25
|
commandClick,
|
|
24
|
-
id
|
|
26
|
+
id,
|
|
27
|
+
data
|
|
25
28
|
} = args;
|
|
26
29
|
const col = cell.column.columnDef.meta ?? {};
|
|
27
30
|
const record = cell.row.original;
|
|
@@ -34,7 +37,9 @@ const renderCommand = args => {
|
|
|
34
37
|
visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
|
|
35
38
|
};
|
|
36
39
|
}) : [];
|
|
37
|
-
return /*#__PURE__*/React.createElement(
|
|
40
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
41
|
+
className: "ui-rc_cell-content"
|
|
42
|
+
}, /*#__PURE__*/React.createElement(Space, null, commands.filter(it => it.visible !== false).map(item => {
|
|
38
43
|
return /*#__PURE__*/React.createElement(Command, {
|
|
39
44
|
id: id,
|
|
40
45
|
key: item.id,
|
|
@@ -43,15 +48,14 @@ const renderCommand = args => {
|
|
|
43
48
|
onClick: () => {
|
|
44
49
|
commandClick?.({
|
|
45
50
|
id: item.id,
|
|
46
|
-
// rowId: getRowKey(record, index) as any,
|
|
47
51
|
rowId: record.rowId,
|
|
48
52
|
rowData: record,
|
|
49
|
-
index: cell.row.index
|
|
50
|
-
|
|
53
|
+
index: cell.row.index,
|
|
54
|
+
rows: [...data]
|
|
51
55
|
});
|
|
52
56
|
}
|
|
53
57
|
});
|
|
54
|
-
}));
|
|
58
|
+
})));
|
|
55
59
|
};
|
|
56
60
|
const renderSelection = args => {
|
|
57
61
|
const {
|
|
@@ -96,25 +100,32 @@ const TableBodyCell = props => {
|
|
|
96
100
|
prefix,
|
|
97
101
|
setIsSelectionChange,
|
|
98
102
|
selectionSettings,
|
|
99
|
-
id
|
|
103
|
+
id,
|
|
104
|
+
originData,
|
|
105
|
+
wrapSettings
|
|
100
106
|
} = useContext(TableContext);
|
|
107
|
+
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
101
108
|
const parrents = cell.row.getParentRows();
|
|
102
109
|
const isPinned = cell.column.getIsPinned();
|
|
103
110
|
const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
104
111
|
const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
105
|
-
const cellContent = flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
112
|
+
const cellContent = columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
106
113
|
const html = ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, cellContent));
|
|
107
114
|
const hasValue = html.trim().length > 0;
|
|
108
115
|
return /*#__PURE__*/React.createElement("td", {
|
|
109
116
|
key: cell.id,
|
|
110
117
|
className: classNames(`${prefix}-grid-cell`, {
|
|
111
|
-
[`${prefix}-grid-cell-ellipsis`]:
|
|
118
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
|
|
119
|
+
[`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
|
|
112
120
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
113
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
121
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
122
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
123
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right' || columnMeta.type === 'number'
|
|
114
124
|
}),
|
|
115
125
|
style: {
|
|
116
|
-
display: 'flex',
|
|
126
|
+
// display: 'flex',
|
|
117
127
|
width: cell.column.getSize(),
|
|
128
|
+
// border: '1px solid #e5e7eb',
|
|
118
129
|
...getCommonPinningStyles(cell.column)
|
|
119
130
|
},
|
|
120
131
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
@@ -138,12 +149,15 @@ const TableBodyCell = props => {
|
|
|
138
149
|
}), cell.column.id === "command" && renderCommand({
|
|
139
150
|
cell,
|
|
140
151
|
commandClick,
|
|
141
|
-
id
|
|
152
|
+
id,
|
|
153
|
+
data: originData
|
|
142
154
|
}), cell.column.id === "selection_column" && renderSelection({
|
|
143
155
|
cell,
|
|
144
156
|
table,
|
|
145
157
|
selectionSettings,
|
|
146
158
|
setIsSelectionChange
|
|
147
|
-
}), !nonActionColumn.includes(cell.column.id) &&
|
|
159
|
+
}), !nonActionColumn.includes(cell.column.id) && (isFirstRightPinnedColumn ? /*#__PURE__*/React.createElement("span", {
|
|
160
|
+
className: "ui-rc_cell-content"
|
|
161
|
+
}, flexRender(cell.column.columnDef.cell, cell.getContext())) : flexRender(cell.column.columnDef.cell, cell.getContext())));
|
|
148
162
|
};
|
|
149
163
|
export default TableBodyCell;
|
|
@@ -8,7 +8,7 @@ interface TableBodyCellProps<T> {
|
|
|
8
8
|
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
9
9
|
tableId: string;
|
|
10
10
|
cell: Cell<T, unknown>;
|
|
11
|
-
commandClick?: (args: CommandClick) => void;
|
|
11
|
+
commandClick?: (args: CommandClick<T>) => void;
|
|
12
12
|
virtualRow: VirtualItem;
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { flexRender } from "@tanstack/react-table";
|
|
2
2
|
import Space from "rc-master-ui/es/space";
|
|
3
3
|
import Command from "../components/command/Command";
|
|
4
|
-
|
|
5
|
-
// import ReactDOMServer from 'react-dom/server'
|
|
4
|
+
import ReactDOMServer from 'react-dom/server';
|
|
6
5
|
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, flattenArray, flattenData,
|
|
7
6
|
// getCellsByPosition,
|
|
8
7
|
getColIdsBetween, getCommonPinningStyles, getEditType, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
|
|
@@ -29,7 +28,8 @@ const renderCommand = args => {
|
|
|
29
28
|
const {
|
|
30
29
|
cell,
|
|
31
30
|
commandClick,
|
|
32
|
-
id
|
|
31
|
+
id,
|
|
32
|
+
data
|
|
33
33
|
} = args;
|
|
34
34
|
const col = cell.column.columnDef.meta ?? {};
|
|
35
35
|
const record = cell.row.original;
|
|
@@ -54,8 +54,8 @@ const renderCommand = args => {
|
|
|
54
54
|
// rowId: getRowKey(record, index) as any,
|
|
55
55
|
rowId: record.rowId,
|
|
56
56
|
rowData: record,
|
|
57
|
-
index: cell.row.index
|
|
58
|
-
|
|
57
|
+
index: cell.row.index,
|
|
58
|
+
rows: [...data]
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
});
|
|
@@ -125,14 +125,11 @@ const TableBodyCellEdit = props => {
|
|
|
125
125
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
|
|
126
126
|
const record = cell.row.original;
|
|
127
127
|
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// const hasValue = html.trim().length > 0;
|
|
132
|
-
|
|
128
|
+
const cellContent = columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
129
|
+
const html = ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, cellContent));
|
|
130
|
+
const hasValue = html.trim().length > 0;
|
|
133
131
|
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
|
|
136
133
|
const canEdit = isEditable(cell.column.columnDef.meta, record);
|
|
137
134
|
// const allRows = table.getRowModel().rows;
|
|
138
135
|
const allRows = table.getRowModel().flatRows;
|
|
@@ -185,7 +182,9 @@ const TableBodyCellEdit = props => {
|
|
|
185
182
|
className: classNames(`${prefix}-grid-cell`, {
|
|
186
183
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
187
184
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
188
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
185
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
186
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
187
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right'
|
|
189
188
|
}),
|
|
190
189
|
style: {
|
|
191
190
|
display: 'flex',
|
|
@@ -237,7 +236,9 @@ const TableBodyCellEdit = props => {
|
|
|
237
236
|
className: classNames(`${prefix}-grid-cell`, {
|
|
238
237
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
239
238
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
240
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
239
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
240
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
241
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right'
|
|
241
242
|
}),
|
|
242
243
|
style: {
|
|
243
244
|
display: 'flex',
|
|
@@ -248,7 +249,8 @@ const TableBodyCellEdit = props => {
|
|
|
248
249
|
}, renderCommand({
|
|
249
250
|
cell,
|
|
250
251
|
commandClick,
|
|
251
|
-
id
|
|
252
|
+
id,
|
|
253
|
+
data: originData
|
|
252
254
|
}));
|
|
253
255
|
}
|
|
254
256
|
if (cell.column.id === "selection_column") {
|
|
@@ -257,7 +259,9 @@ const TableBodyCellEdit = props => {
|
|
|
257
259
|
className: classNames(`${prefix}-grid-cell cell-editable111 `, {
|
|
258
260
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
259
261
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
260
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
262
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
263
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
264
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right'
|
|
261
265
|
}),
|
|
262
266
|
style: {
|
|
263
267
|
display: 'flex',
|
|
@@ -434,6 +438,7 @@ const TableBodyCellEdit = props => {
|
|
|
434
438
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
435
439
|
};
|
|
436
440
|
function handleMouseDown(rowId, colId) {
|
|
441
|
+
console.log('aaaaaa');
|
|
437
442
|
setIsSelecting?.(true);
|
|
438
443
|
if (startCell?.rowId !== rowId || startCell?.colId !== colId || endCell?.rowId !== rowId || endCell?.colId !== colId) {
|
|
439
444
|
setStartCell?.({
|
|
@@ -739,11 +744,9 @@ const TableBodyCellEdit = props => {
|
|
|
739
744
|
"data-col-index": colIndex,
|
|
740
745
|
"data-row-index": rowNumber,
|
|
741
746
|
"data-col-key": cell.column.id,
|
|
742
|
-
"data-row-key": cell.row.id
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
,
|
|
746
|
-
|
|
747
|
+
"data-row-key": cell.row.id,
|
|
748
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
749
|
+
"data-tooltip-html": !isEditing && !hasValue && !message ? undefined : ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : cellContent)),
|
|
747
750
|
className: classNames(`${prefix}-grid-cell cell-editable `, {
|
|
748
751
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
749
752
|
'cell-editing': isEditing,
|
|
@@ -759,7 +762,9 @@ const TableBodyCellEdit = props => {
|
|
|
759
762
|
'cell-paste-border-top': isInRangePaste && isTopPaste && (pasteRangeState.endRowIndex ?? 0) < (endRowIndex ?? 0),
|
|
760
763
|
'cell-paste-border-left': isInRangePaste && isLeftPaste,
|
|
761
764
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
762
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
765
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
766
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
767
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right' || columnMeta.type === 'number'
|
|
763
768
|
}),
|
|
764
769
|
style: {
|
|
765
770
|
display: 'flex',
|
|
@@ -776,13 +781,24 @@ const TableBodyCellEdit = props => {
|
|
|
776
781
|
});
|
|
777
782
|
} else {
|
|
778
783
|
handleMouseDown(cell.row.id, cell.column.id);
|
|
784
|
+
if (editingKey) {
|
|
785
|
+
setTimeout(() => {
|
|
786
|
+
setEditingKey?.('');
|
|
787
|
+
reset?.();
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// reset?.()
|
|
779
792
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
793
|
+
|
|
794
|
+
// if (record[rowKey] !== editingKey) {
|
|
795
|
+
|
|
796
|
+
// setTimeout(() => {
|
|
797
|
+
// // setEditingKey?.('')
|
|
798
|
+
// reset?.()
|
|
799
|
+
// })
|
|
800
|
+
|
|
801
|
+
// }
|
|
786
802
|
},
|
|
787
803
|
onMouseEnter: () => handleMouseEnter(cell.row.id, cell.column.id),
|
|
788
804
|
onMouseUp: e => handleMouseUp(e),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
|
|
2
|
-
import type
|
|
2
|
+
import { type Column, type Row, type Table } from "@tanstack/react-table";
|
|
3
3
|
import type { CommandClick } from "../type";
|
|
4
4
|
import React from "react";
|
|
5
5
|
interface TableBodyRowProps<T> {
|
|
@@ -13,9 +13,9 @@ interface TableBodyRowProps<T> {
|
|
|
13
13
|
virtualRow: VirtualItem;
|
|
14
14
|
fixedLeftColumns: Column<T, unknown>[];
|
|
15
15
|
fixedRightColumns: Column<T, unknown>[];
|
|
16
|
-
commandClick?: (args: CommandClick) => void;
|
|
16
|
+
commandClick?: (args: CommandClick<T>) => void;
|
|
17
17
|
editAble?: boolean;
|
|
18
18
|
[key: string]: any;
|
|
19
19
|
}
|
|
20
|
-
declare const TableBodyRow: <RecordType extends object>({ tableId, table, columnVirtualizer, row, rowVirtualizer, virtualPaddingLeft, virtualPaddingRight, virtualRow, fixedLeftColumns, fixedRightColumns, commandClick, editAble, isEditing, contextMenuItems, ...rest }: TableBodyRowProps<RecordType>) => React.JSX.Element;
|
|
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
21
|
export default TableBodyRow;
|
|
@@ -19,12 +19,12 @@ const TableBodyRow = ({
|
|
|
19
19
|
editAble,
|
|
20
20
|
isEditing,
|
|
21
21
|
contextMenuItems,
|
|
22
|
+
onContextMenu,
|
|
22
23
|
...rest
|
|
23
24
|
}) => {
|
|
24
25
|
const {
|
|
25
26
|
prefix,
|
|
26
|
-
recordDoubleClick
|
|
27
|
-
onContextMenu
|
|
27
|
+
recordDoubleClick
|
|
28
28
|
} = React.useContext(TableContext);
|
|
29
29
|
const visibleCells = row.getVisibleCells();
|
|
30
30
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
@@ -50,8 +50,8 @@ const TableBodyRow = ({
|
|
|
50
50
|
//this should always be a `style` as it changes on scroll
|
|
51
51
|
// width: '100%',
|
|
52
52
|
// height: isEditing ? '36px' : undefined,
|
|
53
|
-
height: isEditing ? virtualRow.size : undefined
|
|
54
|
-
minHeight: isEditing ? undefined : virtualRow.size
|
|
53
|
+
height: isEditing ? virtualRow.size : undefined
|
|
54
|
+
// minHeight: isEditing ? undefined : virtualRow.size
|
|
55
55
|
},
|
|
56
56
|
onDoubleClick: e => {
|
|
57
57
|
recordDoubleClick?.({
|
|
@@ -65,8 +65,6 @@ const TableBodyRow = ({
|
|
|
65
65
|
onContextMenu?.(row.original)(e);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
// onContextMenu={onContextMenu(row.original)}
|
|
70
68
|
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
71
69
|
const cell = row.getVisibleCells().find(c => c.column.id === column.id);
|
|
72
70
|
if (editAble) {
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Virtualizer } from "@tanstack/react-virtual";
|
|
1
|
+
import type { Table } from "@tanstack/react-table";
|
|
3
2
|
import React from "react";
|
|
4
3
|
interface TableFooterProps<T> {
|
|
5
|
-
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
6
4
|
table: Table<T>;
|
|
7
|
-
virtualPaddingLeft: number | undefined;
|
|
8
|
-
virtualPaddingRight: number | undefined;
|
|
9
|
-
fixedLeftColumns: Column<T, unknown>[];
|
|
10
|
-
fixedRightColumns: Column<T, unknown>[];
|
|
11
5
|
}
|
|
12
|
-
declare const TableFooter: <RecordType extends object>({
|
|
6
|
+
declare const TableFooter: <RecordType extends object>({ table, }: TableFooterProps<RecordType>) => React.JSX.Element;
|
|
13
7
|
export default TableFooter;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
// import type { Virtualizer } from "@tanstack/react-virtual";
|
|
2
2
|
import TableFooterRow from "./TableFooterRow";
|
|
3
3
|
import { TableContext } from "../useContext";
|
|
4
4
|
import React, { useContext } from "react";
|
|
5
5
|
const TableFooter = ({
|
|
6
|
-
columnVirtualizer,
|
|
7
|
-
table
|
|
8
|
-
virtualPaddingLeft,
|
|
9
|
-
virtualPaddingRight,
|
|
10
|
-
...rest
|
|
6
|
+
// columnVirtualizer,
|
|
7
|
+
table
|
|
8
|
+
// virtualPaddingLeft,
|
|
9
|
+
// virtualPaddingRight,
|
|
10
|
+
// ...rest
|
|
11
11
|
}) => {
|
|
12
12
|
const {
|
|
13
13
|
prefix
|
|
@@ -20,14 +20,15 @@ const TableFooter = ({
|
|
|
20
20
|
bottom: 0,
|
|
21
21
|
zIndex: 1
|
|
22
22
|
}
|
|
23
|
-
}, /*#__PURE__*/React.createElement(TableFooterRow,
|
|
24
|
-
table: table
|
|
25
|
-
|
|
23
|
+
}, /*#__PURE__*/React.createElement(TableFooterRow, {
|
|
24
|
+
table: table
|
|
25
|
+
// columnVirtualizer={columnVirtualizer}
|
|
26
|
+
,
|
|
26
27
|
headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1]
|
|
27
28
|
// key={headerGroup.id}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
29
|
+
// virtualPaddingLeft={virtualPaddingLeft}
|
|
30
|
+
// virtualPaddingRight={virtualPaddingRight}
|
|
31
|
+
// {...rest}
|
|
32
|
+
}));
|
|
32
33
|
};
|
|
33
34
|
export default TableFooter;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
|
|
1
|
+
import type { Column } from "@tanstack/react-table";
|
|
3
2
|
import React from "react";
|
|
4
3
|
interface TableFooterCellProps<T> {
|
|
5
|
-
|
|
6
|
-
header: Header<T, unknown>;
|
|
7
|
-
column: VirtualItem;
|
|
4
|
+
column: Column<T, any>;
|
|
8
5
|
}
|
|
9
|
-
declare const TableFooterCell: <RecordType extends object>({
|
|
6
|
+
declare const TableFooterCell: <RecordType extends object>({ column }: TableFooterCellProps<RecordType>) => React.JSX.Element;
|
|
10
7
|
export default TableFooterCell;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
|
|
1
2
|
import React, { useContext } from "react";
|
|
2
3
|
// import type { Person } from "../makeData";
|
|
3
4
|
import { checkDecimalSeparator, checkThousandSeparator, getCommonPinningStyles, getFormat, isEmpty } from "../hook/utils";
|
|
@@ -8,17 +9,17 @@ import { numericFormatter } from "react-numeric-component";
|
|
|
8
9
|
// import type { Person } from "../../tanstack-table/makeData";
|
|
9
10
|
|
|
10
11
|
const TableFooterCell = ({
|
|
11
|
-
|
|
12
|
+
column
|
|
12
13
|
}) => {
|
|
13
|
-
const isPinned =
|
|
14
|
-
const isLastLeftPinnedColumn = isPinned === 'left' &&
|
|
15
|
-
const isFirstRightPinnedColumn = isPinned === 'right' &&
|
|
14
|
+
const isPinned = column.getIsPinned();
|
|
15
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
16
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
|
|
16
17
|
const {
|
|
17
18
|
prefix,
|
|
18
19
|
format,
|
|
19
20
|
dataSource
|
|
20
21
|
} = useContext(TableContext);
|
|
21
|
-
const col =
|
|
22
|
+
const col = column.columnDef.meta ?? {};
|
|
22
23
|
const colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
|
|
23
24
|
const cellFormat = getFormat(colFormat, format);
|
|
24
25
|
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
@@ -51,16 +52,18 @@ const TableFooterCell = ({
|
|
|
51
52
|
// [`${prefix}-grid-cell-ellipsis`]:!wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
52
53
|
// [`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
|
|
53
54
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
54
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
55
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
56
|
+
[`${prefix}-grid-cell-text-right`]: true
|
|
55
57
|
}),
|
|
56
|
-
key:
|
|
57
|
-
colSpan
|
|
58
|
+
key: column.id
|
|
59
|
+
// colSpan={header.colSpan}
|
|
60
|
+
,
|
|
58
61
|
style: {
|
|
59
62
|
display: 'flex',
|
|
60
|
-
...getCommonPinningStyles(
|
|
61
|
-
width:
|
|
63
|
+
...getCommonPinningStyles(column),
|
|
64
|
+
width: column?.getSize() ?? column.getSize(),
|
|
62
65
|
backgroundColor: "#fafafa"
|
|
63
66
|
}
|
|
64
|
-
},
|
|
67
|
+
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/React.createElement(React.Fragment, null, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : numericFormatter(cellValue, numericFormatProps)) : '');
|
|
65
68
|
};
|
|
66
69
|
export default TableFooterCell;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Virtualizer } from "@tanstack/react-virtual";
|
|
1
|
+
import type { HeaderGroup, Table } from "@tanstack/react-table";
|
|
3
2
|
import React from "react";
|
|
4
3
|
interface TableFooterRowProps<T> {
|
|
5
4
|
table: Table<T>;
|
|
6
|
-
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
7
5
|
headerGroup: HeaderGroup<T>;
|
|
8
|
-
virtualPaddingLeft: number | undefined;
|
|
9
|
-
virtualPaddingRight: number | undefined;
|
|
10
|
-
fixedLeftColumns: Column<T, unknown>[];
|
|
11
|
-
fixedRightColumns: Column<T, unknown>[];
|
|
12
6
|
}
|
|
13
|
-
declare const TableFooterRow: <RecordType extends object>({ table, headerGroup,
|
|
7
|
+
declare const TableFooterRow: <RecordType extends object>({ table, headerGroup, }: TableFooterRowProps<RecordType>) => React.JSX.Element;
|
|
14
8
|
export default TableFooterRow;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// import type { Virtualizer } from "@tanstack/react-virtual";
|
|
1
2
|
// import type { Person } from "../makeData";
|
|
2
3
|
import TableFooterCell from "./TableFooterCell";
|
|
3
4
|
import React from "react";
|
|
@@ -7,15 +8,23 @@ import React from "react";
|
|
|
7
8
|
const TableFooterRow = ({
|
|
8
9
|
table,
|
|
9
10
|
// columnVirtualizer,
|
|
10
|
-
headerGroup
|
|
11
|
-
virtualPaddingLeft,
|
|
12
|
-
virtualPaddingRight,
|
|
13
|
-
fixedLeftColumns,
|
|
14
|
-
fixedRightColumns,
|
|
11
|
+
headerGroup
|
|
12
|
+
// virtualPaddingLeft,
|
|
13
|
+
// virtualPaddingRight,
|
|
14
|
+
// fixedLeftColumns,
|
|
15
|
+
// fixedRightColumns,
|
|
15
16
|
// virtualColumns,
|
|
16
|
-
columnVirtualizer
|
|
17
|
+
// columnVirtualizer
|
|
17
18
|
}) => {
|
|
18
|
-
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
19
|
+
// const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
20
|
+
|
|
21
|
+
// const a = table.getVisibleFlatColumns()
|
|
22
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
23
|
+
|
|
24
|
+
// console.log('a', a)
|
|
25
|
+
|
|
26
|
+
// const
|
|
27
|
+
|
|
19
28
|
return /*#__PURE__*/React.createElement("tr", {
|
|
20
29
|
// data-index={headerGroup.id}
|
|
21
30
|
key: headerGroup.id,
|
|
@@ -26,48 +35,14 @@ const TableFooterRow = ({
|
|
|
26
35
|
borderTop: "1px solid #e0e0e0",
|
|
27
36
|
height: 37
|
|
28
37
|
}
|
|
29
|
-
},
|
|
38
|
+
}, visibleColumns.map(header => {
|
|
30
39
|
return /*#__PURE__*/React.createElement(TableFooterCell, {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
column:
|
|
40
|
+
key: header.id
|
|
41
|
+
// header={header as any}
|
|
42
|
+
,
|
|
43
|
+
column: header
|
|
44
|
+
// columnVirtualizer={columnVirtualizer}
|
|
35
45
|
});
|
|
36
|
-
})
|
|
37
|
-
className: "",
|
|
38
|
-
style: {
|
|
39
|
-
display: "flex",
|
|
40
|
-
width: virtualPaddingLeft
|
|
41
|
-
}
|
|
42
|
-
}) : null, virtualColumns.map(virtualColumn => {
|
|
43
|
-
const header = headerGroup.headers[virtualColumn.index];
|
|
44
|
-
const isFixed = table.getState().columnPinning.left?.includes(header.column.id) || table.getState().columnPinning.right?.includes(header.column.id);
|
|
45
|
-
// const isFixed = table.getState().columnPinning.left?.includes(header.column.id)
|
|
46
|
-
|
|
47
|
-
if (header && !isFixed) {
|
|
48
|
-
return /*#__PURE__*/React.createElement(TableFooterCell, {
|
|
49
|
-
key: header.id,
|
|
50
|
-
header: header,
|
|
51
|
-
column: virtualColumn,
|
|
52
|
-
columnVirtualizer: columnVirtualizer
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}),
|
|
57
|
-
//fake empty column to the right for virtualization scroll padding
|
|
58
|
-
fixedRightColumns.length > 0 ? fixedRightColumns.map(column => /*#__PURE__*/React.createElement(TableFooterCell, {
|
|
59
|
-
key: column.id,
|
|
60
|
-
header: headerGroup.headers.find(h => h.column.id === column.id),
|
|
61
|
-
column: column
|
|
62
|
-
})) : null, virtualPaddingRight ?
|
|
63
|
-
/*#__PURE__*/
|
|
64
|
-
//fake empty column to the right for virtualization scroll padding
|
|
65
|
-
React.createElement("td", {
|
|
66
|
-
className: "",
|
|
67
|
-
style: {
|
|
68
|
-
display: "flex",
|
|
69
|
-
width: virtualPaddingRight
|
|
70
|
-
}
|
|
71
|
-
}) : null);
|
|
46
|
+
}));
|
|
72
47
|
};
|
|
73
48
|
export default TableFooterRow;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type { Column
|
|
1
|
+
import type { Column } from '@tanstack/react-table';
|
|
2
|
+
import { type Table } from '@tanstack/react-table';
|
|
2
3
|
import { type Virtualizer } from '@tanstack/react-virtual';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
interface TableHeadProps<T> {
|
|
5
6
|
tableContainerRef: React.RefObject<HTMLDivElement>;
|
|
6
|
-
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
7
7
|
table: Table<T>;
|
|
8
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
8
9
|
virtualPaddingLeft: number | undefined;
|
|
9
10
|
virtualPaddingRight: number | undefined;
|
|
10
11
|
fixedLeftColumns: Column<T, unknown>[];
|
|
11
12
|
fixedRightColumns: Column<T, unknown>[];
|
|
12
13
|
}
|
|
13
|
-
declare const TableHead: <RecordType extends object>({
|
|
14
|
+
declare const TableHead: <RecordType extends object>({ columnVirtualizer, table, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns }: TableHeadProps<RecordType>) => React.JSX.Element;
|
|
14
15
|
export default TableHead;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
2
1
|
import React, { useContext } from 'react';
|
|
3
2
|
import { TableContext } from "../useContext";
|
|
4
3
|
import TableHeadRow from "./TableHeadRow";
|
|
4
|
+
// import { getCommonPinningStyles } from '../hook/utils'
|
|
5
|
+
|
|
5
6
|
const TableHead = ({
|
|
6
|
-
tableContainerRef,
|
|
7
7
|
columnVirtualizer,
|
|
8
8
|
table,
|
|
9
9
|
virtualPaddingLeft,
|
|
@@ -14,46 +14,24 @@ const TableHead = ({
|
|
|
14
14
|
const {
|
|
15
15
|
prefix
|
|
16
16
|
} = useContext(TableContext);
|
|
17
|
-
const rowVirtualizer = useVirtualizer({
|
|
18
|
-
count: table.getHeaderGroups().length,
|
|
19
|
-
estimateSize: () => 34,
|
|
20
|
-
//estimate row height for accurate scrollbar dragging
|
|
21
|
-
getScrollElement: () => tableContainerRef.current,
|
|
22
|
-
//measure dynamic row height, except in firefox because it measures table border height incorrectly
|
|
23
|
-
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
|
|
24
|
-
overscan: 5
|
|
25
|
-
});
|
|
26
|
-
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
27
|
-
|
|
28
|
-
// const columnSizingState = table.getState().columnSizing
|
|
29
|
-
|
|
30
|
-
// React.useEffect(() => {
|
|
31
|
-
// requestAnimationFrame(() => {
|
|
32
|
-
// rowVirtualizer.measure()
|
|
33
|
-
// })
|
|
34
|
-
// }, [columnSizingState, rowVirtualizer])
|
|
35
|
-
|
|
36
17
|
return /*#__PURE__*/React.createElement("thead", {
|
|
37
18
|
className: `${prefix}-grid-thead`,
|
|
38
19
|
style: {
|
|
39
|
-
display: 'grid',
|
|
20
|
+
// display: 'grid',
|
|
40
21
|
position: 'sticky',
|
|
41
22
|
top: 0,
|
|
42
23
|
zIndex: 1
|
|
43
24
|
}
|
|
44
|
-
},
|
|
45
|
-
const headerGroup = table.getHeaderGroups()[virtualRow.index];
|
|
25
|
+
}, table.getHeaderGroups().map(headerGroup => {
|
|
46
26
|
return /*#__PURE__*/React.createElement(TableHeadRow, {
|
|
47
27
|
table: table,
|
|
48
|
-
columnVirtualizer: columnVirtualizer,
|
|
49
|
-
rowHeaderVirtualizer: rowVirtualizer,
|
|
50
28
|
headerGroup: headerGroup,
|
|
51
29
|
key: headerGroup.id,
|
|
30
|
+
columnVirtualizer: columnVirtualizer,
|
|
52
31
|
virtualPaddingLeft: virtualPaddingLeft,
|
|
53
32
|
virtualPaddingRight: virtualPaddingRight,
|
|
54
33
|
fixedLeftColumns: fixedLeftColumns,
|
|
55
|
-
fixedRightColumns: fixedRightColumns
|
|
56
|
-
rowHeaderVirtual: virtualRow
|
|
34
|
+
fixedRightColumns: fixedRightColumns
|
|
57
35
|
});
|
|
58
36
|
}));
|
|
59
37
|
};
|