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
|
@@ -469,7 +469,9 @@ const EditCell = props => {
|
|
|
469
469
|
align: colSelect.textAlign
|
|
470
470
|
};
|
|
471
471
|
});
|
|
472
|
-
|
|
472
|
+
|
|
473
|
+
// let valueSelectTable = formValues[dataIndex]
|
|
474
|
+
let valueSelectTable = formValues[dataIndex] !== null ? formValues[dataIndex] : undefined;
|
|
473
475
|
if (fieldValue) {
|
|
474
476
|
// @ts-ignore
|
|
475
477
|
valueSelectTable = record[fieldValue] ?? formValues[dataIndex];
|
|
@@ -618,14 +620,16 @@ const EditCell = props => {
|
|
|
618
620
|
"data-tooltip-id": `${tableId}-tooltip-error`
|
|
619
621
|
});
|
|
620
622
|
case 'select':
|
|
621
|
-
let valueSelect = formValues[dataIndex];
|
|
623
|
+
let valueSelect = formValues[dataIndex] !== null ? formValues[dataIndex] : undefined;
|
|
624
|
+
// let valueSelect = !isNullOrUndefined(formValues[dataIndex]) ? formValues[dataIndex] : undefined
|
|
625
|
+
|
|
622
626
|
if (fieldValue) {
|
|
623
627
|
// @ts-ignore
|
|
624
628
|
valueSelect = record[fieldValue] ?? formValues[dataIndex];
|
|
625
629
|
}
|
|
626
630
|
return /*#__PURE__*/React.createElement(Select, {
|
|
627
631
|
options: options,
|
|
628
|
-
value: valueSelect ??
|
|
632
|
+
value: valueSelect ?? undefined,
|
|
629
633
|
onChange: (val, option) => {
|
|
630
634
|
onChange(val ?? '');
|
|
631
635
|
const formState = getValues();
|
|
@@ -761,7 +765,8 @@ const EditCell = props => {
|
|
|
761
765
|
"data-tooltip-id": `${tableId}-tooltip-error`
|
|
762
766
|
});
|
|
763
767
|
case 'asyncSelect':
|
|
764
|
-
let valueAsyncSelect = formValues[dataIndex]
|
|
768
|
+
// let valueAsyncSelect = formValues[dataIndex]
|
|
769
|
+
let valueAsyncSelect = formValues[dataIndex] !== null ? formValues[dataIndex] : undefined;
|
|
765
770
|
if (fieldValue) {
|
|
766
771
|
// @ts-ignore
|
|
767
772
|
valueAsyncSelect = record[fieldValue] ?? formValues[dataIndex];
|
|
@@ -769,7 +774,7 @@ const EditCell = props => {
|
|
|
769
774
|
return /*#__PURE__*/React.createElement(AsyncSelect, {
|
|
770
775
|
options: options,
|
|
771
776
|
defaultOptions: options,
|
|
772
|
-
value: valueAsyncSelect
|
|
777
|
+
value: valueAsyncSelect,
|
|
773
778
|
onChange: (val, option) => {
|
|
774
779
|
onChange(val ?? '');
|
|
775
780
|
const formState = getValues();
|
|
@@ -1237,7 +1242,10 @@ const EditCell = props => {
|
|
|
1237
1242
|
}
|
|
1238
1243
|
};
|
|
1239
1244
|
return /*#__PURE__*/React.createElement("form", {
|
|
1240
|
-
onSubmit: handleSubmit(onSubmit)
|
|
1245
|
+
onSubmit: handleSubmit(onSubmit),
|
|
1246
|
+
style: {
|
|
1247
|
+
height: '100%'
|
|
1248
|
+
}
|
|
1241
1249
|
}, /*#__PURE__*/React.createElement(Controller, {
|
|
1242
1250
|
name: dataIndex,
|
|
1243
1251
|
control: control,
|
|
@@ -292,7 +292,7 @@ export const renderFilter = args => {
|
|
|
292
292
|
,
|
|
293
293
|
onBlur: e => {
|
|
294
294
|
if (selectedKeys[0] === e.target.value) {} else {
|
|
295
|
-
setSelectedKeys(e.target.value ? [e.target.value] : []);
|
|
295
|
+
setSelectedKeys(e.target.value ? [e.target.value.trim()] : []);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
|
|
@@ -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 {};
|
|
@@ -3,20 +3,25 @@ import { internals } from "../../internals";
|
|
|
3
3
|
import { collectNodes, makeRecursiveMapper, mergeCellProps } from "../../utils";
|
|
4
4
|
import Resizer from "../../base-table/ColumnResizer";
|
|
5
5
|
import { ArrowDown, ArrowUp, FilterFill, SortCancel } from 'becoxy-icons';
|
|
6
|
-
import { booleanOperator, findItemPath, isEditable, isObjEmpty, nonActionColumn, numberOperator, pageSizeOptions, stringOperator, translateOption, updateArrayByKey
|
|
6
|
+
import { booleanOperator, findItemPath, isEditable, isObjEmpty, nonActionColumn, numberOperator, pageSizeOptions, stringOperator, translateOption, updateArrayByKey
|
|
7
|
+
// updateOrInsert
|
|
8
|
+
} from "../../../grid-component/hooks";
|
|
7
9
|
import classNames from 'classnames';
|
|
8
10
|
import { Dropdown, Select, Space, Button } from 'rc-master-ui';
|
|
9
|
-
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, convertFilters, extendsObject, flattenArray, flattenData, getColIdsBetween1, getDefaultOperator, getDragRightData, getKeys, getNextColumn, getNextColumn1, getPrevColumn, getRowIdsBetween3,
|
|
11
|
+
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, convertFilters, extendsObject, flattenArray, flattenData, getColIdsBetween1, getDefaultOperator, getDragRightData, getEditType, getKeys, getNextColumn, getNextColumn1, getPrevColumn, getRowIdsBetween3,
|
|
12
|
+
// getRowIndexMap,
|
|
13
|
+
getSelectedCellMatrix1, getTypeFilter,
|
|
10
14
|
// isObjEqual,
|
|
11
|
-
newGuid
|
|
15
|
+
newGuid } from "../../../table-component/hook/utils";
|
|
12
16
|
import { renderFilter } from "../../base-table/renderFilter";
|
|
13
17
|
import { renderValueCell } from "../../../table-component/hook/useColumns";
|
|
14
18
|
import EditCell from "../../base-table/cell/EditCell";
|
|
15
19
|
import HeaderEditCell from "../../base-table/cell/HeaderEditCell";
|
|
16
20
|
import { stateKeyResize, stateKeyColumnFilter, stateKeyFilter, stateKeyPagination, stateKeySorter, stateKeyTooltip, stateKeyTypePaste, stateKeyVisible,
|
|
17
21
|
// state For edit
|
|
18
|
-
stateKeyEndCell, stateKeyEndPasteCell, stateKeyStartCell, stateKeyStartPasteCell, stateKeyFocusedCell, stateKeyIsEditing, stateKeyIsPasting, stateKeyIsSelecting } from "../../utils/constants";
|
|
22
|
+
stateKeyEndCell, stateKeyEndPasteCell, stateKeyStartCell, stateKeyStartPasteCell, stateKeyFocusedCell, stateKeyEditCellSettings, stateKeyIsEditing, stateKeyIsPasting, stateKeyIsSelecting } from "../../utils/constants";
|
|
19
23
|
import { getColumnsAtLevel } from "../../base-table/utils";
|
|
24
|
+
import { unFlattenData, updateOrInsert } from "../../utils/utility";
|
|
20
25
|
// import { getMaxDepth } from '../../utils/utility';
|
|
21
26
|
|
|
22
27
|
function clamp(min, x, max) {
|
|
@@ -53,7 +58,7 @@ export function columnCustom(opts) {
|
|
|
53
58
|
control,
|
|
54
59
|
getValues,
|
|
55
60
|
errors,
|
|
56
|
-
|
|
61
|
+
triggerChangeData,
|
|
57
62
|
tableRef,
|
|
58
63
|
triggerPaste,
|
|
59
64
|
handleSubmit,
|
|
@@ -62,7 +67,9 @@ export function columnCustom(opts) {
|
|
|
62
67
|
handleHeaderCellChange,
|
|
63
68
|
dataErrors,
|
|
64
69
|
headerData,
|
|
65
|
-
headerEditAble
|
|
70
|
+
headerEditAble,
|
|
71
|
+
rowIndexMap,
|
|
72
|
+
onCellClick
|
|
66
73
|
// originData
|
|
67
74
|
|
|
68
75
|
// currentPage = 1,
|
|
@@ -73,6 +80,7 @@ export function columnCustom(opts) {
|
|
|
73
80
|
mode = 'multiple',
|
|
74
81
|
onSorter
|
|
75
82
|
} = opts;
|
|
83
|
+
const rowKey = 'rowId';
|
|
76
84
|
return function columnResizeFeature(pipeline) {
|
|
77
85
|
// State table
|
|
78
86
|
|
|
@@ -93,7 +101,6 @@ export function columnCustom(opts) {
|
|
|
93
101
|
const originCols = pipeline.getColumns();
|
|
94
102
|
const rowIds = getKeys(allRows, 'rowId');
|
|
95
103
|
const colIds = getKeys(leafColumns, 'field');
|
|
96
|
-
const rowIndexMap = getRowIndexMap(allRows);
|
|
97
104
|
|
|
98
105
|
// const deppthCols = getMaxDepth(originCols)
|
|
99
106
|
|
|
@@ -105,6 +112,7 @@ export function columnCustom(opts) {
|
|
|
105
112
|
|
|
106
113
|
const focusedCell = pipeline.getStateAtKey(stateKeyFocusedCell) ?? {};
|
|
107
114
|
const isEditing = pipeline.getStateAtKey(stateKeyIsEditing) ?? false;
|
|
115
|
+
const editCellSettings = pipeline.getStateAtKey(stateKeyEditCellSettings);
|
|
108
116
|
const isSelecting = pipeline.getStateAtKey(stateKeyIsSelecting) ?? false;
|
|
109
117
|
const isPasting = pipeline.getStateAtKey(stateKeyIsPasting) ?? false;
|
|
110
118
|
const startCell = pipeline.getStateAtKey(stateKeyStartCell) ?? undefined;
|
|
@@ -123,7 +131,10 @@ export function columnCustom(opts) {
|
|
|
123
131
|
endColIndex,
|
|
124
132
|
endRowIndex
|
|
125
133
|
} = rangeState ?? {};
|
|
126
|
-
const
|
|
134
|
+
const rowPasteIds = getRowIdsBetween3(allRows, rowIndexMap, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
|
|
135
|
+
const colPasteds = getColIdsBetween1(leafColumns, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
|
|
136
|
+
const rowSelectIds = getRowIdsBetween3(allRows, rowIndexMap, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
137
|
+
const colSelectIds = getColIdsBetween1(leafColumns, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
127
138
|
leafColumns.forEach((col, colIndex) => {
|
|
128
139
|
if (sizes[colIndex] == null) {
|
|
129
140
|
if (typeof col.width === 'number') {
|
|
@@ -327,11 +338,7 @@ export function columnCustom(opts) {
|
|
|
327
338
|
}
|
|
328
339
|
};
|
|
329
340
|
const triggerDragPaste = (pasteState, ctrlKey) => {
|
|
330
|
-
const tmpCols =
|
|
331
|
-
const rowPasteIds = getRowIdsBetween3(allRows, rowIndexMap, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
|
|
332
|
-
const colPasteds = getColIdsBetween1(leafColumns, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
|
|
333
|
-
const rowSelectIds = getRowIdsBetween3(allRows, rowIndexMap, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
334
|
-
const colSelectIds = getColIdsBetween1(leafColumns, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
341
|
+
const tmpCols = leafColumns;
|
|
335
342
|
const dataSelected = []; // data được copy
|
|
336
343
|
|
|
337
344
|
rowSelectIds.forEach(rowId => {
|
|
@@ -339,8 +346,6 @@ export function columnCustom(opts) {
|
|
|
339
346
|
if (!row) return;
|
|
340
347
|
const rowData = [];
|
|
341
348
|
colSelectIds.forEach(colId => {
|
|
342
|
-
// const cellll = row.getVisibleCells().find(c => c.column.id === colId);
|
|
343
|
-
|
|
344
349
|
const value = row[colId];
|
|
345
350
|
rowData.push(value !== undefined ? value : '');
|
|
346
351
|
});
|
|
@@ -383,7 +388,7 @@ export function columnCustom(opts) {
|
|
|
383
388
|
}
|
|
384
389
|
|
|
385
390
|
// Cập nhật data mới
|
|
386
|
-
const newData = flattenArray(
|
|
391
|
+
const newData = flattenArray(allRows);
|
|
387
392
|
const pastedRows = [];
|
|
388
393
|
if (pasteState.type === 'down' || pasteState.type === 'up') {
|
|
389
394
|
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
@@ -449,7 +454,9 @@ export function columnCustom(opts) {
|
|
|
449
454
|
pastedRows.push(newData[targetRow]);
|
|
450
455
|
});
|
|
451
456
|
}
|
|
452
|
-
|
|
457
|
+
|
|
458
|
+
// const rsFilterData = updateOrInsert(flattenArray(dataSource), newData)
|
|
459
|
+
const rsFilterData = updateOrInsert(dataSource, newData);
|
|
453
460
|
const rs = unFlattenData(rsFilterData);
|
|
454
461
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
455
462
|
pipeline.setStateAtKey(stateKeyEndCell, endPasteCell);
|
|
@@ -457,12 +464,8 @@ export function columnCustom(opts) {
|
|
|
457
464
|
pipeline.setStateAtKey(stateKeyStartPasteCell, undefined);
|
|
458
465
|
};
|
|
459
466
|
const triggerPointPaste = (pasteState, cellStart, cellEnd, ctrlKey) => {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
const rowPasteIds = getRowIdsBetween3(allRows, rowIndexMap, cellStart?.rowId ?? '', cellEnd?.rowId ?? '');
|
|
463
|
-
const colPasteds = getColIdsBetween1(leafColumns, cellStart?.colId ?? '', cellEnd?.colId ?? '');
|
|
464
|
-
const rowSelectIds = getRowIdsBetween3(allRows, rowIndexMap, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
465
|
-
const colSelectIds = getColIdsBetween1(leafColumns, startCell?.colId ?? '', endCell?.colId ?? '');
|
|
467
|
+
const rowsPasteId = getRowIdsBetween3(allRows, rowIndexMap, cellStart?.rowId ?? '', cellEnd?.rowId ?? '');
|
|
468
|
+
const colsPastedId = getColIdsBetween1(leafColumns, cellStart?.colId ?? '', cellEnd?.colId ?? '');
|
|
466
469
|
const dataSelected = [];
|
|
467
470
|
rowSelectIds.forEach(rowId => {
|
|
468
471
|
const row = allRows.find(r => r.rowId === rowId);
|
|
@@ -477,21 +480,13 @@ export function columnCustom(opts) {
|
|
|
477
480
|
const copyRows = flattenData('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
|
|
478
481
|
|
|
479
482
|
// kéo xuóng
|
|
480
|
-
|
|
481
|
-
const newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length);
|
|
483
|
+
const newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowsPasteId.length) : addRowsDown(dataSelected, rowsPasteId.length);
|
|
482
484
|
|
|
483
485
|
// Cập nhật data mới
|
|
484
|
-
const newData = flattenArray(
|
|
486
|
+
const newData = flattenArray(dataSource);
|
|
485
487
|
const pastedRows = [];
|
|
486
488
|
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
487
|
-
const targetRow = pasteState
|
|
488
|
-
|
|
489
|
-
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
490
|
-
// if (targetRow >= newData.length) {
|
|
491
|
-
|
|
492
|
-
// newData.push({ id: undefined, rowId: newGuid() })
|
|
493
|
-
// }
|
|
494
|
-
|
|
489
|
+
const targetRow = pasteState?.startRowIndex + rowIndex1;
|
|
495
490
|
rowValues.forEach((cellValue, colIndex1) => {
|
|
496
491
|
const targetCol = startColIndex + colIndex1;
|
|
497
492
|
if (targetCol >= leafColumns.length) {
|
|
@@ -508,9 +503,9 @@ export function columnCustom(opts) {
|
|
|
508
503
|
// Lưu dòng được paste
|
|
509
504
|
pastedRows.push(newData[targetRow]);
|
|
510
505
|
});
|
|
511
|
-
const rsFilterData = updateOrInsert(
|
|
506
|
+
const rsFilterData = updateOrInsert(dataSource, newData);
|
|
512
507
|
const rs = unFlattenData(rsFilterData);
|
|
513
|
-
triggerPaste?.(pastedRows,
|
|
508
|
+
triggerPaste?.(pastedRows, colsPastedId, rs, copyRows);
|
|
514
509
|
};
|
|
515
510
|
const handleMouseDown = (rowId, colId) => {
|
|
516
511
|
pipeline.setStateAtKey(stateKeyIsSelecting, true);
|
|
@@ -640,6 +635,11 @@ export function columnCustom(opts) {
|
|
|
640
635
|
// }
|
|
641
636
|
}
|
|
642
637
|
};
|
|
638
|
+
|
|
639
|
+
// const handleDeleteContent = () => {
|
|
640
|
+
|
|
641
|
+
// }
|
|
642
|
+
|
|
643
643
|
const handleKeyDown = (e, rowId, colId, rowIndex, column, record, editType) => {
|
|
644
644
|
if (e.key === 'Tab') {
|
|
645
645
|
const nextCol = getNextColumn(allCols, focusedCell.colId);
|
|
@@ -773,8 +773,54 @@ export function columnCustom(opts) {
|
|
|
773
773
|
}
|
|
774
774
|
return;
|
|
775
775
|
}
|
|
776
|
-
if (e.key === 'Delete') {
|
|
777
|
-
handleDeleteContent?.()
|
|
776
|
+
if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
777
|
+
// handleDeleteContent?.()
|
|
778
|
+
|
|
779
|
+
if (startCell && endCell) {
|
|
780
|
+
const tmpData = flattenArray([...dataSource]);
|
|
781
|
+
const rs = tmpData.map((row, index) => {
|
|
782
|
+
if (!rangeState?.rowRange.includes(row.rowId)) {
|
|
783
|
+
return row;
|
|
784
|
+
}
|
|
785
|
+
const updatedRow = {
|
|
786
|
+
...row
|
|
787
|
+
};
|
|
788
|
+
for (const field of rangeState.colRange) {
|
|
789
|
+
const col = leafColumns.find(it => it.field === field);
|
|
790
|
+
const columnIndex = leafColumns.findIndex(it => it.field === field);
|
|
791
|
+
if (isEditable(col, row)) {
|
|
792
|
+
let newValue = '';
|
|
793
|
+
if (col.type === 'number') {
|
|
794
|
+
newValue = 0;
|
|
795
|
+
}
|
|
796
|
+
if (col.type === 'boolean' || col.type === 'checkbox') {
|
|
797
|
+
newValue = false;
|
|
798
|
+
}
|
|
799
|
+
const cellEditType = getEditType(col, row);
|
|
800
|
+
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') {
|
|
801
|
+
newValue = undefined;
|
|
802
|
+
}
|
|
803
|
+
updatedRow[col.field] = newValue;
|
|
804
|
+
handleCellChange({
|
|
805
|
+
key: row[rowKey],
|
|
806
|
+
field: col.field,
|
|
807
|
+
record: updatedRow,
|
|
808
|
+
prevState: row[col.field],
|
|
809
|
+
newState: newValue,
|
|
810
|
+
option: '',
|
|
811
|
+
indexCol: columnIndex,
|
|
812
|
+
indexRow: index,
|
|
813
|
+
type: e.key
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return updatedRow;
|
|
818
|
+
});
|
|
819
|
+
const newData = unFlattenData(rs);
|
|
820
|
+
triggerChangeData?.([...newData], {
|
|
821
|
+
type: 'DELETE_CONTENT'
|
|
822
|
+
});
|
|
823
|
+
}
|
|
778
824
|
return;
|
|
779
825
|
}
|
|
780
826
|
if (e.key === 'Enter') {
|
|
@@ -999,20 +1045,13 @@ export function columnCustom(opts) {
|
|
|
999
1045
|
rowId: rowEnd.id,
|
|
1000
1046
|
colId: column.field
|
|
1001
1047
|
};
|
|
1002
|
-
const
|
|
1003
|
-
const pasteStartRow = allRows[
|
|
1048
|
+
const currentRowIndex = rowIndexMap.get(record.rowId);
|
|
1049
|
+
const pasteStartRow = allRows[currentRowIndex + 1];
|
|
1004
1050
|
const cellStart = {
|
|
1005
1051
|
rowId: pasteStartRow.id,
|
|
1006
1052
|
colId: endCell?.colId ?? ''
|
|
1007
1053
|
};
|
|
1008
|
-
|
|
1009
|
-
// const selectState = getSelectedCellMatrix(table, startCell, cellEnd)
|
|
1010
|
-
|
|
1011
1054
|
const selectPasteState = getSelectedCellMatrix1(allRows, leafColumns, cellStart, cellEnd);
|
|
1012
|
-
|
|
1013
|
-
// setRangeState?.(selectState)
|
|
1014
|
-
// setEndCell?.(cellEnd)
|
|
1015
|
-
|
|
1016
1055
|
pipeline.setStateAtKey(stateKeyEndCell, cellEnd);
|
|
1017
1056
|
triggerPointPaste(selectPasteState, cellStart, cellEnd, e.ctrlKey);
|
|
1018
1057
|
};
|
|
@@ -1616,6 +1655,28 @@ export function columnCustom(opts) {
|
|
|
1616
1655
|
return;
|
|
1617
1656
|
}
|
|
1618
1657
|
if (record.rowId === focusedCell.rowId && col.field === focusedCell.colId && canEdit) {
|
|
1658
|
+
if (onCellClick) {
|
|
1659
|
+
const cellClickCallback = newOptions => {
|
|
1660
|
+
if (newOptions) {
|
|
1661
|
+
pipeline.setStateAtKey(stateKeyEditCellSettings, {
|
|
1662
|
+
rowId: record.rowId,
|
|
1663
|
+
colId: col.field,
|
|
1664
|
+
editSelectSettings: {
|
|
1665
|
+
...col.editSelectSettings,
|
|
1666
|
+
options: newOptions
|
|
1667
|
+
}
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
onCellClick({
|
|
1672
|
+
index: rowIndex,
|
|
1673
|
+
rowId: record.rowId,
|
|
1674
|
+
cellValue: value,
|
|
1675
|
+
type: "Editing",
|
|
1676
|
+
field: col.field,
|
|
1677
|
+
rowData: record
|
|
1678
|
+
}, cellClickCallback);
|
|
1679
|
+
}
|
|
1619
1680
|
handleEdit(e, record, col, editType ?? 'text', false);
|
|
1620
1681
|
}
|
|
1621
1682
|
},
|
|
@@ -1694,7 +1755,10 @@ export function columnCustom(opts) {
|
|
|
1694
1755
|
},
|
|
1695
1756
|
// children: ''
|
|
1696
1757
|
children: canEdit && cellEditing ? /*#__PURE__*/React.createElement(EditCell, {
|
|
1697
|
-
column: col
|
|
1758
|
+
column: editCellSettings?.rowId === record.rowId && editCellSettings?.colId === col.field ? {
|
|
1759
|
+
...col,
|
|
1760
|
+
editSelectSettings: editCellSettings.editSelectSettings
|
|
1761
|
+
} : col,
|
|
1698
1762
|
editType: editType ?? 'text',
|
|
1699
1763
|
record: record,
|
|
1700
1764
|
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";
|
|
@@ -15,6 +15,7 @@ export const stateKeyIsEditing = 'isEditing';
|
|
|
15
15
|
export const stateKeyStartPasteCell = 'startPasteCell';
|
|
16
16
|
export const stateKeyEndPasteCell = 'endPasteCell';
|
|
17
17
|
export const stateKeyIsSelecting = 'isSelecting';
|
|
18
|
+
export const stateKeyEditCellSettings = 'editCellSettings';
|
|
18
19
|
export const stateKeyIsPasting = 'isPasting';
|
|
19
20
|
export const stateKeyEndCell = 'endCell';
|
|
20
21
|
export const 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[];
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// import type { ColumnTable } from "../../table-component"
|
|
2
|
-
|
|
3
1
|
export function convertColumnsToTreeData(columns, groupColumns, t) {
|
|
4
2
|
if (!columns) {
|
|
5
3
|
return [];
|
|
@@ -57,6 +55,7 @@ export function filterColumnsByField(columns, fieldList) {
|
|
|
57
55
|
if (fieldSet.has(col.field) || nextChildren && nextChildren.length) {
|
|
58
56
|
result.push({
|
|
59
57
|
...col,
|
|
58
|
+
visible: true,
|
|
60
59
|
...(nextChildren ? {
|
|
61
60
|
children: nextChildren
|
|
62
61
|
} : {})
|
|
@@ -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 {};
|