es-grid-template 1.9.63 → 1.9.65
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/Grid.js +5 -2
- package/es/ali-table/InternalTable.js +499 -49
- package/es/ali-table/base-table/calculations.js +1 -1
- package/es/ali-table/base-table/cell/EditCell.js +14 -6
- package/es/ali-table/base-table/renderFilter.js +1 -1
- package/es/ali-table/interfaces.d.ts +2 -2
- package/es/ali-table/pipeline/features/columnCustom.d.ts +4 -2
- package/es/ali-table/pipeline/features/columnCustom.js +112 -48
- package/es/ali-table/utils/constants.d.ts +1 -0
- package/es/ali-table/utils/constants.js +1 -0
- package/es/ali-table/utils/convertColumnsChoose.d.ts +2 -2
- package/es/ali-table/utils/convertColumnsChoose.js +1 -2
- package/es/ali-table/utils/utility.d.ts +15 -1
- package/es/ali-table/utils/utility.js +399 -1
- package/es/grid-component/type.d.ts +2 -2
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/table-component/InternalTable.js +11 -3
- package/es/table-component/TableContainerEdit.js +148 -98
- package/es/table-component/body/EditableCell.js +9 -5
- package/es/table-component/body/TableBodyCellEdit.js +14 -8
- package/es/table-component/header/TableHeadCell2.js +2 -2
- package/es/table-component/hook/useColumns.js +1 -1
- package/es/table-component/hook/utils.d.ts +1 -1
- package/es/table-component/hook/utils.js +2 -6
- package/es/table-component/table/Grid.js +23 -17
- package/es/table-component/useContext.d.ts +1 -1
- package/lib/ali-table/Grid.js +5 -2
- package/lib/ali-table/InternalTable.js +490 -45
- package/lib/ali-table/base-table/calculations.js +1 -1
- package/lib/ali-table/base-table/cell/EditCell.js +14 -6
- package/lib/ali-table/base-table/renderFilter.js +1 -1
- package/lib/ali-table/interfaces.d.ts +2 -2
- package/lib/ali-table/pipeline/features/columnCustom.d.ts +4 -2
- package/lib/ali-table/pipeline/features/columnCustom.js +106 -46
- package/lib/ali-table/utils/constants.d.ts +1 -0
- package/lib/ali-table/utils/constants.js +2 -1
- package/lib/ali-table/utils/convertColumnsChoose.d.ts +2 -2
- package/lib/ali-table/utils/convertColumnsChoose.js +1 -2
- package/lib/ali-table/utils/utility.d.ts +15 -1
- package/lib/ali-table/utils/utility.js +410 -2
- package/lib/grid-component/type.d.ts +2 -2
- package/lib/table-component/InternalTable.js +11 -3
- package/lib/table-component/TableContainerEdit.js +148 -98
- package/lib/table-component/body/EditableCell.js +9 -5
- package/lib/table-component/body/TableBodyCellEdit.js +11 -7
- package/lib/table-component/header/TableHeadCell2.js +2 -2
- package/lib/table-component/hook/useColumns.js +1 -1
- package/lib/table-component/hook/utils.d.ts +1 -1
- package/lib/table-component/hook/utils.js +2 -6
- package/lib/table-component/table/Grid.js +22 -16
- package/lib/table-component/useContext.d.ts +1 -1
- package/package.json +1 -1
|
@@ -476,7 +476,9 @@ const EditCell = props => {
|
|
|
476
476
|
align: colSelect.textAlign
|
|
477
477
|
};
|
|
478
478
|
});
|
|
479
|
-
|
|
479
|
+
|
|
480
|
+
// let valueSelectTable = formValues[dataIndex]
|
|
481
|
+
let valueSelectTable = formValues[dataIndex] !== null ? formValues[dataIndex] : undefined;
|
|
480
482
|
if (fieldValue) {
|
|
481
483
|
// @ts-ignore
|
|
482
484
|
valueSelectTable = record[fieldValue] ?? formValues[dataIndex];
|
|
@@ -625,14 +627,16 @@ const EditCell = props => {
|
|
|
625
627
|
"data-tooltip-id": `${tableId}-tooltip-error`
|
|
626
628
|
});
|
|
627
629
|
case 'select':
|
|
628
|
-
let valueSelect = formValues[dataIndex];
|
|
630
|
+
let valueSelect = formValues[dataIndex] !== null ? formValues[dataIndex] : undefined;
|
|
631
|
+
// let valueSelect = !isNullOrUndefined(formValues[dataIndex]) ? formValues[dataIndex] : undefined
|
|
632
|
+
|
|
629
633
|
if (fieldValue) {
|
|
630
634
|
// @ts-ignore
|
|
631
635
|
valueSelect = record[fieldValue] ?? formValues[dataIndex];
|
|
632
636
|
}
|
|
633
637
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
634
638
|
options: options,
|
|
635
|
-
value: valueSelect ??
|
|
639
|
+
value: valueSelect ?? undefined,
|
|
636
640
|
onChange: (val, option) => {
|
|
637
641
|
onChange(val ?? '');
|
|
638
642
|
const formState = getValues();
|
|
@@ -768,7 +772,8 @@ const EditCell = props => {
|
|
|
768
772
|
"data-tooltip-id": `${tableId}-tooltip-error`
|
|
769
773
|
});
|
|
770
774
|
case 'asyncSelect':
|
|
771
|
-
let valueAsyncSelect = formValues[dataIndex]
|
|
775
|
+
// let valueAsyncSelect = formValues[dataIndex]
|
|
776
|
+
let valueAsyncSelect = formValues[dataIndex] !== null ? formValues[dataIndex] : undefined;
|
|
772
777
|
if (fieldValue) {
|
|
773
778
|
// @ts-ignore
|
|
774
779
|
valueAsyncSelect = record[fieldValue] ?? formValues[dataIndex];
|
|
@@ -776,7 +781,7 @@ const EditCell = props => {
|
|
|
776
781
|
return /*#__PURE__*/_react.default.createElement(_asyncSelect.AsyncSelect, {
|
|
777
782
|
options: options,
|
|
778
783
|
defaultOptions: options,
|
|
779
|
-
value: valueAsyncSelect
|
|
784
|
+
value: valueAsyncSelect,
|
|
780
785
|
onChange: (val, option) => {
|
|
781
786
|
onChange(val ?? '');
|
|
782
787
|
const formState = getValues();
|
|
@@ -1244,7 +1249,10 @@ const EditCell = props => {
|
|
|
1244
1249
|
}
|
|
1245
1250
|
};
|
|
1246
1251
|
return /*#__PURE__*/_react.default.createElement("form", {
|
|
1247
|
-
onSubmit: handleSubmit(onSubmit)
|
|
1252
|
+
onSubmit: handleSubmit(onSubmit),
|
|
1253
|
+
style: {
|
|
1254
|
+
height: '100%'
|
|
1255
|
+
}
|
|
1248
1256
|
}, /*#__PURE__*/_react.default.createElement(_reactHookForm.Controller, {
|
|
1249
1257
|
name: dataIndex,
|
|
1250
1258
|
control: control,
|
|
@@ -301,7 +301,7 @@ const renderFilter = args => {
|
|
|
301
301
|
,
|
|
302
302
|
onBlur: e => {
|
|
303
303
|
if (selectedKeys[0] === e.target.value) {} else {
|
|
304
|
-
setSelectedKeys(e.target.value ? [e.target.value] : []);
|
|
304
|
+
setSelectedKeys(e.target.value ? [e.target.value.trim()] : []);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
|
|
@@ -25,8 +25,7 @@ export interface ArtColumnStaticPart<RecordType = any> {
|
|
|
25
25
|
/** Column width; required if the column is locked */
|
|
26
26
|
width?: number;
|
|
27
27
|
fixed?: 'left' | 'right';
|
|
28
|
-
|
|
29
|
-
hidden?: boolean;
|
|
28
|
+
visible?: boolean;
|
|
30
29
|
/** Whether the column is locked (fixed) */
|
|
31
30
|
lock?: boolean;
|
|
32
31
|
/** Props for the header cell */
|
|
@@ -68,6 +67,7 @@ export interface ArtColumnStaticPart<RecordType = any> {
|
|
|
68
67
|
headerEditEnable?: boolean;
|
|
69
68
|
/** Kiểu editor khi edit cell */
|
|
70
69
|
headerEditType?: EditType;
|
|
70
|
+
editSelectSettings?: any;
|
|
71
71
|
}
|
|
72
72
|
export interface ArtColumnDynamicPart<RecordType = any> {
|
|
73
73
|
/** Custom data retrieval method */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TablePipeline } from '../pipeline';
|
|
2
2
|
import type { ColumnResizeMode } from '../../base-table/table';
|
|
3
3
|
import type { ArtColumn, SortOrder } from '../../interfaces';
|
|
4
|
-
import type { FilterItem, IFormat, IWrapSettings, Sorter, SourceFilter } from '../../../grid-component/type';
|
|
4
|
+
import type { FilterItem, ICellClick, IFormat, IWrapSettings, Sorter, SourceFilter } from '../../../grid-component/type';
|
|
5
5
|
type FilterState = {
|
|
6
6
|
field: any;
|
|
7
7
|
key: any;
|
|
@@ -14,6 +14,7 @@ export interface ColumnFeatureOptions {
|
|
|
14
14
|
columns: any[];
|
|
15
15
|
isDataTree?: boolean;
|
|
16
16
|
dataSource: any[];
|
|
17
|
+
rowIndexMap: any;
|
|
17
18
|
/** Uncontrolled usage: default column widths array */
|
|
18
19
|
defaultSizes?: number[];
|
|
19
20
|
columnResizeMode?: ColumnResizeMode;
|
|
@@ -63,7 +64,7 @@ export interface ColumnFeatureOptions {
|
|
|
63
64
|
getValues?: any;
|
|
64
65
|
control?: any;
|
|
65
66
|
errors?: any;
|
|
66
|
-
|
|
67
|
+
triggerChangeData?: any;
|
|
67
68
|
tableRef: any;
|
|
68
69
|
triggerPaste?: (pastedRows: any[], pastedColumnsArray: string[], newData: any[], copyRows: any[]) => void;
|
|
69
70
|
handleSubmit: any;
|
|
@@ -73,6 +74,7 @@ export interface ColumnFeatureOptions {
|
|
|
73
74
|
dataErrors?: any[];
|
|
74
75
|
headerData?: any;
|
|
75
76
|
headerEditAble?: boolean;
|
|
77
|
+
onCellClick?: (args: ICellClick, callback?: any) => void;
|
|
76
78
|
}
|
|
77
79
|
export declare function columnCustom(opts: ColumnFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
|
|
78
80
|
export {};
|
|
@@ -20,6 +20,7 @@ var _EditCell = _interopRequireDefault(require("../../base-table/cell/EditCell")
|
|
|
20
20
|
var _HeaderEditCell = _interopRequireDefault(require("../../base-table/cell/HeaderEditCell"));
|
|
21
21
|
var _constants = require("../../utils/constants");
|
|
22
22
|
var _utils3 = require("../../base-table/utils");
|
|
23
|
+
var _utility = require("../../utils/utility");
|
|
23
24
|
// import { getMaxDepth } from '../../utils/utility';
|
|
24
25
|
|
|
25
26
|
function clamp(min, x, max) {
|
|
@@ -56,7 +57,7 @@ function columnCustom(opts) {
|
|
|
56
57
|
control,
|
|
57
58
|
getValues,
|
|
58
59
|
errors,
|
|
59
|
-
|
|
60
|
+
triggerChangeData,
|
|
60
61
|
tableRef,
|
|
61
62
|
triggerPaste,
|
|
62
63
|
handleSubmit,
|
|
@@ -65,7 +66,9 @@ function columnCustom(opts) {
|
|
|
65
66
|
handleHeaderCellChange,
|
|
66
67
|
dataErrors,
|
|
67
68
|
headerData,
|
|
68
|
-
headerEditAble
|
|
69
|
+
headerEditAble,
|
|
70
|
+
rowIndexMap,
|
|
71
|
+
onCellClick
|
|
69
72
|
// originData
|
|
70
73
|
|
|
71
74
|
// currentPage = 1,
|
|
@@ -76,6 +79,7 @@ function columnCustom(opts) {
|
|
|
76
79
|
mode = 'multiple',
|
|
77
80
|
onSorter
|
|
78
81
|
} = opts;
|
|
82
|
+
const rowKey = 'rowId';
|
|
79
83
|
return function columnResizeFeature(pipeline) {
|
|
80
84
|
// State table
|
|
81
85
|
|
|
@@ -96,7 +100,6 @@ function columnCustom(opts) {
|
|
|
96
100
|
const originCols = pipeline.getColumns();
|
|
97
101
|
const rowIds = (0, _utils2.getKeys)(allRows, 'rowId');
|
|
98
102
|
const colIds = (0, _utils2.getKeys)(leafColumns, 'field');
|
|
99
|
-
const rowIndexMap = (0, _utils2.getRowIndexMap)(allRows);
|
|
100
103
|
|
|
101
104
|
// const deppthCols = getMaxDepth(originCols)
|
|
102
105
|
|
|
@@ -108,6 +111,7 @@ function columnCustom(opts) {
|
|
|
108
111
|
|
|
109
112
|
const focusedCell = pipeline.getStateAtKey(_constants.stateKeyFocusedCell) ?? {};
|
|
110
113
|
const isEditing = pipeline.getStateAtKey(_constants.stateKeyIsEditing) ?? false;
|
|
114
|
+
const editCellSettings = pipeline.getStateAtKey(_constants.stateKeyEditCellSettings);
|
|
111
115
|
const isSelecting = pipeline.getStateAtKey(_constants.stateKeyIsSelecting) ?? false;
|
|
112
116
|
const isPasting = pipeline.getStateAtKey(_constants.stateKeyIsPasting) ?? false;
|
|
113
117
|
const startCell = pipeline.getStateAtKey(_constants.stateKeyStartCell) ?? undefined;
|
|
@@ -126,7 +130,10 @@ function columnCustom(opts) {
|
|
|
126
130
|
endColIndex,
|
|
127
131
|
endRowIndex
|
|
128
132
|
} = rangeState ?? {};
|
|
129
|
-
const
|
|
133
|
+
const rowPasteIds = (0, _utils2.getRowIdsBetween3)(allRows, rowIndexMap, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
|
|
134
|
+
const colPasteds = (0, _utils2.getColIdsBetween1)(leafColumns, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
|
|
135
|
+
const rowSelectIds = (0, _utils2.getRowIdsBetween3)(allRows, rowIndexMap, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
136
|
+
const colSelectIds = (0, _utils2.getColIdsBetween1)(leafColumns, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
130
137
|
leafColumns.forEach((col, colIndex) => {
|
|
131
138
|
if (sizes[colIndex] == null) {
|
|
132
139
|
if (typeof col.width === 'number') {
|
|
@@ -330,11 +337,7 @@ function columnCustom(opts) {
|
|
|
330
337
|
}
|
|
331
338
|
};
|
|
332
339
|
const triggerDragPaste = (pasteState, ctrlKey) => {
|
|
333
|
-
const tmpCols =
|
|
334
|
-
const rowPasteIds = (0, _utils2.getRowIdsBetween3)(allRows, rowIndexMap, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
|
|
335
|
-
const colPasteds = (0, _utils2.getColIdsBetween1)(leafColumns, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
|
|
336
|
-
const rowSelectIds = (0, _utils2.getRowIdsBetween3)(allRows, rowIndexMap, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
337
|
-
const colSelectIds = (0, _utils2.getColIdsBetween1)(leafColumns, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
340
|
+
const tmpCols = leafColumns;
|
|
338
341
|
const dataSelected = []; // data được copy
|
|
339
342
|
|
|
340
343
|
rowSelectIds.forEach(rowId => {
|
|
@@ -342,8 +345,6 @@ function columnCustom(opts) {
|
|
|
342
345
|
if (!row) return;
|
|
343
346
|
const rowData = [];
|
|
344
347
|
colSelectIds.forEach(colId => {
|
|
345
|
-
// const cellll = row.getVisibleCells().find(c => c.column.id === colId);
|
|
346
|
-
|
|
347
348
|
const value = row[colId];
|
|
348
349
|
rowData.push(value !== undefined ? value : '');
|
|
349
350
|
});
|
|
@@ -386,7 +387,7 @@ function columnCustom(opts) {
|
|
|
386
387
|
}
|
|
387
388
|
|
|
388
389
|
// Cập nhật data mới
|
|
389
|
-
const newData = (0, _utils2.flattenArray)(
|
|
390
|
+
const newData = (0, _utils2.flattenArray)(allRows);
|
|
390
391
|
const pastedRows = [];
|
|
391
392
|
if (pasteState.type === 'down' || pasteState.type === 'up') {
|
|
392
393
|
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
@@ -452,20 +453,18 @@ function columnCustom(opts) {
|
|
|
452
453
|
pastedRows.push(newData[targetRow]);
|
|
453
454
|
});
|
|
454
455
|
}
|
|
455
|
-
|
|
456
|
-
const
|
|
456
|
+
|
|
457
|
+
// const rsFilterData = updateOrInsert(flattenArray(dataSource), newData)
|
|
458
|
+
const rsFilterData = (0, _utility.updateOrInsert)(dataSource, newData);
|
|
459
|
+
const rs = (0, _utility.unFlattenData)(rsFilterData);
|
|
457
460
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
458
461
|
pipeline.setStateAtKey(_constants.stateKeyEndCell, endPasteCell);
|
|
459
462
|
pipeline.setStateAtKey(_constants.stateKeyEndPasteCell, undefined);
|
|
460
463
|
pipeline.setStateAtKey(_constants.stateKeyStartPasteCell, undefined);
|
|
461
464
|
};
|
|
462
465
|
const triggerPointPaste = (pasteState, cellStart, cellEnd, ctrlKey) => {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const rowPasteIds = (0, _utils2.getRowIdsBetween3)(allRows, rowIndexMap, cellStart?.rowId ?? '', cellEnd?.rowId ?? '');
|
|
466
|
-
const colPasteds = (0, _utils2.getColIdsBetween1)(leafColumns, cellStart?.colId ?? '', cellEnd?.colId ?? '');
|
|
467
|
-
const rowSelectIds = (0, _utils2.getRowIdsBetween3)(allRows, rowIndexMap, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
468
|
-
const colSelectIds = (0, _utils2.getColIdsBetween1)(leafColumns, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
466
|
+
const rowsPasteId = (0, _utils2.getRowIdsBetween3)(allRows, rowIndexMap, cellStart?.rowId ?? '', cellEnd?.rowId ?? '');
|
|
467
|
+
const colsPastedId = (0, _utils2.getColIdsBetween1)(leafColumns, cellStart?.colId ?? '', cellEnd?.colId ?? '');
|
|
469
468
|
const dataSelected = [];
|
|
470
469
|
rowSelectIds.forEach(rowId => {
|
|
471
470
|
const row = allRows.find(r => r.rowId === rowId);
|
|
@@ -480,21 +479,13 @@ function columnCustom(opts) {
|
|
|
480
479
|
const copyRows = (0, _utils2.flattenData)('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
|
|
481
480
|
|
|
482
481
|
// kéo xuóng
|
|
483
|
-
|
|
484
|
-
const newRange = ctrlKey ? (0, _utils2.addRowsDownWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils2.addRowsDown)(dataSelected, rowPasteIds.length);
|
|
482
|
+
const newRange = ctrlKey ? (0, _utils2.addRowsDownWithCtrl)(dataSelected, rowsPasteId.length) : (0, _utils2.addRowsDown)(dataSelected, rowsPasteId.length);
|
|
485
483
|
|
|
486
484
|
// Cập nhật data mới
|
|
487
|
-
const newData = (0, _utils2.flattenArray)(
|
|
485
|
+
const newData = (0, _utils2.flattenArray)(dataSource);
|
|
488
486
|
const pastedRows = [];
|
|
489
487
|
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
490
|
-
const targetRow = pasteState
|
|
491
|
-
|
|
492
|
-
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
493
|
-
// if (targetRow >= newData.length) {
|
|
494
|
-
|
|
495
|
-
// newData.push({ id: undefined, rowId: newGuid() })
|
|
496
|
-
// }
|
|
497
|
-
|
|
488
|
+
const targetRow = pasteState?.startRowIndex + rowIndex1;
|
|
498
489
|
rowValues.forEach((cellValue, colIndex1) => {
|
|
499
490
|
const targetCol = startColIndex + colIndex1;
|
|
500
491
|
if (targetCol >= leafColumns.length) {
|
|
@@ -511,9 +502,9 @@ function columnCustom(opts) {
|
|
|
511
502
|
// Lưu dòng được paste
|
|
512
503
|
pastedRows.push(newData[targetRow]);
|
|
513
504
|
});
|
|
514
|
-
const rsFilterData = (0,
|
|
515
|
-
const rs = (0,
|
|
516
|
-
triggerPaste?.(pastedRows,
|
|
505
|
+
const rsFilterData = (0, _utility.updateOrInsert)(dataSource, newData);
|
|
506
|
+
const rs = (0, _utility.unFlattenData)(rsFilterData);
|
|
507
|
+
triggerPaste?.(pastedRows, colsPastedId, rs, copyRows);
|
|
517
508
|
};
|
|
518
509
|
const handleMouseDown = (rowId, colId) => {
|
|
519
510
|
pipeline.setStateAtKey(_constants.stateKeyIsSelecting, true);
|
|
@@ -643,6 +634,11 @@ function columnCustom(opts) {
|
|
|
643
634
|
// }
|
|
644
635
|
}
|
|
645
636
|
};
|
|
637
|
+
|
|
638
|
+
// const handleDeleteContent = () => {
|
|
639
|
+
|
|
640
|
+
// }
|
|
641
|
+
|
|
646
642
|
const handleKeyDown = (e, rowId, colId, rowIndex, column, record, editType) => {
|
|
647
643
|
if (e.key === 'Tab') {
|
|
648
644
|
const nextCol = (0, _utils2.getNextColumn)(allCols, focusedCell.colId);
|
|
@@ -776,8 +772,54 @@ function columnCustom(opts) {
|
|
|
776
772
|
}
|
|
777
773
|
return;
|
|
778
774
|
}
|
|
779
|
-
if (e.key === 'Delete') {
|
|
780
|
-
handleDeleteContent?.()
|
|
775
|
+
if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
776
|
+
// handleDeleteContent?.()
|
|
777
|
+
|
|
778
|
+
if (startCell && endCell) {
|
|
779
|
+
const tmpData = (0, _utils2.flattenArray)([...dataSource]);
|
|
780
|
+
const rs = tmpData.map((row, index) => {
|
|
781
|
+
if (!rangeState?.rowRange.includes(row.rowId)) {
|
|
782
|
+
return row;
|
|
783
|
+
}
|
|
784
|
+
const updatedRow = {
|
|
785
|
+
...row
|
|
786
|
+
};
|
|
787
|
+
for (const field of rangeState.colRange) {
|
|
788
|
+
const col = leafColumns.find(it => it.field === field);
|
|
789
|
+
const columnIndex = leafColumns.findIndex(it => it.field === field);
|
|
790
|
+
if ((0, _hooks.isEditable)(col, row)) {
|
|
791
|
+
let newValue = '';
|
|
792
|
+
if (col.type === 'number') {
|
|
793
|
+
newValue = 0;
|
|
794
|
+
}
|
|
795
|
+
if (col.type === 'boolean' || col.type === 'checkbox') {
|
|
796
|
+
newValue = false;
|
|
797
|
+
}
|
|
798
|
+
const cellEditType = (0, _utils2.getEditType)(col, row);
|
|
799
|
+
if (col.type === 'date' || col.type === 'datetime' || col.type === 'time' || col.type === 'month' || col.type === 'week' || col.type === 'year' || col.type === 'quarter' || cellEditType === 'asyncSelect' || cellEditType === 'select' || cellEditType === 'treeSelect' || cellEditType === 'selectTable') {
|
|
800
|
+
newValue = undefined;
|
|
801
|
+
}
|
|
802
|
+
updatedRow[col.field] = newValue;
|
|
803
|
+
handleCellChange({
|
|
804
|
+
key: row[rowKey],
|
|
805
|
+
field: col.field,
|
|
806
|
+
record: updatedRow,
|
|
807
|
+
prevState: row[col.field],
|
|
808
|
+
newState: newValue,
|
|
809
|
+
option: '',
|
|
810
|
+
indexCol: columnIndex,
|
|
811
|
+
indexRow: index,
|
|
812
|
+
type: e.key
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return updatedRow;
|
|
817
|
+
});
|
|
818
|
+
const newData = (0, _utility.unFlattenData)(rs);
|
|
819
|
+
triggerChangeData?.([...newData], {
|
|
820
|
+
type: 'DELETE_CONTENT'
|
|
821
|
+
});
|
|
822
|
+
}
|
|
781
823
|
return;
|
|
782
824
|
}
|
|
783
825
|
if (e.key === 'Enter') {
|
|
@@ -1002,20 +1044,13 @@ function columnCustom(opts) {
|
|
|
1002
1044
|
rowId: rowEnd.id,
|
|
1003
1045
|
colId: column.field
|
|
1004
1046
|
};
|
|
1005
|
-
const
|
|
1006
|
-
const pasteStartRow = allRows[
|
|
1047
|
+
const currentRowIndex = rowIndexMap.get(record.rowId);
|
|
1048
|
+
const pasteStartRow = allRows[currentRowIndex + 1];
|
|
1007
1049
|
const cellStart = {
|
|
1008
1050
|
rowId: pasteStartRow.id,
|
|
1009
1051
|
colId: endCell?.colId ?? ''
|
|
1010
1052
|
};
|
|
1011
|
-
|
|
1012
|
-
// const selectState = getSelectedCellMatrix(table, startCell, cellEnd)
|
|
1013
|
-
|
|
1014
1053
|
const selectPasteState = (0, _utils2.getSelectedCellMatrix1)(allRows, leafColumns, cellStart, cellEnd);
|
|
1015
|
-
|
|
1016
|
-
// setRangeState?.(selectState)
|
|
1017
|
-
// setEndCell?.(cellEnd)
|
|
1018
|
-
|
|
1019
1054
|
pipeline.setStateAtKey(_constants.stateKeyEndCell, cellEnd);
|
|
1020
1055
|
triggerPointPaste(selectPasteState, cellStart, cellEnd, e.ctrlKey);
|
|
1021
1056
|
};
|
|
@@ -1619,6 +1654,28 @@ function columnCustom(opts) {
|
|
|
1619
1654
|
return;
|
|
1620
1655
|
}
|
|
1621
1656
|
if (record.rowId === focusedCell.rowId && col.field === focusedCell.colId && canEdit) {
|
|
1657
|
+
if (onCellClick) {
|
|
1658
|
+
const cellClickCallback = newOptions => {
|
|
1659
|
+
if (newOptions) {
|
|
1660
|
+
pipeline.setStateAtKey(_constants.stateKeyEditCellSettings, {
|
|
1661
|
+
rowId: record.rowId,
|
|
1662
|
+
colId: col.field,
|
|
1663
|
+
editSelectSettings: {
|
|
1664
|
+
...col.editSelectSettings,
|
|
1665
|
+
options: newOptions
|
|
1666
|
+
}
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
onCellClick({
|
|
1671
|
+
index: rowIndex,
|
|
1672
|
+
rowId: record.rowId,
|
|
1673
|
+
cellValue: value,
|
|
1674
|
+
type: "Editing",
|
|
1675
|
+
field: col.field,
|
|
1676
|
+
rowData: record
|
|
1677
|
+
}, cellClickCallback);
|
|
1678
|
+
}
|
|
1622
1679
|
handleEdit(e, record, col, editType ?? 'text', false);
|
|
1623
1680
|
}
|
|
1624
1681
|
},
|
|
@@ -1697,7 +1754,10 @@ function columnCustom(opts) {
|
|
|
1697
1754
|
},
|
|
1698
1755
|
// children: ''
|
|
1699
1756
|
children: canEdit && cellEditing ? /*#__PURE__*/_react.default.createElement(_EditCell.default, {
|
|
1700
|
-
column: col
|
|
1757
|
+
column: editCellSettings?.rowId === record.rowId && editCellSettings?.colId === col.field ? {
|
|
1758
|
+
...col,
|
|
1759
|
+
editSelectSettings: editCellSettings.editSelectSettings
|
|
1760
|
+
} : col,
|
|
1701
1761
|
editType: editType ?? 'text',
|
|
1702
1762
|
record: record,
|
|
1703
1763
|
tableId: id,
|
|
@@ -10,6 +10,7 @@ export declare const stateKeyIsEditing = "isEditing";
|
|
|
10
10
|
export declare const stateKeyStartPasteCell = "startPasteCell";
|
|
11
11
|
export declare const stateKeyEndPasteCell = "endPasteCell";
|
|
12
12
|
export declare const stateKeyIsSelecting = "isSelecting";
|
|
13
|
+
export declare const stateKeyEditCellSettings = "editCellSettings";
|
|
13
14
|
export declare const stateKeyIsPasting = "isPasting";
|
|
14
15
|
export declare const stateKeyEndCell = "endCell";
|
|
15
16
|
export declare const stateKeyStartCell = "startCell";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.stateKeyVisible = exports.stateKeyTypePaste = exports.stateKeyTooltip = exports.stateKeyStartPasteCell = exports.stateKeyStartCell = exports.stateKeySorter = exports.stateKeyResize = exports.stateKeyPagination = exports.stateKeyIsSelecting = exports.stateKeyIsPasting = exports.stateKeyIsEditing = exports.stateKeyFocusedCell = exports.stateKeyFilter = exports.stateKeyEndPasteCell = exports.stateKeyEndCell = exports.stateKeyColumnFilter = void 0;
|
|
6
|
+
exports.stateKeyVisible = exports.stateKeyTypePaste = exports.stateKeyTooltip = exports.stateKeyStartPasteCell = exports.stateKeyStartCell = exports.stateKeySorter = exports.stateKeyResize = exports.stateKeyPagination = exports.stateKeyIsSelecting = exports.stateKeyIsPasting = exports.stateKeyIsEditing = exports.stateKeyFocusedCell = exports.stateKeyFilter = exports.stateKeyEndPasteCell = exports.stateKeyEndCell = exports.stateKeyEditCellSettings = exports.stateKeyColumnFilter = void 0;
|
|
7
7
|
const stateKeyResize = exports.stateKeyResize = 'columnResize';
|
|
8
8
|
const stateKeyFilter = exports.stateKeyFilter = 'columnsFilter';
|
|
9
9
|
const stateKeySorter = exports.stateKeySorter = 'columnsSorter';
|
|
@@ -21,6 +21,7 @@ const stateKeyIsEditing = exports.stateKeyIsEditing = 'isEditing';
|
|
|
21
21
|
const stateKeyStartPasteCell = exports.stateKeyStartPasteCell = 'startPasteCell';
|
|
22
22
|
const stateKeyEndPasteCell = exports.stateKeyEndPasteCell = 'endPasteCell';
|
|
23
23
|
const stateKeyIsSelecting = exports.stateKeyIsSelecting = 'isSelecting';
|
|
24
|
+
const stateKeyEditCellSettings = exports.stateKeyEditCellSettings = 'editCellSettings';
|
|
24
25
|
const stateKeyIsPasting = exports.stateKeyIsPasting = 'isPasting';
|
|
25
26
|
const stateKeyEndCell = exports.stateKeyEndCell = 'endCell';
|
|
26
27
|
const stateKeyStartCell = exports.stateKeyStartCell = 'startCell';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TreeDataNode } from "rc-master-ui";
|
|
2
|
-
import { ColumnTable } from "../../grid-component";
|
|
1
|
+
import type { TreeDataNode } from "rc-master-ui";
|
|
2
|
+
import type { ColumnTable } from "../../grid-component";
|
|
3
3
|
export declare function convertColumnsToTreeData(columns: ColumnTable[], groupColumns?: string[], t?: any): TreeDataNode[];
|
|
4
4
|
export declare function filterColumnsByField(columns: ColumnTable[], fieldList: string[]): ColumnTable[];
|
|
5
5
|
export declare function filterVisibleColumns(columns: ColumnTable[]): ColumnTable[];
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.convertColumnsToTreeData = convertColumnsToTreeData;
|
|
7
7
|
exports.filterColumnsByField = filterColumnsByField;
|
|
8
8
|
exports.filterVisibleColumns = filterVisibleColumns;
|
|
9
|
-
// import type { ColumnTable } from "../../table-component"
|
|
10
|
-
|
|
11
9
|
function convertColumnsToTreeData(columns, groupColumns, t) {
|
|
12
10
|
if (!columns) {
|
|
13
11
|
return [];
|
|
@@ -65,6 +63,7 @@ function filterColumnsByField(columns, fieldList) {
|
|
|
65
63
|
if (fieldSet.has(col.field) || nextChildren && nextChildren.length) {
|
|
66
64
|
result.push({
|
|
67
65
|
...col,
|
|
66
|
+
visible: true,
|
|
68
67
|
...(nextChildren ? {
|
|
69
68
|
children: nextChildren
|
|
70
69
|
} : {})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FilterItem, Sorter } from "../../grid-component/type";
|
|
1
|
+
import type { AnyObject, ColumnTable, FilterItem, RowDnd, Sorter } from "../../grid-component/type";
|
|
2
2
|
type PreparedFilter = FilterItem & {
|
|
3
3
|
normalizedValue: any;
|
|
4
4
|
operatorLower: string;
|
|
@@ -10,4 +10,18 @@ export declare function sortData(data: any[], sorter: Sorter[]): any[];
|
|
|
10
10
|
export declare function filterDataByColumns1(data: any[], queries: FilterItem[] | undefined, sorter: Sorter[] | undefined, keysFilter: string[] | undefined, ignoreAccents?: boolean): any[];
|
|
11
11
|
export declare const getMaxDepth: (data: any[]) => number;
|
|
12
12
|
export declare const addRowIdArray: (inputArray: any[]) => any[];
|
|
13
|
+
export declare const unFlattenData: <RecordType extends AnyObject = AnyObject>(data: RecordType[]) => RecordType[];
|
|
14
|
+
export declare const flattenArray: <RecordType extends AnyObject = AnyObject>(arr: any[]) => RecordType[];
|
|
15
|
+
export declare function updateOrInsert1(dataArray: any[], dataFilter: any[]): any[];
|
|
16
|
+
export declare function updateOrInsert3<T extends {
|
|
17
|
+
rowId: PropertyKey;
|
|
18
|
+
}>(dataArray: T[], dataFilter: Partial<T>[]): T[];
|
|
19
|
+
type Row = {
|
|
20
|
+
rowId: number;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
export declare function updateOrInsert<T extends Row>(dataArray: T[], dataFilter: Partial<T>[]): T[];
|
|
24
|
+
export declare function filterVisibleColumns<T extends ColumnTable>(columns: T[]): T[];
|
|
25
|
+
export declare const sortByType: (arr: ColumnTable[], rowDnd?: RowDnd) => ColumnTable[];
|
|
26
|
+
export declare function getVisibleColumnFields<T extends ColumnTable>(columns: T[]): string[];
|
|
13
27
|
export {};
|