es-grid-template 1.7.38 → 1.7.39
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/CHANGELOG.md +6 -0
- package/LICENSE +21 -21
- package/README.md +1 -1
- package/es/grid-component/hooks/constant.js +6 -6
- package/es/grid-component/hooks/useColumns.d.ts +1 -3
- package/es/grid-component/hooks/utils.d.ts +1 -1
- package/es/grid-component/styles.scss +1437 -1437
- package/es/table-component/ContextMenu.d.ts +3 -2
- package/es/table-component/ContextMenu.js +2 -2
- package/es/table-component/InternalTable.d.ts +6 -6
- package/es/table-component/InternalTable.js +25 -134
- package/es/table-component/TableContainer.d.ts +5 -5
- package/es/table-component/TableContainer.js +32 -31
- package/es/table-component/TableContainerEdit.d.ts +1 -1
- package/es/table-component/TableContainerEdit.js +247 -228
- package/es/table-component/body/EditableCell.js +146 -147
- package/es/table-component/body/TableBody.d.ts +1 -1
- package/es/table-component/body/TableBody.js +5 -5
- package/es/table-component/body/TableBodyCell.js +18 -37
- package/es/table-component/body/TableBodyCellEdit.d.ts +4 -4
- package/es/table-component/body/TableBodyCellEdit.js +64 -63
- package/es/table-component/body/TableBodyRow.js +1 -0
- package/es/table-component/footer/TableFooterCell.d.ts +3 -3
- package/es/table-component/footer/TableFooterCell.js +6 -8
- package/es/table-component/header/TableHead.d.ts +5 -5
- package/es/table-component/header/TableHead.js +2 -2
- package/es/table-component/hook/constant.js +6 -6
- package/es/table-component/hook/useFilterOperator.d.ts +1 -1
- package/es/table-component/hook/utils.d.ts +3 -2
- package/es/table-component/hook/utils.js +159 -202
- package/es/table-component/style.scss +1197 -1197
- package/es/table-component/table/TableWrapper.d.ts +4 -4
- package/es/table-component/table/TableWrapper.js +20 -23
- package/es/table-component/type.d.ts +40 -40
- package/es/table-component/useContext.d.ts +3 -4
- package/es/table-component/useContext.js +4 -4
- package/lib/grid-component/hooks/constant.js +6 -6
- package/lib/grid-component/hooks/useColumns.d.ts +1 -3
- package/lib/grid-component/hooks/utils.d.ts +1 -1
- package/lib/grid-component/styles.scss +1437 -1437
- package/lib/table-component/ContextMenu.d.ts +3 -2
- package/lib/table-component/InternalTable.d.ts +6 -6
- package/lib/table-component/InternalTable.js +18 -125
- package/lib/table-component/TableContainer.d.ts +5 -5
- package/lib/table-component/TableContainer.js +26 -24
- package/lib/table-component/TableContainerEdit.d.ts +1 -1
- package/lib/table-component/TableContainerEdit.js +246 -227
- package/lib/table-component/body/EditableCell.js +145 -146
- package/lib/table-component/body/TableBody.d.ts +1 -1
- package/lib/table-component/body/TableBody.js +5 -5
- package/lib/table-component/body/TableBodyCell.js +17 -36
- package/lib/table-component/body/TableBodyCellEdit.d.ts +4 -4
- package/lib/table-component/body/TableBodyCellEdit.js +60 -59
- package/lib/table-component/body/TableBodyRow.js +1 -0
- package/lib/table-component/footer/TableFooterCell.d.ts +3 -3
- package/lib/table-component/footer/TableFooterCell.js +5 -7
- package/lib/table-component/header/TableHead.d.ts +5 -5
- package/lib/table-component/header/TableHead.js +1 -1
- package/lib/table-component/hook/constant.js +6 -6
- package/lib/table-component/hook/useFilterOperator.d.ts +1 -1
- package/lib/table-component/hook/utils.d.ts +3 -2
- package/lib/table-component/hook/utils.js +159 -201
- package/lib/table-component/style.scss +1197 -1197
- package/lib/table-component/table/TableWrapper.d.ts +4 -4
- package/lib/table-component/table/TableWrapper.js +20 -23
- package/lib/table-component/type.d.ts +40 -40
- package/lib/table-component/useContext.d.ts +3 -4
- package/lib/table-component/useContext.js +3 -3
- package/package.json +116 -116
|
@@ -4,7 +4,7 @@ import { checkDecimalSeparator, checkThousandSeparator, detectSeparators, findIt
|
|
|
4
4
|
// sumSize,
|
|
5
5
|
unFlattenData, updateArrayByKey, updateOrInsert } from "./hook/utils";
|
|
6
6
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
7
|
-
import { useForm } from
|
|
7
|
+
import { useForm } from 'react-hook-form';
|
|
8
8
|
import { Button, Modal, Typography, Dropdown } from "antd";
|
|
9
9
|
import Pagination from "rc-master-ui/es/pagination";
|
|
10
10
|
import { numericFormatter, removeNumericFormat } from "react-numeric-component";
|
|
@@ -122,7 +122,7 @@ const TableContainerEdit = props => {
|
|
|
122
122
|
const containerRef = React.useRef(null);
|
|
123
123
|
const bottomToolbarRef = React.useRef(null);
|
|
124
124
|
const topToolbarRef = React.useRef(null);
|
|
125
|
-
const childrenColumnName =
|
|
125
|
+
const childrenColumnName = 'children';
|
|
126
126
|
|
|
127
127
|
// const visibleColumns = table.getVisibleLeafColumns()
|
|
128
128
|
|
|
@@ -133,73 +133,73 @@ const TableContainerEdit = props => {
|
|
|
133
133
|
|
|
134
134
|
const defaultContext = React.useMemo(() => {
|
|
135
135
|
return [{
|
|
136
|
-
key:
|
|
136
|
+
key: 'INSERT_BEFORE',
|
|
137
137
|
// label: 'Thêm dòng bên trên',
|
|
138
138
|
// label: `${t ? t(locale?.add_rows_before ?? 'Add rows before') : 'Add rows before'}`,
|
|
139
|
-
label: locale?.add_rows_before ??
|
|
139
|
+
label: locale?.add_rows_before ?? 'Add rows before',
|
|
140
140
|
icon: /*#__PURE__*/React.createElement(Plus, {
|
|
141
141
|
fontSize: 14
|
|
142
142
|
}),
|
|
143
143
|
children: [{
|
|
144
|
-
parentKey:
|
|
145
|
-
key:
|
|
146
|
-
label: locale?.add_1 ??
|
|
144
|
+
parentKey: 'INSERT_BEFORE',
|
|
145
|
+
key: 'INSERT_BEFORE_1',
|
|
146
|
+
label: locale?.add_1 ?? 'Add 1 rows',
|
|
147
147
|
row: 1
|
|
148
148
|
}, {
|
|
149
|
-
parentKey:
|
|
150
|
-
key:
|
|
151
|
-
label: locale?.add_10 ??
|
|
149
|
+
parentKey: 'INSERT_BEFORE',
|
|
150
|
+
key: 'INSERT_BEFORE_10',
|
|
151
|
+
label: locale?.add_10 ?? 'Add 10 rows',
|
|
152
152
|
row: 10
|
|
153
153
|
}, {
|
|
154
|
-
parentKey:
|
|
155
|
-
key:
|
|
156
|
-
label: locale?.add_50 ??
|
|
154
|
+
parentKey: 'INSERT_BEFORE',
|
|
155
|
+
key: 'INSERT_BEFORE_50',
|
|
156
|
+
label: locale?.add_50 ?? 'Add 50 rows',
|
|
157
157
|
row: 50
|
|
158
158
|
}, {
|
|
159
|
-
parentKey:
|
|
160
|
-
key:
|
|
161
|
-
label: locale?.add_100 ??
|
|
159
|
+
parentKey: 'INSERT_BEFORE',
|
|
160
|
+
key: 'INSERT_BEFORE_100',
|
|
161
|
+
label: locale?.add_100 ?? 'Add 100 rows',
|
|
162
162
|
row: 100
|
|
163
163
|
}, {
|
|
164
|
-
parentKey:
|
|
165
|
-
key:
|
|
166
|
-
label: locale?.custom ??
|
|
164
|
+
parentKey: 'INSERT_BEFORE',
|
|
165
|
+
key: 'INSERT_BEFORE_ADV',
|
|
166
|
+
label: locale?.custom ?? 'Custom'
|
|
167
167
|
}]
|
|
168
168
|
}, {
|
|
169
|
-
key:
|
|
170
|
-
label: locale?.add_rows_after ??
|
|
169
|
+
key: 'INSERT_AFTER',
|
|
170
|
+
label: locale?.add_rows_after ?? 'Add rows after',
|
|
171
171
|
icon: /*#__PURE__*/React.createElement(Plus, {
|
|
172
172
|
fontSize: 14
|
|
173
173
|
}),
|
|
174
174
|
children: [{
|
|
175
|
-
parentKey:
|
|
176
|
-
key:
|
|
177
|
-
label: locale?.add_1 ??
|
|
175
|
+
parentKey: 'INSERT_AFTER',
|
|
176
|
+
key: 'INSERT_AFTER_1',
|
|
177
|
+
label: locale?.add_1 ?? 'Add 1 rows',
|
|
178
178
|
row: 1
|
|
179
179
|
}, {
|
|
180
|
-
parentKey:
|
|
181
|
-
key:
|
|
182
|
-
label: locale?.add_10 ??
|
|
180
|
+
parentKey: 'INSERT_AFTER',
|
|
181
|
+
key: 'INSERT_AFTER_10',
|
|
182
|
+
label: locale?.add_10 ?? 'Add 10 rows',
|
|
183
183
|
row: 10
|
|
184
184
|
}, {
|
|
185
|
-
parentKey:
|
|
186
|
-
key:
|
|
187
|
-
label: locale?.add_50 ??
|
|
185
|
+
parentKey: 'INSERT_AFTER',
|
|
186
|
+
key: 'INSERT_AFTER_50',
|
|
187
|
+
label: locale?.add_50 ?? 'Add 50 rows',
|
|
188
188
|
row: 50
|
|
189
189
|
}, {
|
|
190
|
-
parentKey:
|
|
191
|
-
key:
|
|
192
|
-
label: locale?.add_100 ??
|
|
190
|
+
parentKey: 'INSERT_AFTER',
|
|
191
|
+
key: 'INSERT_AFTER_100',
|
|
192
|
+
label: locale?.add_100 ?? 'Add 100 rows',
|
|
193
193
|
row: 100
|
|
194
194
|
}, {
|
|
195
|
-
parentKey:
|
|
196
|
-
key:
|
|
197
|
-
label: locale?.custom ??
|
|
195
|
+
parentKey: 'INSERT_AFTER',
|
|
196
|
+
key: 'INSERT_AFTER_ADV',
|
|
197
|
+
label: locale?.custom ?? 'Custom'
|
|
198
198
|
}]
|
|
199
199
|
}, {
|
|
200
|
-
key:
|
|
200
|
+
key: 'INSERT_CHILDREN',
|
|
201
201
|
// label: 'Insert item children',
|
|
202
|
-
label: locale?.add_children ??
|
|
202
|
+
label: locale?.add_children ?? 'Add children',
|
|
203
203
|
icon: /*#__PURE__*/React.createElement(Plus, {
|
|
204
204
|
fontSize: 14
|
|
205
205
|
})
|
|
@@ -235,14 +235,14 @@ const TableContainerEdit = props => {
|
|
|
235
235
|
// }
|
|
236
236
|
// ]
|
|
237
237
|
}, {
|
|
238
|
-
key:
|
|
239
|
-
label: locale?.delete_content ??
|
|
238
|
+
key: 'DELETE_CONTENT',
|
|
239
|
+
label: locale?.delete_content ?? 'Delete content',
|
|
240
240
|
icon: /*#__PURE__*/React.createElement(Trash2, {
|
|
241
241
|
fontSize: 14
|
|
242
242
|
})
|
|
243
243
|
}, {
|
|
244
|
-
key:
|
|
245
|
-
label: locale?.delete_rows ??
|
|
244
|
+
key: 'DELETE_ROWS',
|
|
245
|
+
label: locale?.delete_rows ?? 'Delete rows',
|
|
246
246
|
icon: /*#__PURE__*/React.createElement(Trash2, {
|
|
247
247
|
fontSize: 14
|
|
248
248
|
})
|
|
@@ -250,20 +250,20 @@ const TableContainerEdit = props => {
|
|
|
250
250
|
}, [locale]);
|
|
251
251
|
const itemsAdd = React.useMemo(() => {
|
|
252
252
|
return [{
|
|
253
|
-
key:
|
|
254
|
-
label: `10 ${t ? t(
|
|
253
|
+
key: '10',
|
|
254
|
+
label: `10 ${t ? t('rows') : 'rows'}`
|
|
255
255
|
}, {
|
|
256
|
-
key:
|
|
257
|
-
label: `50 ${t ? t(
|
|
256
|
+
key: '50',
|
|
257
|
+
label: `50 ${t ? t('rows') : 'rows'}`
|
|
258
258
|
}, {
|
|
259
|
-
key:
|
|
260
|
-
label: `100 ${t ? t(
|
|
259
|
+
key: '100',
|
|
260
|
+
label: `100 ${t ? t('rows') : 'rows'}`
|
|
261
261
|
}];
|
|
262
262
|
}, [t]);
|
|
263
263
|
const contextMenuItems = React.useMemo(() => {
|
|
264
264
|
const a = showDefaultContext !== false ? [...defaultContext] : [];
|
|
265
265
|
const b = propsContext && propsContext.length > 0 ? [...propsContext, {
|
|
266
|
-
type:
|
|
266
|
+
type: 'divider'
|
|
267
267
|
}] : [];
|
|
268
268
|
return [...b, ...a];
|
|
269
269
|
}, [defaultContext, propsContext, showDefaultContext]);
|
|
@@ -296,7 +296,7 @@ const TableContainerEdit = props => {
|
|
|
296
296
|
// return element?.getBoundingClientRect().width;
|
|
297
297
|
// },
|
|
298
298
|
|
|
299
|
-
measureElement: typeof window !==
|
|
299
|
+
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
|
|
300
300
|
overscan: 0 //how many columns to render on each side off screen each way (adjust this for performance)
|
|
301
301
|
});
|
|
302
302
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
@@ -318,7 +318,7 @@ const TableContainerEdit = props => {
|
|
|
318
318
|
virtualPaddingRight = fixedRightColumns && fixedRightColumns.length > 0 ? pdRight - rightWidth > 0 ? pdRight - rightWidth : 0 : pdRight;
|
|
319
319
|
// virtualPaddingRight = columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0)
|
|
320
320
|
}
|
|
321
|
-
const [editingKey, setEditingKey] = React.useState(
|
|
321
|
+
const [editingKey, setEditingKey] = React.useState('');
|
|
322
322
|
const [rangeState, setRangeState] = React.useState({
|
|
323
323
|
startRowIndex: undefined,
|
|
324
324
|
endRowIndex: undefined,
|
|
@@ -352,9 +352,7 @@ const TableContainerEdit = props => {
|
|
|
352
352
|
return startCell && endCell ? getRowIdsBetween(table, startCell.rowId, endCell.rowId) : [];
|
|
353
353
|
}, [endCell, startCell, table]);
|
|
354
354
|
const copySelectionToClipboard = React.useCallback(() => {
|
|
355
|
-
if (!startCell || !endCell)
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
355
|
+
if (!startCell || !endCell) return;
|
|
358
356
|
|
|
359
357
|
// const allRows = table.getRowModel().rows;
|
|
360
358
|
const allRows = table.getRowModel().flatRows;
|
|
@@ -365,20 +363,18 @@ const TableContainerEdit = props => {
|
|
|
365
363
|
const dataToCopy = [];
|
|
366
364
|
rowIds.forEach(rowId => {
|
|
367
365
|
const row = allRows.find(r => r.id === rowId);
|
|
368
|
-
if (!row)
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
366
|
+
if (!row) return;
|
|
371
367
|
const rowData = [];
|
|
372
368
|
colIds.forEach(colId => {
|
|
373
369
|
const cellll = row.getVisibleCells().find(c => c.column.id === colId);
|
|
374
370
|
const value = cellll?.getValue();
|
|
375
|
-
rowData.push(value !== undefined ? String(value) :
|
|
371
|
+
rowData.push(value !== undefined ? String(value) : '');
|
|
376
372
|
});
|
|
377
373
|
dataToCopy.push(rowData);
|
|
378
374
|
});
|
|
379
375
|
|
|
380
376
|
// Convert to TSV string
|
|
381
|
-
const tsv = dataToCopy.map(row => row.join(
|
|
377
|
+
const tsv = dataToCopy.map(row => row.join('\t')).join('\n');
|
|
382
378
|
|
|
383
379
|
// Copy to clipboard
|
|
384
380
|
navigator.clipboard.writeText(tsv).then(() => {});
|
|
@@ -398,7 +394,7 @@ const TableContainerEdit = props => {
|
|
|
398
394
|
onCellPaste.onPasted({
|
|
399
395
|
pasteData: pastedRows,
|
|
400
396
|
copyRows,
|
|
401
|
-
type:
|
|
397
|
+
type: 'onPaste',
|
|
402
398
|
data: originData,
|
|
403
399
|
pastedColumns: pastedColumnsArray
|
|
404
400
|
}, handlePasteCallback);
|
|
@@ -406,7 +402,7 @@ const TableContainerEdit = props => {
|
|
|
406
402
|
// không có callback
|
|
407
403
|
onCellPaste.onPasted({
|
|
408
404
|
pasteData: pastedRows,
|
|
409
|
-
type:
|
|
405
|
+
type: 'onPaste',
|
|
410
406
|
copyRows,
|
|
411
407
|
data: originData,
|
|
412
408
|
pastedColumns: pastedColumnsArray
|
|
@@ -462,11 +458,11 @@ const TableContainerEdit = props => {
|
|
|
462
458
|
}
|
|
463
459
|
const columnTarget = allCols[targetCol];
|
|
464
460
|
const columnOri = columnTarget.columnDef.meta ?? {};
|
|
465
|
-
const isEdit = typeof columnOri?.editEnable ===
|
|
461
|
+
const isEdit = typeof columnOri?.editEnable === 'function' ? columnOri.editEnable(newData[targetRow]) : columnOri.editEnable;
|
|
466
462
|
if (isEdit) {
|
|
467
463
|
const columnKey = allCols[targetCol].id;
|
|
468
|
-
if (columnOri.type ===
|
|
469
|
-
const colFormat = typeof columnOri.format ===
|
|
464
|
+
if (columnOri.type === 'number' && isFormattedNumber(cellValue.trim())) {
|
|
465
|
+
const colFormat = typeof columnOri.format === 'function' ? columnOri.format(record) : columnOri.format;
|
|
470
466
|
const valuePasteFormat = detectSeparators(cellValue.trim());
|
|
471
467
|
const cellFormat = getFormat(colFormat, format);
|
|
472
468
|
const thousandSeparator = valuePasteFormat?.thousandSeparator ?? cellFormat?.thousandSeparator;
|
|
@@ -524,7 +520,7 @@ const TableContainerEdit = props => {
|
|
|
524
520
|
childData.push({
|
|
525
521
|
id: undefined,
|
|
526
522
|
rowId: newGuid(),
|
|
527
|
-
parentId: parent[rowKey ??
|
|
523
|
+
parentId: parent[rowKey ?? 'id']
|
|
528
524
|
});
|
|
529
525
|
}
|
|
530
526
|
rowValues.forEach((cellValue, colIndex) => {
|
|
@@ -538,7 +534,7 @@ const TableContainerEdit = props => {
|
|
|
538
534
|
// const isEdit = typeof columnTarget.editEnable === 'function' ? columnTarget.editEnable(childData[targetRow]) : columnTarget.editEnable
|
|
539
535
|
|
|
540
536
|
const columnOri = columnTarget.columnDef.meta ?? {};
|
|
541
|
-
const isEdit = typeof columnOri?.editEnable ===
|
|
537
|
+
const isEdit = typeof columnOri?.editEnable === 'function' ? columnOri.editEnable(childData[targetRow]) : columnOri.editEnable;
|
|
542
538
|
if (isEdit) {
|
|
543
539
|
const columnKey = allCols[targetCol].id;
|
|
544
540
|
childData[targetRow] = {
|
|
@@ -563,14 +559,12 @@ const TableContainerEdit = props => {
|
|
|
563
559
|
}
|
|
564
560
|
}, [dataSource, format, onCellPaste?.maxRowsPaste, originData, rowKey, startCell, table, triggerPaste]);
|
|
565
561
|
const handlePasteToTable = React.useCallback(pasteData => {
|
|
566
|
-
if (!startCell)
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
562
|
+
if (!startCell) return;
|
|
569
563
|
|
|
570
564
|
// const pastedRows = pasted.trim().split('\n').map(row => row.split('\t'));
|
|
571
565
|
|
|
572
566
|
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
573
|
-
const rowsPasted = pasteData.split("\n").filter(row => row !==
|
|
567
|
+
const rowsPasted = pasteData.split("\n").filter(row => row !== '').map(row =>
|
|
574
568
|
// const rows = pasteData.split("\n").map((row: any) =>
|
|
575
569
|
row.replace(/\r/g, "").split("\t"));
|
|
576
570
|
if (rowsPasted.length > (onCellPaste?.maxRowsPaste ?? 200)) {
|
|
@@ -579,17 +573,17 @@ const TableContainerEdit = props => {
|
|
|
579
573
|
Modal.confirm({
|
|
580
574
|
content: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Paragraph, {
|
|
581
575
|
style: {
|
|
582
|
-
marginBottom:
|
|
576
|
+
marginBottom: '.25rem',
|
|
583
577
|
fontSize: 14
|
|
584
578
|
}
|
|
585
579
|
}, "D\u1EEF li\u1EC7u sao ch\xE9p v\u01B0\u1EE3t qu\xE1 s\u1ED1 d\xF2ng cho ph\xE9p (500 d\xF2ng).Ph\u1EA7n m\u1EC1n s\u1EBD ch\u1EC9 l\u1EA5y 500 d\xF2ng \u0111\u1EA7u ti\xEAn."), /*#__PURE__*/React.createElement(Title, {
|
|
586
580
|
level: 5,
|
|
587
581
|
style: {
|
|
588
|
-
marginTop:
|
|
582
|
+
marginTop: '.75rem'
|
|
589
583
|
}
|
|
590
584
|
}, "B\u1EA1n c\xF3 mu\u1ED1n ti\u1EBFp t\u1EE5c sao ch\xE9p kh\xF4ng?")),
|
|
591
585
|
centered: true,
|
|
592
|
-
className:
|
|
586
|
+
className: 'be-popup-container',
|
|
593
587
|
onOk: () => {
|
|
594
588
|
handlePasted(rowsPasted);
|
|
595
589
|
}
|
|
@@ -606,32 +600,28 @@ const TableContainerEdit = props => {
|
|
|
606
600
|
}, [handlePasted, onCellPaste?.maxRowsPaste, startCell]);
|
|
607
601
|
React.useEffect(() => {
|
|
608
602
|
const handleKeyDown = e => {
|
|
609
|
-
|
|
610
|
-
e
|
|
611
|
-
});
|
|
612
|
-
if (e.ctrlKey && e.key === "c" && startCell && endCell) {
|
|
603
|
+
if (e.ctrlKey && e.key === 'c' && startCell && endCell) {
|
|
613
604
|
e.preventDefault();
|
|
614
605
|
copySelectionToClipboard();
|
|
615
606
|
}
|
|
616
607
|
};
|
|
617
|
-
window.addEventListener(
|
|
618
|
-
return () => window.removeEventListener(
|
|
608
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
609
|
+
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
619
610
|
}, [startCell, endCell, table, copySelectionToClipboard]);
|
|
620
611
|
React.useEffect(() => {
|
|
621
612
|
const handlePaste = e => {
|
|
622
613
|
if (startCell && !editingKey) {
|
|
623
614
|
e.preventDefault(); // Chặn hành vi mặc định
|
|
624
|
-
const clipboardText = e.clipboardData?.getData(
|
|
615
|
+
const clipboardText = e.clipboardData?.getData('text/plain') ?? '';
|
|
625
616
|
handlePasteToTable(clipboardText);
|
|
626
617
|
}
|
|
627
618
|
};
|
|
628
|
-
window.addEventListener(
|
|
629
|
-
return () => window.removeEventListener(
|
|
619
|
+
window.addEventListener('paste', handlePaste);
|
|
620
|
+
return () => window.removeEventListener('paste', handlePaste);
|
|
630
621
|
}, [startCell, endCell, table, handlePasteToTable, editingKey]);
|
|
631
622
|
React.useEffect(() => {
|
|
632
623
|
const handleClickOutside = event => {
|
|
633
624
|
const element = event.target;
|
|
634
|
-
console.log("event", event);
|
|
635
625
|
const container = document.querySelector(".be-popup-container");
|
|
636
626
|
const containerContextMenu = document.querySelector(".popup-context-menu");
|
|
637
627
|
const tableBody = document.querySelector(`#${id} .ui-rc-grid-tbody`);
|
|
@@ -649,7 +639,7 @@ const TableContainerEdit = props => {
|
|
|
649
639
|
onBlur?.(dataSource);
|
|
650
640
|
}
|
|
651
641
|
setTimeout(() => {
|
|
652
|
-
setEditingKey(
|
|
642
|
+
setEditingKey('');
|
|
653
643
|
// editingKey.current = ''
|
|
654
644
|
});
|
|
655
645
|
setEndCell(undefined);
|
|
@@ -659,12 +649,12 @@ const TableContainerEdit = props => {
|
|
|
659
649
|
};
|
|
660
650
|
|
|
661
651
|
// document.addEventListener('click', handleClickOutside)
|
|
662
|
-
document.addEventListener(
|
|
652
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
663
653
|
// document.addEventListener('touchstart', handleClickOutside)
|
|
664
654
|
|
|
665
655
|
return () => {
|
|
666
656
|
// document.removeEventListener('click', handleClickOutside)
|
|
667
|
-
document.removeEventListener(
|
|
657
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
668
658
|
// document.removeEventListener('touchstart', handleClickOutside)
|
|
669
659
|
};
|
|
670
660
|
}, [dataSource, editingKey, id, onBlur]);
|
|
@@ -675,9 +665,7 @@ const TableContainerEdit = props => {
|
|
|
675
665
|
});
|
|
676
666
|
}, [columnSizingState, columnVirtualizer]);
|
|
677
667
|
React.useEffect(() => {
|
|
678
|
-
if (!containerRef.current)
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
668
|
+
if (!containerRef.current) return;
|
|
681
669
|
const containerWidth = containerRef.current.offsetWidth - 1;
|
|
682
670
|
const totalWidth = table.getTotalSize();
|
|
683
671
|
if (totalWidth && totalWidth < containerWidth) {
|
|
@@ -709,7 +697,7 @@ const TableContainerEdit = props => {
|
|
|
709
697
|
errors
|
|
710
698
|
}
|
|
711
699
|
} = useForm({
|
|
712
|
-
mode:
|
|
700
|
+
mode: 'onChange',
|
|
713
701
|
resolver: validate ? yupResolver(validate) : undefined
|
|
714
702
|
});
|
|
715
703
|
const onSubmit = formData => {
|
|
@@ -729,7 +717,7 @@ const TableContainerEdit = props => {
|
|
|
729
717
|
triggerChangeData?.(rs);
|
|
730
718
|
}
|
|
731
719
|
} catch (errInfo) {
|
|
732
|
-
console.log(
|
|
720
|
+
console.log('Validate Failed:', errInfo);
|
|
733
721
|
}
|
|
734
722
|
};
|
|
735
723
|
const handleCellChange = args => {
|
|
@@ -744,7 +732,7 @@ const TableContainerEdit = props => {
|
|
|
744
732
|
indexRow,
|
|
745
733
|
key
|
|
746
734
|
} = args;
|
|
747
|
-
if (changeType ===
|
|
735
|
+
if (changeType === 'blur') {
|
|
748
736
|
const handleChangeCallback = callbackData => {
|
|
749
737
|
const callbackRecord = callbackData;
|
|
750
738
|
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
@@ -757,7 +745,7 @@ const TableContainerEdit = props => {
|
|
|
757
745
|
onCellChange({
|
|
758
746
|
field,
|
|
759
747
|
indexCol,
|
|
760
|
-
type:
|
|
748
|
+
type: 'onChange',
|
|
761
749
|
value: newState,
|
|
762
750
|
option,
|
|
763
751
|
indexRow,
|
|
@@ -771,7 +759,7 @@ const TableContainerEdit = props => {
|
|
|
771
759
|
onCellChange({
|
|
772
760
|
field,
|
|
773
761
|
indexCol,
|
|
774
|
-
type:
|
|
762
|
+
type: 'onChange',
|
|
775
763
|
option,
|
|
776
764
|
value: newState,
|
|
777
765
|
indexRow,
|
|
@@ -785,7 +773,7 @@ const TableContainerEdit = props => {
|
|
|
785
773
|
}
|
|
786
774
|
}
|
|
787
775
|
}
|
|
788
|
-
if (prevState && newState && prevState !== newState && changeType ===
|
|
776
|
+
if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
789
777
|
onSubmit(record);
|
|
790
778
|
}
|
|
791
779
|
};
|
|
@@ -822,9 +810,12 @@ const TableContainerEdit = props => {
|
|
|
822
810
|
// const duplicatedItems = rowsFocus.map(index => ({ ...newData[index], rowId: newGuid(), id: undefined, isDuplicate: true }))
|
|
823
811
|
|
|
824
812
|
const duplicatedItem = table.getRowModel().flatRows.find(it => it.id === focusedCell?.rowId);
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
813
|
+
|
|
814
|
+
// setStartCell(focusedCell)
|
|
815
|
+
// setEndCell(focusedCell)
|
|
816
|
+
|
|
817
|
+
// setRangeState(getSelectedCellMatrix(table, focusedCell, focusedCell))
|
|
818
|
+
|
|
828
819
|
const duplicatedItems = [{
|
|
829
820
|
...duplicatedItem?.original,
|
|
830
821
|
rowId: newGuid(),
|
|
@@ -848,6 +839,9 @@ const TableContainerEdit = props => {
|
|
|
848
839
|
// thêm n dòng bên trên
|
|
849
840
|
const handleInsertBefore = React.useCallback((item, n) => {
|
|
850
841
|
const defaultRowValue = getDefaultValue(defaultValue);
|
|
842
|
+
setStartCell(focusedCell);
|
|
843
|
+
setEndCell(focusedCell);
|
|
844
|
+
setRangeState(getSelectedCellMatrix(table, focusedCell, focusedCell));
|
|
851
845
|
|
|
852
846
|
// const record: any = table.getRowModel().rows.find((it) => it.id === rowsFocus[rowsFocus.length - 1])?.original
|
|
853
847
|
const record = table.getRowModel().flatRows.find(it => it.id === rowsFocus[rowsFocus.length - 1])?.original;
|
|
@@ -904,7 +898,7 @@ const TableContainerEdit = props => {
|
|
|
904
898
|
triggerChangeData?.(newDataSource);
|
|
905
899
|
}
|
|
906
900
|
}
|
|
907
|
-
}, [defaultValue, mergedFilterKeys, originData, rowKey, rowsFocus, setMergedFilterKeys, table, triggerChangeData]);
|
|
901
|
+
}, [defaultValue, focusedCell, mergedFilterKeys, originData, rowKey, rowsFocus, setMergedFilterKeys, table, triggerChangeData]);
|
|
908
902
|
|
|
909
903
|
//thêm 1 dòng bên dưới
|
|
910
904
|
const handleInsertAfter = React.useCallback((item, n) => {
|
|
@@ -1035,16 +1029,16 @@ const TableContainerEdit = props => {
|
|
|
1035
1029
|
const newDaa = unFlattenData(rs);
|
|
1036
1030
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
1037
1031
|
MySwal.fire({
|
|
1038
|
-
title: t ? t(
|
|
1039
|
-
text: t ? t(
|
|
1032
|
+
title: t ? t('Confirm') : 'Confirm',
|
|
1033
|
+
text: t ? t('Do you want to delete item?') : 'Do you want to delete item?',
|
|
1040
1034
|
// icon: 'warning',
|
|
1041
1035
|
allowOutsideClick: false,
|
|
1042
1036
|
showCancelButton: true,
|
|
1043
|
-
confirmButtonText: t ? t(
|
|
1044
|
-
cancelButtonText: t ? t(
|
|
1037
|
+
confirmButtonText: t ? t('Delete') : 'Delete',
|
|
1038
|
+
cancelButtonText: t ? t('Cancel') : 'Cancel',
|
|
1045
1039
|
customClass: {
|
|
1046
|
-
confirmButton:
|
|
1047
|
-
cancelButton:
|
|
1040
|
+
confirmButton: 'be-button btn-primary',
|
|
1041
|
+
cancelButton: 'be-button btn-danger ms-1'
|
|
1048
1042
|
},
|
|
1049
1043
|
buttonsStyling: false
|
|
1050
1044
|
}).then(async result => {
|
|
@@ -1053,14 +1047,41 @@ const TableContainerEdit = props => {
|
|
|
1053
1047
|
} else if (result.dismiss === MySwal.DismissReason.cancel) {}
|
|
1054
1048
|
});
|
|
1055
1049
|
} else {
|
|
1056
|
-
// không hiện dialog
|
|
1050
|
+
// không hiện dialog
|
|
1057
1051
|
triggerChangeData?.([...newDaa]);
|
|
1058
1052
|
}
|
|
1059
1053
|
}
|
|
1060
|
-
}, [originData, rowKey, rowsFocus, triggerChangeData]);
|
|
1061
|
-
const handleDeleteAll = React.useCallback(
|
|
1062
|
-
|
|
1063
|
-
|
|
1054
|
+
}, [commandSettings, originData, rowKey, rowsFocus, t, triggerChangeData]);
|
|
1055
|
+
const handleDeleteAll = React.useCallback(item => {
|
|
1056
|
+
if (item.onClick) {
|
|
1057
|
+
item.onClick({
|
|
1058
|
+
toolbar: item
|
|
1059
|
+
});
|
|
1060
|
+
} else {
|
|
1061
|
+
if (commandSettings && commandSettings.confirmDialog) {
|
|
1062
|
+
MySwal.fire({
|
|
1063
|
+
title: t ? t('Confirm') : 'Confirm',
|
|
1064
|
+
text: t ? t('Do you want to delete item?') : 'Do you want to delete item?',
|
|
1065
|
+
// icon: 'warning',
|
|
1066
|
+
allowOutsideClick: false,
|
|
1067
|
+
showCancelButton: true,
|
|
1068
|
+
confirmButtonText: t ? t('Delete') : 'Delete',
|
|
1069
|
+
cancelButtonText: t ? t('Cancel') : 'Cancel',
|
|
1070
|
+
customClass: {
|
|
1071
|
+
confirmButton: 'be-button btn-primary',
|
|
1072
|
+
cancelButton: 'be-button btn-danger ms-1'
|
|
1073
|
+
},
|
|
1074
|
+
buttonsStyling: false
|
|
1075
|
+
}).then(async result => {
|
|
1076
|
+
if (result.value) {
|
|
1077
|
+
triggerChangeData?.([]);
|
|
1078
|
+
} else if (result.dismiss === MySwal.DismissReason.cancel) {}
|
|
1079
|
+
});
|
|
1080
|
+
} else {
|
|
1081
|
+
triggerChangeData?.([]);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}, [commandSettings, t, triggerChangeData]);
|
|
1064
1085
|
const handleDeleteContent = () => {
|
|
1065
1086
|
if (startCell && endCell) {
|
|
1066
1087
|
const tmpData = flattenArray([...dataSource]);
|
|
@@ -1075,17 +1096,17 @@ const TableContainerEdit = props => {
|
|
|
1075
1096
|
const column = table.getVisibleFlatColumns().find(it => it.id === colId)?.columnDef.meta;
|
|
1076
1097
|
const columnIndex = table.getVisibleFlatColumns().findIndex(it => it.id === colId);
|
|
1077
1098
|
if (isEditable(column, row)) {
|
|
1078
|
-
updatedRow[colId] =
|
|
1099
|
+
updatedRow[colId] = '';
|
|
1079
1100
|
handleCellChange({
|
|
1080
1101
|
key: row[rowKey],
|
|
1081
1102
|
field: column.field ?? column.dataIndex,
|
|
1082
1103
|
record: updatedRow,
|
|
1083
1104
|
prevState: row[column.field],
|
|
1084
|
-
newState:
|
|
1085
|
-
option:
|
|
1105
|
+
newState: '',
|
|
1106
|
+
option: '',
|
|
1086
1107
|
indexCol: columnIndex,
|
|
1087
1108
|
indexRow: index,
|
|
1088
|
-
type:
|
|
1109
|
+
type: 'blur'
|
|
1089
1110
|
});
|
|
1090
1111
|
}
|
|
1091
1112
|
}
|
|
@@ -1097,35 +1118,35 @@ const TableContainerEdit = props => {
|
|
|
1097
1118
|
};
|
|
1098
1119
|
const toolbarItemsBottom = React.useMemo(() => {
|
|
1099
1120
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
1100
|
-
return toolbarItems?.filter(it => it.position ===
|
|
1101
|
-
if (item.key ===
|
|
1121
|
+
return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
|
|
1122
|
+
if (item.key === 'ADD') {
|
|
1102
1123
|
return {
|
|
1103
1124
|
...item,
|
|
1104
1125
|
template: () => {
|
|
1105
|
-
return /*#__PURE__*/React.createElement(Fragment, null, item.key ===
|
|
1126
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
|
|
1106
1127
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1107
1128
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1108
|
-
overlayClassName:
|
|
1109
|
-
trigger: [
|
|
1129
|
+
overlayClassName: 'be-popup-container',
|
|
1130
|
+
trigger: ['click'],
|
|
1110
1131
|
style: {
|
|
1111
|
-
color:
|
|
1112
|
-
borderColor:
|
|
1132
|
+
color: '#28c76f',
|
|
1133
|
+
borderColor: '#28c76f'
|
|
1113
1134
|
},
|
|
1114
|
-
className:
|
|
1135
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1115
1136
|
menu: {
|
|
1116
1137
|
items: itemsAdd,
|
|
1117
1138
|
onClick: e => handleAddMulti(item, Number(e.key))
|
|
1118
1139
|
}
|
|
1119
1140
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1120
1141
|
style: {
|
|
1121
|
-
color:
|
|
1142
|
+
color: '#28c76f'
|
|
1122
1143
|
},
|
|
1123
1144
|
onClick: () => handleAddMulti(item, 1)
|
|
1124
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1145
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
1125
1146
|
}
|
|
1126
1147
|
};
|
|
1127
1148
|
}
|
|
1128
|
-
if (item.key ===
|
|
1149
|
+
if (item.key === 'DELETE') {
|
|
1129
1150
|
return {
|
|
1130
1151
|
...item,
|
|
1131
1152
|
template: () => {
|
|
@@ -1133,13 +1154,13 @@ const TableContainerEdit = props => {
|
|
|
1133
1154
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1134
1155
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1135
1156
|
style: {
|
|
1136
|
-
color:
|
|
1137
|
-
borderColor:
|
|
1157
|
+
color: '#eb4619',
|
|
1158
|
+
borderColor: '#eb4619'
|
|
1138
1159
|
},
|
|
1139
|
-
variant:
|
|
1140
|
-
onClick: handleDeleteAll,
|
|
1160
|
+
variant: 'outlined',
|
|
1161
|
+
onClick: () => handleDeleteAll(item),
|
|
1141
1162
|
className: "d-flex toolbar-button"
|
|
1142
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1163
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
1143
1164
|
}
|
|
1144
1165
|
};
|
|
1145
1166
|
}
|
|
@@ -1148,104 +1169,104 @@ const TableContainerEdit = props => {
|
|
|
1148
1169
|
};
|
|
1149
1170
|
});
|
|
1150
1171
|
}
|
|
1151
|
-
return toolbarItems?.filter(it => it.position ===
|
|
1152
|
-
if (item.key ===
|
|
1172
|
+
return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false).map(item => {
|
|
1173
|
+
if (item.key === 'ADD') {
|
|
1153
1174
|
return {
|
|
1154
1175
|
...item,
|
|
1155
1176
|
template: () => {
|
|
1156
|
-
return /*#__PURE__*/React.createElement(Fragment, null, item.key ===
|
|
1177
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
|
|
1157
1178
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1158
1179
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1159
|
-
overlayClassName:
|
|
1180
|
+
overlayClassName: 'be-popup-container',
|
|
1160
1181
|
style: {
|
|
1161
|
-
color:
|
|
1162
|
-
borderColor:
|
|
1182
|
+
color: '#28c76f',
|
|
1183
|
+
borderColor: '#28c76f'
|
|
1163
1184
|
},
|
|
1164
|
-
className:
|
|
1185
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1165
1186
|
menu: {
|
|
1166
1187
|
items: itemsAdd,
|
|
1167
1188
|
onClick: e => handleAddMulti(item, Number(e.key))
|
|
1168
1189
|
}
|
|
1169
1190
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1170
1191
|
style: {
|
|
1171
|
-
color:
|
|
1192
|
+
color: '#28c76f'
|
|
1172
1193
|
},
|
|
1173
1194
|
onClick: () => handleAddMulti(item, 1)
|
|
1174
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1195
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
1175
1196
|
}
|
|
1176
1197
|
};
|
|
1177
1198
|
}
|
|
1178
|
-
if (item.key ===
|
|
1199
|
+
if (item.key === 'DUPLICATE') {
|
|
1179
1200
|
return {
|
|
1180
1201
|
...item,
|
|
1181
1202
|
template: () => {
|
|
1182
|
-
return /*#__PURE__*/React.createElement(Fragment, null, item.key ===
|
|
1203
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
1183
1204
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1184
1205
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1185
1206
|
style: {
|
|
1186
|
-
color:
|
|
1187
|
-
borderColor:
|
|
1207
|
+
color: '#28c76f',
|
|
1208
|
+
borderColor: '#28c76f'
|
|
1188
1209
|
},
|
|
1189
|
-
variant:
|
|
1210
|
+
variant: 'outlined',
|
|
1190
1211
|
onClick: handleDuplicate,
|
|
1191
1212
|
className: "d-flex toolbar-button"
|
|
1192
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1213
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate')));
|
|
1193
1214
|
}
|
|
1194
1215
|
};
|
|
1195
1216
|
}
|
|
1196
|
-
if (item.key ===
|
|
1217
|
+
if (item.key === 'INSERT_BEFORE') {
|
|
1197
1218
|
return {
|
|
1198
1219
|
...item,
|
|
1199
1220
|
template: () => {
|
|
1200
1221
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1201
1222
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1202
1223
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1203
|
-
overlayClassName:
|
|
1224
|
+
overlayClassName: 'be-popup-container',
|
|
1204
1225
|
style: {
|
|
1205
|
-
color:
|
|
1206
|
-
borderColor:
|
|
1226
|
+
color: '#28c76f',
|
|
1227
|
+
borderColor: '#28c76f'
|
|
1207
1228
|
},
|
|
1208
|
-
className:
|
|
1229
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1209
1230
|
menu: {
|
|
1210
1231
|
items: itemsAdd,
|
|
1211
1232
|
onClick: e => handleInsertBefore(item, Number(e.key))
|
|
1212
1233
|
}
|
|
1213
1234
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1214
1235
|
style: {
|
|
1215
|
-
color:
|
|
1236
|
+
color: '#28c76f'
|
|
1216
1237
|
},
|
|
1217
1238
|
onClick: () => handleInsertBefore(item, 1)
|
|
1218
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1239
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before'))));
|
|
1219
1240
|
}
|
|
1220
1241
|
};
|
|
1221
1242
|
}
|
|
1222
|
-
if (item.key ===
|
|
1243
|
+
if (item.key === 'INSERT_AFTER') {
|
|
1223
1244
|
return {
|
|
1224
1245
|
...item,
|
|
1225
1246
|
template: () => {
|
|
1226
1247
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1227
1248
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1228
1249
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1229
|
-
overlayClassName:
|
|
1250
|
+
overlayClassName: 'be-popup-container',
|
|
1230
1251
|
style: {
|
|
1231
|
-
color:
|
|
1232
|
-
borderColor:
|
|
1252
|
+
color: '#28c76f',
|
|
1253
|
+
borderColor: '#28c76f'
|
|
1233
1254
|
},
|
|
1234
|
-
className:
|
|
1255
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1235
1256
|
menu: {
|
|
1236
1257
|
items: itemsAdd,
|
|
1237
1258
|
onClick: e => handleInsertAfter(item, Number(e.key))
|
|
1238
1259
|
}
|
|
1239
1260
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1240
1261
|
style: {
|
|
1241
|
-
color:
|
|
1262
|
+
color: '#28c76f'
|
|
1242
1263
|
},
|
|
1243
1264
|
onClick: () => handleInsertAfter(item, 1)
|
|
1244
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1265
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after'))));
|
|
1245
1266
|
}
|
|
1246
1267
|
};
|
|
1247
1268
|
}
|
|
1248
|
-
if (item.key ===
|
|
1269
|
+
if (item.key === 'INSERT_CHILDREN') {
|
|
1249
1270
|
return {
|
|
1250
1271
|
...item,
|
|
1251
1272
|
template: () => {
|
|
@@ -1253,17 +1274,17 @@ const TableContainerEdit = props => {
|
|
|
1253
1274
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1254
1275
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1255
1276
|
style: {
|
|
1256
|
-
color:
|
|
1257
|
-
borderColor:
|
|
1277
|
+
color: '#28c76f',
|
|
1278
|
+
borderColor: '#28c76f'
|
|
1258
1279
|
},
|
|
1259
|
-
variant:
|
|
1280
|
+
variant: 'outlined',
|
|
1260
1281
|
onClick: () => handleInsertChild(item),
|
|
1261
1282
|
className: "d-flex toolbar-button"
|
|
1262
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1283
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children')));
|
|
1263
1284
|
}
|
|
1264
1285
|
};
|
|
1265
1286
|
}
|
|
1266
|
-
if (item.key ===
|
|
1287
|
+
if (item.key === 'DELETE') {
|
|
1267
1288
|
return {
|
|
1268
1289
|
...item,
|
|
1269
1290
|
template: () => {
|
|
@@ -1271,17 +1292,17 @@ const TableContainerEdit = props => {
|
|
|
1271
1292
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1272
1293
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1273
1294
|
style: {
|
|
1274
|
-
color:
|
|
1275
|
-
borderColor:
|
|
1295
|
+
color: '#eb4619',
|
|
1296
|
+
borderColor: '#eb4619'
|
|
1276
1297
|
},
|
|
1277
|
-
variant:
|
|
1298
|
+
variant: 'outlined',
|
|
1278
1299
|
onClick: handleDeleteAll,
|
|
1279
1300
|
className: "d-flex toolbar-button"
|
|
1280
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1301
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
1281
1302
|
}
|
|
1282
1303
|
};
|
|
1283
1304
|
}
|
|
1284
|
-
if (item.key ===
|
|
1305
|
+
if (item.key === 'DELETE_ROWS') {
|
|
1285
1306
|
return {
|
|
1286
1307
|
...item,
|
|
1287
1308
|
template: () => {
|
|
@@ -1289,13 +1310,13 @@ const TableContainerEdit = props => {
|
|
|
1289
1310
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1290
1311
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1291
1312
|
style: {
|
|
1292
|
-
color:
|
|
1293
|
-
borderColor:
|
|
1313
|
+
color: '#eb4619',
|
|
1314
|
+
borderColor: '#eb4619'
|
|
1294
1315
|
},
|
|
1295
|
-
variant:
|
|
1316
|
+
variant: 'outlined',
|
|
1296
1317
|
onClick: () => handleDeleteRows(item),
|
|
1297
1318
|
className: "d-flex toolbar-button"
|
|
1298
|
-
}, t ? `${t(
|
|
1319
|
+
}, t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`));
|
|
1299
1320
|
}
|
|
1300
1321
|
};
|
|
1301
1322
|
}
|
|
@@ -1312,20 +1333,20 @@ const TableContainerEdit = props => {
|
|
|
1312
1333
|
index
|
|
1313
1334
|
} = args;
|
|
1314
1335
|
const tmpData = [...dataSource];
|
|
1315
|
-
if (idCommand ===
|
|
1336
|
+
if (idCommand === 'DELETE') {
|
|
1316
1337
|
// bật modal confirm
|
|
1317
1338
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
1318
1339
|
MySwal.fire({
|
|
1319
|
-
title: t ? t(
|
|
1320
|
-
text: t ? t(
|
|
1340
|
+
title: t ? t('Confirm') : 'Confirm',
|
|
1341
|
+
text: t ? t('Do you want to delete item?') : 'Do you want to delete item?',
|
|
1321
1342
|
// icon: 'warning',
|
|
1322
1343
|
allowOutsideClick: false,
|
|
1323
1344
|
showCancelButton: true,
|
|
1324
|
-
confirmButtonText: t ? t(
|
|
1325
|
-
cancelButtonText: t ? t(
|
|
1345
|
+
confirmButtonText: t ? t('Delete') : 'Delete',
|
|
1346
|
+
cancelButtonText: t ? t('Cancel') : 'Cancel',
|
|
1326
1347
|
customClass: {
|
|
1327
|
-
confirmButton:
|
|
1328
|
-
cancelButton:
|
|
1348
|
+
confirmButton: 'be-button btn-primary',
|
|
1349
|
+
cancelButton: 'be-button btn-danger ms-1'
|
|
1329
1350
|
},
|
|
1330
1351
|
buttonsStyling: false
|
|
1331
1352
|
}).then(async result => {
|
|
@@ -1427,9 +1448,10 @@ const TableContainerEdit = props => {
|
|
|
1427
1448
|
}
|
|
1428
1449
|
};
|
|
1429
1450
|
const triggerContextMenuClick = args => {
|
|
1430
|
-
if (args.item?.parentKey && args.item.parentKey ===
|
|
1431
|
-
if (args.item.key ===
|
|
1451
|
+
if (args.item?.parentKey && args.item.parentKey === 'INSERT_BEFORE') {
|
|
1452
|
+
if (args.item.key === 'INSERT_BEFORE_ADV') {
|
|
1432
1453
|
// mở Modal
|
|
1454
|
+
|
|
1433
1455
|
// setOpenModalAddRow((prev) => (
|
|
1434
1456
|
// {
|
|
1435
1457
|
// ...prev,
|
|
@@ -1442,8 +1464,9 @@ const TableContainerEdit = props => {
|
|
|
1442
1464
|
}
|
|
1443
1465
|
return;
|
|
1444
1466
|
}
|
|
1445
|
-
if (args.item?.parentKey && args.item.parentKey ===
|
|
1446
|
-
if (args.item.key ===
|
|
1467
|
+
if (args.item?.parentKey && args.item.parentKey === 'INSERT_AFTER') {
|
|
1468
|
+
if (args.item.key === 'INSERT_AFTER_ADV') {
|
|
1469
|
+
|
|
1447
1470
|
// setOpenModalAddRow((prev) => (
|
|
1448
1471
|
// {
|
|
1449
1472
|
// ...prev,
|
|
@@ -1456,15 +1479,15 @@ const TableContainerEdit = props => {
|
|
|
1456
1479
|
}
|
|
1457
1480
|
return;
|
|
1458
1481
|
}
|
|
1459
|
-
if (args.item.key ===
|
|
1482
|
+
if (args.item.key === 'INSERT_CHILDREN') {
|
|
1460
1483
|
handleInsertChild(args.item);
|
|
1461
1484
|
return;
|
|
1462
1485
|
}
|
|
1463
|
-
if (args.item.key ===
|
|
1486
|
+
if (args.item.key === 'DELETE_ROWS') {
|
|
1464
1487
|
handleDeleteRows(args.item);
|
|
1465
1488
|
return;
|
|
1466
1489
|
}
|
|
1467
|
-
if (args.item.key ===
|
|
1490
|
+
if (args.item.key === 'DELETE_CONTENT') {
|
|
1468
1491
|
handleDeleteContent();
|
|
1469
1492
|
return;
|
|
1470
1493
|
}
|
|
@@ -1472,7 +1495,6 @@ const TableContainerEdit = props => {
|
|
|
1472
1495
|
};
|
|
1473
1496
|
const handleCellClick = (rowNumber, record, column, rowId, cellValue) => {
|
|
1474
1497
|
const cellClickCallback = newOptions => {
|
|
1475
|
-
console.log("newOptions", newOptions);
|
|
1476
1498
|
if (newOptions) {
|
|
1477
1499
|
const newElem = {
|
|
1478
1500
|
...column,
|
|
@@ -1483,7 +1505,7 @@ const TableContainerEdit = props => {
|
|
|
1483
1505
|
options: newOptions
|
|
1484
1506
|
}
|
|
1485
1507
|
};
|
|
1486
|
-
const rrr = updateArrayByKey([...propsColumns], newElem,
|
|
1508
|
+
const rrr = updateArrayByKey([...propsColumns], newElem, 'field');
|
|
1487
1509
|
triggerChangeColumns?.(rrr, [], "cellClick");
|
|
1488
1510
|
}
|
|
1489
1511
|
};
|
|
@@ -1499,55 +1521,55 @@ const TableContainerEdit = props => {
|
|
|
1499
1521
|
}
|
|
1500
1522
|
};
|
|
1501
1523
|
return /*#__PURE__*/React.createElement("div", {
|
|
1502
|
-
ref: containerRef
|
|
1503
|
-
|
|
1524
|
+
ref: containerRef,
|
|
1525
|
+
id: id
|
|
1504
1526
|
}, (showToolbar !== false || fullScreen !== false || showColumnChoose) && /*#__PURE__*/React.createElement("div", {
|
|
1505
1527
|
ref: topToolbarRef,
|
|
1506
1528
|
className: classNames(`${prefix}-grid-top-toolbar`, {})
|
|
1507
1529
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1508
1530
|
style: {
|
|
1509
|
-
display:
|
|
1510
|
-
justifyContent:
|
|
1511
|
-
alignItems:
|
|
1512
|
-
gap:
|
|
1531
|
+
display: 'flex',
|
|
1532
|
+
justifyContent: 'space-between',
|
|
1533
|
+
alignItems: 'center',
|
|
1534
|
+
gap: '.75rem'
|
|
1513
1535
|
}
|
|
1514
1536
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1515
1537
|
style: {
|
|
1516
1538
|
flex: 1,
|
|
1517
|
-
overflow:
|
|
1539
|
+
overflow: 'hidden'
|
|
1518
1540
|
}
|
|
1519
1541
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
1520
|
-
items: (toolbarItems ?? []).filter(it => it.position !==
|
|
1521
|
-
mode:
|
|
1542
|
+
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
1543
|
+
mode: 'scroll'
|
|
1522
1544
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1523
1545
|
style: {
|
|
1524
|
-
display:
|
|
1525
|
-
justifyContent:
|
|
1526
|
-
alignItems:
|
|
1527
|
-
gap:
|
|
1546
|
+
display: 'flex',
|
|
1547
|
+
justifyContent: 'space-between',
|
|
1548
|
+
alignItems: 'center',
|
|
1549
|
+
gap: '.75rem'
|
|
1528
1550
|
}
|
|
1529
|
-
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] ===
|
|
1551
|
+
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/React.createElement(Pagination, _extends({
|
|
1530
1552
|
showSizeChanger: true,
|
|
1531
1553
|
responsive: true,
|
|
1532
|
-
size:
|
|
1533
|
-
rootClassName:
|
|
1554
|
+
size: 'small',
|
|
1555
|
+
rootClassName: 'top-pagination',
|
|
1534
1556
|
showTotal: (total, range) =>
|
|
1535
1557
|
// @ts-ignore
|
|
1536
|
-
`${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ??
|
|
1537
|
-
}, pagination)), typeof actionTemplate ===
|
|
1558
|
+
`${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
1559
|
+
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
|
|
1538
1560
|
fontSize: 16,
|
|
1539
1561
|
onClick: () => {
|
|
1540
1562
|
setIsFullScreen(!isFullScreen);
|
|
1541
1563
|
},
|
|
1542
1564
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
1543
|
-
"data-tooltip-content": t ? t(
|
|
1565
|
+
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
1544
1566
|
}) : /*#__PURE__*/React.createElement(Maximize, {
|
|
1545
1567
|
fontSize: 16,
|
|
1546
1568
|
onClick: () => {
|
|
1547
1569
|
setIsFullScreen(!isFullScreen);
|
|
1548
1570
|
},
|
|
1549
1571
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
1550
|
-
"data-tooltip-content": t ? t(
|
|
1572
|
+
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
1551
1573
|
})), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
1552
1574
|
columns: columns,
|
|
1553
1575
|
originColumns: propsColumns,
|
|
@@ -1598,7 +1620,7 @@ const TableContainerEdit = props => {
|
|
|
1598
1620
|
setIsPasting,
|
|
1599
1621
|
setEndPasteCell,
|
|
1600
1622
|
setStartPasteCell,
|
|
1601
|
-
//
|
|
1623
|
+
//
|
|
1602
1624
|
control,
|
|
1603
1625
|
// trigger,
|
|
1604
1626
|
errors,
|
|
@@ -1611,8 +1633,7 @@ const TableContainerEdit = props => {
|
|
|
1611
1633
|
handleAddMulti,
|
|
1612
1634
|
dataErrors,
|
|
1613
1635
|
windowSize,
|
|
1614
|
-
handleCellClick
|
|
1615
|
-
isFullScreen
|
|
1636
|
+
handleCellClick
|
|
1616
1637
|
}
|
|
1617
1638
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
1618
1639
|
contextMenuItems: contextMenuItems,
|
|
@@ -1626,9 +1647,7 @@ const TableContainerEdit = props => {
|
|
|
1626
1647
|
contextMenuClick: triggerContextMenuClick,
|
|
1627
1648
|
contextMenuHidden: contextMenuHidden,
|
|
1628
1649
|
contextMenuOpen: contextMenuOpen,
|
|
1629
|
-
editAble: editAble
|
|
1630
|
-
// editAble={false}
|
|
1631
|
-
,
|
|
1650
|
+
editAble: editAble,
|
|
1632
1651
|
showEmptyText: showEmptyText,
|
|
1633
1652
|
summary: summary,
|
|
1634
1653
|
dataSource: dataSource,
|
|
@@ -1643,30 +1662,30 @@ const TableContainerEdit = props => {
|
|
|
1643
1662
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
1644
1663
|
ref: bottomToolbarRef
|
|
1645
1664
|
}, toolbarItemsBottom && toolbarItemsBottom.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
1646
|
-
className:
|
|
1665
|
+
className: 'ui-rc-toolbar-bottom'
|
|
1647
1666
|
// style={{ border: '0 1px 1px 1px solid #e0e0e0' }}
|
|
1648
1667
|
,
|
|
1649
1668
|
style: {
|
|
1650
|
-
borderBottom:
|
|
1651
|
-
borderRight:
|
|
1652
|
-
borderLeft:
|
|
1669
|
+
borderBottom: '1px solid #e0e0e0',
|
|
1670
|
+
borderRight: '1px solid #e0e0e0',
|
|
1671
|
+
borderLeft: '1px solid #e0e0e0'
|
|
1653
1672
|
}
|
|
1654
1673
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
1655
1674
|
style: {
|
|
1656
|
-
width:
|
|
1675
|
+
width: '100%'
|
|
1657
1676
|
},
|
|
1658
1677
|
items: toolbarItemsBottom ?? [],
|
|
1659
|
-
mode:
|
|
1678
|
+
mode: 'scroll',
|
|
1660
1679
|
onClick: ({}) => {
|
|
1661
|
-
setEditingKey(
|
|
1680
|
+
setEditingKey('');
|
|
1662
1681
|
}
|
|
1663
1682
|
})), pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination
|
|
1664
1683
|
// style={{padding: '0.75rem 1rem'}}
|
|
1665
1684
|
, _extends({}, pagination, {
|
|
1666
|
-
rootClassName:
|
|
1685
|
+
rootClassName: 'pagination-template',
|
|
1667
1686
|
showSizeChanger: true,
|
|
1668
1687
|
responsive: true,
|
|
1669
|
-
size:
|
|
1688
|
+
size: 'small',
|
|
1670
1689
|
total: pagination.total,
|
|
1671
1690
|
pageSize: pagination.onChange ? pagination?.pageSize : table.getState().pagination.pageSize,
|
|
1672
1691
|
pageSizeOptions: [20, 50, 100, 1000, 10000],
|
|
@@ -1679,11 +1698,11 @@ const TableContainerEdit = props => {
|
|
|
1679
1698
|
}
|
|
1680
1699
|
},
|
|
1681
1700
|
showTotal: (total, range) => `${numericFormatter((range[0] ?? 0).toString(), {
|
|
1682
|
-
thousandSeparator:
|
|
1701
|
+
thousandSeparator: '.'
|
|
1683
1702
|
})}-${numericFormatter((range[1] ?? 0).toString(), {
|
|
1684
|
-
thousandSeparator:
|
|
1703
|
+
thousandSeparator: '.'
|
|
1685
1704
|
})} / ${numericFormatter((total ?? 0).toString(), {
|
|
1686
|
-
thousandSeparator:
|
|
1705
|
+
thousandSeparator: '.'
|
|
1687
1706
|
})} items`
|
|
1688
1707
|
}))));
|
|
1689
1708
|
};
|