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
|
@@ -365,6 +365,9 @@ const TableContainerEdit = props => {
|
|
|
365
365
|
const [isPasting, setIsPasting] = _react.default.useState(false);
|
|
366
366
|
// const [isFullScreen] = React.useState(false);
|
|
367
367
|
const [tableHeight, settableHeight] = _react.default.useState(0);
|
|
368
|
+
|
|
369
|
+
// const [isAddNewRow, setIsAddNewRow] = React.useState(false)
|
|
370
|
+
|
|
368
371
|
const rowsFocus = _react.default.useMemo(() => {
|
|
369
372
|
return startCell && endCell ? (0, _utils.getRowIdsBetween)(table, startCell.rowId, endCell.rowId) : [];
|
|
370
373
|
}, [endCell, startCell, table]);
|
|
@@ -403,7 +406,7 @@ const TableContainerEdit = props => {
|
|
|
403
406
|
}, [startCell, endCell, table]);
|
|
404
407
|
const triggerChangeData = _react.default.useCallback(newData => {
|
|
405
408
|
onDataChange?.(newData);
|
|
406
|
-
}, [onDataChange]);
|
|
409
|
+
}, [onDataChange, dataSource]);
|
|
407
410
|
const triggerPaste = _react.default.useCallback((pastedRows, pastedColumnsArray, newData, copyRows) => {
|
|
408
411
|
const handlePasteCallback = callbackData => {
|
|
409
412
|
const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...originData]), callbackData);
|
|
@@ -962,6 +965,30 @@ const TableContainerEdit = props => {
|
|
|
962
965
|
mode: 'onChange',
|
|
963
966
|
resolver: validate ? (0, _yup.yupResolver)(validate) : undefined
|
|
964
967
|
});
|
|
968
|
+
const handleAddMulti = _react.default.useCallback((item, n, newId) => {
|
|
969
|
+
if (item.onClick) {
|
|
970
|
+
item.onClick({
|
|
971
|
+
toolbar: item
|
|
972
|
+
});
|
|
973
|
+
} else {
|
|
974
|
+
const defaultRowValue = (0, _utils.getDefaultValue)(defaultValue);
|
|
975
|
+
const newRows = Array.from({
|
|
976
|
+
length: n
|
|
977
|
+
}).map(() => defaultRowValue ? {
|
|
978
|
+
...defaultRowValue,
|
|
979
|
+
id: undefined,
|
|
980
|
+
rowId: n === 1 && newId ? newId : (0, _utils.newGuid)()
|
|
981
|
+
} : {
|
|
982
|
+
id: undefined,
|
|
983
|
+
rowId: n === 1 && newId ? newId : (0, _utils.newGuid)()
|
|
984
|
+
});
|
|
985
|
+
const kkk = (0, _utils.getAllRowKey)(newRows) ?? [];
|
|
986
|
+
const rs = mergedFilterKeys ? [...mergedFilterKeys, ...kkk] : [...kkk];
|
|
987
|
+
setMergedFilterKeys?.(rs);
|
|
988
|
+
const newData = dataSource.concat(newRows);
|
|
989
|
+
triggerChangeData?.(newData);
|
|
990
|
+
}
|
|
991
|
+
}, [dataSource, defaultValue, mergedFilterKeys, setMergedFilterKeys, triggerChangeData]);
|
|
965
992
|
const onSubmit = formData => {
|
|
966
993
|
try {
|
|
967
994
|
// const record = (await form.validateFields()) as RecordType;
|
|
@@ -982,6 +1009,26 @@ const TableContainerEdit = props => {
|
|
|
982
1009
|
console.log('Validate Failed:', errInfo);
|
|
983
1010
|
}
|
|
984
1011
|
};
|
|
1012
|
+
const onSubmit2 = (formData, newOriginData) => {
|
|
1013
|
+
try {
|
|
1014
|
+
// const record = (await form.validateFields()) as RecordType;
|
|
1015
|
+
const row = {
|
|
1016
|
+
...formData
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
// const newData = [...dataSource]
|
|
1020
|
+
const newData = [...newOriginData];
|
|
1021
|
+
|
|
1022
|
+
// @ts-ignore
|
|
1023
|
+
const index = (0, _utils.flattenData)(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
|
|
1024
|
+
const rs = (0, _utils.updateArrayByKey)(newData, row, rowKey);
|
|
1025
|
+
if (index > -1) {
|
|
1026
|
+
triggerChangeData?.(rs);
|
|
1027
|
+
}
|
|
1028
|
+
} catch (errInfo) {
|
|
1029
|
+
console.log('Validate Failed:', errInfo);
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
985
1032
|
const handleCellChange = args => {
|
|
986
1033
|
const {
|
|
987
1034
|
record,
|
|
@@ -1039,30 +1086,111 @@ const TableContainerEdit = props => {
|
|
|
1039
1086
|
onSubmit(record);
|
|
1040
1087
|
}
|
|
1041
1088
|
};
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1089
|
+
const handleCellChangeAndAddRow = args => {
|
|
1090
|
+
const {
|
|
1091
|
+
record,
|
|
1092
|
+
type: changeType,
|
|
1093
|
+
newState,
|
|
1094
|
+
option,
|
|
1095
|
+
field,
|
|
1096
|
+
indexCol,
|
|
1097
|
+
indexRow,
|
|
1098
|
+
key
|
|
1099
|
+
} = args;
|
|
1100
|
+
|
|
1101
|
+
// add new row
|
|
1102
|
+
|
|
1103
|
+
const defaultRowValue = (0, _utils.getDefaultValue)(defaultValue);
|
|
1104
|
+
const newRowId = (0, _utils.newGuid)();
|
|
1105
|
+
const newRows = Array.from({
|
|
1106
|
+
length: 1
|
|
1107
|
+
}).map(() => defaultRowValue ? {
|
|
1108
|
+
...defaultRowValue,
|
|
1109
|
+
id: undefined,
|
|
1110
|
+
rowId: newRowId
|
|
1111
|
+
} : {
|
|
1112
|
+
id: undefined,
|
|
1113
|
+
rowId: newRowId
|
|
1114
|
+
});
|
|
1115
|
+
const kkk = (0, _utils.getAllRowKey)(newRows) ?? [];
|
|
1116
|
+
const rs = mergedFilterKeys ? [...mergedFilterKeys, ...kkk] : [...kkk];
|
|
1117
|
+
setMergedFilterKeys?.(rs);
|
|
1118
|
+
const newData = originData.concat(newRows);
|
|
1119
|
+
setFocusedCell?.({
|
|
1120
|
+
rowId: newRowId,
|
|
1121
|
+
colId: field
|
|
1122
|
+
});
|
|
1123
|
+
setStartCell?.({
|
|
1124
|
+
rowId: newRowId,
|
|
1125
|
+
colId: field
|
|
1126
|
+
});
|
|
1127
|
+
setEndCell?.({
|
|
1128
|
+
rowId: newRowId,
|
|
1129
|
+
colId: field
|
|
1130
|
+
});
|
|
1131
|
+
setTimeout(() => {
|
|
1132
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
1133
|
+
rowId: newRowId,
|
|
1134
|
+
colId: field
|
|
1135
|
+
}, {
|
|
1136
|
+
rowId: newRowId,
|
|
1137
|
+
colId: field
|
|
1138
|
+
}));
|
|
1139
|
+
});
|
|
1140
|
+
setTimeout(() => {
|
|
1141
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${newRowId}"]`);
|
|
1142
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
1143
|
+
if (cellFocus) {
|
|
1144
|
+
cellFocus.scrollIntoView({
|
|
1145
|
+
behavior: "smooth",
|
|
1146
|
+
block: "start"
|
|
1147
|
+
});
|
|
1148
|
+
cellFocus.focus();
|
|
1149
|
+
}
|
|
1150
|
+
}, 100);
|
|
1151
|
+
if (changeType === 'blur') {
|
|
1152
|
+
const handleChangeCallback = callbackData => {
|
|
1153
|
+
const callbackRecord = callbackData;
|
|
1154
|
+
onSubmit2(callbackRecord, [...newData]);
|
|
1155
|
+
};
|
|
1156
|
+
if (onCellChange) {
|
|
1157
|
+
if (onCellChange.length > 1) {
|
|
1158
|
+
onCellChange({
|
|
1159
|
+
field,
|
|
1160
|
+
indexCol,
|
|
1161
|
+
type: 'onChange',
|
|
1162
|
+
value: newState,
|
|
1163
|
+
option,
|
|
1164
|
+
indexRow,
|
|
1165
|
+
rowData: record,
|
|
1166
|
+
rowId: key,
|
|
1167
|
+
rowsData: [...newData],
|
|
1168
|
+
sumValue: []
|
|
1169
|
+
}, handleChangeCallback);
|
|
1170
|
+
} else {
|
|
1171
|
+
onCellChange({
|
|
1172
|
+
field,
|
|
1173
|
+
indexCol,
|
|
1174
|
+
type: 'onChange',
|
|
1175
|
+
option,
|
|
1176
|
+
value: newState,
|
|
1177
|
+
indexRow,
|
|
1178
|
+
rowData: record,
|
|
1179
|
+
rowId: key,
|
|
1180
|
+
rowsData: [...newData],
|
|
1181
|
+
sumValue: []
|
|
1182
|
+
}, handleChangeCallback);
|
|
1183
|
+
onSubmit2(record, [...newData]);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1064
1186
|
}
|
|
1065
|
-
|
|
1187
|
+
|
|
1188
|
+
// if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
1189
|
+
|
|
1190
|
+
// onSubmit(record)
|
|
1191
|
+
|
|
1192
|
+
// }
|
|
1193
|
+
};
|
|
1066
1194
|
const handleDuplicate = _react.default.useCallback(() => {
|
|
1067
1195
|
// không tính tree
|
|
1068
1196
|
|
|
@@ -1789,10 +1917,6 @@ const TableContainerEdit = props => {
|
|
|
1789
1917
|
ref: topToolbarRef,
|
|
1790
1918
|
className: (0, _classnames.default)(`${prefix}-grid-top-toolbar`, {})
|
|
1791
1919
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1792
|
-
style: {
|
|
1793
|
-
textAlign: 'center'
|
|
1794
|
-
}
|
|
1795
|
-
}, typeof title === 'function' ? title?.(originData) : title), /*#__PURE__*/_react.default.createElement("div", {
|
|
1796
1920
|
style: {
|
|
1797
1921
|
display: 'flex',
|
|
1798
1922
|
justifyContent: 'space-between',
|
|
@@ -1843,7 +1967,11 @@ const TableContainerEdit = props => {
|
|
|
1843
1967
|
columnsGroup: groupColumns,
|
|
1844
1968
|
triggerChangeColumns: triggerChangeColumns,
|
|
1845
1969
|
columnHidden: columnHidden
|
|
1846
|
-
})))
|
|
1970
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
1971
|
+
style: {
|
|
1972
|
+
textAlign: 'center'
|
|
1973
|
+
}
|
|
1974
|
+
}, typeof title === 'function' ? title?.(originData) : title)), /*#__PURE__*/_react.default.createElement("form", {
|
|
1847
1975
|
onSubmit: handleSubmit(onSubmit)
|
|
1848
1976
|
}, /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
|
|
1849
1977
|
value: {
|
|
@@ -1895,6 +2023,7 @@ const TableContainerEdit = props => {
|
|
|
1895
2023
|
setValue,
|
|
1896
2024
|
reset,
|
|
1897
2025
|
handleCellChange,
|
|
2026
|
+
handleCellChangeAndAddRow,
|
|
1898
2027
|
triggerPaste,
|
|
1899
2028
|
handleDeleteContent,
|
|
1900
2029
|
handleAddMulti,
|
|
@@ -233,7 +233,7 @@ const TableBodyCellEdit = props => {
|
|
|
233
233
|
setValue,
|
|
234
234
|
getValues,
|
|
235
235
|
handleCellChange,
|
|
236
|
-
|
|
236
|
+
handleCellChangeAndAddRow,
|
|
237
237
|
dataErrors,
|
|
238
238
|
expanded,
|
|
239
239
|
setExpanded,
|
|
@@ -243,17 +243,13 @@ const TableBodyCellEdit = props => {
|
|
|
243
243
|
isSelectionChange,
|
|
244
244
|
setIsSelectionChange,
|
|
245
245
|
selectionSettings,
|
|
246
|
-
pagination
|
|
246
|
+
pagination,
|
|
247
|
+
handleAddMulti
|
|
247
248
|
} = _react.default.useContext(_useContext.TableContext);
|
|
248
249
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex;
|
|
249
250
|
const record = cell.row.original;
|
|
250
251
|
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
251
252
|
const [isOpenTooltip, setIsOpenTooltip] = _react.default.useState(false);
|
|
252
|
-
|
|
253
|
-
// const cellContent = columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
254
|
-
// const html = ReactDOMServer.renderToStaticMarkup(<>{cellContent}</>);
|
|
255
|
-
// const hasValue = html.trim().length > 0;
|
|
256
|
-
|
|
257
253
|
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
258
254
|
const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
|
|
259
255
|
const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
|
|
@@ -789,6 +785,8 @@ const TableBodyCellEdit = props => {
|
|
|
789
785
|
return;
|
|
790
786
|
}
|
|
791
787
|
if (e.key === 'Enter') {
|
|
788
|
+
e.preventDefault();
|
|
789
|
+
e.stopPropagation();
|
|
792
790
|
handleEdit(e, true);
|
|
793
791
|
return;
|
|
794
792
|
}
|
|
@@ -1044,6 +1042,64 @@ const TableBodyCellEdit = props => {
|
|
|
1044
1042
|
indexRow: currentRowIndex,
|
|
1045
1043
|
type: 'blur'
|
|
1046
1044
|
});
|
|
1045
|
+
} else {}
|
|
1046
|
+
};
|
|
1047
|
+
const handleChangeAndCreateRow = () => {
|
|
1048
|
+
const currentRowIndex = allRows.findIndex(r => r.id === editingKey);
|
|
1049
|
+
const formState = getValues();
|
|
1050
|
+
const itemState = getValues(cell.column.id);
|
|
1051
|
+
const prevState = record[cell.column.id];
|
|
1052
|
+
const newState = itemState;
|
|
1053
|
+
if (newState !== prevState) {
|
|
1054
|
+
// vừa cell change + add new row
|
|
1055
|
+
handleCellChangeAndAddRow?.({
|
|
1056
|
+
key: cell.row.id,
|
|
1057
|
+
field: cell.column.id,
|
|
1058
|
+
record: formState,
|
|
1059
|
+
prevState,
|
|
1060
|
+
newState,
|
|
1061
|
+
option: newState,
|
|
1062
|
+
indexCol: cell.column.getIndex(),
|
|
1063
|
+
indexRow: currentRowIndex,
|
|
1064
|
+
type: 'blur'
|
|
1065
|
+
});
|
|
1066
|
+
} else {
|
|
1067
|
+
// chỉ add new row
|
|
1068
|
+
|
|
1069
|
+
const newRowId = (0, _utils.newGuid)();
|
|
1070
|
+
handleAddMulti?.({}, 1, newRowId);
|
|
1071
|
+
setFocusedCell?.({
|
|
1072
|
+
rowId: newRowId,
|
|
1073
|
+
colId: cell.column.id
|
|
1074
|
+
});
|
|
1075
|
+
setStartCell?.({
|
|
1076
|
+
rowId: newRowId,
|
|
1077
|
+
colId: cell.column.id
|
|
1078
|
+
});
|
|
1079
|
+
setEndCell?.({
|
|
1080
|
+
rowId: newRowId,
|
|
1081
|
+
colId: cell.column.id
|
|
1082
|
+
});
|
|
1083
|
+
setTimeout(() => {
|
|
1084
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
1085
|
+
rowId: newRowId,
|
|
1086
|
+
colId: cell.column.id
|
|
1087
|
+
}, {
|
|
1088
|
+
rowId: newRowId,
|
|
1089
|
+
colId: cell.column.id
|
|
1090
|
+
}));
|
|
1091
|
+
});
|
|
1092
|
+
setTimeout(() => {
|
|
1093
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${newRowId}"]`);
|
|
1094
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
1095
|
+
if (cellFocus) {
|
|
1096
|
+
cellFocus.scrollIntoView({
|
|
1097
|
+
behavior: "smooth",
|
|
1098
|
+
block: "start"
|
|
1099
|
+
});
|
|
1100
|
+
cellFocus.focus();
|
|
1101
|
+
}
|
|
1102
|
+
}, 100);
|
|
1047
1103
|
}
|
|
1048
1104
|
};
|
|
1049
1105
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -1116,9 +1172,10 @@ const TableBodyCellEdit = props => {
|
|
|
1116
1172
|
if (!isEditing) {
|
|
1117
1173
|
handleKeyDown(e, cell.row.id, cell.column.id);
|
|
1118
1174
|
} else {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1175
|
+
if (e.shiftKey && e.key === 'Enter') {
|
|
1176
|
+
e.preventDefault();
|
|
1177
|
+
e.stopPropagation();
|
|
1178
|
+
} else {
|
|
1122
1179
|
if (e.key === 'Enter') {
|
|
1123
1180
|
e.preventDefault();
|
|
1124
1181
|
e.stopPropagation();
|
|
@@ -1147,29 +1204,10 @@ const TableBodyCellEdit = props => {
|
|
|
1147
1204
|
rowVirtualizer.scrollToIndex(nextRow.index, {
|
|
1148
1205
|
align: 'center'
|
|
1149
1206
|
});
|
|
1207
|
+
handleChange();
|
|
1150
1208
|
} else {
|
|
1151
|
-
|
|
1152
|
-
// const newRowId = newGuid()
|
|
1153
|
-
// handleAddMulti?.({}, 1, newRowId)
|
|
1154
|
-
|
|
1155
|
-
// setFocusedCell?.({ rowId: newRowId, colId: cell.column.id });
|
|
1156
|
-
|
|
1157
|
-
// setStartCell?.({ rowId: newRowId, colId: cell.column.id });
|
|
1158
|
-
// setEndCell?.({ rowId: newRowId, colId: cell.column.id });
|
|
1159
|
-
|
|
1160
|
-
// setTimeout(() => {
|
|
1161
|
-
// setRangeState?.(getSelectedCellMatrix(table, { rowId: newRowId, colId: cell.column.id }, { rowId: newRowId, colId: cell.column.id }))
|
|
1162
|
-
// // rowVirtualizer.scrollToIndex(currentRowIndex + 1, { align: 'end', })
|
|
1163
|
-
|
|
1164
|
-
// })
|
|
1165
|
-
|
|
1166
|
-
// setTimeout(() => {
|
|
1167
|
-
|
|
1168
|
-
// rowVirtualizer.scrollToIndex(currentRowIndex + 1, { align: 'center', })
|
|
1169
|
-
|
|
1170
|
-
// }, 100)
|
|
1209
|
+
handleChangeAndCreateRow();
|
|
1171
1210
|
}
|
|
1172
|
-
handleChange();
|
|
1173
1211
|
setEditingKey?.('');
|
|
1174
1212
|
reset?.();
|
|
1175
1213
|
}
|
|
@@ -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>;
|
|
@@ -53,6 +53,7 @@ exports.parseClipboardEvent = parseClipboardEvent;
|
|
|
53
53
|
exports.parseExcelClipboard = parseExcelClipboard;
|
|
54
54
|
exports.parseExcelClipboardText = parseExcelClipboardText;
|
|
55
55
|
exports.parseExcelText = parseExcelText;
|
|
56
|
+
exports.removeColumns = void 0;
|
|
56
57
|
exports.removeDuplicatesByKey = removeDuplicatesByKey;
|
|
57
58
|
exports.sortByType = exports.shouldInclude = exports.removeVietnameseTones = void 0;
|
|
58
59
|
exports.sortData = sortData;
|
|
@@ -60,14 +61,15 @@ exports.sumSize = void 0;
|
|
|
60
61
|
exports.toggleRowAndChildren = toggleRowAndChildren;
|
|
61
62
|
exports.updateArrayByKey = exports.unFlattenData = void 0;
|
|
62
63
|
exports.updateColumnWidthsRecursive = updateColumnWidthsRecursive;
|
|
63
|
-
exports.updateColumns1 = void 0;
|
|
64
|
+
exports.updateColumnsByGroup = exports.updateColumns1 = void 0;
|
|
64
65
|
exports.updateOrInsert = updateOrInsert;
|
|
65
66
|
exports.updateWidthsByOther = updateWidthsByOther;
|
|
66
|
-
var _useSelection = require("rc-master-ui/es/table/hooks/useSelection");
|
|
67
67
|
var _uuid = require("uuid");
|
|
68
68
|
var _colors = require("@ant-design/colors");
|
|
69
69
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
70
70
|
var _moment = _interopRequireDefault(require("moment"));
|
|
71
|
+
// import { SELECTION_COLUMN } from "rc-master-ui/es/table/hooks/useSelection"
|
|
72
|
+
|
|
71
73
|
// import moment from "moment/moment"
|
|
72
74
|
|
|
73
75
|
const newGuid = () => {
|
|
@@ -343,7 +345,7 @@ function groupArrayByColumns(arr, columns) {
|
|
|
343
345
|
const flatColumns2 = columns => {
|
|
344
346
|
return columns.reduce((list, column) => {
|
|
345
347
|
const subColumns = column.children;
|
|
346
|
-
if (column ===
|
|
348
|
+
if (column.field === 'selection_column') {
|
|
347
349
|
return [...list, {
|
|
348
350
|
...column
|
|
349
351
|
}];
|
|
@@ -2304,4 +2306,43 @@ const convertFlatColumn1 = array => {
|
|
|
2304
2306
|
});
|
|
2305
2307
|
return result;
|
|
2306
2308
|
};
|
|
2307
|
-
exports.convertFlatColumn1 = convertFlatColumn1;
|
|
2309
|
+
exports.convertFlatColumn1 = convertFlatColumn1;
|
|
2310
|
+
const updateColumnsByGroup = (columns, columnsGroup) => {
|
|
2311
|
+
return columns.map(column => {
|
|
2312
|
+
const newColumn = {
|
|
2313
|
+
...column
|
|
2314
|
+
};
|
|
2315
|
+
let hasVisibleChild = false;
|
|
2316
|
+
if (!column.field) {
|
|
2317
|
+
return column;
|
|
2318
|
+
}
|
|
2319
|
+
if (newColumn.children) {
|
|
2320
|
+
newColumn.children = updateColumnsByGroup(newColumn.children, columnsGroup);
|
|
2321
|
+
hasVisibleChild = newColumn.children.some(child => child.visible !== false);
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
// Map previous behaviour (hidden = true when field in columnsGroup)
|
|
2325
|
+
// to the new `visible` property: visible = !hidden
|
|
2326
|
+
newColumn.visible = !(newColumn.field && columnsGroup.includes(newColumn.field));
|
|
2327
|
+
|
|
2328
|
+
// For parent columns, visibility depends on whether any child is visible
|
|
2329
|
+
if (newColumn.children && newColumn.children.length > 0) {
|
|
2330
|
+
newColumn.visible = !!hasVisibleChild;
|
|
2331
|
+
}
|
|
2332
|
+
return newColumn;
|
|
2333
|
+
});
|
|
2334
|
+
};
|
|
2335
|
+
exports.updateColumnsByGroup = updateColumnsByGroup;
|
|
2336
|
+
const removeColumns = (columns, groupColumns) => {
|
|
2337
|
+
const ttt = [...columns];
|
|
2338
|
+
return ttt.filter(column => !groupColumns.includes(column.field)).map(column => {
|
|
2339
|
+
const newCol = {
|
|
2340
|
+
...column
|
|
2341
|
+
};
|
|
2342
|
+
if (newCol?.children && newCol?.children.length > 0) {
|
|
2343
|
+
newCol.children = removeColumns(newCol.children, groupColumns);
|
|
2344
|
+
}
|
|
2345
|
+
return newCol;
|
|
2346
|
+
});
|
|
2347
|
+
};
|
|
2348
|
+
exports.removeColumns = removeColumns;
|
|
@@ -63,6 +63,7 @@ const Grid = props => {
|
|
|
63
63
|
mergedSelectedKeys,
|
|
64
64
|
allowResizing,
|
|
65
65
|
windowSize,
|
|
66
|
+
fullScreenTitle,
|
|
66
67
|
...rest
|
|
67
68
|
} = props;
|
|
68
69
|
const [columnResizeMode] = _react.default.useState('onChange');
|
|
@@ -320,9 +321,7 @@ const Grid = props => {
|
|
|
320
321
|
style: {
|
|
321
322
|
maxWidth: '100%',
|
|
322
323
|
height: '100%'
|
|
323
|
-
}
|
|
324
|
-
// onClose={() => setIsFullScreen(false)}
|
|
325
|
-
,
|
|
324
|
+
},
|
|
326
325
|
onCancel: () => setIsFullScreen(false)
|
|
327
326
|
|
|
328
327
|
// destroyOnClose
|
|
@@ -337,12 +336,16 @@ const Grid = props => {
|
|
|
337
336
|
zIndex: 1050
|
|
338
337
|
}
|
|
339
338
|
},
|
|
339
|
+
title: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, " ", typeof fullScreenTitle === 'function' ? fullScreenTitle?.() : fullScreenTitle, " "),
|
|
340
340
|
destroyOnClose: true
|
|
341
341
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
342
|
-
style: {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
342
|
+
style: {}
|
|
343
|
+
}, /*#__PURE__*/_react.default.createElement(_style.GridStyle, {
|
|
344
|
+
$prefix: prefix,
|
|
345
|
+
$theme: {
|
|
346
|
+
theme: theme?.theme,
|
|
347
|
+
...theme
|
|
348
|
+
},
|
|
346
349
|
className: (0, _classnames.default)(`${prefix}-grid`, {
|
|
347
350
|
[`${prefix}-grid-light`]: !theme || theme.theme === 'light',
|
|
348
351
|
[`${prefix}-grid-dark`]: theme?.theme === 'dark'
|
|
@@ -189,11 +189,9 @@ const TableWrapper = props => {
|
|
|
189
189
|
//our scrollable table container
|
|
190
190
|
position: 'relative',
|
|
191
191
|
//needed for sticky header
|
|
192
|
-
// height: height, //should be a fixed height
|
|
193
192
|
maxHeight: height,
|
|
194
193
|
//should be a fixed height
|
|
195
194
|
minHeight: minHeight ? height : undefined //should be a fixed height
|
|
196
|
-
// minWidth: table.getTotalSize()
|
|
197
195
|
}
|
|
198
196
|
// onScroll={infiniteScroll ? handleScroll : undefined}
|
|
199
197
|
,
|
|
@@ -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 {};
|