es-grid-template 1.9.62 → 1.9.64
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/ali-table/Grid.js +6 -3
- package/es/ali-table/InternalTable.js +500 -49
- package/es/ali-table/base-table/calculations.js +1 -1
- package/es/ali-table/base-table/cell/EditCell.js +14 -6
- package/es/ali-table/base-table/renderFilter.js +1 -1
- package/es/ali-table/base-table/styles.js +1 -1
- package/es/ali-table/interfaces.d.ts +2 -2
- package/es/ali-table/pipeline/features/columnCustom.d.ts +5 -2
- package/es/ali-table/pipeline/features/columnCustom.js +172 -102
- package/es/ali-table/utils/constants.d.ts +1 -0
- package/es/ali-table/utils/constants.js +1 -0
- package/es/ali-table/utils/convertColumnsChoose.d.ts +2 -2
- package/es/ali-table/utils/convertColumnsChoose.js +1 -2
- package/es/ali-table/utils/utility.d.ts +16 -1
- package/es/ali-table/utils/utility.js +442 -2
- package/es/grid-component/type.d.ts +2 -2
- package/es/table-component/TableContainerEdit.js +148 -98
- package/es/table-component/body/EditableCell.js +9 -5
- package/es/table-component/body/TableBodyCellEdit.js +14 -8
- package/es/table-component/header/renderFilter.js +1 -1
- package/es/table-component/hook/utils.d.ts +1 -1
- package/es/table-component/hook/utils.js +2 -6
- package/es/table-component/useContext.d.ts +1 -1
- package/lib/ali-table/Grid.js +6 -3
- package/lib/ali-table/InternalTable.js +491 -45
- package/lib/ali-table/base-table/calculations.js +1 -1
- package/lib/ali-table/base-table/cell/EditCell.js +14 -6
- package/lib/ali-table/base-table/renderFilter.js +1 -1
- package/lib/ali-table/base-table/styles.js +1 -1
- package/lib/ali-table/interfaces.d.ts +2 -2
- package/lib/ali-table/pipeline/features/columnCustom.d.ts +5 -2
- package/lib/ali-table/pipeline/features/columnCustom.js +166 -100
- package/lib/ali-table/utils/constants.d.ts +1 -0
- package/lib/ali-table/utils/constants.js +2 -1
- package/lib/ali-table/utils/convertColumnsChoose.d.ts +2 -2
- package/lib/ali-table/utils/convertColumnsChoose.js +1 -2
- package/lib/ali-table/utils/utility.d.ts +16 -1
- package/lib/ali-table/utils/utility.js +454 -2
- package/lib/grid-component/type.d.ts +2 -2
- package/lib/table-component/TableContainerEdit.js +148 -98
- package/lib/table-component/body/EditableCell.js +9 -5
- package/lib/table-component/body/TableBodyCellEdit.js +11 -7
- package/lib/table-component/header/renderFilter.js +1 -1
- package/lib/table-component/hook/utils.d.ts +1 -1
- package/lib/table-component/hook/utils.js +2 -6
- package/lib/table-component/useContext.d.ts +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ var fusion = _interopRequireWildcard(require("@alifd/next"));
|
|
|
11
11
|
var _locale = require("rc-master-ui/es/locale");
|
|
12
12
|
var _faker = require("@faker-js/faker");
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _usehooksTs = require("usehooks-ts");
|
|
14
15
|
require("./base-table/styles.scss");
|
|
15
16
|
var _utils = require("../table-component/hook/utils");
|
|
16
17
|
var _rcMasterUi = require("rc-master-ui");
|
|
@@ -29,9 +30,16 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
29
30
|
var _hooks = require("../grid-component/hooks");
|
|
30
31
|
var _sweetalert2ReactContent = _interopRequireDefault(require("sweetalert2-react-content"));
|
|
31
32
|
var _sweetalert = _interopRequireDefault(require("sweetalert2"));
|
|
33
|
+
var _utils2 = require("./utils");
|
|
34
|
+
var _reactNumericComponent = require("react-numeric-component");
|
|
35
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
32
36
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
33
37
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
34
38
|
const MySwal = (0, _sweetalert2ReactContent.default)(_sweetalert.default);
|
|
39
|
+
const {
|
|
40
|
+
Paragraph,
|
|
41
|
+
Title
|
|
42
|
+
} = _rcMasterUi.Typography;
|
|
35
43
|
const InternalTable = props => {
|
|
36
44
|
const {
|
|
37
45
|
t,
|
|
@@ -74,6 +82,8 @@ const InternalTable = props => {
|
|
|
74
82
|
defaultValue,
|
|
75
83
|
commandSettings,
|
|
76
84
|
headerData,
|
|
85
|
+
format,
|
|
86
|
+
onCellClick,
|
|
77
87
|
...rest
|
|
78
88
|
} = props;
|
|
79
89
|
const tableRef = (0, _react.useRef)(null);
|
|
@@ -82,6 +92,7 @@ const InternalTable = props => {
|
|
|
82
92
|
const childrenColumnName = 'children';
|
|
83
93
|
const childrenKey = 'children';
|
|
84
94
|
const [tableLocal] = (0, _locale.useLocale)('Table');
|
|
95
|
+
const [copiedText, copy] = (0, _usehooksTs.useCopyToClipboard)();
|
|
85
96
|
const tableId = _react.default.useMemo(() => {
|
|
86
97
|
return _faker.faker.string.alpha(20);
|
|
87
98
|
}, []);
|
|
@@ -91,6 +102,9 @@ const InternalTable = props => {
|
|
|
91
102
|
const languages = _react.default.useMemo(() => {
|
|
92
103
|
return (0, _useLocale.getLocales)(lang);
|
|
93
104
|
}, [lang]);
|
|
105
|
+
|
|
106
|
+
// const isCut = React.useRef<any>(false);
|
|
107
|
+
|
|
94
108
|
const getWindowSize = () => {
|
|
95
109
|
const {
|
|
96
110
|
innerWidth,
|
|
@@ -115,7 +129,7 @@ const InternalTable = props => {
|
|
|
115
129
|
const [filterState, setFilterState] = _react.default.useState(undefined);
|
|
116
130
|
const [sortState, setSortState] = _react.default.useState(undefined);
|
|
117
131
|
const columns = _react.default.useMemo(() => {
|
|
118
|
-
return (0,
|
|
132
|
+
return (0, _utility.sortByType)(propColumns, rowDnd);
|
|
119
133
|
}, [propColumns, rowDnd]);
|
|
120
134
|
const convertData = _react.default.useMemo(() => {
|
|
121
135
|
if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
@@ -124,18 +138,19 @@ const InternalTable = props => {
|
|
|
124
138
|
return (0, _utils.addRowIdArray)(dataSource);
|
|
125
139
|
}, [dataSource, groupAble, groupColumns, groupSetting]);
|
|
126
140
|
const isDataTree = _react.default.useMemo(() => {
|
|
127
|
-
return (0, _utils.isTreeArray)(
|
|
128
|
-
}, [
|
|
141
|
+
return (0, _utils.isTreeArray)(dataSource);
|
|
142
|
+
}, [dataSource]);
|
|
129
143
|
const mergedData = _react.default.useMemo(() => {
|
|
130
144
|
const shouldSkip = onFilter && onSorter;
|
|
131
145
|
if (shouldSkip) {
|
|
132
146
|
return convertData;
|
|
133
147
|
}
|
|
134
|
-
|
|
135
|
-
// const rs = filterDataByColumns(convertData, onFilter ? undefined : (filterState ?? defaultFilter), onSorter ? undefined : (sortState ?? defaultSorter), [], ignoreAccents)
|
|
136
148
|
const rss = (0, _utility.filterDataByColumns1)(convertData, onFilter ? undefined : filterState ?? defaultFilter, onSorter ? undefined : sortState ?? defaultSorter, [], ignoreAccents);
|
|
137
149
|
return rss;
|
|
138
150
|
}, [convertData, filterState, ignoreAccents, sortState, onFilter, onSorter, defaultFilter, defaultSorter]);
|
|
151
|
+
const rowIndexMap = _react.default.useMemo(() => {
|
|
152
|
+
return (0, _utils.getRowIndexMap)(convertData);
|
|
153
|
+
}, [convertData]);
|
|
139
154
|
const footerData = _react.default.useMemo(() => {
|
|
140
155
|
if (!summary) {
|
|
141
156
|
return undefined;
|
|
@@ -160,15 +175,15 @@ const InternalTable = props => {
|
|
|
160
175
|
}
|
|
161
176
|
return undefined;
|
|
162
177
|
}, [defaultFilter]);
|
|
163
|
-
|
|
164
|
-
// const columnInVisibility = React.useMemo(() => {
|
|
165
|
-
// return getInvisibleColumns(columns)
|
|
166
|
-
// }, [columns])
|
|
167
|
-
|
|
168
|
-
const dataIds = _react.default.useMemo(() => mergedData.map(it => it.rowId), [mergedData]);
|
|
169
178
|
const columnVisibility = _react.default.useMemo(() => {
|
|
170
179
|
return (0, _utils.getVisibleFields)(columns);
|
|
171
180
|
}, [columns]);
|
|
181
|
+
const dataIds = _react.default.useMemo(() => convertData.map(it => it.rowId), [convertData]);
|
|
182
|
+
|
|
183
|
+
// const columnVisibility = React.useMemo(() => {
|
|
184
|
+
// return getVisibleFields(columns)
|
|
185
|
+
// }, [columns])
|
|
186
|
+
|
|
172
187
|
const {
|
|
173
188
|
control,
|
|
174
189
|
handleSubmit,
|
|
@@ -199,7 +214,7 @@ const InternalTable = props => {
|
|
|
199
214
|
}, [onDataChange]);
|
|
200
215
|
const triggerPaste = _react.default.useCallback((pastedRows, pastedColumnsArray, newData, copyRows) => {
|
|
201
216
|
const handlePasteCallback = callbackData => {
|
|
202
|
-
const rsFilterData = (0,
|
|
217
|
+
const rsFilterData = (0, _utility.updateOrInsert)(convertData, (0, _utils.flattenArray)(callbackData));
|
|
203
218
|
const rs = (0, _utils.unFlattenData)(rsFilterData);
|
|
204
219
|
triggerChangeData(rs, {
|
|
205
220
|
type: 'OnPaste'
|
|
@@ -236,13 +251,10 @@ const InternalTable = props => {
|
|
|
236
251
|
}, [onCellPaste, convertData, triggerChangeData]);
|
|
237
252
|
const onSubmit = formData => {
|
|
238
253
|
try {
|
|
239
|
-
// const record = (await form.validateFields()) as RecordType;
|
|
240
254
|
const row = {
|
|
241
255
|
...formData
|
|
242
256
|
};
|
|
243
|
-
|
|
244
|
-
// const newData = [...dataSource]
|
|
245
|
-
const newData = [...convertData];
|
|
257
|
+
const newData = convertData;
|
|
246
258
|
const index = (0, _utils.flattenData)(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
|
|
247
259
|
const rs = (0, _utils.updateArrayByKey)(newData, row, rowKey);
|
|
248
260
|
if (index > -1) {
|
|
@@ -285,8 +297,7 @@ const InternalTable = props => {
|
|
|
285
297
|
indexRow,
|
|
286
298
|
rowData: record,
|
|
287
299
|
rowId: key,
|
|
288
|
-
|
|
289
|
-
rowsData: [...convertData],
|
|
300
|
+
rowsData: convertData,
|
|
290
301
|
sumValue: []
|
|
291
302
|
}, handleChangeCallback);
|
|
292
303
|
} else {
|
|
@@ -299,8 +310,7 @@ const InternalTable = props => {
|
|
|
299
310
|
indexRow,
|
|
300
311
|
rowData: record,
|
|
301
312
|
rowId: key,
|
|
302
|
-
|
|
303
|
-
rowsData: [...convertData],
|
|
313
|
+
rowsData: dataSource,
|
|
304
314
|
sumValue: []
|
|
305
315
|
}, handleChangeCallback);
|
|
306
316
|
onSubmit(record);
|
|
@@ -406,6 +416,7 @@ const InternalTable = props => {
|
|
|
406
416
|
columns,
|
|
407
417
|
mode: sortMultiple !== false ? 'multiple' : 'single',
|
|
408
418
|
dataSource: convertData,
|
|
419
|
+
rowIndexMap,
|
|
409
420
|
columnResizeMode: 'onChange',
|
|
410
421
|
disableUserSelectWhenResizing: true,
|
|
411
422
|
allowFiltering,
|
|
@@ -448,9 +459,12 @@ const InternalTable = props => {
|
|
|
448
459
|
handleSubmit,
|
|
449
460
|
onSubmit,
|
|
450
461
|
triggerPaste,
|
|
462
|
+
headerEditAble,
|
|
451
463
|
handleCellChange,
|
|
452
464
|
handleHeaderCellChange,
|
|
453
|
-
headerData
|
|
465
|
+
headerData,
|
|
466
|
+
triggerChangeData,
|
|
467
|
+
onCellClick
|
|
454
468
|
})).use(_pipeline.features.paginationFeature({
|
|
455
469
|
pagination
|
|
456
470
|
}));
|
|
@@ -461,14 +475,42 @@ const InternalTable = props => {
|
|
|
461
475
|
|
|
462
476
|
// reorder rows after drag & drop
|
|
463
477
|
|
|
478
|
+
const isEditing = _react.default.useMemo(() => {
|
|
479
|
+
return pipeline.getStateAtKey(_constants.stateKeyIsEditing);
|
|
480
|
+
}, [pipeline]);
|
|
481
|
+
const startCell = _react.default.useMemo(() => {
|
|
482
|
+
return pipeline.getStateAtKey(_constants.stateKeyStartCell);
|
|
483
|
+
}, [pipeline]);
|
|
484
|
+
const endCell = _react.default.useMemo(() => {
|
|
485
|
+
return pipeline.getStateAtKey(_constants.stateKeyEndCell);
|
|
486
|
+
}, [pipeline]);
|
|
487
|
+
const leafColumns = _react.default.useMemo(() => {
|
|
488
|
+
return (0, _utils2.collectNodes)(pipeline.getColumns(), 'leaf-only');
|
|
489
|
+
}, [pipeline]);
|
|
490
|
+
const rangeState = _react.default.useMemo(() => {
|
|
491
|
+
return startCell && endCell ? (0, _utils.getSelectedCellMatrix1)(convertData, leafColumns, startCell, endCell) : undefined;
|
|
492
|
+
}, [convertData, endCell, leafColumns, startCell]);
|
|
493
|
+
|
|
494
|
+
// const rowIds = React.useMemo(() => {
|
|
495
|
+
|
|
496
|
+
// return getKeys(convertData, 'rowId')
|
|
497
|
+
|
|
498
|
+
// }, [convertData])
|
|
499
|
+
|
|
500
|
+
// const colIds = React.useMemo(() => {
|
|
501
|
+
|
|
502
|
+
// const leafColumns = collectNodes(pipeline.getColumns(), 'leaf-only')
|
|
503
|
+
|
|
504
|
+
// return getKeys(leafColumns, 'field')
|
|
505
|
+
|
|
506
|
+
// }, [pipeline])
|
|
507
|
+
|
|
464
508
|
_react.default.useEffect(() => {
|
|
465
509
|
const handleClickOutside = event => {
|
|
466
510
|
if (!editAble) {
|
|
467
511
|
return;
|
|
468
512
|
}
|
|
469
513
|
const isEditting = pipeline.getStateAtKey(_constants.stateKeyIsEditing);
|
|
470
|
-
const startCell = pipeline.getStateAtKey(_constants.stateKeyStartCell);
|
|
471
|
-
const endCell = pipeline.getStateAtKey(_constants.stateKeyEndCell);
|
|
472
514
|
const focusedCell = pipeline.getStateAtKey(_constants.stateKeyFocusedCell);
|
|
473
515
|
const element = event.target;
|
|
474
516
|
const container = document.querySelector(".be-popup-container");
|
|
@@ -533,15 +575,11 @@ const InternalTable = props => {
|
|
|
533
575
|
return () => {
|
|
534
576
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
535
577
|
};
|
|
536
|
-
}, [tableId, pipeline, editAble, headerEditAble]);
|
|
578
|
+
}, [tableId, pipeline, editAble, headerEditAble, endCell, startCell]);
|
|
537
579
|
const rowsFocus = _react.default.useMemo(() => {
|
|
538
|
-
const startCell = pipeline.getStateAtKey(_constants.stateKeyStartCell);
|
|
539
|
-
const endCell = pipeline.getStateAtKey(_constants.stateKeyEndCell);
|
|
540
|
-
const allRows = pipeline.getDataSource(); // flat data
|
|
541
|
-
const rowIndexMap = (0, _utils.getRowIndexMap)(allRows);
|
|
542
580
|
const selectRowIds = startCell && endCell ? (0, _utils.getRowIdsBetween3)(convertData, rowIndexMap, startCell.rowId, endCell.rowId) : [];
|
|
543
581
|
return selectRowIds;
|
|
544
|
-
}, [convertData,
|
|
582
|
+
}, [convertData, endCell, rowIndexMap, startCell]);
|
|
545
583
|
function handleDragEnd(event) {
|
|
546
584
|
const {
|
|
547
585
|
active,
|
|
@@ -552,7 +590,7 @@ const InternalTable = props => {
|
|
|
552
590
|
|
|
553
591
|
const oldIndex = dataIds.indexOf(active.id);
|
|
554
592
|
const newIndex = dataIds.indexOf(over.id);
|
|
555
|
-
const rs = (0, _sortable.arrayMove)(
|
|
593
|
+
const rs = (0, _sortable.arrayMove)(dataSource, oldIndex, newIndex); // this is just a splice util
|
|
556
594
|
|
|
557
595
|
if (rowDnd?.onChange) {
|
|
558
596
|
rowDnd?.onChange({
|
|
@@ -568,7 +606,7 @@ const InternalTable = props => {
|
|
|
568
606
|
toolbar: item
|
|
569
607
|
});
|
|
570
608
|
} else {
|
|
571
|
-
const filterData = (0, _utils.flattenArray)(
|
|
609
|
+
const filterData = (0, _utils.flattenArray)(convertData);
|
|
572
610
|
const rs = filterData.filter(it => !rowsFocus.includes(it[rowKey]));
|
|
573
611
|
const newDaa = (0, _utils.unFlattenData)(rs);
|
|
574
612
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
@@ -587,7 +625,7 @@ const InternalTable = props => {
|
|
|
587
625
|
buttonsStyling: false
|
|
588
626
|
}).then(async result => {
|
|
589
627
|
if (result.value) {
|
|
590
|
-
triggerChangeData?.(
|
|
628
|
+
triggerChangeData?.(newDaa, {
|
|
591
629
|
type: 'DELETE_ROWS',
|
|
592
630
|
row: rowsFocus.length
|
|
593
631
|
});
|
|
@@ -595,7 +633,7 @@ const InternalTable = props => {
|
|
|
595
633
|
});
|
|
596
634
|
} else {
|
|
597
635
|
// không hiện dialog
|
|
598
|
-
triggerChangeData?.(
|
|
636
|
+
triggerChangeData?.(newDaa, {
|
|
599
637
|
type: 'DELETE_ROWS',
|
|
600
638
|
row: rowsFocus.length
|
|
601
639
|
});
|
|
@@ -668,7 +706,7 @@ const InternalTable = props => {
|
|
|
668
706
|
// không tính tree
|
|
669
707
|
|
|
670
708
|
// Cập nhật data mới
|
|
671
|
-
const newData = (0, _utils.flattenArray)(
|
|
709
|
+
const newData = (0, _utils.flattenArray)(convertData);
|
|
672
710
|
const focusedCell = pipeline.getStateAtKey(_constants.stateKeyFocusedCell);
|
|
673
711
|
const duplicatedItem = newData.find(it => it.rowId === focusedCell?.rowId);
|
|
674
712
|
const duplicatedItems = [{
|
|
@@ -683,7 +721,7 @@ const InternalTable = props => {
|
|
|
683
721
|
// const insertAfter = Math.max(...rowsFocus)
|
|
684
722
|
const insertAfter = newData.findIndex(it => it[rowKey] === focusedCell?.rowId);
|
|
685
723
|
const rsFilter = [...newData.slice(0, insertAfter + 1), ...duplicatedItems, ...newData.slice(insertAfter + 1)];
|
|
686
|
-
const rs = (0,
|
|
724
|
+
const rs = (0, _utility.updateOrInsert)(convertData, rsFilter);
|
|
687
725
|
triggerChangeData?.(rs, {
|
|
688
726
|
type: 'DUPLICATE'
|
|
689
727
|
});
|
|
@@ -705,7 +743,7 @@ const InternalTable = props => {
|
|
|
705
743
|
if (!record?.parentId) {
|
|
706
744
|
// Cập nhật data mới
|
|
707
745
|
|
|
708
|
-
const newData =
|
|
746
|
+
const newData = convertData;
|
|
709
747
|
const newRows = Array.from({
|
|
710
748
|
length: n
|
|
711
749
|
}).map(() => defaultRowValue ? {
|
|
@@ -730,7 +768,7 @@ const InternalTable = props => {
|
|
|
730
768
|
row: n
|
|
731
769
|
});
|
|
732
770
|
} else {
|
|
733
|
-
const newData =
|
|
771
|
+
const newData = convertData;
|
|
734
772
|
const parent = (0, _utils.findItemByKey)(newData, rowKey, record.parentId);
|
|
735
773
|
const newRows = Array.from({
|
|
736
774
|
length: n
|
|
@@ -746,7 +784,7 @@ const InternalTable = props => {
|
|
|
746
784
|
});
|
|
747
785
|
|
|
748
786
|
// Cập nhật childData mới
|
|
749
|
-
const childData = parent?.children ?
|
|
787
|
+
const childData = parent?.children ? parent.children : [];
|
|
750
788
|
const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
751
789
|
childData.splice(index, 0, ...newRows);
|
|
752
790
|
const newRowData = {
|
|
@@ -769,7 +807,7 @@ const InternalTable = props => {
|
|
|
769
807
|
|
|
770
808
|
// const insertAfter = Math.max(...rowsFocus)
|
|
771
809
|
|
|
772
|
-
// const record: RecordType = flattenData(childrenColumnName,
|
|
810
|
+
// const record: RecordType = flattenData(childrenColumnName, convertData)[insertAfter]
|
|
773
811
|
|
|
774
812
|
// const record: any = table.getRowModel().rows.find((it) => it.id === focusedCell?.rowId)?.original
|
|
775
813
|
const record = convertData.find(it => it.rowId === focusedCell?.rowId);
|
|
@@ -780,7 +818,7 @@ const InternalTable = props => {
|
|
|
780
818
|
} else {
|
|
781
819
|
if (!record?.parentId) {
|
|
782
820
|
// Cập nhật data mới
|
|
783
|
-
const newData =
|
|
821
|
+
const newData = convertData;
|
|
784
822
|
const newRows = Array.from({
|
|
785
823
|
length: n
|
|
786
824
|
}).map(() => defaultRowValue ? {
|
|
@@ -805,7 +843,7 @@ const InternalTable = props => {
|
|
|
805
843
|
row: n
|
|
806
844
|
});
|
|
807
845
|
} else {
|
|
808
|
-
const newData =
|
|
846
|
+
const newData = convertData;
|
|
809
847
|
const parent = (0, _utils.findItemByKey)(newData, rowKey, record.parentId);
|
|
810
848
|
const newRows = Array.from({
|
|
811
849
|
length: n
|
|
@@ -827,7 +865,7 @@ const InternalTable = props => {
|
|
|
827
865
|
// setMergedFilterKeys?.(rs)
|
|
828
866
|
|
|
829
867
|
// Cập nhật childData mới
|
|
830
|
-
const childData = parent?.children ?
|
|
868
|
+
const childData = parent?.children ? parent.children : [];
|
|
831
869
|
const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
832
870
|
childData.splice(index + 1, 0, ...newRows);
|
|
833
871
|
const newRowData = {
|
|
@@ -852,8 +890,7 @@ const InternalTable = props => {
|
|
|
852
890
|
toolbar: item
|
|
853
891
|
});
|
|
854
892
|
} else {
|
|
855
|
-
|
|
856
|
-
const newData = [...convertData];
|
|
893
|
+
const newData = convertData;
|
|
857
894
|
let newElement;
|
|
858
895
|
if (!record?.children || record?.children && record.children.length === 0) {
|
|
859
896
|
newElement = {
|
|
@@ -905,6 +942,415 @@ const InternalTable = props => {
|
|
|
905
942
|
// setInnerExpandedKeys(newExpandedKeys)
|
|
906
943
|
// }
|
|
907
944
|
}, [convertData, defaultValue, pipeline, triggerChangeData]);
|
|
945
|
+
|
|
946
|
+
// Copy
|
|
947
|
+
|
|
948
|
+
const copySelectionToClipboard = _react.default.useCallback(() => {
|
|
949
|
+
if (!startCell || !endCell) {
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
const allRows = dataSource;
|
|
953
|
+
const rowIds = (0, _utils.getRowIdsBetween3)(convertData, rowIndexMap, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
954
|
+
const colIds = (0, _utils.getColIdsBetween1)(leafColumns, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
955
|
+
const dataToCopy = [];
|
|
956
|
+
rowIds.forEach(rowId => {
|
|
957
|
+
const row = allRows.find(r => r.rowId === rowId);
|
|
958
|
+
if (!row) return;
|
|
959
|
+
const rowData = [];
|
|
960
|
+
colIds.forEach(colId => {
|
|
961
|
+
const value = row[colId];
|
|
962
|
+
rowData.push(value !== undefined ? String(value) : '');
|
|
963
|
+
});
|
|
964
|
+
dataToCopy.push(rowData);
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
// Convert to TSV string
|
|
968
|
+
const tsv = dataToCopy.map(row => row.join('\t')).join('\n');
|
|
969
|
+
copy(tsv).then(() => {}).catch(() => {});
|
|
970
|
+
}, [startCell, endCell, dataSource, convertData, rowIndexMap, leafColumns, copy]);
|
|
971
|
+
_react.default.useEffect(() => {
|
|
972
|
+
const handleKeyDown = e => {
|
|
973
|
+
if (e.ctrlKey && e.key === 'c' && startCell && endCell && !isEditing) {
|
|
974
|
+
e.preventDefault();
|
|
975
|
+
copySelectionToClipboard();
|
|
976
|
+
}
|
|
977
|
+
if (e.ctrlKey && e.key === 'x' && startCell && endCell && !isEditing) {
|
|
978
|
+
e.preventDefault();
|
|
979
|
+
if (startCell && endCell) {
|
|
980
|
+
const tmpData = (0, _utils.flattenArray)(convertData);
|
|
981
|
+
const rs = tmpData.map((row, index) => {
|
|
982
|
+
if (!rangeState?.rowRange.includes(row.rowId)) {
|
|
983
|
+
return row;
|
|
984
|
+
}
|
|
985
|
+
const updatedRow = {
|
|
986
|
+
...row
|
|
987
|
+
};
|
|
988
|
+
for (const field of rangeState.colRange) {
|
|
989
|
+
const col = leafColumns.find(it => it.field === field);
|
|
990
|
+
const columnIndex = leafColumns.findIndex(it => it.field === field);
|
|
991
|
+
if ((0, _utils.isEditable)(col, row)) {
|
|
992
|
+
let newValue = '';
|
|
993
|
+
if (col.type === 'number') {
|
|
994
|
+
newValue = 0;
|
|
995
|
+
}
|
|
996
|
+
if (col.type === 'boolean' || col.type === 'checkbox') {
|
|
997
|
+
newValue = false;
|
|
998
|
+
}
|
|
999
|
+
const cellEditType = (0, _hooks.getEditType)(col, row);
|
|
1000
|
+
if (col.type === 'date' || col.type === 'datetime' || col.type === 'time' || col.type === 'month' || col.type === 'week' || col.type === 'year' || col.type === 'quarter' || cellEditType === 'asyncSelect' || cellEditType === 'select' || cellEditType === 'treeSelect' || cellEditType === 'selectTable') {
|
|
1001
|
+
newValue = undefined;
|
|
1002
|
+
}
|
|
1003
|
+
updatedRow[col.field] = newValue;
|
|
1004
|
+
handleCellChange({
|
|
1005
|
+
key: row[rowKey],
|
|
1006
|
+
field: col.field,
|
|
1007
|
+
record: updatedRow,
|
|
1008
|
+
prevState: row[col.field],
|
|
1009
|
+
newState: newValue,
|
|
1010
|
+
option: '',
|
|
1011
|
+
indexCol: columnIndex,
|
|
1012
|
+
indexRow: index,
|
|
1013
|
+
type: e.key
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return updatedRow;
|
|
1018
|
+
});
|
|
1019
|
+
const newData = (0, _utils.unFlattenData)(rs);
|
|
1020
|
+
triggerChangeData?.(newData, {
|
|
1021
|
+
type: 'DELETE_CONTENT'
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
copySelectionToClipboard();
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
1028
|
+
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
1029
|
+
}, [startCell, endCell, copySelectionToClipboard, isEditing, convertData, triggerChangeData, leafColumns, handleCellChange, rangeState?.rowRange, rangeState?.colRange]);
|
|
1030
|
+
|
|
1031
|
+
// Copy
|
|
1032
|
+
|
|
1033
|
+
// paste
|
|
1034
|
+
|
|
1035
|
+
const handlePasted = _react.default.useCallback(pasteData => {
|
|
1036
|
+
if (!startCell) {
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
const rows = pasteData.slice(0, onCellPaste?.maxRowsPaste ?? 200);
|
|
1040
|
+
const allRows = convertData;
|
|
1041
|
+
const allCols = (0, _utils2.collectNodes)(pipeline.getColumns(), 'leaf-only');
|
|
1042
|
+
const startRowIdx = rowIndexMap.get(startCell.rowId);
|
|
1043
|
+
const startColIdx = allCols.findIndex(c => c.field === startCell.colId);
|
|
1044
|
+
|
|
1045
|
+
// const record: any = allRows[startRowIdx].original
|
|
1046
|
+
|
|
1047
|
+
// const record: any = table.getRow(startCell.rowId).original
|
|
1048
|
+
const recordIndex = rowIndexMap.get(startCell.rowId);
|
|
1049
|
+
const row = recordIndex ? allRows[recordIndex] : {};
|
|
1050
|
+
if (!row.parentId) {
|
|
1051
|
+
// Cập nhật data mới
|
|
1052
|
+
const newData = (0, _utils.flattenArray)(convertData);
|
|
1053
|
+
|
|
1054
|
+
// Lấy vị trí bắt đầu
|
|
1055
|
+
|
|
1056
|
+
// const startRow = newData.findIndex((it) => it[rowKey as any] === record[rowKey])
|
|
1057
|
+
const startRow = startRowIdx;
|
|
1058
|
+
const startCol = startColIdx;
|
|
1059
|
+
const pastedRows = [];
|
|
1060
|
+
const pastedColumns = new Set();
|
|
1061
|
+
rows.forEach((rowValues, rowIndex) => {
|
|
1062
|
+
const targetRow = startRow + rowIndex;
|
|
1063
|
+
|
|
1064
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1065
|
+
if (targetRow >= newData.length) {
|
|
1066
|
+
const newID = (0, _utils.newGuid)();
|
|
1067
|
+
const defaultRowValue = (0, _utils.getDefaultValue)(defaultValue);
|
|
1068
|
+
newData.push(defaultValue ? {
|
|
1069
|
+
...defaultRowValue,
|
|
1070
|
+
id: undefined,
|
|
1071
|
+
rowId: newID
|
|
1072
|
+
} : {
|
|
1073
|
+
id: undefined,
|
|
1074
|
+
rowId: newID
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
rowValues.forEach((cellValue, colIndex) => {
|
|
1078
|
+
const targetCol = startCol + colIndex;
|
|
1079
|
+
if (targetCol >= allCols.length) {
|
|
1080
|
+
// Không vượt quá số cột
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
const columnOri = allCols[targetCol];
|
|
1084
|
+
const isEdit = typeof columnOri?.editEnable === 'function' ? columnOri.editEnable(newData[targetRow]) : columnOri.editEnable;
|
|
1085
|
+
if (isEdit) {
|
|
1086
|
+
const columnKey = allCols[targetCol].field;
|
|
1087
|
+
if (columnOri.type === 'number') {
|
|
1088
|
+
if (cellValue.trim() === '') {
|
|
1089
|
+
newData[targetRow] = {
|
|
1090
|
+
...newData[targetRow],
|
|
1091
|
+
[columnKey]: null
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
if ((0, _utils.isFormattedNumber)(cellValue.trim()) || !isNaN(Number(cellValue.trim()))) {
|
|
1095
|
+
const colFormat = typeof columnOri.format === 'function' ? columnOri.format(row) : columnOri.format;
|
|
1096
|
+
const valuePasteFormat = (0, _utils.detectSeparators)(cellValue.trim());
|
|
1097
|
+
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
1098
|
+
const thousandSeparator = valuePasteFormat?.thousandSeparator;
|
|
1099
|
+
const decimalSeparator = valuePasteFormat?.decimalSeparator;
|
|
1100
|
+
const dec = cellFormat?.decimalScale;
|
|
1101
|
+
const numericFormatProps = {
|
|
1102
|
+
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
1103
|
+
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
1104
|
+
allowNegative: cellFormat?.allowNegative ?? true,
|
|
1105
|
+
prefix: cellFormat?.prefix,
|
|
1106
|
+
suffix: cellFormat?.suffix,
|
|
1107
|
+
decimalScale: dec,
|
|
1108
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
1109
|
+
};
|
|
1110
|
+
const val = (0, _reactNumericComponent.removeNumericFormat)(cellValue.trim(), undefined, numericFormatProps);
|
|
1111
|
+
newData[targetRow] = {
|
|
1112
|
+
...newData[targetRow],
|
|
1113
|
+
[columnKey]: Number(val)
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
} else if (columnOri.type === 'data' || columnOri.type === 'datatime' || columnOri.editType === 'date' || columnOri.editType === 'datetime') {
|
|
1117
|
+
const isDate = (0, _utils.isDateValue)(cellValue.trim());
|
|
1118
|
+
const date = isDate && !(0, _utils.isEmpty)(cellValue.trim()) ? (0, _moment.default)(cellValue.trim()).format() : null;
|
|
1119
|
+
newData[targetRow] = {
|
|
1120
|
+
...newData[targetRow],
|
|
1121
|
+
[columnKey]: date
|
|
1122
|
+
};
|
|
1123
|
+
} else {
|
|
1124
|
+
newData[targetRow] = {
|
|
1125
|
+
...newData[targetRow],
|
|
1126
|
+
[columnKey]: cellValue.trim()
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
pastedColumns.add(columnKey);
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
1132
|
+
|
|
1133
|
+
// Lưu dòng được paste
|
|
1134
|
+
pastedRows.push(newData[targetRow]);
|
|
1135
|
+
});
|
|
1136
|
+
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
1137
|
+
const rsFilterData = (0, _utility.updateOrInsert)(convertData, newData);
|
|
1138
|
+
const rs = (0, _utils.unFlattenData)(rsFilterData);
|
|
1139
|
+
triggerPaste?.(pastedRows, pastedColumnsArray, rs, []);
|
|
1140
|
+
} else {
|
|
1141
|
+
// const parent = findItemByKey(convertData, rowKey as any, record.parentId)
|
|
1142
|
+
const parent = row.getParentRow()?.original;
|
|
1143
|
+
|
|
1144
|
+
// Cập nhật childData mới
|
|
1145
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
1146
|
+
|
|
1147
|
+
// Lấy vị trí bắt đầu
|
|
1148
|
+
// const { row: startRow, col: startCol } = selectedCell;
|
|
1149
|
+
const startRow = childData.findIndex(it => it[rowKey] === row[rowKey]);
|
|
1150
|
+
const startCol = startColIdx;
|
|
1151
|
+
const pastedRows = [];
|
|
1152
|
+
const pastedColumns = new Set();
|
|
1153
|
+
rows.forEach((rowValues, rowIndex) => {
|
|
1154
|
+
const targetRow = startRow + rowIndex;
|
|
1155
|
+
|
|
1156
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
1157
|
+
if (targetRow >= childData.length) {
|
|
1158
|
+
childData.push({
|
|
1159
|
+
id: undefined,
|
|
1160
|
+
rowId: (0, _utils.newGuid)(),
|
|
1161
|
+
parentId: parent[rowKey ?? 'id']
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
rowValues.forEach((cellValue, colIndex) => {
|
|
1165
|
+
const targetCol = startCol + colIndex;
|
|
1166
|
+
if (targetCol >= allCols.length) {
|
|
1167
|
+
// Không vượt quá số cột
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
const columnTarget = allCols[targetCol];
|
|
1171
|
+
const columnOri = columnTarget.columnDef.meta ?? {};
|
|
1172
|
+
const isEdit = typeof columnOri?.editEnable === 'function' ? columnOri.editEnable(childData[targetRow]) : columnOri.editEnable;
|
|
1173
|
+
if (isEdit) {
|
|
1174
|
+
const columnKey = allCols[targetCol].id;
|
|
1175
|
+
if (columnOri.type === 'number') {
|
|
1176
|
+
if (cellValue.trim() === '') {
|
|
1177
|
+
childData[targetRow] = {
|
|
1178
|
+
...childData[targetRow],
|
|
1179
|
+
[columnKey]: null
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
if ((0, _utils.isFormattedNumber)(cellValue.trim()) || !isNaN(Number(cellValue.trim()))) {
|
|
1183
|
+
const colFormat = typeof columnOri.format === 'function' ? columnOri.format(row) : columnOri.format;
|
|
1184
|
+
const valuePasteFormat = (0, _utils.detectSeparators)(cellValue.trim());
|
|
1185
|
+
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
1186
|
+
const thousandSeparator = valuePasteFormat?.thousandSeparator;
|
|
1187
|
+
const decimalSeparator = valuePasteFormat?.decimalSeparator;
|
|
1188
|
+
const dec = cellFormat?.decimalScale;
|
|
1189
|
+
const numericFormatProps = {
|
|
1190
|
+
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
1191
|
+
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
1192
|
+
allowNegative: cellFormat?.allowNegative ?? true,
|
|
1193
|
+
prefix: cellFormat?.prefix,
|
|
1194
|
+
suffix: cellFormat?.suffix,
|
|
1195
|
+
decimalScale: dec,
|
|
1196
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
1197
|
+
};
|
|
1198
|
+
const val = (0, _reactNumericComponent.removeNumericFormat)(cellValue.trim(), undefined, numericFormatProps);
|
|
1199
|
+
childData[targetRow] = {
|
|
1200
|
+
...childData[targetRow],
|
|
1201
|
+
[columnKey]: Number(val)
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
} else if (columnOri.type === 'data' || columnOri.type === 'datatime' || columnOri.editType === 'date' || columnOri.editType === 'datetime') {
|
|
1205
|
+
const isDate = (0, _utils.isDateValue)(cellValue.trim());
|
|
1206
|
+
const date = isDate && !(0, _utils.isEmpty)(cellValue.trim()) ? (0, _moment.default)(cellValue.trim()).format() : null;
|
|
1207
|
+
childData[targetRow] = {
|
|
1208
|
+
...childData[targetRow],
|
|
1209
|
+
[columnKey]: date
|
|
1210
|
+
};
|
|
1211
|
+
} else {
|
|
1212
|
+
childData[targetRow] = {
|
|
1213
|
+
...childData[targetRow],
|
|
1214
|
+
[columnKey]: cellValue.trim()
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
pastedColumns.add(columnKey);
|
|
1218
|
+
}
|
|
1219
|
+
});
|
|
1220
|
+
|
|
1221
|
+
// Lưu dòng được paste
|
|
1222
|
+
pastedRows.push(childData[targetRow]);
|
|
1223
|
+
});
|
|
1224
|
+
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
1225
|
+
const newRowData = {
|
|
1226
|
+
...parent,
|
|
1227
|
+
children: childData
|
|
1228
|
+
}; // item đã được filter
|
|
1229
|
+
|
|
1230
|
+
const newDataSource = (0, _utils.updateArrayByKey)(convertData, newRowData, rowKey);
|
|
1231
|
+
triggerPaste?.(pastedRows, pastedColumnsArray, newDataSource, []);
|
|
1232
|
+
}
|
|
1233
|
+
}, [convertData, defaultValue, format, onCellPaste?.maxRowsPaste, pipeline, rowIndexMap, startCell, triggerPaste]);
|
|
1234
|
+
const handlePasteToTable = _react.default.useCallback((pasteData, e) => {
|
|
1235
|
+
if (!startCell) return;
|
|
1236
|
+
const rowsPasted = (0, _utils.parseExcelClipboard)(e);
|
|
1237
|
+
if (rowsPasted.length > (onCellPaste?.maxRowsPaste ?? 200)) {
|
|
1238
|
+
// bật popup thông báo
|
|
1239
|
+
|
|
1240
|
+
_rcMasterUi.Modal.confirm({
|
|
1241
|
+
content: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(Paragraph, {
|
|
1242
|
+
style: {
|
|
1243
|
+
marginBottom: '.25rem',
|
|
1244
|
+
fontSize: 14
|
|
1245
|
+
}
|
|
1246
|
+
}, "D\u1EEF li\u1EC7u sao ch\xE9p v\u01B0\u1EE3t qu\xE1 s\u1ED1 d\xF2ng cho ph\xE9p (", onCellPaste?.maxRowsPaste ?? 200, " d\xF2ng).Ph\u1EA7n m\u1EC1n s\u1EBD ch\u1EC9 l\u1EA5y (", onCellPaste?.maxRowsPaste ?? 200, " d\xF2ng \u0111\u1EA7u ti\xEAn."), /*#__PURE__*/_react.default.createElement(Title, {
|
|
1247
|
+
level: 5,
|
|
1248
|
+
style: {
|
|
1249
|
+
marginTop: '.75rem'
|
|
1250
|
+
}
|
|
1251
|
+
}, "B\u1EA1n c\xF3 mu\u1ED1n ti\u1EBFp t\u1EE5c sao ch\xE9p kh\xF4ng?")),
|
|
1252
|
+
centered: true,
|
|
1253
|
+
className: 'be-popup-container',
|
|
1254
|
+
onOk: () => {
|
|
1255
|
+
handlePasted(rowsPasted);
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
} else {
|
|
1259
|
+
handlePasted(rowsPasted);
|
|
1260
|
+
}
|
|
1261
|
+
}, [handlePasted, onCellPaste?.maxRowsPaste, startCell]);
|
|
1262
|
+
|
|
1263
|
+
// const handleDeleteContent = () => {
|
|
1264
|
+
|
|
1265
|
+
// if (startCell && endCell) {
|
|
1266
|
+
|
|
1267
|
+
// const tmpData = flattenArray([...convertData])
|
|
1268
|
+
|
|
1269
|
+
// const rs = tmpData.map((row, index: number) => {
|
|
1270
|
+
|
|
1271
|
+
// if (!rangeState?.rowRange.includes(row.rowId)) {
|
|
1272
|
+
// return row
|
|
1273
|
+
// }
|
|
1274
|
+
|
|
1275
|
+
// const updatedRow = { ...row }
|
|
1276
|
+
|
|
1277
|
+
// for (const colId of rangeState.colRange) {
|
|
1278
|
+
|
|
1279
|
+
// const column = leafColumns.find((it) => it.field === colId)
|
|
1280
|
+
// const columnIndex = leafColumns.findIndex((it) => it.field === colId)
|
|
1281
|
+
|
|
1282
|
+
// if (isEditable(column as any, row)) {
|
|
1283
|
+
|
|
1284
|
+
// let newValue: any = ''
|
|
1285
|
+
|
|
1286
|
+
// if (column.type === 'number') {
|
|
1287
|
+
// newValue = 0
|
|
1288
|
+
// }
|
|
1289
|
+
|
|
1290
|
+
// if (column.type === 'boolean' || column.type === 'checkbox') {
|
|
1291
|
+
// newValue = false
|
|
1292
|
+
// }
|
|
1293
|
+
|
|
1294
|
+
// const editType = getEditType(column as any, row)
|
|
1295
|
+
|
|
1296
|
+
// if (column.type === 'date' ||
|
|
1297
|
+
// column.type === 'datetime' ||
|
|
1298
|
+
// column.type === 'time' ||
|
|
1299
|
+
// column.type === 'month' ||
|
|
1300
|
+
// column.type === 'week' ||
|
|
1301
|
+
// column.type === 'year' ||
|
|
1302
|
+
// column.type === 'quarter' ||
|
|
1303
|
+
// editType === 'asyncSelect' ||
|
|
1304
|
+
// editType === 'select' ||
|
|
1305
|
+
// editType === 'treeSelect' ||
|
|
1306
|
+
// editType === 'selectTable'
|
|
1307
|
+
// ) {
|
|
1308
|
+
// newValue = undefined
|
|
1309
|
+
// }
|
|
1310
|
+
|
|
1311
|
+
// updatedRow[colId] = newValue
|
|
1312
|
+
|
|
1313
|
+
// handleCellChange({
|
|
1314
|
+
// key: row[rowKey] as any,
|
|
1315
|
+
// field: column.field ?? column.dataIndex as any,
|
|
1316
|
+
// record: updatedRow,
|
|
1317
|
+
// prevState: row[column.field],
|
|
1318
|
+
// newState: newValue,
|
|
1319
|
+
// option: '',
|
|
1320
|
+
// indexCol: columnIndex,
|
|
1321
|
+
// indexRow: index,
|
|
1322
|
+
// type: 'blur'
|
|
1323
|
+
// }
|
|
1324
|
+
// )
|
|
1325
|
+
|
|
1326
|
+
// }
|
|
1327
|
+
// }
|
|
1328
|
+
|
|
1329
|
+
// return updatedRow;
|
|
1330
|
+
// })
|
|
1331
|
+
|
|
1332
|
+
// const newData = unFlattenData(rs)
|
|
1333
|
+
|
|
1334
|
+
// triggerChangeData?.([...newData], { type: 'DELETE_CONTENT' })
|
|
1335
|
+
|
|
1336
|
+
// }
|
|
1337
|
+
|
|
1338
|
+
// }
|
|
1339
|
+
|
|
1340
|
+
_react.default.useEffect(() => {
|
|
1341
|
+
const handlePaste = e => {
|
|
1342
|
+
if (startCell && !isEditing) {
|
|
1343
|
+
e.preventDefault(); // Chặn hành vi mặc định
|
|
1344
|
+
const clipboardText = e.clipboardData?.getData('text/plain') ?? '';
|
|
1345
|
+
handlePasteToTable(clipboardText, e);
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
document.addEventListener('paste', handlePaste);
|
|
1349
|
+
return () => document.removeEventListener('paste', handlePaste);
|
|
1350
|
+
}, [startCell, endCell, handlePasteToTable, isEditing, copiedText]);
|
|
1351
|
+
|
|
1352
|
+
// Paste
|
|
1353
|
+
|
|
908
1354
|
const toolbarItemsBottom = _react.default.useMemo(() => {
|
|
909
1355
|
// Chưa có dòng| ô được chọn
|
|
910
1356
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
@@ -1493,7 +1939,7 @@ const InternalTable = props => {
|
|
|
1493
1939
|
// {...pipeline.getProps()}
|
|
1494
1940
|
,
|
|
1495
1941
|
originData: convertData,
|
|
1496
|
-
dataSource:
|
|
1942
|
+
dataSource: mergedData,
|
|
1497
1943
|
originColumns: columns,
|
|
1498
1944
|
groupColumns: groupColumns,
|
|
1499
1945
|
setVisibleKeys: setVisibleKeys,
|