es-grid-template 1.5.1 → 1.5.2
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/ColumnsChoose.js +1 -1
- package/es/grid-component/EditableCell.js +14 -12
- package/es/grid-component/InternalTable.d.ts +0 -2
- package/es/grid-component/InternalTable.js +11 -5
- package/es/grid-component/async-select/index.d.ts +4 -2
- package/es/grid-component/async-select/index.js +3 -0
- package/es/grid-component/async-table-select/index.d.ts +4 -2
- package/es/grid-component/async-table-select/index.js +4 -1
- package/es/grid-component/hooks/columns/index.js +1 -1
- package/es/grid-component/hooks/utils.d.ts +1 -0
- package/es/grid-component/hooks/utils.js +40 -1
- package/es/grid-component/table/GridEdit.js +9 -2
- package/es/grid-component/table/Group.js +10 -1
- package/es/grid-component/type.d.ts +9 -0
- package/es/grid-component/useContext.d.ts +1 -0
- package/es/grid-component/useContext.js +2 -1
- package/lib/grid-component/ColumnsChoose.js +1 -1
- package/lib/grid-component/EditableCell.js +14 -12
- package/lib/grid-component/InternalTable.d.ts +0 -2
- package/lib/grid-component/InternalTable.js +10 -4
- package/lib/grid-component/async-select/index.d.ts +4 -2
- package/lib/grid-component/async-select/index.js +3 -0
- package/lib/grid-component/async-table-select/index.d.ts +4 -2
- package/lib/grid-component/async-table-select/index.js +4 -1
- package/lib/grid-component/hooks/columns/index.js +1 -1
- package/lib/grid-component/hooks/utils.d.ts +1 -0
- package/lib/grid-component/hooks/utils.js +45 -4
- package/lib/grid-component/table/GridEdit.js +9 -2
- package/lib/grid-component/table/Group.js +10 -1
- package/lib/grid-component/type.d.ts +9 -0
- package/lib/grid-component/useContext.d.ts +1 -0
- package/lib/grid-component/useContext.js +2 -1
- package/package.json +5 -5
|
@@ -489,7 +489,7 @@ export const ColumnsChoose = props => {
|
|
|
489
489
|
autoExpandParent: autoExpandParent
|
|
490
490
|
// treeData={treeData}
|
|
491
491
|
,
|
|
492
|
-
treeData: columns,
|
|
492
|
+
treeData: columns.filter(it => !columnsGroup?.includes(it.field)),
|
|
493
493
|
defaultExpandAll: true,
|
|
494
494
|
checkable: true
|
|
495
495
|
// onSelect={(keys, info) => {
|
|
@@ -61,7 +61,8 @@ const EditableCell = props => {
|
|
|
61
61
|
getValues,
|
|
62
62
|
handleCellChange,
|
|
63
63
|
getRowKey,
|
|
64
|
-
errors
|
|
64
|
+
errors,
|
|
65
|
+
id
|
|
65
66
|
} = useContext(TableContext);
|
|
66
67
|
const datePickerRef = React.useRef(null);
|
|
67
68
|
const dateTimePickerRef = React.useRef(null);
|
|
@@ -160,7 +161,7 @@ const EditableCell = props => {
|
|
|
160
161
|
popupClassName: 'be-popup-container',
|
|
161
162
|
status: isInvalid ? 'error' : undefined,
|
|
162
163
|
"data-tooltip-content": message,
|
|
163
|
-
"data-tooltip-id":
|
|
164
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
164
165
|
});
|
|
165
166
|
case 'datetime':
|
|
166
167
|
return /*#__PURE__*/React.createElement(DatePicker
|
|
@@ -216,7 +217,7 @@ const EditableCell = props => {
|
|
|
216
217
|
popupClassName: 'be-popup-container',
|
|
217
218
|
status: isInvalid ? 'error' : undefined,
|
|
218
219
|
"data-tooltip-content": message,
|
|
219
|
-
"data-tooltip-id":
|
|
220
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
220
221
|
});
|
|
221
222
|
case 'month':
|
|
222
223
|
case 'quarter':
|
|
@@ -242,7 +243,7 @@ const EditableCell = props => {
|
|
|
242
243
|
popupClassName: 'be-popup-container',
|
|
243
244
|
status: isInvalid ? 'error' : undefined,
|
|
244
245
|
"data-tooltip-content": message,
|
|
245
|
-
"data-tooltip-id":
|
|
246
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
246
247
|
});
|
|
247
248
|
case 'week':
|
|
248
249
|
const weekFormat = getDatepickerFormat(editType, cellFormat);
|
|
@@ -262,7 +263,7 @@ const EditableCell = props => {
|
|
|
262
263
|
popupClassName: 'be-popup-container',
|
|
263
264
|
status: isInvalid ? 'error' : undefined,
|
|
264
265
|
"data-tooltip-content": message,
|
|
265
|
-
"data-tooltip-id":
|
|
266
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
266
267
|
});
|
|
267
268
|
case 'time':
|
|
268
269
|
const timeFormat = getDatepickerFormat(editType, cellFormat);
|
|
@@ -289,7 +290,7 @@ const EditableCell = props => {
|
|
|
289
290
|
popupClassName: 'be-popup-container',
|
|
290
291
|
status: isInvalid ? 'error' : undefined,
|
|
291
292
|
"data-tooltip-content": message,
|
|
292
|
-
"data-tooltip-id":
|
|
293
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
293
294
|
});
|
|
294
295
|
case 'selectTable':
|
|
295
296
|
const rr = selectColumns ?? [];
|
|
@@ -327,6 +328,7 @@ const EditableCell = props => {
|
|
|
327
328
|
options: options,
|
|
328
329
|
defaultOptions: options,
|
|
329
330
|
value: valueSelectTable,
|
|
331
|
+
rowData: record,
|
|
330
332
|
onChange: (val, option) => {
|
|
331
333
|
onChange(val ?? '');
|
|
332
334
|
const formState = getValues();
|
|
@@ -396,7 +398,7 @@ const EditableCell = props => {
|
|
|
396
398
|
label: inputKey ?? 'label'
|
|
397
399
|
},
|
|
398
400
|
"data-tooltip-content": message,
|
|
399
|
-
"data-tooltip-id":
|
|
401
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
400
402
|
});
|
|
401
403
|
case 'select':
|
|
402
404
|
let valueSelect = value;
|
|
@@ -454,7 +456,7 @@ const EditableCell = props => {
|
|
|
454
456
|
label: inputKey ?? 'label'
|
|
455
457
|
},
|
|
456
458
|
"data-tooltip-content": message,
|
|
457
|
-
"data-tooltip-id":
|
|
459
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
458
460
|
});
|
|
459
461
|
case 'asyncSelect':
|
|
460
462
|
let valueAsyncSelect = value;
|
|
@@ -551,7 +553,7 @@ const EditableCell = props => {
|
|
|
551
553
|
label: inputKey ?? 'label'
|
|
552
554
|
},
|
|
553
555
|
"data-tooltip-content": message,
|
|
554
|
-
"data-tooltip-id":
|
|
556
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
555
557
|
});
|
|
556
558
|
case 'treeSelect':
|
|
557
559
|
// let valueTreeSelect
|
|
@@ -624,7 +626,7 @@ const EditableCell = props => {
|
|
|
624
626
|
popupClassName: 'be-popup-container',
|
|
625
627
|
status: isInvalid ? 'error' : undefined,
|
|
626
628
|
"data-tooltip-content": message,
|
|
627
|
-
"data-tooltip-id":
|
|
629
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
628
630
|
});
|
|
629
631
|
case 'checkbox':
|
|
630
632
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -847,7 +849,7 @@ const EditableCell = props => {
|
|
|
847
849
|
}
|
|
848
850
|
},
|
|
849
851
|
"data-tooltip-content": message,
|
|
850
|
-
"data-tooltip-id":
|
|
852
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
851
853
|
}));
|
|
852
854
|
default:
|
|
853
855
|
return /*#__PURE__*/React.createElement(Input, {
|
|
@@ -910,7 +912,7 @@ const EditableCell = props => {
|
|
|
910
912
|
onChange: onChange,
|
|
911
913
|
status: isInvalid ? 'error' : undefined,
|
|
912
914
|
"data-tooltip-content": message,
|
|
913
|
-
"data-tooltip-id":
|
|
915
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
914
916
|
});
|
|
915
917
|
}
|
|
916
918
|
};
|
|
@@ -4,8 +4,6 @@ import type { GridTableProps } from "./type";
|
|
|
4
4
|
import 'dayjs/locale/es';
|
|
5
5
|
import 'dayjs/locale/vi';
|
|
6
6
|
import './styles.scss';
|
|
7
|
-
import 'rc-master-ui/es/date-range-picker/styles/index.less';
|
|
8
|
-
import 'rc-master-ui/assets/index.css';
|
|
9
7
|
export declare const SELECTION_COLUMN: {};
|
|
10
8
|
declare const InternalTable: <RecordType extends object>(props: GridTableProps<RecordType>) => React.JSX.Element;
|
|
11
9
|
export default InternalTable;
|
|
@@ -3,7 +3,7 @@ import React, { createContext, Fragment, useCallback, useContext, useState } fro
|
|
|
3
3
|
// import {Resizable} from "react-resizable";
|
|
4
4
|
import 'react-resizable/css/styles.css';
|
|
5
5
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
6
|
-
import { addRowIdArray, booleanOperator, findItemByKey, findItemPath, getFormat, getTypeFilter, numberOperator, removeColumns, stringOperator, translateOption, updateArrayByKey, updateColumnsByGroup, updateData } from "./hooks";
|
|
6
|
+
import { addRowIdArray, booleanOperator, findItemByKey, findItemPath, getFormat, getTypeFilter, groupArrayByColumns, numberOperator, removeColumns, stringOperator, translateOption, updateArrayByKey, updateColumnsByGroup, updateData } from "./hooks";
|
|
7
7
|
import dayjs from "dayjs";
|
|
8
8
|
import 'dayjs/locale/es';
|
|
9
9
|
import 'dayjs/locale/vi';
|
|
@@ -16,8 +16,8 @@ import viDr from "rc-master-ui/es/locales/vi_VN";
|
|
|
16
16
|
// import useColumns from "./hooks/useColumns";
|
|
17
17
|
|
|
18
18
|
import "./styles.scss";
|
|
19
|
-
import 'rc-master-ui/
|
|
20
|
-
|
|
19
|
+
// import 'rc-master-ui/assets/index.css'
|
|
20
|
+
|
|
21
21
|
import { flatColumns2, renderContent, renderFilter } from "./hooks/columns";
|
|
22
22
|
import Group from "./table/Group";
|
|
23
23
|
import Swal from "sweetalert2";
|
|
@@ -224,8 +224,13 @@ const InternalTable = props => {
|
|
|
224
224
|
});
|
|
225
225
|
const [tooltipContent, setTooltipContent] = useState('');
|
|
226
226
|
const mergedData = React.useMemo(() => {
|
|
227
|
+
// return addRowIdArray(dataSource)
|
|
228
|
+
|
|
229
|
+
if (groupSetting && groupSetting.client !== false) {
|
|
230
|
+
return groupArrayByColumns(dataSource, groupColumns);
|
|
231
|
+
}
|
|
227
232
|
return addRowIdArray(dataSource);
|
|
228
|
-
}, [dataSource]);
|
|
233
|
+
}, [dataSource, groupColumns, groupSetting]);
|
|
229
234
|
const [columns, setColumns] = React.useState([]);
|
|
230
235
|
React.useEffect(() => {
|
|
231
236
|
if (propsHeight) {
|
|
@@ -496,7 +501,8 @@ const InternalTable = props => {
|
|
|
496
501
|
'cell-group': groupColumns && data.children,
|
|
497
502
|
'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field
|
|
498
503
|
}),
|
|
499
|
-
'data-tooltip-id': "tooltip-cell-content"
|
|
504
|
+
// 'data-tooltip-id': "tooltip-cell-content"
|
|
505
|
+
'data-tooltip-id': `${id}-tooltip-cell-content`
|
|
500
506
|
};
|
|
501
507
|
},
|
|
502
508
|
render: (value, record, rowIndex) => {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
3
|
import type { SelectProps } from "rc-master-ui/es/select";
|
|
4
|
+
import type { LoadOptionsArgs } from "../type";
|
|
4
5
|
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends SelectProps {
|
|
5
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
|
|
6
|
+
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
6
7
|
debounceTimeout?: number;
|
|
7
8
|
defaultOptions?: OptionType[];
|
|
9
|
+
rowData?: any;
|
|
8
10
|
}
|
|
9
|
-
export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
11
|
+
export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -6,6 +6,7 @@ export function AsyncSelect({
|
|
|
6
6
|
loadOptions,
|
|
7
7
|
debounceTimeout = 500,
|
|
8
8
|
defaultOptions,
|
|
9
|
+
rowData,
|
|
9
10
|
...props
|
|
10
11
|
}) {
|
|
11
12
|
const [options, setOptions] = useState(defaultOptions ?? []);
|
|
@@ -18,6 +19,8 @@ export function AsyncSelect({
|
|
|
18
19
|
if (loadOptions) {
|
|
19
20
|
loadOptions(value, newOptions => {
|
|
20
21
|
setOptions(newOptions);
|
|
22
|
+
}, {
|
|
23
|
+
rowData
|
|
21
24
|
});
|
|
22
25
|
}
|
|
23
26
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
3
|
import type { TableSelectProps } from "rc-master-ui/es/table-select";
|
|
4
|
+
import type { LoadOptionsArgs } from "../type";
|
|
4
5
|
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
|
|
5
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
|
|
6
|
+
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
6
7
|
debounceTimeout?: number;
|
|
7
8
|
defaultOptions?: OptionType[];
|
|
9
|
+
rowData?: any;
|
|
8
10
|
}
|
|
9
|
-
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
11
|
+
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -7,6 +7,7 @@ export function AsyncTableSelect({
|
|
|
7
7
|
debounceTimeout = 500,
|
|
8
8
|
defaultOptions,
|
|
9
9
|
columns,
|
|
10
|
+
rowData,
|
|
10
11
|
...props
|
|
11
12
|
}) {
|
|
12
13
|
const [options, setOptions] = useState(defaultOptions ?? []);
|
|
@@ -19,11 +20,13 @@ export function AsyncTableSelect({
|
|
|
19
20
|
if (loadOptions) {
|
|
20
21
|
loadOptions(value, newOptions => {
|
|
21
22
|
setOptions(newOptions);
|
|
23
|
+
}, {
|
|
24
|
+
rowData
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
27
|
};
|
|
25
28
|
return debounce(fetchOptions, debounceTimeout);
|
|
26
|
-
}, [loadOptions,
|
|
29
|
+
}, [debounceTimeout, loadOptions, defaultOptions, rowData]);
|
|
27
30
|
useEffect(() => {
|
|
28
31
|
setOptions(defaultOptions ?? []);
|
|
29
32
|
}, [defaultOptions]);
|
|
@@ -189,7 +189,7 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
189
189
|
format: dateRangeFormat,
|
|
190
190
|
value: dateRangeValue,
|
|
191
191
|
onChange: value => {
|
|
192
|
-
const newDateRangeValue = value ? [value[0] ? moment(value[0]).format() : '', value[1] ? moment(value[
|
|
192
|
+
const newDateRangeValue = value ? [value[0] ? moment(value[0]).format() : '', value[1] ? moment(value[1]).format() : ''] : [];
|
|
193
193
|
setSelectedKeys(newDateRangeValue);
|
|
194
194
|
}
|
|
195
195
|
})))));
|
|
@@ -143,3 +143,4 @@ export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
|
|
|
143
143
|
export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
|
|
144
144
|
export declare const isRangeCell: (selectedCells: any, type: string, rowIndex: number, colIndex: number) => boolean;
|
|
145
145
|
export declare const isSelectedCell: (selectedCells: any, rowIndex: number, colIndex: number) => any;
|
|
146
|
+
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
|
|
@@ -2029,4 +2029,43 @@ export const isSelectedCell = (selectedCells, rowIndex, colIndex) => {
|
|
|
2029
2029
|
}
|
|
2030
2030
|
const key = `${rowIndex}-${colIndex}`;
|
|
2031
2031
|
return selectedCells.has(key);
|
|
2032
|
-
};
|
|
2032
|
+
};
|
|
2033
|
+
export function groupArrayByColumns(arr, columns) {
|
|
2034
|
+
const result = [];
|
|
2035
|
+
if (columns) {
|
|
2036
|
+
arr.forEach(item => {
|
|
2037
|
+
let currentLevel = result;
|
|
2038
|
+
columns.forEach((column, index) => {
|
|
2039
|
+
const value = item[column];
|
|
2040
|
+
const existingItem = currentLevel.find(i => i[column] === value);
|
|
2041
|
+
if (existingItem) {
|
|
2042
|
+
currentLevel = existingItem.children;
|
|
2043
|
+
} else {
|
|
2044
|
+
// const newItem = {[column]: value, field: column, rowId: !isEmpty(value) ? (value) : newGuid(), parentId: !isEmpty(item[columns[index - 1]]) ? (item[columns[index - 1]]) : null, indent: index, children: [] }
|
|
2045
|
+
const newItem = {
|
|
2046
|
+
[column]: value,
|
|
2047
|
+
field: column,
|
|
2048
|
+
rowId: newGuid(),
|
|
2049
|
+
// rowId: item[column],
|
|
2050
|
+
parentId: !isEmpty(item[columns[index - 1]]) ? item[columns[index - 1]] : null,
|
|
2051
|
+
// parentId: item.rowId[index - 1],
|
|
2052
|
+
// indent: index,
|
|
2053
|
+
children: []
|
|
2054
|
+
};
|
|
2055
|
+
currentLevel.push(newItem);
|
|
2056
|
+
currentLevel = newItem.children;
|
|
2057
|
+
}
|
|
2058
|
+
});
|
|
2059
|
+
currentLevel.push({
|
|
2060
|
+
...item,
|
|
2061
|
+
rowId: item.id ?? item.rowId,
|
|
2062
|
+
parentId: !isEmpty(columns[columns.length - 1]) ? item[columns[columns.length - 1]] : null,
|
|
2063
|
+
// parentId: item.rowId[columns.length - 1],
|
|
2064
|
+
indent: columns.length
|
|
2065
|
+
});
|
|
2066
|
+
});
|
|
2067
|
+
return result;
|
|
2068
|
+
} else {
|
|
2069
|
+
return arr;
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
@@ -207,6 +207,7 @@ const GridEdit = props => {
|
|
|
207
207
|
showDefaultContext,
|
|
208
208
|
validate,
|
|
209
209
|
setTooltipContent,
|
|
210
|
+
onBlur,
|
|
210
211
|
...rest
|
|
211
212
|
} = props;
|
|
212
213
|
const ref = useRef(null);
|
|
@@ -990,6 +991,9 @@ const GridEdit = props => {
|
|
|
990
991
|
// if (ref.current && tableId && !tableId.contains(event.target as Node)) {
|
|
991
992
|
|
|
992
993
|
if (ref.current && tableBody && !tableBody.contains(event.target)) {
|
|
994
|
+
if (editingKey.current) {
|
|
995
|
+
onBlur?.(dataSource);
|
|
996
|
+
}
|
|
993
997
|
setTimeout(() => {
|
|
994
998
|
// setEditingKey('')
|
|
995
999
|
editingKey.current = '';
|
|
@@ -1017,7 +1021,7 @@ const GridEdit = props => {
|
|
|
1017
1021
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
1018
1022
|
// document.removeEventListener('touchstart', handleClickOutside)
|
|
1019
1023
|
};
|
|
1020
|
-
}, [id]);
|
|
1024
|
+
}, [dataSource, id, onBlur]);
|
|
1021
1025
|
const triggerDragPaste = pastesArray => {
|
|
1022
1026
|
const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
|
|
1023
1027
|
const tmpCols = {
|
|
@@ -1434,6 +1438,7 @@ const GridEdit = props => {
|
|
|
1434
1438
|
setTimeout(() => {
|
|
1435
1439
|
// setEditingKey('')
|
|
1436
1440
|
editingKey.current = '';
|
|
1441
|
+
onBlur?.(dataSource);
|
|
1437
1442
|
});
|
|
1438
1443
|
}
|
|
1439
1444
|
|
|
@@ -2268,7 +2273,8 @@ const GridEdit = props => {
|
|
|
2268
2273
|
title: getValueCell(column, record[column.field], format),
|
|
2269
2274
|
'data-col-index': colIndex,
|
|
2270
2275
|
'data-row-index': rowNumber,
|
|
2271
|
-
'data-tooltip-id': "tooltip-cell-content",
|
|
2276
|
+
// 'data-tooltip-id': "tooltip-cell-content",
|
|
2277
|
+
'data-tooltip-id': `${id}-tooltip-cell-content`,
|
|
2272
2278
|
// editing: isEditing(record) && rowEditable?.(record) !== false && isEditable(column as any, record),
|
|
2273
2279
|
editing: record.rowId === editingKey.current && rowEditable?.(record) !== false && isEditable(column, record),
|
|
2274
2280
|
cellEditing: cellEditing.current,
|
|
@@ -2491,6 +2497,7 @@ const GridEdit = props => {
|
|
|
2491
2497
|
id: id
|
|
2492
2498
|
}, /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
2493
2499
|
value: {
|
|
2500
|
+
id: id ?? '',
|
|
2494
2501
|
rowKey,
|
|
2495
2502
|
form,
|
|
2496
2503
|
format,
|
|
@@ -20,10 +20,12 @@ const Group = props => {
|
|
|
20
20
|
groupAble,
|
|
21
21
|
expandable,
|
|
22
22
|
dataSource,
|
|
23
|
+
rowKey,
|
|
23
24
|
getRowKey,
|
|
24
25
|
groupSetting,
|
|
25
26
|
groupColumns,
|
|
26
27
|
triggerGroupColumns,
|
|
28
|
+
onExpandClick,
|
|
27
29
|
...rest
|
|
28
30
|
} = props;
|
|
29
31
|
const {
|
|
@@ -59,9 +61,15 @@ const Group = props => {
|
|
|
59
61
|
} else {
|
|
60
62
|
newExpandedKeys = [...mergedExpandedKeys, key];
|
|
61
63
|
// gọi sự kiện expand
|
|
64
|
+
|
|
65
|
+
onExpandClick?.({
|
|
66
|
+
expandedKeys: newExpandedKeys,
|
|
67
|
+
key: key,
|
|
68
|
+
rowData: record
|
|
69
|
+
});
|
|
62
70
|
}
|
|
63
71
|
setInnerExpandedKeys(newExpandedKeys);
|
|
64
|
-
}, [getRowKey, mergedExpandedKeys,
|
|
72
|
+
}, [getRowKey, dataSource, mergedExpandedKeys, onExpandClick]);
|
|
65
73
|
const handleExpandAllGroup = () => {
|
|
66
74
|
setInnerExpandedKeys(findAllChildrenKeys(dataSource, getRowKey, childrenColumnName) ?? []);
|
|
67
75
|
};
|
|
@@ -108,6 +116,7 @@ const Group = props => {
|
|
|
108
116
|
}, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
|
|
109
117
|
t: t,
|
|
110
118
|
id: id,
|
|
119
|
+
rowKey: rowKey,
|
|
111
120
|
columns: columns,
|
|
112
121
|
style: {
|
|
113
122
|
...style,
|
|
@@ -84,6 +84,9 @@ export type ToolbarClick = {
|
|
|
84
84
|
item: any;
|
|
85
85
|
column: any;
|
|
86
86
|
};
|
|
87
|
+
export type LoadOptionsArgs = {
|
|
88
|
+
rowData?: any;
|
|
89
|
+
};
|
|
87
90
|
export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>, 'headerTemplate' | 'title' | 'format' | 'commandItems'> & {
|
|
88
91
|
field?: string;
|
|
89
92
|
key?: any;
|
|
@@ -195,6 +198,12 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
|
|
|
195
198
|
onCellClick?: (args: ICellClick, callback?: any) => void;
|
|
196
199
|
rowEditable?: (rowData: RecordType) => boolean;
|
|
197
200
|
validate?: any;
|
|
201
|
+
onBlur?: (data: RecordType[]) => void;
|
|
202
|
+
onExpandClick?: (args: {
|
|
203
|
+
expandedKeys: string[];
|
|
204
|
+
key: string;
|
|
205
|
+
rowData: any;
|
|
206
|
+
}) => void;
|
|
198
207
|
}
|
|
199
208
|
export type PaginationConfig = TablePaginationConfig & {
|
|
200
209
|
currentPage?: number;
|
|
@@ -19,6 +19,7 @@ export interface IContext<RecordType> {
|
|
|
19
19
|
getValues?: any;
|
|
20
20
|
handleCellChange?: (args: ContextCellChange<RecordType>) => void;
|
|
21
21
|
getRowKey?: GetRowKey<RecordType>;
|
|
22
|
+
id: string;
|
|
22
23
|
}
|
|
23
24
|
export type ContextCellChange<RecordType = AnyObject> = {
|
|
24
25
|
key: string | keyof RecordType | GetRowKey<RecordType>;
|
|
@@ -498,7 +498,7 @@ const ColumnsChoose = props => {
|
|
|
498
498
|
autoExpandParent: autoExpandParent
|
|
499
499
|
// treeData={treeData}
|
|
500
500
|
,
|
|
501
|
-
treeData: columns,
|
|
501
|
+
treeData: columns.filter(it => !columnsGroup?.includes(it.field)),
|
|
502
502
|
defaultExpandAll: true,
|
|
503
503
|
checkable: true
|
|
504
504
|
// onSelect={(keys, info) => {
|
|
@@ -63,7 +63,8 @@ const EditableCell = props => {
|
|
|
63
63
|
getValues,
|
|
64
64
|
handleCellChange,
|
|
65
65
|
getRowKey,
|
|
66
|
-
errors
|
|
66
|
+
errors,
|
|
67
|
+
id
|
|
67
68
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
68
69
|
const datePickerRef = _react.default.useRef(null);
|
|
69
70
|
const dateTimePickerRef = _react.default.useRef(null);
|
|
@@ -162,7 +163,7 @@ const EditableCell = props => {
|
|
|
162
163
|
popupClassName: 'be-popup-container',
|
|
163
164
|
status: isInvalid ? 'error' : undefined,
|
|
164
165
|
"data-tooltip-content": message,
|
|
165
|
-
"data-tooltip-id":
|
|
166
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
166
167
|
});
|
|
167
168
|
case 'datetime':
|
|
168
169
|
return /*#__PURE__*/_react.default.createElement(_antd.DatePicker
|
|
@@ -218,7 +219,7 @@ const EditableCell = props => {
|
|
|
218
219
|
popupClassName: 'be-popup-container',
|
|
219
220
|
status: isInvalid ? 'error' : undefined,
|
|
220
221
|
"data-tooltip-content": message,
|
|
221
|
-
"data-tooltip-id":
|
|
222
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
222
223
|
});
|
|
223
224
|
case 'month':
|
|
224
225
|
case 'quarter':
|
|
@@ -244,7 +245,7 @@ const EditableCell = props => {
|
|
|
244
245
|
popupClassName: 'be-popup-container',
|
|
245
246
|
status: isInvalid ? 'error' : undefined,
|
|
246
247
|
"data-tooltip-content": message,
|
|
247
|
-
"data-tooltip-id":
|
|
248
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
248
249
|
});
|
|
249
250
|
case 'week':
|
|
250
251
|
const weekFormat = (0, _hooks.getDatepickerFormat)(editType, cellFormat);
|
|
@@ -264,7 +265,7 @@ const EditableCell = props => {
|
|
|
264
265
|
popupClassName: 'be-popup-container',
|
|
265
266
|
status: isInvalid ? 'error' : undefined,
|
|
266
267
|
"data-tooltip-content": message,
|
|
267
|
-
"data-tooltip-id":
|
|
268
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
268
269
|
});
|
|
269
270
|
case 'time':
|
|
270
271
|
const timeFormat = (0, _hooks.getDatepickerFormat)(editType, cellFormat);
|
|
@@ -291,7 +292,7 @@ const EditableCell = props => {
|
|
|
291
292
|
popupClassName: 'be-popup-container',
|
|
292
293
|
status: isInvalid ? 'error' : undefined,
|
|
293
294
|
"data-tooltip-content": message,
|
|
294
|
-
"data-tooltip-id":
|
|
295
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
295
296
|
});
|
|
296
297
|
case 'selectTable':
|
|
297
298
|
const rr = selectColumns ?? [];
|
|
@@ -329,6 +330,7 @@ const EditableCell = props => {
|
|
|
329
330
|
options: options,
|
|
330
331
|
defaultOptions: options,
|
|
331
332
|
value: valueSelectTable,
|
|
333
|
+
rowData: record,
|
|
332
334
|
onChange: (val, option) => {
|
|
333
335
|
onChange(val ?? '');
|
|
334
336
|
const formState = getValues();
|
|
@@ -398,7 +400,7 @@ const EditableCell = props => {
|
|
|
398
400
|
label: inputKey ?? 'label'
|
|
399
401
|
},
|
|
400
402
|
"data-tooltip-content": message,
|
|
401
|
-
"data-tooltip-id":
|
|
403
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
402
404
|
});
|
|
403
405
|
case 'select':
|
|
404
406
|
let valueSelect = value;
|
|
@@ -456,7 +458,7 @@ const EditableCell = props => {
|
|
|
456
458
|
label: inputKey ?? 'label'
|
|
457
459
|
},
|
|
458
460
|
"data-tooltip-content": message,
|
|
459
|
-
"data-tooltip-id":
|
|
461
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
460
462
|
});
|
|
461
463
|
case 'asyncSelect':
|
|
462
464
|
let valueAsyncSelect = value;
|
|
@@ -553,7 +555,7 @@ const EditableCell = props => {
|
|
|
553
555
|
label: inputKey ?? 'label'
|
|
554
556
|
},
|
|
555
557
|
"data-tooltip-content": message,
|
|
556
|
-
"data-tooltip-id":
|
|
558
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
557
559
|
});
|
|
558
560
|
case 'treeSelect':
|
|
559
561
|
// let valueTreeSelect
|
|
@@ -626,7 +628,7 @@ const EditableCell = props => {
|
|
|
626
628
|
popupClassName: 'be-popup-container',
|
|
627
629
|
status: isInvalid ? 'error' : undefined,
|
|
628
630
|
"data-tooltip-content": message,
|
|
629
|
-
"data-tooltip-id":
|
|
631
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
630
632
|
});
|
|
631
633
|
case 'checkbox':
|
|
632
634
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -849,7 +851,7 @@ const EditableCell = props => {
|
|
|
849
851
|
}
|
|
850
852
|
},
|
|
851
853
|
"data-tooltip-content": message,
|
|
852
|
-
"data-tooltip-id":
|
|
854
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
853
855
|
}));
|
|
854
856
|
default:
|
|
855
857
|
return /*#__PURE__*/_react.default.createElement(_antd.Input, {
|
|
@@ -912,7 +914,7 @@ const EditableCell = props => {
|
|
|
912
914
|
onChange: onChange,
|
|
913
915
|
status: isInvalid ? 'error' : undefined,
|
|
914
916
|
"data-tooltip-content": message,
|
|
915
|
-
"data-tooltip-id":
|
|
917
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
916
918
|
});
|
|
917
919
|
}
|
|
918
920
|
};
|
|
@@ -4,8 +4,6 @@ import type { GridTableProps } from "./type";
|
|
|
4
4
|
import 'dayjs/locale/es';
|
|
5
5
|
import 'dayjs/locale/vi';
|
|
6
6
|
import './styles.scss';
|
|
7
|
-
import 'rc-master-ui/es/date-range-picker/styles/index.less';
|
|
8
|
-
import 'rc-master-ui/assets/index.css';
|
|
9
7
|
export declare const SELECTION_COLUMN: {};
|
|
10
8
|
declare const InternalTable: <RecordType extends object>(props: GridTableProps<RecordType>) => React.JSX.Element;
|
|
11
9
|
export default InternalTable;
|
|
@@ -20,8 +20,6 @@ var _vi_VN = _interopRequireDefault(require("rc-master-ui/es/date-picker/locale/
|
|
|
20
20
|
var _en_US2 = _interopRequireDefault(require("rc-master-ui/es/locales/en_US"));
|
|
21
21
|
var _vi_VN2 = _interopRequireDefault(require("rc-master-ui/es/locales/vi_VN"));
|
|
22
22
|
require("./styles.scss");
|
|
23
|
-
require("rc-master-ui/es/date-range-picker/styles/index.less");
|
|
24
|
-
require("rc-master-ui/assets/index.css");
|
|
25
23
|
var _columns = require("./hooks/columns");
|
|
26
24
|
var _Group = _interopRequireDefault(require("./table/Group"));
|
|
27
25
|
var _sweetalert = _interopRequireDefault(require("sweetalert2"));
|
|
@@ -44,6 +42,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
44
42
|
|
|
45
43
|
// import useColumns from "./hooks/useColumns";
|
|
46
44
|
|
|
45
|
+
// import 'rc-master-ui/assets/index.css'
|
|
46
|
+
|
|
47
47
|
// import {CSS} from "@dnd-kit/utilities";
|
|
48
48
|
|
|
49
49
|
_dayjs.default.extend(_customParseFormat.default);
|
|
@@ -235,8 +235,13 @@ const InternalTable = props => {
|
|
|
235
235
|
});
|
|
236
236
|
const [tooltipContent, setTooltipContent] = (0, _react.useState)('');
|
|
237
237
|
const mergedData = _react.default.useMemo(() => {
|
|
238
|
+
// return addRowIdArray(dataSource)
|
|
239
|
+
|
|
240
|
+
if (groupSetting && groupSetting.client !== false) {
|
|
241
|
+
return (0, _hooks.groupArrayByColumns)(dataSource, groupColumns);
|
|
242
|
+
}
|
|
238
243
|
return (0, _hooks.addRowIdArray)(dataSource);
|
|
239
|
-
}, [dataSource]);
|
|
244
|
+
}, [dataSource, groupColumns, groupSetting]);
|
|
240
245
|
const [columns, setColumns] = _react.default.useState([]);
|
|
241
246
|
_react.default.useEffect(() => {
|
|
242
247
|
if (propsHeight) {
|
|
@@ -507,7 +512,8 @@ const InternalTable = props => {
|
|
|
507
512
|
'cell-group': groupColumns && data.children,
|
|
508
513
|
'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field
|
|
509
514
|
}),
|
|
510
|
-
'data-tooltip-id': "tooltip-cell-content"
|
|
515
|
+
// 'data-tooltip-id': "tooltip-cell-content"
|
|
516
|
+
'data-tooltip-id': `${id}-tooltip-cell-content`
|
|
511
517
|
};
|
|
512
518
|
},
|
|
513
519
|
render: (value, record, rowIndex) => {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
3
|
import type { SelectProps } from "rc-master-ui/es/select";
|
|
4
|
+
import type { LoadOptionsArgs } from "../type";
|
|
4
5
|
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends SelectProps {
|
|
5
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
|
|
6
|
+
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
6
7
|
debounceTimeout?: number;
|
|
7
8
|
defaultOptions?: OptionType[];
|
|
9
|
+
rowData?: any;
|
|
8
10
|
}
|
|
9
|
-
export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
11
|
+
export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -15,6 +15,7 @@ function AsyncSelect({
|
|
|
15
15
|
loadOptions,
|
|
16
16
|
debounceTimeout = 500,
|
|
17
17
|
defaultOptions,
|
|
18
|
+
rowData,
|
|
18
19
|
...props
|
|
19
20
|
}) {
|
|
20
21
|
const [options, setOptions] = (0, _react.useState)(defaultOptions ?? []);
|
|
@@ -27,6 +28,8 @@ function AsyncSelect({
|
|
|
27
28
|
if (loadOptions) {
|
|
28
29
|
loadOptions(value, newOptions => {
|
|
29
30
|
setOptions(newOptions);
|
|
31
|
+
}, {
|
|
32
|
+
rowData
|
|
30
33
|
});
|
|
31
34
|
}
|
|
32
35
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
3
|
import type { TableSelectProps } from "rc-master-ui/es/table-select";
|
|
4
|
+
import type { LoadOptionsArgs } from "../type";
|
|
4
5
|
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
|
|
5
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
|
|
6
|
+
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
6
7
|
debounceTimeout?: number;
|
|
7
8
|
defaultOptions?: OptionType[];
|
|
9
|
+
rowData?: any;
|
|
8
10
|
}
|
|
9
|
-
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
11
|
+
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -16,6 +16,7 @@ function AsyncTableSelect({
|
|
|
16
16
|
debounceTimeout = 500,
|
|
17
17
|
defaultOptions,
|
|
18
18
|
columns,
|
|
19
|
+
rowData,
|
|
19
20
|
...props
|
|
20
21
|
}) {
|
|
21
22
|
const [options, setOptions] = (0, _react.useState)(defaultOptions ?? []);
|
|
@@ -28,11 +29,13 @@ function AsyncTableSelect({
|
|
|
28
29
|
if (loadOptions) {
|
|
29
30
|
loadOptions(value, newOptions => {
|
|
30
31
|
setOptions(newOptions);
|
|
32
|
+
}, {
|
|
33
|
+
rowData
|
|
31
34
|
});
|
|
32
35
|
}
|
|
33
36
|
};
|
|
34
37
|
return (0, _debounce.default)(fetchOptions, debounceTimeout);
|
|
35
|
-
}, [loadOptions,
|
|
38
|
+
}, [debounceTimeout, loadOptions, defaultOptions, rowData]);
|
|
36
39
|
(0, _react.useEffect)(() => {
|
|
37
40
|
setOptions(defaultOptions ?? []);
|
|
38
41
|
}, [defaultOptions]);
|
|
@@ -202,7 +202,7 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
202
202
|
format: dateRangeFormat,
|
|
203
203
|
value: dateRangeValue,
|
|
204
204
|
onChange: value => {
|
|
205
|
-
const newDateRangeValue = value ? [value[0] ? (0, _moment.default)(value[0]).format() : '', value[1] ? (0, _moment.default)(value[
|
|
205
|
+
const newDateRangeValue = value ? [value[0] ? (0, _moment.default)(value[0]).format() : '', value[1] ? (0, _moment.default)(value[1]).format() : ''] : [];
|
|
206
206
|
setSelectedKeys(newDateRangeValue);
|
|
207
207
|
}
|
|
208
208
|
})))));
|
|
@@ -143,3 +143,4 @@ export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
|
|
|
143
143
|
export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
|
|
144
144
|
export declare const isRangeCell: (selectedCells: any, type: string, rowIndex: number, colIndex: number) => boolean;
|
|
145
145
|
export declare const isSelectedCell: (selectedCells: any, rowIndex: number, colIndex: number) => any;
|
|
146
|
+
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
|
|
@@ -21,7 +21,9 @@ exports.getCellsByPosition = getCellsByPosition;
|
|
|
21
21
|
exports.getCellsByPosition2 = getCellsByPosition2;
|
|
22
22
|
exports.getFormat = exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getDateRangeFormat = exports.getColumnsVisible = void 0;
|
|
23
23
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
24
|
-
exports.
|
|
24
|
+
exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
25
|
+
exports.groupArrayByColumns = groupArrayByColumns;
|
|
26
|
+
exports.hideDraggingPoint = void 0;
|
|
25
27
|
exports.invalidDate = invalidDate;
|
|
26
28
|
exports.isArraysEqual = void 0;
|
|
27
29
|
exports.isBottomMostInRanges = isBottomMostInRanges;
|
|
@@ -31,8 +33,8 @@ exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
|
|
|
31
33
|
exports.isEqualSet = isEqualSet;
|
|
32
34
|
exports.isRangeCell = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
|
|
33
35
|
exports.isRightMostInRegion = isRightMostInRegion;
|
|
34
|
-
exports.
|
|
35
|
-
exports.updateData = void 0;
|
|
36
|
+
exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = 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 = exports.isTopMostInRegion = exports.isSelectedCell = void 0;
|
|
37
|
+
exports.updateData = exports.updateColumnsByGroup = void 0;
|
|
36
38
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
37
39
|
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
38
40
|
var _uuid = require("uuid");
|
|
@@ -2149,4 +2151,43 @@ const isSelectedCell = (selectedCells, rowIndex, colIndex) => {
|
|
|
2149
2151
|
const key = `${rowIndex}-${colIndex}`;
|
|
2150
2152
|
return selectedCells.has(key);
|
|
2151
2153
|
};
|
|
2152
|
-
exports.isSelectedCell = isSelectedCell;
|
|
2154
|
+
exports.isSelectedCell = isSelectedCell;
|
|
2155
|
+
function groupArrayByColumns(arr, columns) {
|
|
2156
|
+
const result = [];
|
|
2157
|
+
if (columns) {
|
|
2158
|
+
arr.forEach(item => {
|
|
2159
|
+
let currentLevel = result;
|
|
2160
|
+
columns.forEach((column, index) => {
|
|
2161
|
+
const value = item[column];
|
|
2162
|
+
const existingItem = currentLevel.find(i => i[column] === value);
|
|
2163
|
+
if (existingItem) {
|
|
2164
|
+
currentLevel = existingItem.children;
|
|
2165
|
+
} else {
|
|
2166
|
+
// const newItem = {[column]: value, field: column, rowId: !isEmpty(value) ? (value) : newGuid(), parentId: !isEmpty(item[columns[index - 1]]) ? (item[columns[index - 1]]) : null, indent: index, children: [] }
|
|
2167
|
+
const newItem = {
|
|
2168
|
+
[column]: value,
|
|
2169
|
+
field: column,
|
|
2170
|
+
rowId: newGuid(),
|
|
2171
|
+
// rowId: item[column],
|
|
2172
|
+
parentId: !isEmpty(item[columns[index - 1]]) ? item[columns[index - 1]] : null,
|
|
2173
|
+
// parentId: item.rowId[index - 1],
|
|
2174
|
+
// indent: index,
|
|
2175
|
+
children: []
|
|
2176
|
+
};
|
|
2177
|
+
currentLevel.push(newItem);
|
|
2178
|
+
currentLevel = newItem.children;
|
|
2179
|
+
}
|
|
2180
|
+
});
|
|
2181
|
+
currentLevel.push({
|
|
2182
|
+
...item,
|
|
2183
|
+
rowId: item.id ?? item.rowId,
|
|
2184
|
+
parentId: !isEmpty(columns[columns.length - 1]) ? item[columns[columns.length - 1]] : null,
|
|
2185
|
+
// parentId: item.rowId[columns.length - 1],
|
|
2186
|
+
indent: columns.length
|
|
2187
|
+
});
|
|
2188
|
+
});
|
|
2189
|
+
return result;
|
|
2190
|
+
} else {
|
|
2191
|
+
return arr;
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
@@ -211,6 +211,7 @@ const GridEdit = props => {
|
|
|
211
211
|
showDefaultContext,
|
|
212
212
|
validate,
|
|
213
213
|
setTooltipContent,
|
|
214
|
+
onBlur,
|
|
214
215
|
...rest
|
|
215
216
|
} = props;
|
|
216
217
|
const ref = (0, _react.useRef)(null);
|
|
@@ -994,6 +995,9 @@ const GridEdit = props => {
|
|
|
994
995
|
// if (ref.current && tableId && !tableId.contains(event.target as Node)) {
|
|
995
996
|
|
|
996
997
|
if (ref.current && tableBody && !tableBody.contains(event.target)) {
|
|
998
|
+
if (editingKey.current) {
|
|
999
|
+
onBlur?.(dataSource);
|
|
1000
|
+
}
|
|
997
1001
|
setTimeout(() => {
|
|
998
1002
|
// setEditingKey('')
|
|
999
1003
|
editingKey.current = '';
|
|
@@ -1021,7 +1025,7 @@ const GridEdit = props => {
|
|
|
1021
1025
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
1022
1026
|
// document.removeEventListener('touchstart', handleClickOutside)
|
|
1023
1027
|
};
|
|
1024
|
-
}, [id]);
|
|
1028
|
+
}, [dataSource, id, onBlur]);
|
|
1025
1029
|
const triggerDragPaste = pastesArray => {
|
|
1026
1030
|
const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
|
|
1027
1031
|
const tmpCols = {
|
|
@@ -1438,6 +1442,7 @@ const GridEdit = props => {
|
|
|
1438
1442
|
setTimeout(() => {
|
|
1439
1443
|
// setEditingKey('')
|
|
1440
1444
|
editingKey.current = '';
|
|
1445
|
+
onBlur?.(dataSource);
|
|
1441
1446
|
});
|
|
1442
1447
|
}
|
|
1443
1448
|
|
|
@@ -2272,7 +2277,8 @@ const GridEdit = props => {
|
|
|
2272
2277
|
title: (0, _columns.getValueCell)(column, record[column.field], format),
|
|
2273
2278
|
'data-col-index': colIndex,
|
|
2274
2279
|
'data-row-index': rowNumber,
|
|
2275
|
-
'data-tooltip-id': "tooltip-cell-content",
|
|
2280
|
+
// 'data-tooltip-id': "tooltip-cell-content",
|
|
2281
|
+
'data-tooltip-id': `${id}-tooltip-cell-content`,
|
|
2276
2282
|
// editing: isEditing(record) && rowEditable?.(record) !== false && isEditable(column as any, record),
|
|
2277
2283
|
editing: record.rowId === editingKey.current && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record),
|
|
2278
2284
|
cellEditing: cellEditing.current,
|
|
@@ -2495,6 +2501,7 @@ const GridEdit = props => {
|
|
|
2495
2501
|
id: id
|
|
2496
2502
|
}, /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
|
|
2497
2503
|
value: {
|
|
2504
|
+
id: id ?? '',
|
|
2498
2505
|
rowKey,
|
|
2499
2506
|
form,
|
|
2500
2507
|
format,
|
|
@@ -29,10 +29,12 @@ const Group = props => {
|
|
|
29
29
|
groupAble,
|
|
30
30
|
expandable,
|
|
31
31
|
dataSource,
|
|
32
|
+
rowKey,
|
|
32
33
|
getRowKey,
|
|
33
34
|
groupSetting,
|
|
34
35
|
groupColumns,
|
|
35
36
|
triggerGroupColumns,
|
|
37
|
+
onExpandClick,
|
|
36
38
|
...rest
|
|
37
39
|
} = props;
|
|
38
40
|
const {
|
|
@@ -68,9 +70,15 @@ const Group = props => {
|
|
|
68
70
|
} else {
|
|
69
71
|
newExpandedKeys = [...mergedExpandedKeys, key];
|
|
70
72
|
// gọi sự kiện expand
|
|
73
|
+
|
|
74
|
+
onExpandClick?.({
|
|
75
|
+
expandedKeys: newExpandedKeys,
|
|
76
|
+
key: key,
|
|
77
|
+
rowData: record
|
|
78
|
+
});
|
|
71
79
|
}
|
|
72
80
|
setInnerExpandedKeys(newExpandedKeys);
|
|
73
|
-
}, [getRowKey, mergedExpandedKeys,
|
|
81
|
+
}, [getRowKey, dataSource, mergedExpandedKeys, onExpandClick]);
|
|
74
82
|
const handleExpandAllGroup = () => {
|
|
75
83
|
setInnerExpandedKeys((0, _hooks.findAllChildrenKeys)(dataSource, getRowKey, childrenColumnName) ?? []);
|
|
76
84
|
};
|
|
@@ -117,6 +125,7 @@ const Group = props => {
|
|
|
117
125
|
}, /*#__PURE__*/_react.default.createElement(_TableGrid.default, (0, _extends2.default)({}, rest, {
|
|
118
126
|
t: t,
|
|
119
127
|
id: id,
|
|
128
|
+
rowKey: rowKey,
|
|
120
129
|
columns: columns,
|
|
121
130
|
style: {
|
|
122
131
|
...style,
|
|
@@ -84,6 +84,9 @@ export type ToolbarClick = {
|
|
|
84
84
|
item: any;
|
|
85
85
|
column: any;
|
|
86
86
|
};
|
|
87
|
+
export type LoadOptionsArgs = {
|
|
88
|
+
rowData?: any;
|
|
89
|
+
};
|
|
87
90
|
export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>, 'headerTemplate' | 'title' | 'format' | 'commandItems'> & {
|
|
88
91
|
field?: string;
|
|
89
92
|
key?: any;
|
|
@@ -195,6 +198,12 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
|
|
|
195
198
|
onCellClick?: (args: ICellClick, callback?: any) => void;
|
|
196
199
|
rowEditable?: (rowData: RecordType) => boolean;
|
|
197
200
|
validate?: any;
|
|
201
|
+
onBlur?: (data: RecordType[]) => void;
|
|
202
|
+
onExpandClick?: (args: {
|
|
203
|
+
expandedKeys: string[];
|
|
204
|
+
key: string;
|
|
205
|
+
rowData: any;
|
|
206
|
+
}) => void;
|
|
198
207
|
}
|
|
199
208
|
export type PaginationConfig = TablePaginationConfig & {
|
|
200
209
|
currentPage?: number;
|
|
@@ -19,6 +19,7 @@ export interface IContext<RecordType> {
|
|
|
19
19
|
getValues?: any;
|
|
20
20
|
handleCellChange?: (args: ContextCellChange<RecordType>) => void;
|
|
21
21
|
getRowKey?: GetRowKey<RecordType>;
|
|
22
|
+
id: string;
|
|
22
23
|
}
|
|
23
24
|
export type ContextCellChange<RecordType = AnyObject> = {
|
|
24
25
|
key: string | keyof RecordType | GetRowKey<RecordType>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-grid-template",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "es-grid-template",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"__compile": "father build && ",
|
|
22
22
|
"compile": "father build && sass assets/index.scss assets/index.css",
|
|
23
|
-
"
|
|
23
|
+
"__docs:build": "dumi build",
|
|
24
24
|
"__docs:deploy": "gh-pages -d dist",
|
|
25
25
|
"lint": "eslint src/ --ext .tsx,.ts,.jsx,.js",
|
|
26
|
-
"
|
|
26
|
+
"__now-build": "npm run docs:build",
|
|
27
27
|
"prepare": "dumi setup",
|
|
28
28
|
"prepublishOnly": "npm run compile",
|
|
29
|
-
"
|
|
29
|
+
"___postpublish": "npm run docs:build",
|
|
30
30
|
"__postpublish": "npm run docs:build && npm run docs:deploy",
|
|
31
31
|
"start": "dumi dev",
|
|
32
32
|
"test": "vitest --watch false",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"rc-checkbox": "^3.5.0",
|
|
62
62
|
"rc-dropdown": "^4.2.1",
|
|
63
63
|
"rc-field-form": "^2.6.0",
|
|
64
|
-
"rc-master-ui": "^1.1.
|
|
64
|
+
"rc-master-ui": "^1.1.34",
|
|
65
65
|
"rc-select": "^14.16.3",
|
|
66
66
|
"rc-tooltip": "^6.3.0",
|
|
67
67
|
"rc-tree": "^5.10.1",
|