es-grid-template 1.7.36 → 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 +248 -217
- 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/Grid.js +1 -1
- 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 +247 -216
- 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/Grid.js +1 -1
- 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]);
|
|
@@ -664,24 +674,21 @@ const TableContainerEdit = props => {
|
|
|
664
674
|
columnVirtualizer.measure();
|
|
665
675
|
});
|
|
666
676
|
}, [columnSizingState, columnVirtualizer]);
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
//
|
|
682
|
-
// );
|
|
683
|
-
// }
|
|
684
|
-
// }, [table.getTotalSize(), windowSize.innerWidth])
|
|
677
|
+
React.useEffect(() => {
|
|
678
|
+
if (!containerRef.current) {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
const containerWidth = containerRef.current.offsetWidth - 1;
|
|
682
|
+
const totalWidth = table.getTotalSize();
|
|
683
|
+
if (totalWidth && totalWidth < containerWidth) {
|
|
684
|
+
const factor = containerWidth / totalWidth;
|
|
685
|
+
table.setColumnSizing(table.getAllLeafColumns().reduce((acc, col) => {
|
|
686
|
+
acc[col.id] = (col.getSize() || col.columnDef.size || 150) * factor;
|
|
687
|
+
return acc;
|
|
688
|
+
}, {}));
|
|
689
|
+
}
|
|
690
|
+
}, [table.getTotalSize(), windowSize.innerWidth, table.getState().columnSizing]);
|
|
691
|
+
// }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
|
|
685
692
|
|
|
686
693
|
React.useEffect(() => {
|
|
687
694
|
const totalHeight = minHeight ?? height;
|
|
@@ -702,7 +709,7 @@ const TableContainerEdit = props => {
|
|
|
702
709
|
errors
|
|
703
710
|
}
|
|
704
711
|
} = useForm({
|
|
705
|
-
mode:
|
|
712
|
+
mode: "onChange",
|
|
706
713
|
resolver: validate ? yupResolver(validate) : undefined
|
|
707
714
|
});
|
|
708
715
|
const onSubmit = formData => {
|
|
@@ -722,7 +729,7 @@ const TableContainerEdit = props => {
|
|
|
722
729
|
triggerChangeData?.(rs);
|
|
723
730
|
}
|
|
724
731
|
} catch (errInfo) {
|
|
725
|
-
console.log(
|
|
732
|
+
console.log("Validate Failed:", errInfo);
|
|
726
733
|
}
|
|
727
734
|
};
|
|
728
735
|
const handleCellChange = args => {
|
|
@@ -737,7 +744,7 @@ const TableContainerEdit = props => {
|
|
|
737
744
|
indexRow,
|
|
738
745
|
key
|
|
739
746
|
} = args;
|
|
740
|
-
if (changeType ===
|
|
747
|
+
if (changeType === "blur") {
|
|
741
748
|
const handleChangeCallback = callbackData => {
|
|
742
749
|
const callbackRecord = callbackData;
|
|
743
750
|
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
@@ -750,7 +757,7 @@ const TableContainerEdit = props => {
|
|
|
750
757
|
onCellChange({
|
|
751
758
|
field,
|
|
752
759
|
indexCol,
|
|
753
|
-
type:
|
|
760
|
+
type: "onChange",
|
|
754
761
|
value: newState,
|
|
755
762
|
option,
|
|
756
763
|
indexRow,
|
|
@@ -764,7 +771,7 @@ const TableContainerEdit = props => {
|
|
|
764
771
|
onCellChange({
|
|
765
772
|
field,
|
|
766
773
|
indexCol,
|
|
767
|
-
type:
|
|
774
|
+
type: "onChange",
|
|
768
775
|
option,
|
|
769
776
|
value: newState,
|
|
770
777
|
indexRow,
|
|
@@ -778,7 +785,7 @@ const TableContainerEdit = props => {
|
|
|
778
785
|
}
|
|
779
786
|
}
|
|
780
787
|
}
|
|
781
|
-
if (prevState && newState && prevState !== newState && changeType ===
|
|
788
|
+
if (prevState && newState && prevState !== newState && changeType === "enter") {
|
|
782
789
|
onSubmit(record);
|
|
783
790
|
}
|
|
784
791
|
};
|
|
@@ -1026,7 +1033,29 @@ const TableContainerEdit = props => {
|
|
|
1026
1033
|
const filterData = flattenArray([...originData]);
|
|
1027
1034
|
const rs = filterData.filter(it => !rowsFocus.includes(it[rowKey]));
|
|
1028
1035
|
const newDaa = unFlattenData(rs);
|
|
1029
|
-
|
|
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
|
+
}
|
|
1030
1059
|
}
|
|
1031
1060
|
}, [originData, rowKey, rowsFocus, triggerChangeData]);
|
|
1032
1061
|
const handleDeleteAll = React.useCallback(() => {
|
|
@@ -1046,17 +1075,17 @@ const TableContainerEdit = props => {
|
|
|
1046
1075
|
const column = table.getVisibleFlatColumns().find(it => it.id === colId)?.columnDef.meta;
|
|
1047
1076
|
const columnIndex = table.getVisibleFlatColumns().findIndex(it => it.id === colId);
|
|
1048
1077
|
if (isEditable(column, row)) {
|
|
1049
|
-
updatedRow[colId] =
|
|
1078
|
+
updatedRow[colId] = "";
|
|
1050
1079
|
handleCellChange({
|
|
1051
1080
|
key: row[rowKey],
|
|
1052
1081
|
field: column.field ?? column.dataIndex,
|
|
1053
1082
|
record: updatedRow,
|
|
1054
1083
|
prevState: row[column.field],
|
|
1055
|
-
newState:
|
|
1056
|
-
option:
|
|
1084
|
+
newState: "",
|
|
1085
|
+
option: "",
|
|
1057
1086
|
indexCol: columnIndex,
|
|
1058
1087
|
indexRow: index,
|
|
1059
|
-
type:
|
|
1088
|
+
type: "blur"
|
|
1060
1089
|
});
|
|
1061
1090
|
}
|
|
1062
1091
|
}
|
|
@@ -1068,35 +1097,35 @@ const TableContainerEdit = props => {
|
|
|
1068
1097
|
};
|
|
1069
1098
|
const toolbarItemsBottom = React.useMemo(() => {
|
|
1070
1099
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
1071
|
-
return toolbarItems?.filter(it => it.position ===
|
|
1072
|
-
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") {
|
|
1073
1102
|
return {
|
|
1074
1103
|
...item,
|
|
1075
1104
|
template: () => {
|
|
1076
|
-
return /*#__PURE__*/React.createElement(Fragment, null, item.key ===
|
|
1105
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === "ADD" && /*#__PURE__*/React.createElement("div", {
|
|
1077
1106
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1078
1107
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1079
|
-
overlayClassName:
|
|
1080
|
-
trigger: [
|
|
1108
|
+
overlayClassName: "be-popup-container",
|
|
1109
|
+
trigger: ["click"],
|
|
1081
1110
|
style: {
|
|
1082
|
-
color:
|
|
1083
|
-
borderColor:
|
|
1111
|
+
color: "#28c76f",
|
|
1112
|
+
borderColor: "#28c76f"
|
|
1084
1113
|
},
|
|
1085
|
-
className:
|
|
1114
|
+
className: "toolbar-button toolbar-dropdown-button",
|
|
1086
1115
|
menu: {
|
|
1087
1116
|
items: itemsAdd,
|
|
1088
1117
|
onClick: e => handleAddMulti(item, Number(e.key))
|
|
1089
1118
|
}
|
|
1090
1119
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1091
1120
|
style: {
|
|
1092
|
-
color:
|
|
1121
|
+
color: "#28c76f"
|
|
1093
1122
|
},
|
|
1094
1123
|
onClick: () => handleAddMulti(item, 1)
|
|
1095
|
-
}, 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"))));
|
|
1096
1125
|
}
|
|
1097
1126
|
};
|
|
1098
1127
|
}
|
|
1099
|
-
if (item.key ===
|
|
1128
|
+
if (item.key === "DELETE") {
|
|
1100
1129
|
return {
|
|
1101
1130
|
...item,
|
|
1102
1131
|
template: () => {
|
|
@@ -1104,13 +1133,13 @@ const TableContainerEdit = props => {
|
|
|
1104
1133
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1105
1134
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1106
1135
|
style: {
|
|
1107
|
-
color:
|
|
1108
|
-
borderColor:
|
|
1136
|
+
color: "#eb4619",
|
|
1137
|
+
borderColor: "#eb4619"
|
|
1109
1138
|
},
|
|
1110
|
-
variant:
|
|
1139
|
+
variant: "outlined",
|
|
1111
1140
|
onClick: handleDeleteAll,
|
|
1112
1141
|
className: "d-flex toolbar-button"
|
|
1113
|
-
}, 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"));
|
|
1114
1143
|
}
|
|
1115
1144
|
};
|
|
1116
1145
|
}
|
|
@@ -1119,104 +1148,104 @@ const TableContainerEdit = props => {
|
|
|
1119
1148
|
};
|
|
1120
1149
|
});
|
|
1121
1150
|
}
|
|
1122
|
-
return toolbarItems?.filter(it => it.position ===
|
|
1123
|
-
if (item.key ===
|
|
1151
|
+
return toolbarItems?.filter(it => it.position === "Bottom" && it.visible !== false).map(item => {
|
|
1152
|
+
if (item.key === "ADD") {
|
|
1124
1153
|
return {
|
|
1125
1154
|
...item,
|
|
1126
1155
|
template: () => {
|
|
1127
|
-
return /*#__PURE__*/React.createElement(Fragment, null, item.key ===
|
|
1156
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === "ADD" && /*#__PURE__*/React.createElement("div", {
|
|
1128
1157
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1129
1158
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1130
|
-
overlayClassName:
|
|
1159
|
+
overlayClassName: "be-popup-container",
|
|
1131
1160
|
style: {
|
|
1132
|
-
color:
|
|
1133
|
-
borderColor:
|
|
1161
|
+
color: "#28c76f",
|
|
1162
|
+
borderColor: "#28c76f"
|
|
1134
1163
|
},
|
|
1135
|
-
className:
|
|
1164
|
+
className: "toolbar-button toolbar-dropdown-button",
|
|
1136
1165
|
menu: {
|
|
1137
1166
|
items: itemsAdd,
|
|
1138
1167
|
onClick: e => handleAddMulti(item, Number(e.key))
|
|
1139
1168
|
}
|
|
1140
1169
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1141
1170
|
style: {
|
|
1142
|
-
color:
|
|
1171
|
+
color: "#28c76f"
|
|
1143
1172
|
},
|
|
1144
1173
|
onClick: () => handleAddMulti(item, 1)
|
|
1145
|
-
}, 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"))));
|
|
1146
1175
|
}
|
|
1147
1176
|
};
|
|
1148
1177
|
}
|
|
1149
|
-
if (item.key ===
|
|
1178
|
+
if (item.key === "DUPLICATE") {
|
|
1150
1179
|
return {
|
|
1151
1180
|
...item,
|
|
1152
1181
|
template: () => {
|
|
1153
|
-
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", {
|
|
1154
1183
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1155
1184
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1156
1185
|
style: {
|
|
1157
|
-
color:
|
|
1158
|
-
borderColor:
|
|
1186
|
+
color: "#28c76f",
|
|
1187
|
+
borderColor: "#28c76f"
|
|
1159
1188
|
},
|
|
1160
|
-
variant:
|
|
1189
|
+
variant: "outlined",
|
|
1161
1190
|
onClick: handleDuplicate,
|
|
1162
1191
|
className: "d-flex toolbar-button"
|
|
1163
|
-
}, item.label ? t ? t(item.label) : item.label : t ? t(
|
|
1192
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t("Duplicate") : "Duplicate")));
|
|
1164
1193
|
}
|
|
1165
1194
|
};
|
|
1166
1195
|
}
|
|
1167
|
-
if (item.key ===
|
|
1196
|
+
if (item.key === "INSERT_BEFORE") {
|
|
1168
1197
|
return {
|
|
1169
1198
|
...item,
|
|
1170
1199
|
template: () => {
|
|
1171
1200
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1172
1201
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1173
1202
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1174
|
-
overlayClassName:
|
|
1203
|
+
overlayClassName: "be-popup-container",
|
|
1175
1204
|
style: {
|
|
1176
|
-
color:
|
|
1177
|
-
borderColor:
|
|
1205
|
+
color: "#28c76f",
|
|
1206
|
+
borderColor: "#28c76f"
|
|
1178
1207
|
},
|
|
1179
|
-
className:
|
|
1208
|
+
className: "toolbar-button toolbar-dropdown-button",
|
|
1180
1209
|
menu: {
|
|
1181
1210
|
items: itemsAdd,
|
|
1182
1211
|
onClick: e => handleInsertBefore(item, Number(e.key))
|
|
1183
1212
|
}
|
|
1184
1213
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1185
1214
|
style: {
|
|
1186
|
-
color:
|
|
1215
|
+
color: "#28c76f"
|
|
1187
1216
|
},
|
|
1188
1217
|
onClick: () => handleInsertBefore(item, 1)
|
|
1189
|
-
}, 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"))));
|
|
1190
1219
|
}
|
|
1191
1220
|
};
|
|
1192
1221
|
}
|
|
1193
|
-
if (item.key ===
|
|
1222
|
+
if (item.key === "INSERT_AFTER") {
|
|
1194
1223
|
return {
|
|
1195
1224
|
...item,
|
|
1196
1225
|
template: () => {
|
|
1197
1226
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1198
1227
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1199
1228
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1200
|
-
overlayClassName:
|
|
1229
|
+
overlayClassName: "be-popup-container",
|
|
1201
1230
|
style: {
|
|
1202
|
-
color:
|
|
1203
|
-
borderColor:
|
|
1231
|
+
color: "#28c76f",
|
|
1232
|
+
borderColor: "#28c76f"
|
|
1204
1233
|
},
|
|
1205
|
-
className:
|
|
1234
|
+
className: "toolbar-button toolbar-dropdown-button",
|
|
1206
1235
|
menu: {
|
|
1207
1236
|
items: itemsAdd,
|
|
1208
1237
|
onClick: e => handleInsertAfter(item, Number(e.key))
|
|
1209
1238
|
}
|
|
1210
1239
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1211
1240
|
style: {
|
|
1212
|
-
color:
|
|
1241
|
+
color: "#28c76f"
|
|
1213
1242
|
},
|
|
1214
1243
|
onClick: () => handleInsertAfter(item, 1)
|
|
1215
|
-
}, 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"))));
|
|
1216
1245
|
}
|
|
1217
1246
|
};
|
|
1218
1247
|
}
|
|
1219
|
-
if (item.key ===
|
|
1248
|
+
if (item.key === "INSERT_CHILDREN") {
|
|
1220
1249
|
return {
|
|
1221
1250
|
...item,
|
|
1222
1251
|
template: () => {
|
|
@@ -1224,17 +1253,17 @@ const TableContainerEdit = props => {
|
|
|
1224
1253
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1225
1254
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1226
1255
|
style: {
|
|
1227
|
-
color:
|
|
1228
|
-
borderColor:
|
|
1256
|
+
color: "#28c76f",
|
|
1257
|
+
borderColor: "#28c76f"
|
|
1229
1258
|
},
|
|
1230
|
-
variant:
|
|
1259
|
+
variant: "outlined",
|
|
1231
1260
|
onClick: () => handleInsertChild(item),
|
|
1232
1261
|
className: "d-flex toolbar-button"
|
|
1233
|
-
}, 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")));
|
|
1234
1263
|
}
|
|
1235
1264
|
};
|
|
1236
1265
|
}
|
|
1237
|
-
if (item.key ===
|
|
1266
|
+
if (item.key === "DELETE") {
|
|
1238
1267
|
return {
|
|
1239
1268
|
...item,
|
|
1240
1269
|
template: () => {
|
|
@@ -1242,17 +1271,17 @@ const TableContainerEdit = props => {
|
|
|
1242
1271
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1243
1272
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1244
1273
|
style: {
|
|
1245
|
-
color:
|
|
1246
|
-
borderColor:
|
|
1274
|
+
color: "#eb4619",
|
|
1275
|
+
borderColor: "#eb4619"
|
|
1247
1276
|
},
|
|
1248
|
-
variant:
|
|
1277
|
+
variant: "outlined",
|
|
1249
1278
|
onClick: handleDeleteAll,
|
|
1250
1279
|
className: "d-flex toolbar-button"
|
|
1251
|
-
}, 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"));
|
|
1252
1281
|
}
|
|
1253
1282
|
};
|
|
1254
1283
|
}
|
|
1255
|
-
if (item.key ===
|
|
1284
|
+
if (item.key === "DELETE_ROWS") {
|
|
1256
1285
|
return {
|
|
1257
1286
|
...item,
|
|
1258
1287
|
template: () => {
|
|
@@ -1260,13 +1289,13 @@ const TableContainerEdit = props => {
|
|
|
1260
1289
|
className: classNames(`be-toolbar-item`, item?.className)
|
|
1261
1290
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
1262
1291
|
style: {
|
|
1263
|
-
color:
|
|
1264
|
-
borderColor:
|
|
1292
|
+
color: "#eb4619",
|
|
1293
|
+
borderColor: "#eb4619"
|
|
1265
1294
|
},
|
|
1266
|
-
variant:
|
|
1295
|
+
variant: "outlined",
|
|
1267
1296
|
onClick: () => handleDeleteRows(item),
|
|
1268
1297
|
className: "d-flex toolbar-button"
|
|
1269
|
-
}, t ? `${t(
|
|
1298
|
+
}, t ? `${t("Delete")} ${rowsFocus.length} ${t("row")}` : `Delete ${rowsFocus.length} item`));
|
|
1270
1299
|
}
|
|
1271
1300
|
};
|
|
1272
1301
|
}
|
|
@@ -1283,20 +1312,20 @@ const TableContainerEdit = props => {
|
|
|
1283
1312
|
index
|
|
1284
1313
|
} = args;
|
|
1285
1314
|
const tmpData = [...dataSource];
|
|
1286
|
-
if (idCommand ===
|
|
1315
|
+
if (idCommand === "DELETE") {
|
|
1287
1316
|
// bật modal confirm
|
|
1288
1317
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
1289
1318
|
MySwal.fire({
|
|
1290
|
-
title: t ? t(
|
|
1291
|
-
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?",
|
|
1292
1321
|
// icon: 'warning',
|
|
1293
1322
|
allowOutsideClick: false,
|
|
1294
1323
|
showCancelButton: true,
|
|
1295
|
-
confirmButtonText: t ? t(
|
|
1296
|
-
cancelButtonText: t ? t(
|
|
1324
|
+
confirmButtonText: t ? t("Delete") : "Delete",
|
|
1325
|
+
cancelButtonText: t ? t("Cancel") : "Cancel",
|
|
1297
1326
|
customClass: {
|
|
1298
|
-
confirmButton:
|
|
1299
|
-
cancelButton:
|
|
1327
|
+
confirmButton: "be-button btn-primary",
|
|
1328
|
+
cancelButton: "be-button btn-danger ms-1"
|
|
1300
1329
|
},
|
|
1301
1330
|
buttonsStyling: false
|
|
1302
1331
|
}).then(async result => {
|
|
@@ -1398,10 +1427,9 @@ const TableContainerEdit = props => {
|
|
|
1398
1427
|
}
|
|
1399
1428
|
};
|
|
1400
1429
|
const triggerContextMenuClick = args => {
|
|
1401
|
-
if (args.item?.parentKey && args.item.parentKey ===
|
|
1402
|
-
if (args.item.key ===
|
|
1430
|
+
if (args.item?.parentKey && args.item.parentKey === "INSERT_BEFORE") {
|
|
1431
|
+
if (args.item.key === "INSERT_BEFORE_ADV") {
|
|
1403
1432
|
// mở Modal
|
|
1404
|
-
|
|
1405
1433
|
// setOpenModalAddRow((prev) => (
|
|
1406
1434
|
// {
|
|
1407
1435
|
// ...prev,
|
|
@@ -1414,9 +1442,8 @@ const TableContainerEdit = props => {
|
|
|
1414
1442
|
}
|
|
1415
1443
|
return;
|
|
1416
1444
|
}
|
|
1417
|
-
if (args.item?.parentKey && args.item.parentKey ===
|
|
1418
|
-
if (args.item.key ===
|
|
1419
|
-
|
|
1445
|
+
if (args.item?.parentKey && args.item.parentKey === "INSERT_AFTER") {
|
|
1446
|
+
if (args.item.key === "INSERT_AFTER_ADV") {
|
|
1420
1447
|
// setOpenModalAddRow((prev) => (
|
|
1421
1448
|
// {
|
|
1422
1449
|
// ...prev,
|
|
@@ -1429,15 +1456,15 @@ const TableContainerEdit = props => {
|
|
|
1429
1456
|
}
|
|
1430
1457
|
return;
|
|
1431
1458
|
}
|
|
1432
|
-
if (args.item.key ===
|
|
1459
|
+
if (args.item.key === "INSERT_CHILDREN") {
|
|
1433
1460
|
handleInsertChild(args.item);
|
|
1434
1461
|
return;
|
|
1435
1462
|
}
|
|
1436
|
-
if (args.item.key ===
|
|
1463
|
+
if (args.item.key === "DELETE_ROWS") {
|
|
1437
1464
|
handleDeleteRows(args.item);
|
|
1438
1465
|
return;
|
|
1439
1466
|
}
|
|
1440
|
-
if (args.item.key ===
|
|
1467
|
+
if (args.item.key === "DELETE_CONTENT") {
|
|
1441
1468
|
handleDeleteContent();
|
|
1442
1469
|
return;
|
|
1443
1470
|
}
|
|
@@ -1445,6 +1472,7 @@ const TableContainerEdit = props => {
|
|
|
1445
1472
|
};
|
|
1446
1473
|
const handleCellClick = (rowNumber, record, column, rowId, cellValue) => {
|
|
1447
1474
|
const cellClickCallback = newOptions => {
|
|
1475
|
+
console.log("newOptions", newOptions);
|
|
1448
1476
|
if (newOptions) {
|
|
1449
1477
|
const newElem = {
|
|
1450
1478
|
...column,
|
|
@@ -1455,8 +1483,8 @@ const TableContainerEdit = props => {
|
|
|
1455
1483
|
options: newOptions
|
|
1456
1484
|
}
|
|
1457
1485
|
};
|
|
1458
|
-
const rrr = updateArrayByKey([...
|
|
1459
|
-
triggerChangeColumns?.(rrr,
|
|
1486
|
+
const rrr = updateArrayByKey([...propsColumns], newElem, "field");
|
|
1487
|
+
triggerChangeColumns?.(rrr, [], "cellClick");
|
|
1460
1488
|
}
|
|
1461
1489
|
};
|
|
1462
1490
|
if (onCellClick) {
|
|
@@ -1471,55 +1499,55 @@ const TableContainerEdit = props => {
|
|
|
1471
1499
|
}
|
|
1472
1500
|
};
|
|
1473
1501
|
return /*#__PURE__*/React.createElement("div", {
|
|
1474
|
-
ref: containerRef
|
|
1475
|
-
id
|
|
1502
|
+
ref: containerRef
|
|
1503
|
+
// id={id}
|
|
1476
1504
|
}, (showToolbar !== false || fullScreen !== false || showColumnChoose) && /*#__PURE__*/React.createElement("div", {
|
|
1477
1505
|
ref: topToolbarRef,
|
|
1478
1506
|
className: classNames(`${prefix}-grid-top-toolbar`, {})
|
|
1479
1507
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1480
1508
|
style: {
|
|
1481
|
-
display:
|
|
1482
|
-
justifyContent:
|
|
1483
|
-
alignItems:
|
|
1484
|
-
gap:
|
|
1509
|
+
display: "flex",
|
|
1510
|
+
justifyContent: "space-between",
|
|
1511
|
+
alignItems: "center",
|
|
1512
|
+
gap: ".75rem"
|
|
1485
1513
|
}
|
|
1486
1514
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1487
1515
|
style: {
|
|
1488
1516
|
flex: 1,
|
|
1489
|
-
overflow:
|
|
1517
|
+
overflow: "hidden"
|
|
1490
1518
|
}
|
|
1491
1519
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
1492
|
-
items: (toolbarItems ?? []).filter(it => it.position !==
|
|
1493
|
-
mode:
|
|
1520
|
+
items: (toolbarItems ?? []).filter(it => it.position !== "Bottom"),
|
|
1521
|
+
mode: "scroll"
|
|
1494
1522
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1495
1523
|
style: {
|
|
1496
|
-
display:
|
|
1497
|
-
justifyContent:
|
|
1498
|
-
alignItems:
|
|
1499
|
-
gap:
|
|
1524
|
+
display: "flex",
|
|
1525
|
+
justifyContent: "space-between",
|
|
1526
|
+
alignItems: "center",
|
|
1527
|
+
gap: ".75rem"
|
|
1500
1528
|
}
|
|
1501
|
-
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] ===
|
|
1529
|
+
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === "topRight" && /*#__PURE__*/React.createElement(Pagination, _extends({
|
|
1502
1530
|
showSizeChanger: true,
|
|
1503
1531
|
responsive: true,
|
|
1504
|
-
size:
|
|
1505
|
-
rootClassName:
|
|
1532
|
+
size: "small",
|
|
1533
|
+
rootClassName: "top-pagination",
|
|
1506
1534
|
showTotal: (total, range) =>
|
|
1507
1535
|
// @ts-ignore
|
|
1508
|
-
`${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ??
|
|
1509
|
-
}, 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, {
|
|
1510
1538
|
fontSize: 16,
|
|
1511
1539
|
onClick: () => {
|
|
1512
1540
|
setIsFullScreen(!isFullScreen);
|
|
1513
1541
|
},
|
|
1514
1542
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
1515
|
-
"data-tooltip-content": t ? t(
|
|
1543
|
+
"data-tooltip-content": t ? t("Minimized") : "Minimized"
|
|
1516
1544
|
}) : /*#__PURE__*/React.createElement(Maximize, {
|
|
1517
1545
|
fontSize: 16,
|
|
1518
1546
|
onClick: () => {
|
|
1519
1547
|
setIsFullScreen(!isFullScreen);
|
|
1520
1548
|
},
|
|
1521
1549
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
1522
|
-
"data-tooltip-content": t ? t(
|
|
1550
|
+
"data-tooltip-content": t ? t("Full screen") : "Full screen"
|
|
1523
1551
|
})), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
1524
1552
|
columns: columns,
|
|
1525
1553
|
originColumns: propsColumns,
|
|
@@ -1570,7 +1598,7 @@ const TableContainerEdit = props => {
|
|
|
1570
1598
|
setIsPasting,
|
|
1571
1599
|
setEndPasteCell,
|
|
1572
1600
|
setStartPasteCell,
|
|
1573
|
-
//
|
|
1601
|
+
//
|
|
1574
1602
|
control,
|
|
1575
1603
|
// trigger,
|
|
1576
1604
|
errors,
|
|
@@ -1583,7 +1611,8 @@ const TableContainerEdit = props => {
|
|
|
1583
1611
|
handleAddMulti,
|
|
1584
1612
|
dataErrors,
|
|
1585
1613
|
windowSize,
|
|
1586
|
-
handleCellClick
|
|
1614
|
+
handleCellClick,
|
|
1615
|
+
isFullScreen
|
|
1587
1616
|
}
|
|
1588
1617
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
1589
1618
|
contextMenuItems: contextMenuItems,
|
|
@@ -1597,7 +1626,9 @@ const TableContainerEdit = props => {
|
|
|
1597
1626
|
contextMenuClick: triggerContextMenuClick,
|
|
1598
1627
|
contextMenuHidden: contextMenuHidden,
|
|
1599
1628
|
contextMenuOpen: contextMenuOpen,
|
|
1600
|
-
editAble: editAble
|
|
1629
|
+
editAble: editAble
|
|
1630
|
+
// editAble={false}
|
|
1631
|
+
,
|
|
1601
1632
|
showEmptyText: showEmptyText,
|
|
1602
1633
|
summary: summary,
|
|
1603
1634
|
dataSource: dataSource,
|
|
@@ -1612,30 +1643,30 @@ const TableContainerEdit = props => {
|
|
|
1612
1643
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
1613
1644
|
ref: bottomToolbarRef
|
|
1614
1645
|
}, toolbarItemsBottom && toolbarItemsBottom.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
1615
|
-
className:
|
|
1646
|
+
className: "ui-rc-toolbar-bottom"
|
|
1616
1647
|
// style={{ border: '0 1px 1px 1px solid #e0e0e0' }}
|
|
1617
1648
|
,
|
|
1618
1649
|
style: {
|
|
1619
|
-
borderBottom:
|
|
1620
|
-
borderRight:
|
|
1621
|
-
borderLeft:
|
|
1650
|
+
borderBottom: "1px solid #e0e0e0",
|
|
1651
|
+
borderRight: "1px solid #e0e0e0",
|
|
1652
|
+
borderLeft: "1px solid #e0e0e0"
|
|
1622
1653
|
}
|
|
1623
1654
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
1624
1655
|
style: {
|
|
1625
|
-
width:
|
|
1656
|
+
width: "100%"
|
|
1626
1657
|
},
|
|
1627
1658
|
items: toolbarItemsBottom ?? [],
|
|
1628
|
-
mode:
|
|
1659
|
+
mode: "scroll",
|
|
1629
1660
|
onClick: ({}) => {
|
|
1630
|
-
setEditingKey(
|
|
1661
|
+
setEditingKey("");
|
|
1631
1662
|
}
|
|
1632
1663
|
})), pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination
|
|
1633
1664
|
// style={{padding: '0.75rem 1rem'}}
|
|
1634
1665
|
, _extends({}, pagination, {
|
|
1635
|
-
rootClassName:
|
|
1666
|
+
rootClassName: "pagination-template",
|
|
1636
1667
|
showSizeChanger: true,
|
|
1637
1668
|
responsive: true,
|
|
1638
|
-
size:
|
|
1669
|
+
size: "small",
|
|
1639
1670
|
total: pagination.total,
|
|
1640
1671
|
pageSize: pagination.onChange ? pagination?.pageSize : table.getState().pagination.pageSize,
|
|
1641
1672
|
pageSizeOptions: [20, 50, 100, 1000, 10000],
|
|
@@ -1648,11 +1679,11 @@ const TableContainerEdit = props => {
|
|
|
1648
1679
|
}
|
|
1649
1680
|
},
|
|
1650
1681
|
showTotal: (total, range) => `${numericFormatter((range[0] ?? 0).toString(), {
|
|
1651
|
-
thousandSeparator:
|
|
1682
|
+
thousandSeparator: "."
|
|
1652
1683
|
})}-${numericFormatter((range[1] ?? 0).toString(), {
|
|
1653
|
-
thousandSeparator:
|
|
1684
|
+
thousandSeparator: "."
|
|
1654
1685
|
})} / ${numericFormatter((total ?? 0).toString(), {
|
|
1655
|
-
thousandSeparator:
|
|
1686
|
+
thousandSeparator: "."
|
|
1656
1687
|
})} items`
|
|
1657
1688
|
}))));
|
|
1658
1689
|
};
|