es-grid-template 1.9.73 → 1.9.75
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 +0 -1
- package/es/ali-table/InternalTable.js +169 -29
- package/es/ali-table/base-table/html-table.js +1 -1
- package/es/ali-table/base-table/styles.d.ts +1 -0
- package/es/ali-table/base-table/styles.js +2 -1
- package/es/ali-table/pipeline/features/columnCustom.d.ts +1 -0
- package/es/ali-table/pipeline/features/columnCustom.js +143 -10
- package/es/ali-table/utils/utility.d.ts +11 -0
- package/es/ali-table/utils/utility.js +49 -0
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/table-component/table/Grid.js +12 -1
- package/lib/ali-table/Grid.js +0 -1
- package/lib/ali-table/InternalTable.js +167 -27
- package/lib/ali-table/base-table/html-table.js +1 -1
- package/lib/ali-table/base-table/styles.d.ts +1 -0
- package/lib/ali-table/base-table/styles.js +2 -1
- package/lib/ali-table/pipeline/features/columnCustom.d.ts +1 -0
- package/lib/ali-table/pipeline/features/columnCustom.js +144 -12
- package/lib/ali-table/utils/utility.d.ts +11 -0
- package/lib/ali-table/utils/utility.js +55 -3
- package/lib/table-component/table/Grid.js +12 -1
- package/package.json +2 -2
|
@@ -20,7 +20,7 @@ var _EditCell = _interopRequireDefault(require("../../base-table/cell/EditCell")
|
|
|
20
20
|
var _HeaderEditCell = _interopRequireDefault(require("../../base-table/cell/HeaderEditCell"));
|
|
21
21
|
var _constants = require("../../utils/constants");
|
|
22
22
|
var _utils3 = require("../../base-table/utils");
|
|
23
|
-
|
|
23
|
+
// import { unFlattenData } from '../../utils/utility';
|
|
24
24
|
// import { getMaxDepth } from '../../utils/utility';
|
|
25
25
|
|
|
26
26
|
function clamp(min, x, max) {
|
|
@@ -47,6 +47,7 @@ function columnCustom(opts) {
|
|
|
47
47
|
wrapSettings,
|
|
48
48
|
// ignoreAccents,
|
|
49
49
|
dataSource,
|
|
50
|
+
dataFlatten,
|
|
50
51
|
isDataTree,
|
|
51
52
|
defaultSorter,
|
|
52
53
|
defaultFilter,
|
|
@@ -437,7 +438,7 @@ function columnCustom(opts) {
|
|
|
437
438
|
}
|
|
438
439
|
|
|
439
440
|
// Cập nhật data mới
|
|
440
|
-
const newData =
|
|
441
|
+
const newData = dataFlatten;
|
|
441
442
|
const pastedRows = [];
|
|
442
443
|
if (pasteState.type === 'down' || pasteState.type === 'up') {
|
|
443
444
|
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
@@ -505,8 +506,8 @@ function columnCustom(opts) {
|
|
|
505
506
|
}
|
|
506
507
|
|
|
507
508
|
// const rsFilterData = updateOrInsert(dataSource, newData)
|
|
508
|
-
const rsFilterData = (0,
|
|
509
|
-
const rs = (0,
|
|
509
|
+
const rsFilterData = (0, _utils2.updateOrInsert)(dataFlatten, newData);
|
|
510
|
+
const rs = (0, _utils2.unFlattenData)(rsFilterData);
|
|
510
511
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
511
512
|
pipeline.setStateAtKey(_constants.stateKeyEndCell, endPasteCell);
|
|
512
513
|
pipeline.setStateAtKey(_constants.stateKeyEndPasteCell, undefined);
|
|
@@ -532,7 +533,7 @@ function columnCustom(opts) {
|
|
|
532
533
|
const newRange = ctrlKey ? (0, _utils2.addRowsDownWithCtrl)(dataSelected, rowsPasteId.length) : (0, _utils2.addRowsDown)(dataSelected, rowsPasteId.length);
|
|
533
534
|
|
|
534
535
|
// Cập nhật data mới
|
|
535
|
-
const newData =
|
|
536
|
+
const newData = dataFlatten;
|
|
536
537
|
const pastedRows = [];
|
|
537
538
|
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
538
539
|
const targetRow = pasteState?.startRowIndex + rowIndex1;
|
|
@@ -554,8 +555,8 @@ function columnCustom(opts) {
|
|
|
554
555
|
});
|
|
555
556
|
|
|
556
557
|
// const rsFilterData = updateOrInsert(dataSource, newData)
|
|
557
|
-
const rsFilterData = (0,
|
|
558
|
-
const rs = (0,
|
|
558
|
+
const rsFilterData = (0, _utils2.updateOrInsert)(dataFlatten, newData);
|
|
559
|
+
const rs = (0, _utils2.unFlattenData)(rsFilterData);
|
|
559
560
|
triggerPaste?.(pastedRows, colsPastedId, rs, copyRows);
|
|
560
561
|
};
|
|
561
562
|
const handleMouseDown = (rowId, colId) => {
|
|
@@ -867,7 +868,7 @@ function columnCustom(opts) {
|
|
|
867
868
|
}
|
|
868
869
|
return updatedRow;
|
|
869
870
|
});
|
|
870
|
-
const newData = (0,
|
|
871
|
+
const newData = (0, _utils2.unFlattenData)(rs);
|
|
871
872
|
triggerChangeData?.([...newData], {
|
|
872
873
|
type: 'DELETE_CONTENT'
|
|
873
874
|
});
|
|
@@ -1058,6 +1059,73 @@ function columnCustom(opts) {
|
|
|
1058
1059
|
pipeline.setStateAtKey(_constants.stateKeyEndCell, cellEnd);
|
|
1059
1060
|
triggerPointPaste(selectPasteState, cellStart, cellEnd, e.ctrlKey);
|
|
1060
1061
|
};
|
|
1062
|
+
|
|
1063
|
+
// cell Số thứ tự
|
|
1064
|
+
|
|
1065
|
+
const handleMouseDownIndex = rowId => {
|
|
1066
|
+
// setIsSelecting?.(true);
|
|
1067
|
+
pipeline.setStateAtKey(_constants.stateKeyIsSelecting, true);
|
|
1068
|
+
const allColumns = allCols.filter(it => !_hooks.nonActionColumn.includes(it.field));
|
|
1069
|
+
|
|
1070
|
+
// const firstCOlSpin = findFirst(allColumns)
|
|
1071
|
+
|
|
1072
|
+
const startCol = allColumns[0].field;
|
|
1073
|
+
const endCol = allColumns[allColumns.length - 1].field;
|
|
1074
|
+
|
|
1075
|
+
// setStartCell?.({ rowId, colId: startCol });
|
|
1076
|
+
// setEndCell?.({ rowId, colId: endCol });
|
|
1077
|
+
|
|
1078
|
+
pipeline.setStateAtKey(_constants.stateKeyStartCell, {
|
|
1079
|
+
rowId,
|
|
1080
|
+
colId: startCol
|
|
1081
|
+
});
|
|
1082
|
+
pipeline.setStateAtKey(_constants.stateKeyEndCell, {
|
|
1083
|
+
rowId,
|
|
1084
|
+
colId: endCol
|
|
1085
|
+
});
|
|
1086
|
+
|
|
1087
|
+
// if (firstCOlSpin) {
|
|
1088
|
+
// setFocusedCell?.({ rowId: cell.row.id, colId: firstCOlSpin.id })
|
|
1089
|
+
// } else {
|
|
1090
|
+
// const firstCOlVisible = allColumns[0]
|
|
1091
|
+
// setFocusedCell?.({ rowId: cell.row.id, colId: firstCOlVisible.id })
|
|
1092
|
+
// }
|
|
1093
|
+
pipeline.setStateAtKey(_constants.stateKeyFocusedCell, {
|
|
1094
|
+
rowId,
|
|
1095
|
+
colId: startCol
|
|
1096
|
+
});
|
|
1097
|
+
|
|
1098
|
+
// setRangeState?.(getSelectedCellMatrix(table, { rowId, colId: startCol }, { rowId, colId: endCol }))
|
|
1099
|
+
};
|
|
1100
|
+
const handleMouseEnterIndex = rowId => {
|
|
1101
|
+
if (isSelecting) {
|
|
1102
|
+
const allColumns = allCols.filter(it => !_hooks.nonActionColumn.includes(it.field));
|
|
1103
|
+
|
|
1104
|
+
// const firstCOl = findFirst(allColumns)
|
|
1105
|
+
|
|
1106
|
+
// const startCol = allColumns[0].id
|
|
1107
|
+
const endCol = allColumns[allColumns.length - 1].field;
|
|
1108
|
+
|
|
1109
|
+
// // setStartCell?.({ rowId, colId: startCol });
|
|
1110
|
+
// setEndCell?.({ rowId, colId: endCol });
|
|
1111
|
+
pipeline.setStateAtKey(_constants.stateKeyEndCell, {
|
|
1112
|
+
rowId,
|
|
1113
|
+
colId: endCol
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
const handleMouseUpIndex = () => {
|
|
1118
|
+
// setIsSelecting?.(false);
|
|
1119
|
+
|
|
1120
|
+
pipeline.setStateAtKey(_constants.stateKeyIsSelecting, false);
|
|
1121
|
+
|
|
1122
|
+
// const selectState = getSelectedCellMatrix(table, startCell, endCell)
|
|
1123
|
+
|
|
1124
|
+
// if (!isObjEqual(rangeState, selectState)) {
|
|
1125
|
+
|
|
1126
|
+
// setRangeState?.(selectState)
|
|
1127
|
+
// }
|
|
1128
|
+
};
|
|
1061
1129
|
pipeline.mapColumns((0, _utils.makeRecursiveMapper)((col, params) => {
|
|
1062
1130
|
const {
|
|
1063
1131
|
startIndex,
|
|
@@ -1210,6 +1278,7 @@ function columnCustom(opts) {
|
|
|
1210
1278
|
// cell Index
|
|
1211
1279
|
if (col.field === '#') {
|
|
1212
1280
|
const prevContent = col.template;
|
|
1281
|
+
const prevGetCellProps = col?.getCellProps;
|
|
1213
1282
|
return {
|
|
1214
1283
|
...col,
|
|
1215
1284
|
lock: !!col.fixed,
|
|
@@ -1244,7 +1313,73 @@ function columnCustom(opts) {
|
|
|
1244
1313
|
overflow: 'visible',
|
|
1245
1314
|
position: 'relative'
|
|
1246
1315
|
}
|
|
1247
|
-
})
|
|
1316
|
+
}),
|
|
1317
|
+
getCellProps(value, record, rowIndex) {
|
|
1318
|
+
const prevCellProps = prevGetCellProps?.(value, record, rowIndex);
|
|
1319
|
+
|
|
1320
|
+
// const isCellSelected = (!startCell || !endCell) ? false : selectRowIds.includes(record.rowId) && cols.includes(col.field);
|
|
1321
|
+
|
|
1322
|
+
return (0, _utils.mergeCellProps)(prevCellProps, {
|
|
1323
|
+
// @ts-ignore
|
|
1324
|
+
'data-col-key': col.field,
|
|
1325
|
+
ref: el => {
|
|
1326
|
+
if (focusedCell?.rowId === record.rowId && focusedCell?.colId === col.field && !isEditing.editing) {
|
|
1327
|
+
el?.focus({
|
|
1328
|
+
preventScroll: true
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
},
|
|
1332
|
+
style: {
|
|
1333
|
+
...prevCellProps?.style,
|
|
1334
|
+
userSelect: 'none'
|
|
1335
|
+
// padding: cellEditing ? 0 : undefined
|
|
1336
|
+
// ...cellStyles,
|
|
1337
|
+
},
|
|
1338
|
+
className: (0, _classnames.default)(prevCellProps?.className, `${prefix}-grid-cell`, {
|
|
1339
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
|
|
1340
|
+
[`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
|
|
1341
|
+
[`${prefix}-grid-cell-text-center`]: col?.textAlign === 'center',
|
|
1342
|
+
[`${prefix}-grid-cell-text-right`]: col?.textAlign === 'right' || col.type === 'number',
|
|
1343
|
+
[`${prefix}-grid-cell-index-selected`]: selectRowIds?.includes(record.rowId),
|
|
1344
|
+
'no-hover': editAble
|
|
1345
|
+
|
|
1346
|
+
// isValid: !isEditing && rowError && rowError[col.field]?.field === col.field,
|
|
1347
|
+
// [`${prefix}-grid-cell-selected`]: isCellSelected,
|
|
1348
|
+
}),
|
|
1349
|
+
onMouseDown: e => {
|
|
1350
|
+
prevCellProps?.onMouseDown?.(e);
|
|
1351
|
+
if (editAble) {
|
|
1352
|
+
// if (record[rowKey] === editingKey) {
|
|
1353
|
+
if (isEditing.editing) {
|
|
1354
|
+
// setFocusedCell?.({ rowId: cell.row.id, colId: cell.column.id })
|
|
1355
|
+
} else {
|
|
1356
|
+
handleMouseDownIndex(record.rowId);
|
|
1357
|
+
if (isEditing.editing) {
|
|
1358
|
+
setTimeout(() => {
|
|
1359
|
+
// setEditingKey?.('')
|
|
1360
|
+
pipeline.setStateAtKey(_constants.stateKeyIsEditing, defaultCellEditing);
|
|
1361
|
+
reset?.();
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
},
|
|
1367
|
+
onMouseEnter: e => {
|
|
1368
|
+
prevCellProps?.onMouseEnter?.(e);
|
|
1369
|
+
// Edit
|
|
1370
|
+
|
|
1371
|
+
if (editAble) {
|
|
1372
|
+
handleMouseEnterIndex(record.rowId);
|
|
1373
|
+
}
|
|
1374
|
+
},
|
|
1375
|
+
onMouseUp: e => {
|
|
1376
|
+
prevCellProps?.onMouseUp?.(e);
|
|
1377
|
+
if (editAble) {
|
|
1378
|
+
handleMouseUpIndex();
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1248
1383
|
};
|
|
1249
1384
|
}
|
|
1250
1385
|
|
|
@@ -1511,9 +1646,6 @@ function columnCustom(opts) {
|
|
|
1511
1646
|
}),
|
|
1512
1647
|
getCellProps(value, record, rowIndex) {
|
|
1513
1648
|
const prevCellProps = prevGetCellProps?.(value, record, rowIndex);
|
|
1514
|
-
|
|
1515
|
-
// console.log('record', record)
|
|
1516
|
-
|
|
1517
1649
|
const fomatedValue = ['color', 'checkbox', 'field'].includes(col.type ?? '') ? '' : (0, _useColumns.renderValueCell)(col, value, record, rowIndex, 0, format, false);
|
|
1518
1650
|
const tooltipContent = isOpenTooltip === false ? '' : col?.tooltipDescription ? typeof col.tooltipDescription === 'function' ? col.tooltipDescription({
|
|
1519
1651
|
value,
|
|
@@ -25,4 +25,15 @@ export declare function filterVisibleColumns<T extends ColumnTable>(columns: T[]
|
|
|
25
25
|
export declare const sortByType: (arr: ColumnTable[], rowDnd?: RowDnd) => ColumnTable[];
|
|
26
26
|
export declare function getVisibleColumnFields<T extends ColumnTable>(columns: T[]): string[];
|
|
27
27
|
export declare const getOnlyInA: (a: string[], b: string[]) => string[];
|
|
28
|
+
export declare const buildParentMap: <T extends {
|
|
29
|
+
id: string;
|
|
30
|
+
rowId: string;
|
|
31
|
+
children?: T[];
|
|
32
|
+
}>(tree: T[]) => Map<string, T>;
|
|
33
|
+
export declare const flattenTree: <T extends {
|
|
34
|
+
children?: T[];
|
|
35
|
+
}>(tree: T[]) => T[];
|
|
36
|
+
export declare const flattenTree2: <T extends {
|
|
37
|
+
children?: T[];
|
|
38
|
+
}>(tree: T[]) => Omit<T, 'children'>[];
|
|
28
39
|
export {};
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.addRowIdArray = void 0;
|
|
6
|
+
exports.buildParentMap = exports.addRowIdArray = void 0;
|
|
7
7
|
exports.filterDataByColumns1 = filterDataByColumns1;
|
|
8
8
|
exports.filterVisibleColumns = filterVisibleColumns;
|
|
9
|
-
exports.getOnlyInA = exports.getMaxDepth = exports.flattenArray = void 0;
|
|
9
|
+
exports.getOnlyInA = exports.getMaxDepth = exports.flattenTree2 = exports.flattenTree = exports.flattenArray = void 0;
|
|
10
10
|
exports.getVisibleColumnFields = getVisibleColumnFields;
|
|
11
11
|
exports.sortByType = exports.shouldIncludeOptimized = void 0;
|
|
12
12
|
exports.sortData = sortData;
|
|
@@ -723,4 +723,56 @@ const getOnlyInA = (a, b) => {
|
|
|
723
723
|
const setB = new Set(b);
|
|
724
724
|
return a.filter(item => !setB.has(item));
|
|
725
725
|
};
|
|
726
|
-
exports.getOnlyInA = getOnlyInA;
|
|
726
|
+
exports.getOnlyInA = getOnlyInA;
|
|
727
|
+
const buildParentMap = tree => {
|
|
728
|
+
const parentMap = new Map();
|
|
729
|
+
const stack = [...tree];
|
|
730
|
+
while (stack.length) {
|
|
731
|
+
const node = stack.pop();
|
|
732
|
+
const children = node.children;
|
|
733
|
+
if (!children?.length) continue;
|
|
734
|
+
for (let i = 0; i < children.length; i++) {
|
|
735
|
+
const child = children[i];
|
|
736
|
+
parentMap.set(child.rowId, node);
|
|
737
|
+
stack.push(child);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return parentMap;
|
|
741
|
+
};
|
|
742
|
+
exports.buildParentMap = buildParentMap;
|
|
743
|
+
const flattenTree = tree => {
|
|
744
|
+
const result = [];
|
|
745
|
+
const stack = [...tree];
|
|
746
|
+
while (stack.length) {
|
|
747
|
+
const node = stack.pop();
|
|
748
|
+
result.push(node);
|
|
749
|
+
const children = node.children;
|
|
750
|
+
if (children?.length) {
|
|
751
|
+
// Push ngược để giữ nguyên thứ tự tree
|
|
752
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
753
|
+
stack.push(children[i]);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
return result;
|
|
758
|
+
};
|
|
759
|
+
exports.flattenTree = flattenTree;
|
|
760
|
+
const flattenTree2 = tree => {
|
|
761
|
+
const result = [];
|
|
762
|
+
const stack = [...tree];
|
|
763
|
+
while (stack.length) {
|
|
764
|
+
const node = stack.pop();
|
|
765
|
+
const {
|
|
766
|
+
children,
|
|
767
|
+
...item
|
|
768
|
+
} = node;
|
|
769
|
+
result.push(item);
|
|
770
|
+
if (children?.length) {
|
|
771
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
772
|
+
stack.push(children[i]);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
return result;
|
|
777
|
+
};
|
|
778
|
+
exports.flattenTree2 = flattenTree2;
|
|
@@ -175,12 +175,17 @@ const Grid = props => {
|
|
|
175
175
|
// debugTable: true
|
|
176
176
|
});
|
|
177
177
|
_react.default.useEffect(() => {
|
|
178
|
+
setIsSelectionChange(prev => ({
|
|
179
|
+
...prev,
|
|
180
|
+
isChange: false
|
|
181
|
+
}));
|
|
178
182
|
if (!isSelectionChange.isChange) {
|
|
179
183
|
if (mergedSelectedKeys.length === 0) {
|
|
180
184
|
setIsSelectionChange(prev => ({
|
|
181
185
|
...prev,
|
|
182
186
|
rowsData: []
|
|
183
187
|
}));
|
|
188
|
+
setRowSelection((0, _utils.convertToObjTrue)(mergedSelectedKeys));
|
|
184
189
|
} else {
|
|
185
190
|
const abc = (0, _utils.flattenArray)(dataSource);
|
|
186
191
|
const selectedKeySet = new Set(mergedSelectedKeys);
|
|
@@ -191,8 +196,14 @@ const Grid = props => {
|
|
|
191
196
|
rowsData: result
|
|
192
197
|
}));
|
|
193
198
|
}
|
|
199
|
+
} else {
|
|
200
|
+
if (mergedSelectedKeys.length === 0) {
|
|
201
|
+
setRowSelection((0, _utils.convertToObjTrue)(mergedSelectedKeys));
|
|
202
|
+
}
|
|
194
203
|
}
|
|
195
|
-
}, [mergedSelectedKeys, dataSource]);
|
|
204
|
+
}, [mergedSelectedKeys, dataSource, isSelectionChange.isChange]);
|
|
205
|
+
// }, [mergedSelectedKeys, dataSource])
|
|
206
|
+
|
|
196
207
|
_react.default.useEffect(() => {
|
|
197
208
|
if (defaultFilter) {
|
|
198
209
|
const a = (0, _utils.revertConvertFilters)(defaultFilter);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-grid-template",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.75",
|
|
4
4
|
"description": "es-grid-template",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"rc-checkbox": "3.5.0",
|
|
67
67
|
"rc-dropdown": "4.2.1",
|
|
68
68
|
"rc-field-form": "2.6.0",
|
|
69
|
-
"rc-master-ui": "1.1.
|
|
69
|
+
"rc-master-ui": "1.1.64",
|
|
70
70
|
"rc-select": "14.16.3",
|
|
71
71
|
"rc-tooltip": "6.3.0",
|
|
72
72
|
"rc-tree": "5.10.1",
|