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
|
@@ -268,15 +268,15 @@ const EditableCell = props => {
|
|
|
268
268
|
const columnsTable = rr.map(colSelect => {
|
|
269
269
|
return {
|
|
270
270
|
title: colSelect.headerTemplate ? colSelect.headerTemplate : t ? t(colSelect.headerText) : colSelect.headerText,
|
|
271
|
-
dataIndex: colSelect.dataIndex,
|
|
271
|
+
dataIndex: colSelect.field ?? colSelect.dataIndex,
|
|
272
272
|
key: colSelect.dataIndex,
|
|
273
273
|
render: colSelect.template ? (text, recd, ind) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, colSelect.template?.({
|
|
274
274
|
value: text,
|
|
275
275
|
rowData: recd,
|
|
276
276
|
column: colSelect,
|
|
277
|
-
field: colSelect.
|
|
277
|
+
field: colSelect.field,
|
|
278
278
|
index: ind,
|
|
279
|
-
[colSelect.
|
|
279
|
+
[colSelect.field]: text
|
|
280
280
|
})) : undefined,
|
|
281
281
|
width: colSelect.width,
|
|
282
282
|
ellipsis: true,
|
|
@@ -324,8 +324,9 @@ const EditableCell = props => {
|
|
|
324
324
|
width: '100%',
|
|
325
325
|
height: '100%'
|
|
326
326
|
},
|
|
327
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
328
|
-
autoFocus
|
|
327
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
328
|
+
// autoFocus={true}
|
|
329
|
+
,
|
|
329
330
|
placeholder: t ? t('Select') : 'Select',
|
|
330
331
|
allowClear: column.isClearable ?? false,
|
|
331
332
|
maxTagCount: 'responsive',
|
|
@@ -398,8 +399,10 @@ const EditableCell = props => {
|
|
|
398
399
|
showSearch: true,
|
|
399
400
|
mode: isMulti || selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
400
401
|
valueSelectAble: true,
|
|
401
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
402
|
-
autoFocus
|
|
402
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
403
|
+
// autoFocus={true}
|
|
404
|
+
,
|
|
405
|
+
|
|
403
406
|
style: {
|
|
404
407
|
width: '100%',
|
|
405
408
|
height: '100%'
|
|
@@ -449,8 +452,9 @@ const EditableCell = props => {
|
|
|
449
452
|
});
|
|
450
453
|
},
|
|
451
454
|
showSearch: true,
|
|
452
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
453
|
-
autoFocus
|
|
455
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
456
|
+
// autoFocus={true}
|
|
457
|
+
,
|
|
454
458
|
mode: isMulti || selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
455
459
|
valueSelectAble: true,
|
|
456
460
|
style: {
|
|
@@ -529,8 +533,9 @@ const EditableCell = props => {
|
|
|
529
533
|
treeData: newTreeData,
|
|
530
534
|
placeholder: t ? t('Select') : 'Select',
|
|
531
535
|
treeDefaultExpandAll: true,
|
|
532
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
533
|
-
autoFocus
|
|
536
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
537
|
+
// autoFocus={true}
|
|
538
|
+
,
|
|
534
539
|
virtual: true,
|
|
535
540
|
allowClear: true
|
|
536
541
|
// maxTagTextLength={column?.editSelectSettings?.showItems}
|
|
@@ -22,7 +22,10 @@ var _useColumns = _interopRequireDefault(require("./hooks/useColumns"));
|
|
|
22
22
|
require("./styles.scss");
|
|
23
23
|
var _columns = require("./hooks/columns");
|
|
24
24
|
var _Group = _interopRequireDefault(require("./table/Group"));
|
|
25
|
+
var _sweetalert = _interopRequireDefault(require("sweetalert2"));
|
|
26
|
+
var _sweetalert2ReactContent = _interopRequireDefault(require("sweetalert2-react-content"));
|
|
25
27
|
_dayjs.default.extend(_customParseFormat.default);
|
|
28
|
+
const MySwal = (0, _sweetalert2ReactContent.default)(_sweetalert.default);
|
|
26
29
|
|
|
27
30
|
// const ASCEND = 'ascend';
|
|
28
31
|
// const DESCEND = 'descend';
|
|
@@ -80,6 +83,8 @@ const InternalTable = props => {
|
|
|
80
83
|
groupAble,
|
|
81
84
|
groupSetting,
|
|
82
85
|
groupColumns,
|
|
86
|
+
commandClick,
|
|
87
|
+
commandSettings,
|
|
83
88
|
...rest
|
|
84
89
|
} = props;
|
|
85
90
|
const rowKey = _react.default.useMemo(() => {
|
|
@@ -205,6 +210,126 @@ const InternalTable = props => {
|
|
|
205
210
|
// setMergedData(newData)
|
|
206
211
|
onDataChange?.(newData);
|
|
207
212
|
};
|
|
213
|
+
const triggerCommandClick = args => {
|
|
214
|
+
const {
|
|
215
|
+
id,
|
|
216
|
+
rowId,
|
|
217
|
+
rowData,
|
|
218
|
+
index
|
|
219
|
+
} = args;
|
|
220
|
+
const tmpData = [...dataSource];
|
|
221
|
+
if (id === 'DELETE') {
|
|
222
|
+
// bật modal confirm
|
|
223
|
+
if (commandSettings && commandSettings.confirmDialog) {
|
|
224
|
+
MySwal.fire({
|
|
225
|
+
title: t ? t('Confirm') : 'Confirm',
|
|
226
|
+
text: t ? t('Do you want to delete item?') : 'Do you want to delete item?',
|
|
227
|
+
// icon: 'warning',
|
|
228
|
+
allowOutsideClick: false,
|
|
229
|
+
showCancelButton: true,
|
|
230
|
+
confirmButtonText: t ? t('Delete') : 'Delete',
|
|
231
|
+
cancelButtonText: t ? t('Cancel') : 'Cancel',
|
|
232
|
+
customClass: {
|
|
233
|
+
confirmButton: 'be-button btn-primary',
|
|
234
|
+
cancelButton: 'be-button btn-danger ms-1'
|
|
235
|
+
},
|
|
236
|
+
buttonsStyling: false
|
|
237
|
+
}).then(async result => {
|
|
238
|
+
if (result.value) {
|
|
239
|
+
if (!commandSettings || commandSettings && commandSettings.client !== false) {
|
|
240
|
+
// client
|
|
241
|
+
|
|
242
|
+
// kiểm tra dòng hiện tại có parent
|
|
243
|
+
|
|
244
|
+
let newData = [];
|
|
245
|
+
if (rowData?.parentId) {
|
|
246
|
+
const parent = (0, _hooks.findItemByKey)(dataSource, rowKey, rowData.parentId);
|
|
247
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
248
|
+
const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
|
|
249
|
+
childData.splice(Number(findIndex), 1);
|
|
250
|
+
const newRowData = {
|
|
251
|
+
...parent,
|
|
252
|
+
children: childData
|
|
253
|
+
};
|
|
254
|
+
// const newDataSource = updateArrayByKey(tmpData, newRowData, rowKey as string)
|
|
255
|
+
newData = (0, _hooks.updateArrayByKey)(tmpData, newRowData, rowKey);
|
|
256
|
+
} else {
|
|
257
|
+
tmpData.splice(Number(index), 1);
|
|
258
|
+
newData = [...tmpData];
|
|
259
|
+
}
|
|
260
|
+
if (commandClick) {
|
|
261
|
+
commandClick({
|
|
262
|
+
id,
|
|
263
|
+
rowId: rowData.rowId,
|
|
264
|
+
rowData,
|
|
265
|
+
index,
|
|
266
|
+
// rows: [...tmpData]
|
|
267
|
+
rows: [...newData]
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
// server ~~ không làm gì
|
|
272
|
+
if (commandClick) {
|
|
273
|
+
commandClick({
|
|
274
|
+
id,
|
|
275
|
+
rowId: rowData.rowId,
|
|
276
|
+
rowData,
|
|
277
|
+
index,
|
|
278
|
+
rows: [...dataSource]
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} else if (result.dismiss === MySwal.DismissReason.cancel) {}
|
|
283
|
+
});
|
|
284
|
+
} else {
|
|
285
|
+
// -------------------
|
|
286
|
+
|
|
287
|
+
if (!commandSettings || commandSettings && commandSettings.client !== false) {
|
|
288
|
+
// client
|
|
289
|
+
|
|
290
|
+
let newData2 = [];
|
|
291
|
+
if (rowData?.parentId) {
|
|
292
|
+
const parent = (0, _hooks.findItemByKey)(dataSource, rowKey, rowData.parentId);
|
|
293
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
294
|
+
const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
|
|
295
|
+
childData.splice(Number(findIndex), 1);
|
|
296
|
+
const newRowData = {
|
|
297
|
+
...parent,
|
|
298
|
+
children: childData
|
|
299
|
+
};
|
|
300
|
+
newData2 = (0, _hooks.updateArrayByKey)(tmpData, newRowData, rowKey);
|
|
301
|
+
} else {
|
|
302
|
+
tmpData.splice(Number(index), 1);
|
|
303
|
+
newData2 = [...tmpData];
|
|
304
|
+
}
|
|
305
|
+
if (commandClick) {
|
|
306
|
+
commandClick({
|
|
307
|
+
id,
|
|
308
|
+
rowId,
|
|
309
|
+
rowData,
|
|
310
|
+
index,
|
|
311
|
+
rows: [...newData2]
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
} else {
|
|
315
|
+
// server
|
|
316
|
+
if (commandClick) {
|
|
317
|
+
commandClick({
|
|
318
|
+
id,
|
|
319
|
+
rowId,
|
|
320
|
+
rowData,
|
|
321
|
+
index,
|
|
322
|
+
rows: [...dataSource]
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
if (commandClick) {
|
|
329
|
+
commandClick(args);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
208
333
|
const triggerPaste = (pastedRows, pastedColumnsArray, newData) => {
|
|
209
334
|
const handlePasteCallback = callbackData => {
|
|
210
335
|
const newDataUpdate = (0, _hooks.updateData)(dataSource, callbackData, rowKey);
|
|
@@ -260,7 +385,8 @@ const InternalTable = props => {
|
|
|
260
385
|
clickHeaderToSort: clickHeaderToSort,
|
|
261
386
|
groupSetting: groupSetting,
|
|
262
387
|
groupAble: groupAble,
|
|
263
|
-
groupColumns: groupColumns
|
|
388
|
+
groupColumns: groupColumns,
|
|
389
|
+
commandClick: triggerCommandClick
|
|
264
390
|
}));
|
|
265
391
|
};
|
|
266
392
|
var _default = exports.default = InternalTable;
|
|
@@ -377,8 +377,9 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
377
377
|
className: 'mb-1'
|
|
378
378
|
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select
|
|
379
379
|
// options={translateOption(numberOperator, t)}
|
|
380
|
+
// options={find ? options : column.source ?? []}
|
|
380
381
|
, {
|
|
381
|
-
options:
|
|
382
|
+
options: column.source ? column.source : options ?? [],
|
|
382
383
|
style: {
|
|
383
384
|
width: '100%',
|
|
384
385
|
marginBottom: 8
|
|
@@ -175,7 +175,10 @@ const useColumns = config => {
|
|
|
175
175
|
// title: () => (<span>{t ? t(col.columnGroupText ?? col.headerText ?? col.title) : col.columnGroupText ?? col.headerText ?? col.title}</span>),
|
|
176
176
|
ellipsis: col.ellipsis !== false,
|
|
177
177
|
align: col.textAlign ?? col.align,
|
|
178
|
-
fixed: col.
|
|
178
|
+
fixed: col.fixedType ?? col.fixed,
|
|
179
|
+
isSummary: col.isSummary ?? col.haveSum,
|
|
180
|
+
hidden: col.hidden ?? col.visible === false
|
|
181
|
+
// hidden: true
|
|
179
182
|
};
|
|
180
183
|
if (transformedColumn.children && transformedColumn.children?.length) {
|
|
181
184
|
return {
|
|
@@ -280,7 +283,7 @@ const useColumns = config => {
|
|
|
280
283
|
}
|
|
281
284
|
return (0, _columns.renderContent)(col, value, record, rowIndex, format);
|
|
282
285
|
},
|
|
283
|
-
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ?
|
|
286
|
+
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(col.field) ? true : transformedColumn.hidden
|
|
284
287
|
};
|
|
285
288
|
});
|
|
286
289
|
};
|
|
@@ -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));
|
|
@@ -795,7 +795,7 @@ const convertColumns = cols => {
|
|
|
795
795
|
// title: () => (<span>{t ? t(col.columnGroupText ?? col.headerText ?? col.title) : col.columnGroupText ?? col.headerText ?? col.title}</span>),
|
|
796
796
|
ellipsis: col.ellipsis !== false,
|
|
797
797
|
align: col.textAlign ?? col.align,
|
|
798
|
-
fixed: col.
|
|
798
|
+
fixed: col.fixedType ?? col.fixed
|
|
799
799
|
};
|
|
800
800
|
if (transformedColumn.children && transformedColumn.children?.length) {
|
|
801
801
|
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 {
|
|
@@ -127,7 +127,7 @@ const GridEdit = props => {
|
|
|
127
127
|
const handleAddSingle = item => {
|
|
128
128
|
const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
|
|
129
129
|
const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
|
|
130
|
-
if (item.onClick) {
|
|
130
|
+
if (item && item.onClick) {
|
|
131
131
|
item.onClick({
|
|
132
132
|
toolbar: item
|
|
133
133
|
});
|
|
@@ -190,7 +190,7 @@ const GridEdit = props => {
|
|
|
190
190
|
toolbar: item
|
|
191
191
|
});
|
|
192
192
|
} else {
|
|
193
|
-
if (!record
|
|
193
|
+
if (!record?.parentId) {
|
|
194
194
|
// Cập nhật data mới
|
|
195
195
|
const newData = [...dataSource];
|
|
196
196
|
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
@@ -235,7 +235,7 @@ const GridEdit = props => {
|
|
|
235
235
|
toolbar: item
|
|
236
236
|
});
|
|
237
237
|
} else {
|
|
238
|
-
if (!record
|
|
238
|
+
if (!record?.parentId) {
|
|
239
239
|
// Cập nhật data mới
|
|
240
240
|
const newData = [...dataSource];
|
|
241
241
|
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
@@ -335,7 +335,7 @@ const GridEdit = props => {
|
|
|
335
335
|
color: '#28c76f'
|
|
336
336
|
},
|
|
337
337
|
onClick: () => handleAddSingle(item)
|
|
338
|
-
}, item.
|
|
338
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
339
339
|
}
|
|
340
340
|
};
|
|
341
341
|
}
|
|
@@ -353,7 +353,7 @@ const GridEdit = props => {
|
|
|
353
353
|
variant: 'outlined',
|
|
354
354
|
onClick: handleDeleteAll,
|
|
355
355
|
className: "d-flex toolbar-button"
|
|
356
|
-
}, item.
|
|
356
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
359
|
}
|
|
@@ -384,7 +384,7 @@ const GridEdit = props => {
|
|
|
384
384
|
color: '#28c76f'
|
|
385
385
|
},
|
|
386
386
|
onClick: () => handleAddSingle(item)
|
|
387
|
-
}, item.
|
|
387
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
388
388
|
}
|
|
389
389
|
};
|
|
390
390
|
}
|
|
@@ -402,7 +402,7 @@ const GridEdit = props => {
|
|
|
402
402
|
variant: 'outlined',
|
|
403
403
|
onClick: handleDuplicate,
|
|
404
404
|
className: "d-flex toolbar-button"
|
|
405
|
-
}, item.
|
|
405
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate')));
|
|
406
406
|
}
|
|
407
407
|
};
|
|
408
408
|
}
|
|
@@ -420,7 +420,7 @@ const GridEdit = props => {
|
|
|
420
420
|
variant: 'outlined',
|
|
421
421
|
onClick: () => handleInsertBefore(item),
|
|
422
422
|
className: "d-flex toolbar-button"
|
|
423
|
-
}, item.
|
|
423
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before')));
|
|
424
424
|
}
|
|
425
425
|
};
|
|
426
426
|
}
|
|
@@ -438,7 +438,7 @@ const GridEdit = props => {
|
|
|
438
438
|
variant: 'outlined',
|
|
439
439
|
onClick: () => handleInsertAfter(item),
|
|
440
440
|
className: "d-flex toolbar-button"
|
|
441
|
-
}, item.
|
|
441
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
|
|
442
442
|
}
|
|
443
443
|
};
|
|
444
444
|
}
|
|
@@ -456,7 +456,7 @@ const GridEdit = props => {
|
|
|
456
456
|
variant: 'outlined',
|
|
457
457
|
onClick: () => handleInsertChild(item),
|
|
458
458
|
className: "d-flex toolbar-button"
|
|
459
|
-
}, item.
|
|
459
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
|
|
460
460
|
}
|
|
461
461
|
};
|
|
462
462
|
}
|
|
@@ -474,7 +474,7 @@ const GridEdit = props => {
|
|
|
474
474
|
variant: 'outlined',
|
|
475
475
|
onClick: handleDeleteAll,
|
|
476
476
|
className: "d-flex toolbar-button"
|
|
477
|
-
}, item.
|
|
477
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
478
478
|
}
|
|
479
479
|
};
|
|
480
480
|
}
|
|
@@ -627,7 +627,7 @@ const GridEdit = props => {
|
|
|
627
627
|
});
|
|
628
628
|
const newRange = (0, _hooks.addRows8)(table, (0, _hooks.getRowsPasteIndex)(pastesArray).length);
|
|
629
629
|
const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[(0, _hooks.getFirstSelectCell)(pastesArray).row];
|
|
630
|
-
if (!record
|
|
630
|
+
if (!record?.parentId) {
|
|
631
631
|
// Cập nhật data mới
|
|
632
632
|
const newData = [...dataSource];
|
|
633
633
|
|
|
@@ -905,7 +905,7 @@ const GridEdit = props => {
|
|
|
905
905
|
|
|
906
906
|
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
907
907
|
const rows = pasteData.split("\n").map(row => row.replace(/\r/g, "").split("\t"));
|
|
908
|
-
if (!record
|
|
908
|
+
if (!record?.parentId) {
|
|
909
909
|
// Cập nhật data mới
|
|
910
910
|
const newData = [...dataSource];
|
|
911
911
|
|
|
@@ -1301,7 +1301,10 @@ const GridEdit = props => {
|
|
|
1301
1301
|
onKeyDown: event => {
|
|
1302
1302
|
const key = getRowKey(record, dataSource.indexOf(record));
|
|
1303
1303
|
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
1304
|
-
if (
|
|
1304
|
+
if (record[rowKey] !== editingKey) {
|
|
1305
|
+
// ~~ khi editingKey = ''
|
|
1306
|
+
event.preventDefault();
|
|
1307
|
+
event.stopPropagation();
|
|
1305
1308
|
handleEdit(record, column, column.editType, event);
|
|
1306
1309
|
handleCellClick(rowNumber, record, column);
|
|
1307
1310
|
const hasKey = mergedExpandedKeys.has(key);
|
|
@@ -1311,9 +1314,24 @@ const GridEdit = props => {
|
|
|
1311
1314
|
} else {
|
|
1312
1315
|
onTriggerExpand(record);
|
|
1313
1316
|
}
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
+
} else {
|
|
1318
|
+
if (event.key === 'Enter') {
|
|
1319
|
+
event.preventDefault();
|
|
1320
|
+
event.stopPropagation();
|
|
1321
|
+
if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length && event.key === 'Enter') {
|
|
1322
|
+
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
1323
|
+
} else {
|
|
1324
|
+
// focus cell hiện tại và tắt edit
|
|
1325
|
+
handleFocusCell(rowNumber ?? 0, colIndex, column, 'vertical', event);
|
|
1326
|
+
setEditingKey('');
|
|
1327
|
+
|
|
1328
|
+
// thêm dòng mới
|
|
1329
|
+
|
|
1330
|
+
// handleAddSingle()
|
|
1331
|
+
//
|
|
1332
|
+
// handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event)
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1317
1335
|
}
|
|
1318
1336
|
}
|
|
1319
1337
|
if (event.key === 'Tab') {
|
|
@@ -1366,7 +1384,7 @@ const GridEdit = props => {
|
|
|
1366
1384
|
},
|
|
1367
1385
|
onClick: () => {
|
|
1368
1386
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1369
|
-
setEditingKey('')
|
|
1387
|
+
// setEditingKey('')
|
|
1370
1388
|
}
|
|
1371
1389
|
},
|
|
1372
1390
|
// 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 {};
|