es-grid-template 1.3.5 → 1.3.6
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/assets/index.css +3 -0
- package/assets/index.scss +3 -0
- package/es/grid-component/EditableCell.js +1 -0
- package/es/grid-component/hooks/columns/index.js +4 -3
- package/es/grid-component/hooks/utils.d.ts +11 -0
- package/es/grid-component/hooks/utils.js +190 -0
- package/es/grid-component/number/index.d.ts +2 -2
- package/es/grid-component/number/index.js +2 -2
- package/es/grid-component/styles.scss +3 -0
- package/es/grid-component/table/GridEdit.js +37 -11
- package/lib/grid-component/EditableCell.js +1 -0
- package/lib/grid-component/hooks/columns/index.js +2 -1
- package/lib/grid-component/hooks/utils.d.ts +11 -0
- package/lib/grid-component/hooks/utils.js +197 -2
- package/lib/grid-component/number/index.d.ts +2 -2
- package/lib/grid-component/number/index.js +2 -2
- package/lib/grid-component/styles.scss +3 -0
- package/lib/grid-component/table/GridEdit.js +35 -9
- package/package.json +109 -109
package/assets/index.css
CHANGED
|
@@ -222,6 +222,9 @@
|
|
|
222
222
|
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-paste-border-left {
|
|
223
223
|
border-inline-end: 1px dashed #949494;
|
|
224
224
|
}
|
|
225
|
+
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-paste-border-top {
|
|
226
|
+
border-bottom: 1px dashed #949494 !important;
|
|
227
|
+
}
|
|
225
228
|
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-border-right {
|
|
226
229
|
border-inline-end: 1px solid #0550C5;
|
|
227
230
|
}
|
package/assets/index.scss
CHANGED
|
@@ -426,6 +426,9 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
426
426
|
&.cell-paste-border-left {
|
|
427
427
|
border-inline-end: 1px dashed #949494;
|
|
428
428
|
}
|
|
429
|
+
&.cell-paste-border-top {
|
|
430
|
+
border-bottom: 1px dashed #949494 !important;
|
|
431
|
+
}
|
|
429
432
|
|
|
430
433
|
&.cell-border-right {
|
|
431
434
|
border-inline-end: 1px solid $border-selected-color;
|
|
@@ -572,6 +572,7 @@ const EditableCell = props => {
|
|
|
572
572
|
},
|
|
573
573
|
treeCheckable: column?.editSelectSettings?.selectMode === 'checkbox',
|
|
574
574
|
filterTreeNode: filterTreeNode,
|
|
575
|
+
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
575
576
|
onSelect: (val, option) => {
|
|
576
577
|
onChange(val ?? '');
|
|
577
578
|
const formState = getValues();
|
|
@@ -7,7 +7,7 @@ import { DatePicker, Empty, Input, Select } from "rc-master-ui";
|
|
|
7
7
|
import CheckboxFilter from "../../CheckboxFilter";
|
|
8
8
|
import { SELECTION_COLUMN } from "rc-master-ui/es/table/hooks/useSelection";
|
|
9
9
|
import NumberRange from "../../number-range";
|
|
10
|
-
import
|
|
10
|
+
import NumberInput from "../../number";
|
|
11
11
|
// import {Typography} from "antd";
|
|
12
12
|
const {
|
|
13
13
|
RangePicker
|
|
@@ -76,7 +76,8 @@ export const getValueCell = (column, value, format) => {
|
|
|
76
76
|
|
|
77
77
|
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
|
|
78
78
|
|
|
79
|
-
const
|
|
79
|
+
const tmpval = typeof value === 'string' ? Number(value) : value;
|
|
80
|
+
const contentNumber = !isEmpty(value) ? dec || dec === 0 ? tmpval.toFixed(dec) : tmpval.toString() : '0';
|
|
80
81
|
const numericFormatProps = {
|
|
81
82
|
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
82
83
|
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
@@ -144,7 +145,7 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
144
145
|
case 'Number':
|
|
145
146
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
146
147
|
className: 'mb-1'
|
|
147
|
-
}, /*#__PURE__*/React.createElement(
|
|
148
|
+
}, /*#__PURE__*/React.createElement(NumberInput, {
|
|
148
149
|
t: t,
|
|
149
150
|
value: selectedKeys[0],
|
|
150
151
|
onChange: vals => {
|
|
@@ -62,6 +62,13 @@ export declare function addRows8(arr: any, n: number): {
|
|
|
62
62
|
combined: any[];
|
|
63
63
|
addedRows: any[];
|
|
64
64
|
};
|
|
65
|
+
export declare function addRowsUp(array: any, n: number): {
|
|
66
|
+
combined: any;
|
|
67
|
+
addedRows: any[];
|
|
68
|
+
} | {
|
|
69
|
+
combined: any[];
|
|
70
|
+
addedRows: any[];
|
|
71
|
+
};
|
|
65
72
|
export declare const transformColumns: <RecordType>(cols: ColumnsTable<RecordType>, convertColumns: any[], t?: any) => ColumnsTable<RecordType>;
|
|
66
73
|
export declare const transformColumns1: <RecordType>(cols: ColumnsTable<RecordType>, sortMultiple?: boolean) => ColumnsTable<RecordType>;
|
|
67
74
|
export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType>[], groupColumns: string[]) => ColumnsTable<RecordType>;
|
|
@@ -93,3 +100,7 @@ export declare function isRightMostInRegion(rowIndex: number, colIndex: number,
|
|
|
93
100
|
export declare function isEqualSet(setA: any, setB: any): boolean;
|
|
94
101
|
export declare function isBottomMostInRanges(rowIndex: number, colIndex: number, regions: any[]): boolean;
|
|
95
102
|
export declare const mergedSets: (arr: any[]) => Set<unknown>;
|
|
103
|
+
export declare const sortedSetASC: (setValue: any) => Set<unknown>;
|
|
104
|
+
export declare const sortedSetDSC: (setValue: any) => Set<unknown>;
|
|
105
|
+
export declare const onAddClassSelectedCell: (selectedCells: any, id?: string) => void;
|
|
106
|
+
export declare const onRemoveClassSelectedCell: (selectedCells: any, id?: string) => void;
|
|
@@ -623,6 +623,146 @@ export function addRows8(arr, n) {
|
|
|
623
623
|
addedRows
|
|
624
624
|
};
|
|
625
625
|
}
|
|
626
|
+
export function addRowsUp(array, n) {
|
|
627
|
+
const arr = array.reverse();
|
|
628
|
+
if (!Array.isArray(arr) || arr.length === 0) return {
|
|
629
|
+
combined: arr,
|
|
630
|
+
addedRows: []
|
|
631
|
+
};
|
|
632
|
+
const m = arr.length;
|
|
633
|
+
const numCols = arr[0].length;
|
|
634
|
+
const addedRows = [];
|
|
635
|
+
|
|
636
|
+
// Hàm kiểm tra kiểu date hợp lệ
|
|
637
|
+
const isValidDate = item => {
|
|
638
|
+
// console.log('!isNaN(Date.parse(d))', !isNaN(Date.parse(d)))
|
|
639
|
+
// return !isNaN(Date.parse(d))
|
|
640
|
+
|
|
641
|
+
if (typeof item === 'number') {
|
|
642
|
+
// return 'number'
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
if (typeof item === 'string') {
|
|
646
|
+
// Kiểm tra nếu là chuỗi ISO date hợp lệ
|
|
647
|
+
const date = new Date(item);
|
|
648
|
+
if (!isNaN(date.getTime()) && item.includes('T')) {
|
|
649
|
+
// return 'date'
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
// return 'string'
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
return !isNaN(Date.parse(item));
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// Lấy giá trị mẫu của cột j từ hàng đầu tiên
|
|
659
|
+
const getSample = j => arr[0][j];
|
|
660
|
+
|
|
661
|
+
// Xác định chế độ xử lý cho mỗi cột:
|
|
662
|
+
// mode = 'number-stepping' | 'date-stepping' | 'number-constant' | 'cycle'
|
|
663
|
+
const modes = [];
|
|
664
|
+
const steps = []; // bước tăng, nếu có (cho number hoặc date)
|
|
665
|
+
|
|
666
|
+
for (let j = 0; j < numCols; j++) {
|
|
667
|
+
const sample = getSample(j);
|
|
668
|
+
if (m === 1) {
|
|
669
|
+
// Nếu mảng chỉ có 1 hàng: nếu là số thì giữ nguyên; nếu là date thì tăng 1 ngày; còn lại giữ nguyên.
|
|
670
|
+
if (typeof sample === "number") {
|
|
671
|
+
modes[j] = "number-constant";
|
|
672
|
+
} else if (isValidDate(sample)) {
|
|
673
|
+
modes[j] = "date-stepping";
|
|
674
|
+
steps[j] = 24 * 3600 * 1000; // 1 ngày = 86400000 ms
|
|
675
|
+
} else {
|
|
676
|
+
modes[j] = "cycle";
|
|
677
|
+
}
|
|
678
|
+
} else if (m === 2) {
|
|
679
|
+
// Nếu mảng có 2 hàng: nếu là số thì tính bước = row2 - row1, tương tự với date
|
|
680
|
+
const first = arr[0][j],
|
|
681
|
+
second = arr[1][j];
|
|
682
|
+
if (typeof first === "number" && typeof second === "number") {
|
|
683
|
+
modes[j] = "number-stepping";
|
|
684
|
+
steps[j] = second - first;
|
|
685
|
+
} else if (isValidDate(first) && isValidDate(second)) {
|
|
686
|
+
modes[j] = "date-stepping";
|
|
687
|
+
steps[j] = Date.parse(second) - Date.parse(first);
|
|
688
|
+
} else {
|
|
689
|
+
modes[j] = "cycle";
|
|
690
|
+
}
|
|
691
|
+
} else {
|
|
692
|
+
// Nếu mảng có >2 hàng
|
|
693
|
+
const first = arr[0][j],
|
|
694
|
+
second = arr[1][j],
|
|
695
|
+
third = arr[2][j];
|
|
696
|
+
if (typeof first === "number" && typeof second === "number" && typeof third === "number") {
|
|
697
|
+
const step1 = second - first;
|
|
698
|
+
const step2 = third - second;
|
|
699
|
+
if (step1 === step2) {
|
|
700
|
+
modes[j] = "number-stepping";
|
|
701
|
+
steps[j] = step1;
|
|
702
|
+
} else {
|
|
703
|
+
modes[j] = "cycle";
|
|
704
|
+
}
|
|
705
|
+
} else if (isValidDate(first) && isValidDate(second) && isValidDate(third)) {
|
|
706
|
+
const step1 = Date.parse(second) - Date.parse(first);
|
|
707
|
+
const step2 = Date.parse(third) - Date.parse(second);
|
|
708
|
+
if (step1 === step2) {
|
|
709
|
+
modes[j] = "date-stepping";
|
|
710
|
+
steps[j] = step1;
|
|
711
|
+
} else {
|
|
712
|
+
modes[j] = "cycle";
|
|
713
|
+
}
|
|
714
|
+
} else {
|
|
715
|
+
modes[j] = "cycle";
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// Tạo các dòng mới (thêm n dòng)
|
|
721
|
+
// Với mỗi cột, nếu chế độ là stepping thì lấy giá trị cuối của mảng ban đầu và cộng thêm (i+1)*step
|
|
722
|
+
// Nếu chế độ là cycle thì dùng arr[i mod m][j]
|
|
723
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
724
|
+
const newRow = [];
|
|
725
|
+
for (let j = 0; j < numCols; j++) {
|
|
726
|
+
let newValue;
|
|
727
|
+
switch (modes[j]) {
|
|
728
|
+
case "number-constant":
|
|
729
|
+
// Mảng có 1 hàng, số giữ nguyên
|
|
730
|
+
newValue = arr[0][j];
|
|
731
|
+
break;
|
|
732
|
+
case "number-stepping":
|
|
733
|
+
{
|
|
734
|
+
// Lấy giá trị cuối của cột j trong mảng ban đầu
|
|
735
|
+
|
|
736
|
+
const lastValue = arr[m - 1][j];
|
|
737
|
+
newValue = lastValue - (i + 1) * steps[j] * -1;
|
|
738
|
+
}
|
|
739
|
+
break;
|
|
740
|
+
case "date-stepping":
|
|
741
|
+
{
|
|
742
|
+
// Lấy giá trị cuối, chuyển về date, cộng thêm (i+1)*step, chuyển lại về định dạng ISO
|
|
743
|
+
|
|
744
|
+
const lastDate = new Date(array[m - 1][j]);
|
|
745
|
+
const newTime = lastDate.getTime() - (i + 1) * steps[j] * -1;
|
|
746
|
+
newValue = moment(new Date(newTime)).format();
|
|
747
|
+
}
|
|
748
|
+
break;
|
|
749
|
+
case "cycle":
|
|
750
|
+
default:
|
|
751
|
+
// Lặp lại nội dung theo vòng tròn: dùng hàng thứ (i mod m)
|
|
752
|
+
|
|
753
|
+
newValue = arr[i % m][j];
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
newRow.push(newValue);
|
|
757
|
+
}
|
|
758
|
+
addedRows.push(newRow);
|
|
759
|
+
}
|
|
760
|
+
const combined = arr.concat(addedRows);
|
|
761
|
+
return {
|
|
762
|
+
combined,
|
|
763
|
+
addedRows
|
|
764
|
+
};
|
|
765
|
+
}
|
|
626
766
|
export const transformColumns = (cols, convertColumns, t) => {
|
|
627
767
|
// @ts-ignore
|
|
628
768
|
return cols.map(column => {
|
|
@@ -1196,4 +1336,54 @@ export function isBottomMostInRanges(rowIndex, colIndex, regions) {
|
|
|
1196
1336
|
}
|
|
1197
1337
|
export const mergedSets = arr => {
|
|
1198
1338
|
return new Set(arr.flatMap(set => Array.from(set)));
|
|
1339
|
+
};
|
|
1340
|
+
export const sortedSetASC = setValue => {
|
|
1341
|
+
const sorted = Array.from(setValue).sort((a, b) => {
|
|
1342
|
+
const [a1, a2] = a.split("-").map(Number);
|
|
1343
|
+
const [b1, b2] = b.split("-").map(Number);
|
|
1344
|
+
return a1 - b1 || a2 - b2;
|
|
1345
|
+
});
|
|
1346
|
+
return new Set(sorted);
|
|
1347
|
+
};
|
|
1348
|
+
export const sortedSetDSC = setValue => {
|
|
1349
|
+
const sorted = Array.from(setValue).sort((a, b) => {
|
|
1350
|
+
const [a1, a2] = a.split("-").map(Number);
|
|
1351
|
+
const [b1, b2] = b.split("-").map(Number);
|
|
1352
|
+
return b1 - a1 || b2 - a2;
|
|
1353
|
+
});
|
|
1354
|
+
return new Set(sorted);
|
|
1355
|
+
};
|
|
1356
|
+
export const onAddClassSelectedCell = (selectedCells, id) => {
|
|
1357
|
+
const selectors = Array.from(selectedCells).map(pos => {
|
|
1358
|
+
const [row1, col1] = pos.split('-');
|
|
1359
|
+
return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1362
|
+
// const cells = document.querySelectorAll(selectors.join(','));
|
|
1363
|
+
|
|
1364
|
+
const table = document.querySelector(`#${id}`);
|
|
1365
|
+
console.log('table', table);
|
|
1366
|
+
const cells = table?.querySelectorAll(selectors.join(','));
|
|
1367
|
+
if (cells) {
|
|
1368
|
+
cells.forEach(cell => {
|
|
1369
|
+
cell.classList.add('selected');
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
export const onRemoveClassSelectedCell = (selectedCells, id) => {
|
|
1374
|
+
const selectors = Array.from(selectedCells).map(pos => {
|
|
1375
|
+
const [row, col] = pos.split('-');
|
|
1376
|
+
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
1377
|
+
});
|
|
1378
|
+
const table = document.querySelector(`#${id}`);
|
|
1379
|
+
const cells = table?.querySelectorAll(selectors.join(','));
|
|
1380
|
+
// const cells = table?.querySelectorAll(selectors.join(','))
|
|
1381
|
+
|
|
1382
|
+
// const cells = table?.querySelectorAll('.ui-rc-table-cell.selected');
|
|
1383
|
+
|
|
1384
|
+
if (cells) {
|
|
1385
|
+
cells.forEach(cell => {
|
|
1386
|
+
cell.classList.remove('selected');
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1199
1389
|
};
|
|
@@ -6,5 +6,5 @@ type Props = {
|
|
|
6
6
|
value: number | string | undefined;
|
|
7
7
|
onChange?: (values: any[]) => void;
|
|
8
8
|
};
|
|
9
|
-
declare const
|
|
10
|
-
export default
|
|
9
|
+
declare const NumberInput: (props: Props) => React.JSX.Element;
|
|
10
|
+
export default NumberInput;
|
|
@@ -2,7 +2,7 @@ import React, { Fragment } from "react";
|
|
|
2
2
|
import { NumericFormat } from "react-numeric-component";
|
|
3
3
|
import { Input } from "rc-master-ui";
|
|
4
4
|
import { checkDecimalSeparator, checkThousandSeparator } from "../hooks";
|
|
5
|
-
const
|
|
5
|
+
const NumberInput = props => {
|
|
6
6
|
const {
|
|
7
7
|
t,
|
|
8
8
|
value,
|
|
@@ -36,4 +36,4 @@ const Number = props => {
|
|
|
36
36
|
autoFocus: true
|
|
37
37
|
}));
|
|
38
38
|
};
|
|
39
|
-
export default
|
|
39
|
+
export default NumberInput;
|
|
@@ -426,6 +426,9 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
426
426
|
&.cell-paste-border-left {
|
|
427
427
|
border-inline-end: 1px dashed #949494;
|
|
428
428
|
}
|
|
429
|
+
&.cell-paste-border-top {
|
|
430
|
+
border-bottom: 1px dashed #949494 !important;
|
|
431
|
+
}
|
|
429
432
|
|
|
430
433
|
&.cell-border-right {
|
|
431
434
|
border-inline-end: 1px solid $border-selected-color;
|
|
@@ -13,7 +13,7 @@ import dayjs from "dayjs";
|
|
|
13
13
|
import 'dayjs/locale/es';
|
|
14
14
|
import 'dayjs/locale/vi';
|
|
15
15
|
import TableGrid from "../TableGrid";
|
|
16
|
-
import { addRows8, checkChild, editAbleColumns, findAllChildrenKeys, findItemByKey, findItemPath, flattenArray, flattenData, getDefaultValue, getEditType, getFirstSelectCell, getLastSelectCell, getRowNumber, getRowsPasteIndex,
|
|
16
|
+
import { addRows8, addRowsUp, checkChild, editAbleColumns, findAllChildrenKeys, findItemByKey, findItemPath, flattenArray, flattenData, getDefaultValue, getEditType, getFirstSelectCell, getLastSelectCell, getRowNumber, getRowsPasteIndex,
|
|
17
17
|
// isBottomMostInRanges,
|
|
18
18
|
isBottomMostInRegion,
|
|
19
19
|
// isContinuous,
|
|
@@ -21,7 +21,7 @@ isEditable,
|
|
|
21
21
|
// isEqualSet,
|
|
22
22
|
isObjEmpty, isRightMostInRegion, isTopMostInRegion,
|
|
23
23
|
// mergedSets,
|
|
24
|
-
newGuid, totalFixedWidth, updateArrayByKey } from "../hooks";
|
|
24
|
+
newGuid, sortedSetASC, totalFixedWidth, updateArrayByKey } from "../hooks";
|
|
25
25
|
import Message from "../../Message/Message";
|
|
26
26
|
// import Command from "../Command";
|
|
27
27
|
|
|
@@ -849,8 +849,14 @@ const GridEdit = props => {
|
|
|
849
849
|
};
|
|
850
850
|
const triggerDragPaste = pastesArray => {
|
|
851
851
|
const mergedSet = new Set([...selectedCells, ...pastesArray]);
|
|
852
|
-
|
|
852
|
+
|
|
853
|
+
// console.log('pastesArray', pastesArray)
|
|
854
|
+
// console.log('selectedCells', selectedCells)
|
|
855
|
+
|
|
856
|
+
setSelectedCells(sortedSetASC(mergedSet));
|
|
853
857
|
setPasteCells(new Set());
|
|
858
|
+
const rowSelectedFirst = getFirstSelectCell(selectedCells).row;
|
|
859
|
+
const rowPasteLast = getLastSelectCell(pasteCells).row;
|
|
854
860
|
const selectedArray = Array.from(selectedCells).map(key => {
|
|
855
861
|
const [row, col] = key.split("-").map(Number);
|
|
856
862
|
// @ts-ignore
|
|
@@ -884,7 +890,17 @@ const GridEdit = props => {
|
|
|
884
890
|
}) => {
|
|
885
891
|
table[row - minRow][col - minCol] = value;
|
|
886
892
|
});
|
|
887
|
-
|
|
893
|
+
let newRange = {
|
|
894
|
+
combined: [],
|
|
895
|
+
addedRows: []
|
|
896
|
+
};
|
|
897
|
+
if (rowPasteLast > rowSelectedFirst) {
|
|
898
|
+
// kéo xuóng
|
|
899
|
+
newRange = addRows8(table, getRowsPasteIndex(pastesArray).length);
|
|
900
|
+
} else {
|
|
901
|
+
// kéo lên
|
|
902
|
+
newRange = addRowsUp(table, getRowsPasteIndex(pastesArray).length);
|
|
903
|
+
}
|
|
888
904
|
const record = flattenData(childrenColumnName, dataSource)[getFirstSelectCell(pastesArray).row];
|
|
889
905
|
if (!record?.parentId) {
|
|
890
906
|
// Cập nhật data mới
|
|
@@ -1049,11 +1065,14 @@ const GridEdit = props => {
|
|
|
1049
1065
|
// kéo lên trên
|
|
1050
1066
|
|
|
1051
1067
|
const rowSelectedStart = getFirstSelectCell(selectedCells).row;
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
for (let
|
|
1055
|
-
|
|
1068
|
+
if (row < rowSelectedStart) {
|
|
1069
|
+
const newPasteCells = new Set();
|
|
1070
|
+
for (let r = Math.min(rowSelectedStart, row); r <= Math.max(rowSelectedStart, row) - 1; r++) {
|
|
1071
|
+
for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
|
|
1072
|
+
newPasteCells.add(`${r}-${c}`);
|
|
1073
|
+
}
|
|
1056
1074
|
}
|
|
1075
|
+
setPasteCells(newPasteCells);
|
|
1057
1076
|
}
|
|
1058
1077
|
}
|
|
1059
1078
|
if (col > colEnd) {
|
|
@@ -1701,7 +1720,9 @@ const GridEdit = props => {
|
|
|
1701
1720
|
const isTopSelected = selectedCells.has(topCellKey);
|
|
1702
1721
|
const isLeftSelected = selectedCells.has(leftCellKey);
|
|
1703
1722
|
const isRightSelected = selectedCells.has(rightCellKey);
|
|
1723
|
+
const topPasteCellKey = `${rowIndex + 1}-${colIndex}`;
|
|
1704
1724
|
const isPasteSelected = pasteCells.has(cellKey);
|
|
1725
|
+
const isPasteTopSelected = pasteCells.has(topPasteCellKey);
|
|
1705
1726
|
const isPasteLeftSelected = pasteCells.has(leftCellKey);
|
|
1706
1727
|
const isPasteRightSelected = pasteCells.has(rightCellKey);
|
|
1707
1728
|
const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable';
|
|
@@ -1710,15 +1731,20 @@ const GridEdit = props => {
|
|
|
1710
1731
|
const cellEnd = getLastSelectCell(selectedCells);
|
|
1711
1732
|
const cellPasteStart = getFirstSelectCell(pasteCells);
|
|
1712
1733
|
const cellPasteSEnd = getLastSelectCell(pasteCells);
|
|
1713
|
-
const isPasteBottom = pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row);
|
|
1734
|
+
const isPasteBottom = cellPasteSEnd.row > cellStart.row && pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row);
|
|
1735
|
+
|
|
1736
|
+
// const rowSelectedFirst = getFirstSelectCell(selectedCells).row
|
|
1737
|
+
// const rowPasteLast = getLastSelectCell(pasteCells).row
|
|
1738
|
+
|
|
1714
1739
|
if (!isSelected && !isPasteSelected) {
|
|
1715
1740
|
// const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
|
|
1716
1741
|
const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && isTopMostInRegion(rowIndex + 1, colIndex, selectedCells);
|
|
1717
1742
|
const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
|
|
1718
1743
|
const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
|
|
1744
|
+
const isPasteTop = cellPasteSEnd.row < cellStart.row && isTopMostInRegion(rowIndex + 1, colIndex, pasteCells);
|
|
1719
1745
|
const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
|
|
1720
1746
|
const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
|
|
1721
|
-
return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` : isPasteLeftSelected || isPasteRightSelected ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''}` : cellClass;
|
|
1747
|
+
return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` : isPasteLeftSelected || isPasteRightSelected || isPasteTopSelected ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''} ${isPasteTop ? `cell-paste-border-top` : ''}` : cellClass;
|
|
1722
1748
|
}
|
|
1723
1749
|
const isBottom = isBottomMostInRegion(rowIndex, colIndex, selectedCells);
|
|
1724
1750
|
// const isBottom = isBottomMostInRanges(rowIndex, colIndex, [selectedCells, ...ctrlCells])
|
|
@@ -1990,7 +2016,7 @@ const GridEdit = props => {
|
|
|
1990
2016
|
,
|
|
1991
2017
|
onMouseDown: e => {
|
|
1992
2018
|
// e.stopPropagation()
|
|
1993
|
-
|
|
2019
|
+
e.preventDefault();
|
|
1994
2020
|
setIsPasteDragging(true);
|
|
1995
2021
|
},
|
|
1996
2022
|
onDoubleClick: handlePointDoubleClick
|
|
@@ -574,6 +574,7 @@ const EditableCell = props => {
|
|
|
574
574
|
},
|
|
575
575
|
treeCheckable: column?.editSelectSettings?.selectMode === 'checkbox',
|
|
576
576
|
filterTreeNode: filterTreeNode,
|
|
577
|
+
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
577
578
|
onSelect: (val, option) => {
|
|
578
579
|
onChange(val ?? '');
|
|
579
580
|
const formState = getValues();
|
|
@@ -87,7 +87,8 @@ const getValueCell = (column, value, format) => {
|
|
|
87
87
|
|
|
88
88
|
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
|
|
89
89
|
|
|
90
|
-
const
|
|
90
|
+
const tmpval = typeof value === 'string' ? Number(value) : value;
|
|
91
|
+
const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? tmpval.toFixed(dec) : tmpval.toString() : '0';
|
|
91
92
|
const numericFormatProps = {
|
|
92
93
|
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
93
94
|
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
@@ -62,6 +62,13 @@ export declare function addRows8(arr: any, n: number): {
|
|
|
62
62
|
combined: any[];
|
|
63
63
|
addedRows: any[];
|
|
64
64
|
};
|
|
65
|
+
export declare function addRowsUp(array: any, n: number): {
|
|
66
|
+
combined: any;
|
|
67
|
+
addedRows: any[];
|
|
68
|
+
} | {
|
|
69
|
+
combined: any[];
|
|
70
|
+
addedRows: any[];
|
|
71
|
+
};
|
|
65
72
|
export declare const transformColumns: <RecordType>(cols: ColumnsTable<RecordType>, convertColumns: any[], t?: any) => ColumnsTable<RecordType>;
|
|
66
73
|
export declare const transformColumns1: <RecordType>(cols: ColumnsTable<RecordType>, sortMultiple?: boolean) => ColumnsTable<RecordType>;
|
|
67
74
|
export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType>[], groupColumns: string[]) => ColumnsTable<RecordType>;
|
|
@@ -93,3 +100,7 @@ export declare function isRightMostInRegion(rowIndex: number, colIndex: number,
|
|
|
93
100
|
export declare function isEqualSet(setA: any, setB: any): boolean;
|
|
94
101
|
export declare function isBottomMostInRanges(rowIndex: number, colIndex: number, regions: any[]): boolean;
|
|
95
102
|
export declare const mergedSets: (arr: any[]) => Set<unknown>;
|
|
103
|
+
export declare const sortedSetASC: (setValue: any) => Set<unknown>;
|
|
104
|
+
export declare const sortedSetDSC: (setValue: any) => Set<unknown>;
|
|
105
|
+
export declare const onAddClassSelectedCell: (selectedCells: any, id?: string) => void;
|
|
106
|
+
export declare const onRemoveClassSelectedCell: (selectedCells: any, id?: string) => void;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.addRowIdArray = void 0;
|
|
8
8
|
exports.addRows8 = addRows8;
|
|
9
|
+
exports.addRowsUp = addRowsUp;
|
|
9
10
|
exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = exports.buildConnectedRegions = void 0;
|
|
10
11
|
exports.compareDate = compareDate;
|
|
11
12
|
exports.compareDates = compareDates;
|
|
@@ -23,7 +24,7 @@ exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
|
|
|
23
24
|
exports.isEqualSet = isEqualSet;
|
|
24
25
|
exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
|
|
25
26
|
exports.isRightMostInRegion = isRightMostInRegion;
|
|
26
|
-
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.removeFieldRecursive = exports.removeColumns = exports.parseCells = exports.parseBooleanToValue = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = void 0;
|
|
27
|
+
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.removeFieldRecursive = exports.removeColumns = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveClassSelectedCell = exports.onAddClassSelectedCell = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = void 0;
|
|
27
28
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
28
29
|
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
29
30
|
var _uuid = require("uuid");
|
|
@@ -690,6 +691,146 @@ function addRows8(arr, n) {
|
|
|
690
691
|
addedRows
|
|
691
692
|
};
|
|
692
693
|
}
|
|
694
|
+
function addRowsUp(array, n) {
|
|
695
|
+
const arr = array.reverse();
|
|
696
|
+
if (!Array.isArray(arr) || arr.length === 0) return {
|
|
697
|
+
combined: arr,
|
|
698
|
+
addedRows: []
|
|
699
|
+
};
|
|
700
|
+
const m = arr.length;
|
|
701
|
+
const numCols = arr[0].length;
|
|
702
|
+
const addedRows = [];
|
|
703
|
+
|
|
704
|
+
// Hàm kiểm tra kiểu date hợp lệ
|
|
705
|
+
const isValidDate = item => {
|
|
706
|
+
// console.log('!isNaN(Date.parse(d))', !isNaN(Date.parse(d)))
|
|
707
|
+
// return !isNaN(Date.parse(d))
|
|
708
|
+
|
|
709
|
+
if (typeof item === 'number') {
|
|
710
|
+
// return 'number'
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
713
|
+
if (typeof item === 'string') {
|
|
714
|
+
// Kiểm tra nếu là chuỗi ISO date hợp lệ
|
|
715
|
+
const date = new Date(item);
|
|
716
|
+
if (!isNaN(date.getTime()) && item.includes('T')) {
|
|
717
|
+
// return 'date'
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
// return 'string'
|
|
721
|
+
return false;
|
|
722
|
+
}
|
|
723
|
+
return !isNaN(Date.parse(item));
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
// Lấy giá trị mẫu của cột j từ hàng đầu tiên
|
|
727
|
+
const getSample = j => arr[0][j];
|
|
728
|
+
|
|
729
|
+
// Xác định chế độ xử lý cho mỗi cột:
|
|
730
|
+
// mode = 'number-stepping' | 'date-stepping' | 'number-constant' | 'cycle'
|
|
731
|
+
const modes = [];
|
|
732
|
+
const steps = []; // bước tăng, nếu có (cho number hoặc date)
|
|
733
|
+
|
|
734
|
+
for (let j = 0; j < numCols; j++) {
|
|
735
|
+
const sample = getSample(j);
|
|
736
|
+
if (m === 1) {
|
|
737
|
+
// Nếu mảng chỉ có 1 hàng: nếu là số thì giữ nguyên; nếu là date thì tăng 1 ngày; còn lại giữ nguyên.
|
|
738
|
+
if (typeof sample === "number") {
|
|
739
|
+
modes[j] = "number-constant";
|
|
740
|
+
} else if (isValidDate(sample)) {
|
|
741
|
+
modes[j] = "date-stepping";
|
|
742
|
+
steps[j] = 24 * 3600 * 1000; // 1 ngày = 86400000 ms
|
|
743
|
+
} else {
|
|
744
|
+
modes[j] = "cycle";
|
|
745
|
+
}
|
|
746
|
+
} else if (m === 2) {
|
|
747
|
+
// Nếu mảng có 2 hàng: nếu là số thì tính bước = row2 - row1, tương tự với date
|
|
748
|
+
const first = arr[0][j],
|
|
749
|
+
second = arr[1][j];
|
|
750
|
+
if (typeof first === "number" && typeof second === "number") {
|
|
751
|
+
modes[j] = "number-stepping";
|
|
752
|
+
steps[j] = second - first;
|
|
753
|
+
} else if (isValidDate(first) && isValidDate(second)) {
|
|
754
|
+
modes[j] = "date-stepping";
|
|
755
|
+
steps[j] = Date.parse(second) - Date.parse(first);
|
|
756
|
+
} else {
|
|
757
|
+
modes[j] = "cycle";
|
|
758
|
+
}
|
|
759
|
+
} else {
|
|
760
|
+
// Nếu mảng có >2 hàng
|
|
761
|
+
const first = arr[0][j],
|
|
762
|
+
second = arr[1][j],
|
|
763
|
+
third = arr[2][j];
|
|
764
|
+
if (typeof first === "number" && typeof second === "number" && typeof third === "number") {
|
|
765
|
+
const step1 = second - first;
|
|
766
|
+
const step2 = third - second;
|
|
767
|
+
if (step1 === step2) {
|
|
768
|
+
modes[j] = "number-stepping";
|
|
769
|
+
steps[j] = step1;
|
|
770
|
+
} else {
|
|
771
|
+
modes[j] = "cycle";
|
|
772
|
+
}
|
|
773
|
+
} else if (isValidDate(first) && isValidDate(second) && isValidDate(third)) {
|
|
774
|
+
const step1 = Date.parse(second) - Date.parse(first);
|
|
775
|
+
const step2 = Date.parse(third) - Date.parse(second);
|
|
776
|
+
if (step1 === step2) {
|
|
777
|
+
modes[j] = "date-stepping";
|
|
778
|
+
steps[j] = step1;
|
|
779
|
+
} else {
|
|
780
|
+
modes[j] = "cycle";
|
|
781
|
+
}
|
|
782
|
+
} else {
|
|
783
|
+
modes[j] = "cycle";
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Tạo các dòng mới (thêm n dòng)
|
|
789
|
+
// Với mỗi cột, nếu chế độ là stepping thì lấy giá trị cuối của mảng ban đầu và cộng thêm (i+1)*step
|
|
790
|
+
// Nếu chế độ là cycle thì dùng arr[i mod m][j]
|
|
791
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
792
|
+
const newRow = [];
|
|
793
|
+
for (let j = 0; j < numCols; j++) {
|
|
794
|
+
let newValue;
|
|
795
|
+
switch (modes[j]) {
|
|
796
|
+
case "number-constant":
|
|
797
|
+
// Mảng có 1 hàng, số giữ nguyên
|
|
798
|
+
newValue = arr[0][j];
|
|
799
|
+
break;
|
|
800
|
+
case "number-stepping":
|
|
801
|
+
{
|
|
802
|
+
// Lấy giá trị cuối của cột j trong mảng ban đầu
|
|
803
|
+
|
|
804
|
+
const lastValue = arr[m - 1][j];
|
|
805
|
+
newValue = lastValue - (i + 1) * steps[j] * -1;
|
|
806
|
+
}
|
|
807
|
+
break;
|
|
808
|
+
case "date-stepping":
|
|
809
|
+
{
|
|
810
|
+
// Lấy giá trị cuối, chuyển về date, cộng thêm (i+1)*step, chuyển lại về định dạng ISO
|
|
811
|
+
|
|
812
|
+
const lastDate = new Date(array[m - 1][j]);
|
|
813
|
+
const newTime = lastDate.getTime() - (i + 1) * steps[j] * -1;
|
|
814
|
+
newValue = (0, _moment.default)(new Date(newTime)).format();
|
|
815
|
+
}
|
|
816
|
+
break;
|
|
817
|
+
case "cycle":
|
|
818
|
+
default:
|
|
819
|
+
// Lặp lại nội dung theo vòng tròn: dùng hàng thứ (i mod m)
|
|
820
|
+
|
|
821
|
+
newValue = arr[i % m][j];
|
|
822
|
+
break;
|
|
823
|
+
}
|
|
824
|
+
newRow.push(newValue);
|
|
825
|
+
}
|
|
826
|
+
addedRows.push(newRow);
|
|
827
|
+
}
|
|
828
|
+
const combined = arr.concat(addedRows);
|
|
829
|
+
return {
|
|
830
|
+
combined,
|
|
831
|
+
addedRows
|
|
832
|
+
};
|
|
833
|
+
}
|
|
693
834
|
const transformColumns = (cols, convertColumns, t) => {
|
|
694
835
|
// @ts-ignore
|
|
695
836
|
return cols.map(column => {
|
|
@@ -1282,4 +1423,58 @@ function isBottomMostInRanges(rowIndex, colIndex, regions) {
|
|
|
1282
1423
|
const mergedSets = arr => {
|
|
1283
1424
|
return new Set(arr.flatMap(set => Array.from(set)));
|
|
1284
1425
|
};
|
|
1285
|
-
exports.mergedSets = mergedSets;
|
|
1426
|
+
exports.mergedSets = mergedSets;
|
|
1427
|
+
const sortedSetASC = setValue => {
|
|
1428
|
+
const sorted = Array.from(setValue).sort((a, b) => {
|
|
1429
|
+
const [a1, a2] = a.split("-").map(Number);
|
|
1430
|
+
const [b1, b2] = b.split("-").map(Number);
|
|
1431
|
+
return a1 - b1 || a2 - b2;
|
|
1432
|
+
});
|
|
1433
|
+
return new Set(sorted);
|
|
1434
|
+
};
|
|
1435
|
+
exports.sortedSetASC = sortedSetASC;
|
|
1436
|
+
const sortedSetDSC = setValue => {
|
|
1437
|
+
const sorted = Array.from(setValue).sort((a, b) => {
|
|
1438
|
+
const [a1, a2] = a.split("-").map(Number);
|
|
1439
|
+
const [b1, b2] = b.split("-").map(Number);
|
|
1440
|
+
return b1 - a1 || b2 - a2;
|
|
1441
|
+
});
|
|
1442
|
+
return new Set(sorted);
|
|
1443
|
+
};
|
|
1444
|
+
exports.sortedSetDSC = sortedSetDSC;
|
|
1445
|
+
const onAddClassSelectedCell = (selectedCells, id) => {
|
|
1446
|
+
const selectors = Array.from(selectedCells).map(pos => {
|
|
1447
|
+
const [row1, col1] = pos.split('-');
|
|
1448
|
+
return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
|
|
1449
|
+
});
|
|
1450
|
+
|
|
1451
|
+
// const cells = document.querySelectorAll(selectors.join(','));
|
|
1452
|
+
|
|
1453
|
+
const table = document.querySelector(`#${id}`);
|
|
1454
|
+
console.log('table', table);
|
|
1455
|
+
const cells = table?.querySelectorAll(selectors.join(','));
|
|
1456
|
+
if (cells) {
|
|
1457
|
+
cells.forEach(cell => {
|
|
1458
|
+
cell.classList.add('selected');
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
exports.onAddClassSelectedCell = onAddClassSelectedCell;
|
|
1463
|
+
const onRemoveClassSelectedCell = (selectedCells, id) => {
|
|
1464
|
+
const selectors = Array.from(selectedCells).map(pos => {
|
|
1465
|
+
const [row, col] = pos.split('-');
|
|
1466
|
+
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
1467
|
+
});
|
|
1468
|
+
const table = document.querySelector(`#${id}`);
|
|
1469
|
+
const cells = table?.querySelectorAll(selectors.join(','));
|
|
1470
|
+
// const cells = table?.querySelectorAll(selectors.join(','))
|
|
1471
|
+
|
|
1472
|
+
// const cells = table?.querySelectorAll('.ui-rc-table-cell.selected');
|
|
1473
|
+
|
|
1474
|
+
if (cells) {
|
|
1475
|
+
cells.forEach(cell => {
|
|
1476
|
+
cell.classList.remove('selected');
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
exports.onRemoveClassSelectedCell = onRemoveClassSelectedCell;
|
|
@@ -6,5 +6,5 @@ type Props = {
|
|
|
6
6
|
value: number | string | undefined;
|
|
7
7
|
onChange?: (values: any[]) => void;
|
|
8
8
|
};
|
|
9
|
-
declare const
|
|
10
|
-
export default
|
|
9
|
+
declare const NumberInput: (props: Props) => React.JSX.Element;
|
|
10
|
+
export default NumberInput;
|
|
@@ -10,7 +10,7 @@ var _rcMasterUi = require("rc-master-ui");
|
|
|
10
10
|
var _hooks = require("../hooks");
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
13
|
-
const
|
|
13
|
+
const NumberInput = props => {
|
|
14
14
|
const {
|
|
15
15
|
t,
|
|
16
16
|
value,
|
|
@@ -44,4 +44,4 @@ const Number = props => {
|
|
|
44
44
|
autoFocus: true
|
|
45
45
|
}));
|
|
46
46
|
};
|
|
47
|
-
var _default = exports.default =
|
|
47
|
+
var _default = exports.default = NumberInput;
|
|
@@ -426,6 +426,9 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
426
426
|
&.cell-paste-border-left {
|
|
427
427
|
border-inline-end: 1px dashed #949494;
|
|
428
428
|
}
|
|
429
|
+
&.cell-paste-border-top {
|
|
430
|
+
border-bottom: 1px dashed #949494 !important;
|
|
431
|
+
}
|
|
429
432
|
|
|
430
433
|
&.cell-border-right {
|
|
431
434
|
border-inline-end: 1px solid $border-selected-color;
|
|
@@ -849,8 +849,14 @@ const GridEdit = props => {
|
|
|
849
849
|
};
|
|
850
850
|
const triggerDragPaste = pastesArray => {
|
|
851
851
|
const mergedSet = new Set([...selectedCells, ...pastesArray]);
|
|
852
|
-
|
|
852
|
+
|
|
853
|
+
// console.log('pastesArray', pastesArray)
|
|
854
|
+
// console.log('selectedCells', selectedCells)
|
|
855
|
+
|
|
856
|
+
setSelectedCells((0, _hooks.sortedSetASC)(mergedSet));
|
|
853
857
|
setPasteCells(new Set());
|
|
858
|
+
const rowSelectedFirst = (0, _hooks.getFirstSelectCell)(selectedCells).row;
|
|
859
|
+
const rowPasteLast = (0, _hooks.getLastSelectCell)(pasteCells).row;
|
|
854
860
|
const selectedArray = Array.from(selectedCells).map(key => {
|
|
855
861
|
const [row, col] = key.split("-").map(Number);
|
|
856
862
|
// @ts-ignore
|
|
@@ -884,7 +890,17 @@ const GridEdit = props => {
|
|
|
884
890
|
}) => {
|
|
885
891
|
table[row - minRow][col - minCol] = value;
|
|
886
892
|
});
|
|
887
|
-
|
|
893
|
+
let newRange = {
|
|
894
|
+
combined: [],
|
|
895
|
+
addedRows: []
|
|
896
|
+
};
|
|
897
|
+
if (rowPasteLast > rowSelectedFirst) {
|
|
898
|
+
// kéo xuóng
|
|
899
|
+
newRange = (0, _hooks.addRows8)(table, (0, _hooks.getRowsPasteIndex)(pastesArray).length);
|
|
900
|
+
} else {
|
|
901
|
+
// kéo lên
|
|
902
|
+
newRange = (0, _hooks.addRowsUp)(table, (0, _hooks.getRowsPasteIndex)(pastesArray).length);
|
|
903
|
+
}
|
|
888
904
|
const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[(0, _hooks.getFirstSelectCell)(pastesArray).row];
|
|
889
905
|
if (!record?.parentId) {
|
|
890
906
|
// Cập nhật data mới
|
|
@@ -1049,11 +1065,14 @@ const GridEdit = props => {
|
|
|
1049
1065
|
// kéo lên trên
|
|
1050
1066
|
|
|
1051
1067
|
const rowSelectedStart = (0, _hooks.getFirstSelectCell)(selectedCells).row;
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
for (let
|
|
1055
|
-
|
|
1068
|
+
if (row < rowSelectedStart) {
|
|
1069
|
+
const newPasteCells = new Set();
|
|
1070
|
+
for (let r = Math.min(rowSelectedStart, row); r <= Math.max(rowSelectedStart, row) - 1; r++) {
|
|
1071
|
+
for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
|
|
1072
|
+
newPasteCells.add(`${r}-${c}`);
|
|
1073
|
+
}
|
|
1056
1074
|
}
|
|
1075
|
+
setPasteCells(newPasteCells);
|
|
1057
1076
|
}
|
|
1058
1077
|
}
|
|
1059
1078
|
if (col > colEnd) {
|
|
@@ -1701,7 +1720,9 @@ const GridEdit = props => {
|
|
|
1701
1720
|
const isTopSelected = selectedCells.has(topCellKey);
|
|
1702
1721
|
const isLeftSelected = selectedCells.has(leftCellKey);
|
|
1703
1722
|
const isRightSelected = selectedCells.has(rightCellKey);
|
|
1723
|
+
const topPasteCellKey = `${rowIndex + 1}-${colIndex}`;
|
|
1704
1724
|
const isPasteSelected = pasteCells.has(cellKey);
|
|
1725
|
+
const isPasteTopSelected = pasteCells.has(topPasteCellKey);
|
|
1705
1726
|
const isPasteLeftSelected = pasteCells.has(leftCellKey);
|
|
1706
1727
|
const isPasteRightSelected = pasteCells.has(rightCellKey);
|
|
1707
1728
|
const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable';
|
|
@@ -1710,15 +1731,20 @@ const GridEdit = props => {
|
|
|
1710
1731
|
const cellEnd = (0, _hooks.getLastSelectCell)(selectedCells);
|
|
1711
1732
|
const cellPasteStart = (0, _hooks.getFirstSelectCell)(pasteCells);
|
|
1712
1733
|
const cellPasteSEnd = (0, _hooks.getLastSelectCell)(pasteCells);
|
|
1713
|
-
const isPasteBottom = pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row);
|
|
1734
|
+
const isPasteBottom = cellPasteSEnd.row > cellStart.row && pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row);
|
|
1735
|
+
|
|
1736
|
+
// const rowSelectedFirst = getFirstSelectCell(selectedCells).row
|
|
1737
|
+
// const rowPasteLast = getLastSelectCell(pasteCells).row
|
|
1738
|
+
|
|
1714
1739
|
if (!isSelected && !isPasteSelected) {
|
|
1715
1740
|
// const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
|
|
1716
1741
|
const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && (0, _hooks.isTopMostInRegion)(rowIndex + 1, colIndex, selectedCells);
|
|
1717
1742
|
const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
|
|
1718
1743
|
const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
|
|
1744
|
+
const isPasteTop = cellPasteSEnd.row < cellStart.row && (0, _hooks.isTopMostInRegion)(rowIndex + 1, colIndex, pasteCells);
|
|
1719
1745
|
const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
|
|
1720
1746
|
const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
|
|
1721
|
-
return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` : isPasteLeftSelected || isPasteRightSelected ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''}` : cellClass;
|
|
1747
|
+
return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` : isPasteLeftSelected || isPasteRightSelected || isPasteTopSelected ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''} ${isPasteTop ? `cell-paste-border-top` : ''}` : cellClass;
|
|
1722
1748
|
}
|
|
1723
1749
|
const isBottom = (0, _hooks.isBottomMostInRegion)(rowIndex, colIndex, selectedCells);
|
|
1724
1750
|
// const isBottom = isBottomMostInRanges(rowIndex, colIndex, [selectedCells, ...ctrlCells])
|
|
@@ -1990,7 +2016,7 @@ const GridEdit = props => {
|
|
|
1990
2016
|
,
|
|
1991
2017
|
onMouseDown: e => {
|
|
1992
2018
|
// e.stopPropagation()
|
|
1993
|
-
|
|
2019
|
+
e.preventDefault();
|
|
1994
2020
|
setIsPasteDragging(true);
|
|
1995
2021
|
},
|
|
1996
2022
|
onDoubleClick: handlePointDoubleClick
|
package/package.json
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "es-grid-template",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "es-grid-template",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"react",
|
|
7
|
-
"react-component",
|
|
8
|
-
"grid",
|
|
9
|
-
"table"
|
|
10
|
-
],
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"main": "lib/index",
|
|
13
|
-
"module": "es/index",
|
|
14
|
-
"files": [
|
|
15
|
-
"lib",
|
|
16
|
-
"es",
|
|
17
|
-
"assets/*.css",
|
|
18
|
-
"assets/*.scss"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"__compile": "father build && ",
|
|
22
|
-
"compile": "father build && sass assets/index.scss assets/index.css",
|
|
23
|
-
"docs:build": "dumi build",
|
|
24
|
-
"__docs:deploy": "gh-pages -d dist",
|
|
25
|
-
"lint": "eslint src/ --ext .tsx,.ts,.jsx,.js",
|
|
26
|
-
"now-build": "npm run docs:build",
|
|
27
|
-
"prepare": "dumi setup",
|
|
28
|
-
"prepublishOnly": "npm run compile",
|
|
29
|
-
"postpublish": "npm run docs:build",
|
|
30
|
-
"__postpublish": "npm run docs:build && npm run docs:deploy",
|
|
31
|
-
"start": "dumi dev",
|
|
32
|
-
"test": "vitest --watch false",
|
|
33
|
-
"coverage": "vitest run --coverage"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@ant-design/colors": "^8.0.0",
|
|
37
|
-
"@ant-design/cssinjs": "^1.22.0",
|
|
38
|
-
"@ant-design/cssinjs-utils": "^1.1.1",
|
|
39
|
-
"@ant-design/icons": "^5.5.2",
|
|
40
|
-
"@babel/runtime": "^7.11.2",
|
|
41
|
-
"@core-rc/rc-select": "^0.0.8",
|
|
42
|
-
"@ctrl/tinycolor": "^3.6.1",
|
|
43
|
-
"@faker-js/faker": "^9.5.0",
|
|
44
|
-
"@floating-ui/react": "^0.27.5",
|
|
45
|
-
"@rc-component/color-picker": "^2.0.1",
|
|
46
|
-
"@rc-component/father-plugin": "^2.0.1",
|
|
47
|
-
"@rc-component/trigger": "^2.0.0",
|
|
48
|
-
"@rc-component/util": "^1.0.1",
|
|
49
|
-
"@types/react-resizable": "^3.0.8",
|
|
50
|
-
"@types/styled-components": "^5.1.34",
|
|
51
|
-
"@vitest/coverage-v8": "^2.0.5",
|
|
52
|
-
"antd": "^5.24.1",
|
|
53
|
-
"antd-style": "^3.7.1",
|
|
54
|
-
"becoxy-icons": "^2.0.1",
|
|
55
|
-
"classnames": "^2.3.1",
|
|
56
|
-
"dayjs": "^1.11.13",
|
|
57
|
-
"lodash": "^4.17.21",
|
|
58
|
-
"moment": "^2.30.1",
|
|
59
|
-
"postcss": "^8.4.35",
|
|
60
|
-
"rc-checkbox": "^3.5.0",
|
|
61
|
-
"rc-dropdown": "^4.2.1",
|
|
62
|
-
"rc-field-form": "^2.6.0",
|
|
63
|
-
"rc-master-ui": "^1.1.24",
|
|
64
|
-
"rc-select": "^14.16.3",
|
|
65
|
-
"rc-tooltip": "^6.3.0",
|
|
66
|
-
"rc-tree": "^5.10.1",
|
|
67
|
-
"rc-tree-select": "^5.24.5",
|
|
68
|
-
"react-hook-form": "^7.54.2",
|
|
69
|
-
"react-hot-toast": "^2.5.2",
|
|
70
|
-
"react-numeric-component": "^1.0.7",
|
|
71
|
-
"react-resizable": "^3.0.5",
|
|
72
|
-
"react-tooltip": "^5.28.1",
|
|
73
|
-
"sass": "^1.81.0",
|
|
74
|
-
"styled-components": "^6.1.15",
|
|
75
|
-
"sweetalert2": "^11.4.14",
|
|
76
|
-
"sweetalert2-react-content": "^5.0.0",
|
|
77
|
-
"throttle-debounce": "^5.0.2",
|
|
78
|
-
"vitest": "^2.0.5"
|
|
79
|
-
},
|
|
80
|
-
"devDependencies": {
|
|
81
|
-
"@babel/cli": "^7.26.4",
|
|
82
|
-
"@babel/preset-env": "^7.26.9",
|
|
83
|
-
"@rc-component/np": "^1.0.3",
|
|
84
|
-
"@testing-library/react": "^14.0.0",
|
|
85
|
-
"@types/jest": "^29.4.0",
|
|
86
|
-
"@types/react": "^18.0.26",
|
|
87
|
-
"@types/react-dom": "^18.0.10",
|
|
88
|
-
"@types/warning": "^3.0.0",
|
|
89
|
-
"cross-env": "^7.0.0",
|
|
90
|
-
"dumi": "^2.2.13",
|
|
91
|
-
"eslint": "^8.56.0",
|
|
92
|
-
"eslint-plugin-unicorn": "^55.0.0",
|
|
93
|
-
"father": "^4.0.0",
|
|
94
|
-
"gh-pages": "^3.1.0",
|
|
95
|
-
"less": "^4.1.1",
|
|
96
|
-
"np": "^7.1.0",
|
|
97
|
-
"rc-test": "^7.0.9",
|
|
98
|
-
"react": "^18.2.0",
|
|
99
|
-
"react-dom": "^18.2.0",
|
|
100
|
-
"typescript": "^4.0.5"
|
|
101
|
-
},
|
|
102
|
-
"peerDependencies": {
|
|
103
|
-
"react": ">=16.9.0",
|
|
104
|
-
"react-dom": ">=16.9.0"
|
|
105
|
-
},
|
|
106
|
-
"umi": {
|
|
107
|
-
"configFile": "config.ts"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "es-grid-template",
|
|
3
|
+
"version": "1.3.6",
|
|
4
|
+
"description": "es-grid-template",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"react-component",
|
|
8
|
+
"grid",
|
|
9
|
+
"table"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"main": "lib/index",
|
|
13
|
+
"module": "es/index",
|
|
14
|
+
"files": [
|
|
15
|
+
"lib",
|
|
16
|
+
"es",
|
|
17
|
+
"assets/*.css",
|
|
18
|
+
"assets/*.scss"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"__compile": "father build && ",
|
|
22
|
+
"compile": "father build && sass assets/index.scss assets/index.css",
|
|
23
|
+
"docs:build": "dumi build",
|
|
24
|
+
"__docs:deploy": "gh-pages -d dist",
|
|
25
|
+
"lint": "eslint src/ --ext .tsx,.ts,.jsx,.js",
|
|
26
|
+
"now-build": "npm run docs:build",
|
|
27
|
+
"prepare": "dumi setup",
|
|
28
|
+
"prepublishOnly": "npm run compile",
|
|
29
|
+
"postpublish": "npm run docs:build",
|
|
30
|
+
"__postpublish": "npm run docs:build && npm run docs:deploy",
|
|
31
|
+
"start": "dumi dev",
|
|
32
|
+
"test": "vitest --watch false",
|
|
33
|
+
"coverage": "vitest run --coverage"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@ant-design/colors": "^8.0.0",
|
|
37
|
+
"@ant-design/cssinjs": "^1.22.0",
|
|
38
|
+
"@ant-design/cssinjs-utils": "^1.1.1",
|
|
39
|
+
"@ant-design/icons": "^5.5.2",
|
|
40
|
+
"@babel/runtime": "^7.11.2",
|
|
41
|
+
"@core-rc/rc-select": "^0.0.8",
|
|
42
|
+
"@ctrl/tinycolor": "^3.6.1",
|
|
43
|
+
"@faker-js/faker": "^9.5.0",
|
|
44
|
+
"@floating-ui/react": "^0.27.5",
|
|
45
|
+
"@rc-component/color-picker": "^2.0.1",
|
|
46
|
+
"@rc-component/father-plugin": "^2.0.1",
|
|
47
|
+
"@rc-component/trigger": "^2.0.0",
|
|
48
|
+
"@rc-component/util": "^1.0.1",
|
|
49
|
+
"@types/react-resizable": "^3.0.8",
|
|
50
|
+
"@types/styled-components": "^5.1.34",
|
|
51
|
+
"@vitest/coverage-v8": "^2.0.5",
|
|
52
|
+
"antd": "^5.24.1",
|
|
53
|
+
"antd-style": "^3.7.1",
|
|
54
|
+
"becoxy-icons": "^2.0.1",
|
|
55
|
+
"classnames": "^2.3.1",
|
|
56
|
+
"dayjs": "^1.11.13",
|
|
57
|
+
"lodash": "^4.17.21",
|
|
58
|
+
"moment": "^2.30.1",
|
|
59
|
+
"postcss": "^8.4.35",
|
|
60
|
+
"rc-checkbox": "^3.5.0",
|
|
61
|
+
"rc-dropdown": "^4.2.1",
|
|
62
|
+
"rc-field-form": "^2.6.0",
|
|
63
|
+
"rc-master-ui": "^1.1.24",
|
|
64
|
+
"rc-select": "^14.16.3",
|
|
65
|
+
"rc-tooltip": "^6.3.0",
|
|
66
|
+
"rc-tree": "^5.10.1",
|
|
67
|
+
"rc-tree-select": "^5.24.5",
|
|
68
|
+
"react-hook-form": "^7.54.2",
|
|
69
|
+
"react-hot-toast": "^2.5.2",
|
|
70
|
+
"react-numeric-component": "^1.0.7",
|
|
71
|
+
"react-resizable": "^3.0.5",
|
|
72
|
+
"react-tooltip": "^5.28.1",
|
|
73
|
+
"sass": "^1.81.0",
|
|
74
|
+
"styled-components": "^6.1.15",
|
|
75
|
+
"sweetalert2": "^11.4.14",
|
|
76
|
+
"sweetalert2-react-content": "^5.0.0",
|
|
77
|
+
"throttle-debounce": "^5.0.2",
|
|
78
|
+
"vitest": "^2.0.5"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@babel/cli": "^7.26.4",
|
|
82
|
+
"@babel/preset-env": "^7.26.9",
|
|
83
|
+
"@rc-component/np": "^1.0.3",
|
|
84
|
+
"@testing-library/react": "^14.0.0",
|
|
85
|
+
"@types/jest": "^29.4.0",
|
|
86
|
+
"@types/react": "^18.0.26",
|
|
87
|
+
"@types/react-dom": "^18.0.10",
|
|
88
|
+
"@types/warning": "^3.0.0",
|
|
89
|
+
"cross-env": "^7.0.0",
|
|
90
|
+
"dumi": "^2.2.13",
|
|
91
|
+
"eslint": "^8.56.0",
|
|
92
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
93
|
+
"father": "^4.0.0",
|
|
94
|
+
"gh-pages": "^3.1.0",
|
|
95
|
+
"less": "^4.1.1",
|
|
96
|
+
"np": "^7.1.0",
|
|
97
|
+
"rc-test": "^7.0.9",
|
|
98
|
+
"react": "^18.2.0",
|
|
99
|
+
"react-dom": "^18.2.0",
|
|
100
|
+
"typescript": "^4.0.5"
|
|
101
|
+
},
|
|
102
|
+
"peerDependencies": {
|
|
103
|
+
"react": ">=16.9.0",
|
|
104
|
+
"react-dom": ">=16.9.0"
|
|
105
|
+
},
|
|
106
|
+
"umi": {
|
|
107
|
+
"configFile": "config.ts"
|
|
108
|
+
}
|
|
109
|
+
}
|