es-grid-template 1.9.59 → 1.9.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/ali-table/ColumnsConfig.d.ts +14 -0
- package/es/ali-table/ColumnsConfig.js +303 -0
- package/es/ali-table/Grid.js +110 -31
- package/es/ali-table/InternalTable.js +1208 -18
- package/es/ali-table/assets/WebsiteBaseTable.js +7 -3
- package/es/ali-table/base-table/calculations.js +23 -22
- package/es/ali-table/base-table/cell/EditCell.d.ts +27 -0
- package/es/ali-table/base-table/cell/EditCell.js +1252 -0
- package/es/ali-table/base-table/cell/HeaderEditCell.d.ts +28 -0
- package/es/ali-table/base-table/cell/HeaderEditCell.js +1252 -0
- package/es/ali-table/base-table/header.js +3 -1
- package/es/ali-table/base-table/html-table.d.ts +4 -4
- package/es/ali-table/base-table/html-table.js +5 -289
- package/es/ali-table/base-table/styles.d.ts +2 -1
- package/es/ali-table/base-table/styles.js +8 -8
- package/es/ali-table/base-table/styles.scss +0 -34
- package/es/ali-table/base-table/table.d.ts +13 -10
- package/es/ali-table/base-table/table.js +23 -45
- package/es/ali-table/base-table/utils.d.ts +4 -7
- package/es/ali-table/base-table/utils.js +5 -8
- package/es/ali-table/interfaces.d.ts +10 -5
- package/es/ali-table/pipeline/features/columnCustom.d.ts +15 -0
- package/es/ali-table/pipeline/features/columnCustom.js +913 -36
- package/es/ali-table/t-body/RenderRow.d.ts +41 -0
- package/es/ali-table/{base-table/html-table-new.js → t-body/RenderRow.js} +15 -161
- package/es/ali-table/utils/constants.d.ts +16 -0
- package/es/ali-table/utils/constants.js +21 -0
- package/es/ali-table/utils/utility.d.ts +12 -0
- package/es/ali-table/utils/utility.js +255 -0
- package/es/grid-component/hooks/constant.js +1 -1
- package/es/grid-component/type.d.ts +14 -0
- package/es/group-component/hook/utils.d.ts +6 -3
- package/es/table-component/ColumnsConfig.d.ts +0 -4
- package/es/table-component/ColumnsConfig.js +1 -1
- package/es/table-component/TableContainer.js +0 -3
- package/es/table-component/TableContainerEdit.js +0 -3
- package/es/table-component/body/TableBodyCell.js +8 -0
- package/es/table-component/hook/utils.d.ts +22 -0
- package/es/table-component/hook/utils.js +204 -5
- package/lib/ali-table/ColumnsConfig.d.ts +14 -0
- package/lib/ali-table/ColumnsConfig.js +313 -0
- package/lib/ali-table/Grid.js +109 -30
- package/lib/ali-table/InternalTable.js +1203 -15
- package/lib/ali-table/assets/WebsiteBaseTable.js +7 -3
- package/lib/ali-table/base-table/calculations.js +23 -22
- package/lib/ali-table/base-table/cell/EditCell.d.ts +27 -0
- package/lib/ali-table/base-table/cell/EditCell.js +1259 -0
- package/lib/ali-table/base-table/cell/HeaderEditCell.d.ts +28 -0
- package/lib/ali-table/base-table/cell/HeaderEditCell.js +1259 -0
- package/lib/ali-table/base-table/header.js +3 -1
- package/lib/ali-table/base-table/html-table.d.ts +4 -4
- package/lib/ali-table/base-table/html-table.js +7 -291
- package/lib/ali-table/base-table/styles.d.ts +2 -1
- package/lib/ali-table/base-table/styles.js +8 -8
- package/lib/ali-table/base-table/styles.scss +0 -34
- package/lib/ali-table/base-table/table.d.ts +13 -10
- package/lib/ali-table/base-table/table.js +22 -42
- package/lib/ali-table/base-table/utils.d.ts +4 -7
- package/lib/ali-table/base-table/utils.js +5 -8
- package/lib/ali-table/interfaces.d.ts +10 -5
- package/lib/ali-table/pipeline/features/columnCustom.d.ts +15 -0
- package/lib/ali-table/pipeline/features/columnCustom.js +926 -53
- package/lib/ali-table/t-body/RenderRow.d.ts +41 -0
- package/lib/ali-table/{base-table/html-table-new.js → t-body/RenderRow.js} +14 -160
- package/lib/ali-table/utils/constants.d.ts +16 -0
- package/lib/ali-table/utils/constants.js +27 -0
- package/lib/ali-table/utils/utility.d.ts +12 -0
- package/lib/ali-table/utils/utility.js +266 -0
- package/lib/grid-component/hooks/constant.js +1 -1
- package/lib/grid-component/type.d.ts +14 -0
- package/lib/group-component/hook/utils.d.ts +3 -0
- package/lib/table-component/ColumnsConfig.d.ts +0 -4
- package/lib/table-component/ColumnsConfig.js +1 -1
- package/lib/table-component/TableContainer.js +0 -3
- package/lib/table-component/TableContainerEdit.js +0 -3
- package/lib/table-component/body/TableBodyCell.js +8 -0
- package/lib/table-component/hook/utils.d.ts +22 -0
- package/lib/table-component/hook/utils.js +221 -4
- package/package.json +1 -1
- package/es/ali-table/base-table/html-table-default.d.ts +0 -20
- package/es/ali-table/base-table/html-table-default.js +0 -224
- package/es/ali-table/base-table/html-table-new.d.ts +0 -20
- package/lib/ali-table/base-table/html-table-default.d.ts +0 -20
- package/lib/ali-table/base-table/html-table-default.js +0 -231
- package/lib/ali-table/base-table/html-table-new.d.ts +0 -20
|
@@ -3,12 +3,14 @@ import { features, useTablePipeline } from "./pipeline";
|
|
|
3
3
|
import * as fusion from '@alifd/next';
|
|
4
4
|
import { useLocale } from "rc-master-ui/es/locale";
|
|
5
5
|
import { faker } from "@faker-js/faker";
|
|
6
|
-
import React from "react";
|
|
6
|
+
import React, { Fragment, useRef } from "react";
|
|
7
7
|
import "./base-table/styles.scss";
|
|
8
|
-
import { addRowIdArray,
|
|
8
|
+
import { addRowIdArray, findItemByKey, flatColumns2, flattenArray, flattenData,
|
|
9
|
+
// getAllRowKey,
|
|
10
|
+
getDefaultValue, getRowIdsBetween3, getRowIndexMap,
|
|
9
11
|
// getInvisibleColumns,
|
|
10
|
-
getVisibleFields, groupArrayByColumns, isTreeArray, revertConvertFilters, sortByType, sumFields } from "../table-component/hook/utils";
|
|
11
|
-
import { CustomProvider, ConfigProvider, Modal } from 'rc-master-ui';
|
|
12
|
+
getVisibleFields, groupArrayByColumns, isTreeArray, newGuid, revertConvertFilters, sortByType, sumFields, unFlattenData, updateArrayByKey, updateOrInsert } from "../table-component/hook/utils";
|
|
13
|
+
import { CustomProvider, ConfigProvider, Modal, Button, Dropdown } from 'rc-master-ui';
|
|
12
14
|
import { getLocale, getLocales } from "../locale/useLocale";
|
|
13
15
|
import { TableContext } from "./useContext";
|
|
14
16
|
import Grid from "./Grid";
|
|
@@ -16,6 +18,15 @@ import { getParentKeysLarge, getRowsByKeysKeepTreeOrder } from "./utils/selected
|
|
|
16
18
|
import { DndContext, KeyboardSensor, MouseSensor, TouchSensor, closestCenter, useSensor, useSensors } from '@dnd-kit/core';
|
|
17
19
|
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
|
18
20
|
import { arrayMove } from "@dnd-kit/sortable";
|
|
21
|
+
import { useForm } from "react-hook-form";
|
|
22
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
23
|
+
import { filterDataByColumns1 } from "./utils/utility";
|
|
24
|
+
import { stateKeyEndCell, stateKeyFocusedCell, stateKeyIsEditing, stateKeyStartCell } from "./utils/constants";
|
|
25
|
+
import classNames from "classnames";
|
|
26
|
+
import { getToolbarTemplate } from "../grid-component/hooks";
|
|
27
|
+
import withReactContent from "sweetalert2-react-content";
|
|
28
|
+
import Swal from "sweetalert2";
|
|
29
|
+
const MySwal = withReactContent(Swal);
|
|
19
30
|
const InternalTable = props => {
|
|
20
31
|
const {
|
|
21
32
|
t,
|
|
@@ -45,13 +56,27 @@ const InternalTable = props => {
|
|
|
45
56
|
summary,
|
|
46
57
|
useVirtual,
|
|
47
58
|
rowDnd,
|
|
59
|
+
// Edit
|
|
60
|
+
editAble,
|
|
61
|
+
headerEditAble,
|
|
62
|
+
rowEditable,
|
|
63
|
+
validate,
|
|
64
|
+
onCellPaste,
|
|
65
|
+
onDataChange,
|
|
66
|
+
onCellChange,
|
|
67
|
+
onHeaderCellChange,
|
|
68
|
+
toolbarItems,
|
|
69
|
+
defaultValue,
|
|
70
|
+
commandSettings,
|
|
48
71
|
...rest
|
|
49
72
|
} = props;
|
|
73
|
+
const tableRef = useRef(null);
|
|
50
74
|
const prefix = 'ui-rc';
|
|
51
75
|
const rowKey = 'rowId';
|
|
76
|
+
const childrenColumnName = 'children';
|
|
52
77
|
const childrenKey = 'children';
|
|
53
78
|
const [tableLocal] = useLocale('Table');
|
|
54
|
-
const
|
|
79
|
+
const tableId = React.useMemo(() => {
|
|
55
80
|
return faker.string.alpha(20);
|
|
56
81
|
}, []);
|
|
57
82
|
const language = React.useMemo(() => {
|
|
@@ -100,7 +125,10 @@ const InternalTable = props => {
|
|
|
100
125
|
if (shouldSkip) {
|
|
101
126
|
return convertData;
|
|
102
127
|
}
|
|
103
|
-
|
|
128
|
+
|
|
129
|
+
// const rs = filterDataByColumns(convertData, onFilter ? undefined : (filterState ?? defaultFilter), onSorter ? undefined : (sortState ?? defaultSorter), [], ignoreAccents)
|
|
130
|
+
const rss = filterDataByColumns1(convertData, onFilter ? undefined : filterState ?? defaultFilter, onSorter ? undefined : sortState ?? defaultSorter, [], ignoreAccents);
|
|
131
|
+
return rss;
|
|
104
132
|
}, [convertData, filterState, ignoreAccents, sortState, onFilter, onSorter, defaultFilter, defaultSorter]);
|
|
105
133
|
const footerData = React.useMemo(() => {
|
|
106
134
|
if (!summary) {
|
|
@@ -135,6 +163,208 @@ const InternalTable = props => {
|
|
|
135
163
|
const columnVisibility = React.useMemo(() => {
|
|
136
164
|
return getVisibleFields(columns);
|
|
137
165
|
}, [columns]);
|
|
166
|
+
const {
|
|
167
|
+
control,
|
|
168
|
+
handleSubmit,
|
|
169
|
+
setValue,
|
|
170
|
+
getValues,
|
|
171
|
+
reset,
|
|
172
|
+
formState: {
|
|
173
|
+
errors
|
|
174
|
+
}
|
|
175
|
+
} = useForm({
|
|
176
|
+
mode: 'onChange',
|
|
177
|
+
resolver: validate ? yupResolver(validate) : undefined
|
|
178
|
+
});
|
|
179
|
+
const itemsAdd = React.useMemo(() => {
|
|
180
|
+
return [{
|
|
181
|
+
key: '10',
|
|
182
|
+
label: `10 ${t ? t('rows') : 'rows'}`
|
|
183
|
+
}, {
|
|
184
|
+
key: '50',
|
|
185
|
+
label: `50 ${t ? t('rows') : 'rows'}`
|
|
186
|
+
}, {
|
|
187
|
+
key: '100',
|
|
188
|
+
label: `100 ${t ? t('rows') : 'rows'}`
|
|
189
|
+
}];
|
|
190
|
+
}, [t]);
|
|
191
|
+
const triggerChangeData = React.useCallback((newData, args) => {
|
|
192
|
+
onDataChange?.(newData, args);
|
|
193
|
+
}, [onDataChange]);
|
|
194
|
+
const triggerPaste = React.useCallback((pastedRows, pastedColumnsArray, newData, copyRows) => {
|
|
195
|
+
const handlePasteCallback = callbackData => {
|
|
196
|
+
const rsFilterData = updateOrInsert(flattenArray([...convertData]), flattenArray([...callbackData]));
|
|
197
|
+
const rs = unFlattenData(rsFilterData);
|
|
198
|
+
triggerChangeData(rs, {
|
|
199
|
+
type: 'OnPaste'
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
if (onCellPaste && onCellPaste.onPasted) {
|
|
203
|
+
if (onCellPaste.onPasted.length > 1) {
|
|
204
|
+
// có callback
|
|
205
|
+
onCellPaste.onPasted({
|
|
206
|
+
pasteData: pastedRows,
|
|
207
|
+
copyRows,
|
|
208
|
+
type: 'onPaste',
|
|
209
|
+
data: convertData,
|
|
210
|
+
pastedColumns: pastedColumnsArray
|
|
211
|
+
}, handlePasteCallback);
|
|
212
|
+
} else {
|
|
213
|
+
// không có callback
|
|
214
|
+
onCellPaste.onPasted({
|
|
215
|
+
pasteData: pastedRows,
|
|
216
|
+
type: 'onPaste',
|
|
217
|
+
copyRows,
|
|
218
|
+
data: convertData,
|
|
219
|
+
pastedColumns: pastedColumnsArray
|
|
220
|
+
}, handlePasteCallback);
|
|
221
|
+
triggerChangeData(newData, {
|
|
222
|
+
type: 'OnPaste'
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
triggerChangeData(newData, {
|
|
227
|
+
type: 'OnPaste'
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}, [onCellPaste, convertData, triggerChangeData]);
|
|
231
|
+
const onSubmit = formData => {
|
|
232
|
+
try {
|
|
233
|
+
// const record = (await form.validateFields()) as RecordType;
|
|
234
|
+
const row = {
|
|
235
|
+
...formData
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// const newData = [...dataSource]
|
|
239
|
+
const newData = [...convertData];
|
|
240
|
+
const index = flattenData(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
|
|
241
|
+
const rs = updateArrayByKey(newData, row, rowKey);
|
|
242
|
+
if (index > -1) {
|
|
243
|
+
triggerChangeData?.(rs, {
|
|
244
|
+
type: 'CellChange'
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
} catch (errInfo) {
|
|
248
|
+
console.log('Validate Failed:', errInfo);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const handleCellChange = args => {
|
|
252
|
+
const {
|
|
253
|
+
record,
|
|
254
|
+
type: changeType,
|
|
255
|
+
newState,
|
|
256
|
+
prevState,
|
|
257
|
+
option,
|
|
258
|
+
field,
|
|
259
|
+
indexCol,
|
|
260
|
+
indexRow,
|
|
261
|
+
key
|
|
262
|
+
} = args;
|
|
263
|
+
if (changeType === 'blur') {
|
|
264
|
+
const handleChangeCallback = callbackData => {
|
|
265
|
+
const callbackRecord = callbackData;
|
|
266
|
+
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
267
|
+
setValue(name, value);
|
|
268
|
+
});
|
|
269
|
+
onSubmit(callbackRecord);
|
|
270
|
+
};
|
|
271
|
+
if (onCellChange) {
|
|
272
|
+
if (onCellChange.length > 1) {
|
|
273
|
+
onCellChange({
|
|
274
|
+
field,
|
|
275
|
+
indexCol,
|
|
276
|
+
type: 'onChange',
|
|
277
|
+
value: newState,
|
|
278
|
+
option,
|
|
279
|
+
indexRow,
|
|
280
|
+
rowData: record,
|
|
281
|
+
rowId: key,
|
|
282
|
+
// rowsData: [...dataSource],
|
|
283
|
+
rowsData: [...convertData],
|
|
284
|
+
sumValue: []
|
|
285
|
+
}, handleChangeCallback);
|
|
286
|
+
} else {
|
|
287
|
+
onCellChange({
|
|
288
|
+
field,
|
|
289
|
+
indexCol,
|
|
290
|
+
type: 'onChange',
|
|
291
|
+
option,
|
|
292
|
+
value: newState,
|
|
293
|
+
indexRow,
|
|
294
|
+
rowData: record,
|
|
295
|
+
rowId: key,
|
|
296
|
+
// rowsData: [...dataSource],
|
|
297
|
+
rowsData: [...convertData],
|
|
298
|
+
sumValue: []
|
|
299
|
+
}, handleChangeCallback);
|
|
300
|
+
onSubmit(record);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (!onCellChange) {
|
|
304
|
+
onSubmit(record);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
308
|
+
onSubmit(record);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
const handleHeaderCellChange = args => {
|
|
312
|
+
const {
|
|
313
|
+
record,
|
|
314
|
+
type: changeType,
|
|
315
|
+
newState,
|
|
316
|
+
prevState,
|
|
317
|
+
option,
|
|
318
|
+
field,
|
|
319
|
+
indexCol,
|
|
320
|
+
indexRow,
|
|
321
|
+
key
|
|
322
|
+
} = args;
|
|
323
|
+
if (changeType === 'blur') {
|
|
324
|
+
const handleChangeCallback = callbackData => {
|
|
325
|
+
const callbackRecord = callbackData;
|
|
326
|
+
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
327
|
+
setValue(name, value);
|
|
328
|
+
});
|
|
329
|
+
onSubmit(callbackRecord);
|
|
330
|
+
};
|
|
331
|
+
if (onHeaderCellChange) {
|
|
332
|
+
if (onHeaderCellChange.length > 1) {
|
|
333
|
+
onHeaderCellChange({
|
|
334
|
+
field,
|
|
335
|
+
indexCol,
|
|
336
|
+
type: 'onChange',
|
|
337
|
+
value: newState,
|
|
338
|
+
option,
|
|
339
|
+
indexRow,
|
|
340
|
+
rowData: record,
|
|
341
|
+
rowId: key,
|
|
342
|
+
// rowsData: [...dataSource],
|
|
343
|
+
rowsData: [...convertData],
|
|
344
|
+
sumValue: []
|
|
345
|
+
}, handleChangeCallback);
|
|
346
|
+
} else {
|
|
347
|
+
onHeaderCellChange({
|
|
348
|
+
field,
|
|
349
|
+
indexCol,
|
|
350
|
+
type: 'onChange',
|
|
351
|
+
option,
|
|
352
|
+
value: newState,
|
|
353
|
+
indexRow,
|
|
354
|
+
rowData: record,
|
|
355
|
+
rowId: key,
|
|
356
|
+
rowsData: [...convertData],
|
|
357
|
+
sumValue: []
|
|
358
|
+
}, handleChangeCallback);
|
|
359
|
+
|
|
360
|
+
// onSubmit(record)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
365
|
+
onSubmit(record);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
138
368
|
const pipeline = useTablePipeline({
|
|
139
369
|
components: fusion
|
|
140
370
|
}).input({
|
|
@@ -146,8 +376,6 @@ const InternalTable = props => {
|
|
|
146
376
|
.use(features.hiddenColumns({
|
|
147
377
|
columns,
|
|
148
378
|
visibleKeys: visibleKeys ?? columnVisibility
|
|
149
|
-
// visibleKeys: ['name']
|
|
150
|
-
// visibleKeys
|
|
151
379
|
})).use(features.treeSelect({
|
|
152
380
|
tree: mergedData,
|
|
153
381
|
value: selectionSettings?.selectedRowKeys,
|
|
@@ -188,11 +416,12 @@ const InternalTable = props => {
|
|
|
188
416
|
defaultOpenKeys: expandAllKeys ?? expandable?.defaultExpandedRowKeys,
|
|
189
417
|
isTreeArray: !!isDataTree
|
|
190
418
|
})).use(features.columnCustom({
|
|
191
|
-
|
|
419
|
+
tableRef,
|
|
420
|
+
id: tableId,
|
|
192
421
|
t,
|
|
193
422
|
columns,
|
|
194
423
|
mode: sortMultiple !== false ? 'multiple' : 'single',
|
|
195
|
-
dataSource:
|
|
424
|
+
dataSource: convertData,
|
|
196
425
|
columnResizeMode: 'onChange',
|
|
197
426
|
disableUserSelectWhenResizing: true,
|
|
198
427
|
allowFiltering,
|
|
@@ -223,7 +452,20 @@ const InternalTable = props => {
|
|
|
223
452
|
} else {
|
|
224
453
|
setSortState(val);
|
|
225
454
|
}
|
|
226
|
-
}
|
|
455
|
+
},
|
|
456
|
+
// Edit
|
|
457
|
+
editAble,
|
|
458
|
+
rowEditable,
|
|
459
|
+
setValue,
|
|
460
|
+
reset,
|
|
461
|
+
control,
|
|
462
|
+
getValues,
|
|
463
|
+
errors,
|
|
464
|
+
handleSubmit,
|
|
465
|
+
onSubmit,
|
|
466
|
+
triggerPaste,
|
|
467
|
+
handleCellChange,
|
|
468
|
+
handleHeaderCellChange
|
|
227
469
|
})).use(features.paginationFeature({
|
|
228
470
|
pagination
|
|
229
471
|
}));
|
|
@@ -233,6 +475,88 @@ const InternalTable = props => {
|
|
|
233
475
|
// }
|
|
234
476
|
|
|
235
477
|
// reorder rows after drag & drop
|
|
478
|
+
|
|
479
|
+
React.useEffect(() => {
|
|
480
|
+
const handleClickOutside = event => {
|
|
481
|
+
if (!editAble) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const isEditting = pipeline.getStateAtKey(stateKeyIsEditing);
|
|
485
|
+
const startCell = pipeline.getStateAtKey(stateKeyStartCell);
|
|
486
|
+
const endCell = pipeline.getStateAtKey(stateKeyEndCell);
|
|
487
|
+
const focusedCell = pipeline.getStateAtKey(stateKeyFocusedCell);
|
|
488
|
+
const element = event.target;
|
|
489
|
+
const container = document.querySelector(".be-popup-container");
|
|
490
|
+
const containerContextMenu = document.querySelector(".popup-context-menu");
|
|
491
|
+
|
|
492
|
+
// const tableBody = document.querySelector(`#${tableId} .ui-rc-grid-tbody`)
|
|
493
|
+
const tableBody = tableRef?.current?.domHelper?.tableBody;
|
|
494
|
+
// const tableHeader = tableRef?.current?.domHelper?.tableHeader
|
|
495
|
+
|
|
496
|
+
const itemContainer = document.querySelector(`#${tableId} .ui-rc-toolbar-selection-overflow-item`);
|
|
497
|
+
const isInsideContainer = element.closest(".be-popup-container") && container;
|
|
498
|
+
const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
|
|
499
|
+
const isInsideToolbar = element.closest(`.ui-rc-toolbar-selection-overflow-item`) && itemContainer;
|
|
500
|
+
|
|
501
|
+
// const isInsideHeader = itemHeader && itemHeader.contains(element as Node)
|
|
502
|
+
|
|
503
|
+
if (headerEditAble) {
|
|
504
|
+
const items = document.querySelectorAll(`#${tableId} .ui-rc-grid-table-header .header-cell-editable`);
|
|
505
|
+
const hasElement = Array.from(items).some(item => item.contains(element));
|
|
506
|
+
if (hasElement) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (isInsideContainer || isInsideToolbar || isInsideContainerContext || element.id === tableId) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// trường hợp đặc biệt select table clear icon
|
|
515
|
+
const path = '<path d="M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"></path>';
|
|
516
|
+
const expectedD = path.match(/d="([^"]*)"/)?.[1];
|
|
517
|
+
const clickedPath = element.closest('path') ?? element.closest('svg')?.querySelector('path');
|
|
518
|
+
if (clickedPath) {
|
|
519
|
+
const isMatch = clickedPath.getAttribute('d') === expectedD;
|
|
520
|
+
if (isMatch) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
// trường hợp đặc biệt select table clear icon
|
|
525
|
+
|
|
526
|
+
// if (tableRef.current && tableBody && !tableBody.contains(element as Node) && !tableHeader.contains(element as Node) ) {
|
|
527
|
+
if (tableRef.current && tableBody && !tableBody.contains(element)) {
|
|
528
|
+
if (isEditting) {}
|
|
529
|
+
if (isEditting) {
|
|
530
|
+
setTimeout(() => {
|
|
531
|
+
pipeline.setStateAtKey(stateKeyIsEditing, false);
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
if (endCell) {
|
|
535
|
+
pipeline.setStateAtKey(stateKeyEndCell, undefined);
|
|
536
|
+
}
|
|
537
|
+
if (startCell) {
|
|
538
|
+
pipeline.setStateAtKey(stateKeyStartCell, undefined);
|
|
539
|
+
}
|
|
540
|
+
if (focusedCell) {
|
|
541
|
+
setTimeout(() => {
|
|
542
|
+
pipeline.setStateAtKey(stateKeyFocusedCell, undefined);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
548
|
+
return () => {
|
|
549
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
550
|
+
};
|
|
551
|
+
}, [tableId, pipeline, editAble, headerEditAble]);
|
|
552
|
+
const rowsFocus = React.useMemo(() => {
|
|
553
|
+
const startCell = pipeline.getStateAtKey(stateKeyStartCell);
|
|
554
|
+
const endCell = pipeline.getStateAtKey(stateKeyEndCell);
|
|
555
|
+
const allRows = pipeline.getDataSource(); // flat data
|
|
556
|
+
const rowIndexMap = getRowIndexMap(allRows);
|
|
557
|
+
const selectRowIds = startCell && endCell ? getRowIdsBetween3(convertData, rowIndexMap, startCell.rowId, endCell.rowId) : [];
|
|
558
|
+
return selectRowIds;
|
|
559
|
+
}, [convertData, pipeline]);
|
|
236
560
|
function handleDragEnd(event) {
|
|
237
561
|
const {
|
|
238
562
|
active,
|
|
@@ -253,6 +577,859 @@ const InternalTable = props => {
|
|
|
253
577
|
}
|
|
254
578
|
}
|
|
255
579
|
const sensors = useSensors(useSensor(MouseSensor, {}), useSensor(TouchSensor, {}), useSensor(KeyboardSensor, {}));
|
|
580
|
+
const handleDeleteRows = React.useCallback(item => {
|
|
581
|
+
if (item.onClick) {
|
|
582
|
+
item.onClick({
|
|
583
|
+
toolbar: item
|
|
584
|
+
});
|
|
585
|
+
} else {
|
|
586
|
+
const filterData = flattenArray([...convertData]);
|
|
587
|
+
const rs = filterData.filter(it => !rowsFocus.includes(it[rowKey]));
|
|
588
|
+
const newDaa = unFlattenData(rs);
|
|
589
|
+
if (commandSettings && commandSettings.confirmDialog) {
|
|
590
|
+
MySwal.fire({
|
|
591
|
+
title: t ? t('Confirm') : 'Confirm',
|
|
592
|
+
text: t ? t('Do you want to delete item?') : 'Do you want to delete item?',
|
|
593
|
+
// icon: 'warning',
|
|
594
|
+
allowOutsideClick: false,
|
|
595
|
+
showCancelButton: true,
|
|
596
|
+
confirmButtonText: t ? t('Delete') : 'Delete',
|
|
597
|
+
cancelButtonText: t ? t('Cancel') : 'Cancel',
|
|
598
|
+
customClass: {
|
|
599
|
+
confirmButton: 'be-button btn-primary',
|
|
600
|
+
cancelButton: 'be-button btn-danger ms-1'
|
|
601
|
+
},
|
|
602
|
+
buttonsStyling: false
|
|
603
|
+
}).then(async result => {
|
|
604
|
+
if (result.value) {
|
|
605
|
+
triggerChangeData?.([...newDaa], {
|
|
606
|
+
type: 'DELETE_ROWS',
|
|
607
|
+
row: rowsFocus.length
|
|
608
|
+
});
|
|
609
|
+
} else if (result.dismiss === MySwal.DismissReason.cancel) {}
|
|
610
|
+
});
|
|
611
|
+
} else {
|
|
612
|
+
// không hiện dialog
|
|
613
|
+
triggerChangeData?.([...newDaa], {
|
|
614
|
+
type: 'DELETE_ROWS',
|
|
615
|
+
row: rowsFocus.length
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}, [commandSettings, convertData, rowsFocus, t, triggerChangeData]);
|
|
620
|
+
const handleDeleteAll = React.useCallback(item => {
|
|
621
|
+
if (item.onClick) {
|
|
622
|
+
item.onClick({
|
|
623
|
+
toolbar: item
|
|
624
|
+
});
|
|
625
|
+
} else {
|
|
626
|
+
if (commandSettings && commandSettings.confirmDialog) {
|
|
627
|
+
MySwal.fire({
|
|
628
|
+
title: t ? t('Confirm') : 'Confirm',
|
|
629
|
+
text: t ? t('Do you want to delete item?') : 'Do you want to delete item?',
|
|
630
|
+
// icon: 'warning',
|
|
631
|
+
allowOutsideClick: false,
|
|
632
|
+
showCancelButton: true,
|
|
633
|
+
confirmButtonText: t ? t('Delete') : 'Delete',
|
|
634
|
+
cancelButtonText: t ? t('Cancel') : 'Cancel',
|
|
635
|
+
customClass: {
|
|
636
|
+
confirmButton: 'be-button btn-primary',
|
|
637
|
+
cancelButton: 'be-button btn-danger ms-1'
|
|
638
|
+
},
|
|
639
|
+
buttonsStyling: false
|
|
640
|
+
}).then(async result => {
|
|
641
|
+
if (result.value) {
|
|
642
|
+
triggerChangeData?.([], {
|
|
643
|
+
type: 'DELETE'
|
|
644
|
+
});
|
|
645
|
+
} else if (result.dismiss === MySwal.DismissReason.cancel) {}
|
|
646
|
+
});
|
|
647
|
+
} else {
|
|
648
|
+
triggerChangeData?.([], {
|
|
649
|
+
type: 'DELETE'
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}, [commandSettings, t, triggerChangeData]);
|
|
654
|
+
const handleAddMulti = React.useCallback((item, n, newId) => {
|
|
655
|
+
if (item.onClick) {
|
|
656
|
+
item.onClick({
|
|
657
|
+
toolbar: item
|
|
658
|
+
});
|
|
659
|
+
} else {
|
|
660
|
+
const defaultRowValue = getDefaultValue(defaultValue);
|
|
661
|
+
const newRows = Array.from({
|
|
662
|
+
length: n
|
|
663
|
+
}).map(() => defaultRowValue ? {
|
|
664
|
+
...defaultRowValue,
|
|
665
|
+
id: undefined,
|
|
666
|
+
rowId: n === 1 && newId ? newId : newGuid()
|
|
667
|
+
} : {
|
|
668
|
+
id: undefined,
|
|
669
|
+
rowId: n === 1 && newId ? newId : newGuid()
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
// const kkk = getAllRowKey(newRows) ?? []
|
|
673
|
+
|
|
674
|
+
// const rs = mergedFilterKeys ? [...mergedFilterKeys, ...kkk] : [...kkk]
|
|
675
|
+
|
|
676
|
+
// setMergedFilterKeys?.(rs)
|
|
677
|
+
|
|
678
|
+
const newData = convertData.concat(newRows);
|
|
679
|
+
triggerChangeData?.(newData);
|
|
680
|
+
}
|
|
681
|
+
}, [convertData, defaultValue, triggerChangeData]);
|
|
682
|
+
const handleDuplicate = React.useCallback(() => {
|
|
683
|
+
// không tính tree
|
|
684
|
+
|
|
685
|
+
// Cập nhật data mới
|
|
686
|
+
const newData = flattenArray([...convertData]);
|
|
687
|
+
const focusedCell = pipeline.getStateAtKey(stateKeyFocusedCell);
|
|
688
|
+
const duplicatedItem = newData.find(it => it.rowId === focusedCell?.rowId);
|
|
689
|
+
const duplicatedItems = [{
|
|
690
|
+
...duplicatedItem,
|
|
691
|
+
rowId: newGuid(),
|
|
692
|
+
id: undefined,
|
|
693
|
+
isDuplicate: true
|
|
694
|
+
}];
|
|
695
|
+
|
|
696
|
+
// Vị trí chèn là ngay sau phần tử lớn nhất trong rowsFocus
|
|
697
|
+
|
|
698
|
+
// const insertAfter = Math.max(...rowsFocus)
|
|
699
|
+
const insertAfter = newData.findIndex(it => it[rowKey] === focusedCell?.rowId);
|
|
700
|
+
const rsFilter = [...newData.slice(0, insertAfter + 1), ...duplicatedItems, ...newData.slice(insertAfter + 1)];
|
|
701
|
+
const rs = updateOrInsert(convertData, rsFilter);
|
|
702
|
+
triggerChangeData?.(rs, {
|
|
703
|
+
type: 'DUPLICATE'
|
|
704
|
+
});
|
|
705
|
+
}, [convertData, pipeline, triggerChangeData]);
|
|
706
|
+
|
|
707
|
+
// thêm n dòng bên trên
|
|
708
|
+
const handleInsertBefore = React.useCallback((item, n) => {
|
|
709
|
+
const defaultRowValue = getDefaultValue(defaultValue);
|
|
710
|
+
// setStartCell(focusedCell)
|
|
711
|
+
// setEndCell(focusedCell)
|
|
712
|
+
// setRangeState(getSelectedCellMatrix(table, focusedCell, focusedCell))
|
|
713
|
+
|
|
714
|
+
const record = convertData.find(it => it.rowId === rowsFocus[rowsFocus.length - 1]);
|
|
715
|
+
if (item.onClick) {
|
|
716
|
+
item.onClick({
|
|
717
|
+
toolbar: item
|
|
718
|
+
});
|
|
719
|
+
} else {
|
|
720
|
+
if (!record?.parentId) {
|
|
721
|
+
// Cập nhật data mới
|
|
722
|
+
|
|
723
|
+
const newData = [...convertData];
|
|
724
|
+
const newRows = Array.from({
|
|
725
|
+
length: n
|
|
726
|
+
}).map(() => defaultRowValue ? {
|
|
727
|
+
...defaultRowValue,
|
|
728
|
+
id: undefined,
|
|
729
|
+
rowId: newGuid()
|
|
730
|
+
} : {
|
|
731
|
+
id: undefined,
|
|
732
|
+
rowId: newGuid()
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
// const kkk = getAllRowKey(newRows) ?? []
|
|
736
|
+
|
|
737
|
+
// const rs = mergedFilterKeys ? [...mergedFilterKeys, ...kkk] : [...kkk]
|
|
738
|
+
|
|
739
|
+
// setMergedFilterKeys?.(rs)
|
|
740
|
+
|
|
741
|
+
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
742
|
+
newData.splice(index, 0, ...newRows);
|
|
743
|
+
triggerChangeData?.(newData, {
|
|
744
|
+
type: 'INSERT_BEFORE',
|
|
745
|
+
row: n
|
|
746
|
+
});
|
|
747
|
+
} else {
|
|
748
|
+
const newData = [...convertData];
|
|
749
|
+
const parent = findItemByKey(newData, rowKey, record.parentId);
|
|
750
|
+
const newRows = Array.from({
|
|
751
|
+
length: n
|
|
752
|
+
}).map(() => defaultRowValue ? {
|
|
753
|
+
...defaultRowValue,
|
|
754
|
+
id: undefined,
|
|
755
|
+
rowId: newGuid(),
|
|
756
|
+
parentId: parent.rowId
|
|
757
|
+
} : {
|
|
758
|
+
id: undefined,
|
|
759
|
+
rowId: newGuid(),
|
|
760
|
+
parentId: parent.rowId
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
// Cập nhật childData mới
|
|
764
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
765
|
+
const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
766
|
+
childData.splice(index, 0, ...newRows);
|
|
767
|
+
const newRowData = {
|
|
768
|
+
...parent,
|
|
769
|
+
children: childData
|
|
770
|
+
};
|
|
771
|
+
const newDataSource = updateArrayByKey(newData, newRowData, rowKey);
|
|
772
|
+
triggerChangeData?.(newDataSource, {
|
|
773
|
+
type: 'INSERT_BEFORE',
|
|
774
|
+
row: n
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}, [convertData, defaultValue, rowsFocus, triggerChangeData]);
|
|
779
|
+
|
|
780
|
+
//thêm 1 dòng bên dưới
|
|
781
|
+
const handleInsertAfter = React.useCallback((item, n) => {
|
|
782
|
+
const defaultRowValue = getDefaultValue(defaultValue);
|
|
783
|
+
const focusedCell = pipeline.getStateAtKey(stateKeyFocusedCell);
|
|
784
|
+
|
|
785
|
+
// const insertAfter = Math.max(...rowsFocus)
|
|
786
|
+
|
|
787
|
+
// const record: RecordType = flattenData(childrenColumnName, dataSource)[insertAfter]
|
|
788
|
+
|
|
789
|
+
// const record: any = table.getRowModel().rows.find((it) => it.id === focusedCell?.rowId)?.original
|
|
790
|
+
const record = convertData.find(it => it.rowId === focusedCell?.rowId);
|
|
791
|
+
if (item.onClick) {
|
|
792
|
+
item.onClick({
|
|
793
|
+
toolbar: item
|
|
794
|
+
});
|
|
795
|
+
} else {
|
|
796
|
+
if (!record?.parentId) {
|
|
797
|
+
// Cập nhật data mới
|
|
798
|
+
const newData = [...convertData];
|
|
799
|
+
const newRows = Array.from({
|
|
800
|
+
length: n
|
|
801
|
+
}).map(() => defaultRowValue ? {
|
|
802
|
+
...defaultRowValue,
|
|
803
|
+
id: undefined,
|
|
804
|
+
rowId: newGuid()
|
|
805
|
+
} : {
|
|
806
|
+
id: undefined,
|
|
807
|
+
rowId: newGuid()
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
// const kkk = getAllRowKey(newRows) ?? []
|
|
811
|
+
|
|
812
|
+
// const rs = mergedFilterKeys ? [...mergedFilterKeys, ...kkk] : [...kkk]
|
|
813
|
+
|
|
814
|
+
// setMergedFilterKeys?.(rs)
|
|
815
|
+
|
|
816
|
+
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
817
|
+
newData.splice(index + 1, 0, ...newRows);
|
|
818
|
+
triggerChangeData?.(newData, {
|
|
819
|
+
type: 'INSERT_AFTER',
|
|
820
|
+
row: n
|
|
821
|
+
});
|
|
822
|
+
} else {
|
|
823
|
+
const newData = [...convertData];
|
|
824
|
+
const parent = findItemByKey(newData, rowKey, record.parentId);
|
|
825
|
+
const newRows = Array.from({
|
|
826
|
+
length: n
|
|
827
|
+
}).map(() => defaultRowValue ? {
|
|
828
|
+
...defaultRowValue,
|
|
829
|
+
id: undefined,
|
|
830
|
+
rowId: newGuid(),
|
|
831
|
+
parentId: parent.rowId
|
|
832
|
+
} : {
|
|
833
|
+
id: undefined,
|
|
834
|
+
rowId: newGuid(),
|
|
835
|
+
parentId: parent.rowId
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
// const kkk = getAllRowKey(newRows) ?? []
|
|
839
|
+
|
|
840
|
+
// const rs = mergedFilterKeys ? [...mergedFilterKeys, ...kkk] : [...kkk]
|
|
841
|
+
|
|
842
|
+
// setMergedFilterKeys?.(rs)
|
|
843
|
+
|
|
844
|
+
// Cập nhật childData mới
|
|
845
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
846
|
+
const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
847
|
+
childData.splice(index + 1, 0, ...newRows);
|
|
848
|
+
const newRowData = {
|
|
849
|
+
...parent,
|
|
850
|
+
children: childData
|
|
851
|
+
};
|
|
852
|
+
const newDataSource = updateArrayByKey(newData, newRowData, rowKey);
|
|
853
|
+
triggerChangeData?.(newDataSource, {
|
|
854
|
+
type: 'INSERT_AFTER',
|
|
855
|
+
row: n
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}, [defaultValue, pipeline, convertData, triggerChangeData]);
|
|
860
|
+
const handleInsertChild = React.useCallback(item => {
|
|
861
|
+
const defaultRowValue = getDefaultValue(defaultValue);
|
|
862
|
+
const focusedCell = pipeline.getStateAtKey(stateKeyFocusedCell);
|
|
863
|
+
const rowId = newGuid();
|
|
864
|
+
const record = convertData.find(it => it.rowId === focusedCell?.rowId);
|
|
865
|
+
if (item.onClick) {
|
|
866
|
+
item.onClick({
|
|
867
|
+
toolbar: item
|
|
868
|
+
});
|
|
869
|
+
} else {
|
|
870
|
+
// const newData = [...dataSource]
|
|
871
|
+
const newData = [...convertData];
|
|
872
|
+
let newElement;
|
|
873
|
+
if (!record?.children || record?.children && record.children.length === 0) {
|
|
874
|
+
newElement = {
|
|
875
|
+
...record,
|
|
876
|
+
children: [{
|
|
877
|
+
...defaultRowValue,
|
|
878
|
+
parentId: record?.rowId,
|
|
879
|
+
rowId
|
|
880
|
+
}]
|
|
881
|
+
};
|
|
882
|
+
} else {
|
|
883
|
+
newElement = {
|
|
884
|
+
...record,
|
|
885
|
+
children: [...record.children, {
|
|
886
|
+
...defaultRowValue,
|
|
887
|
+
parentId: record.rowId,
|
|
888
|
+
rowId
|
|
889
|
+
}]
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// const rs = mergedFilterKeys ? [...mergedFilterKeys, rowId] : [rowId]
|
|
894
|
+
|
|
895
|
+
// setMergedFilterKeys?.(rs)
|
|
896
|
+
|
|
897
|
+
const newDataSource = updateArrayByKey(newData, newElement, rowKey);
|
|
898
|
+
triggerChangeData?.(newDataSource, {
|
|
899
|
+
type: 'INSERT_CHILDREN'
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
// setTimeout(() => {
|
|
904
|
+
// const row = table.getRowModel().rows.find((it) => it.id === focusedCell?.rowId)
|
|
905
|
+
|
|
906
|
+
// if (row) {
|
|
907
|
+
|
|
908
|
+
// setExpanded((old: any) => ({
|
|
909
|
+
// ...old,
|
|
910
|
+
// [row.id]: true
|
|
911
|
+
// }))
|
|
912
|
+
|
|
913
|
+
// }
|
|
914
|
+
|
|
915
|
+
// }, 10)
|
|
916
|
+
|
|
917
|
+
// const hasKey = mergedExpandedKeys.has(key)
|
|
918
|
+
// if (!hasKey) {
|
|
919
|
+
// const newExpandedKeys = [...mergedExpandedKeys, key]
|
|
920
|
+
// setInnerExpandedKeys(newExpandedKeys)
|
|
921
|
+
// }
|
|
922
|
+
}, [convertData, defaultValue, pipeline, triggerChangeData]);
|
|
923
|
+
const toolbarItemsBottom = React.useMemo(() => {
|
|
924
|
+
// Chưa có dòng| ô được chọn
|
|
925
|
+
if (!rowsFocus || rowsFocus.length === 0) {
|
|
926
|
+
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 => {
|
|
927
|
+
if (item.key === 'ADD') {
|
|
928
|
+
return {
|
|
929
|
+
...item,
|
|
930
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item',
|
|
931
|
+
template: () => {
|
|
932
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
|
|
933
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
934
|
+
}, item?.hasMenu === false ? /*#__PURE__*/React.createElement(Button, {
|
|
935
|
+
style: {
|
|
936
|
+
color: '#28c76f',
|
|
937
|
+
borderColor: '#28c76f'
|
|
938
|
+
},
|
|
939
|
+
variant: 'outlined',
|
|
940
|
+
onClick: () => handleAddMulti(item, 1),
|
|
941
|
+
className: "d-flex toolbar-button"
|
|
942
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item')) : /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
943
|
+
overlayClassName: 'be-popup-container',
|
|
944
|
+
trigger: ['click'],
|
|
945
|
+
style: {
|
|
946
|
+
color: '#28c76f',
|
|
947
|
+
borderColor: '#28c76f'
|
|
948
|
+
},
|
|
949
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
950
|
+
menu: {
|
|
951
|
+
items: itemsAdd,
|
|
952
|
+
onClick: e => handleAddMulti(item, Number(e.key))
|
|
953
|
+
}
|
|
954
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
955
|
+
style: {
|
|
956
|
+
color: '#28c76f'
|
|
957
|
+
},
|
|
958
|
+
onClick: () => handleAddMulti(item, 1)
|
|
959
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item')))));
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
if (item.key === 'DELETE') {
|
|
964
|
+
return {
|
|
965
|
+
...item,
|
|
966
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item',
|
|
967
|
+
template: () => {
|
|
968
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
969
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
970
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
971
|
+
style: {
|
|
972
|
+
color: '#eb4619',
|
|
973
|
+
borderColor: '#eb4619'
|
|
974
|
+
},
|
|
975
|
+
variant: 'outlined',
|
|
976
|
+
onClick: () => handleDeleteAll(item),
|
|
977
|
+
className: "d-flex toolbar-button"
|
|
978
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item')));
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
return {
|
|
983
|
+
...item
|
|
984
|
+
};
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false).map(item => {
|
|
988
|
+
if (item.key === 'ADD') {
|
|
989
|
+
return {
|
|
990
|
+
...item,
|
|
991
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item',
|
|
992
|
+
template: () => {
|
|
993
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
|
|
994
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
995
|
+
}, item?.hasMenu === false ? /*#__PURE__*/React.createElement(Button, {
|
|
996
|
+
style: {
|
|
997
|
+
color: '#28c76f',
|
|
998
|
+
borderColor: '#28c76f'
|
|
999
|
+
},
|
|
1000
|
+
variant: 'outlined',
|
|
1001
|
+
onClick: () => handleAddMulti(item, 1),
|
|
1002
|
+
className: "d-flex toolbar-button"
|
|
1003
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item')) : /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1004
|
+
title: "",
|
|
1005
|
+
overlayClassName: 'be-popup-container',
|
|
1006
|
+
style: {
|
|
1007
|
+
color: '#28c76f',
|
|
1008
|
+
borderColor: '#28c76f'
|
|
1009
|
+
},
|
|
1010
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1011
|
+
menu: {
|
|
1012
|
+
items: itemsAdd,
|
|
1013
|
+
onClick: e => handleAddMulti(item, Number(e.key))
|
|
1014
|
+
}
|
|
1015
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1016
|
+
style: {
|
|
1017
|
+
color: '#28c76f'
|
|
1018
|
+
},
|
|
1019
|
+
onClick: () => handleAddMulti(item, 1)
|
|
1020
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item')))));
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
if (item.key === 'DUPLICATE') {
|
|
1025
|
+
return {
|
|
1026
|
+
...item,
|
|
1027
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate',
|
|
1028
|
+
template: () => {
|
|
1029
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
1030
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1031
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1032
|
+
style: {
|
|
1033
|
+
color: '#28c76f',
|
|
1034
|
+
borderColor: '#28c76f'
|
|
1035
|
+
},
|
|
1036
|
+
variant: 'outlined',
|
|
1037
|
+
onClick: handleDuplicate,
|
|
1038
|
+
className: "d-flex toolbar-button"
|
|
1039
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate'))));
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
if (item.key === 'INSERT_BEFORE') {
|
|
1044
|
+
return {
|
|
1045
|
+
...item,
|
|
1046
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before',
|
|
1047
|
+
template: () => {
|
|
1048
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1049
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1050
|
+
}, item?.hasMenu === false ? /*#__PURE__*/React.createElement(Button, {
|
|
1051
|
+
style: {
|
|
1052
|
+
color: '#28c76f',
|
|
1053
|
+
borderColor: '#28c76f'
|
|
1054
|
+
},
|
|
1055
|
+
variant: 'outlined',
|
|
1056
|
+
onClick: () => handleInsertBefore(item, 1),
|
|
1057
|
+
className: "d-flex toolbar-button"
|
|
1058
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before')) : /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1059
|
+
overlayClassName: 'be-popup-container',
|
|
1060
|
+
style: {
|
|
1061
|
+
color: '#28c76f',
|
|
1062
|
+
borderColor: '#28c76f'
|
|
1063
|
+
},
|
|
1064
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1065
|
+
menu: {
|
|
1066
|
+
items: itemsAdd,
|
|
1067
|
+
onClick: e => handleInsertBefore(item, Number(e.key))
|
|
1068
|
+
}
|
|
1069
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1070
|
+
style: {
|
|
1071
|
+
color: '#28c76f'
|
|
1072
|
+
},
|
|
1073
|
+
onClick: () => handleInsertBefore(item, 1)
|
|
1074
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before')))));
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
if (item.key === 'INSERT_AFTER') {
|
|
1079
|
+
return {
|
|
1080
|
+
...item,
|
|
1081
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after',
|
|
1082
|
+
template: () => {
|
|
1083
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1084
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1085
|
+
}, item?.hasMenu === false ? /*#__PURE__*/React.createElement(Button, {
|
|
1086
|
+
style: {
|
|
1087
|
+
color: '#28c76f',
|
|
1088
|
+
borderColor: '#28c76f'
|
|
1089
|
+
},
|
|
1090
|
+
variant: 'outlined',
|
|
1091
|
+
onClick: () => handleInsertAfter(item, 1),
|
|
1092
|
+
className: "d-flex toolbar-button"
|
|
1093
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')) : /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1094
|
+
overlayClassName: 'be-popup-container',
|
|
1095
|
+
style: {
|
|
1096
|
+
color: '#28c76f',
|
|
1097
|
+
borderColor: '#28c76f'
|
|
1098
|
+
},
|
|
1099
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1100
|
+
menu: {
|
|
1101
|
+
items: itemsAdd,
|
|
1102
|
+
onClick: e => handleInsertAfter(item, Number(e.key))
|
|
1103
|
+
}
|
|
1104
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1105
|
+
style: {
|
|
1106
|
+
color: '#28c76f'
|
|
1107
|
+
},
|
|
1108
|
+
onClick: () => handleInsertAfter(item, 1)
|
|
1109
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')))));
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
if (item.key === 'INSERT_CHILDREN') {
|
|
1114
|
+
return {
|
|
1115
|
+
...item,
|
|
1116
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children',
|
|
1117
|
+
template: () => {
|
|
1118
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1119
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1120
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1121
|
+
style: {
|
|
1122
|
+
color: '#28c76f',
|
|
1123
|
+
borderColor: '#28c76f'
|
|
1124
|
+
},
|
|
1125
|
+
variant: 'outlined',
|
|
1126
|
+
onClick: () => handleInsertChild(item),
|
|
1127
|
+
className: "d-flex toolbar-button"
|
|
1128
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children'))));
|
|
1129
|
+
}
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
if (item.key === 'DELETE') {
|
|
1133
|
+
return {
|
|
1134
|
+
...item,
|
|
1135
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item',
|
|
1136
|
+
template: () => {
|
|
1137
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1138
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1139
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1140
|
+
style: {
|
|
1141
|
+
color: '#eb4619',
|
|
1142
|
+
borderColor: '#eb4619'
|
|
1143
|
+
},
|
|
1144
|
+
variant: 'outlined',
|
|
1145
|
+
onClick: handleDeleteAll,
|
|
1146
|
+
className: "d-flex toolbar-button"
|
|
1147
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item')));
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
if (item.key === 'DELETE_ROWS') {
|
|
1152
|
+
return {
|
|
1153
|
+
...item,
|
|
1154
|
+
label: t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`,
|
|
1155
|
+
template: () => {
|
|
1156
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1157
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1158
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1159
|
+
style: {
|
|
1160
|
+
color: '#eb4619',
|
|
1161
|
+
borderColor: '#eb4619'
|
|
1162
|
+
},
|
|
1163
|
+
variant: 'outlined',
|
|
1164
|
+
onClick: () => handleDeleteRows(item),
|
|
1165
|
+
className: "d-flex toolbar-button"
|
|
1166
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`)));
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
return {
|
|
1171
|
+
...item
|
|
1172
|
+
};
|
|
1173
|
+
});
|
|
1174
|
+
}, [handleAddMulti, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
|
|
1175
|
+
const toolbarItemsTop = React.useMemo(() => {
|
|
1176
|
+
// Chưa có dòng| ô được chọn
|
|
1177
|
+
if (!rowsFocus || rowsFocus.length === 0) {
|
|
1178
|
+
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== true && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
|
|
1179
|
+
if (item.key === 'ADD') {
|
|
1180
|
+
return {
|
|
1181
|
+
...item,
|
|
1182
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item',
|
|
1183
|
+
template: () => {
|
|
1184
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
|
|
1185
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1186
|
+
}, item?.hasMenu === false ? /*#__PURE__*/React.createElement(Button, {
|
|
1187
|
+
style: {
|
|
1188
|
+
color: '#28c76f',
|
|
1189
|
+
borderColor: '#28c76f'
|
|
1190
|
+
},
|
|
1191
|
+
variant: 'outlined',
|
|
1192
|
+
onClick: () => handleAddMulti(item, 1),
|
|
1193
|
+
className: "d-flex toolbar-button"
|
|
1194
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item')) : /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1195
|
+
overlayClassName: 'be-popup-container',
|
|
1196
|
+
trigger: ['click'],
|
|
1197
|
+
style: {
|
|
1198
|
+
color: '#28c76f',
|
|
1199
|
+
borderColor: '#28c76f'
|
|
1200
|
+
},
|
|
1201
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1202
|
+
menu: {
|
|
1203
|
+
items: itemsAdd,
|
|
1204
|
+
onClick: e => handleAddMulti(item, Number(e.key))
|
|
1205
|
+
}
|
|
1206
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1207
|
+
style: {
|
|
1208
|
+
color: '#28c76f'
|
|
1209
|
+
},
|
|
1210
|
+
onClick: () => handleAddMulti(item, 1)
|
|
1211
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item')))));
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
if (item.key === 'DELETE') {
|
|
1216
|
+
return {
|
|
1217
|
+
...item,
|
|
1218
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item',
|
|
1219
|
+
template: () => {
|
|
1220
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1221
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1222
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1223
|
+
style: {
|
|
1224
|
+
color: '#eb4619',
|
|
1225
|
+
borderColor: '#eb4619'
|
|
1226
|
+
},
|
|
1227
|
+
variant: 'outlined',
|
|
1228
|
+
onClick: () => handleDeleteAll(item),
|
|
1229
|
+
className: "d-flex toolbar-button"
|
|
1230
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item')));
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
return {
|
|
1235
|
+
...item
|
|
1236
|
+
};
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== true).map(item => {
|
|
1240
|
+
if (item.key === 'ADD') {
|
|
1241
|
+
return {
|
|
1242
|
+
...item,
|
|
1243
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item',
|
|
1244
|
+
template: () => {
|
|
1245
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
|
|
1246
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1247
|
+
}, item?.hasMenu === false ? /*#__PURE__*/React.createElement(Button, {
|
|
1248
|
+
style: {
|
|
1249
|
+
color: '#28c76f',
|
|
1250
|
+
borderColor: '#28c76f'
|
|
1251
|
+
},
|
|
1252
|
+
variant: 'outlined',
|
|
1253
|
+
onClick: () => handleAddMulti(item, 1),
|
|
1254
|
+
className: "d-flex toolbar-button"
|
|
1255
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item')) : /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1256
|
+
title: "",
|
|
1257
|
+
overlayClassName: 'be-popup-container',
|
|
1258
|
+
style: {
|
|
1259
|
+
color: '#28c76f',
|
|
1260
|
+
borderColor: '#28c76f'
|
|
1261
|
+
},
|
|
1262
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1263
|
+
menu: {
|
|
1264
|
+
items: itemsAdd,
|
|
1265
|
+
onClick: e => handleAddMulti(item, Number(e.key))
|
|
1266
|
+
}
|
|
1267
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1268
|
+
style: {
|
|
1269
|
+
color: '#28c76f'
|
|
1270
|
+
},
|
|
1271
|
+
onClick: () => handleAddMulti(item, 1)
|
|
1272
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item')))));
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
if (item.key === 'DUPLICATE') {
|
|
1277
|
+
return {
|
|
1278
|
+
...item,
|
|
1279
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate',
|
|
1280
|
+
template: () => {
|
|
1281
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
1282
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1283
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1284
|
+
style: {
|
|
1285
|
+
color: '#28c76f',
|
|
1286
|
+
borderColor: '#28c76f'
|
|
1287
|
+
},
|
|
1288
|
+
variant: 'outlined',
|
|
1289
|
+
onClick: handleDuplicate,
|
|
1290
|
+
className: "d-flex toolbar-button"
|
|
1291
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate'))));
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
if (item.key === 'INSERT_BEFORE') {
|
|
1296
|
+
return {
|
|
1297
|
+
...item,
|
|
1298
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before',
|
|
1299
|
+
template: () => {
|
|
1300
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1301
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1302
|
+
}, item?.hasMenu === false ? /*#__PURE__*/React.createElement(Button, {
|
|
1303
|
+
style: {
|
|
1304
|
+
color: '#28c76f',
|
|
1305
|
+
borderColor: '#28c76f'
|
|
1306
|
+
},
|
|
1307
|
+
variant: 'outlined',
|
|
1308
|
+
onClick: () => handleInsertBefore(item, 1),
|
|
1309
|
+
className: "d-flex toolbar-button"
|
|
1310
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before')) : /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1311
|
+
overlayClassName: 'be-popup-container',
|
|
1312
|
+
style: {
|
|
1313
|
+
color: '#28c76f',
|
|
1314
|
+
borderColor: '#28c76f'
|
|
1315
|
+
},
|
|
1316
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1317
|
+
menu: {
|
|
1318
|
+
items: itemsAdd,
|
|
1319
|
+
onClick: e => handleInsertBefore(item, Number(e.key))
|
|
1320
|
+
}
|
|
1321
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1322
|
+
style: {
|
|
1323
|
+
color: '#28c76f'
|
|
1324
|
+
},
|
|
1325
|
+
onClick: () => handleInsertBefore(item, 1)
|
|
1326
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before')))));
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
if (item.key === 'INSERT_AFTER') {
|
|
1331
|
+
return {
|
|
1332
|
+
...item,
|
|
1333
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after',
|
|
1334
|
+
template: () => {
|
|
1335
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1336
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1337
|
+
}, item?.hasMenu === false ? /*#__PURE__*/React.createElement(Button, {
|
|
1338
|
+
style: {
|
|
1339
|
+
color: '#28c76f',
|
|
1340
|
+
borderColor: '#28c76f'
|
|
1341
|
+
},
|
|
1342
|
+
variant: 'outlined',
|
|
1343
|
+
onClick: () => handleInsertAfter(item, 1),
|
|
1344
|
+
className: "d-flex toolbar-button"
|
|
1345
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')) : /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
1346
|
+
overlayClassName: 'be-popup-container',
|
|
1347
|
+
style: {
|
|
1348
|
+
color: '#28c76f',
|
|
1349
|
+
borderColor: '#28c76f'
|
|
1350
|
+
},
|
|
1351
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
1352
|
+
menu: {
|
|
1353
|
+
items: itemsAdd,
|
|
1354
|
+
onClick: e => handleInsertAfter(item, Number(e.key))
|
|
1355
|
+
}
|
|
1356
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1357
|
+
style: {
|
|
1358
|
+
color: '#28c76f'
|
|
1359
|
+
},
|
|
1360
|
+
onClick: () => handleInsertAfter(item, 1)
|
|
1361
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')))));
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
if (item.key === 'INSERT_CHILDREN') {
|
|
1366
|
+
return {
|
|
1367
|
+
...item,
|
|
1368
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children',
|
|
1369
|
+
template: () => {
|
|
1370
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1371
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1372
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1373
|
+
style: {
|
|
1374
|
+
color: '#28c76f',
|
|
1375
|
+
borderColor: '#28c76f'
|
|
1376
|
+
},
|
|
1377
|
+
variant: 'outlined',
|
|
1378
|
+
onClick: () => handleInsertChild(item),
|
|
1379
|
+
className: "d-flex toolbar-button"
|
|
1380
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children'))));
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
if (item.key === 'DELETE') {
|
|
1385
|
+
return {
|
|
1386
|
+
...item,
|
|
1387
|
+
label: item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item',
|
|
1388
|
+
template: () => {
|
|
1389
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1390
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1391
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1392
|
+
style: {
|
|
1393
|
+
color: '#eb4619',
|
|
1394
|
+
borderColor: '#eb4619'
|
|
1395
|
+
},
|
|
1396
|
+
variant: 'outlined',
|
|
1397
|
+
onClick: handleDeleteAll,
|
|
1398
|
+
className: "d-flex toolbar-button"
|
|
1399
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item')));
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
if (item.key === 'DELETE_ROWS') {
|
|
1404
|
+
return {
|
|
1405
|
+
...item,
|
|
1406
|
+
label: t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`,
|
|
1407
|
+
template: () => {
|
|
1408
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1409
|
+
className: classNames(`be-toolbar-item`, item?.className)
|
|
1410
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1411
|
+
style: {
|
|
1412
|
+
color: '#eb4619',
|
|
1413
|
+
borderColor: '#eb4619'
|
|
1414
|
+
},
|
|
1415
|
+
variant: 'outlined',
|
|
1416
|
+
onClick: () => handleDeleteRows(item),
|
|
1417
|
+
className: "d-flex toolbar-button"
|
|
1418
|
+
}, item.template ? getToolbarTemplate(item.template) : /*#__PURE__*/React.createElement(React.Fragment, null, t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`)));
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
}
|
|
1422
|
+
return {
|
|
1423
|
+
...item
|
|
1424
|
+
};
|
|
1425
|
+
});
|
|
1426
|
+
}, [handleAddMulti, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
|
|
1427
|
+
const toolbarItemTopRight = React.useMemo(() => {
|
|
1428
|
+
if (!toolbarItems) {
|
|
1429
|
+
return undefined;
|
|
1430
|
+
}
|
|
1431
|
+
return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight);
|
|
1432
|
+
}, [toolbarItems]);
|
|
256
1433
|
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
257
1434
|
locale: language,
|
|
258
1435
|
theme: {
|
|
@@ -303,7 +1480,7 @@ const InternalTable = props => {
|
|
|
303
1480
|
}, /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
304
1481
|
value: {
|
|
305
1482
|
prefix,
|
|
306
|
-
id,
|
|
1483
|
+
id: tableId,
|
|
307
1484
|
rowKey,
|
|
308
1485
|
dataSource: mergedData,
|
|
309
1486
|
originData: convertData,
|
|
@@ -317,18 +1494,21 @@ const InternalTable = props => {
|
|
|
317
1494
|
onDragEnd: handleDragEnd,
|
|
318
1495
|
sensors: sensors
|
|
319
1496
|
}, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
|
|
320
|
-
id:
|
|
1497
|
+
id: tableId,
|
|
321
1498
|
useVirtual: {
|
|
322
1499
|
header: false,
|
|
323
1500
|
horizontal: useVirtual?.horizontal ?? true,
|
|
324
1501
|
vertical: useVirtual?.vertical ?? true
|
|
325
1502
|
},
|
|
1503
|
+
ref: tableRef,
|
|
326
1504
|
isFullScreen: isFullScreen,
|
|
327
1505
|
pagination: pagination,
|
|
328
1506
|
setIsFullScreen: setIsFullScreen,
|
|
329
1507
|
pipeline: pipeline
|
|
330
|
-
|
|
1508
|
+
// {...pipeline.getProps()}
|
|
1509
|
+
,
|
|
331
1510
|
originData: convertData,
|
|
1511
|
+
dataSource: dataSource,
|
|
332
1512
|
originColumns: columns,
|
|
333
1513
|
groupColumns: groupColumns,
|
|
334
1514
|
setVisibleKeys: setVisibleKeys,
|
|
@@ -337,7 +1517,12 @@ const InternalTable = props => {
|
|
|
337
1517
|
onSorter: onSorter,
|
|
338
1518
|
defaultFilter: defaultFilter,
|
|
339
1519
|
defaultSorter: defaultSorter,
|
|
340
|
-
dataRowIds: dataIds
|
|
1520
|
+
dataRowIds: dataIds,
|
|
1521
|
+
columns: columns,
|
|
1522
|
+
editAble: editAble,
|
|
1523
|
+
toolbarItemTopRight: toolbarItemTopRight,
|
|
1524
|
+
toolbarItemsTop: toolbarItemsTop,
|
|
1525
|
+
toolbarItemsBottom: toolbarItemsBottom
|
|
341
1526
|
})), /*#__PURE__*/React.createElement(Modal, {
|
|
342
1527
|
open: isFullScreen,
|
|
343
1528
|
footer: null,
|
|
@@ -368,7 +1553,7 @@ const InternalTable = props => {
|
|
|
368
1553
|
}, /*#__PURE__*/React.createElement("div", {
|
|
369
1554
|
style: {}
|
|
370
1555
|
}, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
|
|
371
|
-
id:
|
|
1556
|
+
id: tableId,
|
|
372
1557
|
useVirtual: {
|
|
373
1558
|
header: false,
|
|
374
1559
|
horizontal: useVirtual?.horizontal ?? true,
|
|
@@ -378,7 +1563,11 @@ const InternalTable = props => {
|
|
|
378
1563
|
setIsFullScreen: setIsFullScreen,
|
|
379
1564
|
pipeline: pipeline,
|
|
380
1565
|
pagination: pagination
|
|
381
|
-
|
|
1566
|
+
// {...pipeline.getProps()}
|
|
1567
|
+
,
|
|
1568
|
+
|
|
1569
|
+
columns: columns,
|
|
1570
|
+
dataSource: dataSource,
|
|
382
1571
|
originData: convertData,
|
|
383
1572
|
originColumns: columns,
|
|
384
1573
|
groupColumns: groupColumns,
|
|
@@ -388,7 +1577,8 @@ const InternalTable = props => {
|
|
|
388
1577
|
onSorter: onSorter,
|
|
389
1578
|
defaultFilter: defaultFilter,
|
|
390
1579
|
defaultSorter: defaultSorter,
|
|
391
|
-
dataRowIds: dataIds
|
|
1580
|
+
dataRowIds: dataIds,
|
|
1581
|
+
editAble: editAble
|
|
392
1582
|
}))))))));
|
|
393
1583
|
};
|
|
394
1584
|
export default InternalTable;
|