es-grid-template 1.2.6 → 1.2.7
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 +2 -1
- package/es/grid-component/ContextMenu.js +2 -1
- package/es/grid-component/EditableCell.js +16 -11
- package/es/grid-component/InternalTable.js +128 -2
- package/es/grid-component/hooks/columns/index.js +2 -1
- package/es/grid-component/hooks/useColumns.js +5 -2
- package/es/grid-component/hooks/utils.d.ts +1 -1
- package/es/grid-component/hooks/utils.js +1 -1
- package/es/grid-component/styles.scss +13 -3
- package/es/grid-component/table/GridEdit.js +36 -18
- package/es/grid-component/type.d.ts +34 -7
- package/lib/grid-component/ColumnsChoose.js +2 -1
- package/lib/grid-component/ContextMenu.js +2 -1
- package/lib/grid-component/EditableCell.js +16 -11
- package/lib/grid-component/InternalTable.js +127 -1
- package/lib/grid-component/hooks/columns/index.js +2 -1
- package/lib/grid-component/hooks/useColumns.js +5 -2
- package/lib/grid-component/hooks/utils.d.ts +1 -1
- package/lib/grid-component/hooks/utils.js +1 -1
- package/lib/grid-component/styles.scss +13 -3
- package/lib/grid-component/table/GridEdit.js +36 -18
- package/lib/grid-component/type.d.ts +34 -7
- package/package.json +108 -106
|
@@ -536,7 +536,8 @@ export const ColumnsChoose = props => {
|
|
|
536
536
|
trigger: "click",
|
|
537
537
|
open: clicked,
|
|
538
538
|
onOpenChange: handleClickChange,
|
|
539
|
-
arrow: false
|
|
539
|
+
arrow: false,
|
|
540
|
+
zIndex: 1065
|
|
540
541
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
541
542
|
arrow: false,
|
|
542
543
|
title: 'Cài đặt'
|
|
@@ -267,15 +267,15 @@ const EditableCell = props => {
|
|
|
267
267
|
const columnsTable = rr.map(colSelect => {
|
|
268
268
|
return {
|
|
269
269
|
title: colSelect.headerTemplate ? colSelect.headerTemplate : t ? t(colSelect.headerText) : colSelect.headerText,
|
|
270
|
-
dataIndex: colSelect.dataIndex,
|
|
270
|
+
dataIndex: colSelect.field ?? colSelect.dataIndex,
|
|
271
271
|
key: colSelect.dataIndex,
|
|
272
272
|
render: colSelect.template ? (text, recd, ind) => /*#__PURE__*/React.createElement(React.Fragment, null, colSelect.template?.({
|
|
273
273
|
value: text,
|
|
274
274
|
rowData: recd,
|
|
275
275
|
column: colSelect,
|
|
276
|
-
field: colSelect.
|
|
276
|
+
field: colSelect.field,
|
|
277
277
|
index: ind,
|
|
278
|
-
[colSelect.
|
|
278
|
+
[colSelect.field]: text
|
|
279
279
|
})) : undefined,
|
|
280
280
|
width: colSelect.width,
|
|
281
281
|
ellipsis: true,
|
|
@@ -323,8 +323,9 @@ const EditableCell = props => {
|
|
|
323
323
|
width: '100%',
|
|
324
324
|
height: '100%'
|
|
325
325
|
},
|
|
326
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
327
|
-
autoFocus
|
|
326
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
327
|
+
// autoFocus={true}
|
|
328
|
+
,
|
|
328
329
|
placeholder: t ? t('Select') : 'Select',
|
|
329
330
|
allowClear: column.isClearable ?? false,
|
|
330
331
|
maxTagCount: 'responsive',
|
|
@@ -397,8 +398,10 @@ const EditableCell = props => {
|
|
|
397
398
|
showSearch: true,
|
|
398
399
|
mode: isMulti || selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
399
400
|
valueSelectAble: true,
|
|
400
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
401
|
-
autoFocus
|
|
401
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
402
|
+
// autoFocus={true}
|
|
403
|
+
,
|
|
404
|
+
|
|
402
405
|
style: {
|
|
403
406
|
width: '100%',
|
|
404
407
|
height: '100%'
|
|
@@ -448,8 +451,9 @@ const EditableCell = props => {
|
|
|
448
451
|
});
|
|
449
452
|
},
|
|
450
453
|
showSearch: true,
|
|
451
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
452
|
-
autoFocus
|
|
454
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
455
|
+
// autoFocus={true}
|
|
456
|
+
,
|
|
453
457
|
mode: isMulti || selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
454
458
|
valueSelectAble: true,
|
|
455
459
|
style: {
|
|
@@ -528,8 +532,9 @@ const EditableCell = props => {
|
|
|
528
532
|
treeData: newTreeData,
|
|
529
533
|
placeholder: t ? t('Select') : 'Select',
|
|
530
534
|
treeDefaultExpandAll: true,
|
|
531
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
532
|
-
autoFocus
|
|
535
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
536
|
+
// autoFocus={true}
|
|
537
|
+
,
|
|
533
538
|
virtual: true,
|
|
534
539
|
allowClear: true
|
|
535
540
|
// maxTagTextLength={column?.editSelectSettings?.showItems}
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
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,
|
|
6
|
+
import { addRowIdArray, findItemByKey,
|
|
7
7
|
// convertFlatColumn,
|
|
8
8
|
removeColumns,
|
|
9
9
|
// addRowIdArray,
|
|
@@ -19,7 +19,10 @@ import useColumns from "./hooks/useColumns";
|
|
|
19
19
|
import "./styles.scss";
|
|
20
20
|
import { flatColumns2 } from "./hooks/columns";
|
|
21
21
|
import Group from "./table/Group";
|
|
22
|
+
import Swal from "sweetalert2";
|
|
23
|
+
import withReactContent from "sweetalert2-react-content";
|
|
22
24
|
dayjs.extend(customParseFormat);
|
|
25
|
+
const MySwal = withReactContent(Swal);
|
|
23
26
|
|
|
24
27
|
// const ASCEND = 'ascend';
|
|
25
28
|
// const DESCEND = 'descend';
|
|
@@ -77,6 +80,8 @@ const InternalTable = props => {
|
|
|
77
80
|
groupAble,
|
|
78
81
|
groupSetting,
|
|
79
82
|
groupColumns,
|
|
83
|
+
commandClick,
|
|
84
|
+
commandSettings,
|
|
80
85
|
...rest
|
|
81
86
|
} = props;
|
|
82
87
|
const rowKey = React.useMemo(() => {
|
|
@@ -202,6 +207,126 @@ const InternalTable = props => {
|
|
|
202
207
|
// setMergedData(newData)
|
|
203
208
|
onDataChange?.(newData);
|
|
204
209
|
};
|
|
210
|
+
const triggerCommandClick = args => {
|
|
211
|
+
const {
|
|
212
|
+
id,
|
|
213
|
+
rowId,
|
|
214
|
+
rowData,
|
|
215
|
+
index
|
|
216
|
+
} = args;
|
|
217
|
+
const tmpData = [...dataSource];
|
|
218
|
+
if (id === 'DELETE') {
|
|
219
|
+
// bật modal confirm
|
|
220
|
+
if (commandSettings && commandSettings.confirmDialog) {
|
|
221
|
+
MySwal.fire({
|
|
222
|
+
title: t ? t('Confirm') : 'Confirm',
|
|
223
|
+
text: t ? t('Do you want to delete item?') : 'Do you want to delete item?',
|
|
224
|
+
// icon: 'warning',
|
|
225
|
+
allowOutsideClick: false,
|
|
226
|
+
showCancelButton: true,
|
|
227
|
+
confirmButtonText: t ? t('Delete') : 'Delete',
|
|
228
|
+
cancelButtonText: t ? t('Cancel') : 'Cancel',
|
|
229
|
+
customClass: {
|
|
230
|
+
confirmButton: 'be-button btn-primary',
|
|
231
|
+
cancelButton: 'be-button btn-danger ms-1'
|
|
232
|
+
},
|
|
233
|
+
buttonsStyling: false
|
|
234
|
+
}).then(async result => {
|
|
235
|
+
if (result.value) {
|
|
236
|
+
if (!commandSettings || commandSettings && commandSettings.client !== false) {
|
|
237
|
+
// client
|
|
238
|
+
|
|
239
|
+
// kiểm tra dòng hiện tại có parent
|
|
240
|
+
|
|
241
|
+
let newData = [];
|
|
242
|
+
if (rowData?.parentId) {
|
|
243
|
+
const parent = findItemByKey(dataSource, rowKey, rowData.parentId);
|
|
244
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
245
|
+
const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
|
|
246
|
+
childData.splice(Number(findIndex), 1);
|
|
247
|
+
const newRowData = {
|
|
248
|
+
...parent,
|
|
249
|
+
children: childData
|
|
250
|
+
};
|
|
251
|
+
// const newDataSource = updateArrayByKey(tmpData, newRowData, rowKey as string)
|
|
252
|
+
newData = updateArrayByKey(tmpData, newRowData, rowKey);
|
|
253
|
+
} else {
|
|
254
|
+
tmpData.splice(Number(index), 1);
|
|
255
|
+
newData = [...tmpData];
|
|
256
|
+
}
|
|
257
|
+
if (commandClick) {
|
|
258
|
+
commandClick({
|
|
259
|
+
id,
|
|
260
|
+
rowId: rowData.rowId,
|
|
261
|
+
rowData,
|
|
262
|
+
index,
|
|
263
|
+
// rows: [...tmpData]
|
|
264
|
+
rows: [...newData]
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
// server ~~ không làm gì
|
|
269
|
+
if (commandClick) {
|
|
270
|
+
commandClick({
|
|
271
|
+
id,
|
|
272
|
+
rowId: rowData.rowId,
|
|
273
|
+
rowData,
|
|
274
|
+
index,
|
|
275
|
+
rows: [...dataSource]
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
} else if (result.dismiss === MySwal.DismissReason.cancel) {}
|
|
280
|
+
});
|
|
281
|
+
} else {
|
|
282
|
+
// -------------------
|
|
283
|
+
|
|
284
|
+
if (!commandSettings || commandSettings && commandSettings.client !== false) {
|
|
285
|
+
// client
|
|
286
|
+
|
|
287
|
+
let newData2 = [];
|
|
288
|
+
if (rowData?.parentId) {
|
|
289
|
+
const parent = findItemByKey(dataSource, rowKey, rowData.parentId);
|
|
290
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
291
|
+
const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
|
|
292
|
+
childData.splice(Number(findIndex), 1);
|
|
293
|
+
const newRowData = {
|
|
294
|
+
...parent,
|
|
295
|
+
children: childData
|
|
296
|
+
};
|
|
297
|
+
newData2 = updateArrayByKey(tmpData, newRowData, rowKey);
|
|
298
|
+
} else {
|
|
299
|
+
tmpData.splice(Number(index), 1);
|
|
300
|
+
newData2 = [...tmpData];
|
|
301
|
+
}
|
|
302
|
+
if (commandClick) {
|
|
303
|
+
commandClick({
|
|
304
|
+
id,
|
|
305
|
+
rowId,
|
|
306
|
+
rowData,
|
|
307
|
+
index,
|
|
308
|
+
rows: [...newData2]
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
// server
|
|
313
|
+
if (commandClick) {
|
|
314
|
+
commandClick({
|
|
315
|
+
id,
|
|
316
|
+
rowId,
|
|
317
|
+
rowData,
|
|
318
|
+
index,
|
|
319
|
+
rows: [...dataSource]
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
} else {
|
|
325
|
+
if (commandClick) {
|
|
326
|
+
commandClick(args);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
};
|
|
205
330
|
const triggerPaste = (pastedRows, pastedColumnsArray, newData) => {
|
|
206
331
|
const handlePasteCallback = callbackData => {
|
|
207
332
|
const newDataUpdate = updateData(dataSource, callbackData, rowKey);
|
|
@@ -257,7 +382,8 @@ const InternalTable = props => {
|
|
|
257
382
|
clickHeaderToSort: clickHeaderToSort,
|
|
258
383
|
groupSetting: groupSetting,
|
|
259
384
|
groupAble: groupAble,
|
|
260
|
-
groupColumns: groupColumns
|
|
385
|
+
groupColumns: groupColumns,
|
|
386
|
+
commandClick: triggerCommandClick
|
|
261
387
|
}));
|
|
262
388
|
};
|
|
263
389
|
export default InternalTable;
|
|
@@ -364,8 +364,9 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
364
364
|
className: 'mb-1'
|
|
365
365
|
}, /*#__PURE__*/React.createElement(Select
|
|
366
366
|
// options={translateOption(numberOperator, t)}
|
|
367
|
+
// options={find ? options : column.source ?? []}
|
|
367
368
|
, {
|
|
368
|
-
options:
|
|
369
|
+
options: column.source ? column.source : options ?? [],
|
|
369
370
|
style: {
|
|
370
371
|
width: '100%',
|
|
371
372
|
marginBottom: 8
|
|
@@ -164,7 +164,10 @@ const useColumns = config => {
|
|
|
164
164
|
// title: () => (<span>{t ? t(col.columnGroupText ?? col.headerText ?? col.title) : col.columnGroupText ?? col.headerText ?? col.title}</span>),
|
|
165
165
|
ellipsis: col.ellipsis !== false,
|
|
166
166
|
align: col.textAlign ?? col.align,
|
|
167
|
-
fixed: col.
|
|
167
|
+
fixed: col.fixedType ?? col.fixed,
|
|
168
|
+
isSummary: col.isSummary ?? col.haveSum,
|
|
169
|
+
hidden: col.hidden ?? col.visible === false
|
|
170
|
+
// hidden: true
|
|
168
171
|
};
|
|
169
172
|
if (transformedColumn.children && transformedColumn.children?.length) {
|
|
170
173
|
return {
|
|
@@ -269,7 +272,7 @@ const useColumns = config => {
|
|
|
269
272
|
}
|
|
270
273
|
return renderContent(col, value, record, rowIndex, format);
|
|
271
274
|
},
|
|
272
|
-
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ?
|
|
275
|
+
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(col.field) ? true : transformedColumn.hidden
|
|
273
276
|
};
|
|
274
277
|
});
|
|
275
278
|
};
|
|
@@ -68,4 +68,4 @@ export declare const removeColumns: <RecordType>(columns: ColumnsTable<RecordTyp
|
|
|
68
68
|
export declare const convertFlatColumn: (array: ColumnsTable) => ColumnsTable[];
|
|
69
69
|
export declare const convertColumns: <RecordType>(cols: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
|
|
70
70
|
export declare const checkChild: (inputArray: any[]) => boolean;
|
|
71
|
-
export declare const isEditable: <RecordType>(column: ColumnEditType, rowData: RecordType) => boolean | ((rowData: any) => boolean);
|
|
71
|
+
export declare const isEditable: <RecordType>(column: ColumnEditType, rowData: RecordType) => (boolean | ((rowData: any) => boolean)) & (boolean | ((rowData: any) => boolean));
|
|
@@ -737,7 +737,7 @@ export const convertColumns = cols => {
|
|
|
737
737
|
// title: () => (<span>{t ? t(col.columnGroupText ?? col.headerText ?? col.title) : col.columnGroupText ?? col.headerText ?? col.title}</span>),
|
|
738
738
|
ellipsis: col.ellipsis !== false,
|
|
739
739
|
align: col.textAlign ?? col.align,
|
|
740
|
-
fixed: col.
|
|
740
|
+
fixed: col.fixedType ?? col.fixed
|
|
741
741
|
};
|
|
742
742
|
if (transformedColumn.children && transformedColumn.children?.length) {
|
|
743
743
|
return {
|
|
@@ -205,6 +205,8 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
205
205
|
border-bottom: 1px solid $tableBorderColor;
|
|
206
206
|
//background: #fff;
|
|
207
207
|
font-weight: 500;
|
|
208
|
+
//line-height: 23px;
|
|
209
|
+
//height: 40px;
|
|
208
210
|
}
|
|
209
211
|
}
|
|
210
212
|
|
|
@@ -336,10 +338,18 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
336
338
|
.#{$prefix}-table-wrapper {
|
|
337
339
|
|
|
338
340
|
.#{$prefix}-table.#{$prefix}-table-small {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
341
|
+
.ui-rc-table-thead {
|
|
342
|
+
>tr >th.#{$prefix}-table-selection-column{
|
|
343
|
+
//padding-block: 7px;
|
|
344
|
+
padding: 0;
|
|
345
|
+
//padding: 6px 8px;
|
|
346
|
+
}
|
|
342
347
|
}
|
|
348
|
+
//.#{$prefix}-table-selection-column{
|
|
349
|
+
// padding-block: 7px;
|
|
350
|
+
// padding: 0;
|
|
351
|
+
// //padding: 6px 8px;
|
|
352
|
+
//}
|
|
343
353
|
}
|
|
344
354
|
|
|
345
355
|
&.grid-editable {
|
|
@@ -120,7 +120,7 @@ const GridEdit = props => {
|
|
|
120
120
|
const handleAddSingle = item => {
|
|
121
121
|
const defaultRowValue = getDefaultValue(defaultValue);
|
|
122
122
|
const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid();
|
|
123
|
-
if (item.onClick) {
|
|
123
|
+
if (item && item.onClick) {
|
|
124
124
|
item.onClick({
|
|
125
125
|
toolbar: item
|
|
126
126
|
});
|
|
@@ -183,7 +183,7 @@ const GridEdit = props => {
|
|
|
183
183
|
toolbar: item
|
|
184
184
|
});
|
|
185
185
|
} else {
|
|
186
|
-
if (!record
|
|
186
|
+
if (!record?.parentId) {
|
|
187
187
|
// Cập nhật data mới
|
|
188
188
|
const newData = [...dataSource];
|
|
189
189
|
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
@@ -228,7 +228,7 @@ const GridEdit = props => {
|
|
|
228
228
|
toolbar: item
|
|
229
229
|
});
|
|
230
230
|
} else {
|
|
231
|
-
if (!record
|
|
231
|
+
if (!record?.parentId) {
|
|
232
232
|
// Cập nhật data mới
|
|
233
233
|
const newData = [...dataSource];
|
|
234
234
|
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
@@ -328,7 +328,7 @@ const GridEdit = props => {
|
|
|
328
328
|
color: '#28c76f'
|
|
329
329
|
},
|
|
330
330
|
onClick: () => handleAddSingle(item)
|
|
331
|
-
}, item.
|
|
331
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
332
332
|
}
|
|
333
333
|
};
|
|
334
334
|
}
|
|
@@ -346,7 +346,7 @@ const GridEdit = props => {
|
|
|
346
346
|
variant: 'outlined',
|
|
347
347
|
onClick: handleDeleteAll,
|
|
348
348
|
className: "d-flex toolbar-button"
|
|
349
|
-
}, item.
|
|
349
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
352
|
}
|
|
@@ -377,7 +377,7 @@ const GridEdit = props => {
|
|
|
377
377
|
color: '#28c76f'
|
|
378
378
|
},
|
|
379
379
|
onClick: () => handleAddSingle(item)
|
|
380
|
-
}, item.
|
|
380
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
381
381
|
}
|
|
382
382
|
};
|
|
383
383
|
}
|
|
@@ -395,7 +395,7 @@ const GridEdit = props => {
|
|
|
395
395
|
variant: 'outlined',
|
|
396
396
|
onClick: handleDuplicate,
|
|
397
397
|
className: "d-flex toolbar-button"
|
|
398
|
-
}, item.
|
|
398
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate')));
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
}
|
|
@@ -413,7 +413,7 @@ const GridEdit = props => {
|
|
|
413
413
|
variant: 'outlined',
|
|
414
414
|
onClick: () => handleInsertBefore(item),
|
|
415
415
|
className: "d-flex toolbar-button"
|
|
416
|
-
}, item.
|
|
416
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before')));
|
|
417
417
|
}
|
|
418
418
|
};
|
|
419
419
|
}
|
|
@@ -431,7 +431,7 @@ const GridEdit = props => {
|
|
|
431
431
|
variant: 'outlined',
|
|
432
432
|
onClick: () => handleInsertAfter(item),
|
|
433
433
|
className: "d-flex toolbar-button"
|
|
434
|
-
}, item.
|
|
434
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
|
|
435
435
|
}
|
|
436
436
|
};
|
|
437
437
|
}
|
|
@@ -449,7 +449,7 @@ const GridEdit = props => {
|
|
|
449
449
|
variant: 'outlined',
|
|
450
450
|
onClick: () => handleInsertChild(item),
|
|
451
451
|
className: "d-flex toolbar-button"
|
|
452
|
-
}, item.
|
|
452
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
|
|
453
453
|
}
|
|
454
454
|
};
|
|
455
455
|
}
|
|
@@ -467,7 +467,7 @@ const GridEdit = props => {
|
|
|
467
467
|
variant: 'outlined',
|
|
468
468
|
onClick: handleDeleteAll,
|
|
469
469
|
className: "d-flex toolbar-button"
|
|
470
|
-
}, item.
|
|
470
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
471
471
|
}
|
|
472
472
|
};
|
|
473
473
|
}
|
|
@@ -620,7 +620,7 @@ const GridEdit = props => {
|
|
|
620
620
|
});
|
|
621
621
|
const newRange = addRows8(table, getRowsPasteIndex(pastesArray).length);
|
|
622
622
|
const record = flattenData(childrenColumnName, dataSource)[getFirstSelectCell(pastesArray).row];
|
|
623
|
-
if (!record
|
|
623
|
+
if (!record?.parentId) {
|
|
624
624
|
// Cập nhật data mới
|
|
625
625
|
const newData = [...dataSource];
|
|
626
626
|
|
|
@@ -898,7 +898,7 @@ const GridEdit = props => {
|
|
|
898
898
|
|
|
899
899
|
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
900
900
|
const rows = pasteData.split("\n").map(row => row.replace(/\r/g, "").split("\t"));
|
|
901
|
-
if (!record
|
|
901
|
+
if (!record?.parentId) {
|
|
902
902
|
// Cập nhật data mới
|
|
903
903
|
const newData = [...dataSource];
|
|
904
904
|
|
|
@@ -1294,7 +1294,10 @@ const GridEdit = props => {
|
|
|
1294
1294
|
onKeyDown: event => {
|
|
1295
1295
|
const key = getRowKey(record, dataSource.indexOf(record));
|
|
1296
1296
|
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
1297
|
-
if (
|
|
1297
|
+
if (record[rowKey] !== editingKey) {
|
|
1298
|
+
// ~~ khi editingKey = ''
|
|
1299
|
+
event.preventDefault();
|
|
1300
|
+
event.stopPropagation();
|
|
1298
1301
|
handleEdit(record, column, column.editType, event);
|
|
1299
1302
|
handleCellClick(rowNumber, record, column);
|
|
1300
1303
|
const hasKey = mergedExpandedKeys.has(key);
|
|
@@ -1304,9 +1307,24 @@ const GridEdit = props => {
|
|
|
1304
1307
|
} else {
|
|
1305
1308
|
onTriggerExpand(record);
|
|
1306
1309
|
}
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
+
} else {
|
|
1311
|
+
if (event.key === 'Enter') {
|
|
1312
|
+
event.preventDefault();
|
|
1313
|
+
event.stopPropagation();
|
|
1314
|
+
if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length && event.key === 'Enter') {
|
|
1315
|
+
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
1316
|
+
} else {
|
|
1317
|
+
// focus cell hiện tại và tắt edit
|
|
1318
|
+
handleFocusCell(rowNumber ?? 0, colIndex, column, 'vertical', event);
|
|
1319
|
+
setEditingKey('');
|
|
1320
|
+
|
|
1321
|
+
// thêm dòng mới
|
|
1322
|
+
|
|
1323
|
+
// handleAddSingle()
|
|
1324
|
+
//
|
|
1325
|
+
// handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event)
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1310
1328
|
}
|
|
1311
1329
|
}
|
|
1312
1330
|
if (event.key === 'Tab') {
|
|
@@ -1359,7 +1377,7 @@ const GridEdit = props => {
|
|
|
1359
1377
|
},
|
|
1360
1378
|
onClick: () => {
|
|
1361
1379
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1362
|
-
setEditingKey('')
|
|
1380
|
+
// setEditingKey('')
|
|
1363
1381
|
}
|
|
1364
1382
|
},
|
|
1365
1383
|
// className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
|
|
@@ -7,15 +7,17 @@ import type { ToolbarItem as RcToolbarItem } from "rc-master-ui/es/toolbar";
|
|
|
7
7
|
import type { ItemType } from "rc-master-ui/es/menu/interface";
|
|
8
8
|
import type { FieldNames, FilterFunc } from "rc-select/es/Select";
|
|
9
9
|
import type { ColorPickerProps } from "antd";
|
|
10
|
+
import type { FixedType } from "rc-base-table/lib/interface";
|
|
10
11
|
export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
|
|
11
12
|
export type AnyObject = Record<PropertyKey, any>;
|
|
12
|
-
export type ToolbarItem = Omit<RcToolbarItem, 'position'> & {
|
|
13
|
-
position?: 'Top' | 'Bottom';
|
|
14
|
-
onClick?: (args: any) => void;
|
|
15
|
-
};
|
|
16
13
|
export type SelectMode = 'checkbox' | 'radio' | undefined;
|
|
17
14
|
export type ITextAlign = 'center' | 'left' | 'right';
|
|
18
15
|
export type Frozen = 'left' | 'right' | 'Left' | 'Right';
|
|
16
|
+
export type ToolbarItem = Omit<RcToolbarItem, 'position' | 'align'> & {
|
|
17
|
+
position?: 'Top' | 'Bottom';
|
|
18
|
+
align?: ITextAlign;
|
|
19
|
+
onClick?: (args: any) => void;
|
|
20
|
+
};
|
|
19
21
|
export type ContextMenuItem = ItemType & {};
|
|
20
22
|
export type ITemplateColumn = {
|
|
21
23
|
value: any;
|
|
@@ -26,7 +28,7 @@ export type ITemplateColumn = {
|
|
|
26
28
|
};
|
|
27
29
|
export type ColumnSelectTable = {
|
|
28
30
|
field: string;
|
|
29
|
-
dataIndex
|
|
31
|
+
dataIndex?: string;
|
|
30
32
|
type?: IColumnType;
|
|
31
33
|
headerText?: string;
|
|
32
34
|
fixedType?: 'left' | 'right' | undefined;
|
|
@@ -86,6 +88,8 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
86
88
|
field?: string;
|
|
87
89
|
key?: any;
|
|
88
90
|
type?: IColumnType;
|
|
91
|
+
/** @deprecated This function is deprecated and should use `onChange` instead */
|
|
92
|
+
haveSum?: boolean;
|
|
89
93
|
isSummary?: boolean;
|
|
90
94
|
summaryTemplate?: (data: number, key: string) => ReactElement | ReactNode;
|
|
91
95
|
maxWidth?: string | number;
|
|
@@ -100,16 +104,34 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
100
104
|
source?: any[];
|
|
101
105
|
showFilterSearch?: boolean;
|
|
102
106
|
headerText?: string;
|
|
107
|
+
visible?: boolean;
|
|
103
108
|
headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
|
|
104
109
|
columnGroupText?: string;
|
|
105
110
|
textAlign?: ITextAlign;
|
|
106
|
-
|
|
107
|
-
template?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
|
|
111
|
+
template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
|
|
108
112
|
showTooltip?: boolean;
|
|
109
113
|
tooltipDescription?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
|
|
110
114
|
headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnType<RecordType>) => React.ReactNode | React.ReactElement);
|
|
111
115
|
commandItems?: CommandItem[];
|
|
112
116
|
children?: ColumnType<RecordType>[];
|
|
117
|
+
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
118
|
+
disable?: boolean | ((rowData: any) => boolean);
|
|
119
|
+
editEnable?: boolean | ((rowData: any) => boolean);
|
|
120
|
+
isClearable?: boolean;
|
|
121
|
+
maxDate?: any;
|
|
122
|
+
minDate?: any;
|
|
123
|
+
maxTime?: any;
|
|
124
|
+
minTime?: any;
|
|
125
|
+
max?: number;
|
|
126
|
+
min?: number;
|
|
127
|
+
editSelectSettings?: IEditSelectSettings;
|
|
128
|
+
fixedType?: FixedType;
|
|
129
|
+
};
|
|
130
|
+
export type ColumnTemplate<RecordType> = {
|
|
131
|
+
value: any;
|
|
132
|
+
rowData: RecordType;
|
|
133
|
+
index: number;
|
|
134
|
+
field: string;
|
|
113
135
|
};
|
|
114
136
|
export type ColumnEditType<RecordType = AnyObject> = Omit<ColumnType<RecordType>, 'children'> & {
|
|
115
137
|
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
@@ -180,6 +202,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
180
202
|
defaultValue?: AnyObject | (() => AnyObject);
|
|
181
203
|
summary?: boolean | ((data: readonly RecordType[]) => React.ReactNode);
|
|
182
204
|
showEmptyText?: boolean;
|
|
205
|
+
commandSettings?: CommandSettings;
|
|
183
206
|
}
|
|
184
207
|
export interface TableEditProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, 'columns'> {
|
|
185
208
|
columns: ColumnsTable<RecordType>;
|
|
@@ -289,4 +312,8 @@ export type IFormat = {
|
|
|
289
312
|
};
|
|
290
313
|
export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;
|
|
291
314
|
export type Presets = Required<ColorPickerProps>['presets'][number];
|
|
315
|
+
export type CommandSettings = {
|
|
316
|
+
client?: boolean;
|
|
317
|
+
confirmDialog?: boolean;
|
|
318
|
+
};
|
|
292
319
|
export {};
|
|
@@ -545,7 +545,8 @@ const ColumnsChoose = props => {
|
|
|
545
545
|
trigger: "click",
|
|
546
546
|
open: clicked,
|
|
547
547
|
onOpenChange: handleClickChange,
|
|
548
|
-
arrow: false
|
|
548
|
+
arrow: false,
|
|
549
|
+
zIndex: 1065
|
|
549
550
|
}, /*#__PURE__*/_react.default.createElement(_antd.Tooltip, {
|
|
550
551
|
arrow: false,
|
|
551
552
|
title: 'Cài đặt'
|
|
@@ -104,7 +104,8 @@ const ContextMenu = props => {
|
|
|
104
104
|
items: contextMenuItems,
|
|
105
105
|
style: {
|
|
106
106
|
minWidth: 200,
|
|
107
|
-
maxHeight: pos.viewportHeight - 20
|
|
107
|
+
maxHeight: pos.viewportHeight - 20,
|
|
108
|
+
width: 'fit-content'
|
|
108
109
|
},
|
|
109
110
|
rootClassName: 'popup-context-menu',
|
|
110
111
|
onClick: e => {
|