es-grid-template 1.9.57 → 1.9.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/grid-component/hooks/utils.d.ts +2 -2
- package/es/grid-component/hooks/utils.js +0 -8
- package/es/grid-component/type.d.ts +4 -2
- package/es/group-component/body/EditableCell.d.ts +1 -2
- package/es/group-component/hook/utils.d.ts +4 -3
- package/es/table-component/body/EditableCell.d.ts +1 -2
- package/es/table-component/body/EditableCell.js +5 -3
- package/es/table-component/body/TableBodyCell.js +77 -8
- package/es/table-component/body/TableBodyCellEdit.js +242 -74
- package/es/table-component/hook/utils.d.ts +12 -1
- package/es/table-component/hook/utils.js +29 -3
- package/es/table-component/style.js +1 -1
- package/lib/grid-component/hooks/utils.d.ts +2 -2
- package/lib/grid-component/hooks/utils.js +0 -10
- package/lib/grid-component/type.d.ts +4 -2
- package/lib/group-component/body/EditableCell.d.ts +1 -2
- package/lib/group-component/hook/utils.d.ts +1 -0
- package/lib/table-component/body/EditableCell.d.ts +1 -2
- package/lib/table-component/body/EditableCell.js +5 -3
- package/lib/table-component/body/TableBodyCell.js +77 -8
- package/lib/table-component/body/TableBodyCellEdit.js +241 -73
- package/lib/table-component/hook/utils.d.ts +12 -1
- package/lib/table-component/hook/utils.js +31 -4
- package/lib/table-component/style.js +1 -1
- package/package.json +1 -1
|
@@ -23,6 +23,8 @@ var _locale = require("rc-master-ui/es/locale");
|
|
|
23
23
|
var _hooks = require("../../grid-component/hooks");
|
|
24
24
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
25
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
|
+
// import type { EditType } from "rc-master-ui"
|
|
27
|
+
|
|
26
28
|
const {
|
|
27
29
|
SHOW_PARENT
|
|
28
30
|
} = _rcMasterUi.TreeSelect;
|
|
@@ -490,7 +492,7 @@ const EditableCell = props => {
|
|
|
490
492
|
const formState = getValues();
|
|
491
493
|
const formNewState = {
|
|
492
494
|
...getValues(),
|
|
493
|
-
[dataIndex]: formState[dataIndex]
|
|
495
|
+
[dataIndex]: !(0, _utils.isNullOrUndefined)(formState[dataIndex]) ? formState[dataIndex] : undefined
|
|
494
496
|
};
|
|
495
497
|
// @ts-ignore
|
|
496
498
|
const prevState = record[dataIndex] ?? undefined;
|
|
@@ -636,7 +638,7 @@ const EditableCell = props => {
|
|
|
636
638
|
const formState = getValues();
|
|
637
639
|
const formNewState = {
|
|
638
640
|
...getValues(),
|
|
639
|
-
[dataIndex]: formState[dataIndex]
|
|
641
|
+
[dataIndex]: !(0, _utils.isNullOrUndefined)(formState[dataIndex]) ? formState[dataIndex] : undefined
|
|
640
642
|
};
|
|
641
643
|
// @ts-ignore
|
|
642
644
|
const prevState = record[dataIndex] ?? undefined;
|
|
@@ -780,7 +782,7 @@ const EditableCell = props => {
|
|
|
780
782
|
const formState = getValues();
|
|
781
783
|
const formNewState = {
|
|
782
784
|
...getValues(),
|
|
783
|
-
[dataIndex]: formState[dataIndex]
|
|
785
|
+
[dataIndex]: !(0, _utils.isNullOrUndefined)(formState[dataIndex]) ? formState[dataIndex] : undefined
|
|
784
786
|
};
|
|
785
787
|
// @ts-ignore
|
|
786
788
|
const prevState = record[dataIndex] ?? undefined;
|
|
@@ -13,6 +13,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
13
13
|
var _react = _interopRequireDefault(require("react"));
|
|
14
14
|
var _useContext = require("../useContext");
|
|
15
15
|
var _useColumns = require("../hook/useColumns");
|
|
16
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
16
17
|
const renderCellIndex = props => {
|
|
17
18
|
const {
|
|
18
19
|
parrents,
|
|
@@ -220,6 +221,18 @@ const TableBodyCell = props => {
|
|
|
220
221
|
const colFormat = typeof columnMeta?.format === 'function' ? columnMeta?.format(record) : columnMeta?.format;
|
|
221
222
|
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
222
223
|
const fomatedValue = (0, _useColumns.renderValueCell)(columnMeta, cellValue, record, rowIndex, colIndex, cellFormat, true);
|
|
224
|
+
const cellContent = columnMeta?.template ? typeof columnMeta.template === 'function' ? columnMeta.template({
|
|
225
|
+
field: columnMeta.field,
|
|
226
|
+
index: cell.row.index,
|
|
227
|
+
rowData: cell.row.original,
|
|
228
|
+
value: cell.getValue()
|
|
229
|
+
}) : columnMeta.template : fomatedValue;
|
|
230
|
+
const linkContent = columnMeta?.linkTemplate ? typeof columnMeta.linkTemplate === 'function' ? columnMeta.linkTemplate({
|
|
231
|
+
field: columnMeta.field,
|
|
232
|
+
index: cell.row.index,
|
|
233
|
+
rowData: cell.row.original,
|
|
234
|
+
value: cell.getValue()
|
|
235
|
+
}) : columnMeta.linkTemplate : cellContent;
|
|
223
236
|
const valueCellString = (0, _useColumns.getValueCellString)(columnMeta, cellValue, record, rowIndex, colIndex, format);
|
|
224
237
|
const tooltipContent = _react.default.useMemo(() => {
|
|
225
238
|
if (isOpenTooltip === false) {
|
|
@@ -382,7 +395,7 @@ const TableBodyCell = props => {
|
|
|
382
395
|
"data-row-index": rowNumber,
|
|
383
396
|
"data-col-key": cell.column.id,
|
|
384
397
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
385
|
-
"data-tooltip-content": tooltipContent
|
|
398
|
+
"data-tooltip-content": columnMeta?.type === 'link' ? '' : tooltipContent
|
|
386
399
|
// data-tooltip-delay-show={500}
|
|
387
400
|
,
|
|
388
401
|
|
|
@@ -396,7 +409,8 @@ const TableBodyCell = props => {
|
|
|
396
409
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
397
410
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
398
411
|
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
399
|
-
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta
|
|
412
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta?.type === 'number',
|
|
413
|
+
[`${prefix}-grid-cell-link`]: columnMeta?.type === 'link'
|
|
400
414
|
}),
|
|
401
415
|
style: {
|
|
402
416
|
...cellStyles,
|
|
@@ -494,6 +508,30 @@ const TableBodyCell = props => {
|
|
|
494
508
|
}
|
|
495
509
|
}
|
|
496
510
|
}
|
|
511
|
+
}, cellContent && columnMeta?.type === 'link' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Dropdown, {
|
|
512
|
+
trigger: ['hover'],
|
|
513
|
+
menu: {
|
|
514
|
+
items: [{
|
|
515
|
+
key: '1',
|
|
516
|
+
label: ''
|
|
517
|
+
}]
|
|
518
|
+
},
|
|
519
|
+
dropdownRender: () => /*#__PURE__*/_react.default.createElement("div", {
|
|
520
|
+
style: {
|
|
521
|
+
padding: '1rem',
|
|
522
|
+
backgroundColor: '#ffffff',
|
|
523
|
+
borderRadius: 6,
|
|
524
|
+
boxShadow: '0 6px 16px 0 rgba(0, 0, 0, 0.08),0 3px 6px -4px rgba(0, 0, 0, 0.12),0 9px 28px 8px rgba(0, 0, 0, 0.05)'
|
|
525
|
+
}
|
|
526
|
+
}, linkContent && typeof linkContent === 'string' ? /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("a", {
|
|
527
|
+
href: linkContent,
|
|
528
|
+
target: "_blank",
|
|
529
|
+
rel: "noreferrer"
|
|
530
|
+
}, linkContent)) : linkContent ? linkContent : /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("a", {
|
|
531
|
+
href: typeof cellContent === 'string' ? cellContent : '',
|
|
532
|
+
target: "_blank",
|
|
533
|
+
rel: "noreferrer"
|
|
534
|
+
}, cellContent)))
|
|
497
535
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
498
536
|
className: (0, _classnames.default)('ui-rc_cell-content', {})
|
|
499
537
|
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -542,11 +580,42 @@ const TableBodyCell = props => {
|
|
|
542
580
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
543
581
|
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
544
582
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
545
|
-
}))),
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
583
|
+
}))), cellContent))) : /*#__PURE__*/_react.default.createElement("div", {
|
|
584
|
+
className: (0, _classnames.default)('ui-rc_cell-content', {})
|
|
585
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
|
|
586
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
587
|
+
style: {
|
|
588
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
589
|
+
}
|
|
590
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
|
|
591
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
592
|
+
onClick: e => {
|
|
593
|
+
e.stopPropagation();
|
|
594
|
+
const keys = Object.keys(expanded);
|
|
595
|
+
// @ts-ignore
|
|
596
|
+
const tmp = {
|
|
597
|
+
...expanded
|
|
598
|
+
};
|
|
599
|
+
if (keys.includes(cell.row.id)) {
|
|
600
|
+
delete tmp[cell.row.id];
|
|
601
|
+
setExpanded(tmp);
|
|
602
|
+
} else {
|
|
603
|
+
setExpanded(old => ({
|
|
604
|
+
...old,
|
|
605
|
+
[cell.row.id]: true
|
|
606
|
+
}));
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
style: {
|
|
610
|
+
cursor: "pointer"
|
|
611
|
+
},
|
|
612
|
+
className: "ui-rc-table-row-expand"
|
|
613
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
|
|
614
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
615
|
+
}) : /*#__PURE__*/_react.default.createElement("span", {
|
|
616
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
617
|
+
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
618
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
619
|
+
}))), cellContent));
|
|
551
620
|
};
|
|
552
621
|
var _default = exports.default = TableBodyCell;
|
|
@@ -15,6 +15,7 @@ var _useContext = require("../useContext");
|
|
|
15
15
|
var _EditableCell = _interopRequireDefault(require("./EditableCell"));
|
|
16
16
|
var _hooks = require("../../grid-component/hooks");
|
|
17
17
|
var _useColumns = require("../hook/useColumns");
|
|
18
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
18
19
|
const renderCellIndex = props => {
|
|
19
20
|
const {
|
|
20
21
|
parrents,
|
|
@@ -202,6 +203,7 @@ const TableBodyCellEdit = props => {
|
|
|
202
203
|
setFocusedCell,
|
|
203
204
|
setEditingKey,
|
|
204
205
|
setRangeState,
|
|
206
|
+
rangePasteState,
|
|
205
207
|
setRangePasteState,
|
|
206
208
|
endCell,
|
|
207
209
|
setEndCell,
|
|
@@ -245,13 +247,6 @@ const TableBodyCellEdit = props => {
|
|
|
245
247
|
const [isOpenTooltip, setIsOpenTooltip] = _react.default.useState(false);
|
|
246
248
|
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
247
249
|
const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
|
|
248
|
-
|
|
249
|
-
// const tooltipContent = (isOpenTooltip === false)
|
|
250
|
-
// ? ''
|
|
251
|
-
// : columnMeta?.tooltipDescription
|
|
252
|
-
// ? (typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({ value: cell.getValue(), rowData: record }) : columnMeta.tooltipDescription)
|
|
253
|
-
// : cell.getValue()
|
|
254
|
-
|
|
255
250
|
const canEdit = (0, _utils.isEditable)(cell.column.columnDef.meta, record) && isRowEditable !== false;
|
|
256
251
|
|
|
257
252
|
// const allRows = table.getRowModel().rows;
|
|
@@ -324,7 +319,8 @@ const TableBodyCellEdit = props => {
|
|
|
324
319
|
const colPasteds = (0, _utils.getColIdsBetween)(table, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
|
|
325
320
|
const rowSelectIds = (0, _utils.getRowIdsBetween)(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
326
321
|
const colSelectIds = (0, _utils.getColIdsBetween)(table, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
327
|
-
const dataSelected = [];
|
|
322
|
+
const dataSelected = []; // data được copy
|
|
323
|
+
|
|
328
324
|
rowSelectIds.forEach(rowId => {
|
|
329
325
|
const row = allRows.find(r => r.id === rowId);
|
|
330
326
|
if (!row) return;
|
|
@@ -338,49 +334,104 @@ const TableBodyCellEdit = props => {
|
|
|
338
334
|
});
|
|
339
335
|
const copyRows = (0, _utils.flattenData)('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
|
|
340
336
|
let newRange;
|
|
341
|
-
if (
|
|
337
|
+
if (pasteState.type === 'down') {
|
|
342
338
|
// kéo xuóng
|
|
343
339
|
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, startCell, endPasteCell));
|
|
344
340
|
newRange = ctrlKey ? (0, _utils.addRowsDownWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsDown)(dataSelected, rowPasteIds.length);
|
|
345
|
-
} else {
|
|
341
|
+
} else if (pasteState.type === 'up') {
|
|
346
342
|
// kéo lên
|
|
347
343
|
setStartCell?.(endCell);
|
|
348
344
|
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, endCell, endPasteCell));
|
|
349
345
|
newRange = ctrlKey ? (0, _utils.addRowsUpWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsUp)(dataSelected, rowPasteIds.length);
|
|
346
|
+
} else if (pasteState.type === 'right') {
|
|
347
|
+
// kéo phải
|
|
348
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, startCell, endPasteCell));
|
|
349
|
+
// newRange = { addedRows: [], combined: [] }
|
|
350
|
+
// newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length)
|
|
351
|
+
newRange = (0, _utils.getDragRightData)({
|
|
352
|
+
colPasteds,
|
|
353
|
+
colSelectIds,
|
|
354
|
+
copyRows,
|
|
355
|
+
rowSelectIds
|
|
356
|
+
});
|
|
357
|
+
} else if (pasteState.type === 'left') {
|
|
358
|
+
// kéo trái
|
|
359
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, startCell, endPasteCell));
|
|
360
|
+
// newRange = { addedRows: [], combined: [] }
|
|
361
|
+
// newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length)
|
|
362
|
+
newRange = (0, _utils.getDragRightData)({
|
|
363
|
+
colPasteds,
|
|
364
|
+
colSelectIds,
|
|
365
|
+
copyRows,
|
|
366
|
+
rowSelectIds
|
|
367
|
+
});
|
|
350
368
|
}
|
|
351
369
|
|
|
352
370
|
// Cập nhật data mới
|
|
353
371
|
const newData = (0, _utils.flattenArray)([...dataSource]);
|
|
354
372
|
const pastedRows = [];
|
|
355
|
-
|
|
356
|
-
|
|
373
|
+
if (pasteState.type === 'down' || pasteState.type === 'up') {
|
|
374
|
+
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
375
|
+
const targetRow = pasteState.startRowIndex + rowIndex1;
|
|
357
376
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
rowValues.forEach((cellValue, colIndex1) => {
|
|
366
|
-
const targetCol = startColIndex + colIndex1;
|
|
367
|
-
if (targetCol >= tmpCols.length) {
|
|
368
|
-
// Không vượt quá số cột
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const columnKey = tmpCols[targetCol].id;
|
|
372
|
-
const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
|
|
373
|
-
if (!disable) {
|
|
374
|
-
newData[targetRow] = {
|
|
375
|
-
...newData[targetRow],
|
|
376
|
-
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
377
|
-
};
|
|
377
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
378
|
+
if (targetRow >= newData.length) {
|
|
379
|
+
newData.push({
|
|
380
|
+
id: undefined,
|
|
381
|
+
rowId: (0, _utils.newGuid)()
|
|
382
|
+
});
|
|
378
383
|
}
|
|
384
|
+
rowValues.forEach((cellValue, colIndex1) => {
|
|
385
|
+
const targetCol = startColIndex + colIndex1;
|
|
386
|
+
if (targetCol >= tmpCols.length) {
|
|
387
|
+
// Không vượt quá số cột
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const columnKey = tmpCols[targetCol].id;
|
|
391
|
+
const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
|
|
392
|
+
if (!disable) {
|
|
393
|
+
newData[targetRow] = {
|
|
394
|
+
...newData[targetRow],
|
|
395
|
+
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// Lưu dòng được paste
|
|
401
|
+
pastedRows.push(newData[targetRow]);
|
|
379
402
|
});
|
|
403
|
+
}
|
|
404
|
+
if (pasteState.type === 'right' || pasteState.type === 'left') {
|
|
405
|
+
newRange.addedCols.forEach((rowValues, rowIndex1) => {
|
|
406
|
+
const targetRow = pasteState.startRowIndex + rowIndex1;
|
|
380
407
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
408
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
409
|
+
if (targetRow >= newData.length) {
|
|
410
|
+
newData.push({
|
|
411
|
+
id: undefined,
|
|
412
|
+
rowId: (0, _utils.newGuid)()
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
rowValues.forEach((cellValue, colIndex1) => {
|
|
416
|
+
const targetCol = pasteState.startColIndex + colIndex1;
|
|
417
|
+
if (targetCol >= tmpCols.length) {
|
|
418
|
+
// Không vượt quá số cột
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
const columnKey = tmpCols[targetCol].id;
|
|
422
|
+
const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
|
|
423
|
+
if (!disable) {
|
|
424
|
+
newData[targetRow] = {
|
|
425
|
+
...newData[targetRow],
|
|
426
|
+
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// Lưu dòng được paste
|
|
432
|
+
pastedRows.push(newData[targetRow]);
|
|
433
|
+
});
|
|
434
|
+
}
|
|
384
435
|
const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...originData]), newData);
|
|
385
436
|
const rs = (0, _utils.unFlattenData)(rsFilterData);
|
|
386
437
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
@@ -461,11 +512,22 @@ const TableBodyCellEdit = props => {
|
|
|
461
512
|
});
|
|
462
513
|
}
|
|
463
514
|
if (isPasting) {
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
515
|
+
const allCols = table.getAllLeafColumns();
|
|
516
|
+
const absRowIndex = table.getRowModel().flatRows.findIndex(it => it.id === rowId); // row cell con chỏ chuột hiện tại
|
|
517
|
+
const absColIndex = allCols.findIndex(it => it.id === colId); // col cell con chỏ chuột hiện tại
|
|
467
518
|
|
|
468
|
-
|
|
519
|
+
// const absColIndex = allCols.findIndex((it) => it.id === endCell?.colId )
|
|
520
|
+
|
|
521
|
+
const endCellColIndex = allCols.findIndex(it => it.id === endCell?.colId); // col cuối cùng vùng được copy
|
|
522
|
+
|
|
523
|
+
const rowGap = absRowIndex - (endRowIndex ?? 0);
|
|
524
|
+
const colGap = absColIndex - (endCellColIndex ?? 0);
|
|
525
|
+
const absRowGap = rangeState?.rowRange.length === 1 ? rowGap : rowGap >= 0 ? rowGap : rowGap + (rangeState?.rowRange.length ?? 0) - 1;
|
|
526
|
+
const absColGap = rangeState?.colRange.length === 1 ? colGap : colGap >= 0 ? colGap : colGap + (rangeState?.colRange.length ?? 0) - 1;
|
|
527
|
+
if (rowGap > 0 && absRowGap > 0 && Math.abs(absRowGap) >= Math.abs(absColGap)) {
|
|
528
|
+
// kéo xuống : cell cuối trùng endCell
|
|
529
|
+
const findIndex = allRows.findIndex(it => it.id === endCell?.rowId);
|
|
530
|
+
const startRowPaste = allRows[findIndex + 1];
|
|
469
531
|
setStartPasteCell?.({
|
|
470
532
|
colId: startCell?.colId ?? '',
|
|
471
533
|
rowId: startRowPaste?.id ?? ''
|
|
@@ -480,28 +542,57 @@ const TableBodyCellEdit = props => {
|
|
|
480
542
|
}, {
|
|
481
543
|
colId: endCell?.colId ?? '',
|
|
482
544
|
rowId
|
|
483
|
-
}));
|
|
545
|
+
}, 'down'));
|
|
546
|
+
return;
|
|
484
547
|
}
|
|
485
|
-
if (
|
|
486
|
-
//
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
const startRowPaste = allRows[findIndex + 1];
|
|
490
|
-
setStartPasteCell?.({
|
|
491
|
-
colId: startCell?.colId ?? '',
|
|
492
|
-
rowId: startRowPaste?.id ?? ''
|
|
493
|
-
});
|
|
494
|
-
setEndPasteCell?.({
|
|
495
|
-
colId: endCell?.colId ?? '',
|
|
496
|
-
rowId
|
|
497
|
-
});
|
|
498
|
-
setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
548
|
+
if (rowGap < 0 && absRowGap < 0 && Math.abs(absRowGap) >= Math.abs(absColGap)) {
|
|
549
|
+
// kéo lên
|
|
550
|
+
const startRowPaste = allRows.find(it => it.index === (startRowIndex ?? 0) - 1);
|
|
551
|
+
const startPastCell = {
|
|
499
552
|
colId: startCell?.colId ?? '',
|
|
500
553
|
rowId: startRowPaste?.id ?? ''
|
|
501
|
-
}
|
|
554
|
+
};
|
|
555
|
+
const endPastCell = {
|
|
502
556
|
colId: endCell?.colId ?? '',
|
|
503
557
|
rowId
|
|
504
|
-
}
|
|
558
|
+
};
|
|
559
|
+
setStartPasteCell?.(startPastCell);
|
|
560
|
+
setEndPasteCell?.(endPastCell);
|
|
561
|
+
setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, startPastCell, endPastCell, 'up'));
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (colGap > 0 && absColGap > 0 && Math.abs(absColGap) > Math.abs(absRowGap)) {
|
|
565
|
+
const startCol = allCols[(rangeState?.endColIndex ?? 0) + 1];
|
|
566
|
+
const startPastCell = {
|
|
567
|
+
colId: startCol?.id ?? '',
|
|
568
|
+
rowId: rangeState?.rowRange[0] ?? ''
|
|
569
|
+
};
|
|
570
|
+
const endPastCell = {
|
|
571
|
+
colId,
|
|
572
|
+
rowId: rangeState?.rowRange[rangeState?.rowRange.length - 1] ?? ''
|
|
573
|
+
};
|
|
574
|
+
setStartPasteCell?.(startPastCell);
|
|
575
|
+
setEndPasteCell?.(endPastCell);
|
|
576
|
+
setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, startPastCell, endPastCell, 'right'));
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
if (colGap < 0 && absColGap < 0 && Math.abs(absColGap) > Math.abs(absRowGap)) {
|
|
580
|
+
const endCol = allCols[(rangeState?.startColIndex ?? 0) - 1];
|
|
581
|
+
const startPastCell = {
|
|
582
|
+
colId: colId ?? '',
|
|
583
|
+
rowId: rangeState?.rowRange[0] ?? ''
|
|
584
|
+
};
|
|
585
|
+
const endPastCell = {
|
|
586
|
+
colId: endCol.id,
|
|
587
|
+
rowId: rangeState?.rowRange[rangeState?.rowRange.length - 1] ?? ''
|
|
588
|
+
};
|
|
589
|
+
setStartPasteCell?.(startPastCell);
|
|
590
|
+
setEndPasteCell?.(endPastCell);
|
|
591
|
+
setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, startPastCell, endPastCell, 'left'));
|
|
592
|
+
return;
|
|
593
|
+
} else {
|
|
594
|
+
setStartPasteCell?.(undefined);
|
|
595
|
+
setEndPasteCell?.(undefined);
|
|
505
596
|
}
|
|
506
597
|
}
|
|
507
598
|
}
|
|
@@ -529,14 +620,15 @@ const TableBodyCellEdit = props => {
|
|
|
529
620
|
setIsSelecting?.(false);
|
|
530
621
|
setIsPasting?.(false);
|
|
531
622
|
const selectState = (0, _utils.getSelectedCellMatrix)(table, startCell, endCell);
|
|
532
|
-
const selectPasteState =
|
|
533
|
-
|
|
623
|
+
// const selectPasteState = getSelectedCellMatrix(table, startPasteCell, endPasteCell)
|
|
624
|
+
const selectPasteState = rangePasteState ? {
|
|
625
|
+
...rangePasteState
|
|
626
|
+
} : {};
|
|
627
|
+
|
|
628
|
+
// if (endPasteCell && endCell?.rowId !== endPasteCell?.rowId && isPasting) {
|
|
629
|
+
if (selectPasteState.type && isPasting) {
|
|
534
630
|
triggerDragPaste(selectPasteState, e.ctrlKey);
|
|
535
631
|
} else {
|
|
536
|
-
// if ( endCell?.rowId !== rowId || endCell?.colId !== colId) {
|
|
537
|
-
// setRangeState?.(selectState)
|
|
538
|
-
// }
|
|
539
|
-
|
|
540
632
|
if (!(0, _utils.isObjEqual)(rangeState, selectState)) {
|
|
541
633
|
setRangeState?.(selectState);
|
|
542
634
|
}
|
|
@@ -1182,6 +1274,18 @@ const TableBodyCellEdit = props => {
|
|
|
1182
1274
|
const colFormat = typeof columnMeta?.format === 'function' ? columnMeta?.format(record) : columnMeta?.format;
|
|
1183
1275
|
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
1184
1276
|
const fomatedValue = (0, _useColumns.renderValueCell)(columnMeta, cellValue, record, rowIndex, colIndex, cellFormat, true);
|
|
1277
|
+
const cellContent = columnMeta?.template ? typeof columnMeta.template === 'function' ? columnMeta.template({
|
|
1278
|
+
field: columnMeta.field,
|
|
1279
|
+
index: cell.row.index,
|
|
1280
|
+
rowData: cell.row.original,
|
|
1281
|
+
value: cell.getValue()
|
|
1282
|
+
}) : columnMeta.template : fomatedValue;
|
|
1283
|
+
const linkContent = columnMeta?.linkTemplate ? typeof columnMeta.linkTemplate === 'function' ? columnMeta.linkTemplate({
|
|
1284
|
+
field: columnMeta.field,
|
|
1285
|
+
index: cell.row.index,
|
|
1286
|
+
rowData: cell.row.original,
|
|
1287
|
+
value: cell.getValue()
|
|
1288
|
+
}) : columnMeta.linkTemplate : cellContent;
|
|
1185
1289
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1186
1290
|
key: cell.id,
|
|
1187
1291
|
ref: el => {
|
|
@@ -1196,7 +1300,7 @@ const TableBodyCellEdit = props => {
|
|
|
1196
1300
|
"data-row-key": cell.row.id,
|
|
1197
1301
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
1198
1302
|
"data-tooltip-delay-show": 500,
|
|
1199
|
-
"data-tooltip-content": isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : tooltipContent,
|
|
1303
|
+
"data-tooltip-content": isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : columnMeta?.type === 'link' ? '' : tooltipContent,
|
|
1200
1304
|
className: (0, _classnames.default)(`${prefix}-grid-cell cell-editable editable `, {
|
|
1201
1305
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
1202
1306
|
'cell-editing': isEditing,
|
|
@@ -1215,7 +1319,8 @@ const TableBodyCellEdit = props => {
|
|
|
1215
1319
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
1216
1320
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
1217
1321
|
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
1218
|
-
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta
|
|
1322
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta?.type === 'number',
|
|
1323
|
+
[`${prefix}-grid-cell-link`]: columnMeta?.type === 'link'
|
|
1219
1324
|
}),
|
|
1220
1325
|
style: {
|
|
1221
1326
|
display: 'flex',
|
|
@@ -1315,8 +1420,31 @@ const TableBodyCellEdit = props => {
|
|
|
1315
1420
|
record: record,
|
|
1316
1421
|
visibleColumns: visibleColumns,
|
|
1317
1422
|
handleNextCell: handleNextCell
|
|
1318
|
-
|
|
1319
|
-
|
|
1423
|
+
}) : columnMeta?.type === 'link' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Dropdown, {
|
|
1424
|
+
trigger: ['hover'],
|
|
1425
|
+
menu: {
|
|
1426
|
+
items: [{
|
|
1427
|
+
key: '1',
|
|
1428
|
+
label: ''
|
|
1429
|
+
}]
|
|
1430
|
+
},
|
|
1431
|
+
dropdownRender: () => /*#__PURE__*/_react.default.createElement("div", {
|
|
1432
|
+
style: {
|
|
1433
|
+
padding: '1rem',
|
|
1434
|
+
backgroundColor: '#ffffff',
|
|
1435
|
+
borderRadius: 6,
|
|
1436
|
+
boxShadow: '0 6px 16px 0 rgba(0, 0, 0, 0.08),0 3px 6px -4px rgba(0, 0, 0, 0.12),0 9px 28px 8px rgba(0, 0, 0, 0.05)'
|
|
1437
|
+
}
|
|
1438
|
+
}, linkContent && typeof linkContent === 'string' ? /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("a", {
|
|
1439
|
+
href: linkContent,
|
|
1440
|
+
target: "_blank",
|
|
1441
|
+
rel: "noreferrer"
|
|
1442
|
+
}, linkContent)) : linkContent ? linkContent : /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("a", {
|
|
1443
|
+
href: typeof cellContent === 'string' ? cellContent : '',
|
|
1444
|
+
target: "_blank",
|
|
1445
|
+
rel: "noreferrer"
|
|
1446
|
+
}, cellContent)))
|
|
1447
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1320
1448
|
className: (0, _classnames.default)('ui-rc_cell-content', {
|
|
1321
1449
|
'select-cell': canEdit && ['select', 'selectTable', 'asyncSelect', 'treeSelect'].includes((0, _utils.getEditType)(columnMeta, record))
|
|
1322
1450
|
})
|
|
@@ -1356,17 +1484,57 @@ const TableBodyCellEdit = props => {
|
|
|
1356
1484
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
1357
1485
|
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
1358
1486
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
1359
|
-
}))),
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
}) :
|
|
1487
|
+
}))), cellContent, (editType === 'select' || editType === 'selectTable' || editType === 'asyncSelect' || editType === 'treeSelect') && canEdit && /*#__PURE__*/_react.default.createElement("span", {
|
|
1488
|
+
className: 'caret-down',
|
|
1489
|
+
onClick: e => {
|
|
1490
|
+
handleEdit(e);
|
|
1491
|
+
}
|
|
1492
|
+
})))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
1493
|
+
className: (0, _classnames.default)('ui-rc_cell-content', {
|
|
1494
|
+
'select-cell': canEdit && ['select', 'selectTable', 'asyncSelect', 'treeSelect'].includes((0, _utils.getEditType)(columnMeta, record))
|
|
1495
|
+
})
|
|
1496
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
|
|
1497
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
1498
|
+
style: {
|
|
1499
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
1500
|
+
}
|
|
1501
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
|
|
1502
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
1503
|
+
onClick: e => {
|
|
1504
|
+
e.stopPropagation();
|
|
1505
|
+
e.preventDefault();
|
|
1506
|
+
setIsExpandClick(true);
|
|
1507
|
+
const keys = Object.keys(expanded);
|
|
1508
|
+
// @ts-ignore
|
|
1509
|
+
const tmp = {
|
|
1510
|
+
...expanded
|
|
1511
|
+
};
|
|
1512
|
+
if (keys.includes(cell.row.id)) {
|
|
1513
|
+
delete tmp[cell.row.id];
|
|
1514
|
+
setExpanded(tmp);
|
|
1515
|
+
} else {
|
|
1516
|
+
setExpanded(old => ({
|
|
1517
|
+
...old,
|
|
1518
|
+
[cell.row.id]: true
|
|
1519
|
+
}));
|
|
1520
|
+
}
|
|
1521
|
+
},
|
|
1522
|
+
style: {
|
|
1523
|
+
cursor: "pointer"
|
|
1524
|
+
},
|
|
1525
|
+
className: "ui-rc-table-row-expand"
|
|
1526
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
|
|
1527
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
1528
|
+
}) : /*#__PURE__*/_react.default.createElement("span", {
|
|
1529
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
1530
|
+
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
1531
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
1532
|
+
}))), cellContent, (editType === 'select' || editType === 'selectTable' || editType === 'asyncSelect' || editType === 'treeSelect') && canEdit && /*#__PURE__*/_react.default.createElement("span", {
|
|
1365
1533
|
className: 'caret-down',
|
|
1366
1534
|
onClick: e => {
|
|
1367
1535
|
handleEdit(e);
|
|
1368
1536
|
}
|
|
1369
|
-
})), !isSelecting && !isEditing && rowRange &&
|
|
1537
|
+
}))), !isSelecting && !isEditing && rowRange &&
|
|
1370
1538
|
// rowNumber === rangeState?.endRowIndex &&
|
|
1371
1539
|
cell.row.id === rowRange[rowRange?.length - 1] && cell.column.getIndex() === rangeState?.endColIndex && /*#__PURE__*/_react.default.createElement("div", {
|
|
1372
1540
|
className: 'dragging-point',
|
|
@@ -96,7 +96,7 @@ export declare const genPresets: (presets?: import("@ant-design/colors").Palette
|
|
|
96
96
|
export declare const getEditType: <T>(column: ColumnTable<T>, rowData?: any) => EditType;
|
|
97
97
|
export declare const getDefaultValue: (defaultValue: any) => AnyObject;
|
|
98
98
|
export declare const flattenData: <RecordType extends AnyObject = AnyObject>(childrenColumnName: string, data?: RecordType[]) => RecordType[];
|
|
99
|
-
export declare const getSelectedCellMatrix: (table: Table<any>, startCell: IPositionCell | undefined, endCell: IPositionCell | undefined) => RangeState;
|
|
99
|
+
export declare const getSelectedCellMatrix: (table: Table<any>, startCell: IPositionCell | undefined, endCell: IPositionCell | undefined, type?: string) => RangeState;
|
|
100
100
|
export declare function addRowsDownWithCtrl(arr: any, n: number): {
|
|
101
101
|
combined: any;
|
|
102
102
|
addedRows: any[];
|
|
@@ -125,6 +125,16 @@ export declare function addRowsUp(array: any, n: number): {
|
|
|
125
125
|
combined: any[];
|
|
126
126
|
addedRows: any[];
|
|
127
127
|
};
|
|
128
|
+
interface DragCopyParams {
|
|
129
|
+
rowSelectIds: string[];
|
|
130
|
+
colSelectIds: string[];
|
|
131
|
+
colPasteds: string[];
|
|
132
|
+
copyRows: any[];
|
|
133
|
+
}
|
|
134
|
+
export declare const getDragRightData: ({ rowSelectIds, colSelectIds, colPasteds, copyRows, }: DragCopyParams) => {
|
|
135
|
+
combined: any[][];
|
|
136
|
+
addedCols: any[][];
|
|
137
|
+
};
|
|
128
138
|
export declare const convertFilters: (filters: any[]) => any[];
|
|
129
139
|
export declare const revertConvertFilters: (clauses: any[]) => FilterState[];
|
|
130
140
|
export declare function getInvisibleColumns(columns: ColumnTable[]): Record<string, boolean>;
|
|
@@ -170,3 +180,4 @@ export declare function sumNumberFields(columns: ColumnTable[], data: any[], chi
|
|
|
170
180
|
export declare const getTreeDepth: (rows: any[]) => number;
|
|
171
181
|
export type FormatToken = 'YYYY' | 'MM' | 'DD' | 'HH' | 'mm' | 'ss';
|
|
172
182
|
export declare const isDateChanged: (oldDate: string | Date, newDate: string | Date, format: string) => FormatToken | null;
|
|
183
|
+
export {};
|