es-grid-template 1.8.63 → 1.8.65
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/ColumnsGroup/ColumnsGroup.js +4 -1
- package/es/grid-component/TempTable.js +2 -2
- package/es/grid-component/hooks/utils.d.ts +2 -8
- package/es/grid-component/hooks/utils.js +175 -144
- package/es/grid-component/index.d.ts +1 -1
- package/es/grid-component/index.js +0 -4
- package/es/grid-component/type.d.ts +8 -0
- package/es/table-component/InternalTable.js +1 -4
- package/es/table-component/TableContainer.js +5 -5
- package/es/table-component/TableContainerEdit.js +158 -29
- package/es/table-component/body/TableBodyCellEdit.js +69 -31
- package/es/table-component/hook/utils.d.ts +2 -0
- package/es/table-component/hook/utils.js +39 -2
- package/es/table-component/table/Grid.js +10 -7
- package/es/table-component/table/TableWrapper.js +0 -2
- package/es/table-component/type.d.ts +9 -0
- package/es/table-component/useContext.d.ts +3 -1
- package/es/table-virtuoso/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/table-virtuoso/ColumnsGroup/ColumnsGroup.js +232 -0
- package/es/table-virtuoso/ColumnsGroup/index.d.ts +1 -0
- package/es/table-virtuoso/ColumnsGroup/index.js +1 -0
- package/es/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
- package/es/table-virtuoso/InternalTable.js +413 -0
- package/es/table-virtuoso/body/TableBody.d.ts +14 -0
- package/es/table-virtuoso/body/TableBody.js +84 -0
- package/es/table-virtuoso/body/TableBodyCell.d.ts +14 -0
- package/es/table-virtuoso/body/TableBodyCell.js +466 -0
- package/es/table-virtuoso/body/TableBodyRow.d.ts +13 -0
- package/es/table-virtuoso/body/TableBodyRow.js +116 -0
- package/es/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
- package/es/table-virtuoso/footer/TableFooterCell.js +54 -0
- package/es/table-virtuoso/header/TableHeadCell.d.ts +14 -0
- package/es/table-virtuoso/header/TableHeadCell.js +265 -0
- package/es/table-virtuoso/header/renderFilter.d.ts +20 -0
- package/es/table-virtuoso/header/renderFilter.js +289 -0
- package/es/table-virtuoso/hook/constant.d.ts +73 -0
- package/es/table-virtuoso/hook/constant.js +240 -0
- package/es/table-virtuoso/hook/convert.d.ts +1 -0
- package/es/table-virtuoso/hook/convert.js +28 -0
- package/es/table-virtuoso/hook/useColumns.d.ts +28 -0
- package/es/table-virtuoso/hook/useColumns.js +302 -0
- package/es/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
- package/es/table-virtuoso/hook/useFilterOperator.js +33 -0
- package/es/table-virtuoso/hook/utils.d.ts +159 -0
- package/es/table-virtuoso/hook/utils.js +2263 -0
- package/es/table-virtuoso/index.d.ts +2 -0
- package/es/table-virtuoso/index.js +2 -0
- package/es/table-virtuoso/style.d.ts +22 -0
- package/es/table-virtuoso/style.js +11 -0
- package/es/table-virtuoso/style.scss +1440 -0
- package/es/table-virtuoso/table/Grid.d.ts +37 -0
- package/es/table-virtuoso/table/Grid.js +302 -0
- package/es/table-virtuoso/table/TableContainer.d.ts +49 -0
- package/es/table-virtuoso/table/TableContainer.js +305 -0
- package/es/table-virtuoso/table/TableWrapper.d.ts +20 -0
- package/es/table-virtuoso/table/TableWrapper.js +158 -0
- package/es/table-virtuoso/type.d.ts +0 -0
- package/es/table-virtuoso/type.js +785 -0
- package/es/table-virtuoso/useContext.d.ts +97 -0
- package/es/table-virtuoso/useContext.js +21 -0
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +4 -1
- package/lib/grid-component/TempTable.js +2 -2
- package/lib/grid-component/hooks/utils.d.ts +2 -8
- package/lib/grid-component/hooks/utils.js +176 -152
- package/lib/grid-component/index.d.ts +1 -1
- package/lib/grid-component/index.js +0 -3
- package/lib/grid-component/type.d.ts +8 -0
- package/lib/table-component/InternalTable.js +1 -4
- package/lib/table-component/TableContainer.js +5 -5
- package/lib/table-component/TableContainerEdit.js +158 -29
- package/lib/table-component/body/TableBodyCellEdit.js +69 -31
- package/lib/table-component/hook/utils.d.ts +2 -0
- package/lib/table-component/hook/utils.js +45 -4
- package/lib/table-component/table/Grid.js +10 -7
- package/lib/table-component/table/TableWrapper.js +0 -2
- package/lib/table-component/type.d.ts +9 -0
- package/lib/table-component/useContext.d.ts +3 -1
- package/lib/table-virtuoso/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/table-virtuoso/ColumnsGroup/ColumnsGroup.js +243 -0
- package/lib/table-virtuoso/ColumnsGroup/index.d.ts +1 -0
- package/lib/table-virtuoso/ColumnsGroup/index.js +16 -0
- package/lib/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
- package/lib/table-virtuoso/InternalTable.js +422 -0
- package/lib/table-virtuoso/body/TableBody.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBody.js +95 -0
- package/lib/table-virtuoso/body/TableBodyCell.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBodyCell.js +473 -0
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +13 -0
- package/lib/table-virtuoso/body/TableBodyRow.js +124 -0
- package/lib/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
- package/lib/table-virtuoso/footer/TableFooterCell.js +63 -0
- package/lib/table-virtuoso/header/TableHeadCell.d.ts +14 -0
- package/lib/table-virtuoso/header/TableHeadCell.js +274 -0
- package/lib/table-virtuoso/header/renderFilter.d.ts +20 -0
- package/lib/table-virtuoso/header/renderFilter.js +299 -0
- package/lib/table-virtuoso/hook/constant.d.ts +73 -0
- package/lib/table-virtuoso/hook/constant.js +247 -0
- package/lib/table-virtuoso/hook/convert.d.ts +1 -0
- package/lib/table-virtuoso/hook/convert.js +34 -0
- package/lib/table-virtuoso/hook/useColumns.d.ts +28 -0
- package/lib/table-virtuoso/hook/useColumns.js +315 -0
- package/lib/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
- package/lib/table-virtuoso/hook/useFilterOperator.js +40 -0
- package/lib/table-virtuoso/hook/utils.d.ts +159 -0
- package/lib/table-virtuoso/hook/utils.js +2389 -0
- package/lib/table-virtuoso/index.d.ts +2 -0
- package/lib/table-virtuoso/index.js +9 -0
- package/lib/table-virtuoso/style.d.ts +22 -0
- package/lib/table-virtuoso/style.js +18 -0
- package/lib/table-virtuoso/style.scss +1440 -0
- package/lib/table-virtuoso/table/Grid.d.ts +37 -0
- package/lib/table-virtuoso/table/Grid.js +311 -0
- package/lib/table-virtuoso/table/TableContainer.d.ts +49 -0
- package/lib/table-virtuoso/table/TableContainer.js +313 -0
- package/lib/table-virtuoso/table/TableWrapper.d.ts +20 -0
- package/lib/table-virtuoso/table/TableWrapper.js +164 -0
- package/lib/table-virtuoso/type.d.ts +0 -0
- package/lib/table-virtuoso/type.js +786 -0
- package/lib/table-virtuoso/useContext.d.ts +97 -0
- package/lib/table-virtuoso/useContext.js +27 -0
- package/package.json +2 -1
- package/es/grid-component/ConvertColumnTable.d.ts +0 -7
- package/es/grid-component/ConvertColumnTable.js +0 -144
- package/es/grid-component/InternalTable.js +0 -1170
- package/es/grid-component/table/Grid.d.ts +0 -23
- package/es/grid-component/table/Grid.js +0 -49
- package/es/grid-component/table/GridEdit.d.ts +0 -23
- package/es/grid-component/table/GridEdit.js +0 -2726
- package/es/grid-component/table/Group.d.ts +0 -21
- package/es/grid-component/table/Group.js +0 -195
- package/es/grid-component/table/InfiniteTable.d.ts +0 -23
- package/es/grid-component/table/InfiniteTable.js +0 -101
- package/lib/grid-component/ConvertColumnTable.d.ts +0 -7
- package/lib/grid-component/ConvertColumnTable.js +0 -153
- package/lib/grid-component/InternalTable.js +0 -1178
- package/lib/grid-component/table/Grid.d.ts +0 -23
- package/lib/grid-component/table/Grid.js +0 -58
- package/lib/grid-component/table/GridEdit.d.ts +0 -23
- package/lib/grid-component/table/GridEdit.js +0 -2723
- package/lib/grid-component/table/Group.d.ts +0 -21
- package/lib/grid-component/table/Group.js +0 -204
- package/lib/grid-component/table/InfiniteTable.d.ts +0 -23
- package/lib/grid-component/table/InfiniteTable.js +0 -109
|
@@ -358,6 +358,9 @@ const TableContainerEdit = props => {
|
|
|
358
358
|
const [isPasting, setIsPasting] = React.useState(false);
|
|
359
359
|
// const [isFullScreen] = React.useState(false);
|
|
360
360
|
const [tableHeight, settableHeight] = React.useState(0);
|
|
361
|
+
|
|
362
|
+
// const [isAddNewRow, setIsAddNewRow] = React.useState(false)
|
|
363
|
+
|
|
361
364
|
const rowsFocus = React.useMemo(() => {
|
|
362
365
|
return startCell && endCell ? getRowIdsBetween(table, startCell.rowId, endCell.rowId) : [];
|
|
363
366
|
}, [endCell, startCell, table]);
|
|
@@ -396,7 +399,7 @@ const TableContainerEdit = props => {
|
|
|
396
399
|
}, [startCell, endCell, table]);
|
|
397
400
|
const triggerChangeData = React.useCallback(newData => {
|
|
398
401
|
onDataChange?.(newData);
|
|
399
|
-
}, [onDataChange]);
|
|
402
|
+
}, [onDataChange, dataSource]);
|
|
400
403
|
const triggerPaste = React.useCallback((pastedRows, pastedColumnsArray, newData, copyRows) => {
|
|
401
404
|
const handlePasteCallback = callbackData => {
|
|
402
405
|
const rsFilterData = updateOrInsert(flattenArray([...originData]), callbackData);
|
|
@@ -955,6 +958,30 @@ const TableContainerEdit = props => {
|
|
|
955
958
|
mode: 'onChange',
|
|
956
959
|
resolver: validate ? yupResolver(validate) : undefined
|
|
957
960
|
});
|
|
961
|
+
const handleAddMulti = React.useCallback((item, n, newId) => {
|
|
962
|
+
if (item.onClick) {
|
|
963
|
+
item.onClick({
|
|
964
|
+
toolbar: item
|
|
965
|
+
});
|
|
966
|
+
} else {
|
|
967
|
+
const defaultRowValue = getDefaultValue(defaultValue);
|
|
968
|
+
const newRows = Array.from({
|
|
969
|
+
length: n
|
|
970
|
+
}).map(() => defaultRowValue ? {
|
|
971
|
+
...defaultRowValue,
|
|
972
|
+
id: undefined,
|
|
973
|
+
rowId: n === 1 && newId ? newId : newGuid()
|
|
974
|
+
} : {
|
|
975
|
+
id: undefined,
|
|
976
|
+
rowId: n === 1 && newId ? newId : newGuid()
|
|
977
|
+
});
|
|
978
|
+
const kkk = getAllRowKey(newRows) ?? [];
|
|
979
|
+
const rs = mergedFilterKeys ? [...mergedFilterKeys, ...kkk] : [...kkk];
|
|
980
|
+
setMergedFilterKeys?.(rs);
|
|
981
|
+
const newData = dataSource.concat(newRows);
|
|
982
|
+
triggerChangeData?.(newData);
|
|
983
|
+
}
|
|
984
|
+
}, [dataSource, defaultValue, mergedFilterKeys, setMergedFilterKeys, triggerChangeData]);
|
|
958
985
|
const onSubmit = formData => {
|
|
959
986
|
try {
|
|
960
987
|
// const record = (await form.validateFields()) as RecordType;
|
|
@@ -975,6 +1002,26 @@ const TableContainerEdit = props => {
|
|
|
975
1002
|
console.log('Validate Failed:', errInfo);
|
|
976
1003
|
}
|
|
977
1004
|
};
|
|
1005
|
+
const onSubmit2 = (formData, newOriginData) => {
|
|
1006
|
+
try {
|
|
1007
|
+
// const record = (await form.validateFields()) as RecordType;
|
|
1008
|
+
const row = {
|
|
1009
|
+
...formData
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
// const newData = [...dataSource]
|
|
1013
|
+
const newData = [...newOriginData];
|
|
1014
|
+
|
|
1015
|
+
// @ts-ignore
|
|
1016
|
+
const index = flattenData(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
|
|
1017
|
+
const rs = updateArrayByKey(newData, row, rowKey);
|
|
1018
|
+
if (index > -1) {
|
|
1019
|
+
triggerChangeData?.(rs);
|
|
1020
|
+
}
|
|
1021
|
+
} catch (errInfo) {
|
|
1022
|
+
console.log('Validate Failed:', errInfo);
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
978
1025
|
const handleCellChange = args => {
|
|
979
1026
|
const {
|
|
980
1027
|
record,
|
|
@@ -1032,30 +1079,111 @@ const TableContainerEdit = props => {
|
|
|
1032
1079
|
onSubmit(record);
|
|
1033
1080
|
}
|
|
1034
1081
|
};
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1082
|
+
const handleCellChangeAndAddRow = args => {
|
|
1083
|
+
const {
|
|
1084
|
+
record,
|
|
1085
|
+
type: changeType,
|
|
1086
|
+
newState,
|
|
1087
|
+
option,
|
|
1088
|
+
field,
|
|
1089
|
+
indexCol,
|
|
1090
|
+
indexRow,
|
|
1091
|
+
key
|
|
1092
|
+
} = args;
|
|
1093
|
+
|
|
1094
|
+
// add new row
|
|
1095
|
+
|
|
1096
|
+
const defaultRowValue = getDefaultValue(defaultValue);
|
|
1097
|
+
const newRowId = newGuid();
|
|
1098
|
+
const newRows = Array.from({
|
|
1099
|
+
length: 1
|
|
1100
|
+
}).map(() => defaultRowValue ? {
|
|
1101
|
+
...defaultRowValue,
|
|
1102
|
+
id: undefined,
|
|
1103
|
+
rowId: newRowId
|
|
1104
|
+
} : {
|
|
1105
|
+
id: undefined,
|
|
1106
|
+
rowId: newRowId
|
|
1107
|
+
});
|
|
1108
|
+
const kkk = getAllRowKey(newRows) ?? [];
|
|
1109
|
+
const rs = mergedFilterKeys ? [...mergedFilterKeys, ...kkk] : [...kkk];
|
|
1110
|
+
setMergedFilterKeys?.(rs);
|
|
1111
|
+
const newData = originData.concat(newRows);
|
|
1112
|
+
setFocusedCell?.({
|
|
1113
|
+
rowId: newRowId,
|
|
1114
|
+
colId: field
|
|
1115
|
+
});
|
|
1116
|
+
setStartCell?.({
|
|
1117
|
+
rowId: newRowId,
|
|
1118
|
+
colId: field
|
|
1119
|
+
});
|
|
1120
|
+
setEndCell?.({
|
|
1121
|
+
rowId: newRowId,
|
|
1122
|
+
colId: field
|
|
1123
|
+
});
|
|
1124
|
+
setTimeout(() => {
|
|
1125
|
+
setRangeState?.(getSelectedCellMatrix(table, {
|
|
1126
|
+
rowId: newRowId,
|
|
1127
|
+
colId: field
|
|
1128
|
+
}, {
|
|
1129
|
+
rowId: newRowId,
|
|
1130
|
+
colId: field
|
|
1131
|
+
}));
|
|
1132
|
+
});
|
|
1133
|
+
setTimeout(() => {
|
|
1134
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${newRowId}"]`);
|
|
1135
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
1136
|
+
if (cellFocus) {
|
|
1137
|
+
cellFocus.scrollIntoView({
|
|
1138
|
+
behavior: "smooth",
|
|
1139
|
+
block: "start"
|
|
1140
|
+
});
|
|
1141
|
+
cellFocus.focus();
|
|
1142
|
+
}
|
|
1143
|
+
}, 100);
|
|
1144
|
+
if (changeType === 'blur') {
|
|
1145
|
+
const handleChangeCallback = callbackData => {
|
|
1146
|
+
const callbackRecord = callbackData;
|
|
1147
|
+
onSubmit2(callbackRecord, [...newData]);
|
|
1148
|
+
};
|
|
1149
|
+
if (onCellChange) {
|
|
1150
|
+
if (onCellChange.length > 1) {
|
|
1151
|
+
onCellChange({
|
|
1152
|
+
field,
|
|
1153
|
+
indexCol,
|
|
1154
|
+
type: 'onChange',
|
|
1155
|
+
value: newState,
|
|
1156
|
+
option,
|
|
1157
|
+
indexRow,
|
|
1158
|
+
rowData: record,
|
|
1159
|
+
rowId: key,
|
|
1160
|
+
rowsData: [...newData],
|
|
1161
|
+
sumValue: []
|
|
1162
|
+
}, handleChangeCallback);
|
|
1163
|
+
} else {
|
|
1164
|
+
onCellChange({
|
|
1165
|
+
field,
|
|
1166
|
+
indexCol,
|
|
1167
|
+
type: 'onChange',
|
|
1168
|
+
option,
|
|
1169
|
+
value: newState,
|
|
1170
|
+
indexRow,
|
|
1171
|
+
rowData: record,
|
|
1172
|
+
rowId: key,
|
|
1173
|
+
rowsData: [...newData],
|
|
1174
|
+
sumValue: []
|
|
1175
|
+
}, handleChangeCallback);
|
|
1176
|
+
onSubmit2(record, [...newData]);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1057
1179
|
}
|
|
1058
|
-
|
|
1180
|
+
|
|
1181
|
+
// if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
1182
|
+
|
|
1183
|
+
// onSubmit(record)
|
|
1184
|
+
|
|
1185
|
+
// }
|
|
1186
|
+
};
|
|
1059
1187
|
const handleDuplicate = React.useCallback(() => {
|
|
1060
1188
|
// không tính tree
|
|
1061
1189
|
|
|
@@ -1782,10 +1910,6 @@ const TableContainerEdit = props => {
|
|
|
1782
1910
|
ref: topToolbarRef,
|
|
1783
1911
|
className: classNames(`${prefix}-grid-top-toolbar`, {})
|
|
1784
1912
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1785
|
-
style: {
|
|
1786
|
-
textAlign: 'center'
|
|
1787
|
-
}
|
|
1788
|
-
}, typeof title === 'function' ? title?.(originData) : title), /*#__PURE__*/React.createElement("div", {
|
|
1789
1913
|
style: {
|
|
1790
1914
|
display: 'flex',
|
|
1791
1915
|
justifyContent: 'space-between',
|
|
@@ -1836,7 +1960,11 @@ const TableContainerEdit = props => {
|
|
|
1836
1960
|
columnsGroup: groupColumns,
|
|
1837
1961
|
triggerChangeColumns: triggerChangeColumns,
|
|
1838
1962
|
columnHidden: columnHidden
|
|
1839
|
-
})))
|
|
1963
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
1964
|
+
style: {
|
|
1965
|
+
textAlign: 'center'
|
|
1966
|
+
}
|
|
1967
|
+
}, typeof title === 'function' ? title?.(originData) : title)), /*#__PURE__*/React.createElement("form", {
|
|
1840
1968
|
onSubmit: handleSubmit(onSubmit)
|
|
1841
1969
|
}, /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
1842
1970
|
value: {
|
|
@@ -1888,6 +2016,7 @@ const TableContainerEdit = props => {
|
|
|
1888
2016
|
setValue,
|
|
1889
2017
|
reset,
|
|
1890
2018
|
handleCellChange,
|
|
2019
|
+
handleCellChangeAndAddRow,
|
|
1891
2020
|
triggerPaste,
|
|
1892
2021
|
handleDeleteContent,
|
|
1893
2022
|
handleAddMulti,
|
|
@@ -227,7 +227,7 @@ const TableBodyCellEdit = props => {
|
|
|
227
227
|
setValue,
|
|
228
228
|
getValues,
|
|
229
229
|
handleCellChange,
|
|
230
|
-
|
|
230
|
+
handleCellChangeAndAddRow,
|
|
231
231
|
dataErrors,
|
|
232
232
|
expanded,
|
|
233
233
|
setExpanded,
|
|
@@ -237,17 +237,13 @@ const TableBodyCellEdit = props => {
|
|
|
237
237
|
isSelectionChange,
|
|
238
238
|
setIsSelectionChange,
|
|
239
239
|
selectionSettings,
|
|
240
|
-
pagination
|
|
240
|
+
pagination,
|
|
241
|
+
handleAddMulti
|
|
241
242
|
} = React.useContext(TableContext);
|
|
242
243
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex;
|
|
243
244
|
const record = cell.row.original;
|
|
244
245
|
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
245
246
|
const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
|
|
246
|
-
|
|
247
|
-
// const cellContent = columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
248
|
-
// const html = ReactDOMServer.renderToStaticMarkup(<>{cellContent}</>);
|
|
249
|
-
// const hasValue = html.trim().length > 0;
|
|
250
|
-
|
|
251
247
|
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
252
248
|
const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
|
|
253
249
|
const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
|
|
@@ -783,6 +779,8 @@ const TableBodyCellEdit = props => {
|
|
|
783
779
|
return;
|
|
784
780
|
}
|
|
785
781
|
if (e.key === 'Enter') {
|
|
782
|
+
e.preventDefault();
|
|
783
|
+
e.stopPropagation();
|
|
786
784
|
handleEdit(e, true);
|
|
787
785
|
return;
|
|
788
786
|
}
|
|
@@ -1038,6 +1036,64 @@ const TableBodyCellEdit = props => {
|
|
|
1038
1036
|
indexRow: currentRowIndex,
|
|
1039
1037
|
type: 'blur'
|
|
1040
1038
|
});
|
|
1039
|
+
} else {}
|
|
1040
|
+
};
|
|
1041
|
+
const handleChangeAndCreateRow = () => {
|
|
1042
|
+
const currentRowIndex = allRows.findIndex(r => r.id === editingKey);
|
|
1043
|
+
const formState = getValues();
|
|
1044
|
+
const itemState = getValues(cell.column.id);
|
|
1045
|
+
const prevState = record[cell.column.id];
|
|
1046
|
+
const newState = itemState;
|
|
1047
|
+
if (newState !== prevState) {
|
|
1048
|
+
// vừa cell change + add new row
|
|
1049
|
+
handleCellChangeAndAddRow?.({
|
|
1050
|
+
key: cell.row.id,
|
|
1051
|
+
field: cell.column.id,
|
|
1052
|
+
record: formState,
|
|
1053
|
+
prevState,
|
|
1054
|
+
newState,
|
|
1055
|
+
option: newState,
|
|
1056
|
+
indexCol: cell.column.getIndex(),
|
|
1057
|
+
indexRow: currentRowIndex,
|
|
1058
|
+
type: 'blur'
|
|
1059
|
+
});
|
|
1060
|
+
} else {
|
|
1061
|
+
// chỉ add new row
|
|
1062
|
+
|
|
1063
|
+
const newRowId = newGuid();
|
|
1064
|
+
handleAddMulti?.({}, 1, newRowId);
|
|
1065
|
+
setFocusedCell?.({
|
|
1066
|
+
rowId: newRowId,
|
|
1067
|
+
colId: cell.column.id
|
|
1068
|
+
});
|
|
1069
|
+
setStartCell?.({
|
|
1070
|
+
rowId: newRowId,
|
|
1071
|
+
colId: cell.column.id
|
|
1072
|
+
});
|
|
1073
|
+
setEndCell?.({
|
|
1074
|
+
rowId: newRowId,
|
|
1075
|
+
colId: cell.column.id
|
|
1076
|
+
});
|
|
1077
|
+
setTimeout(() => {
|
|
1078
|
+
setRangeState?.(getSelectedCellMatrix(table, {
|
|
1079
|
+
rowId: newRowId,
|
|
1080
|
+
colId: cell.column.id
|
|
1081
|
+
}, {
|
|
1082
|
+
rowId: newRowId,
|
|
1083
|
+
colId: cell.column.id
|
|
1084
|
+
}));
|
|
1085
|
+
});
|
|
1086
|
+
setTimeout(() => {
|
|
1087
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${newRowId}"]`);
|
|
1088
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
1089
|
+
if (cellFocus) {
|
|
1090
|
+
cellFocus.scrollIntoView({
|
|
1091
|
+
behavior: "smooth",
|
|
1092
|
+
block: "start"
|
|
1093
|
+
});
|
|
1094
|
+
cellFocus.focus();
|
|
1095
|
+
}
|
|
1096
|
+
}, 100);
|
|
1041
1097
|
}
|
|
1042
1098
|
};
|
|
1043
1099
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1110,9 +1166,10 @@ const TableBodyCellEdit = props => {
|
|
|
1110
1166
|
if (!isEditing) {
|
|
1111
1167
|
handleKeyDown(e, cell.row.id, cell.column.id);
|
|
1112
1168
|
} else {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1169
|
+
if (e.shiftKey && e.key === 'Enter') {
|
|
1170
|
+
e.preventDefault();
|
|
1171
|
+
e.stopPropagation();
|
|
1172
|
+
} else {
|
|
1116
1173
|
if (e.key === 'Enter') {
|
|
1117
1174
|
e.preventDefault();
|
|
1118
1175
|
e.stopPropagation();
|
|
@@ -1141,29 +1198,10 @@ const TableBodyCellEdit = props => {
|
|
|
1141
1198
|
rowVirtualizer.scrollToIndex(nextRow.index, {
|
|
1142
1199
|
align: 'center'
|
|
1143
1200
|
});
|
|
1201
|
+
handleChange();
|
|
1144
1202
|
} else {
|
|
1145
|
-
|
|
1146
|
-
// const newRowId = newGuid()
|
|
1147
|
-
// handleAddMulti?.({}, 1, newRowId)
|
|
1148
|
-
|
|
1149
|
-
// setFocusedCell?.({ rowId: newRowId, colId: cell.column.id });
|
|
1150
|
-
|
|
1151
|
-
// setStartCell?.({ rowId: newRowId, colId: cell.column.id });
|
|
1152
|
-
// setEndCell?.({ rowId: newRowId, colId: cell.column.id });
|
|
1153
|
-
|
|
1154
|
-
// setTimeout(() => {
|
|
1155
|
-
// setRangeState?.(getSelectedCellMatrix(table, { rowId: newRowId, colId: cell.column.id }, { rowId: newRowId, colId: cell.column.id }))
|
|
1156
|
-
// // rowVirtualizer.scrollToIndex(currentRowIndex + 1, { align: 'end', })
|
|
1157
|
-
|
|
1158
|
-
// })
|
|
1159
|
-
|
|
1160
|
-
// setTimeout(() => {
|
|
1161
|
-
|
|
1162
|
-
// rowVirtualizer.scrollToIndex(currentRowIndex + 1, { align: 'center', })
|
|
1163
|
-
|
|
1164
|
-
// }, 100)
|
|
1203
|
+
handleChangeAndCreateRow();
|
|
1165
1204
|
}
|
|
1166
|
-
handleChange();
|
|
1167
1205
|
setEditingKey?.('');
|
|
1168
1206
|
reset?.();
|
|
1169
1207
|
}
|
|
@@ -154,3 +154,5 @@ export declare function countUnselectedChildren(row: Row<any>): number;
|
|
|
154
154
|
export declare function removeDuplicatesByKey(arr: any[], key?: string): any[];
|
|
155
155
|
export declare const getTableHeight: (height?: number, minHeight?: number) => number;
|
|
156
156
|
export declare const convertFlatColumn1: (array: ColumnsTable) => ColumnsTable[];
|
|
157
|
+
export declare const updateColumnsByGroup: (columns: any[], columnsGroup: string[]) => any[];
|
|
158
|
+
export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType>[], groupColumns: string[]) => ColumnsTable<RecordType>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SELECTION_COLUMN } from "rc-master-ui/es/table/hooks/useSelection"
|
|
1
|
+
// import { SELECTION_COLUMN } from "rc-master-ui/es/table/hooks/useSelection"
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
import { presetPalettes } from "@ant-design/colors";
|
|
4
4
|
// import moment from "moment/moment"
|
|
@@ -263,7 +263,7 @@ export function groupArrayByColumns(arr, columns) {
|
|
|
263
263
|
export const flatColumns2 = columns => {
|
|
264
264
|
return columns.reduce((list, column) => {
|
|
265
265
|
const subColumns = column.children;
|
|
266
|
-
if (column ===
|
|
266
|
+
if (column.field === 'selection_column') {
|
|
267
267
|
return [...list, {
|
|
268
268
|
...column
|
|
269
269
|
}];
|
|
@@ -2180,4 +2180,41 @@ export const convertFlatColumn1 = array => {
|
|
|
2180
2180
|
}
|
|
2181
2181
|
});
|
|
2182
2182
|
return result;
|
|
2183
|
+
};
|
|
2184
|
+
export const updateColumnsByGroup = (columns, columnsGroup) => {
|
|
2185
|
+
return columns.map(column => {
|
|
2186
|
+
const newColumn = {
|
|
2187
|
+
...column
|
|
2188
|
+
};
|
|
2189
|
+
let hasVisibleChild = false;
|
|
2190
|
+
if (!column.field) {
|
|
2191
|
+
return column;
|
|
2192
|
+
}
|
|
2193
|
+
if (newColumn.children) {
|
|
2194
|
+
newColumn.children = updateColumnsByGroup(newColumn.children, columnsGroup);
|
|
2195
|
+
hasVisibleChild = newColumn.children.some(child => child.visible !== false);
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
// Map previous behaviour (hidden = true when field in columnsGroup)
|
|
2199
|
+
// to the new `visible` property: visible = !hidden
|
|
2200
|
+
newColumn.visible = !(newColumn.field && columnsGroup.includes(newColumn.field));
|
|
2201
|
+
|
|
2202
|
+
// For parent columns, visibility depends on whether any child is visible
|
|
2203
|
+
if (newColumn.children && newColumn.children.length > 0) {
|
|
2204
|
+
newColumn.visible = !!hasVisibleChild;
|
|
2205
|
+
}
|
|
2206
|
+
return newColumn;
|
|
2207
|
+
});
|
|
2208
|
+
};
|
|
2209
|
+
export const removeColumns = (columns, groupColumns) => {
|
|
2210
|
+
const ttt = [...columns];
|
|
2211
|
+
return ttt.filter(column => !groupColumns.includes(column.field)).map(column => {
|
|
2212
|
+
const newCol = {
|
|
2213
|
+
...column
|
|
2214
|
+
};
|
|
2215
|
+
if (newCol?.children && newCol?.children.length > 0) {
|
|
2216
|
+
newCol.children = removeColumns(newCol.children, groupColumns);
|
|
2217
|
+
}
|
|
2218
|
+
return newCol;
|
|
2219
|
+
});
|
|
2183
2220
|
};
|
|
@@ -59,6 +59,7 @@ const Grid = props => {
|
|
|
59
59
|
mergedSelectedKeys,
|
|
60
60
|
allowResizing,
|
|
61
61
|
windowSize,
|
|
62
|
+
fullScreenTitle,
|
|
62
63
|
...rest
|
|
63
64
|
} = props;
|
|
64
65
|
const [columnResizeMode] = React.useState('onChange');
|
|
@@ -316,9 +317,7 @@ const Grid = props => {
|
|
|
316
317
|
style: {
|
|
317
318
|
maxWidth: '100%',
|
|
318
319
|
height: '100%'
|
|
319
|
-
}
|
|
320
|
-
// onClose={() => setIsFullScreen(false)}
|
|
321
|
-
,
|
|
320
|
+
},
|
|
322
321
|
onCancel: () => setIsFullScreen(false)
|
|
323
322
|
|
|
324
323
|
// destroyOnClose
|
|
@@ -333,12 +332,16 @@ const Grid = props => {
|
|
|
333
332
|
zIndex: 1050
|
|
334
333
|
}
|
|
335
334
|
},
|
|
335
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, " ", typeof fullScreenTitle === 'function' ? fullScreenTitle?.() : fullScreenTitle, " "),
|
|
336
336
|
destroyOnClose: true
|
|
337
337
|
}, /*#__PURE__*/React.createElement("div", {
|
|
338
|
-
style: {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
338
|
+
style: {}
|
|
339
|
+
}, /*#__PURE__*/React.createElement(GridStyle, {
|
|
340
|
+
$prefix: prefix,
|
|
341
|
+
$theme: {
|
|
342
|
+
theme: theme?.theme,
|
|
343
|
+
...theme
|
|
344
|
+
},
|
|
342
345
|
className: classNames(`${prefix}-grid`, {
|
|
343
346
|
[`${prefix}-grid-light`]: !theme || theme.theme === 'light',
|
|
344
347
|
[`${prefix}-grid-dark`]: theme?.theme === 'dark'
|
|
@@ -180,11 +180,9 @@ const TableWrapper = props => {
|
|
|
180
180
|
//our scrollable table container
|
|
181
181
|
position: 'relative',
|
|
182
182
|
//needed for sticky header
|
|
183
|
-
// height: height, //should be a fixed height
|
|
184
183
|
maxHeight: height,
|
|
185
184
|
//should be a fixed height
|
|
186
185
|
minHeight: minHeight ? height : undefined //should be a fixed height
|
|
187
|
-
// minWidth: table.getTotalSize()
|
|
188
186
|
}
|
|
189
187
|
// onScroll={infiniteScroll ? handleScroll : undefined}
|
|
190
188
|
,
|
|
@@ -198,6 +198,7 @@ export type TableProps<RecordType = AnyObject> = {
|
|
|
198
198
|
color?: string;
|
|
199
199
|
};
|
|
200
200
|
title?: ReactNode | ((data: RecordType) => ReactNode);
|
|
201
|
+
fullScreenTitle?: ReactNode | (() => ReactNode);
|
|
201
202
|
editAble?: boolean;
|
|
202
203
|
infiniteScroll?: boolean;
|
|
203
204
|
next?: () => void;
|
|
@@ -424,13 +425,21 @@ export type ToolbarItem = {
|
|
|
424
425
|
export type LoadOptionsArgs = {
|
|
425
426
|
rowData?: any;
|
|
426
427
|
};
|
|
428
|
+
export type GroupTemplate = {
|
|
429
|
+
rowData: any;
|
|
430
|
+
value: any;
|
|
431
|
+
column: ColumnTable;
|
|
432
|
+
};
|
|
427
433
|
export type IGroupSetting = {
|
|
428
434
|
client?: boolean;
|
|
429
435
|
onGroup?: (props: IOnGroup) => void;
|
|
436
|
+
groupColumnSpan?: number;
|
|
430
437
|
hiddenColumnGroup?: boolean;
|
|
438
|
+
showHeaderColumn?: boolean;
|
|
431
439
|
showGroupIcon?: boolean;
|
|
432
440
|
unClearableLevel?: 1 | 2 | 3 | undefined;
|
|
433
441
|
sumGroup?: boolean;
|
|
442
|
+
groupTemplate?: React.ReactNode | React.ReactElement | ((args: GroupTemplate) => React.ReactNode | React.ReactElement);
|
|
434
443
|
};
|
|
435
444
|
type IOnGroup = {
|
|
436
445
|
columnGrouped: string[];
|
|
@@ -48,6 +48,7 @@ export interface IContext<T> {
|
|
|
48
48
|
reset?: any;
|
|
49
49
|
setValue?: any;
|
|
50
50
|
handleCellChange?: (args: ContextCellChange) => void;
|
|
51
|
+
handleCellChangeAndAddRow?: (args: ContextCellChange) => void;
|
|
51
52
|
editingKey?: string;
|
|
52
53
|
setEditingKey?: Dispatch<SetStateAction<string>>;
|
|
53
54
|
rangeState?: RangeState;
|
|
@@ -86,11 +87,12 @@ export declare const TableContext: import("react").Context<IContext<any>>;
|
|
|
86
87
|
export type ContextCellChange = {
|
|
87
88
|
key: string;
|
|
88
89
|
record: any;
|
|
89
|
-
field: string
|
|
90
|
+
field: string;
|
|
90
91
|
option: any;
|
|
91
92
|
indexRow: number;
|
|
92
93
|
indexCol: number;
|
|
93
94
|
newState?: any;
|
|
94
95
|
prevState?: any;
|
|
95
96
|
type: 'enter' | 'blur' | 'outClick';
|
|
97
|
+
addNewRow?: boolean;
|
|
96
98
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type IColumnsGroup = {
|
|
3
|
+
columns: any[];
|
|
4
|
+
dataSource?: string[];
|
|
5
|
+
onSubmit: (value: any) => void;
|
|
6
|
+
t?: any;
|
|
7
|
+
columnsGrouped?: string[];
|
|
8
|
+
unClearableLevel?: number;
|
|
9
|
+
defaultGroupColumns?: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare const ColumnsGroup: (props: IColumnsGroup) => React.JSX.Element;
|
|
12
|
+
export {};
|