es-grid-template 1.9.57 → 1.9.58
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/type.d.ts +1 -0
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/table-component/body/TableBodyCellEdit.js +154 -56
- package/es/table-component/hook/utils.d.ts +12 -1
- package/es/table-component/hook/utils.js +29 -3
- package/lib/grid-component/type.d.ts +1 -0
- package/lib/table-component/body/TableBodyCellEdit.js +153 -55
- package/lib/table-component/hook/utils.d.ts +12 -1
- package/lib/table-component/hook/utils.js +31 -4
- package/package.json +1 -1
|
@@ -194,10 +194,10 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
194
194
|
value: any;
|
|
195
195
|
rowData: RecordType;
|
|
196
196
|
}) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
197
|
-
onCellStyles?: Omit<CSSProperties, "
|
|
198
|
-
onCellHeaderStyles?: Omit<CSSProperties, "
|
|
197
|
+
onCellStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display">);
|
|
198
|
+
onCellHeaderStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display">);
|
|
199
199
|
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
200
|
-
onCellFooterStyles?: Omit<CSSProperties, "
|
|
200
|
+
onCellFooterStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display">);
|
|
201
201
|
getValue?: (row: any, rowIndex: number) => any;
|
|
202
202
|
getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
|
|
203
203
|
headerCellProps?: import("./../../grid-component/type").CellProps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Space from "rc-master-ui/es/space";
|
|
2
2
|
import Command from "../components/command/Command";
|
|
3
|
-
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getEditType, getFormat, getNextEditableColumn, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
|
|
3
|
+
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getDragRightData, getEditType, getFormat, getNextEditableColumn, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
|
|
4
4
|
import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
|
|
5
5
|
import classNames from "classnames";
|
|
6
6
|
import React from "react";
|
|
@@ -195,6 +195,7 @@ const TableBodyCellEdit = props => {
|
|
|
195
195
|
setFocusedCell,
|
|
196
196
|
setEditingKey,
|
|
197
197
|
setRangeState,
|
|
198
|
+
rangePasteState,
|
|
198
199
|
setRangePasteState,
|
|
199
200
|
endCell,
|
|
200
201
|
setEndCell,
|
|
@@ -317,7 +318,8 @@ const TableBodyCellEdit = props => {
|
|
|
317
318
|
const colPasteds = getColIdsBetween(table, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
|
|
318
319
|
const rowSelectIds = getRowIdsBetween(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
319
320
|
const colSelectIds = getColIdsBetween(table, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
320
|
-
const dataSelected = [];
|
|
321
|
+
const dataSelected = []; // data được copy
|
|
322
|
+
|
|
321
323
|
rowSelectIds.forEach(rowId => {
|
|
322
324
|
const row = allRows.find(r => r.id === rowId);
|
|
323
325
|
if (!row) return;
|
|
@@ -331,49 +333,104 @@ const TableBodyCellEdit = props => {
|
|
|
331
333
|
});
|
|
332
334
|
const copyRows = flattenData('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
|
|
333
335
|
let newRange;
|
|
334
|
-
if (
|
|
336
|
+
if (pasteState.type === 'down') {
|
|
335
337
|
// kéo xuóng
|
|
336
338
|
setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell));
|
|
337
339
|
newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length);
|
|
338
|
-
} else {
|
|
340
|
+
} else if (pasteState.type === 'up') {
|
|
339
341
|
// kéo lên
|
|
340
342
|
setStartCell?.(endCell);
|
|
341
343
|
setRangeState?.(getSelectedCellMatrix(table, endCell, endPasteCell));
|
|
342
344
|
newRange = ctrlKey ? addRowsUpWithCtrl(dataSelected, rowPasteIds.length) : addRowsUp(dataSelected, rowPasteIds.length);
|
|
345
|
+
} else if (pasteState.type === 'right') {
|
|
346
|
+
// kéo phải
|
|
347
|
+
setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell));
|
|
348
|
+
// newRange = { addedRows: [], combined: [] }
|
|
349
|
+
// newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length)
|
|
350
|
+
newRange = getDragRightData({
|
|
351
|
+
colPasteds,
|
|
352
|
+
colSelectIds,
|
|
353
|
+
copyRows,
|
|
354
|
+
rowSelectIds
|
|
355
|
+
});
|
|
356
|
+
} else if (pasteState.type === 'left') {
|
|
357
|
+
// kéo trái
|
|
358
|
+
setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell));
|
|
359
|
+
// newRange = { addedRows: [], combined: [] }
|
|
360
|
+
// newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length)
|
|
361
|
+
newRange = getDragRightData({
|
|
362
|
+
colPasteds,
|
|
363
|
+
colSelectIds,
|
|
364
|
+
copyRows,
|
|
365
|
+
rowSelectIds
|
|
366
|
+
});
|
|
343
367
|
}
|
|
344
368
|
|
|
345
369
|
// Cập nhật data mới
|
|
346
370
|
const newData = flattenArray([...dataSource]);
|
|
347
371
|
const pastedRows = [];
|
|
348
|
-
|
|
349
|
-
|
|
372
|
+
if (pasteState.type === 'down' || pasteState.type === 'up') {
|
|
373
|
+
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
374
|
+
const targetRow = pasteState.startRowIndex + rowIndex1;
|
|
350
375
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
rowValues.forEach((cellValue, colIndex1) => {
|
|
359
|
-
const targetCol = startColIndex + colIndex1;
|
|
360
|
-
if (targetCol >= tmpCols.length) {
|
|
361
|
-
// Không vượt quá số cột
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
const columnKey = tmpCols[targetCol].id;
|
|
365
|
-
const disable = !isEditable(tmpCols[targetCol].columnDef.meta, record);
|
|
366
|
-
if (!disable) {
|
|
367
|
-
newData[targetRow] = {
|
|
368
|
-
...newData[targetRow],
|
|
369
|
-
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
370
|
-
};
|
|
376
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
377
|
+
if (targetRow >= newData.length) {
|
|
378
|
+
newData.push({
|
|
379
|
+
id: undefined,
|
|
380
|
+
rowId: newGuid()
|
|
381
|
+
});
|
|
371
382
|
}
|
|
383
|
+
rowValues.forEach((cellValue, colIndex1) => {
|
|
384
|
+
const targetCol = startColIndex + colIndex1;
|
|
385
|
+
if (targetCol >= tmpCols.length) {
|
|
386
|
+
// Không vượt quá số cột
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const columnKey = tmpCols[targetCol].id;
|
|
390
|
+
const disable = !isEditable(tmpCols[targetCol].columnDef.meta, record);
|
|
391
|
+
if (!disable) {
|
|
392
|
+
newData[targetRow] = {
|
|
393
|
+
...newData[targetRow],
|
|
394
|
+
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// Lưu dòng được paste
|
|
400
|
+
pastedRows.push(newData[targetRow]);
|
|
372
401
|
});
|
|
402
|
+
}
|
|
403
|
+
if (pasteState.type === 'right' || pasteState.type === 'left') {
|
|
404
|
+
newRange.addedCols.forEach((rowValues, rowIndex1) => {
|
|
405
|
+
const targetRow = pasteState.startRowIndex + rowIndex1;
|
|
373
406
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
407
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
408
|
+
if (targetRow >= newData.length) {
|
|
409
|
+
newData.push({
|
|
410
|
+
id: undefined,
|
|
411
|
+
rowId: newGuid()
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
rowValues.forEach((cellValue, colIndex1) => {
|
|
415
|
+
const targetCol = pasteState.startColIndex + colIndex1;
|
|
416
|
+
if (targetCol >= tmpCols.length) {
|
|
417
|
+
// Không vượt quá số cột
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const columnKey = tmpCols[targetCol].id;
|
|
421
|
+
const disable = !isEditable(tmpCols[targetCol].columnDef.meta, record);
|
|
422
|
+
if (!disable) {
|
|
423
|
+
newData[targetRow] = {
|
|
424
|
+
...newData[targetRow],
|
|
425
|
+
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// Lưu dòng được paste
|
|
431
|
+
pastedRows.push(newData[targetRow]);
|
|
432
|
+
});
|
|
433
|
+
}
|
|
377
434
|
const rsFilterData = updateOrInsert(flattenArray([...originData]), newData);
|
|
378
435
|
const rs = unFlattenData(rsFilterData);
|
|
379
436
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
@@ -454,11 +511,22 @@ const TableBodyCellEdit = props => {
|
|
|
454
511
|
});
|
|
455
512
|
}
|
|
456
513
|
if (isPasting) {
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
|
|
514
|
+
const allCols = table.getAllLeafColumns();
|
|
515
|
+
const absRowIndex = table.getRowModel().flatRows.findIndex(it => it.id === rowId); // row cell con chỏ chuột hiện tại
|
|
516
|
+
const absColIndex = allCols.findIndex(it => it.id === colId); // col cell con chỏ chuột hiện tại
|
|
460
517
|
|
|
461
|
-
|
|
518
|
+
// const absColIndex = allCols.findIndex((it) => it.id === endCell?.colId )
|
|
519
|
+
|
|
520
|
+
const endCellColIndex = allCols.findIndex(it => it.id === endCell?.colId); // col cuối cùng vùng được copy
|
|
521
|
+
|
|
522
|
+
const rowGap = absRowIndex - (endRowIndex ?? 0);
|
|
523
|
+
const colGap = absColIndex - (endCellColIndex ?? 0);
|
|
524
|
+
const absRowGap = rangeState?.rowRange.length === 1 ? rowGap : rowGap >= 0 ? rowGap : rowGap + (rangeState?.rowRange.length ?? 0) - 1;
|
|
525
|
+
const absColGap = rangeState?.colRange.length === 1 ? colGap : colGap >= 0 ? colGap : colGap + (rangeState?.colRange.length ?? 0) - 1;
|
|
526
|
+
if (rowGap > 0 && absRowGap > 0 && Math.abs(absRowGap) >= Math.abs(absColGap)) {
|
|
527
|
+
// kéo xuống : cell cuối trùng endCell
|
|
528
|
+
const findIndex = allRows.findIndex(it => it.id === endCell?.rowId);
|
|
529
|
+
const startRowPaste = allRows[findIndex + 1];
|
|
462
530
|
setStartPasteCell?.({
|
|
463
531
|
colId: startCell?.colId ?? '',
|
|
464
532
|
rowId: startRowPaste?.id ?? ''
|
|
@@ -473,28 +541,57 @@ const TableBodyCellEdit = props => {
|
|
|
473
541
|
}, {
|
|
474
542
|
colId: endCell?.colId ?? '',
|
|
475
543
|
rowId
|
|
476
|
-
}));
|
|
544
|
+
}, 'down'));
|
|
545
|
+
return;
|
|
477
546
|
}
|
|
478
|
-
if (
|
|
479
|
-
//
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
const startRowPaste = allRows[findIndex + 1];
|
|
483
|
-
setStartPasteCell?.({
|
|
484
|
-
colId: startCell?.colId ?? '',
|
|
485
|
-
rowId: startRowPaste?.id ?? ''
|
|
486
|
-
});
|
|
487
|
-
setEndPasteCell?.({
|
|
488
|
-
colId: endCell?.colId ?? '',
|
|
489
|
-
rowId
|
|
490
|
-
});
|
|
491
|
-
setRangePasteState?.(getSelectedCellMatrix(table, {
|
|
547
|
+
if (rowGap < 0 && absRowGap < 0 && Math.abs(absRowGap) >= Math.abs(absColGap)) {
|
|
548
|
+
// kéo lên
|
|
549
|
+
const startRowPaste = allRows.find(it => it.index === (startRowIndex ?? 0) - 1);
|
|
550
|
+
const startPastCell = {
|
|
492
551
|
colId: startCell?.colId ?? '',
|
|
493
552
|
rowId: startRowPaste?.id ?? ''
|
|
494
|
-
}
|
|
553
|
+
};
|
|
554
|
+
const endPastCell = {
|
|
495
555
|
colId: endCell?.colId ?? '',
|
|
496
556
|
rowId
|
|
497
|
-
}
|
|
557
|
+
};
|
|
558
|
+
setStartPasteCell?.(startPastCell);
|
|
559
|
+
setEndPasteCell?.(endPastCell);
|
|
560
|
+
setRangePasteState?.(getSelectedCellMatrix(table, startPastCell, endPastCell, 'up'));
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (colGap > 0 && absColGap > 0 && Math.abs(absColGap) > Math.abs(absRowGap)) {
|
|
564
|
+
const startCol = allCols[(rangeState?.endColIndex ?? 0) + 1];
|
|
565
|
+
const startPastCell = {
|
|
566
|
+
colId: startCol?.id ?? '',
|
|
567
|
+
rowId: rangeState?.rowRange[0] ?? ''
|
|
568
|
+
};
|
|
569
|
+
const endPastCell = {
|
|
570
|
+
colId,
|
|
571
|
+
rowId: rangeState?.rowRange[rangeState?.rowRange.length - 1] ?? ''
|
|
572
|
+
};
|
|
573
|
+
setStartPasteCell?.(startPastCell);
|
|
574
|
+
setEndPasteCell?.(endPastCell);
|
|
575
|
+
setRangePasteState?.(getSelectedCellMatrix(table, startPastCell, endPastCell, 'right'));
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
if (colGap < 0 && absColGap < 0 && Math.abs(absColGap) > Math.abs(absRowGap)) {
|
|
579
|
+
const endCol = allCols[(rangeState?.startColIndex ?? 0) - 1];
|
|
580
|
+
const startPastCell = {
|
|
581
|
+
colId: colId ?? '',
|
|
582
|
+
rowId: rangeState?.rowRange[0] ?? ''
|
|
583
|
+
};
|
|
584
|
+
const endPastCell = {
|
|
585
|
+
colId: endCol.id,
|
|
586
|
+
rowId: rangeState?.rowRange[rangeState?.rowRange.length - 1] ?? ''
|
|
587
|
+
};
|
|
588
|
+
setStartPasteCell?.(startPastCell);
|
|
589
|
+
setEndPasteCell?.(endPastCell);
|
|
590
|
+
setRangePasteState?.(getSelectedCellMatrix(table, startPastCell, endPastCell, 'left'));
|
|
591
|
+
return;
|
|
592
|
+
} else {
|
|
593
|
+
setStartPasteCell?.(undefined);
|
|
594
|
+
setEndPasteCell?.(undefined);
|
|
498
595
|
}
|
|
499
596
|
}
|
|
500
597
|
}
|
|
@@ -522,14 +619,15 @@ const TableBodyCellEdit = props => {
|
|
|
522
619
|
setIsSelecting?.(false);
|
|
523
620
|
setIsPasting?.(false);
|
|
524
621
|
const selectState = getSelectedCellMatrix(table, startCell, endCell);
|
|
525
|
-
const selectPasteState = getSelectedCellMatrix(table, startPasteCell, endPasteCell)
|
|
526
|
-
|
|
622
|
+
// const selectPasteState = getSelectedCellMatrix(table, startPasteCell, endPasteCell)
|
|
623
|
+
const selectPasteState = rangePasteState ? {
|
|
624
|
+
...rangePasteState
|
|
625
|
+
} : {};
|
|
626
|
+
|
|
627
|
+
// if (endPasteCell && endCell?.rowId !== endPasteCell?.rowId && isPasting) {
|
|
628
|
+
if (selectPasteState.type && isPasting) {
|
|
527
629
|
triggerDragPaste(selectPasteState, e.ctrlKey);
|
|
528
630
|
} else {
|
|
529
|
-
// if ( endCell?.rowId !== rowId || endCell?.colId !== colId) {
|
|
530
|
-
// setRangeState?.(selectState)
|
|
531
|
-
// }
|
|
532
|
-
|
|
533
631
|
if (!isObjEqual(rangeState, selectState)) {
|
|
534
632
|
setRangeState?.(selectState);
|
|
535
633
|
}
|
|
@@ -96,7 +96,7 @@ export declare const genPresets: (presets?: import("@ant-design/colors").Palette
|
|
|
96
96
|
export declare const getEditType: <T>(column: ColumnTable<T>, rowData?: any) => EditType;
|
|
97
97
|
export declare const getDefaultValue: (defaultValue: any) => AnyObject;
|
|
98
98
|
export declare const flattenData: <RecordType extends AnyObject = AnyObject>(childrenColumnName: string, data?: RecordType[]) => RecordType[];
|
|
99
|
-
export declare const getSelectedCellMatrix: (table: Table<any>, startCell: IPositionCell | undefined, endCell: IPositionCell | undefined) => RangeState;
|
|
99
|
+
export declare const getSelectedCellMatrix: (table: Table<any>, startCell: IPositionCell | undefined, endCell: IPositionCell | undefined, type?: string) => RangeState;
|
|
100
100
|
export declare function addRowsDownWithCtrl(arr: any, n: number): {
|
|
101
101
|
combined: any;
|
|
102
102
|
addedRows: any[];
|
|
@@ -125,6 +125,16 @@ export declare function addRowsUp(array: any, n: number): {
|
|
|
125
125
|
combined: any[];
|
|
126
126
|
addedRows: any[];
|
|
127
127
|
};
|
|
128
|
+
interface DragCopyParams {
|
|
129
|
+
rowSelectIds: string[];
|
|
130
|
+
colSelectIds: string[];
|
|
131
|
+
colPasteds: string[];
|
|
132
|
+
copyRows: any[];
|
|
133
|
+
}
|
|
134
|
+
export declare const getDragRightData: ({ rowSelectIds, colSelectIds, colPasteds, copyRows, }: DragCopyParams) => {
|
|
135
|
+
combined: any[][];
|
|
136
|
+
addedCols: any[][];
|
|
137
|
+
};
|
|
128
138
|
export declare const convertFilters: (filters: any[]) => any[];
|
|
129
139
|
export declare const revertConvertFilters: (clauses: any[]) => FilterState[];
|
|
130
140
|
export declare function getInvisibleColumns(columns: ColumnTable[]): Record<string, boolean>;
|
|
@@ -170,3 +180,4 @@ export declare function sumNumberFields(columns: ColumnTable[], data: any[], chi
|
|
|
170
180
|
export declare const getTreeDepth: (rows: any[]) => number;
|
|
171
181
|
export type FormatToken = 'YYYY' | 'MM' | 'DD' | 'HH' | 'mm' | 'ss';
|
|
172
182
|
export declare const isDateChanged: (oldDate: string | Date, newDate: string | Date, format: string) => FormatToken | null;
|
|
183
|
+
export {};
|
|
@@ -1355,7 +1355,7 @@ export const flattenData = (childrenColumnName, data) => {
|
|
|
1355
1355
|
});
|
|
1356
1356
|
return list;
|
|
1357
1357
|
};
|
|
1358
|
-
export const getSelectedCellMatrix = (table, startCell, endCell) => {
|
|
1358
|
+
export const getSelectedCellMatrix = (table, startCell, endCell, type) => {
|
|
1359
1359
|
if (!startCell || !endCell) return {
|
|
1360
1360
|
rowIds: [],
|
|
1361
1361
|
colIds: [],
|
|
@@ -1364,7 +1364,8 @@ export const getSelectedCellMatrix = (table, startCell, endCell) => {
|
|
|
1364
1364
|
startColIndex: undefined,
|
|
1365
1365
|
endColIndex: undefined,
|
|
1366
1366
|
colRange: [],
|
|
1367
|
-
rowRange: []
|
|
1367
|
+
rowRange: [],
|
|
1368
|
+
type
|
|
1368
1369
|
};
|
|
1369
1370
|
|
|
1370
1371
|
// const rowIds = table.getRowModel().rows.map(r => r.id);
|
|
@@ -1386,7 +1387,8 @@ export const getSelectedCellMatrix = (table, startCell, endCell) => {
|
|
|
1386
1387
|
startColIndex,
|
|
1387
1388
|
endColIndex,
|
|
1388
1389
|
rowIds,
|
|
1389
|
-
colIds
|
|
1390
|
+
colIds,
|
|
1391
|
+
type
|
|
1390
1392
|
};
|
|
1391
1393
|
};
|
|
1392
1394
|
export function addRowsDownWithCtrl(arr, n) {
|
|
@@ -1935,6 +1937,30 @@ export function addRowsUp(array, n) {
|
|
|
1935
1937
|
addedRows
|
|
1936
1938
|
};
|
|
1937
1939
|
}
|
|
1940
|
+
export const getDragRightData = ({
|
|
1941
|
+
rowSelectIds,
|
|
1942
|
+
colSelectIds,
|
|
1943
|
+
colPasteds,
|
|
1944
|
+
copyRows
|
|
1945
|
+
}) => {
|
|
1946
|
+
const selectedRows = copyRows.filter(row => rowSelectIds.includes(String(row.rowId ?? row.id)));
|
|
1947
|
+
const addedCols = selectedRows.map(row => {
|
|
1948
|
+
return colPasteds.map((_, index) => {
|
|
1949
|
+
const sourceCol = colSelectIds[index % colSelectIds.length];
|
|
1950
|
+
return row[sourceCol] ?? '';
|
|
1951
|
+
});
|
|
1952
|
+
});
|
|
1953
|
+
const combined = selectedRows.map((row, rowIndex) => {
|
|
1954
|
+
const sourceValues = colSelectIds.map(col => {
|
|
1955
|
+
return row[col] ?? '';
|
|
1956
|
+
});
|
|
1957
|
+
return [...sourceValues, ...addedCols[rowIndex]];
|
|
1958
|
+
});
|
|
1959
|
+
return {
|
|
1960
|
+
combined,
|
|
1961
|
+
addedCols
|
|
1962
|
+
};
|
|
1963
|
+
};
|
|
1938
1964
|
export const convertFilters = filters => {
|
|
1939
1965
|
const result = [];
|
|
1940
1966
|
filters.forEach(({
|
|
@@ -202,6 +202,7 @@ const TableBodyCellEdit = props => {
|
|
|
202
202
|
setFocusedCell,
|
|
203
203
|
setEditingKey,
|
|
204
204
|
setRangeState,
|
|
205
|
+
rangePasteState,
|
|
205
206
|
setRangePasteState,
|
|
206
207
|
endCell,
|
|
207
208
|
setEndCell,
|
|
@@ -324,7 +325,8 @@ const TableBodyCellEdit = props => {
|
|
|
324
325
|
const colPasteds = (0, _utils.getColIdsBetween)(table, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
|
|
325
326
|
const rowSelectIds = (0, _utils.getRowIdsBetween)(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
326
327
|
const colSelectIds = (0, _utils.getColIdsBetween)(table, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
327
|
-
const dataSelected = [];
|
|
328
|
+
const dataSelected = []; // data được copy
|
|
329
|
+
|
|
328
330
|
rowSelectIds.forEach(rowId => {
|
|
329
331
|
const row = allRows.find(r => r.id === rowId);
|
|
330
332
|
if (!row) return;
|
|
@@ -338,49 +340,104 @@ const TableBodyCellEdit = props => {
|
|
|
338
340
|
});
|
|
339
341
|
const copyRows = (0, _utils.flattenData)('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
|
|
340
342
|
let newRange;
|
|
341
|
-
if (
|
|
343
|
+
if (pasteState.type === 'down') {
|
|
342
344
|
// kéo xuóng
|
|
343
345
|
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, startCell, endPasteCell));
|
|
344
346
|
newRange = ctrlKey ? (0, _utils.addRowsDownWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsDown)(dataSelected, rowPasteIds.length);
|
|
345
|
-
} else {
|
|
347
|
+
} else if (pasteState.type === 'up') {
|
|
346
348
|
// kéo lên
|
|
347
349
|
setStartCell?.(endCell);
|
|
348
350
|
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, endCell, endPasteCell));
|
|
349
351
|
newRange = ctrlKey ? (0, _utils.addRowsUpWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsUp)(dataSelected, rowPasteIds.length);
|
|
352
|
+
} else if (pasteState.type === 'right') {
|
|
353
|
+
// kéo phải
|
|
354
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, startCell, endPasteCell));
|
|
355
|
+
// newRange = { addedRows: [], combined: [] }
|
|
356
|
+
// newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length)
|
|
357
|
+
newRange = (0, _utils.getDragRightData)({
|
|
358
|
+
colPasteds,
|
|
359
|
+
colSelectIds,
|
|
360
|
+
copyRows,
|
|
361
|
+
rowSelectIds
|
|
362
|
+
});
|
|
363
|
+
} else if (pasteState.type === 'left') {
|
|
364
|
+
// kéo trái
|
|
365
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, startCell, endPasteCell));
|
|
366
|
+
// newRange = { addedRows: [], combined: [] }
|
|
367
|
+
// newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length)
|
|
368
|
+
newRange = (0, _utils.getDragRightData)({
|
|
369
|
+
colPasteds,
|
|
370
|
+
colSelectIds,
|
|
371
|
+
copyRows,
|
|
372
|
+
rowSelectIds
|
|
373
|
+
});
|
|
350
374
|
}
|
|
351
375
|
|
|
352
376
|
// Cập nhật data mới
|
|
353
377
|
const newData = (0, _utils.flattenArray)([...dataSource]);
|
|
354
378
|
const pastedRows = [];
|
|
355
|
-
|
|
356
|
-
|
|
379
|
+
if (pasteState.type === 'down' || pasteState.type === 'up') {
|
|
380
|
+
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
381
|
+
const targetRow = pasteState.startRowIndex + rowIndex1;
|
|
357
382
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
rowValues.forEach((cellValue, colIndex1) => {
|
|
366
|
-
const targetCol = startColIndex + colIndex1;
|
|
367
|
-
if (targetCol >= tmpCols.length) {
|
|
368
|
-
// Không vượt quá số cột
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const columnKey = tmpCols[targetCol].id;
|
|
372
|
-
const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
|
|
373
|
-
if (!disable) {
|
|
374
|
-
newData[targetRow] = {
|
|
375
|
-
...newData[targetRow],
|
|
376
|
-
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
377
|
-
};
|
|
383
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
384
|
+
if (targetRow >= newData.length) {
|
|
385
|
+
newData.push({
|
|
386
|
+
id: undefined,
|
|
387
|
+
rowId: (0, _utils.newGuid)()
|
|
388
|
+
});
|
|
378
389
|
}
|
|
390
|
+
rowValues.forEach((cellValue, colIndex1) => {
|
|
391
|
+
const targetCol = startColIndex + colIndex1;
|
|
392
|
+
if (targetCol >= tmpCols.length) {
|
|
393
|
+
// Không vượt quá số cột
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const columnKey = tmpCols[targetCol].id;
|
|
397
|
+
const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
|
|
398
|
+
if (!disable) {
|
|
399
|
+
newData[targetRow] = {
|
|
400
|
+
...newData[targetRow],
|
|
401
|
+
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
// Lưu dòng được paste
|
|
407
|
+
pastedRows.push(newData[targetRow]);
|
|
379
408
|
});
|
|
409
|
+
}
|
|
410
|
+
if (pasteState.type === 'right' || pasteState.type === 'left') {
|
|
411
|
+
newRange.addedCols.forEach((rowValues, rowIndex1) => {
|
|
412
|
+
const targetRow = pasteState.startRowIndex + rowIndex1;
|
|
380
413
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
414
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
415
|
+
if (targetRow >= newData.length) {
|
|
416
|
+
newData.push({
|
|
417
|
+
id: undefined,
|
|
418
|
+
rowId: (0, _utils.newGuid)()
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
rowValues.forEach((cellValue, colIndex1) => {
|
|
422
|
+
const targetCol = pasteState.startColIndex + colIndex1;
|
|
423
|
+
if (targetCol >= tmpCols.length) {
|
|
424
|
+
// Không vượt quá số cột
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
const columnKey = tmpCols[targetCol].id;
|
|
428
|
+
const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
|
|
429
|
+
if (!disable) {
|
|
430
|
+
newData[targetRow] = {
|
|
431
|
+
...newData[targetRow],
|
|
432
|
+
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// Lưu dòng được paste
|
|
438
|
+
pastedRows.push(newData[targetRow]);
|
|
439
|
+
});
|
|
440
|
+
}
|
|
384
441
|
const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...originData]), newData);
|
|
385
442
|
const rs = (0, _utils.unFlattenData)(rsFilterData);
|
|
386
443
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
@@ -461,11 +518,22 @@ const TableBodyCellEdit = props => {
|
|
|
461
518
|
});
|
|
462
519
|
}
|
|
463
520
|
if (isPasting) {
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
521
|
+
const allCols = table.getAllLeafColumns();
|
|
522
|
+
const absRowIndex = table.getRowModel().flatRows.findIndex(it => it.id === rowId); // row cell con chỏ chuột hiện tại
|
|
523
|
+
const absColIndex = allCols.findIndex(it => it.id === colId); // col cell con chỏ chuột hiện tại
|
|
467
524
|
|
|
468
|
-
|
|
525
|
+
// const absColIndex = allCols.findIndex((it) => it.id === endCell?.colId )
|
|
526
|
+
|
|
527
|
+
const endCellColIndex = allCols.findIndex(it => it.id === endCell?.colId); // col cuối cùng vùng được copy
|
|
528
|
+
|
|
529
|
+
const rowGap = absRowIndex - (endRowIndex ?? 0);
|
|
530
|
+
const colGap = absColIndex - (endCellColIndex ?? 0);
|
|
531
|
+
const absRowGap = rangeState?.rowRange.length === 1 ? rowGap : rowGap >= 0 ? rowGap : rowGap + (rangeState?.rowRange.length ?? 0) - 1;
|
|
532
|
+
const absColGap = rangeState?.colRange.length === 1 ? colGap : colGap >= 0 ? colGap : colGap + (rangeState?.colRange.length ?? 0) - 1;
|
|
533
|
+
if (rowGap > 0 && absRowGap > 0 && Math.abs(absRowGap) >= Math.abs(absColGap)) {
|
|
534
|
+
// kéo xuống : cell cuối trùng endCell
|
|
535
|
+
const findIndex = allRows.findIndex(it => it.id === endCell?.rowId);
|
|
536
|
+
const startRowPaste = allRows[findIndex + 1];
|
|
469
537
|
setStartPasteCell?.({
|
|
470
538
|
colId: startCell?.colId ?? '',
|
|
471
539
|
rowId: startRowPaste?.id ?? ''
|
|
@@ -480,28 +548,57 @@ const TableBodyCellEdit = props => {
|
|
|
480
548
|
}, {
|
|
481
549
|
colId: endCell?.colId ?? '',
|
|
482
550
|
rowId
|
|
483
|
-
}));
|
|
551
|
+
}, 'down'));
|
|
552
|
+
return;
|
|
484
553
|
}
|
|
485
|
-
if (
|
|
486
|
-
//
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
const startRowPaste = allRows[findIndex + 1];
|
|
490
|
-
setStartPasteCell?.({
|
|
491
|
-
colId: startCell?.colId ?? '',
|
|
492
|
-
rowId: startRowPaste?.id ?? ''
|
|
493
|
-
});
|
|
494
|
-
setEndPasteCell?.({
|
|
495
|
-
colId: endCell?.colId ?? '',
|
|
496
|
-
rowId
|
|
497
|
-
});
|
|
498
|
-
setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
554
|
+
if (rowGap < 0 && absRowGap < 0 && Math.abs(absRowGap) >= Math.abs(absColGap)) {
|
|
555
|
+
// kéo lên
|
|
556
|
+
const startRowPaste = allRows.find(it => it.index === (startRowIndex ?? 0) - 1);
|
|
557
|
+
const startPastCell = {
|
|
499
558
|
colId: startCell?.colId ?? '',
|
|
500
559
|
rowId: startRowPaste?.id ?? ''
|
|
501
|
-
}
|
|
560
|
+
};
|
|
561
|
+
const endPastCell = {
|
|
502
562
|
colId: endCell?.colId ?? '',
|
|
503
563
|
rowId
|
|
504
|
-
}
|
|
564
|
+
};
|
|
565
|
+
setStartPasteCell?.(startPastCell);
|
|
566
|
+
setEndPasteCell?.(endPastCell);
|
|
567
|
+
setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, startPastCell, endPastCell, 'up'));
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
if (colGap > 0 && absColGap > 0 && Math.abs(absColGap) > Math.abs(absRowGap)) {
|
|
571
|
+
const startCol = allCols[(rangeState?.endColIndex ?? 0) + 1];
|
|
572
|
+
const startPastCell = {
|
|
573
|
+
colId: startCol?.id ?? '',
|
|
574
|
+
rowId: rangeState?.rowRange[0] ?? ''
|
|
575
|
+
};
|
|
576
|
+
const endPastCell = {
|
|
577
|
+
colId,
|
|
578
|
+
rowId: rangeState?.rowRange[rangeState?.rowRange.length - 1] ?? ''
|
|
579
|
+
};
|
|
580
|
+
setStartPasteCell?.(startPastCell);
|
|
581
|
+
setEndPasteCell?.(endPastCell);
|
|
582
|
+
setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, startPastCell, endPastCell, 'right'));
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
if (colGap < 0 && absColGap < 0 && Math.abs(absColGap) > Math.abs(absRowGap)) {
|
|
586
|
+
const endCol = allCols[(rangeState?.startColIndex ?? 0) - 1];
|
|
587
|
+
const startPastCell = {
|
|
588
|
+
colId: colId ?? '',
|
|
589
|
+
rowId: rangeState?.rowRange[0] ?? ''
|
|
590
|
+
};
|
|
591
|
+
const endPastCell = {
|
|
592
|
+
colId: endCol.id,
|
|
593
|
+
rowId: rangeState?.rowRange[rangeState?.rowRange.length - 1] ?? ''
|
|
594
|
+
};
|
|
595
|
+
setStartPasteCell?.(startPastCell);
|
|
596
|
+
setEndPasteCell?.(endPastCell);
|
|
597
|
+
setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, startPastCell, endPastCell, 'left'));
|
|
598
|
+
return;
|
|
599
|
+
} else {
|
|
600
|
+
setStartPasteCell?.(undefined);
|
|
601
|
+
setEndPasteCell?.(undefined);
|
|
505
602
|
}
|
|
506
603
|
}
|
|
507
604
|
}
|
|
@@ -529,14 +626,15 @@ const TableBodyCellEdit = props => {
|
|
|
529
626
|
setIsSelecting?.(false);
|
|
530
627
|
setIsPasting?.(false);
|
|
531
628
|
const selectState = (0, _utils.getSelectedCellMatrix)(table, startCell, endCell);
|
|
532
|
-
const selectPasteState =
|
|
533
|
-
|
|
629
|
+
// const selectPasteState = getSelectedCellMatrix(table, startPasteCell, endPasteCell)
|
|
630
|
+
const selectPasteState = rangePasteState ? {
|
|
631
|
+
...rangePasteState
|
|
632
|
+
} : {};
|
|
633
|
+
|
|
634
|
+
// if (endPasteCell && endCell?.rowId !== endPasteCell?.rowId && isPasting) {
|
|
635
|
+
if (selectPasteState.type && isPasting) {
|
|
534
636
|
triggerDragPaste(selectPasteState, e.ctrlKey);
|
|
535
637
|
} else {
|
|
536
|
-
// if ( endCell?.rowId !== rowId || endCell?.colId !== colId) {
|
|
537
|
-
// setRangeState?.(selectState)
|
|
538
|
-
// }
|
|
539
|
-
|
|
540
638
|
if (!(0, _utils.isObjEqual)(rangeState, selectState)) {
|
|
541
639
|
setRangeState?.(selectState);
|
|
542
640
|
}
|
|
@@ -96,7 +96,7 @@ export declare const genPresets: (presets?: import("@ant-design/colors").Palette
|
|
|
96
96
|
export declare const getEditType: <T>(column: ColumnTable<T>, rowData?: any) => EditType;
|
|
97
97
|
export declare const getDefaultValue: (defaultValue: any) => AnyObject;
|
|
98
98
|
export declare const flattenData: <RecordType extends AnyObject = AnyObject>(childrenColumnName: string, data?: RecordType[]) => RecordType[];
|
|
99
|
-
export declare const getSelectedCellMatrix: (table: Table<any>, startCell: IPositionCell | undefined, endCell: IPositionCell | undefined) => RangeState;
|
|
99
|
+
export declare const getSelectedCellMatrix: (table: Table<any>, startCell: IPositionCell | undefined, endCell: IPositionCell | undefined, type?: string) => RangeState;
|
|
100
100
|
export declare function addRowsDownWithCtrl(arr: any, n: number): {
|
|
101
101
|
combined: any;
|
|
102
102
|
addedRows: any[];
|
|
@@ -125,6 +125,16 @@ export declare function addRowsUp(array: any, n: number): {
|
|
|
125
125
|
combined: any[];
|
|
126
126
|
addedRows: any[];
|
|
127
127
|
};
|
|
128
|
+
interface DragCopyParams {
|
|
129
|
+
rowSelectIds: string[];
|
|
130
|
+
colSelectIds: string[];
|
|
131
|
+
colPasteds: string[];
|
|
132
|
+
copyRows: any[];
|
|
133
|
+
}
|
|
134
|
+
export declare const getDragRightData: ({ rowSelectIds, colSelectIds, colPasteds, copyRows, }: DragCopyParams) => {
|
|
135
|
+
combined: any[][];
|
|
136
|
+
addedCols: any[][];
|
|
137
|
+
};
|
|
128
138
|
export declare const convertFilters: (filters: any[]) => any[];
|
|
129
139
|
export declare const revertConvertFilters: (clauses: any[]) => FilterState[];
|
|
130
140
|
export declare function getInvisibleColumns(columns: ColumnTable[]): Record<string, boolean>;
|
|
@@ -170,3 +180,4 @@ export declare function sumNumberFields(columns: ColumnTable[], data: any[], chi
|
|
|
170
180
|
export declare const getTreeDepth: (rows: any[]) => number;
|
|
171
181
|
export type FormatToken = 'YYYY' | 'MM' | 'DD' | 'HH' | 'mm' | 'ss';
|
|
172
182
|
export declare const isDateChanged: (oldDate: string | Date, newDate: string | Date, format: string) => FormatToken | null;
|
|
183
|
+
export {};
|
|
@@ -35,7 +35,7 @@ exports.getCellsByPosition = getCellsByPosition;
|
|
|
35
35
|
exports.getColIdsBetween = getColIdsBetween;
|
|
36
36
|
exports.getDateRangeFormat = exports.getCommonPinningStyles2 = exports.getCommonPinningStyles = void 0;
|
|
37
37
|
exports.getDateValueType = getDateValueType;
|
|
38
|
-
exports.getFormat = exports.getFixedFields = exports.getEditType = exports.getDiffent2Array = exports.getDefaultValue = exports.getDefaultOperator = exports.getDatepickerFormat = void 0;
|
|
38
|
+
exports.getFormat = exports.getFixedFields = exports.getEditType = exports.getDragRightData = exports.getDiffent2Array = exports.getDefaultValue = exports.getDefaultOperator = exports.getDatepickerFormat = void 0;
|
|
39
39
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
40
40
|
exports.getHiddenParentKeys1 = getHiddenParentKeys1;
|
|
41
41
|
exports.getInvisibleColumns = getInvisibleColumns;
|
|
@@ -1476,7 +1476,7 @@ const flattenData = (childrenColumnName, data) => {
|
|
|
1476
1476
|
return list;
|
|
1477
1477
|
};
|
|
1478
1478
|
exports.flattenData = flattenData;
|
|
1479
|
-
const getSelectedCellMatrix = (table, startCell, endCell) => {
|
|
1479
|
+
const getSelectedCellMatrix = (table, startCell, endCell, type) => {
|
|
1480
1480
|
if (!startCell || !endCell) return {
|
|
1481
1481
|
rowIds: [],
|
|
1482
1482
|
colIds: [],
|
|
@@ -1485,7 +1485,8 @@ const getSelectedCellMatrix = (table, startCell, endCell) => {
|
|
|
1485
1485
|
startColIndex: undefined,
|
|
1486
1486
|
endColIndex: undefined,
|
|
1487
1487
|
colRange: [],
|
|
1488
|
-
rowRange: []
|
|
1488
|
+
rowRange: [],
|
|
1489
|
+
type
|
|
1489
1490
|
};
|
|
1490
1491
|
|
|
1491
1492
|
// const rowIds = table.getRowModel().rows.map(r => r.id);
|
|
@@ -1507,7 +1508,8 @@ const getSelectedCellMatrix = (table, startCell, endCell) => {
|
|
|
1507
1508
|
startColIndex,
|
|
1508
1509
|
endColIndex,
|
|
1509
1510
|
rowIds,
|
|
1510
|
-
colIds
|
|
1511
|
+
colIds,
|
|
1512
|
+
type
|
|
1511
1513
|
};
|
|
1512
1514
|
};
|
|
1513
1515
|
exports.getSelectedCellMatrix = getSelectedCellMatrix;
|
|
@@ -2057,6 +2059,31 @@ function addRowsUp(array, n) {
|
|
|
2057
2059
|
addedRows
|
|
2058
2060
|
};
|
|
2059
2061
|
}
|
|
2062
|
+
const getDragRightData = ({
|
|
2063
|
+
rowSelectIds,
|
|
2064
|
+
colSelectIds,
|
|
2065
|
+
colPasteds,
|
|
2066
|
+
copyRows
|
|
2067
|
+
}) => {
|
|
2068
|
+
const selectedRows = copyRows.filter(row => rowSelectIds.includes(String(row.rowId ?? row.id)));
|
|
2069
|
+
const addedCols = selectedRows.map(row => {
|
|
2070
|
+
return colPasteds.map((_, index) => {
|
|
2071
|
+
const sourceCol = colSelectIds[index % colSelectIds.length];
|
|
2072
|
+
return row[sourceCol] ?? '';
|
|
2073
|
+
});
|
|
2074
|
+
});
|
|
2075
|
+
const combined = selectedRows.map((row, rowIndex) => {
|
|
2076
|
+
const sourceValues = colSelectIds.map(col => {
|
|
2077
|
+
return row[col] ?? '';
|
|
2078
|
+
});
|
|
2079
|
+
return [...sourceValues, ...addedCols[rowIndex]];
|
|
2080
|
+
});
|
|
2081
|
+
return {
|
|
2082
|
+
combined,
|
|
2083
|
+
addedCols
|
|
2084
|
+
};
|
|
2085
|
+
};
|
|
2086
|
+
exports.getDragRightData = getDragRightData;
|
|
2060
2087
|
const convertFilters = filters => {
|
|
2061
2088
|
const result = [];
|
|
2062
2089
|
filters.forEach(({
|