es-grid-template 1.9.72 → 1.9.74
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 +52 -0
- package/es/grid-component/hooks/constant.js +4 -0
- package/es/group-component/hook/useColumns.js +2 -2
- package/es/group-component/hook/utils.js +3 -0
- package/es/table-component/ColumnsConfig.js +6 -4
- package/es/table-component/TableContainer.js +1 -0
- package/es/table-component/TableContainerEdit.js +1 -0
- package/es/table-component/hook/utils.js +3 -0
- package/es/table-component/table/Grid.js +2 -2
- package/es/table-component/table/TableWrapper.js +97 -33
- package/es/table-virtuoso/hook/utils.js +3 -0
- 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 +58 -3
- package/lib/grid-component/hooks/constant.js +4 -0
- package/lib/group-component/hook/useColumns.js +2 -2
- package/lib/group-component/hook/utils.js +3 -0
- package/lib/table-component/ColumnsConfig.js +6 -4
- package/lib/table-component/TableContainer.js +1 -0
- package/lib/table-component/TableContainerEdit.js +1 -0
- package/lib/table-component/hook/utils.js +3 -0
- package/lib/table-component/table/Grid.js +2 -2
- package/lib/table-component/table/TableWrapper.js +97 -33
- package/lib/table-virtuoso/hook/utils.js +3 -0
- 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;
|
|
@@ -111,6 +111,9 @@ const shouldIncludeOptimized = (item, queries, ignoreAccents = true) => {
|
|
|
111
111
|
case 'contains':
|
|
112
112
|
condition = ignoreAccents === false ? itemValue?.includes(value) : itemStr.includes(compareValue);
|
|
113
113
|
break;
|
|
114
|
+
case 'notcontains':
|
|
115
|
+
condition = ignoreAccents === false ? !itemValue?.includes(value) : !itemStr.includes(compareValue);
|
|
116
|
+
break;
|
|
114
117
|
case 'startswith':
|
|
115
118
|
condition = ignoreAccents === false ? itemValue?.startsWith(value) : itemStr.startsWith(compareValue);
|
|
116
119
|
break;
|
|
@@ -720,4 +723,56 @@ const getOnlyInA = (a, b) => {
|
|
|
720
723
|
const setB = new Set(b);
|
|
721
724
|
return a.filter(item => !setB.has(item));
|
|
722
725
|
};
|
|
723
|
-
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;
|
|
@@ -215,12 +215,12 @@ const toggleRowSelection = props => {
|
|
|
215
215
|
} else {
|
|
216
216
|
// chưa selected
|
|
217
217
|
|
|
218
|
-
const checkedRows = [...prevSelected, row];
|
|
218
|
+
const checkedRows = [...prevSelected, row.original];
|
|
219
219
|
setIsSelectionChange({
|
|
220
220
|
isChange: true,
|
|
221
221
|
type: 'rowSelected',
|
|
222
222
|
rowData: row.original,
|
|
223
|
-
rowsData: selectionSettings?.type === 'single' ? [row] : checkedRows
|
|
223
|
+
rowsData: selectionSettings?.type === 'single' ? [row.original] : checkedRows
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
return;
|
|
@@ -893,6 +893,9 @@ const shouldInclude = (item, queries) => {
|
|
|
893
893
|
case "contains":
|
|
894
894
|
condition = itemStr?.includes(queryStr);
|
|
895
895
|
break;
|
|
896
|
+
case "notcontains":
|
|
897
|
+
condition = !itemStr?.includes(queryStr);
|
|
898
|
+
break;
|
|
896
899
|
case "startswith":
|
|
897
900
|
condition = itemStr?.startsWith(queryStr);
|
|
898
901
|
break;
|
|
@@ -69,6 +69,7 @@ const ColumnsConfig = props => {
|
|
|
69
69
|
};
|
|
70
70
|
const handleAccept = () => {
|
|
71
71
|
triggerChangeColumns?.(tmpColumn, [], 'columnChoose');
|
|
72
|
+
setCurrentRow('');
|
|
72
73
|
onClose();
|
|
73
74
|
};
|
|
74
75
|
const handleChange = newElemt => {
|
|
@@ -118,10 +119,11 @@ const ColumnsConfig = props => {
|
|
|
118
119
|
return /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Input, {
|
|
119
120
|
defaultValue: value,
|
|
120
121
|
allowClear: true,
|
|
122
|
+
autoFocus: true,
|
|
121
123
|
onBlur: e => {
|
|
122
124
|
const newData = {
|
|
123
125
|
...rowData,
|
|
124
|
-
|
|
126
|
+
headerText: e.target.value
|
|
125
127
|
};
|
|
126
128
|
handleChange(newData);
|
|
127
129
|
}
|
|
@@ -218,7 +220,7 @@ const ColumnsConfig = props => {
|
|
|
218
220
|
} = args;
|
|
219
221
|
if (currentRow === rowData.field) {
|
|
220
222
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.InputNumber, {
|
|
221
|
-
defaultValue: value,
|
|
223
|
+
defaultValue: value ?? 150,
|
|
222
224
|
style: {
|
|
223
225
|
width: '100%'
|
|
224
226
|
},
|
|
@@ -226,13 +228,13 @@ const ColumnsConfig = props => {
|
|
|
226
228
|
onBlur: e => {
|
|
227
229
|
const newData = {
|
|
228
230
|
...rowData,
|
|
229
|
-
|
|
231
|
+
width: e.target.value ? Number(e.target.value) : 150
|
|
230
232
|
};
|
|
231
233
|
handleChange(newData);
|
|
232
234
|
}
|
|
233
235
|
});
|
|
234
236
|
}
|
|
235
|
-
return /*#__PURE__*/_react.default.createElement("span", null, value);
|
|
237
|
+
return /*#__PURE__*/_react.default.createElement("span", null, value ?? 150, "px");
|
|
236
238
|
}
|
|
237
239
|
}];
|
|
238
240
|
const handleReset = () => {
|
|
@@ -1183,6 +1183,9 @@ const shouldInclude = (item, queries, ignoreAccents) => {
|
|
|
1183
1183
|
case "contains":
|
|
1184
1184
|
condition = ignoreAccents === false ? itemValue?.includes(value) : itemStr?.includes(queryStr);
|
|
1185
1185
|
break;
|
|
1186
|
+
case "notcontains":
|
|
1187
|
+
condition = ignoreAccents === false ? !itemValue?.includes(value) : !itemStr?.includes(queryStr);
|
|
1188
|
+
break;
|
|
1186
1189
|
case "startswith":
|
|
1187
1190
|
condition = ignoreAccents === false ? itemValue?.startsWith(value) : itemStr?.startsWith(queryStr);
|
|
1188
1191
|
break;
|
|
@@ -69,8 +69,8 @@ const Grid = props => {
|
|
|
69
69
|
const [columnResizeMode] = _react.default.useState('onChange');
|
|
70
70
|
const [columnResizeDirection] = _react.default.useState('ltr');
|
|
71
71
|
const [paginationState, setPagination] = _react.default.useState({
|
|
72
|
-
pageIndex: pagination && pagination
|
|
73
|
-
pageSize: pagination && pagination
|
|
72
|
+
pageIndex: pagination && pagination?.currentPage ? pagination.currentPage - 1 : 0,
|
|
73
|
+
pageSize: pagination && pagination?.pageSize ? pagination.pageSize : 20
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
// const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({})
|
|
@@ -14,7 +14,6 @@ var _reactTooltip = require("react-tooltip");
|
|
|
14
14
|
var _ContextMenu = _interopRequireDefault(require("../ContextMenu"));
|
|
15
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
16
|
var _useContext = require("../useContext");
|
|
17
|
-
var _utils = require("../hook/utils");
|
|
18
17
|
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); }
|
|
19
18
|
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; }
|
|
20
19
|
const TableWrapper = props => {
|
|
@@ -49,6 +48,12 @@ const TableWrapper = props => {
|
|
|
49
48
|
const menuRef = _react.default.useRef(null);
|
|
50
49
|
const loadingRef = _react.default.useRef(false);
|
|
51
50
|
const hasMoreRef = _react.default.useRef(true);
|
|
51
|
+
const pendingPageRef = _react.default.useRef(null);
|
|
52
|
+
const pendingDataLengthRef = _react.default.useRef(0);
|
|
53
|
+
const sawLoadingRef = _react.default.useRef(false);
|
|
54
|
+
const lastScrollTopRef = _react.default.useRef(0);
|
|
55
|
+
// const directionRef = React.useRef<'up' | 'down' | null>(null);
|
|
56
|
+
|
|
52
57
|
const {
|
|
53
58
|
windowSize
|
|
54
59
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
@@ -57,6 +62,23 @@ const TableWrapper = props => {
|
|
|
57
62
|
pageSize,
|
|
58
63
|
total
|
|
59
64
|
} = pagination ?? {};
|
|
65
|
+
_react.default.useEffect(() => {
|
|
66
|
+
if (pendingPageRef.current === null) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (loading) {
|
|
70
|
+
sawLoadingRef.current = true;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const pageLoaded = currentPage >= pendingPageRef.current;
|
|
74
|
+
const dataLoaded = dataSource.length !== pendingDataLengthRef.current;
|
|
75
|
+
const requestFinished = sawLoadingRef.current;
|
|
76
|
+
if (pageLoaded || dataLoaded || requestFinished) {
|
|
77
|
+
loadingRef.current = false;
|
|
78
|
+
pendingPageRef.current = null;
|
|
79
|
+
sawLoadingRef.current = false;
|
|
80
|
+
}
|
|
81
|
+
}, [currentPage, dataSource.length, loading]);
|
|
60
82
|
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
61
83
|
const [selectedRowData, setSelectedRowData] = _react.default.useState(undefined);
|
|
62
84
|
const [position, setPosition] = _react.default.useState({
|
|
@@ -83,46 +105,88 @@ const TableWrapper = props => {
|
|
|
83
105
|
const loadData = page => {
|
|
84
106
|
if (!hasMoreRef.current || loadingRef.current || loading) return;
|
|
85
107
|
loadingRef.current = true;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}, 10);
|
|
108
|
+
pendingPageRef.current = page;
|
|
109
|
+
pendingDataLengthRef.current = dataSource.length;
|
|
110
|
+
next?.();
|
|
111
|
+
if (pageSize && total && page * pageSize >= total) {
|
|
112
|
+
hasMoreRef.current = false;
|
|
113
|
+
}
|
|
93
114
|
};
|
|
94
115
|
const handleNext = () => {
|
|
95
116
|
loadData(currentPage + 1);
|
|
96
117
|
};
|
|
97
118
|
const handleScroll = e => {
|
|
98
|
-
if (infiniteScroll) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
e.preventDefault();
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const {
|
|
105
|
-
scrollHeight: tbScrollHeight,
|
|
106
|
-
scrollTop,
|
|
107
|
-
clientHeight
|
|
108
|
-
} = e.currentTarget;
|
|
109
|
-
const abc = clientHeight * ((0, _utils.isNullOrUndefined)(onEndReachedThreshold) ? 0.1 : onEndReachedThreshold ?? 0);
|
|
119
|
+
// if (infiniteScroll) {
|
|
120
|
+
// const current = e.currentTarget.scrollTop;
|
|
121
|
+
// const last = lastScrollTopRef.current;
|
|
110
122
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
// if (loadingRef.current || loading || dataSource?.length === 0 || current === last) {
|
|
124
|
+
|
|
125
|
+
// e.stopPropagation()
|
|
126
|
+
// e.preventDefault()
|
|
127
|
+
// return
|
|
128
|
+
// }
|
|
129
|
+
|
|
130
|
+
// const { scrollHeight: tbScrollHeight, scrollTop, clientHeight } = e.currentTarget;
|
|
131
|
+
|
|
132
|
+
// const abc = clientHeight * (isNullOrUndefined(onEndReachedThreshold) ? 0.1 : onEndReachedThreshold ?? 0)
|
|
133
|
+
|
|
134
|
+
// // const isEnd = scrollTop + clientHeight >= tbScrollHeight - 50;
|
|
135
|
+
// const isEnd = scrollTop + clientHeight >= tbScrollHeight - abc;
|
|
136
|
+
|
|
137
|
+
// if (isEnd && !loadingRef.current && hasMoreRef.current && dataSource?.length > 0) {
|
|
138
|
+
|
|
139
|
+
// handleNext()
|
|
140
|
+
|
|
141
|
+
// }
|
|
142
|
+
// }
|
|
143
|
+
|
|
144
|
+
// if (e.target.scrollLeft >= 0 && e.target.scrollLeft + e.target.clientWidth < e.target.scrollWidth) {
|
|
145
|
+
// e.target.classList.add('ui-rc-table-ping-right')
|
|
146
|
+
// } else {
|
|
147
|
+
// e.target.classList.remove('ui-rc-table-ping-right')
|
|
148
|
+
// }
|
|
149
|
+
|
|
150
|
+
// if ((e.target.scrollLeft ?? 0) > 0) {
|
|
151
|
+
// e.target.classList.add('ui-rc-table-ping-left')
|
|
152
|
+
// } else {
|
|
153
|
+
// e.target.classList.remove('ui-rc-table-ping-left')
|
|
154
|
+
// }
|
|
155
|
+
|
|
156
|
+
const target = e.currentTarget;
|
|
157
|
+
|
|
158
|
+
// Horizontal scroll
|
|
159
|
+
const {
|
|
160
|
+
scrollLeft,
|
|
161
|
+
clientWidth,
|
|
162
|
+
scrollWidth,
|
|
163
|
+
clientHeight
|
|
164
|
+
} = target;
|
|
165
|
+
target.classList.toggle('ui-rc-table-ping-left', scrollLeft > 0);
|
|
166
|
+
target.classList.toggle('ui-rc-table-ping-right', scrollLeft + clientWidth < scrollWidth);
|
|
167
|
+
if (!infiniteScroll) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const {
|
|
171
|
+
scrollTop,
|
|
172
|
+
scrollHeight
|
|
173
|
+
} = target;
|
|
174
|
+
const last = lastScrollTopRef.current;
|
|
175
|
+
|
|
176
|
+
// Update ngay
|
|
177
|
+
lastScrollTopRef.current = scrollTop;
|
|
178
|
+
|
|
179
|
+
// Chỉ xử lý khi scroll DOWN
|
|
180
|
+
if (scrollTop <= last) {
|
|
181
|
+
return;
|
|
116
182
|
}
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
} else {
|
|
120
|
-
e.target.classList.remove('ui-rc-table-ping-right');
|
|
183
|
+
if (loadingRef.current || loading || !dataSource?.length || !hasMoreRef.current) {
|
|
184
|
+
return;
|
|
121
185
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
186
|
+
const thresholdRatio = onEndReachedThreshold ?? 0.1;
|
|
187
|
+
const threshold = clientHeight * thresholdRatio;
|
|
188
|
+
if (scrollTop + clientHeight >= scrollHeight - threshold) {
|
|
189
|
+
handleNext();
|
|
126
190
|
}
|
|
127
191
|
};
|
|
128
192
|
const onContextMenu = args => event => {
|
|
@@ -948,6 +948,9 @@ const shouldInclude = (item, queries) => {
|
|
|
948
948
|
case "contains":
|
|
949
949
|
condition = itemStr?.includes(queryStr);
|
|
950
950
|
break;
|
|
951
|
+
case "notcontains":
|
|
952
|
+
condition = !itemStr?.includes(queryStr);
|
|
953
|
+
break;
|
|
951
954
|
case "startswith":
|
|
952
955
|
condition = itemStr?.startsWith(queryStr);
|
|
953
956
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-grid-template",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.74",
|
|
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",
|