es-grid-template 1.7.37 → 1.7.38
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/LICENSE +21 -21
- package/README.md +1 -1
- package/es/grid-component/ContextMenu.d.ts +2 -3
- package/es/grid-component/ContextMenu.js +2 -2
- package/es/grid-component/InternalTable.d.ts +1 -1
- package/es/grid-component/InternalTable.js +31 -39
- package/es/grid-component/hooks/constant.js +6 -6
- package/es/grid-component/hooks/content/TooltipContent.d.ts +2 -1
- package/es/grid-component/hooks/useColumns.d.ts +3 -1
- 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 +2 -3
- package/es/table-component/ContextMenu.js +2 -2
- package/es/table-component/InternalTable.d.ts +6 -6
- package/es/table-component/InternalTable.js +32 -29
- package/es/table-component/TableContainer.d.ts +5 -5
- package/es/table-component/TableContainer.js +31 -32
- package/es/table-component/TableContainerEdit.d.ts +1 -1
- package/es/table-component/TableContainerEdit.js +236 -200
- package/es/table-component/body/EditableCell.js +154 -157
- 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 +37 -18
- package/es/table-component/body/TableBodyCellEdit.d.ts +4 -4
- package/es/table-component/body/TableBodyCellEdit.js +61 -53
- package/es/table-component/body/TableBodyRow.js +0 -1
- package/es/table-component/footer/TableFooterCell.d.ts +3 -3
- package/es/table-component/footer/TableFooterCell.js +8 -6
- 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 +2 -2
- package/es/table-component/hook/utils.js +202 -154
- 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 +23 -20
- package/es/table-component/type.d.ts +40 -40
- package/es/table-component/useContext.d.ts +4 -3
- package/es/table-component/useContext.js +4 -4
- package/lib/grid-component/ContextMenu.d.ts +2 -3
- package/lib/grid-component/InternalTable.d.ts +1 -1
- package/lib/grid-component/InternalTable.js +25 -33
- package/lib/grid-component/hooks/constant.js +6 -6
- package/lib/grid-component/hooks/content/TooltipContent.d.ts +2 -1
- package/lib/grid-component/hooks/useColumns.d.ts +3 -1
- 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 +2 -3
- package/lib/table-component/InternalTable.d.ts +6 -6
- package/lib/table-component/InternalTable.js +23 -22
- package/lib/table-component/TableContainer.d.ts +5 -5
- package/lib/table-component/TableContainer.js +24 -26
- package/lib/table-component/TableContainerEdit.d.ts +1 -1
- package/lib/table-component/TableContainerEdit.js +235 -199
- package/lib/table-component/body/EditableCell.js +153 -156
- 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 +36 -17
- package/lib/table-component/body/TableBodyCellEdit.d.ts +4 -4
- package/lib/table-component/body/TableBodyCellEdit.js +58 -50
- package/lib/table-component/body/TableBodyRow.js +0 -1
- package/lib/table-component/footer/TableFooterCell.d.ts +3 -3
- package/lib/table-component/footer/TableFooterCell.js +7 -5
- 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 +2 -2
- package/lib/table-component/hook/utils.js +201 -153
- 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 +23 -20
- package/lib/table-component/type.d.ts +40 -40
- package/lib/table-component/useContext.d.ts +4 -3
- package/lib/table-component/useContext.js +3 -3
- package/package.json +2 -2
- package/CHANGELOG.md +0 -6
|
@@ -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,7 +352,9 @@ 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)
|
|
355
|
+
if (!startCell || !endCell) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
356
358
|
|
|
357
359
|
// const allRows = table.getRowModel().rows;
|
|
358
360
|
const allRows = table.getRowModel().flatRows;
|
|
@@ -363,18 +365,20 @@ const TableContainerEdit = props => {
|
|
|
363
365
|
const dataToCopy = [];
|
|
364
366
|
rowIds.forEach(rowId => {
|
|
365
367
|
const row = allRows.find(r => r.id === rowId);
|
|
366
|
-
if (!row)
|
|
368
|
+
if (!row) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
367
371
|
const rowData = [];
|
|
368
372
|
colIds.forEach(colId => {
|
|
369
373
|
const cellll = row.getVisibleCells().find(c => c.column.id === colId);
|
|
370
374
|
const value = cellll?.getValue();
|
|
371
|
-
rowData.push(value !== undefined ? String(value) :
|
|
375
|
+
rowData.push(value !== undefined ? String(value) : "");
|
|
372
376
|
});
|
|
373
377
|
dataToCopy.push(rowData);
|
|
374
378
|
});
|
|
375
379
|
|
|
376
380
|
// Convert to TSV string
|
|
377
|
-
const tsv = dataToCopy.map(row => row.join(
|
|
381
|
+
const tsv = dataToCopy.map(row => row.join("\t")).join("\n");
|
|
378
382
|
|
|
379
383
|
// Copy to clipboard
|
|
380
384
|
navigator.clipboard.writeText(tsv).then(() => {});
|
|
@@ -394,7 +398,7 @@ const TableContainerEdit = props => {
|
|
|
394
398
|
onCellPaste.onPasted({
|
|
395
399
|
pasteData: pastedRows,
|
|
396
400
|
copyRows,
|
|
397
|
-
type:
|
|
401
|
+
type: "onPaste",
|
|
398
402
|
data: originData,
|
|
399
403
|
pastedColumns: pastedColumnsArray
|
|
400
404
|
}, handlePasteCallback);
|
|
@@ -402,7 +406,7 @@ const TableContainerEdit = props => {
|
|
|
402
406
|
// không có callback
|
|
403
407
|
onCellPaste.onPasted({
|
|
404
408
|
pasteData: pastedRows,
|
|
405
|
-
type:
|
|
409
|
+
type: "onPaste",
|
|
406
410
|
copyRows,
|
|
407
411
|
data: originData,
|
|
408
412
|
pastedColumns: pastedColumnsArray
|
|
@@ -458,11 +462,11 @@ const TableContainerEdit = props => {
|
|
|
458
462
|
}
|
|
459
463
|
const columnTarget = allCols[targetCol];
|
|
460
464
|
const columnOri = columnTarget.columnDef.meta ?? {};
|
|
461
|
-
const isEdit = typeof columnOri?.editEnable ===
|
|
465
|
+
const isEdit = typeof columnOri?.editEnable === "function" ? columnOri.editEnable(newData[targetRow]) : columnOri.editEnable;
|
|
462
466
|
if (isEdit) {
|
|
463
467
|
const columnKey = allCols[targetCol].id;
|
|
464
|
-
if (columnOri.type ===
|
|
465
|
-
const colFormat = typeof columnOri.format ===
|
|
468
|
+
if (columnOri.type === "number" && isFormattedNumber(cellValue.trim())) {
|
|
469
|
+
const colFormat = typeof columnOri.format === "function" ? columnOri.format(record) : columnOri.format;
|
|
466
470
|
const valuePasteFormat = detectSeparators(cellValue.trim());
|
|
467
471
|
const cellFormat = getFormat(colFormat, format);
|
|
468
472
|
const thousandSeparator = valuePasteFormat?.thousandSeparator ?? cellFormat?.thousandSeparator;
|
|
@@ -520,7 +524,7 @@ const TableContainerEdit = props => {
|
|
|
520
524
|
childData.push({
|
|
521
525
|
id: undefined,
|
|
522
526
|
rowId: newGuid(),
|
|
523
|
-
parentId: parent[rowKey ??
|
|
527
|
+
parentId: parent[rowKey ?? "id"]
|
|
524
528
|
});
|
|
525
529
|
}
|
|
526
530
|
rowValues.forEach((cellValue, colIndex) => {
|
|
@@ -534,7 +538,7 @@ const TableContainerEdit = props => {
|
|
|
534
538
|
// const isEdit = typeof columnTarget.editEnable === 'function' ? columnTarget.editEnable(childData[targetRow]) : columnTarget.editEnable
|
|
535
539
|
|
|
536
540
|
const columnOri = columnTarget.columnDef.meta ?? {};
|
|
537
|
-
const isEdit = typeof columnOri?.editEnable ===
|
|
541
|
+
const isEdit = typeof columnOri?.editEnable === "function" ? columnOri.editEnable(childData[targetRow]) : columnOri.editEnable;
|
|
538
542
|
if (isEdit) {
|
|
539
543
|
const columnKey = allCols[targetCol].id;
|
|
540
544
|
childData[targetRow] = {
|
|
@@ -559,12 +563,14 @@ const TableContainerEdit = props => {
|
|
|
559
563
|
}
|
|
560
564
|
}, [dataSource, format, onCellPaste?.maxRowsPaste, originData, rowKey, startCell, table, triggerPaste]);
|
|
561
565
|
const handlePasteToTable = React.useCallback(pasteData => {
|
|
562
|
-
if (!startCell)
|
|
566
|
+
if (!startCell) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
563
569
|
|
|
564
570
|
// const pastedRows = pasted.trim().split('\n').map(row => row.split('\t'));
|
|
565
571
|
|
|
566
572
|
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
567
|
-
const rowsPasted = pasteData.split("\n").filter(row => row !==
|
|
573
|
+
const rowsPasted = pasteData.split("\n").filter(row => row !== "").map(row =>
|
|
568
574
|
// const rows = pasteData.split("\n").map((row: any) =>
|
|
569
575
|
row.replace(/\r/g, "").split("\t"));
|
|
570
576
|
if (rowsPasted.length > (onCellPaste?.maxRowsPaste ?? 200)) {
|
|
@@ -573,17 +579,17 @@ const TableContainerEdit = props => {
|
|
|
573
579
|
Modal.confirm({
|
|
574
580
|
content: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Paragraph, {
|
|
575
581
|
style: {
|
|
576
|
-
marginBottom:
|
|
582
|
+
marginBottom: ".25rem",
|
|
577
583
|
fontSize: 14
|
|
578
584
|
}
|
|
579
585
|
}, "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, {
|
|
580
586
|
level: 5,
|
|
581
587
|
style: {
|
|
582
|
-
marginTop:
|
|
588
|
+
marginTop: ".75rem"
|
|
583
589
|
}
|
|
584
590
|
}, "B\u1EA1n c\xF3 mu\u1ED1n ti\u1EBFp t\u1EE5c sao ch\xE9p kh\xF4ng?")),
|
|
585
591
|
centered: true,
|
|
586
|
-
className:
|
|
592
|
+
className: "be-popup-container",
|
|
587
593
|
onOk: () => {
|
|
588
594
|
handlePasted(rowsPasted);
|
|
589
595
|
}
|
|
@@ -600,28 +606,32 @@ const TableContainerEdit = props => {
|
|
|
600
606
|
}, [handlePasted, onCellPaste?.maxRowsPaste, startCell]);
|
|
601
607
|
React.useEffect(() => {
|
|
602
608
|
const handleKeyDown = e => {
|
|
603
|
-
|
|
609
|
+
console.log({
|
|
610
|
+
e
|
|
611
|
+
});
|
|
612
|
+
if (e.ctrlKey && e.key === "c" && startCell && endCell) {
|
|
604
613
|
e.preventDefault();
|
|
605
614
|
copySelectionToClipboard();
|
|
606
615
|
}
|
|
607
616
|
};
|
|
608
|
-
window.addEventListener(
|
|
609
|
-
return () => window.removeEventListener(
|
|
617
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
618
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
610
619
|
}, [startCell, endCell, table, copySelectionToClipboard]);
|
|
611
620
|
React.useEffect(() => {
|
|
612
621
|
const handlePaste = e => {
|
|
613
622
|
if (startCell && !editingKey) {
|
|
614
623
|
e.preventDefault(); // Chặn hành vi mặc định
|
|
615
|
-
const clipboardText = e.clipboardData?.getData(
|
|
624
|
+
const clipboardText = e.clipboardData?.getData("text/plain") ?? "";
|
|
616
625
|
handlePasteToTable(clipboardText);
|
|
617
626
|
}
|
|
618
627
|
};
|
|
619
|
-
window.addEventListener(
|
|
620
|
-
return () => window.removeEventListener(
|
|
628
|
+
window.addEventListener("paste", handlePaste);
|
|
629
|
+
return () => window.removeEventListener("paste", handlePaste);
|
|
621
630
|
}, [startCell, endCell, table, handlePasteToTable, editingKey]);
|
|
622
631
|
React.useEffect(() => {
|
|
623
632
|
const handleClickOutside = event => {
|
|
624
633
|
const element = event.target;
|
|
634
|
+
console.log("event", event);
|
|
625
635
|
const container = document.querySelector(".be-popup-container");
|
|
626
636
|
const containerContextMenu = document.querySelector(".popup-context-menu");
|
|
627
637
|
const tableBody = document.querySelector(`#${id} .ui-rc-grid-tbody`);
|
|
@@ -639,7 +649,7 @@ const TableContainerEdit = props => {
|
|
|
639
649
|
onBlur?.(dataSource);
|
|
640
650
|
}
|
|
641
651
|
setTimeout(() => {
|
|
642
|
-
setEditingKey(
|
|
652
|
+
setEditingKey("");
|
|
643
653
|
// editingKey.current = ''
|
|
644
654
|
});
|
|
645
655
|
setEndCell(undefined);
|
|
@@ -649,12 +659,12 @@ const TableContainerEdit = props => {
|
|
|
649
659
|
};
|
|
650
660
|
|
|
651
661
|
// document.addEventListener('click', handleClickOutside)
|
|
652
|
-
document.addEventListener(
|
|
662
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
653
663
|
// document.addEventListener('touchstart', handleClickOutside)
|
|
654
664
|
|
|
655
665
|
return () => {
|
|
656
666
|
// document.removeEventListener('click', handleClickOutside)
|
|
657
|
-
document.removeEventListener(
|
|
667
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
658
668
|
// document.removeEventListener('touchstart', handleClickOutside)
|
|
659
669
|
};
|
|
660
670
|
}, [dataSource, editingKey, id, onBlur]);
|
|
@@ -665,7 +675,9 @@ const TableContainerEdit = props => {
|
|
|
665
675
|
});
|
|
666
676
|
}, [columnSizingState, columnVirtualizer]);
|
|
667
677
|
React.useEffect(() => {
|
|
668
|
-
if (!containerRef.current)
|
|
678
|
+
if (!containerRef.current) {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
669
681
|
const containerWidth = containerRef.current.offsetWidth - 1;
|
|
670
682
|
const totalWidth = table.getTotalSize();
|
|
671
683
|
if (totalWidth && totalWidth < containerWidth) {
|
|
@@ -697,7 +709,7 @@ const TableContainerEdit = props => {
|
|
|
697
709
|
errors
|
|
698
710
|
}
|
|
699
711
|
} = useForm({
|
|
700
|
-
mode:
|
|
712
|
+
mode: "onChange",
|
|
701
713
|
resolver: validate ? yupResolver(validate) : undefined
|
|
702
714
|
});
|
|
703
715
|
const onSubmit = formData => {
|
|
@@ -717,7 +729,7 @@ const TableContainerEdit = props => {
|
|
|
717
729
|
triggerChangeData?.(rs);
|
|
718
730
|
}
|
|
719
731
|
} catch (errInfo) {
|
|
720
|
-
console.log(
|
|
732
|
+
console.log("Validate Failed:", errInfo);
|
|
721
733
|
}
|
|
722
734
|
};
|
|
723
735
|
const handleCellChange = args => {
|
|
@@ -732,7 +744,7 @@ const TableContainerEdit = props => {
|
|
|
732
744
|
indexRow,
|
|
733
745
|
key
|
|
734
746
|
} = args;
|
|
735
|
-
if (changeType ===
|
|
747
|
+
if (changeType === "blur") {
|
|
736
748
|
const handleChangeCallback = callbackData => {
|
|
737
749
|
const callbackRecord = callbackData;
|
|
738
750
|
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
@@ -745,7 +757,7 @@ const TableContainerEdit = props => {
|
|
|
745
757
|
onCellChange({
|
|
746
758
|
field,
|
|
747
759
|
indexCol,
|
|
748
|
-
type:
|
|
760
|
+
type: "onChange",
|
|
749
761
|
value: newState,
|
|
750
762
|
option,
|
|
751
763
|
indexRow,
|
|
@@ -759,7 +771,7 @@ const TableContainerEdit = props => {
|
|
|
759
771
|
onCellChange({
|
|
760
772
|
field,
|
|
761
773
|
indexCol,
|
|
762
|
-
type:
|
|
774
|
+
type: "onChange",
|
|
763
775
|
option,
|
|
764
776
|
value: newState,
|
|
765
777
|
indexRow,
|
|
@@ -773,7 +785,7 @@ const TableContainerEdit = props => {
|
|
|
773
785
|
}
|
|
774
786
|
}
|
|
775
787
|
}
|
|
776
|
-
if (prevState && newState && prevState !== newState && changeType ===
|
|
788
|
+
if (prevState && newState && prevState !== newState && changeType === "enter") {
|
|
777
789
|
onSubmit(record);
|
|
778
790
|
}
|
|
779
791
|
};
|
|
@@ -1021,7 +1033,29 @@ const TableContainerEdit = props => {
|
|
|
1021
1033
|
const filterData = flattenArray([...originData]);
|
|
1022
1034
|
const rs = filterData.filter(it => !rowsFocus.includes(it[rowKey]));
|
|
1023
1035
|
const newDaa = unFlattenData(rs);
|
|
1024
|
-
|
|
1036
|
+
if (commandSettings && commandSettings.confirmDialog) {
|
|
1037
|
+
MySwal.fire({
|
|
1038
|
+
title: t ? t("Confirm") : "Confirm",
|
|
1039
|
+
text: t ? t("Do you want to delete item?") : "Do you want to delete item?",
|
|
1040
|
+
// icon: 'warning',
|
|
1041
|
+
allowOutsideClick: false,
|
|
1042
|
+
showCancelButton: true,
|
|
1043
|
+
confirmButtonText: t ? t("Delete") : "Delete",
|
|
1044
|
+
cancelButtonText: t ? t("Cancel") : "Cancel",
|
|
1045
|
+
customClass: {
|
|
1046
|
+
confirmButton: "be-button btn-primary",
|
|
1047
|
+
cancelButton: "be-button btn-danger ms-1"
|
|
1048
|
+
},
|
|
1049
|
+
buttonsStyling: false
|
|
1050
|
+
}).then(async result => {
|
|
1051
|
+
if (result.value) {
|
|
1052
|
+
triggerChangeData?.([...newDaa]);
|
|
1053
|
+
} else if (result.dismiss === MySwal.DismissReason.cancel) {}
|
|
1054
|
+
});
|
|
1055
|
+
} else {
|
|
1056
|
+
// không hiện dialog
|
|
1057
|
+
triggerChangeData?.([...newDaa]);
|
|
1058
|
+
}
|
|
1025
1059
|
}
|
|
1026
1060
|
}, [originData, rowKey, rowsFocus, triggerChangeData]);
|
|
1027
1061
|
const handleDeleteAll = React.useCallback(() => {
|
|
@@ -1041,17 +1075,17 @@ const TableContainerEdit = props => {
|
|
|
1041
1075
|
const column = table.getVisibleFlatColumns().find(it => it.id === colId)?.columnDef.meta;
|
|
1042
1076
|
const columnIndex = table.getVisibleFlatColumns().findIndex(it => it.id === colId);
|
|
1043
1077
|
if (isEditable(column, row)) {
|
|
1044
|
-
updatedRow[colId] =
|
|
1078
|
+
updatedRow[colId] = "";
|
|
1045
1079
|
handleCellChange({
|
|
1046
1080
|
key: row[rowKey],
|
|
1047
1081
|
field: column.field ?? column.dataIndex,
|
|
1048
1082
|
record: updatedRow,
|
|
1049
1083
|
prevState: row[column.field],
|
|
1050
|
-
newState:
|
|
1051
|
-
option:
|
|
1084
|
+
newState: "",
|
|
1085
|
+
option: "",
|
|
1052
1086
|
indexCol: columnIndex,
|
|
1053
1087
|
indexRow: index,
|
|
1054
|
-
type:
|
|
1088
|
+
type: "blur"
|
|
1055
1089
|
});
|
|
1056
1090
|
}
|
|
1057
1091
|
}
|
|
@@ -1063,35 +1097,35 @@ const TableContainerEdit = props => {
|
|
|
1063
1097
|
};
|
|
1064
1098
|
const toolbarItemsBottom = React.useMemo(() => {
|
|
1065
1099
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
1066
|
-
return toolbarItems?.filter(it => it.position ===
|
|
1067
|
-
if (item.key ===
|
|
1100
|
+
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 => {
|
|
1101
|
+
if (item.key === "ADD") {
|
|
1068
1102
|
return {
|
|
1069
1103
|
...item,
|
|
1070
1104
|
template: () => {
|
|
1071
|
-
return /*#__PURE__*/React.createElement(Fragment, null, item.key ===
|
|
1105
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === "ADD" && /*#__PURE__*/React.createElement("div", {
|
|
1072
1106
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1073
1107
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1074
|
-
overlayClassName:
|
|
1075
|
-
trigger: [
|
|
1108
|
+
overlayClassName: "be-popup-container",
|
|
1109
|
+
trigger: ["click"],
|
|
1076
1110
|
style: {
|
|
1077
|
-
color:
|
|
1078
|
-
borderColor:
|
|
1111
|
+
color: "#28c76f",
|
|
1112
|
+
borderColor: "#28c76f"
|
|
1079
1113
|
},
|
|
1080
|
-
className:
|
|
1114
|
+
className: "toolbar-button toolbar-dropdown-button",
|
|
1081
1115
|
menu: {
|
|
1082
1116
|
items: itemsAdd,
|
|
1083
1117
|
onClick: e => handleAddMulti(item, Number(e.key))
|
|
1084
1118
|
}
|
|
1085
1119
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1086
1120
|
style: {
|
|
1087
|
-
color:
|
|
1121
|
+
color: "#28c76f"
|
|
1088
1122
|
},
|
|
1089
1123
|
onClick: () => handleAddMulti(item, 1)
|
|
1090
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1124
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t("Add item") : "Add item"))));
|
|
1091
1125
|
}
|
|
1092
1126
|
};
|
|
1093
1127
|
}
|
|
1094
|
-
if (item.key ===
|
|
1128
|
+
if (item.key === "DELETE") {
|
|
1095
1129
|
return {
|
|
1096
1130
|
...item,
|
|
1097
1131
|
template: () => {
|
|
@@ -1099,13 +1133,13 @@ const TableContainerEdit = props => {
|
|
|
1099
1133
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1100
1134
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1101
1135
|
style: {
|
|
1102
|
-
color:
|
|
1103
|
-
borderColor:
|
|
1136
|
+
color: "#eb4619",
|
|
1137
|
+
borderColor: "#eb4619"
|
|
1104
1138
|
},
|
|
1105
|
-
variant:
|
|
1139
|
+
variant: "outlined",
|
|
1106
1140
|
onClick: handleDeleteAll,
|
|
1107
1141
|
className: "d-flex toolbar-button"
|
|
1108
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1142
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t("Delete all item") : "Delete all item"));
|
|
1109
1143
|
}
|
|
1110
1144
|
};
|
|
1111
1145
|
}
|
|
@@ -1114,104 +1148,104 @@ const TableContainerEdit = props => {
|
|
|
1114
1148
|
};
|
|
1115
1149
|
});
|
|
1116
1150
|
}
|
|
1117
|
-
return toolbarItems?.filter(it => it.position ===
|
|
1118
|
-
if (item.key ===
|
|
1151
|
+
return toolbarItems?.filter(it => it.position === "Bottom" && it.visible !== false).map(item => {
|
|
1152
|
+
if (item.key === "ADD") {
|
|
1119
1153
|
return {
|
|
1120
1154
|
...item,
|
|
1121
1155
|
template: () => {
|
|
1122
|
-
return /*#__PURE__*/React.createElement(Fragment, null, item.key ===
|
|
1156
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === "ADD" && /*#__PURE__*/React.createElement("div", {
|
|
1123
1157
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1124
1158
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1125
|
-
overlayClassName:
|
|
1159
|
+
overlayClassName: "be-popup-container",
|
|
1126
1160
|
style: {
|
|
1127
|
-
color:
|
|
1128
|
-
borderColor:
|
|
1161
|
+
color: "#28c76f",
|
|
1162
|
+
borderColor: "#28c76f"
|
|
1129
1163
|
},
|
|
1130
|
-
className:
|
|
1164
|
+
className: "toolbar-button toolbar-dropdown-button",
|
|
1131
1165
|
menu: {
|
|
1132
1166
|
items: itemsAdd,
|
|
1133
1167
|
onClick: e => handleAddMulti(item, Number(e.key))
|
|
1134
1168
|
}
|
|
1135
1169
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1136
1170
|
style: {
|
|
1137
|
-
color:
|
|
1171
|
+
color: "#28c76f"
|
|
1138
1172
|
},
|
|
1139
1173
|
onClick: () => handleAddMulti(item, 1)
|
|
1140
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1174
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t("Add item") : "Add item"))));
|
|
1141
1175
|
}
|
|
1142
1176
|
};
|
|
1143
1177
|
}
|
|
1144
|
-
if (item.key ===
|
|
1178
|
+
if (item.key === "DUPLICATE") {
|
|
1145
1179
|
return {
|
|
1146
1180
|
...item,
|
|
1147
1181
|
template: () => {
|
|
1148
|
-
return /*#__PURE__*/React.createElement(Fragment, null, item.key ===
|
|
1182
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === "DUPLICATE" && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
1149
1183
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1150
1184
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1151
1185
|
style: {
|
|
1152
|
-
color:
|
|
1153
|
-
borderColor:
|
|
1186
|
+
color: "#28c76f",
|
|
1187
|
+
borderColor: "#28c76f"
|
|
1154
1188
|
},
|
|
1155
|
-
variant:
|
|
1189
|
+
variant: "outlined",
|
|
1156
1190
|
onClick: handleDuplicate,
|
|
1157
1191
|
className: "d-flex toolbar-button"
|
|
1158
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1192
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t("Duplicate") : "Duplicate")));
|
|
1159
1193
|
}
|
|
1160
1194
|
};
|
|
1161
1195
|
}
|
|
1162
|
-
if (item.key ===
|
|
1196
|
+
if (item.key === "INSERT_BEFORE") {
|
|
1163
1197
|
return {
|
|
1164
1198
|
...item,
|
|
1165
1199
|
template: () => {
|
|
1166
1200
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1167
1201
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1168
1202
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1169
|
-
overlayClassName:
|
|
1203
|
+
overlayClassName: "be-popup-container",
|
|
1170
1204
|
style: {
|
|
1171
|
-
color:
|
|
1172
|
-
borderColor:
|
|
1205
|
+
color: "#28c76f",
|
|
1206
|
+
borderColor: "#28c76f"
|
|
1173
1207
|
},
|
|
1174
|
-
className:
|
|
1208
|
+
className: "toolbar-button toolbar-dropdown-button",
|
|
1175
1209
|
menu: {
|
|
1176
1210
|
items: itemsAdd,
|
|
1177
1211
|
onClick: e => handleInsertBefore(item, Number(e.key))
|
|
1178
1212
|
}
|
|
1179
1213
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1180
1214
|
style: {
|
|
1181
|
-
color:
|
|
1215
|
+
color: "#28c76f"
|
|
1182
1216
|
},
|
|
1183
1217
|
onClick: () => handleInsertBefore(item, 1)
|
|
1184
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1218
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t("Insert item before") : "Insert item before"))));
|
|
1185
1219
|
}
|
|
1186
1220
|
};
|
|
1187
1221
|
}
|
|
1188
|
-
if (item.key ===
|
|
1222
|
+
if (item.key === "INSERT_AFTER") {
|
|
1189
1223
|
return {
|
|
1190
1224
|
...item,
|
|
1191
1225
|
template: () => {
|
|
1192
1226
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1193
1227
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1194
1228
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1195
|
-
overlayClassName:
|
|
1229
|
+
overlayClassName: "be-popup-container",
|
|
1196
1230
|
style: {
|
|
1197
|
-
color:
|
|
1198
|
-
borderColor:
|
|
1231
|
+
color: "#28c76f",
|
|
1232
|
+
borderColor: "#28c76f"
|
|
1199
1233
|
},
|
|
1200
|
-
className:
|
|
1234
|
+
className: "toolbar-button toolbar-dropdown-button",
|
|
1201
1235
|
menu: {
|
|
1202
1236
|
items: itemsAdd,
|
|
1203
1237
|
onClick: e => handleInsertAfter(item, Number(e.key))
|
|
1204
1238
|
}
|
|
1205
1239
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1206
1240
|
style: {
|
|
1207
|
-
color:
|
|
1241
|
+
color: "#28c76f"
|
|
1208
1242
|
},
|
|
1209
1243
|
onClick: () => handleInsertAfter(item, 1)
|
|
1210
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1244
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t("Insert item after") : "Insert item after"))));
|
|
1211
1245
|
}
|
|
1212
1246
|
};
|
|
1213
1247
|
}
|
|
1214
|
-
if (item.key ===
|
|
1248
|
+
if (item.key === "INSERT_CHILDREN") {
|
|
1215
1249
|
return {
|
|
1216
1250
|
...item,
|
|
1217
1251
|
template: () => {
|
|
@@ -1219,17 +1253,17 @@ const TableContainerEdit = props => {
|
|
|
1219
1253
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1220
1254
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1221
1255
|
style: {
|
|
1222
|
-
color:
|
|
1223
|
-
borderColor:
|
|
1256
|
+
color: "#28c76f",
|
|
1257
|
+
borderColor: "#28c76f"
|
|
1224
1258
|
},
|
|
1225
|
-
variant:
|
|
1259
|
+
variant: "outlined",
|
|
1226
1260
|
onClick: () => handleInsertChild(item),
|
|
1227
1261
|
className: "d-flex toolbar-button"
|
|
1228
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1262
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t("Insert item children") : "Insert item children")));
|
|
1229
1263
|
}
|
|
1230
1264
|
};
|
|
1231
1265
|
}
|
|
1232
|
-
if (item.key ===
|
|
1266
|
+
if (item.key === "DELETE") {
|
|
1233
1267
|
return {
|
|
1234
1268
|
...item,
|
|
1235
1269
|
template: () => {
|
|
@@ -1237,17 +1271,17 @@ const TableContainerEdit = props => {
|
|
|
1237
1271
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1238
1272
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1239
1273
|
style: {
|
|
1240
|
-
color:
|
|
1241
|
-
borderColor:
|
|
1274
|
+
color: "#eb4619",
|
|
1275
|
+
borderColor: "#eb4619"
|
|
1242
1276
|
},
|
|
1243
|
-
variant:
|
|
1277
|
+
variant: "outlined",
|
|
1244
1278
|
onClick: handleDeleteAll,
|
|
1245
1279
|
className: "d-flex toolbar-button"
|
|
1246
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1280
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t("Delete all item") : "Delete all item"));
|
|
1247
1281
|
}
|
|
1248
1282
|
};
|
|
1249
1283
|
}
|
|
1250
|
-
if (item.key ===
|
|
1284
|
+
if (item.key === "DELETE_ROWS") {
|
|
1251
1285
|
return {
|
|
1252
1286
|
...item,
|
|
1253
1287
|
template: () => {
|
|
@@ -1255,13 +1289,13 @@ const TableContainerEdit = props => {
|
|
|
1255
1289
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1256
1290
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1257
1291
|
style: {
|
|
1258
|
-
color:
|
|
1259
|
-
borderColor:
|
|
1292
|
+
color: "#eb4619",
|
|
1293
|
+
borderColor: "#eb4619"
|
|
1260
1294
|
},
|
|
1261
|
-
variant:
|
|
1295
|
+
variant: "outlined",
|
|
1262
1296
|
onClick: () => handleDeleteRows(item),
|
|
1263
1297
|
className: "d-flex toolbar-button"
|
|
1264
|
-
}, t ? `${t(
|
|
1298
|
+
}, t ? `${t("Delete")} ${rowsFocus.length} ${t("row")}` : `Delete ${rowsFocus.length} item`));
|
|
1265
1299
|
}
|
|
1266
1300
|
};
|
|
1267
1301
|
}
|
|
@@ -1278,20 +1312,20 @@ const TableContainerEdit = props => {
|
|
|
1278
1312
|
index
|
|
1279
1313
|
} = args;
|
|
1280
1314
|
const tmpData = [...dataSource];
|
|
1281
|
-
if (idCommand ===
|
|
1315
|
+
if (idCommand === "DELETE") {
|
|
1282
1316
|
// bật modal confirm
|
|
1283
1317
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
1284
1318
|
MySwal.fire({
|
|
1285
|
-
title: t ? t(
|
|
1286
|
-
text: t ? t(
|
|
1319
|
+
title: t ? t("Confirm") : "Confirm",
|
|
1320
|
+
text: t ? t("Do you want to delete item?") : "Do you want to delete item?",
|
|
1287
1321
|
// icon: 'warning',
|
|
1288
1322
|
allowOutsideClick: false,
|
|
1289
1323
|
showCancelButton: true,
|
|
1290
|
-
confirmButtonText: t ? t(
|
|
1291
|
-
cancelButtonText: t ? t(
|
|
1324
|
+
confirmButtonText: t ? t("Delete") : "Delete",
|
|
1325
|
+
cancelButtonText: t ? t("Cancel") : "Cancel",
|
|
1292
1326
|
customClass: {
|
|
1293
|
-
confirmButton:
|
|
1294
|
-
cancelButton:
|
|
1327
|
+
confirmButton: "be-button btn-primary",
|
|
1328
|
+
cancelButton: "be-button btn-danger ms-1"
|
|
1295
1329
|
},
|
|
1296
1330
|
buttonsStyling: false
|
|
1297
1331
|
}).then(async result => {
|
|
@@ -1393,10 +1427,9 @@ const TableContainerEdit = props => {
|
|
|
1393
1427
|
}
|
|
1394
1428
|
};
|
|
1395
1429
|
const triggerContextMenuClick = args => {
|
|
1396
|
-
if (args.item?.parentKey && args.item.parentKey ===
|
|
1397
|
-
if (args.item.key ===
|
|
1430
|
+
if (args.item?.parentKey && args.item.parentKey === "INSERT_BEFORE") {
|
|
1431
|
+
if (args.item.key === "INSERT_BEFORE_ADV") {
|
|
1398
1432
|
// mở Modal
|
|
1399
|
-
|
|
1400
1433
|
// setOpenModalAddRow((prev) => (
|
|
1401
1434
|
// {
|
|
1402
1435
|
// ...prev,
|
|
@@ -1409,9 +1442,8 @@ const TableContainerEdit = props => {
|
|
|
1409
1442
|
}
|
|
1410
1443
|
return;
|
|
1411
1444
|
}
|
|
1412
|
-
if (args.item?.parentKey && args.item.parentKey ===
|
|
1413
|
-
if (args.item.key ===
|
|
1414
|
-
|
|
1445
|
+
if (args.item?.parentKey && args.item.parentKey === "INSERT_AFTER") {
|
|
1446
|
+
if (args.item.key === "INSERT_AFTER_ADV") {
|
|
1415
1447
|
// setOpenModalAddRow((prev) => (
|
|
1416
1448
|
// {
|
|
1417
1449
|
// ...prev,
|
|
@@ -1424,15 +1456,15 @@ const TableContainerEdit = props => {
|
|
|
1424
1456
|
}
|
|
1425
1457
|
return;
|
|
1426
1458
|
}
|
|
1427
|
-
if (args.item.key ===
|
|
1459
|
+
if (args.item.key === "INSERT_CHILDREN") {
|
|
1428
1460
|
handleInsertChild(args.item);
|
|
1429
1461
|
return;
|
|
1430
1462
|
}
|
|
1431
|
-
if (args.item.key ===
|
|
1463
|
+
if (args.item.key === "DELETE_ROWS") {
|
|
1432
1464
|
handleDeleteRows(args.item);
|
|
1433
1465
|
return;
|
|
1434
1466
|
}
|
|
1435
|
-
if (args.item.key ===
|
|
1467
|
+
if (args.item.key === "DELETE_CONTENT") {
|
|
1436
1468
|
handleDeleteContent();
|
|
1437
1469
|
return;
|
|
1438
1470
|
}
|
|
@@ -1440,6 +1472,7 @@ const TableContainerEdit = props => {
|
|
|
1440
1472
|
};
|
|
1441
1473
|
const handleCellClick = (rowNumber, record, column, rowId, cellValue) => {
|
|
1442
1474
|
const cellClickCallback = newOptions => {
|
|
1475
|
+
console.log("newOptions", newOptions);
|
|
1443
1476
|
if (newOptions) {
|
|
1444
1477
|
const newElem = {
|
|
1445
1478
|
...column,
|
|
@@ -1450,8 +1483,8 @@ const TableContainerEdit = props => {
|
|
|
1450
1483
|
options: newOptions
|
|
1451
1484
|
}
|
|
1452
1485
|
};
|
|
1453
|
-
const rrr = updateArrayByKey([...
|
|
1454
|
-
triggerChangeColumns?.(rrr,
|
|
1486
|
+
const rrr = updateArrayByKey([...propsColumns], newElem, "field");
|
|
1487
|
+
triggerChangeColumns?.(rrr, [], "cellClick");
|
|
1455
1488
|
}
|
|
1456
1489
|
};
|
|
1457
1490
|
if (onCellClick) {
|
|
@@ -1466,55 +1499,55 @@ const TableContainerEdit = props => {
|
|
|
1466
1499
|
}
|
|
1467
1500
|
};
|
|
1468
1501
|
return /*#__PURE__*/React.createElement("div", {
|
|
1469
|
-
ref: containerRef
|
|
1470
|
-
id
|
|
1502
|
+
ref: containerRef
|
|
1503
|
+
// id={id}
|
|
1471
1504
|
}, (showToolbar !== false || fullScreen !== false || showColumnChoose) && /*#__PURE__*/React.createElement("div", {
|
|
1472
1505
|
ref: topToolbarRef,
|
|
1473
1506
|
className: classNames(`${prefix}-grid-top-toolbar`, {})
|
|
1474
1507
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1475
1508
|
style: {
|
|
1476
|
-
display:
|
|
1477
|
-
justifyContent:
|
|
1478
|
-
alignItems:
|
|
1479
|
-
gap:
|
|
1509
|
+
display: "flex",
|
|
1510
|
+
justifyContent: "space-between",
|
|
1511
|
+
alignItems: "center",
|
|
1512
|
+
gap: ".75rem"
|
|
1480
1513
|
}
|
|
1481
1514
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1482
1515
|
style: {
|
|
1483
1516
|
flex: 1,
|
|
1484
|
-
overflow:
|
|
1517
|
+
overflow: "hidden"
|
|
1485
1518
|
}
|
|
1486
1519
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
1487
|
-
items: (toolbarItems ?? []).filter(it => it.position !==
|
|
1488
|
-
mode:
|
|
1520
|
+
items: (toolbarItems ?? []).filter(it => it.position !== "Bottom"),
|
|
1521
|
+
mode: "scroll"
|
|
1489
1522
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1490
1523
|
style: {
|
|
1491
|
-
display:
|
|
1492
|
-
justifyContent:
|
|
1493
|
-
alignItems:
|
|
1494
|
-
gap:
|
|
1524
|
+
display: "flex",
|
|
1525
|
+
justifyContent: "space-between",
|
|
1526
|
+
alignItems: "center",
|
|
1527
|
+
gap: ".75rem"
|
|
1495
1528
|
}
|
|
1496
|
-
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] ===
|
|
1529
|
+
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === "topRight" && /*#__PURE__*/React.createElement(Pagination, _extends({
|
|
1497
1530
|
showSizeChanger: true,
|
|
1498
1531
|
responsive: true,
|
|
1499
|
-
size:
|
|
1500
|
-
rootClassName:
|
|
1532
|
+
size: "small",
|
|
1533
|
+
rootClassName: "top-pagination",
|
|
1501
1534
|
showTotal: (total, range) =>
|
|
1502
1535
|
// @ts-ignore
|
|
1503
|
-
`${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ??
|
|
1504
|
-
}, pagination)), typeof actionTemplate ===
|
|
1536
|
+
`${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? "items") : "items"}`
|
|
1537
|
+
}, pagination)), typeof actionTemplate === "function" ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
|
|
1505
1538
|
fontSize: 16,
|
|
1506
1539
|
onClick: () => {
|
|
1507
1540
|
setIsFullScreen(!isFullScreen);
|
|
1508
1541
|
},
|
|
1509
1542
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
1510
|
-
"data-tooltip-content": t ? t(
|
|
1543
|
+
"data-tooltip-content": t ? t("Minimized") : "Minimized"
|
|
1511
1544
|
}) : /*#__PURE__*/React.createElement(Maximize, {
|
|
1512
1545
|
fontSize: 16,
|
|
1513
1546
|
onClick: () => {
|
|
1514
1547
|
setIsFullScreen(!isFullScreen);
|
|
1515
1548
|
},
|
|
1516
1549
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
1517
|
-
"data-tooltip-content": t ? t(
|
|
1550
|
+
"data-tooltip-content": t ? t("Full screen") : "Full screen"
|
|
1518
1551
|
})), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
1519
1552
|
columns: columns,
|
|
1520
1553
|
originColumns: propsColumns,
|
|
@@ -1565,7 +1598,7 @@ const TableContainerEdit = props => {
|
|
|
1565
1598
|
setIsPasting,
|
|
1566
1599
|
setEndPasteCell,
|
|
1567
1600
|
setStartPasteCell,
|
|
1568
|
-
//
|
|
1601
|
+
//
|
|
1569
1602
|
control,
|
|
1570
1603
|
// trigger,
|
|
1571
1604
|
errors,
|
|
@@ -1578,7 +1611,8 @@ const TableContainerEdit = props => {
|
|
|
1578
1611
|
handleAddMulti,
|
|
1579
1612
|
dataErrors,
|
|
1580
1613
|
windowSize,
|
|
1581
|
-
handleCellClick
|
|
1614
|
+
handleCellClick,
|
|
1615
|
+
isFullScreen
|
|
1582
1616
|
}
|
|
1583
1617
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
1584
1618
|
contextMenuItems: contextMenuItems,
|
|
@@ -1592,7 +1626,9 @@ const TableContainerEdit = props => {
|
|
|
1592
1626
|
contextMenuClick: triggerContextMenuClick,
|
|
1593
1627
|
contextMenuHidden: contextMenuHidden,
|
|
1594
1628
|
contextMenuOpen: contextMenuOpen,
|
|
1595
|
-
editAble: editAble
|
|
1629
|
+
editAble: editAble
|
|
1630
|
+
// editAble={false}
|
|
1631
|
+
,
|
|
1596
1632
|
showEmptyText: showEmptyText,
|
|
1597
1633
|
summary: summary,
|
|
1598
1634
|
dataSource: dataSource,
|
|
@@ -1607,30 +1643,30 @@ const TableContainerEdit = props => {
|
|
|
1607
1643
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
1608
1644
|
ref: bottomToolbarRef
|
|
1609
1645
|
}, toolbarItemsBottom && toolbarItemsBottom.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
1610
|
-
className:
|
|
1646
|
+
className: "ui-rc-toolbar-bottom"
|
|
1611
1647
|
// style={{ border: '0 1px 1px 1px solid #e0e0e0' }}
|
|
1612
1648
|
,
|
|
1613
1649
|
style: {
|
|
1614
|
-
borderBottom:
|
|
1615
|
-
borderRight:
|
|
1616
|
-
borderLeft:
|
|
1650
|
+
borderBottom: "1px solid #e0e0e0",
|
|
1651
|
+
borderRight: "1px solid #e0e0e0",
|
|
1652
|
+
borderLeft: "1px solid #e0e0e0"
|
|
1617
1653
|
}
|
|
1618
1654
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
1619
1655
|
style: {
|
|
1620
|
-
width:
|
|
1656
|
+
width: "100%"
|
|
1621
1657
|
},
|
|
1622
1658
|
items: toolbarItemsBottom ?? [],
|
|
1623
|
-
mode:
|
|
1659
|
+
mode: "scroll",
|
|
1624
1660
|
onClick: ({}) => {
|
|
1625
|
-
setEditingKey(
|
|
1661
|
+
setEditingKey("");
|
|
1626
1662
|
}
|
|
1627
1663
|
})), pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination
|
|
1628
1664
|
// style={{padding: '0.75rem 1rem'}}
|
|
1629
1665
|
, _extends({}, pagination, {
|
|
1630
|
-
rootClassName:
|
|
1666
|
+
rootClassName: "pagination-template",
|
|
1631
1667
|
showSizeChanger: true,
|
|
1632
1668
|
responsive: true,
|
|
1633
|
-
size:
|
|
1669
|
+
size: "small",
|
|
1634
1670
|
total: pagination.total,
|
|
1635
1671
|
pageSize: pagination.onChange ? pagination?.pageSize : table.getState().pagination.pageSize,
|
|
1636
1672
|
pageSizeOptions: [20, 50, 100, 1000, 10000],
|
|
@@ -1643,11 +1679,11 @@ const TableContainerEdit = props => {
|
|
|
1643
1679
|
}
|
|
1644
1680
|
},
|
|
1645
1681
|
showTotal: (total, range) => `${numericFormatter((range[0] ?? 0).toString(), {
|
|
1646
|
-
thousandSeparator:
|
|
1682
|
+
thousandSeparator: "."
|
|
1647
1683
|
})}-${numericFormatter((range[1] ?? 0).toString(), {
|
|
1648
|
-
thousandSeparator:
|
|
1684
|
+
thousandSeparator: "."
|
|
1649
1685
|
})} / ${numericFormatter((total ?? 0).toString(), {
|
|
1650
|
-
thousandSeparator:
|
|
1686
|
+
thousandSeparator: "."
|
|
1651
1687
|
})} items`
|
|
1652
1688
|
}))));
|
|
1653
1689
|
};
|