es-grid-template 1.7.28 → 1.7.30
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/hooks/useColumns.d.ts +3 -1
- package/es/table-component/TableContainer.d.ts +0 -1
- package/es/table-component/TableContainer.js +8 -4
- package/es/table-component/TableContainerEdit.js +32 -7
- package/es/table-component/body/EditableCell.js +11 -11
- package/es/table-component/body/TableBodyCell.js +2 -1
- package/es/table-component/body/TableBodyCellEdit.js +305 -213
- package/es/table-component/footer/TableFooterRow.js +0 -2
- package/es/table-component/header/TableHeadCell.js +1 -0
- package/es/table-component/hook/utils.js +2 -2
- package/es/table-component/index.d.ts +2 -3
- package/es/table-component/index.js +3 -0
- package/es/table-component/style.scss +31 -20
- package/es/table-component/table/Grid.js +6 -3
- package/es/table-component/table/TableWrapper.d.ts +1 -0
- package/es/table-component/table/TableWrapper.js +10 -1
- package/es/table-component/type.d.ts +1 -0
- package/lib/table-component/TableContainer.d.ts +0 -1
- package/lib/table-component/TableContainer.js +8 -4
- package/lib/table-component/TableContainerEdit.js +32 -7
- package/lib/table-component/body/EditableCell.js +11 -11
- package/lib/table-component/body/TableBodyCell.js +2 -1
- package/lib/table-component/body/TableBodyCellEdit.js +304 -213
- package/lib/table-component/footer/TableFooterRow.js +0 -2
- package/lib/table-component/header/TableHeadCell.js +1 -0
- package/lib/table-component/hook/utils.js +2 -2
- package/lib/table-component/index.d.ts +2 -3
- package/lib/table-component/index.js +1 -0
- package/lib/table-component/style.scss +31 -20
- package/lib/table-component/table/Grid.js +6 -3
- package/lib/table-component/table/TableWrapper.d.ts +1 -0
- package/lib/table-component/table/TableWrapper.js +10 -1
- package/lib/table-component/type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
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
|
-
|
|
4
|
+
|
|
5
|
+
// import ReactDOMServer from 'react-dom/server'
|
|
6
|
+
|
|
5
7
|
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, flattenArray, flattenData,
|
|
6
8
|
// getCellsByPosition,
|
|
7
9
|
getColIdsBetween, getCommonPinningStyles, getEditType, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
|
|
@@ -20,7 +22,9 @@ const renderCellIndex = props => {
|
|
|
20
22
|
parrents,
|
|
21
23
|
cell
|
|
22
24
|
} = props;
|
|
23
|
-
return /*#__PURE__*/React.createElement("span",
|
|
25
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
26
|
+
className: "ui-rc_cell-content"
|
|
27
|
+
}, parrents.map(pr => {
|
|
24
28
|
return `${pr.index + 1}.`;
|
|
25
29
|
}), cell.row.index + 1);
|
|
26
30
|
};
|
|
@@ -42,7 +46,9 @@ const renderCommand = args => {
|
|
|
42
46
|
visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
|
|
43
47
|
};
|
|
44
48
|
}) : [];
|
|
45
|
-
return /*#__PURE__*/React.createElement(
|
|
49
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
50
|
+
className: "ui-rc_cell-content"
|
|
51
|
+
}, /*#__PURE__*/React.createElement(Space, null, commands.filter(it => it.visible !== false).map(item => {
|
|
46
52
|
return /*#__PURE__*/React.createElement(Command, {
|
|
47
53
|
id: id,
|
|
48
54
|
key: item.id,
|
|
@@ -59,13 +65,14 @@ const renderCommand = args => {
|
|
|
59
65
|
});
|
|
60
66
|
}
|
|
61
67
|
});
|
|
62
|
-
}));
|
|
68
|
+
})));
|
|
63
69
|
};
|
|
64
70
|
const renderSelection = args => {
|
|
65
71
|
const {
|
|
66
72
|
row
|
|
67
73
|
} = args.cell;
|
|
68
74
|
return /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: "ui-rc_cell-content",
|
|
69
76
|
style: {
|
|
70
77
|
|
|
71
78
|
// paddingLeft: `${row.depth * 2}rem`,
|
|
@@ -116,7 +123,9 @@ const TableBodyCellEdit = props => {
|
|
|
116
123
|
handleDeleteContent,
|
|
117
124
|
reset,
|
|
118
125
|
setValue,
|
|
119
|
-
|
|
126
|
+
getValues,
|
|
127
|
+
handleCellChange,
|
|
128
|
+
// handleAddMulti,
|
|
120
129
|
dataErrors,
|
|
121
130
|
expanded,
|
|
122
131
|
setExpanded,
|
|
@@ -125,9 +134,11 @@ const TableBodyCellEdit = props => {
|
|
|
125
134
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
|
|
126
135
|
const record = cell.row.original;
|
|
127
136
|
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
const
|
|
137
|
+
|
|
138
|
+
// const cellContent = columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
139
|
+
// const html = ReactDOMServer.renderToStaticMarkup(<>{cellContent}</>);
|
|
140
|
+
// const hasValue = html.trim().length > 0;
|
|
141
|
+
|
|
131
142
|
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
132
143
|
const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
|
|
133
144
|
const canEdit = isEditable(cell.column.columnDef.meta, record);
|
|
@@ -140,12 +151,16 @@ const TableBodyCellEdit = props => {
|
|
|
140
151
|
const isPinned = cell.column.getIsPinned();
|
|
141
152
|
const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
142
153
|
const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
154
|
+
const selectRowIds = React.useMemo(() => {
|
|
155
|
+
return startCell && endCell ? getRowIdsBetween(table, startCell.rowId, endCell.rowId) : [];
|
|
156
|
+
}, [endCell, startCell, table]);
|
|
143
157
|
const isCellSelected = React.useMemo(() => {
|
|
144
158
|
if (!startCell || !endCell) return false;
|
|
145
|
-
|
|
159
|
+
|
|
160
|
+
// const rowIds = getRowIdsBetween(table, startCell.rowId, endCell.rowId);
|
|
146
161
|
const colIds = getColIdsBetween(table, startCell.colId, endCell.colId);
|
|
147
|
-
return
|
|
148
|
-
}, [cell.column.id, cell.row.id, endCell, startCell, table]);
|
|
162
|
+
return selectRowIds.includes(cell.row.id) && colIds.includes(cell.column.id);
|
|
163
|
+
}, [cell.column.id, cell.row.id, endCell, selectRowIds, startCell, table]);
|
|
149
164
|
const editType = typeof columnMeta.editType === 'function' ? columnMeta.editType(record) : columnMeta.editType;
|
|
150
165
|
const {
|
|
151
166
|
rowRange,
|
|
@@ -176,136 +191,6 @@ const TableBodyCellEdit = props => {
|
|
|
176
191
|
const isLeftPaste = colIdxPaste === pasteRangeState.startColIndex;
|
|
177
192
|
const isRightPaste = colIdxPaste === pasteRangeState.endColIndex;
|
|
178
193
|
const parrents = cell.row.getParentRows();
|
|
179
|
-
if (cell.column.id === "#") {
|
|
180
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
181
|
-
key: cell.id,
|
|
182
|
-
className: classNames(`${prefix}-grid-cell`, {
|
|
183
|
-
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
184
|
-
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
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'
|
|
188
|
-
}),
|
|
189
|
-
style: {
|
|
190
|
-
display: 'flex',
|
|
191
|
-
height: '36px',
|
|
192
|
-
width: cell.column.getSize(),
|
|
193
|
-
...getCommonPinningStyles(cell.column)
|
|
194
|
-
}
|
|
195
|
-
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/React.createElement("div", {
|
|
196
|
-
className: "ui-rc-table-row-expand-trigger",
|
|
197
|
-
style: {
|
|
198
|
-
paddingLeft: `${cell.row.depth * 25}px`
|
|
199
|
-
}
|
|
200
|
-
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
201
|
-
// onClick: row.getToggleExpandedHandler(),
|
|
202
|
-
onClick: () => {
|
|
203
|
-
const keys = Object.keys(expanded);
|
|
204
|
-
// @ts-ignore
|
|
205
|
-
const tmp = {
|
|
206
|
-
...expanded
|
|
207
|
-
};
|
|
208
|
-
if (keys.includes(cell.row.id)) {
|
|
209
|
-
delete tmp[cell.row.id];
|
|
210
|
-
setExpanded(tmp);
|
|
211
|
-
} else {
|
|
212
|
-
setExpanded(old => ({
|
|
213
|
-
...old,
|
|
214
|
-
[cell.row.id]: true
|
|
215
|
-
}));
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
style: {
|
|
219
|
-
cursor: "pointer"
|
|
220
|
-
},
|
|
221
|
-
className: "ui-rc-table-row-expand"
|
|
222
|
-
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
223
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
224
|
-
}) : /*#__PURE__*/React.createElement("span", {
|
|
225
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
226
|
-
})) : /*#__PURE__*/React.createElement("span", {
|
|
227
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
228
|
-
}))), renderCellIndex({
|
|
229
|
-
parrents,
|
|
230
|
-
cell
|
|
231
|
-
}));
|
|
232
|
-
}
|
|
233
|
-
if (cell.column.id === "command") {
|
|
234
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
235
|
-
key: cell.id,
|
|
236
|
-
className: classNames(`${prefix}-grid-cell`, {
|
|
237
|
-
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
238
|
-
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
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'
|
|
242
|
-
}),
|
|
243
|
-
style: {
|
|
244
|
-
display: 'flex',
|
|
245
|
-
height: '36px',
|
|
246
|
-
width: cell.column.getSize(),
|
|
247
|
-
...getCommonPinningStyles(cell.column)
|
|
248
|
-
}
|
|
249
|
-
}, renderCommand({
|
|
250
|
-
cell,
|
|
251
|
-
commandClick,
|
|
252
|
-
id,
|
|
253
|
-
data: originData
|
|
254
|
-
}));
|
|
255
|
-
}
|
|
256
|
-
if (cell.column.id === "selection_column") {
|
|
257
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
258
|
-
key: cell.id,
|
|
259
|
-
className: classNames(`${prefix}-grid-cell cell-editable111 `, {
|
|
260
|
-
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
261
|
-
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
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'
|
|
265
|
-
}),
|
|
266
|
-
style: {
|
|
267
|
-
display: 'flex',
|
|
268
|
-
height: '36px',
|
|
269
|
-
width: cell.column.getSize(),
|
|
270
|
-
...getCommonPinningStyles(cell.column)
|
|
271
|
-
}
|
|
272
|
-
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/React.createElement("div", {
|
|
273
|
-
className: "ui-rc-table-row-expand-trigger",
|
|
274
|
-
style: {
|
|
275
|
-
paddingLeft: `${cell.row.depth * 25}px`
|
|
276
|
-
}
|
|
277
|
-
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
278
|
-
// onClick: row.getToggleExpandedHandler(),
|
|
279
|
-
onClick: () => {
|
|
280
|
-
const keys = Object.keys(expanded);
|
|
281
|
-
// @ts-ignore
|
|
282
|
-
const tmp = {
|
|
283
|
-
...expanded
|
|
284
|
-
};
|
|
285
|
-
if (keys.includes(cell.row.id)) {
|
|
286
|
-
delete tmp[cell.row.id];
|
|
287
|
-
setExpanded(tmp);
|
|
288
|
-
} else {
|
|
289
|
-
setExpanded(old => ({
|
|
290
|
-
...old,
|
|
291
|
-
[cell.row.id]: true
|
|
292
|
-
}));
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
style: {
|
|
296
|
-
cursor: "pointer"
|
|
297
|
-
},
|
|
298
|
-
className: "ui-rc-table-row-expand"
|
|
299
|
-
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
300
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
301
|
-
}) : /*#__PURE__*/React.createElement("span", {
|
|
302
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
303
|
-
})) : /*#__PURE__*/React.createElement("span", {
|
|
304
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
305
|
-
}))), renderSelection({
|
|
306
|
-
cell
|
|
307
|
-
}));
|
|
308
|
-
}
|
|
309
194
|
const triggerDragPaste = (pasteState, ctrlKey) => {
|
|
310
195
|
const tmpCols = table.getVisibleLeafColumns();
|
|
311
196
|
const rowPasteIds = getRowIdsBetween(table, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
|
|
@@ -437,33 +322,6 @@ const TableBodyCellEdit = props => {
|
|
|
437
322
|
const rs = unFlattenData(rsFilterData);
|
|
438
323
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
439
324
|
};
|
|
440
|
-
function handleMouseDown(rowId, colId) {
|
|
441
|
-
console.log('aaaaaa');
|
|
442
|
-
setIsSelecting?.(true);
|
|
443
|
-
if (startCell?.rowId !== rowId || startCell?.colId !== colId || endCell?.rowId !== rowId || endCell?.colId !== colId) {
|
|
444
|
-
setStartCell?.({
|
|
445
|
-
rowId,
|
|
446
|
-
colId
|
|
447
|
-
});
|
|
448
|
-
setEndCell?.({
|
|
449
|
-
rowId,
|
|
450
|
-
colId
|
|
451
|
-
});
|
|
452
|
-
setRangeState?.(getSelectedCellMatrix(table, {
|
|
453
|
-
rowId,
|
|
454
|
-
colId
|
|
455
|
-
}, {
|
|
456
|
-
rowId,
|
|
457
|
-
colId
|
|
458
|
-
}));
|
|
459
|
-
}
|
|
460
|
-
if (focusedCell?.rowId !== cell.row.id || focusedCell?.colId !== cell.column.id) {
|
|
461
|
-
setFocusedCell?.({
|
|
462
|
-
rowId: cell.row.id,
|
|
463
|
-
colId: cell.column.id
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
325
|
function handleMouseEnter(rowId, colId) {
|
|
468
326
|
if (isSelecting) {
|
|
469
327
|
setEndCell?.({
|
|
@@ -662,6 +520,7 @@ const TableBodyCellEdit = props => {
|
|
|
662
520
|
});
|
|
663
521
|
}
|
|
664
522
|
}
|
|
523
|
+
return;
|
|
665
524
|
}
|
|
666
525
|
if (e.key === 'ArrowRight') {
|
|
667
526
|
e.preventDefault();
|
|
@@ -693,6 +552,7 @@ const TableBodyCellEdit = props => {
|
|
|
693
552
|
align: 'center'
|
|
694
553
|
});
|
|
695
554
|
}
|
|
555
|
+
return;
|
|
696
556
|
}
|
|
697
557
|
if (e.key === 'ArrowLeft') {
|
|
698
558
|
e.preventDefault();
|
|
@@ -725,14 +585,246 @@ const TableBodyCellEdit = props => {
|
|
|
725
585
|
align: 'center'
|
|
726
586
|
});
|
|
727
587
|
}
|
|
588
|
+
return;
|
|
728
589
|
}
|
|
729
590
|
if (e.key === 'Delete') {
|
|
730
591
|
handleDeleteContent?.();
|
|
592
|
+
return;
|
|
731
593
|
}
|
|
732
594
|
if (e.key === 'Enter') {
|
|
733
595
|
handleEdit(e);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
if (e.key.length === 1) {
|
|
599
|
+
e.preventDefault();
|
|
600
|
+
e.stopPropagation();
|
|
601
|
+
handleEdit(e);
|
|
602
|
+
// setValue(cell.column.id, editType === 'numeric' ? (!isNaN(Number(e.key)) ? Number(e.key) : '') : e.key)
|
|
734
603
|
}
|
|
735
604
|
}
|
|
605
|
+
function handleMouseDown(rowId, colId) {
|
|
606
|
+
setIsSelecting?.(true);
|
|
607
|
+
if (startCell?.rowId !== rowId || startCell?.colId !== colId || endCell?.rowId !== rowId || endCell?.colId !== colId) {
|
|
608
|
+
setStartCell?.({
|
|
609
|
+
rowId,
|
|
610
|
+
colId
|
|
611
|
+
});
|
|
612
|
+
setEndCell?.({
|
|
613
|
+
rowId,
|
|
614
|
+
colId
|
|
615
|
+
});
|
|
616
|
+
setRangeState?.(getSelectedCellMatrix(table, {
|
|
617
|
+
rowId,
|
|
618
|
+
colId
|
|
619
|
+
}, {
|
|
620
|
+
rowId,
|
|
621
|
+
colId
|
|
622
|
+
}));
|
|
623
|
+
}
|
|
624
|
+
if (focusedCell?.rowId !== cell.row.id || focusedCell?.colId !== cell.column.id) {
|
|
625
|
+
setFocusedCell?.({
|
|
626
|
+
rowId: cell.row.id,
|
|
627
|
+
colId: cell.column.id
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
const handleMouseDownIndex = rowId => {
|
|
632
|
+
const allColumns = table.getVisibleLeafColumns();
|
|
633
|
+
const startCol = allColumns[0].id;
|
|
634
|
+
const endCol = allColumns[allColumns.length - 1].id;
|
|
635
|
+
setStartCell?.({
|
|
636
|
+
rowId,
|
|
637
|
+
colId: startCol
|
|
638
|
+
});
|
|
639
|
+
setEndCell?.({
|
|
640
|
+
rowId,
|
|
641
|
+
colId: endCol
|
|
642
|
+
});
|
|
643
|
+
setRangeState?.(getSelectedCellMatrix(table, {
|
|
644
|
+
rowId,
|
|
645
|
+
colId: startCol
|
|
646
|
+
}, {
|
|
647
|
+
rowId,
|
|
648
|
+
colId: endCol
|
|
649
|
+
}));
|
|
650
|
+
};
|
|
651
|
+
if (cell.column.id === "#") {
|
|
652
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
653
|
+
key: cell.id,
|
|
654
|
+
className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-index`, {
|
|
655
|
+
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
656
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
657
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
658
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
659
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right',
|
|
660
|
+
// [`${prefix}-grid-cell-index-selected`]: rowRange?.includes(cell.row.id),
|
|
661
|
+
[`${prefix}-grid-cell-index-selected`]: selectRowIds?.includes(cell.row.id)
|
|
662
|
+
}),
|
|
663
|
+
style: {
|
|
664
|
+
display: 'flex',
|
|
665
|
+
height: '36px',
|
|
666
|
+
userSelect: 'none',
|
|
667
|
+
width: cell.column.getSize(),
|
|
668
|
+
// minWidth: cell.column.getSize(),
|
|
669
|
+
// maxWidth: cell.column.getSize(),
|
|
670
|
+
...getCommonPinningStyles(cell.column)
|
|
671
|
+
},
|
|
672
|
+
onMouseDown: () => {
|
|
673
|
+
if (record[rowKey] === editingKey) {
|
|
674
|
+
setFocusedCell?.({
|
|
675
|
+
rowId: cell.row.id,
|
|
676
|
+
colId: cell.column.id
|
|
677
|
+
});
|
|
678
|
+
} else {
|
|
679
|
+
handleMouseDownIndex(cell.row.id);
|
|
680
|
+
if (editingKey) {
|
|
681
|
+
setTimeout(() => {
|
|
682
|
+
setEditingKey?.('');
|
|
683
|
+
reset?.();
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// reset?.()
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/React.createElement("div", {
|
|
691
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
692
|
+
style: {
|
|
693
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
694
|
+
}
|
|
695
|
+
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
696
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
697
|
+
onClick: () => {
|
|
698
|
+
const keys = Object.keys(expanded);
|
|
699
|
+
// @ts-ignore
|
|
700
|
+
const tmp = {
|
|
701
|
+
...expanded
|
|
702
|
+
};
|
|
703
|
+
if (keys.includes(cell.row.id)) {
|
|
704
|
+
delete tmp[cell.row.id];
|
|
705
|
+
setExpanded(tmp);
|
|
706
|
+
} else {
|
|
707
|
+
setExpanded(old => ({
|
|
708
|
+
...old,
|
|
709
|
+
[cell.row.id]: true
|
|
710
|
+
}));
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
style: {
|
|
714
|
+
cursor: "pointer"
|
|
715
|
+
},
|
|
716
|
+
className: "ui-rc-table-row-expand"
|
|
717
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
718
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
719
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
720
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
721
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
722
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
723
|
+
}))), renderCellIndex({
|
|
724
|
+
parrents,
|
|
725
|
+
cell
|
|
726
|
+
}));
|
|
727
|
+
}
|
|
728
|
+
if (cell.column.id === "command") {
|
|
729
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
730
|
+
key: cell.id,
|
|
731
|
+
className: classNames(`${prefix}-grid-cell`, {
|
|
732
|
+
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
733
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
734
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
735
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
736
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right'
|
|
737
|
+
}),
|
|
738
|
+
style: {
|
|
739
|
+
display: 'flex',
|
|
740
|
+
height: '36px',
|
|
741
|
+
width: cell.column.getSize(),
|
|
742
|
+
// minWidth: cell.column.getSize(),
|
|
743
|
+
// maxWidth: cell.column.getSize(),
|
|
744
|
+
...getCommonPinningStyles(cell.column)
|
|
745
|
+
}
|
|
746
|
+
}, renderCommand({
|
|
747
|
+
cell,
|
|
748
|
+
commandClick,
|
|
749
|
+
id,
|
|
750
|
+
data: originData
|
|
751
|
+
}));
|
|
752
|
+
}
|
|
753
|
+
if (cell.column.id === "selection_column") {
|
|
754
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
755
|
+
key: cell.id,
|
|
756
|
+
className: classNames(`${prefix}-grid-cell cell-editable111 `, {
|
|
757
|
+
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
758
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
759
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
760
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
761
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right'
|
|
762
|
+
}),
|
|
763
|
+
style: {
|
|
764
|
+
display: 'flex',
|
|
765
|
+
height: '36px',
|
|
766
|
+
width: cell.column.getSize(),
|
|
767
|
+
// minWidth: cell.column.getSize(),
|
|
768
|
+
// maxWidth: cell.column.getSize(),
|
|
769
|
+
...getCommonPinningStyles(cell.column)
|
|
770
|
+
}
|
|
771
|
+
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/React.createElement("div", {
|
|
772
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
773
|
+
style: {
|
|
774
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
775
|
+
}
|
|
776
|
+
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
777
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
778
|
+
onClick: () => {
|
|
779
|
+
const keys = Object.keys(expanded);
|
|
780
|
+
// @ts-ignore
|
|
781
|
+
const tmp = {
|
|
782
|
+
...expanded
|
|
783
|
+
};
|
|
784
|
+
if (keys.includes(cell.row.id)) {
|
|
785
|
+
delete tmp[cell.row.id];
|
|
786
|
+
setExpanded(tmp);
|
|
787
|
+
} else {
|
|
788
|
+
setExpanded(old => ({
|
|
789
|
+
...old,
|
|
790
|
+
[cell.row.id]: true
|
|
791
|
+
}));
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
style: {
|
|
795
|
+
cursor: "pointer"
|
|
796
|
+
},
|
|
797
|
+
className: "ui-rc-table-row-expand"
|
|
798
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
799
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
800
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
801
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
802
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
803
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
804
|
+
}))), renderSelection({
|
|
805
|
+
cell
|
|
806
|
+
}));
|
|
807
|
+
}
|
|
808
|
+
const handleChange = () => {
|
|
809
|
+
const currentRowIndex = allRows.findIndex(r => r.id === editingKey);
|
|
810
|
+
const formState = getValues();
|
|
811
|
+
const itemState = getValues(cell.column.id);
|
|
812
|
+
const prevState = record[cell.column.id];
|
|
813
|
+
const newState = itemState;
|
|
814
|
+
if (newState !== prevState) {
|
|
815
|
+
handleCellChange?.({
|
|
816
|
+
key: cell.row.id,
|
|
817
|
+
field: cell.column.id,
|
|
818
|
+
record: formState,
|
|
819
|
+
prevState,
|
|
820
|
+
newState,
|
|
821
|
+
option: newState,
|
|
822
|
+
indexCol: cell.column.getIndex(),
|
|
823
|
+
indexRow: currentRowIndex,
|
|
824
|
+
type: 'blur'
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
};
|
|
736
828
|
return /*#__PURE__*/React.createElement("td", {
|
|
737
829
|
key: cell.id,
|
|
738
830
|
ref: el => {
|
|
@@ -745,8 +837,11 @@ const TableBodyCellEdit = props => {
|
|
|
745
837
|
"data-row-index": rowNumber,
|
|
746
838
|
"data-col-key": cell.column.id,
|
|
747
839
|
"data-row-key": cell.row.id,
|
|
748
|
-
"data-tooltip-id": `${id}-tooltip-content
|
|
749
|
-
|
|
840
|
+
"data-tooltip-id": `${id}-tooltip-content`
|
|
841
|
+
// data-tooltip-html={!isEditing && !hasValue && !message ? undefined : ReactDOMServer.renderToStaticMarkup(<>{rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : cellContent}</>)}
|
|
842
|
+
// data-tooltip-content={!isEditing && !message ? undefined : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : record[columnMeta.field ?? '']}
|
|
843
|
+
,
|
|
844
|
+
"data-tooltip-content": isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : record[columnMeta.field ?? ''],
|
|
750
845
|
className: classNames(`${prefix}-grid-cell cell-editable `, {
|
|
751
846
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
752
847
|
'cell-editing': isEditing,
|
|
@@ -769,6 +864,8 @@ const TableBodyCellEdit = props => {
|
|
|
769
864
|
style: {
|
|
770
865
|
display: 'flex',
|
|
771
866
|
width: cell.column.getSize(),
|
|
867
|
+
// minWidth: cell.column.getSize(),
|
|
868
|
+
// maxWidth: cell.column.getSize(),
|
|
772
869
|
height: '36px',
|
|
773
870
|
...getCommonPinningStyles(cell.column),
|
|
774
871
|
cursor: isPasting ? 'crosshair' : undefined
|
|
@@ -782,10 +879,14 @@ const TableBodyCellEdit = props => {
|
|
|
782
879
|
} else {
|
|
783
880
|
handleMouseDown(cell.row.id, cell.column.id);
|
|
784
881
|
if (editingKey) {
|
|
785
|
-
setTimeout(() => {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
})
|
|
882
|
+
// setTimeout(() => {
|
|
883
|
+
// setEditingKey?.('')
|
|
884
|
+
// reset?.()
|
|
885
|
+
// })
|
|
886
|
+
|
|
887
|
+
handleChange();
|
|
888
|
+
setEditingKey?.('');
|
|
889
|
+
reset?.();
|
|
789
890
|
}
|
|
790
891
|
|
|
791
892
|
// reset?.()
|
|
@@ -812,8 +913,6 @@ const TableBodyCellEdit = props => {
|
|
|
812
913
|
if (e.key === 'Enter') {
|
|
813
914
|
e.preventDefault();
|
|
814
915
|
e.stopPropagation();
|
|
815
|
-
setEditingKey?.('');
|
|
816
|
-
reset?.();
|
|
817
916
|
const currentRowIndex = allRows.findIndex(r => r.id === cell.row.id);
|
|
818
917
|
const nextRow = allRows[currentRowIndex + 1];
|
|
819
918
|
if (nextRow) {
|
|
@@ -836,47 +935,38 @@ const TableBodyCellEdit = props => {
|
|
|
836
935
|
rowId: nextRow.id,
|
|
837
936
|
colId: cell.column.id
|
|
838
937
|
}));
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
} else {
|
|
842
|
-
const newRowId = newGuid();
|
|
843
|
-
handleAddMulti?.({}, 1, newRowId);
|
|
844
|
-
setFocusedCell?.({
|
|
845
|
-
rowId: newRowId,
|
|
846
|
-
colId: cell.column.id
|
|
847
|
-
});
|
|
848
|
-
setStartCell?.({
|
|
849
|
-
rowId: newRowId,
|
|
850
|
-
colId: cell.column.id
|
|
938
|
+
rowVirtualizer.scrollToIndex(nextRow.index, {
|
|
939
|
+
align: 'center'
|
|
851
940
|
});
|
|
852
|
-
setEndCell?.({
|
|
853
|
-
rowId: newRowId,
|
|
854
|
-
colId: cell.column.id
|
|
855
|
-
});
|
|
856
|
-
setTimeout(() => {
|
|
857
|
-
setRangeState?.(getSelectedCellMatrix(table, {
|
|
858
|
-
rowId: newRowId,
|
|
859
|
-
colId: cell.column.id
|
|
860
|
-
}, {
|
|
861
|
-
rowId: newRowId,
|
|
862
|
-
colId: cell.column.id
|
|
863
|
-
}));
|
|
864
|
-
// rowVirtualizer.scrollToIndex(101)
|
|
865
|
-
}, 0);
|
|
866
|
-
}
|
|
867
|
-
if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length) {
|
|
868
|
-
|
|
869
|
-
// handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event)
|
|
870
941
|
} else {
|
|
871
|
-
// // focus cell hiện tại và tắt edit
|
|
872
|
-
// handleFocusCell((rowNumber ?? 0), colIndex, column, 'vertical', event)
|
|
873
|
-
// setEditingKey('')
|
|
874
942
|
|
|
875
|
-
//
|
|
943
|
+
// const newRowId = newGuid()
|
|
944
|
+
// handleAddMulti?.({}, 1, newRowId)
|
|
945
|
+
|
|
946
|
+
// setFocusedCell?.({ rowId: newRowId, colId: cell.column.id });
|
|
876
947
|
|
|
877
|
-
//
|
|
878
|
-
//
|
|
948
|
+
// setStartCell?.({ rowId: newRowId, colId: cell.column.id });
|
|
949
|
+
// setEndCell?.({ rowId: newRowId, colId: cell.column.id });
|
|
950
|
+
|
|
951
|
+
// setTimeout(() => {
|
|
952
|
+
// setRangeState?.(getSelectedCellMatrix(table, { rowId: newRowId, colId: cell.column.id }, { rowId: newRowId, colId: cell.column.id }))
|
|
953
|
+
// // rowVirtualizer.scrollToIndex(currentRowIndex + 1, { align: 'end', })
|
|
954
|
+
|
|
955
|
+
// })
|
|
956
|
+
|
|
957
|
+
// setTimeout(() => {
|
|
958
|
+
|
|
959
|
+
// rowVirtualizer.scrollToIndex(currentRowIndex + 1, { align: 'center', })
|
|
960
|
+
|
|
961
|
+
// }, 100)
|
|
879
962
|
}
|
|
963
|
+
handleChange();
|
|
964
|
+
setEditingKey?.('');
|
|
965
|
+
reset?.();
|
|
966
|
+
|
|
967
|
+
// setTimeout(() => {
|
|
968
|
+
|
|
969
|
+
// })
|
|
880
970
|
}
|
|
881
971
|
}
|
|
882
972
|
}
|
|
@@ -950,6 +1040,8 @@ const TableBodyCellEdit = props => {
|
|
|
950
1040
|
onDoubleClick: handlePointDoubleClick
|
|
951
1041
|
}, /*#__PURE__*/React.createElement("span", {
|
|
952
1042
|
className: 'dot-point'
|
|
953
|
-
}))
|
|
1043
|
+
})), !isEditing && rowError && rowError[cell.column.id]?.field === cell.column.id && /*#__PURE__*/React.createElement("span", {
|
|
1044
|
+
className: "isValid"
|
|
1045
|
+
}));
|
|
954
1046
|
};
|
|
955
1047
|
export default TableBodyCellEdit;
|
|
@@ -42,7 +42,7 @@ export const getCommonPinningStyles = column => {
|
|
|
42
42
|
// opacity: isPinned ? 0.5 : 1,
|
|
43
43
|
opacity: 1,
|
|
44
44
|
position: isPinned ? "sticky" : "relative",
|
|
45
|
-
width: column.getSize(),
|
|
45
|
+
// width: column.getSize(),
|
|
46
46
|
zIndex: isPinned ? 2 : 0
|
|
47
47
|
// border: '1px solid #e5e7eb',
|
|
48
48
|
// borderTop: 0,
|
|
@@ -309,7 +309,7 @@ export function getFixedFields(columns, type) {
|
|
|
309
309
|
const result = [];
|
|
310
310
|
function traverse(cols) {
|
|
311
311
|
for (const col of cols) {
|
|
312
|
-
if ((col.fixed ?? col.fixedType) === type && col.field) {
|
|
312
|
+
if ((col.fixed ?? col.fixedType) === type && col.field && col.visible !== false) {
|
|
313
313
|
result.push(col.field);
|
|
314
314
|
}
|
|
315
315
|
if (col.children && col.children.length > 0) {
|