es-grid-template 1.8.32 → 1.8.34
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/table-component/TableContainerEdit.js +3 -1
- package/es/table-component/body/TableBodyCellEdit.d.ts +1 -0
- package/es/table-component/body/TableBodyCellEdit.js +10 -2
- package/es/table-component/body/TableBodyRow.js +6 -1
- package/es/table-component/hook/utils.d.ts +0 -1
- package/es/table-component/hook/utils.js +45 -52
- package/es/table-component/table/Grid.js +2 -2
- package/es/table-component/useContext.d.ts +1 -0
- package/lib/table-component/TableContainerEdit.js +3 -1
- package/lib/table-component/body/TableBodyCellEdit.d.ts +1 -0
- package/lib/table-component/body/TableBodyCellEdit.js +10 -2
- package/lib/table-component/body/TableBodyRow.js +6 -1
- package/lib/table-component/hook/utils.d.ts +0 -1
- package/lib/table-component/hook/utils.js +46 -55
- package/lib/table-component/table/Grid.js +2 -2
- package/lib/table-component/useContext.d.ts +1 -0
- package/package.json +1 -1
|
@@ -63,6 +63,7 @@ const TableContainerEdit = props => {
|
|
|
63
63
|
prefix,
|
|
64
64
|
commandClick,
|
|
65
65
|
editAble,
|
|
66
|
+
rowEditable,
|
|
66
67
|
rowKey,
|
|
67
68
|
format,
|
|
68
69
|
dataSource,
|
|
@@ -1835,7 +1836,8 @@ const TableContainerEdit = props => {
|
|
|
1835
1836
|
windowSize,
|
|
1836
1837
|
handleCellClick,
|
|
1837
1838
|
pagination,
|
|
1838
|
-
rowClassName
|
|
1839
|
+
rowClassName,
|
|
1840
|
+
rowEditable
|
|
1839
1841
|
}
|
|
1840
1842
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
1841
1843
|
contextMenuItems: contextMenuItems,
|
|
@@ -10,6 +10,7 @@ interface TableBodyCellProps<T> {
|
|
|
10
10
|
cell: Cell<T, unknown>;
|
|
11
11
|
commandClick?: (args: CommandClick<T>) => void;
|
|
12
12
|
virtualRow: VirtualItem;
|
|
13
|
+
isRowEditable?: boolean;
|
|
13
14
|
[key: string]: any;
|
|
14
15
|
}
|
|
15
16
|
declare const TableBodyCellEdit: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
|
|
@@ -186,6 +186,7 @@ const TableBodyCellEdit = props => {
|
|
|
186
186
|
// tableId,
|
|
187
187
|
table,
|
|
188
188
|
isEditing,
|
|
189
|
+
isRowEditable,
|
|
189
190
|
columnVirtualizer,
|
|
190
191
|
rowVirtualizer
|
|
191
192
|
// virtualRow
|
|
@@ -242,7 +243,8 @@ const TableBodyCellEdit = props => {
|
|
|
242
243
|
|
|
243
244
|
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
244
245
|
const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
|
|
245
|
-
const canEdit = isEditable(cell.column.columnDef.meta, record);
|
|
246
|
+
const canEdit = isEditable(cell.column.columnDef.meta, record) && isRowEditable !== false;
|
|
247
|
+
|
|
246
248
|
// const allRows = table.getRowModel().rows;
|
|
247
249
|
const allRows = table.getRowModel().flatRows;
|
|
248
250
|
|
|
@@ -975,7 +977,8 @@ const TableBodyCellEdit = props => {
|
|
|
975
977
|
className: classNames(`${prefix}-grid-cell cell-editable editable `, {
|
|
976
978
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
977
979
|
'cell-editing': isEditing,
|
|
978
|
-
disable: !isEditable(cell.column.columnDef.meta, record),
|
|
980
|
+
// disable: !isEditable(cell.column.columnDef.meta as any, record),
|
|
981
|
+
disable: !canEdit,
|
|
979
982
|
isValid: !isEditing && rowError && rowError[cell.column.id]?.field === cell.column.id,
|
|
980
983
|
[`${prefix}-grid-cell-selected`]: isCellSelected,
|
|
981
984
|
'cell-border-bottom': !isEditing && isInRange && isBottom,
|
|
@@ -1087,6 +1090,11 @@ const TableBodyCellEdit = props => {
|
|
|
1087
1090
|
}
|
|
1088
1091
|
},
|
|
1089
1092
|
onDoubleClick: e => {
|
|
1093
|
+
if (!canEdit) {
|
|
1094
|
+
e.stopPropagation();
|
|
1095
|
+
e.preventDefault();
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1090
1098
|
if (!(record[rowKey] === editingKey && canEdit)) {
|
|
1091
1099
|
handleEdit(e);
|
|
1092
1100
|
}
|
|
@@ -26,7 +26,8 @@ const TableBodyRow = ({
|
|
|
26
26
|
prefix,
|
|
27
27
|
recordDoubleClick,
|
|
28
28
|
focusedCell,
|
|
29
|
-
rowClassName
|
|
29
|
+
rowClassName,
|
|
30
|
+
rowEditable
|
|
30
31
|
} = React.useContext(TableContext);
|
|
31
32
|
const visibleCells = row.getVisibleCells();
|
|
32
33
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
@@ -38,6 +39,7 @@ const TableBodyRow = ({
|
|
|
38
39
|
const virtualRight = virtualPaddingRight ? [virtualPaddingRight] : [];
|
|
39
40
|
const templateColumns = [...leftTemplate, ...virtualLeft, ...centerTemplate, ...virtualRight, ...rightTemplate];
|
|
40
41
|
const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
|
|
42
|
+
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
41
43
|
return /*#__PURE__*/React.createElement("div", {
|
|
42
44
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
43
45
|
,
|
|
@@ -91,6 +93,7 @@ const TableBodyRow = ({
|
|
|
91
93
|
commandClick: commandClick,
|
|
92
94
|
virtualRow: virtualRow,
|
|
93
95
|
isEditing: isEditing,
|
|
96
|
+
isRowEditable: isRowEditable,
|
|
94
97
|
rowVirtualizer: rowVirtualizer,
|
|
95
98
|
columnVirtualizer: columnVirtualizer
|
|
96
99
|
}));
|
|
@@ -124,6 +127,7 @@ const TableBodyRow = ({
|
|
|
124
127
|
cell: cell,
|
|
125
128
|
commandClick: commandClick,
|
|
126
129
|
isEditing: isEditing,
|
|
130
|
+
isRowEditable: isRowEditable,
|
|
127
131
|
rowVirtualizer: rowVirtualizer,
|
|
128
132
|
columnVirtualizer: columnVirtualizer,
|
|
129
133
|
virtualRow: virtualRow
|
|
@@ -150,6 +154,7 @@ const TableBodyRow = ({
|
|
|
150
154
|
cell: row.getVisibleCells().find(c => c.column.id === column.id),
|
|
151
155
|
commandClick: commandClick,
|
|
152
156
|
isEditing: isEditing,
|
|
157
|
+
isRowEditable: isRowEditable,
|
|
153
158
|
rowVirtualizer: rowVirtualizer,
|
|
154
159
|
columnVirtualizer: columnVirtualizer,
|
|
155
160
|
virtualRow: virtualRow
|
|
@@ -135,7 +135,6 @@ export declare const convertToObjTrue: (arr: any) => {
|
|
|
135
135
|
[k: string]: any;
|
|
136
136
|
};
|
|
137
137
|
export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
|
|
138
|
-
export declare function isTree(arr: any[]): boolean;
|
|
139
138
|
export declare function findFirst(items: Column<any>[]): Column<any, unknown>;
|
|
140
139
|
export declare function isTreeArray(arr: any[], options?: any): boolean;
|
|
141
140
|
export declare function updateColumnWidthsRecursive(columns: any[], sizing: Record<string, number>): any[];
|
|
@@ -1902,76 +1902,69 @@ export const convertToObjTrue = arr => {
|
|
|
1902
1902
|
export const getDiffent2Array = (a, b) => {
|
|
1903
1903
|
return [...a.filter(x => !b.includes(x)), ...b.filter(x => !a.includes(x))];
|
|
1904
1904
|
};
|
|
1905
|
-
export function isTree(arr) {
|
|
1906
|
-
if (!Array.isArray(arr)) {
|
|
1907
|
-
return false;
|
|
1908
|
-
}
|
|
1909
|
-
function checkNode(node) {
|
|
1910
|
-
if (typeof node !== "object" || node === null) {
|
|
1911
|
-
return false;
|
|
1912
|
-
}
|
|
1913
|
-
if ("children" in node) {
|
|
1914
|
-
if (!Array.isArray(node.children)) {
|
|
1915
|
-
return false;
|
|
1916
|
-
}
|
|
1917
|
-
if (node.children.length === 0) {
|
|
1918
|
-
return false;
|
|
1919
|
-
}
|
|
1920
|
-
for (const child of node.children) {
|
|
1921
|
-
if (!checkNode(child)) {
|
|
1922
|
-
return false;
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
return true;
|
|
1927
|
-
}
|
|
1928
|
-
for (const item of arr) {
|
|
1929
|
-
if (!checkNode(item)) return false;
|
|
1930
|
-
}
|
|
1931
|
-
return true;
|
|
1932
|
-
}
|
|
1933
|
-
export function findFirst(items) {
|
|
1934
|
-
const leftItem = items.find(item => item.getIsPinned() === 'left');
|
|
1935
|
-
if (leftItem) return leftItem;
|
|
1936
|
-
return null;
|
|
1937
|
-
}
|
|
1938
1905
|
|
|
1939
|
-
// export function
|
|
1906
|
+
// export function isTree(arr: any[]): boolean {
|
|
1907
|
+
// if (!Array.isArray(arr)){
|
|
1908
|
+
// return false
|
|
1909
|
+
// }
|
|
1940
1910
|
|
|
1941
|
-
//
|
|
1911
|
+
// function checkNode(node: any): boolean {
|
|
1912
|
+
// if (typeof node !== "object" || node === null) {
|
|
1913
|
+
// return false
|
|
1914
|
+
// }
|
|
1942
1915
|
|
|
1943
|
-
//
|
|
1944
|
-
// // if ("children" in item) {
|
|
1945
|
-
// // return Array.isArray(item.children) && item.children.length > 0;
|
|
1946
|
-
// // }
|
|
1947
|
-
// // return true; // node lá thì hợp lệ
|
|
1948
|
-
// // });
|
|
1916
|
+
// if ("children" in node) {
|
|
1949
1917
|
|
|
1950
|
-
//
|
|
1918
|
+
// if (!Array.isArray(node.children)) {
|
|
1919
|
+
// return false
|
|
1920
|
+
// }
|
|
1921
|
+
// if (node.children.length === 0) {
|
|
1922
|
+
// return false
|
|
1923
|
+
// }
|
|
1951
1924
|
|
|
1952
|
-
//
|
|
1953
|
-
//
|
|
1925
|
+
// for (const child of node.children) {
|
|
1926
|
+
// if (!checkNode(child)) {
|
|
1927
|
+
// return false
|
|
1928
|
+
// }
|
|
1929
|
+
// }
|
|
1954
1930
|
|
|
1955
|
-
// if ("children" in item) {
|
|
1956
|
-
// return Array.isArray(item.children);
|
|
1957
1931
|
// }
|
|
1958
1932
|
|
|
1959
|
-
// return
|
|
1960
|
-
// }
|
|
1933
|
+
// return true;
|
|
1934
|
+
// }
|
|
1935
|
+
|
|
1936
|
+
// for (const item of arr) {
|
|
1937
|
+
// if (!checkNode(item)) return false;
|
|
1938
|
+
// }
|
|
1961
1939
|
|
|
1940
|
+
// return true;
|
|
1962
1941
|
// }
|
|
1963
1942
|
|
|
1943
|
+
export function findFirst(items) {
|
|
1944
|
+
const leftItem = items.find(item => item.getIsPinned() === 'left');
|
|
1945
|
+
if (leftItem) return leftItem;
|
|
1946
|
+
return null;
|
|
1947
|
+
}
|
|
1964
1948
|
export function isTreeArray(arr, options) {
|
|
1965
|
-
if (!Array.isArray(arr) || arr.length === 0)
|
|
1949
|
+
if (!Array.isArray(arr) || arr.length === 0) {
|
|
1950
|
+
return false;
|
|
1951
|
+
}
|
|
1966
1952
|
const requireNonEmpty = options?.requireNonEmptyChildren ?? false;
|
|
1967
1953
|
let hasParent = false;
|
|
1968
1954
|
for (const item of arr) {
|
|
1969
|
-
if (typeof item !== 'object' || item === null)
|
|
1955
|
+
if (typeof item !== 'object' || item === null) {
|
|
1956
|
+
return false;
|
|
1957
|
+
}
|
|
1970
1958
|
if ('children' in item) {
|
|
1971
1959
|
const children = item.children;
|
|
1972
|
-
if (!Array.isArray(children))
|
|
1960
|
+
if (!Array.isArray(children)) {
|
|
1961
|
+
// return false;
|
|
1962
|
+
hasParent = false;
|
|
1963
|
+
}
|
|
1973
1964
|
if (requireNonEmpty) {
|
|
1974
|
-
if (children.length > 0)
|
|
1965
|
+
if (children.length > 0) {
|
|
1966
|
+
hasParent = true;
|
|
1967
|
+
}
|
|
1975
1968
|
} else {
|
|
1976
1969
|
hasParent = true;
|
|
1977
1970
|
}
|
|
@@ -133,8 +133,8 @@ const Grid = props => {
|
|
|
133
133
|
// ColumnSorting
|
|
134
134
|
// getSortedRowModel: getSortedRowModel(),
|
|
135
135
|
onSortingChange: setSorting,
|
|
136
|
-
enableMultiSort: sortMultiple,
|
|
137
|
-
isMultiSortEvent: () => sortMultiple ?
|
|
136
|
+
enableMultiSort: sortMultiple !== false,
|
|
137
|
+
isMultiSortEvent: () => sortMultiple === false ? false : true,
|
|
138
138
|
enableSorting: allowSortering !== false,
|
|
139
139
|
// ColumnSorting
|
|
140
140
|
|
|
@@ -77,6 +77,7 @@ export interface IContext<T> {
|
|
|
77
77
|
pagination?: false | PaginationConfig;
|
|
78
78
|
rowClassName?: string | RowClassName<T>;
|
|
79
79
|
table?: Table<T>;
|
|
80
|
+
rowEditable?: (rowData: T) => boolean;
|
|
80
81
|
}
|
|
81
82
|
export declare const TableContext: import("react").Context<IContext<any>>;
|
|
82
83
|
export type ContextCellChange = {
|
|
@@ -70,6 +70,7 @@ const TableContainerEdit = props => {
|
|
|
70
70
|
prefix,
|
|
71
71
|
commandClick,
|
|
72
72
|
editAble,
|
|
73
|
+
rowEditable,
|
|
73
74
|
rowKey,
|
|
74
75
|
format,
|
|
75
76
|
dataSource,
|
|
@@ -1842,7 +1843,8 @@ const TableContainerEdit = props => {
|
|
|
1842
1843
|
windowSize,
|
|
1843
1844
|
handleCellClick,
|
|
1844
1845
|
pagination,
|
|
1845
|
-
rowClassName
|
|
1846
|
+
rowClassName,
|
|
1847
|
+
rowEditable
|
|
1846
1848
|
}
|
|
1847
1849
|
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
|
|
1848
1850
|
contextMenuItems: contextMenuItems,
|
|
@@ -10,6 +10,7 @@ interface TableBodyCellProps<T> {
|
|
|
10
10
|
cell: Cell<T, unknown>;
|
|
11
11
|
commandClick?: (args: CommandClick<T>) => void;
|
|
12
12
|
virtualRow: VirtualItem;
|
|
13
|
+
isRowEditable?: boolean;
|
|
13
14
|
[key: string]: any;
|
|
14
15
|
}
|
|
15
16
|
declare const TableBodyCellEdit: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
|
|
@@ -192,6 +192,7 @@ const TableBodyCellEdit = props => {
|
|
|
192
192
|
// tableId,
|
|
193
193
|
table,
|
|
194
194
|
isEditing,
|
|
195
|
+
isRowEditable,
|
|
195
196
|
columnVirtualizer,
|
|
196
197
|
rowVirtualizer
|
|
197
198
|
// virtualRow
|
|
@@ -248,7 +249,8 @@ const TableBodyCellEdit = props => {
|
|
|
248
249
|
|
|
249
250
|
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
250
251
|
const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
|
|
251
|
-
const canEdit = (0, _utils.isEditable)(cell.column.columnDef.meta, record);
|
|
252
|
+
const canEdit = (0, _utils.isEditable)(cell.column.columnDef.meta, record) && isRowEditable !== false;
|
|
253
|
+
|
|
252
254
|
// const allRows = table.getRowModel().rows;
|
|
253
255
|
const allRows = table.getRowModel().flatRows;
|
|
254
256
|
|
|
@@ -981,7 +983,8 @@ const TableBodyCellEdit = props => {
|
|
|
981
983
|
className: (0, _classnames.default)(`${prefix}-grid-cell cell-editable editable `, {
|
|
982
984
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
983
985
|
'cell-editing': isEditing,
|
|
984
|
-
disable: !
|
|
986
|
+
// disable: !isEditable(cell.column.columnDef.meta as any, record),
|
|
987
|
+
disable: !canEdit,
|
|
985
988
|
isValid: !isEditing && rowError && rowError[cell.column.id]?.field === cell.column.id,
|
|
986
989
|
[`${prefix}-grid-cell-selected`]: isCellSelected,
|
|
987
990
|
'cell-border-bottom': !isEditing && isInRange && isBottom,
|
|
@@ -1093,6 +1096,11 @@ const TableBodyCellEdit = props => {
|
|
|
1093
1096
|
}
|
|
1094
1097
|
},
|
|
1095
1098
|
onDoubleClick: e => {
|
|
1099
|
+
if (!canEdit) {
|
|
1100
|
+
e.stopPropagation();
|
|
1101
|
+
e.preventDefault();
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1096
1104
|
if (!(record[rowKey] === editingKey && canEdit)) {
|
|
1097
1105
|
handleEdit(e);
|
|
1098
1106
|
}
|
|
@@ -33,7 +33,8 @@ const TableBodyRow = ({
|
|
|
33
33
|
prefix,
|
|
34
34
|
recordDoubleClick,
|
|
35
35
|
focusedCell,
|
|
36
|
-
rowClassName
|
|
36
|
+
rowClassName,
|
|
37
|
+
rowEditable
|
|
37
38
|
} = _react.default.useContext(_useContext.TableContext);
|
|
38
39
|
const visibleCells = row.getVisibleCells();
|
|
39
40
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
@@ -45,6 +46,7 @@ const TableBodyRow = ({
|
|
|
45
46
|
const virtualRight = virtualPaddingRight ? [virtualPaddingRight] : [];
|
|
46
47
|
const templateColumns = [...leftTemplate, ...virtualLeft, ...centerTemplate, ...virtualRight, ...rightTemplate];
|
|
47
48
|
const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
|
|
49
|
+
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
48
50
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
49
51
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
50
52
|
,
|
|
@@ -98,6 +100,7 @@ const TableBodyRow = ({
|
|
|
98
100
|
commandClick: commandClick,
|
|
99
101
|
virtualRow: virtualRow,
|
|
100
102
|
isEditing: isEditing,
|
|
103
|
+
isRowEditable: isRowEditable,
|
|
101
104
|
rowVirtualizer: rowVirtualizer,
|
|
102
105
|
columnVirtualizer: columnVirtualizer
|
|
103
106
|
}));
|
|
@@ -131,6 +134,7 @@ const TableBodyRow = ({
|
|
|
131
134
|
cell: cell,
|
|
132
135
|
commandClick: commandClick,
|
|
133
136
|
isEditing: isEditing,
|
|
137
|
+
isRowEditable: isRowEditable,
|
|
134
138
|
rowVirtualizer: rowVirtualizer,
|
|
135
139
|
columnVirtualizer: columnVirtualizer,
|
|
136
140
|
virtualRow: virtualRow
|
|
@@ -157,6 +161,7 @@ const TableBodyRow = ({
|
|
|
157
161
|
cell: row.getVisibleCells().find(c => c.column.id === column.id),
|
|
158
162
|
commandClick: commandClick,
|
|
159
163
|
isEditing: isEditing,
|
|
164
|
+
isRowEditable: isRowEditable,
|
|
160
165
|
rowVirtualizer: rowVirtualizer,
|
|
161
166
|
columnVirtualizer: columnVirtualizer,
|
|
162
167
|
virtualRow: virtualRow
|
|
@@ -135,7 +135,6 @@ export declare const convertToObjTrue: (arr: any) => {
|
|
|
135
135
|
[k: string]: any;
|
|
136
136
|
};
|
|
137
137
|
export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
|
|
138
|
-
export declare function isTree(arr: any[]): boolean;
|
|
139
138
|
export declare function findFirst(items: Column<any>[]): Column<any, unknown>;
|
|
140
139
|
export declare function isTreeArray(arr: any[], options?: any): boolean;
|
|
141
140
|
export declare function updateColumnWidthsRecursive(columns: any[], sizing: Record<string, number>): any[];
|
|
@@ -47,7 +47,6 @@ exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
|
|
|
47
47
|
exports.isEqualSet = isEqualSet;
|
|
48
48
|
exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isFormattedNumber = void 0;
|
|
49
49
|
exports.isObjEqual = isObjEqual;
|
|
50
|
-
exports.isTree = isTree;
|
|
51
50
|
exports.isTreeArray = isTreeArray;
|
|
52
51
|
exports.parseBooleanToValue = exports.onRemoveBgSelectedCell = exports.onAddBgSelectedCell = exports.newGuid = void 0;
|
|
53
52
|
exports.parseClipboardEvent = parseClipboardEvent;
|
|
@@ -2024,77 +2023,69 @@ exports.convertToObjTrue = convertToObjTrue;
|
|
|
2024
2023
|
const getDiffent2Array = (a, b) => {
|
|
2025
2024
|
return [...a.filter(x => !b.includes(x)), ...b.filter(x => !a.includes(x))];
|
|
2026
2025
|
};
|
|
2027
|
-
exports.getDiffent2Array = getDiffent2Array;
|
|
2028
|
-
function isTree(arr) {
|
|
2029
|
-
if (!Array.isArray(arr)) {
|
|
2030
|
-
return false;
|
|
2031
|
-
}
|
|
2032
|
-
function checkNode(node) {
|
|
2033
|
-
if (typeof node !== "object" || node === null) {
|
|
2034
|
-
return false;
|
|
2035
|
-
}
|
|
2036
|
-
if ("children" in node) {
|
|
2037
|
-
if (!Array.isArray(node.children)) {
|
|
2038
|
-
return false;
|
|
2039
|
-
}
|
|
2040
|
-
if (node.children.length === 0) {
|
|
2041
|
-
return false;
|
|
2042
|
-
}
|
|
2043
|
-
for (const child of node.children) {
|
|
2044
|
-
if (!checkNode(child)) {
|
|
2045
|
-
return false;
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
return true;
|
|
2050
|
-
}
|
|
2051
|
-
for (const item of arr) {
|
|
2052
|
-
if (!checkNode(item)) return false;
|
|
2053
|
-
}
|
|
2054
|
-
return true;
|
|
2055
|
-
}
|
|
2056
|
-
function findFirst(items) {
|
|
2057
|
-
const leftItem = items.find(item => item.getIsPinned() === 'left');
|
|
2058
|
-
if (leftItem) return leftItem;
|
|
2059
|
-
return null;
|
|
2060
|
-
}
|
|
2061
2026
|
|
|
2062
|
-
// export function
|
|
2027
|
+
// export function isTree(arr: any[]): boolean {
|
|
2028
|
+
// if (!Array.isArray(arr)){
|
|
2029
|
+
// return false
|
|
2030
|
+
// }
|
|
2063
2031
|
|
|
2064
|
-
//
|
|
2032
|
+
// function checkNode(node: any): boolean {
|
|
2033
|
+
// if (typeof node !== "object" || node === null) {
|
|
2034
|
+
// return false
|
|
2035
|
+
// }
|
|
2065
2036
|
|
|
2066
|
-
//
|
|
2067
|
-
// // if ("children" in item) {
|
|
2068
|
-
// // return Array.isArray(item.children) && item.children.length > 0;
|
|
2069
|
-
// // }
|
|
2070
|
-
// // return true; // node lá thì hợp lệ
|
|
2071
|
-
// // });
|
|
2037
|
+
// if ("children" in node) {
|
|
2072
2038
|
|
|
2073
|
-
//
|
|
2039
|
+
// if (!Array.isArray(node.children)) {
|
|
2040
|
+
// return false
|
|
2041
|
+
// }
|
|
2042
|
+
// if (node.children.length === 0) {
|
|
2043
|
+
// return false
|
|
2044
|
+
// }
|
|
2074
2045
|
|
|
2075
|
-
//
|
|
2076
|
-
//
|
|
2046
|
+
// for (const child of node.children) {
|
|
2047
|
+
// if (!checkNode(child)) {
|
|
2048
|
+
// return false
|
|
2049
|
+
// }
|
|
2050
|
+
// }
|
|
2077
2051
|
|
|
2078
|
-
// if ("children" in item) {
|
|
2079
|
-
// return Array.isArray(item.children);
|
|
2080
2052
|
// }
|
|
2081
2053
|
|
|
2082
|
-
// return
|
|
2083
|
-
// }
|
|
2054
|
+
// return true;
|
|
2055
|
+
// }
|
|
2084
2056
|
|
|
2085
|
-
//
|
|
2057
|
+
// for (const item of arr) {
|
|
2058
|
+
// if (!checkNode(item)) return false;
|
|
2059
|
+
// }
|
|
2086
2060
|
|
|
2061
|
+
// return true;
|
|
2062
|
+
// }
|
|
2063
|
+
exports.getDiffent2Array = getDiffent2Array;
|
|
2064
|
+
function findFirst(items) {
|
|
2065
|
+
const leftItem = items.find(item => item.getIsPinned() === 'left');
|
|
2066
|
+
if (leftItem) return leftItem;
|
|
2067
|
+
return null;
|
|
2068
|
+
}
|
|
2087
2069
|
function isTreeArray(arr, options) {
|
|
2088
|
-
if (!Array.isArray(arr) || arr.length === 0)
|
|
2070
|
+
if (!Array.isArray(arr) || arr.length === 0) {
|
|
2071
|
+
return false;
|
|
2072
|
+
}
|
|
2089
2073
|
const requireNonEmpty = options?.requireNonEmptyChildren ?? false;
|
|
2090
2074
|
let hasParent = false;
|
|
2091
2075
|
for (const item of arr) {
|
|
2092
|
-
if (typeof item !== 'object' || item === null)
|
|
2076
|
+
if (typeof item !== 'object' || item === null) {
|
|
2077
|
+
return false;
|
|
2078
|
+
}
|
|
2093
2079
|
if ('children' in item) {
|
|
2094
2080
|
const children = item.children;
|
|
2095
|
-
if (!Array.isArray(children))
|
|
2081
|
+
if (!Array.isArray(children)) {
|
|
2082
|
+
// return false;
|
|
2083
|
+
hasParent = false;
|
|
2084
|
+
}
|
|
2096
2085
|
if (requireNonEmpty) {
|
|
2097
|
-
if (children.length > 0)
|
|
2086
|
+
if (children.length > 0) {
|
|
2087
|
+
hasParent = true;
|
|
2088
|
+
}
|
|
2098
2089
|
} else {
|
|
2099
2090
|
hasParent = true;
|
|
2100
2091
|
}
|
|
@@ -135,8 +135,8 @@ const Grid = props => {
|
|
|
135
135
|
// ColumnSorting
|
|
136
136
|
// getSortedRowModel: getSortedRowModel(),
|
|
137
137
|
onSortingChange: setSorting,
|
|
138
|
-
enableMultiSort: sortMultiple,
|
|
139
|
-
isMultiSortEvent: () => sortMultiple ?
|
|
138
|
+
enableMultiSort: sortMultiple !== false,
|
|
139
|
+
isMultiSortEvent: () => sortMultiple === false ? false : true,
|
|
140
140
|
enableSorting: allowSortering !== false,
|
|
141
141
|
// ColumnSorting
|
|
142
142
|
|
|
@@ -77,6 +77,7 @@ export interface IContext<T> {
|
|
|
77
77
|
pagination?: false | PaginationConfig;
|
|
78
78
|
rowClassName?: string | RowClassName<T>;
|
|
79
79
|
table?: Table<T>;
|
|
80
|
+
rowEditable?: (rowData: T) => boolean;
|
|
80
81
|
}
|
|
81
82
|
export declare const TableContext: import("react").Context<IContext<any>>;
|
|
82
83
|
export type ContextCellChange = {
|