es-grid-template 1.7.39 → 1.7.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/grid-component/hooks/utils.d.ts +1 -0
- package/es/grid-component/hooks/utils.js +11 -0
- package/es/table-component/InternalTable.js +24 -9
- package/es/table-component/hook/utils.d.ts +1 -0
- package/es/table-component/hook/utils.js +24 -5
- package/es/table-component/table/Grid.js +7 -4
- package/lib/grid-component/hooks/utils.d.ts +1 -0
- package/lib/grid-component/hooks/utils.js +14 -2
- package/lib/table-component/InternalTable.js +22 -7
- package/lib/table-component/hook/utils.d.ts +1 -0
- package/lib/table-component/hook/utils.js +25 -5
- package/lib/table-component/table/Grid.js +7 -4
- package/package.json +1 -1
|
@@ -57,6 +57,7 @@ export declare const updateData: <Record_1 = AnyObject>(initData: Record_1[], ro
|
|
|
57
57
|
export declare const parseBooleanToValue: (value: boolean, type: 'boolean' | 'number') => number | boolean;
|
|
58
58
|
export declare const genPresets: (presets?: import("@ant-design/colors").PalettesProps) => import("antd/es/color-picker/interface").PresetsItem[];
|
|
59
59
|
export declare function findAllChildrenKeys<RecordType>(data: readonly RecordType[], getRowKey: GetRowKey<RecordType>, childrenColumnName: string): Key[];
|
|
60
|
+
export declare function findAllChildrenKeys2<RecordType>(data: readonly RecordType[], rowKey: any, childrenColumnName: string): Key[];
|
|
60
61
|
export declare const flattenArray: <RecordType extends AnyObject = AnyObject>(arr: any[]) => RecordType[];
|
|
61
62
|
export declare const flattenData: <RecordType extends AnyObject = AnyObject>(childrenColumnName: string, data?: RecordType[]) => RecordType[];
|
|
62
63
|
export declare const unFlattenData: <RecordType extends AnyObject = AnyObject>(data: RecordType[]) => RecordType[];
|
|
@@ -447,6 +447,17 @@ export function findAllChildrenKeys(data, getRowKey, childrenColumnName) {
|
|
|
447
447
|
dig(data);
|
|
448
448
|
return keys;
|
|
449
449
|
}
|
|
450
|
+
export function findAllChildrenKeys2(data, rowKey, childrenColumnName) {
|
|
451
|
+
const keys = [];
|
|
452
|
+
function dig(list) {
|
|
453
|
+
(list || []).forEach(item => {
|
|
454
|
+
keys.push(item[rowKey]);
|
|
455
|
+
dig(item[childrenColumnName]);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
dig(data);
|
|
459
|
+
return keys;
|
|
460
|
+
}
|
|
450
461
|
export const flattenArray = arr => {
|
|
451
462
|
if (!arr) {
|
|
452
463
|
return [];
|
|
@@ -29,15 +29,16 @@ import Grid from "./table/Grid";
|
|
|
29
29
|
|
|
30
30
|
// import { Tooltip } from 'react-tooltip'
|
|
31
31
|
// import ContextMenu from './ContextMenu'
|
|
32
|
-
import { addRowIdArray, convertToObj,
|
|
32
|
+
import { addRowIdArray, convertToObj, convertToObjTrue,
|
|
33
33
|
// convertFilters,
|
|
34
34
|
filterDataByColumns, flatColumns2,
|
|
35
35
|
// filterDataByColumns,
|
|
36
|
-
getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayByColumns,
|
|
36
|
+
getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayByColumns, isTreeArray } from "./hook/utils";
|
|
37
37
|
// import GridEdit from './table/GridEdit'
|
|
38
38
|
import { convertToTanStackColumns } from "./hook/useColumns";
|
|
39
39
|
import { convertColumns } from "./hook/convert";
|
|
40
40
|
import { Modal } from 'antd';
|
|
41
|
+
import { findAllChildrenKeys2 } from "../grid-component/hooks";
|
|
41
42
|
// import { columns111 } from '../test-2/columns'
|
|
42
43
|
|
|
43
44
|
dayjs.extend(customParseFormat);
|
|
@@ -62,6 +63,7 @@ const InternalTable = props => {
|
|
|
62
63
|
groupSetting,
|
|
63
64
|
groupColumns,
|
|
64
65
|
selectionSettings,
|
|
66
|
+
expandable,
|
|
65
67
|
// contextMenuClick,
|
|
66
68
|
// contextMenuOpen,
|
|
67
69
|
height,
|
|
@@ -70,6 +72,10 @@ const InternalTable = props => {
|
|
|
70
72
|
const id = React.useMemo(() => {
|
|
71
73
|
return faker.string.alpha(20);
|
|
72
74
|
}, []);
|
|
75
|
+
const {
|
|
76
|
+
defaultExpandedRowKeys,
|
|
77
|
+
defaultExpandAllRows
|
|
78
|
+
} = expandable || {};
|
|
73
79
|
const rowKey = 'rowId';
|
|
74
80
|
const prefix = 'ui-rc';
|
|
75
81
|
const getWindowSize = () => {
|
|
@@ -110,17 +116,14 @@ const InternalTable = props => {
|
|
|
110
116
|
return convertToTanStackColumns({
|
|
111
117
|
t,
|
|
112
118
|
columns,
|
|
113
|
-
// expanded,
|
|
114
|
-
// setExpanded,
|
|
115
|
-
// expandable,
|
|
116
119
|
format,
|
|
117
120
|
editAble
|
|
118
121
|
});
|
|
119
122
|
|
|
120
|
-
// return convertToTanStackColumns<RecordType>(columns
|
|
123
|
+
// return convertToTanStackColumns<RecordType>(columns)
|
|
121
124
|
}, [t, columns, format, editAble]);
|
|
122
125
|
const isDataTree = React.useMemo(() => {
|
|
123
|
-
return
|
|
126
|
+
return isTreeArray(dataSource);
|
|
124
127
|
}, [dataSource]);
|
|
125
128
|
const columnPinning = React.useMemo(() => {
|
|
126
129
|
return {
|
|
@@ -133,6 +136,16 @@ const InternalTable = props => {
|
|
|
133
136
|
const [mergedFilterKeys, setMergedFilterKeys] = useMergedState(getAllRowKey(convertData), {
|
|
134
137
|
value: undefined
|
|
135
138
|
});
|
|
139
|
+
React.useEffect(() => {
|
|
140
|
+
if (defaultExpandAllRows) {
|
|
141
|
+
const allKeys = findAllChildrenKeys2(convertData, rowKey, 'children');
|
|
142
|
+
setExpanded(convertToObjTrue(allKeys));
|
|
143
|
+
} else {
|
|
144
|
+
if (defaultExpandedRowKeys) {
|
|
145
|
+
setExpanded(convertToObjTrue(defaultExpandedRowKeys ?? []));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, [defaultExpandAllRows, convertData, defaultExpandedRowKeys]);
|
|
136
149
|
|
|
137
150
|
// ========================= Keys =========================
|
|
138
151
|
|
|
@@ -196,7 +209,8 @@ const InternalTable = props => {
|
|
|
196
209
|
height: height,
|
|
197
210
|
isDataTree: isDataTree,
|
|
198
211
|
selectionSettings: selectionSettings,
|
|
199
|
-
mergedSelectedKeys: mergedSelectedKeys
|
|
212
|
+
mergedSelectedKeys: mergedSelectedKeys,
|
|
213
|
+
expandable: expandable
|
|
200
214
|
})), /*#__PURE__*/React.createElement(Modal, {
|
|
201
215
|
open: isFullScreen,
|
|
202
216
|
footer: null,
|
|
@@ -265,7 +279,8 @@ const InternalTable = props => {
|
|
|
265
279
|
windowSize: windowSize,
|
|
266
280
|
isDataTree: isDataTree,
|
|
267
281
|
selectionSettings: selectionSettings,
|
|
268
|
-
mergedSelectedKeys: mergedSelectedKeys
|
|
282
|
+
mergedSelectedKeys: mergedSelectedKeys,
|
|
283
|
+
expandable: expandable
|
|
269
284
|
})))));
|
|
270
285
|
};
|
|
271
286
|
export default InternalTable;
|
|
@@ -136,3 +136,4 @@ export declare const convertToObjTrue: (arr: any) => {
|
|
|
136
136
|
export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
|
|
137
137
|
export declare function isTree(arr: any[]): boolean;
|
|
138
138
|
export declare function findFirst(items: Column<any>[]): Column<any, unknown>;
|
|
139
|
+
export declare function isTreeArray(arr: any[]): boolean;
|
|
@@ -1877,14 +1877,24 @@ export const getDiffent2Array = (a, b) => {
|
|
|
1877
1877
|
return [...a.filter(x => !b.includes(x)), ...b.filter(x => !a.includes(x))];
|
|
1878
1878
|
};
|
|
1879
1879
|
export function isTree(arr) {
|
|
1880
|
-
if (!Array.isArray(arr))
|
|
1880
|
+
if (!Array.isArray(arr)) {
|
|
1881
|
+
return false;
|
|
1882
|
+
}
|
|
1881
1883
|
function checkNode(node) {
|
|
1882
|
-
if (typeof node !== "object" || node === null)
|
|
1884
|
+
if (typeof node !== "object" || node === null) {
|
|
1885
|
+
return false;
|
|
1886
|
+
}
|
|
1883
1887
|
if ("children" in node) {
|
|
1884
|
-
if (!Array.isArray(node.children))
|
|
1885
|
-
|
|
1888
|
+
if (!Array.isArray(node.children)) {
|
|
1889
|
+
return false;
|
|
1890
|
+
}
|
|
1891
|
+
if (node.children.length === 0) {
|
|
1892
|
+
return false;
|
|
1893
|
+
}
|
|
1886
1894
|
for (const child of node.children) {
|
|
1887
|
-
if (!checkNode(child))
|
|
1895
|
+
if (!checkNode(child)) {
|
|
1896
|
+
return false;
|
|
1897
|
+
}
|
|
1888
1898
|
}
|
|
1889
1899
|
}
|
|
1890
1900
|
return true;
|
|
@@ -1898,4 +1908,13 @@ export function findFirst(items) {
|
|
|
1898
1908
|
const leftItem = items.find(item => item.getIsPinned() === 'left');
|
|
1899
1909
|
if (leftItem) return leftItem;
|
|
1900
1910
|
return null;
|
|
1911
|
+
}
|
|
1912
|
+
export function isTreeArray(arr) {
|
|
1913
|
+
if (!Array.isArray(arr)) return false;
|
|
1914
|
+
return arr.every(item => {
|
|
1915
|
+
if ("children" in item) {
|
|
1916
|
+
return Array.isArray(item.children) && item.children.length > 0;
|
|
1917
|
+
}
|
|
1918
|
+
return true; // node lá thì hợp lệ
|
|
1919
|
+
});
|
|
1901
1920
|
}
|
|
@@ -64,7 +64,7 @@ const Grid = props => {
|
|
|
64
64
|
const [rowSelection, setRowSelection] = React.useState(convertToObjTrue(mergedSelectedKeys));
|
|
65
65
|
const [grouping, setGrouping] = React.useState([]);
|
|
66
66
|
const [columnSizing, setColumnSizing] = React.useState({});
|
|
67
|
-
const [manualUpdate, setManualUpdate] = React.useState(false)
|
|
67
|
+
// const [manualUpdate, setManualUpdate] = React.useState(false)
|
|
68
68
|
// const [manualResize, setManualResize] = React.useState(false)
|
|
69
69
|
|
|
70
70
|
const [columnFilters, setColumnFilters] = React.useState([]);
|
|
@@ -149,13 +149,16 @@ const Grid = props => {
|
|
|
149
149
|
}
|
|
150
150
|
}, [columnHidden, table]);
|
|
151
151
|
React.useEffect(() => {
|
|
152
|
-
if (!manualUpdate) {
|
|
152
|
+
// if (!manualUpdate) {
|
|
153
|
+
if (Object.keys(rowSelection) !== Object.keys(mergedSelectedKeys)) {
|
|
153
154
|
setRowSelection(convertToObjTrue(mergedSelectedKeys));
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
+
|
|
157
|
+
// }
|
|
158
|
+
}, [mergedSelectedKeys]);
|
|
156
159
|
React.useEffect(() => {
|
|
157
160
|
if (isSelectionChange.isChange) {
|
|
158
|
-
setManualUpdate(true)
|
|
161
|
+
// setManualUpdate(true)
|
|
159
162
|
const aa = table.getState().rowSelection;
|
|
160
163
|
const dataTable = table.getRowModel().flatRows;
|
|
161
164
|
const ids = Object.keys(aa);
|
|
@@ -57,6 +57,7 @@ export declare const updateData: <Record_1 = AnyObject>(initData: Record_1[], ro
|
|
|
57
57
|
export declare const parseBooleanToValue: (value: boolean, type: 'boolean' | 'number') => number | boolean;
|
|
58
58
|
export declare const genPresets: (presets?: import("@ant-design/colors").PalettesProps) => import("antd/es/color-picker/interface").PresetsItem[];
|
|
59
59
|
export declare function findAllChildrenKeys<RecordType>(data: readonly RecordType[], getRowKey: GetRowKey<RecordType>, childrenColumnName: string): Key[];
|
|
60
|
+
export declare function findAllChildrenKeys2<RecordType>(data: readonly RecordType[], rowKey: any, childrenColumnName: string): Key[];
|
|
60
61
|
export declare const flattenArray: <RecordType extends AnyObject = AnyObject>(arr: any[]) => RecordType[];
|
|
61
62
|
export declare const flattenData: <RecordType extends AnyObject = AnyObject>(childrenColumnName: string, data?: RecordType[]) => RecordType[];
|
|
62
63
|
export declare const unFlattenData: <RecordType extends AnyObject = AnyObject>(data: RecordType[]) => RecordType[];
|
|
@@ -17,6 +17,7 @@ exports.convertFormat = convertFormat;
|
|
|
17
17
|
exports.filterDataByColumns3 = exports.filterDataByColumns2 = exports.filterDataByColumns = exports.editAbleColumns = exports.detectSeparators = exports.customWeekStartEndFormat = exports.customFilterOption = exports.countItemsBeforeIndex = exports.convertLabelToTitle = void 0;
|
|
18
18
|
exports.filterDataByColumns4 = filterDataByColumns4;
|
|
19
19
|
exports.findAllChildrenKeys = findAllChildrenKeys;
|
|
20
|
+
exports.findAllChildrenKeys2 = findAllChildrenKeys2;
|
|
20
21
|
exports.getAllVisibleKeys = exports.getAllRowKey = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemPath = exports.findItemByKey = void 0;
|
|
21
22
|
exports.getBottomRowCells = getBottomRowCells;
|
|
22
23
|
exports.getCellsByPosition = getCellsByPosition;
|
|
@@ -38,8 +39,8 @@ exports.isRightMostInRegion = isRightMostInRegion;
|
|
|
38
39
|
exports.isTopMostInRegion = exports.isSelectedCell = void 0;
|
|
39
40
|
exports.mergeWithFilter = mergeWithFilter;
|
|
40
41
|
exports.mergeWithFilter2 = mergeWithFilter2;
|
|
41
|
-
exports.
|
|
42
|
-
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.unFlattenData = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sumByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeVietnameseTones = void 0;
|
|
42
|
+
exports.removeFieldRecursive = exports.removeColumns = exports.removeClassCellIndexSelected = exports.removeClassBorderPasteCell = exports.removeBorderPasteClass = exports.removeBorderClass2 = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveBorderSelectedCell = exports.onRemoveBgSelectedCell = exports.onRemoveBgCellIndex = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.onAddBgCellIndex = exports.newGuid = exports.mergedSets = void 0;
|
|
43
|
+
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.unFlattenData = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sumByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeVietnameseTones = exports.removeInvisibleColumns = void 0;
|
|
43
44
|
exports.updateDataByFilter = updateDataByFilter;
|
|
44
45
|
exports.updateOrInsert = updateOrInsert;
|
|
45
46
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
@@ -525,6 +526,17 @@ function findAllChildrenKeys(data, getRowKey, childrenColumnName) {
|
|
|
525
526
|
dig(data);
|
|
526
527
|
return keys;
|
|
527
528
|
}
|
|
529
|
+
function findAllChildrenKeys2(data, rowKey, childrenColumnName) {
|
|
530
|
+
const keys = [];
|
|
531
|
+
function dig(list) {
|
|
532
|
+
(list || []).forEach(item => {
|
|
533
|
+
keys.push(item[rowKey]);
|
|
534
|
+
dig(item[childrenColumnName]);
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
dig(data);
|
|
538
|
+
return keys;
|
|
539
|
+
}
|
|
528
540
|
const flattenArray = arr => {
|
|
529
541
|
if (!arr) {
|
|
530
542
|
return [];
|
|
@@ -20,6 +20,7 @@ var _utils = require("./hook/utils");
|
|
|
20
20
|
var _useColumns = require("./hook/useColumns");
|
|
21
21
|
var _convert = require("./hook/convert");
|
|
22
22
|
var _antd = require("antd");
|
|
23
|
+
var _hooks = require("../grid-component/hooks");
|
|
23
24
|
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); }
|
|
24
25
|
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; }
|
|
25
26
|
// import en from "rc-master-ui/es/date-picker/locale/en_US"
|
|
@@ -68,6 +69,7 @@ const InternalTable = props => {
|
|
|
68
69
|
groupSetting,
|
|
69
70
|
groupColumns,
|
|
70
71
|
selectionSettings,
|
|
72
|
+
expandable,
|
|
71
73
|
// contextMenuClick,
|
|
72
74
|
// contextMenuOpen,
|
|
73
75
|
height,
|
|
@@ -76,6 +78,10 @@ const InternalTable = props => {
|
|
|
76
78
|
const id = _react.default.useMemo(() => {
|
|
77
79
|
return _faker.faker.string.alpha(20);
|
|
78
80
|
}, []);
|
|
81
|
+
const {
|
|
82
|
+
defaultExpandedRowKeys,
|
|
83
|
+
defaultExpandAllRows
|
|
84
|
+
} = expandable || {};
|
|
79
85
|
const rowKey = 'rowId';
|
|
80
86
|
const prefix = 'ui-rc';
|
|
81
87
|
const getWindowSize = () => {
|
|
@@ -116,17 +122,14 @@ const InternalTable = props => {
|
|
|
116
122
|
return (0, _useColumns.convertToTanStackColumns)({
|
|
117
123
|
t,
|
|
118
124
|
columns,
|
|
119
|
-
// expanded,
|
|
120
|
-
// setExpanded,
|
|
121
|
-
// expandable,
|
|
122
125
|
format,
|
|
123
126
|
editAble
|
|
124
127
|
});
|
|
125
128
|
|
|
126
|
-
// return convertToTanStackColumns<RecordType>(columns
|
|
129
|
+
// return convertToTanStackColumns<RecordType>(columns)
|
|
127
130
|
}, [t, columns, format, editAble]);
|
|
128
131
|
const isDataTree = _react.default.useMemo(() => {
|
|
129
|
-
return (0, _utils.
|
|
132
|
+
return (0, _utils.isTreeArray)(dataSource);
|
|
130
133
|
}, [dataSource]);
|
|
131
134
|
const columnPinning = _react.default.useMemo(() => {
|
|
132
135
|
return {
|
|
@@ -139,6 +142,16 @@ const InternalTable = props => {
|
|
|
139
142
|
const [mergedFilterKeys, setMergedFilterKeys] = (0, _useMergedState.default)((0, _utils.getAllRowKey)(convertData), {
|
|
140
143
|
value: undefined
|
|
141
144
|
});
|
|
145
|
+
_react.default.useEffect(() => {
|
|
146
|
+
if (defaultExpandAllRows) {
|
|
147
|
+
const allKeys = (0, _hooks.findAllChildrenKeys2)(convertData, rowKey, 'children');
|
|
148
|
+
setExpanded((0, _utils.convertToObjTrue)(allKeys));
|
|
149
|
+
} else {
|
|
150
|
+
if (defaultExpandedRowKeys) {
|
|
151
|
+
setExpanded((0, _utils.convertToObjTrue)(defaultExpandedRowKeys ?? []));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}, [defaultExpandAllRows, convertData, defaultExpandedRowKeys]);
|
|
142
155
|
|
|
143
156
|
// ========================= Keys =========================
|
|
144
157
|
|
|
@@ -202,7 +215,8 @@ const InternalTable = props => {
|
|
|
202
215
|
height: height,
|
|
203
216
|
isDataTree: isDataTree,
|
|
204
217
|
selectionSettings: selectionSettings,
|
|
205
|
-
mergedSelectedKeys: mergedSelectedKeys
|
|
218
|
+
mergedSelectedKeys: mergedSelectedKeys,
|
|
219
|
+
expandable: expandable
|
|
206
220
|
})), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
|
|
207
221
|
open: isFullScreen,
|
|
208
222
|
footer: null,
|
|
@@ -271,7 +285,8 @@ const InternalTable = props => {
|
|
|
271
285
|
windowSize: windowSize,
|
|
272
286
|
isDataTree: isDataTree,
|
|
273
287
|
selectionSettings: selectionSettings,
|
|
274
|
-
mergedSelectedKeys: mergedSelectedKeys
|
|
288
|
+
mergedSelectedKeys: mergedSelectedKeys,
|
|
289
|
+
expandable: expandable
|
|
275
290
|
})))));
|
|
276
291
|
};
|
|
277
292
|
var _default = exports.default = InternalTable;
|
|
@@ -136,3 +136,4 @@ export declare const convertToObjTrue: (arr: any) => {
|
|
|
136
136
|
export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
|
|
137
137
|
export declare function isTree(arr: any[]): boolean;
|
|
138
138
|
export declare function findFirst(items: Column<any>[]): Column<any, unknown>;
|
|
139
|
+
export declare function isTreeArray(arr: any[]): boolean;
|
|
@@ -39,6 +39,7 @@ exports.isEqualSet = isEqualSet;
|
|
|
39
39
|
exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isFormattedNumber = void 0;
|
|
40
40
|
exports.isObjEqual = isObjEqual;
|
|
41
41
|
exports.isTree = isTree;
|
|
42
|
+
exports.isTreeArray = isTreeArray;
|
|
42
43
|
exports.sortByType = exports.shouldInclude = exports.removeVietnameseTones = exports.parseBooleanToValue = exports.onRemoveBgSelectedCell = exports.onAddBgSelectedCell = exports.newGuid = void 0;
|
|
43
44
|
exports.sortData = sortData;
|
|
44
45
|
exports.updateColumns1 = exports.updateArrayByKey = exports.unFlattenData = exports.sumSize = void 0;
|
|
@@ -1978,14 +1979,24 @@ const getDiffent2Array = (a, b) => {
|
|
|
1978
1979
|
};
|
|
1979
1980
|
exports.getDiffent2Array = getDiffent2Array;
|
|
1980
1981
|
function isTree(arr) {
|
|
1981
|
-
if (!Array.isArray(arr))
|
|
1982
|
+
if (!Array.isArray(arr)) {
|
|
1983
|
+
return false;
|
|
1984
|
+
}
|
|
1982
1985
|
function checkNode(node) {
|
|
1983
|
-
if (typeof node !== "object" || node === null)
|
|
1986
|
+
if (typeof node !== "object" || node === null) {
|
|
1987
|
+
return false;
|
|
1988
|
+
}
|
|
1984
1989
|
if ("children" in node) {
|
|
1985
|
-
if (!Array.isArray(node.children))
|
|
1986
|
-
|
|
1990
|
+
if (!Array.isArray(node.children)) {
|
|
1991
|
+
return false;
|
|
1992
|
+
}
|
|
1993
|
+
if (node.children.length === 0) {
|
|
1994
|
+
return false;
|
|
1995
|
+
}
|
|
1987
1996
|
for (const child of node.children) {
|
|
1988
|
-
if (!checkNode(child))
|
|
1997
|
+
if (!checkNode(child)) {
|
|
1998
|
+
return false;
|
|
1999
|
+
}
|
|
1989
2000
|
}
|
|
1990
2001
|
}
|
|
1991
2002
|
return true;
|
|
@@ -1999,4 +2010,13 @@ function findFirst(items) {
|
|
|
1999
2010
|
const leftItem = items.find(item => item.getIsPinned() === 'left');
|
|
2000
2011
|
if (leftItem) return leftItem;
|
|
2001
2012
|
return null;
|
|
2013
|
+
}
|
|
2014
|
+
function isTreeArray(arr) {
|
|
2015
|
+
if (!Array.isArray(arr)) return false;
|
|
2016
|
+
return arr.every(item => {
|
|
2017
|
+
if ("children" in item) {
|
|
2018
|
+
return Array.isArray(item.children) && item.children.length > 0;
|
|
2019
|
+
}
|
|
2020
|
+
return true; // node lá thì hợp lệ
|
|
2021
|
+
});
|
|
2002
2022
|
}
|
|
@@ -66,7 +66,7 @@ const Grid = props => {
|
|
|
66
66
|
const [rowSelection, setRowSelection] = _react.default.useState((0, _utils.convertToObjTrue)(mergedSelectedKeys));
|
|
67
67
|
const [grouping, setGrouping] = _react.default.useState([]);
|
|
68
68
|
const [columnSizing, setColumnSizing] = _react.default.useState({});
|
|
69
|
-
const [manualUpdate, setManualUpdate] =
|
|
69
|
+
// const [manualUpdate, setManualUpdate] = React.useState(false)
|
|
70
70
|
// const [manualResize, setManualResize] = React.useState(false)
|
|
71
71
|
|
|
72
72
|
const [columnFilters, setColumnFilters] = _react.default.useState([]);
|
|
@@ -151,13 +151,16 @@ const Grid = props => {
|
|
|
151
151
|
}
|
|
152
152
|
}, [columnHidden, table]);
|
|
153
153
|
_react.default.useEffect(() => {
|
|
154
|
-
if (!manualUpdate) {
|
|
154
|
+
// if (!manualUpdate) {
|
|
155
|
+
if (Object.keys(rowSelection) !== Object.keys(mergedSelectedKeys)) {
|
|
155
156
|
setRowSelection((0, _utils.convertToObjTrue)(mergedSelectedKeys));
|
|
156
157
|
}
|
|
157
|
-
|
|
158
|
+
|
|
159
|
+
// }
|
|
160
|
+
}, [mergedSelectedKeys]);
|
|
158
161
|
_react.default.useEffect(() => {
|
|
159
162
|
if (isSelectionChange.isChange) {
|
|
160
|
-
setManualUpdate(true)
|
|
163
|
+
// setManualUpdate(true)
|
|
161
164
|
const aa = table.getState().rowSelection;
|
|
162
165
|
const dataTable = table.getRowModel().flatRows;
|
|
163
166
|
const ids = Object.keys(aa);
|