es-grid-template 1.4.0 → 1.4.1
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/InternalTable.js +2 -2
- package/es/grid-component/TableGrid.js +44 -41
- package/es/grid-component/hooks/useColumns.js +3 -2
- package/es/grid-component/hooks/utils.d.ts +16 -1
- package/es/grid-component/hooks/utils.js +21 -2
- package/es/grid-component/styles.scss +13 -13
- package/es/grid-component/table/GridEdit.js +36 -21
- package/lib/grid-component/InternalTable.js +2 -2
- package/lib/grid-component/TableGrid.js +43 -40
- package/lib/grid-component/hooks/useColumns.js +2 -1
- package/lib/grid-component/hooks/utils.d.ts +16 -1
- package/lib/grid-component/hooks/utils.js +23 -3
- package/lib/grid-component/styles.scss +13 -13
- package/lib/grid-component/table/GridEdit.js +35 -20
- package/package.json +109 -109
|
@@ -92,8 +92,8 @@ const InternalTable = props => {
|
|
|
92
92
|
...rest
|
|
93
93
|
} = props;
|
|
94
94
|
const rowKey = React.useMemo(() => {
|
|
95
|
-
return
|
|
96
|
-
}, [
|
|
95
|
+
return propRowKey ?? 'rowId';
|
|
96
|
+
}, [propRowKey]);
|
|
97
97
|
const local = lang && lang === 'en' ? en : vi;
|
|
98
98
|
const buddhistLocale = {
|
|
99
99
|
...local,
|
|
@@ -12,7 +12,7 @@ import classNames from "classnames";
|
|
|
12
12
|
import { checkDecimalSeparator, checkThousandSeparator,
|
|
13
13
|
// filterDataByColumns2,
|
|
14
14
|
// filterDataByColumns3,
|
|
15
|
-
filterDataByColumns4,
|
|
15
|
+
filterDataByColumns4, getFormat,
|
|
16
16
|
// convertFlatColumn,
|
|
17
17
|
isEmpty,
|
|
18
18
|
// newGuid,
|
|
@@ -413,46 +413,6 @@ const TableGrid = props => {
|
|
|
413
413
|
// }}
|
|
414
414
|
,
|
|
415
415
|
|
|
416
|
-
summary: () => {
|
|
417
|
-
if (typeof summary === 'function') {
|
|
418
|
-
return summary(dataSource);
|
|
419
|
-
}
|
|
420
|
-
if (!summary) {
|
|
421
|
-
return undefined;
|
|
422
|
-
}
|
|
423
|
-
return /*#__PURE__*/React.createElement(Table.Summary, {
|
|
424
|
-
fixed: true
|
|
425
|
-
}, /*#__PURE__*/React.createElement(Table.Summary.Row, null, flatColumns(!!mode ? [Table.SELECTION_COLUMN, ...columns] : [...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
426
|
-
const cellFormat = col.format ? typeof col.format === 'function' ? col.format({}) : col.format : format;
|
|
427
|
-
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
428
|
-
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
429
|
-
|
|
430
|
-
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
431
|
-
const dec = cellFormat?.decimalScale;
|
|
432
|
-
const sumValue = col.type === 'number' ? sumDataByField(dataSource, col?.key) : 0;
|
|
433
|
-
const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
434
|
-
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
435
|
-
const numericFormatProps = {
|
|
436
|
-
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
437
|
-
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
438
|
-
allowNegative: cellFormat?.allowNegative ?? false,
|
|
439
|
-
prefix: cellFormat?.prefix,
|
|
440
|
-
suffix: cellFormat?.suffix,
|
|
441
|
-
decimalScale: dec,
|
|
442
|
-
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
443
|
-
};
|
|
444
|
-
return /*#__PURE__*/React.createElement(Table.Summary.Cell, {
|
|
445
|
-
key: col.key,
|
|
446
|
-
index: index,
|
|
447
|
-
align: col.align ?? 'right',
|
|
448
|
-
className: 'ui-rc-table-cell-ellipsis'
|
|
449
|
-
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : numericFormatter(cellValue, numericFormatProps));
|
|
450
|
-
})));
|
|
451
|
-
},
|
|
452
|
-
pagination: !pagination || pagination && pagination?.onChange ? false : {
|
|
453
|
-
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
454
|
-
...pagination
|
|
455
|
-
},
|
|
456
416
|
onFilter: val => {
|
|
457
417
|
handleOnFilter(val);
|
|
458
418
|
// triggerFilter?.(convertFilters(val))
|
|
@@ -507,6 +467,49 @@ const TableGrid = props => {
|
|
|
507
467
|
},
|
|
508
468
|
expandable: {
|
|
509
469
|
...expandable
|
|
470
|
+
},
|
|
471
|
+
summary: () => {
|
|
472
|
+
if (typeof summary === 'function') {
|
|
473
|
+
return summary(dataSource);
|
|
474
|
+
}
|
|
475
|
+
if (!summary) {
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
return /*#__PURE__*/React.createElement(Table.Summary, {
|
|
479
|
+
fixed: true
|
|
480
|
+
}, /*#__PURE__*/React.createElement(Table.Summary.Row, null, flatColumns(!!mode ? [Table.SELECTION_COLUMN, ...columns] : [...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
481
|
+
// const cellFormat: IFormat | undefined = col.format ? typeof col.format === 'function' ? col.format({}) : col.format : format
|
|
482
|
+
|
|
483
|
+
const colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
|
|
484
|
+
const cellFormat = getFormat(colFormat, format);
|
|
485
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
486
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
487
|
+
|
|
488
|
+
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
489
|
+
const dec = cellFormat?.decimalScale;
|
|
490
|
+
const sumValue = col.type === 'number' ? sumDataByField(dataSource, col?.key) : 0;
|
|
491
|
+
const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
492
|
+
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
493
|
+
const numericFormatProps = {
|
|
494
|
+
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
495
|
+
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
496
|
+
allowNegative: cellFormat?.allowNegative ?? false,
|
|
497
|
+
prefix: cellFormat?.prefix,
|
|
498
|
+
suffix: cellFormat?.suffix,
|
|
499
|
+
decimalScale: dec,
|
|
500
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
501
|
+
};
|
|
502
|
+
return /*#__PURE__*/React.createElement(Table.Summary.Cell, {
|
|
503
|
+
key: col.key,
|
|
504
|
+
index: index,
|
|
505
|
+
align: col.align ?? 'right',
|
|
506
|
+
className: 'ui-rc-table-cell-ellipsis'
|
|
507
|
+
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : numericFormatter(cellValue, numericFormatProps));
|
|
508
|
+
})));
|
|
509
|
+
},
|
|
510
|
+
pagination: !pagination || pagination && pagination?.onChange ? false : {
|
|
511
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
512
|
+
...pagination
|
|
510
513
|
}
|
|
511
514
|
})), /*#__PURE__*/React.createElement("div", null), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/React.createElement(Pagination
|
|
512
515
|
// style={{padding: '0.75rem 1rem'}}
|
|
@@ -4,7 +4,7 @@ import { Fragment, useCallback } from 'react';
|
|
|
4
4
|
// import Command from "../Command";
|
|
5
5
|
import { Button, Space } from "antd";
|
|
6
6
|
import { Select } from "rc-master-ui";
|
|
7
|
-
import { findItemPath, getTypeFilter } from "./utils";
|
|
7
|
+
import { findItemPath, getFormat, getTypeFilter } from "./utils";
|
|
8
8
|
import { booleanOperator, numberOperator, stringOperator, translateOption } from "./constant";
|
|
9
9
|
import { flatColumns2, renderContent, renderFilter } from "./columns";
|
|
10
10
|
import { SearchOutlined } from "@ant-design/icons";
|
|
@@ -282,7 +282,8 @@ const useColumns = config => {
|
|
|
282
282
|
};
|
|
283
283
|
},
|
|
284
284
|
render: (value, record, rowIndex) => {
|
|
285
|
-
const
|
|
285
|
+
const colFormat = typeof col.format === 'function' ? col.format(record) : col.format;
|
|
286
|
+
const cellFormat = getFormat(colFormat, format);
|
|
286
287
|
if (groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
287
288
|
if (record.children) {
|
|
288
289
|
return renderContent(col, value, record, rowIndex, cellFormat);
|
|
@@ -21,6 +21,21 @@ export declare const getVisibleColumnKeys: (columns: any[]) => string[];
|
|
|
21
21
|
export declare function getHiddenParentKeys(columns: any[], parentKeys?: string[]): string[];
|
|
22
22
|
export declare const updateColumns: (columns: any[], includes: string[]) => any[];
|
|
23
23
|
export declare const updateColumnsByGroup: (columns: any[], columnsGroup: string[]) => any[];
|
|
24
|
+
export declare const getFormat: (colFormat?: IFormat, format?: IFormat) => {
|
|
25
|
+
thousandSeparator: string;
|
|
26
|
+
decimalSeparator: string;
|
|
27
|
+
decimalScale: number;
|
|
28
|
+
allowNegative: boolean;
|
|
29
|
+
prefix: string;
|
|
30
|
+
suffix: string;
|
|
31
|
+
fixedDecimalScale: boolean;
|
|
32
|
+
dateFormat: string;
|
|
33
|
+
datetimeFormat: string;
|
|
34
|
+
timeFormat: string;
|
|
35
|
+
weekFormat: string;
|
|
36
|
+
monthFormat: string;
|
|
37
|
+
yearFormat: string;
|
|
38
|
+
};
|
|
24
39
|
export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
|
|
25
40
|
export declare const customWeekStartEndFormat: (value: any, weekFormat: string) => string;
|
|
26
41
|
export declare const getTypeFilter: (col: ColumnTable<any>) => TypeFilter;
|
|
@@ -109,7 +124,7 @@ export declare function getCellsByPosition(cellSet: any, position?: string): any
|
|
|
109
124
|
export declare const addBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
|
|
110
125
|
export declare const removeBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
|
|
111
126
|
export declare const removeBorderClass2: (className: string, id?: string) => void;
|
|
112
|
-
export declare const onAddBgSelectedCell: (selectedCells: any, id?: string) => void;
|
|
127
|
+
export declare const onAddBgSelectedCell: (selectedCells: any, id?: string, isFocusCellIndex?: boolean) => void;
|
|
113
128
|
export declare const onAddBorderSelectedCell: (selectedCells: any, id?: string) => void;
|
|
114
129
|
export declare const onRemoveBgSelectedCell: (selectedCells: any, id?: string, rowsSelected?: any) => void;
|
|
115
130
|
export declare const onRemoveBorderSelectedCell: (selectedCells: any, id?: string) => void;
|
|
@@ -171,6 +171,25 @@ export const updateColumnsByGroup = (columns, columnsGroup) => {
|
|
|
171
171
|
return newColumn;
|
|
172
172
|
});
|
|
173
173
|
};
|
|
174
|
+
export const getFormat = (colFormat, format) => {
|
|
175
|
+
return {
|
|
176
|
+
thousandSeparator: colFormat?.thousandSeparator ?? format?.thousandSeparator,
|
|
177
|
+
decimalSeparator: colFormat?.decimalSeparator ?? format?.decimalSeparator,
|
|
178
|
+
decimalScale: colFormat?.decimalScale ?? format?.decimalScale,
|
|
179
|
+
allowNegative: colFormat?.allowNegative ?? format?.allowNegative,
|
|
180
|
+
// check nhập số âm
|
|
181
|
+
prefix: colFormat?.prefix ?? format?.prefix,
|
|
182
|
+
suffix: colFormat?.suffix ?? format?.suffix,
|
|
183
|
+
fixedDecimalScale: colFormat?.fixedDecimalScale ?? format?.fixedDecimalScale,
|
|
184
|
+
// mặc định thêm số 0 sau số thập phân
|
|
185
|
+
dateFormat: colFormat?.dateFormat ?? format?.dateFormat,
|
|
186
|
+
datetimeFormat: colFormat?.datetimeFormat ?? format?.datetimeFormat,
|
|
187
|
+
timeFormat: colFormat?.timeFormat ?? format?.timeFormat,
|
|
188
|
+
weekFormat: colFormat?.weekFormat ?? format?.weekFormat,
|
|
189
|
+
monthFormat: colFormat?.monthFormat ?? format?.monthFormat,
|
|
190
|
+
yearFormat: colFormat?.yearFormat ?? format?.yearFormat
|
|
191
|
+
};
|
|
192
|
+
};
|
|
174
193
|
export const getDatepickerFormat = (type, format) => {
|
|
175
194
|
const typeFormat = type ? type.toLowerCase() : '';
|
|
176
195
|
switch (typeFormat) {
|
|
@@ -1544,7 +1563,7 @@ export const removeBorderClass2 = (className, id) => {
|
|
|
1544
1563
|
});
|
|
1545
1564
|
}
|
|
1546
1565
|
};
|
|
1547
|
-
export const onAddBgSelectedCell = (selectedCells, id) => {
|
|
1566
|
+
export const onAddBgSelectedCell = (selectedCells, id, isFocusCellIndex) => {
|
|
1548
1567
|
const selectors = Array.from(selectedCells).map(pos => {
|
|
1549
1568
|
const [row1, col1] = pos.split('-');
|
|
1550
1569
|
return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
|
|
@@ -1559,7 +1578,7 @@ export const onAddBgSelectedCell = (selectedCells, id) => {
|
|
|
1559
1578
|
const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
|
|
1560
1579
|
const rowsSelectors = rowsArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
|
|
1561
1580
|
const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
|
|
1562
|
-
if (cellsIndex) {
|
|
1581
|
+
if (cellsIndex && isFocusCellIndex !== false) {
|
|
1563
1582
|
cellsIndex.forEach(cell => {
|
|
1564
1583
|
cell.classList.add('focus');
|
|
1565
1584
|
});
|
|
@@ -426,7 +426,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
426
426
|
&.rc-ui-cell-index {
|
|
427
427
|
&.focus {
|
|
428
428
|
background-color: $cell-index-focus-bg;
|
|
429
|
-
font-weight: 500;
|
|
429
|
+
//font-weight: 500;
|
|
430
430
|
}
|
|
431
431
|
&.selected {
|
|
432
432
|
background-color: $cell-index-selected-bg !important;
|
|
@@ -681,18 +681,18 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
681
681
|
// background-color: #f0f0f0;
|
|
682
682
|
//}
|
|
683
683
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
684
|
+
//.ui-rc_cell-content--index {
|
|
685
|
+
// &.focus {
|
|
686
|
+
// background-color: $cell-index-focus-bg;
|
|
687
|
+
// //color: #fff;
|
|
688
|
+
// //font-weight: 500;
|
|
689
|
+
// }
|
|
690
|
+
// &.selected {
|
|
691
|
+
// background-color: $cell-index-selected-bg;
|
|
692
|
+
// color: #fff;
|
|
693
|
+
// //font-weight: 500;
|
|
694
|
+
// }
|
|
695
|
+
//}
|
|
696
696
|
|
|
697
697
|
.#{$prefix}-table-tbody {
|
|
698
698
|
|
|
@@ -13,7 +13,7 @@ import dayjs from "dayjs";
|
|
|
13
13
|
import 'dayjs/locale/es';
|
|
14
14
|
import 'dayjs/locale/vi';
|
|
15
15
|
import TableGrid from "../TableGrid";
|
|
16
|
-
import { addClassBorderPasteCell, addClassCellIndexSelected, addRows8, addRowsUp, checkChild, editAbleColumns, findAllChildrenKeys, findItemByKey, findItemPath, flattenArray, flattenData, getDefaultValue, getEditType, getFirstSelectCell, getLastSelectCell, getRowNumber, getRowsPasteIndex, hideDraggingPoint, isEditable, isEqualSet, isObjEmpty, newGuid, onAddBorderSelectedCell, onAddBgSelectedCell, onRemoveBorderSelectedCell, onRemoveBgSelectedCell, removeClassBorderPasteCell, removeClassCellIndexSelected, showDraggingPoint, sortedSetASC, totalFixedWidth, updateArrayByKey } from "../hooks";
|
|
16
|
+
import { addClassBorderPasteCell, addClassCellIndexSelected, addRows8, addRowsUp, checkChild, editAbleColumns, findAllChildrenKeys, findItemByKey, findItemPath, flattenArray, flattenData, getDefaultValue, getEditType, getFirstSelectCell, getLastSelectCell, getRowNumber, getRowsPasteIndex, hideDraggingPoint, isEditable, isEqualSet, isObjEmpty, newGuid, onAddBorderSelectedCell, onAddBgSelectedCell, onRemoveBorderSelectedCell, onRemoveBgSelectedCell, removeClassBorderPasteCell, removeClassCellIndexSelected, showDraggingPoint, sortedSetASC, totalFixedWidth, updateArrayByKey, getFormat } from "../hooks";
|
|
17
17
|
import Message from "../../Message/Message";
|
|
18
18
|
import { Toolbar, ConfigProvider, InputNumber } from "rc-master-ui";
|
|
19
19
|
import classnames from "classnames";
|
|
@@ -149,6 +149,9 @@ const GridEdit = props => {
|
|
|
149
149
|
// quét vùng được paste - tiếp tục hiển thị con trỏ crosshair
|
|
150
150
|
// const isPasteDragging = useRef(false);
|
|
151
151
|
|
|
152
|
+
const visibleCols = React.useMemo(() => {
|
|
153
|
+
return flatColumns2(columns.filter(it => it.visible !== false));
|
|
154
|
+
}, [columns]);
|
|
152
155
|
const id = React.useMemo(() => {
|
|
153
156
|
return tableId ?? faker.string.alpha(20);
|
|
154
157
|
// return tableId ?? newGuid()
|
|
@@ -507,7 +510,7 @@ const GridEdit = props => {
|
|
|
507
510
|
const newData = [...dataSource];
|
|
508
511
|
|
|
509
512
|
// colIndex => field
|
|
510
|
-
const colIndexToField = flatColumns2(
|
|
513
|
+
const colIndexToField = flatColumns2(visibleCols).map(col => col.field);
|
|
511
514
|
|
|
512
515
|
// Duyệt qua mỗi ô cần xóa
|
|
513
516
|
for (const cell of selectedCells.current) {
|
|
@@ -859,7 +862,9 @@ const GridEdit = props => {
|
|
|
859
862
|
};
|
|
860
863
|
const triggerDragPaste = pastesArray => {
|
|
861
864
|
const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
|
|
862
|
-
const tmpCols =
|
|
865
|
+
const tmpCols = {
|
|
866
|
+
...visibleCols
|
|
867
|
+
};
|
|
863
868
|
const rowSelectedFirst = getFirstSelectCell(selectedCells.current).row;
|
|
864
869
|
const rowPasteLast = getLastSelectCell(pasteCells.current).row;
|
|
865
870
|
const selectedArray = Array.from(selectedCells.current).map(key => {
|
|
@@ -1250,7 +1255,7 @@ const GridEdit = props => {
|
|
|
1250
1255
|
col
|
|
1251
1256
|
};
|
|
1252
1257
|
const newSelectedCells = new Set();
|
|
1253
|
-
const tCols = editAbleColumns(
|
|
1258
|
+
const tCols = editAbleColumns(visibleCols);
|
|
1254
1259
|
for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
|
|
1255
1260
|
for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
|
|
1256
1261
|
newSelectedCells.add(`${r}-${c}`);
|
|
@@ -1270,7 +1275,7 @@ const GridEdit = props => {
|
|
|
1270
1275
|
hideDraggingPoint(selectedCells.current, id);
|
|
1271
1276
|
selectedCells.current = newSelectedCells;
|
|
1272
1277
|
rowsSelected.current = new Set([`${row}-${col}`]);
|
|
1273
|
-
onAddBgSelectedCell(newSelectedCells, id);
|
|
1278
|
+
onAddBgSelectedCell(newSelectedCells, id, false);
|
|
1274
1279
|
onAddBorderSelectedCell(newSelectedCells, id);
|
|
1275
1280
|
addClassCellIndexSelected(new Set([`${row}-${col}`]), id);
|
|
1276
1281
|
};
|
|
@@ -1412,13 +1417,13 @@ const GridEdit = props => {
|
|
|
1412
1417
|
}
|
|
1413
1418
|
rowValues.forEach((cellValue, colIndex) => {
|
|
1414
1419
|
const targetCol = startCol + colIndex;
|
|
1415
|
-
if (targetCol >=
|
|
1420
|
+
if (targetCol >= visibleCols.length) {
|
|
1416
1421
|
// Không vượt quá số cột
|
|
1417
1422
|
return;
|
|
1418
1423
|
}
|
|
1419
|
-
if (
|
|
1424
|
+
if (visibleCols[targetCol].editEnable) {
|
|
1420
1425
|
// @ts-ignore
|
|
1421
|
-
const columnKey =
|
|
1426
|
+
const columnKey = visibleCols[targetCol].field;
|
|
1422
1427
|
|
|
1423
1428
|
// @ts-ignore
|
|
1424
1429
|
newData[targetRow] = {
|
|
@@ -1461,13 +1466,13 @@ const GridEdit = props => {
|
|
|
1461
1466
|
}
|
|
1462
1467
|
rowValues.forEach((cellValue, colIndex) => {
|
|
1463
1468
|
const targetCol = startCol + colIndex;
|
|
1464
|
-
if (targetCol >=
|
|
1469
|
+
if (targetCol >= visibleCols.length) {
|
|
1465
1470
|
// Không vượt quá số cột
|
|
1466
1471
|
return;
|
|
1467
1472
|
}
|
|
1468
|
-
if (
|
|
1473
|
+
if (visibleCols[targetCol].editEnable) {
|
|
1469
1474
|
// @ts-ignore
|
|
1470
|
-
const columnKey =
|
|
1475
|
+
const columnKey = visibleCols[targetCol].field;
|
|
1471
1476
|
|
|
1472
1477
|
// @ts-ignore
|
|
1473
1478
|
childData[targetRow] = {
|
|
@@ -1783,7 +1788,7 @@ const GridEdit = props => {
|
|
|
1783
1788
|
// }, []);
|
|
1784
1789
|
|
|
1785
1790
|
const scrollToCell = (rowIndex, colIndex, cell, scrollType) => {
|
|
1786
|
-
const fixedWidth = totalFixedWidth(
|
|
1791
|
+
const fixedWidth = totalFixedWidth(visibleCols, 'left', selectionSettings);
|
|
1787
1792
|
if (scrollType === 'horizontal') {
|
|
1788
1793
|
if (tableRef.current) {
|
|
1789
1794
|
tableRef.current.scrollTo({
|
|
@@ -1904,7 +1909,7 @@ const GridEdit = props => {
|
|
|
1904
1909
|
setEditingKey('');
|
|
1905
1910
|
}
|
|
1906
1911
|
},
|
|
1907
|
-
tabIndex: (rowIndex ?? 0) *
|
|
1912
|
+
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex
|
|
1908
1913
|
};
|
|
1909
1914
|
},
|
|
1910
1915
|
render: (value, record) => {
|
|
@@ -1971,14 +1976,18 @@ const GridEdit = props => {
|
|
|
1971
1976
|
}
|
|
1972
1977
|
}
|
|
1973
1978
|
if (event.key === 'Tab') {
|
|
1974
|
-
if (
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
+
if (editingKey) {} else {
|
|
1980
|
+
if (colIndex + 1 !== visibleCols.length) {
|
|
1981
|
+
// console.log('bbbbb')
|
|
1982
|
+
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
1983
|
+
} else {
|
|
1984
|
+
// console.log('fffff')
|
|
1985
|
+
event.stopPropagation();
|
|
1986
|
+
event.preventDefault();
|
|
1987
|
+
}
|
|
1979
1988
|
}
|
|
1980
1989
|
}
|
|
1981
|
-
if (event.key === 'ArrowRight' && colIndex + 1 !==
|
|
1990
|
+
if (event.key === 'ArrowRight' && colIndex + 1 !== visibleCols.length) {
|
|
1982
1991
|
if (editingKey !== '') {} else {
|
|
1983
1992
|
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
1984
1993
|
}
|
|
@@ -2058,6 +2067,10 @@ const GridEdit = props => {
|
|
|
2058
2067
|
onClick: () => {
|
|
2059
2068
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
2060
2069
|
setEditingKey('');
|
|
2070
|
+
} else {
|
|
2071
|
+
if (editingKey) {
|
|
2072
|
+
handleCellClick(rowNumber, record, column);
|
|
2073
|
+
}
|
|
2061
2074
|
}
|
|
2062
2075
|
},
|
|
2063
2076
|
className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : `rc-ui-cell-editable cell-editable ${!isEditable(column, record) ? 'disable' : ''}`,
|
|
@@ -2077,7 +2090,7 @@ const GridEdit = props => {
|
|
|
2077
2090
|
editing: isEditing(record) && rowEditable?.(record) !== false && isEditable(column, record),
|
|
2078
2091
|
cellEditing,
|
|
2079
2092
|
t,
|
|
2080
|
-
tabIndex: (rowIndex ?? 0) *
|
|
2093
|
+
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex,
|
|
2081
2094
|
style: isPasteDragging ? {
|
|
2082
2095
|
cursor: "crosshair"
|
|
2083
2096
|
} : {}
|
|
@@ -2108,6 +2121,8 @@ const GridEdit = props => {
|
|
|
2108
2121
|
},
|
|
2109
2122
|
render: (value, record, rowIndex) => {
|
|
2110
2123
|
const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
|
|
2124
|
+
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
2125
|
+
const cellFormat = getFormat(colFormat, format);
|
|
2111
2126
|
return /*#__PURE__*/React.createElement("div", {
|
|
2112
2127
|
className: classNames('ui-rc_cell-content', {
|
|
2113
2128
|
// disable: !isEditable(column as any, record)
|
|
@@ -2129,7 +2144,7 @@ const GridEdit = props => {
|
|
|
2129
2144
|
// }}
|
|
2130
2145
|
}, /*#__PURE__*/React.createElement("div", {
|
|
2131
2146
|
className: 'ui-rc_content'
|
|
2132
|
-
}, renderContent(column, value, record, rowIndex,
|
|
2147
|
+
}, renderContent(column, value, record, rowIndex, cellFormat)),
|
|
2133
2148
|
// selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
|
|
2134
2149
|
// getLastSelectCell(selectedCells.current).col === colIndex &&
|
|
2135
2150
|
// isEditable(column as any, record) &&
|
|
@@ -92,8 +92,8 @@ const InternalTable = props => {
|
|
|
92
92
|
...rest
|
|
93
93
|
} = props;
|
|
94
94
|
const rowKey = _react.default.useMemo(() => {
|
|
95
|
-
return
|
|
96
|
-
}, [
|
|
95
|
+
return propRowKey ?? 'rowId';
|
|
96
|
+
}, [propRowKey]);
|
|
97
97
|
const local = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
|
|
98
98
|
const buddhistLocale = {
|
|
99
99
|
...local,
|
|
@@ -413,46 +413,6 @@ const TableGrid = props => {
|
|
|
413
413
|
// }}
|
|
414
414
|
,
|
|
415
415
|
|
|
416
|
-
summary: () => {
|
|
417
|
-
if (typeof summary === 'function') {
|
|
418
|
-
return summary(dataSource);
|
|
419
|
-
}
|
|
420
|
-
if (!summary) {
|
|
421
|
-
return undefined;
|
|
422
|
-
}
|
|
423
|
-
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary, {
|
|
424
|
-
fixed: true
|
|
425
|
-
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0, _columns.flatColumns)(!!mode ? [_rcMasterUi.Table.SELECTION_COLUMN, ...columns] : [...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
426
|
-
const cellFormat = col.format ? typeof col.format === 'function' ? col.format({}) : col.format : format;
|
|
427
|
-
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
428
|
-
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
429
|
-
|
|
430
|
-
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
431
|
-
const dec = cellFormat?.decimalScale;
|
|
432
|
-
const sumValue = col.type === 'number' ? (0, _hooks.sumDataByField)(dataSource, col?.key) : 0;
|
|
433
|
-
const value = !(0, _hooks.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
434
|
-
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
435
|
-
const numericFormatProps = {
|
|
436
|
-
thousandSeparator: (0, _hooks.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
437
|
-
decimalSeparator: (0, _hooks.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
438
|
-
allowNegative: cellFormat?.allowNegative ?? false,
|
|
439
|
-
prefix: cellFormat?.prefix,
|
|
440
|
-
suffix: cellFormat?.suffix,
|
|
441
|
-
decimalScale: dec,
|
|
442
|
-
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
443
|
-
};
|
|
444
|
-
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Cell, {
|
|
445
|
-
key: col.key,
|
|
446
|
-
index: index,
|
|
447
|
-
align: col.align ?? 'right',
|
|
448
|
-
className: 'ui-rc-table-cell-ellipsis'
|
|
449
|
-
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps));
|
|
450
|
-
})));
|
|
451
|
-
},
|
|
452
|
-
pagination: !pagination || pagination && pagination?.onChange ? false : {
|
|
453
|
-
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
454
|
-
...pagination
|
|
455
|
-
},
|
|
456
416
|
onFilter: val => {
|
|
457
417
|
handleOnFilter(val);
|
|
458
418
|
// triggerFilter?.(convertFilters(val))
|
|
@@ -507,6 +467,49 @@ const TableGrid = props => {
|
|
|
507
467
|
},
|
|
508
468
|
expandable: {
|
|
509
469
|
...expandable
|
|
470
|
+
},
|
|
471
|
+
summary: () => {
|
|
472
|
+
if (typeof summary === 'function') {
|
|
473
|
+
return summary(dataSource);
|
|
474
|
+
}
|
|
475
|
+
if (!summary) {
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary, {
|
|
479
|
+
fixed: true
|
|
480
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0, _columns.flatColumns)(!!mode ? [_rcMasterUi.Table.SELECTION_COLUMN, ...columns] : [...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
481
|
+
// const cellFormat: IFormat | undefined = col.format ? typeof col.format === 'function' ? col.format({}) : col.format : format
|
|
482
|
+
|
|
483
|
+
const colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
|
|
484
|
+
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
485
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
486
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
487
|
+
|
|
488
|
+
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
489
|
+
const dec = cellFormat?.decimalScale;
|
|
490
|
+
const sumValue = col.type === 'number' ? (0, _hooks.sumDataByField)(dataSource, col?.key) : 0;
|
|
491
|
+
const value = !(0, _hooks.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
492
|
+
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
493
|
+
const numericFormatProps = {
|
|
494
|
+
thousandSeparator: (0, _hooks.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
495
|
+
decimalSeparator: (0, _hooks.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
496
|
+
allowNegative: cellFormat?.allowNegative ?? false,
|
|
497
|
+
prefix: cellFormat?.prefix,
|
|
498
|
+
suffix: cellFormat?.suffix,
|
|
499
|
+
decimalScale: dec,
|
|
500
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
501
|
+
};
|
|
502
|
+
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Cell, {
|
|
503
|
+
key: col.key,
|
|
504
|
+
index: index,
|
|
505
|
+
align: col.align ?? 'right',
|
|
506
|
+
className: 'ui-rc-table-cell-ellipsis'
|
|
507
|
+
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps));
|
|
508
|
+
})));
|
|
509
|
+
},
|
|
510
|
+
pagination: !pagination || pagination && pagination?.onChange ? false : {
|
|
511
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
512
|
+
...pagination
|
|
510
513
|
}
|
|
511
514
|
})), /*#__PURE__*/_react.default.createElement("div", null), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/_react.default.createElement(_pagination.default
|
|
512
515
|
// style={{padding: '0.75rem 1rem'}}
|
|
@@ -293,7 +293,8 @@ const useColumns = config => {
|
|
|
293
293
|
};
|
|
294
294
|
},
|
|
295
295
|
render: (value, record, rowIndex) => {
|
|
296
|
-
const
|
|
296
|
+
const colFormat = typeof col.format === 'function' ? col.format(record) : col.format;
|
|
297
|
+
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
297
298
|
if (groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
298
299
|
if (record.children) {
|
|
299
300
|
return (0, _columns.renderContent)(col, value, record, rowIndex, cellFormat);
|
|
@@ -21,6 +21,21 @@ export declare const getVisibleColumnKeys: (columns: any[]) => string[];
|
|
|
21
21
|
export declare function getHiddenParentKeys(columns: any[], parentKeys?: string[]): string[];
|
|
22
22
|
export declare const updateColumns: (columns: any[], includes: string[]) => any[];
|
|
23
23
|
export declare const updateColumnsByGroup: (columns: any[], columnsGroup: string[]) => any[];
|
|
24
|
+
export declare const getFormat: (colFormat?: IFormat, format?: IFormat) => {
|
|
25
|
+
thousandSeparator: string;
|
|
26
|
+
decimalSeparator: string;
|
|
27
|
+
decimalScale: number;
|
|
28
|
+
allowNegative: boolean;
|
|
29
|
+
prefix: string;
|
|
30
|
+
suffix: string;
|
|
31
|
+
fixedDecimalScale: boolean;
|
|
32
|
+
dateFormat: string;
|
|
33
|
+
datetimeFormat: string;
|
|
34
|
+
timeFormat: string;
|
|
35
|
+
weekFormat: string;
|
|
36
|
+
monthFormat: string;
|
|
37
|
+
yearFormat: string;
|
|
38
|
+
};
|
|
24
39
|
export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
|
|
25
40
|
export declare const customWeekStartEndFormat: (value: any, weekFormat: string) => string;
|
|
26
41
|
export declare const getTypeFilter: (col: ColumnTable<any>) => TypeFilter;
|
|
@@ -109,7 +124,7 @@ export declare function getCellsByPosition(cellSet: any, position?: string): any
|
|
|
109
124
|
export declare const addBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
|
|
110
125
|
export declare const removeBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
|
|
111
126
|
export declare const removeBorderClass2: (className: string, id?: string) => void;
|
|
112
|
-
export declare const onAddBgSelectedCell: (selectedCells: any, id?: string) => void;
|
|
127
|
+
export declare const onAddBgSelectedCell: (selectedCells: any, id?: string, isFocusCellIndex?: boolean) => void;
|
|
113
128
|
export declare const onAddBorderSelectedCell: (selectedCells: any, id?: string) => void;
|
|
114
129
|
export declare const onRemoveBgSelectedCell: (selectedCells: any, id?: string, rowsSelected?: any) => void;
|
|
115
130
|
export declare const onRemoveBorderSelectedCell: (selectedCells: any, id?: string) => void;
|
|
@@ -16,7 +16,7 @@ exports.findAllChildrenKeys = findAllChildrenKeys;
|
|
|
16
16
|
exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemPath = exports.findItemByKey = void 0;
|
|
17
17
|
exports.getBottomRowCells = getBottomRowCells;
|
|
18
18
|
exports.getCellsByPosition = getCellsByPosition;
|
|
19
|
-
exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = void 0;
|
|
19
|
+
exports.getFormat = exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = void 0;
|
|
20
20
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
21
21
|
exports.hideDraggingPoint = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
22
22
|
exports.invalidDate = invalidDate;
|
|
@@ -216,6 +216,26 @@ const updateColumnsByGroup = (columns, columnsGroup) => {
|
|
|
216
216
|
});
|
|
217
217
|
};
|
|
218
218
|
exports.updateColumnsByGroup = updateColumnsByGroup;
|
|
219
|
+
const getFormat = (colFormat, format) => {
|
|
220
|
+
return {
|
|
221
|
+
thousandSeparator: colFormat?.thousandSeparator ?? format?.thousandSeparator,
|
|
222
|
+
decimalSeparator: colFormat?.decimalSeparator ?? format?.decimalSeparator,
|
|
223
|
+
decimalScale: colFormat?.decimalScale ?? format?.decimalScale,
|
|
224
|
+
allowNegative: colFormat?.allowNegative ?? format?.allowNegative,
|
|
225
|
+
// check nhập số âm
|
|
226
|
+
prefix: colFormat?.prefix ?? format?.prefix,
|
|
227
|
+
suffix: colFormat?.suffix ?? format?.suffix,
|
|
228
|
+
fixedDecimalScale: colFormat?.fixedDecimalScale ?? format?.fixedDecimalScale,
|
|
229
|
+
// mặc định thêm số 0 sau số thập phân
|
|
230
|
+
dateFormat: colFormat?.dateFormat ?? format?.dateFormat,
|
|
231
|
+
datetimeFormat: colFormat?.datetimeFormat ?? format?.datetimeFormat,
|
|
232
|
+
timeFormat: colFormat?.timeFormat ?? format?.timeFormat,
|
|
233
|
+
weekFormat: colFormat?.weekFormat ?? format?.weekFormat,
|
|
234
|
+
monthFormat: colFormat?.monthFormat ?? format?.monthFormat,
|
|
235
|
+
yearFormat: colFormat?.yearFormat ?? format?.yearFormat
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
exports.getFormat = getFormat;
|
|
219
239
|
const getDatepickerFormat = (type, format) => {
|
|
220
240
|
const typeFormat = type ? type.toLowerCase() : '';
|
|
221
241
|
switch (typeFormat) {
|
|
@@ -1642,7 +1662,7 @@ const removeBorderClass2 = (className, id) => {
|
|
|
1642
1662
|
}
|
|
1643
1663
|
};
|
|
1644
1664
|
exports.removeBorderClass2 = removeBorderClass2;
|
|
1645
|
-
const onAddBgSelectedCell = (selectedCells, id) => {
|
|
1665
|
+
const onAddBgSelectedCell = (selectedCells, id, isFocusCellIndex) => {
|
|
1646
1666
|
const selectors = Array.from(selectedCells).map(pos => {
|
|
1647
1667
|
const [row1, col1] = pos.split('-');
|
|
1648
1668
|
return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
|
|
@@ -1657,7 +1677,7 @@ const onAddBgSelectedCell = (selectedCells, id) => {
|
|
|
1657
1677
|
const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
|
|
1658
1678
|
const rowsSelectors = rowsArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
|
|
1659
1679
|
const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
|
|
1660
|
-
if (cellsIndex) {
|
|
1680
|
+
if (cellsIndex && isFocusCellIndex !== false) {
|
|
1661
1681
|
cellsIndex.forEach(cell => {
|
|
1662
1682
|
cell.classList.add('focus');
|
|
1663
1683
|
});
|
|
@@ -426,7 +426,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
426
426
|
&.rc-ui-cell-index {
|
|
427
427
|
&.focus {
|
|
428
428
|
background-color: $cell-index-focus-bg;
|
|
429
|
-
font-weight: 500;
|
|
429
|
+
//font-weight: 500;
|
|
430
430
|
}
|
|
431
431
|
&.selected {
|
|
432
432
|
background-color: $cell-index-selected-bg !important;
|
|
@@ -681,18 +681,18 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
681
681
|
// background-color: #f0f0f0;
|
|
682
682
|
//}
|
|
683
683
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
684
|
+
//.ui-rc_cell-content--index {
|
|
685
|
+
// &.focus {
|
|
686
|
+
// background-color: $cell-index-focus-bg;
|
|
687
|
+
// //color: #fff;
|
|
688
|
+
// //font-weight: 500;
|
|
689
|
+
// }
|
|
690
|
+
// &.selected {
|
|
691
|
+
// background-color: $cell-index-selected-bg;
|
|
692
|
+
// color: #fff;
|
|
693
|
+
// //font-weight: 500;
|
|
694
|
+
// }
|
|
695
|
+
//}
|
|
696
696
|
|
|
697
697
|
.#{$prefix}-table-tbody {
|
|
698
698
|
|
|
@@ -157,6 +157,9 @@ const GridEdit = props => {
|
|
|
157
157
|
// quét vùng được paste - tiếp tục hiển thị con trỏ crosshair
|
|
158
158
|
// const isPasteDragging = useRef(false);
|
|
159
159
|
|
|
160
|
+
const visibleCols = _react.default.useMemo(() => {
|
|
161
|
+
return (0, _columns.flatColumns2)(columns.filter(it => it.visible !== false));
|
|
162
|
+
}, [columns]);
|
|
160
163
|
const id = _react.default.useMemo(() => {
|
|
161
164
|
return tableId ?? _faker.faker.string.alpha(20);
|
|
162
165
|
// return tableId ?? newGuid()
|
|
@@ -515,7 +518,7 @@ const GridEdit = props => {
|
|
|
515
518
|
const newData = [...dataSource];
|
|
516
519
|
|
|
517
520
|
// colIndex => field
|
|
518
|
-
const colIndexToField = (0, _columns.flatColumns2)(
|
|
521
|
+
const colIndexToField = (0, _columns.flatColumns2)(visibleCols).map(col => col.field);
|
|
519
522
|
|
|
520
523
|
// Duyệt qua mỗi ô cần xóa
|
|
521
524
|
for (const cell of selectedCells.current) {
|
|
@@ -867,7 +870,9 @@ const GridEdit = props => {
|
|
|
867
870
|
};
|
|
868
871
|
const triggerDragPaste = pastesArray => {
|
|
869
872
|
const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
|
|
870
|
-
const tmpCols =
|
|
873
|
+
const tmpCols = {
|
|
874
|
+
...visibleCols
|
|
875
|
+
};
|
|
871
876
|
const rowSelectedFirst = (0, _hooks.getFirstSelectCell)(selectedCells.current).row;
|
|
872
877
|
const rowPasteLast = (0, _hooks.getLastSelectCell)(pasteCells.current).row;
|
|
873
878
|
const selectedArray = Array.from(selectedCells.current).map(key => {
|
|
@@ -1258,7 +1263,7 @@ const GridEdit = props => {
|
|
|
1258
1263
|
col
|
|
1259
1264
|
};
|
|
1260
1265
|
const newSelectedCells = new Set();
|
|
1261
|
-
const tCols = (0, _hooks.editAbleColumns)(
|
|
1266
|
+
const tCols = (0, _hooks.editAbleColumns)(visibleCols);
|
|
1262
1267
|
for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
|
|
1263
1268
|
for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
|
|
1264
1269
|
newSelectedCells.add(`${r}-${c}`);
|
|
@@ -1278,7 +1283,7 @@ const GridEdit = props => {
|
|
|
1278
1283
|
(0, _hooks.hideDraggingPoint)(selectedCells.current, id);
|
|
1279
1284
|
selectedCells.current = newSelectedCells;
|
|
1280
1285
|
rowsSelected.current = new Set([`${row}-${col}`]);
|
|
1281
|
-
(0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
|
|
1286
|
+
(0, _hooks.onAddBgSelectedCell)(newSelectedCells, id, false);
|
|
1282
1287
|
(0, _hooks.onAddBorderSelectedCell)(newSelectedCells, id);
|
|
1283
1288
|
(0, _hooks.addClassCellIndexSelected)(new Set([`${row}-${col}`]), id);
|
|
1284
1289
|
};
|
|
@@ -1420,13 +1425,13 @@ const GridEdit = props => {
|
|
|
1420
1425
|
}
|
|
1421
1426
|
rowValues.forEach((cellValue, colIndex) => {
|
|
1422
1427
|
const targetCol = startCol + colIndex;
|
|
1423
|
-
if (targetCol >=
|
|
1428
|
+
if (targetCol >= visibleCols.length) {
|
|
1424
1429
|
// Không vượt quá số cột
|
|
1425
1430
|
return;
|
|
1426
1431
|
}
|
|
1427
|
-
if (
|
|
1432
|
+
if (visibleCols[targetCol].editEnable) {
|
|
1428
1433
|
// @ts-ignore
|
|
1429
|
-
const columnKey =
|
|
1434
|
+
const columnKey = visibleCols[targetCol].field;
|
|
1430
1435
|
|
|
1431
1436
|
// @ts-ignore
|
|
1432
1437
|
newData[targetRow] = {
|
|
@@ -1469,13 +1474,13 @@ const GridEdit = props => {
|
|
|
1469
1474
|
}
|
|
1470
1475
|
rowValues.forEach((cellValue, colIndex) => {
|
|
1471
1476
|
const targetCol = startCol + colIndex;
|
|
1472
|
-
if (targetCol >=
|
|
1477
|
+
if (targetCol >= visibleCols.length) {
|
|
1473
1478
|
// Không vượt quá số cột
|
|
1474
1479
|
return;
|
|
1475
1480
|
}
|
|
1476
|
-
if (
|
|
1481
|
+
if (visibleCols[targetCol].editEnable) {
|
|
1477
1482
|
// @ts-ignore
|
|
1478
|
-
const columnKey =
|
|
1483
|
+
const columnKey = visibleCols[targetCol].field;
|
|
1479
1484
|
|
|
1480
1485
|
// @ts-ignore
|
|
1481
1486
|
childData[targetRow] = {
|
|
@@ -1791,7 +1796,7 @@ const GridEdit = props => {
|
|
|
1791
1796
|
// }, []);
|
|
1792
1797
|
|
|
1793
1798
|
const scrollToCell = (rowIndex, colIndex, cell, scrollType) => {
|
|
1794
|
-
const fixedWidth = (0, _hooks.totalFixedWidth)(
|
|
1799
|
+
const fixedWidth = (0, _hooks.totalFixedWidth)(visibleCols, 'left', selectionSettings);
|
|
1795
1800
|
if (scrollType === 'horizontal') {
|
|
1796
1801
|
if (tableRef.current) {
|
|
1797
1802
|
tableRef.current.scrollTo({
|
|
@@ -1912,7 +1917,7 @@ const GridEdit = props => {
|
|
|
1912
1917
|
setEditingKey('');
|
|
1913
1918
|
}
|
|
1914
1919
|
},
|
|
1915
|
-
tabIndex: (rowIndex ?? 0) *
|
|
1920
|
+
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex
|
|
1916
1921
|
};
|
|
1917
1922
|
},
|
|
1918
1923
|
render: (value, record) => {
|
|
@@ -1979,14 +1984,18 @@ const GridEdit = props => {
|
|
|
1979
1984
|
}
|
|
1980
1985
|
}
|
|
1981
1986
|
if (event.key === 'Tab') {
|
|
1982
|
-
if (
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
+
if (editingKey) {} else {
|
|
1988
|
+
if (colIndex + 1 !== visibleCols.length) {
|
|
1989
|
+
// console.log('bbbbb')
|
|
1990
|
+
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
1991
|
+
} else {
|
|
1992
|
+
// console.log('fffff')
|
|
1993
|
+
event.stopPropagation();
|
|
1994
|
+
event.preventDefault();
|
|
1995
|
+
}
|
|
1987
1996
|
}
|
|
1988
1997
|
}
|
|
1989
|
-
if (event.key === 'ArrowRight' && colIndex + 1 !==
|
|
1998
|
+
if (event.key === 'ArrowRight' && colIndex + 1 !== visibleCols.length) {
|
|
1990
1999
|
if (editingKey !== '') {} else {
|
|
1991
2000
|
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
1992
2001
|
}
|
|
@@ -2066,6 +2075,10 @@ const GridEdit = props => {
|
|
|
2066
2075
|
onClick: () => {
|
|
2067
2076
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
2068
2077
|
setEditingKey('');
|
|
2078
|
+
} else {
|
|
2079
|
+
if (editingKey) {
|
|
2080
|
+
handleCellClick(rowNumber, record, column);
|
|
2081
|
+
}
|
|
2069
2082
|
}
|
|
2070
2083
|
},
|
|
2071
2084
|
className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : `rc-ui-cell-editable cell-editable ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}`,
|
|
@@ -2085,7 +2098,7 @@ const GridEdit = props => {
|
|
|
2085
2098
|
editing: isEditing(record) && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record),
|
|
2086
2099
|
cellEditing,
|
|
2087
2100
|
t,
|
|
2088
|
-
tabIndex: (rowIndex ?? 0) *
|
|
2101
|
+
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex,
|
|
2089
2102
|
style: isPasteDragging ? {
|
|
2090
2103
|
cursor: "crosshair"
|
|
2091
2104
|
} : {}
|
|
@@ -2116,6 +2129,8 @@ const GridEdit = props => {
|
|
|
2116
2129
|
},
|
|
2117
2130
|
render: (value, record, rowIndex) => {
|
|
2118
2131
|
const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
|
|
2132
|
+
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
2133
|
+
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
2119
2134
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
2120
2135
|
className: (0, _classnames.default)('ui-rc_cell-content', {
|
|
2121
2136
|
// disable: !isEditable(column as any, record)
|
|
@@ -2137,7 +2152,7 @@ const GridEdit = props => {
|
|
|
2137
2152
|
// }}
|
|
2138
2153
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
2139
2154
|
className: 'ui-rc_content'
|
|
2140
|
-
}, (0, _columns.renderContent)(column, value, record, rowIndex,
|
|
2155
|
+
}, (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat)),
|
|
2141
2156
|
// selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
|
|
2142
2157
|
// getLastSelectCell(selectedCells.current).col === colIndex &&
|
|
2143
2158
|
// isEditable(column as any, record) &&
|
package/package.json
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "es-grid-template",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "es-grid-template",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"react",
|
|
7
|
-
"react-component",
|
|
8
|
-
"grid",
|
|
9
|
-
"table"
|
|
10
|
-
],
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"main": "lib/index",
|
|
13
|
-
"module": "es/index",
|
|
14
|
-
"files": [
|
|
15
|
-
"lib",
|
|
16
|
-
"es",
|
|
17
|
-
"assets/*.css",
|
|
18
|
-
"assets/*.scss"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"__compile": "father build && ",
|
|
22
|
-
"compile": "father build && sass assets/index.scss assets/index.css",
|
|
23
|
-
"docs:build": "dumi build",
|
|
24
|
-
"__docs:deploy": "gh-pages -d dist",
|
|
25
|
-
"lint": "eslint src/ --ext .tsx,.ts,.jsx,.js",
|
|
26
|
-
"now-build": "npm run docs:build",
|
|
27
|
-
"prepare": "dumi setup",
|
|
28
|
-
"prepublishOnly": "npm run compile",
|
|
29
|
-
"postpublish": "npm run docs:build",
|
|
30
|
-
"__postpublish": "npm run docs:build && npm run docs:deploy",
|
|
31
|
-
"start": "dumi dev",
|
|
32
|
-
"test": "vitest --watch false",
|
|
33
|
-
"coverage": "vitest run --coverage"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@ant-design/colors": "^8.0.0",
|
|
37
|
-
"@ant-design/cssinjs": "^1.22.0",
|
|
38
|
-
"@ant-design/cssinjs-utils": "^1.1.1",
|
|
39
|
-
"@ant-design/icons": "^5.5.2",
|
|
40
|
-
"@babel/runtime": "^7.11.2",
|
|
41
|
-
"@core-rc/rc-select": "^0.0.8",
|
|
42
|
-
"@ctrl/tinycolor": "^3.6.1",
|
|
43
|
-
"@faker-js/faker": "^9.5.0",
|
|
44
|
-
"@floating-ui/react": "^0.27.5",
|
|
45
|
-
"@rc-component/color-picker": "^2.0.1",
|
|
46
|
-
"@rc-component/father-plugin": "^2.0.1",
|
|
47
|
-
"@rc-component/trigger": "^2.0.0",
|
|
48
|
-
"@rc-component/util": "^1.0.1",
|
|
49
|
-
"@types/react-resizable": "^3.0.8",
|
|
50
|
-
"@types/styled-components": "^5.1.34",
|
|
51
|
-
"@vitest/coverage-v8": "^2.0.5",
|
|
52
|
-
"antd": "^5.24.1",
|
|
53
|
-
"antd-style": "^3.7.1",
|
|
54
|
-
"becoxy-icons": "^2.0.1",
|
|
55
|
-
"classnames": "^2.3.1",
|
|
56
|
-
"dayjs": "^1.11.13",
|
|
57
|
-
"lodash": "^4.17.21",
|
|
58
|
-
"moment": "^2.30.1",
|
|
59
|
-
"postcss": "^8.4.35",
|
|
60
|
-
"rc-checkbox": "^3.5.0",
|
|
61
|
-
"rc-dropdown": "^4.2.1",
|
|
62
|
-
"rc-field-form": "^2.6.0",
|
|
63
|
-
"rc-master-ui": "^1.1.31",
|
|
64
|
-
"rc-select": "^14.16.3",
|
|
65
|
-
"rc-tooltip": "^6.3.0",
|
|
66
|
-
"rc-tree": "^5.10.1",
|
|
67
|
-
"rc-tree-select": "^5.24.5",
|
|
68
|
-
"react-hook-form": "^7.54.2",
|
|
69
|
-
"react-hot-toast": "^2.5.2",
|
|
70
|
-
"react-numeric-component": "^1.0.7",
|
|
71
|
-
"react-resizable": "^3.0.5",
|
|
72
|
-
"react-tooltip": "^5.28.1",
|
|
73
|
-
"sass": "^1.81.0",
|
|
74
|
-
"styled-components": "^6.1.15",
|
|
75
|
-
"sweetalert2": "^11.4.14",
|
|
76
|
-
"sweetalert2-react-content": "^5.0.0",
|
|
77
|
-
"throttle-debounce": "^5.0.2",
|
|
78
|
-
"vitest": "^2.0.5"
|
|
79
|
-
},
|
|
80
|
-
"devDependencies": {
|
|
81
|
-
"@babel/cli": "^7.26.4",
|
|
82
|
-
"@babel/preset-env": "^7.26.9",
|
|
83
|
-
"@rc-component/np": "^1.0.3",
|
|
84
|
-
"@testing-library/react": "^14.0.0",
|
|
85
|
-
"@types/jest": "^29.4.0",
|
|
86
|
-
"@types/react": "^18.0.26",
|
|
87
|
-
"@types/react-dom": "^18.0.10",
|
|
88
|
-
"@types/warning": "^3.0.0",
|
|
89
|
-
"cross-env": "^7.0.0",
|
|
90
|
-
"dumi": "^2.2.13",
|
|
91
|
-
"eslint": "^8.56.0",
|
|
92
|
-
"eslint-plugin-unicorn": "^55.0.0",
|
|
93
|
-
"father": "^4.0.0",
|
|
94
|
-
"gh-pages": "^3.1.0",
|
|
95
|
-
"less": "^4.1.1",
|
|
96
|
-
"np": "^7.1.0",
|
|
97
|
-
"rc-test": "^7.0.9",
|
|
98
|
-
"react": "^18.2.0",
|
|
99
|
-
"react-dom": "^18.2.0",
|
|
100
|
-
"typescript": "^4.0.5"
|
|
101
|
-
},
|
|
102
|
-
"peerDependencies": {
|
|
103
|
-
"react": ">=16.9.0",
|
|
104
|
-
"react-dom": ">=16.9.0"
|
|
105
|
-
},
|
|
106
|
-
"umi": {
|
|
107
|
-
"configFile": "config.ts"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "es-grid-template",
|
|
3
|
+
"version": "1.4.1",
|
|
4
|
+
"description": "es-grid-template",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"react-component",
|
|
8
|
+
"grid",
|
|
9
|
+
"table"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"main": "lib/index",
|
|
13
|
+
"module": "es/index",
|
|
14
|
+
"files": [
|
|
15
|
+
"lib",
|
|
16
|
+
"es",
|
|
17
|
+
"assets/*.css",
|
|
18
|
+
"assets/*.scss"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"__compile": "father build && ",
|
|
22
|
+
"compile": "father build && sass assets/index.scss assets/index.css",
|
|
23
|
+
"docs:build": "dumi build",
|
|
24
|
+
"__docs:deploy": "gh-pages -d dist",
|
|
25
|
+
"lint": "eslint src/ --ext .tsx,.ts,.jsx,.js",
|
|
26
|
+
"now-build": "npm run docs:build",
|
|
27
|
+
"prepare": "dumi setup",
|
|
28
|
+
"prepublishOnly": "npm run compile",
|
|
29
|
+
"postpublish": "npm run docs:build",
|
|
30
|
+
"__postpublish": "npm run docs:build && npm run docs:deploy",
|
|
31
|
+
"start": "dumi dev",
|
|
32
|
+
"test": "vitest --watch false",
|
|
33
|
+
"coverage": "vitest run --coverage"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@ant-design/colors": "^8.0.0",
|
|
37
|
+
"@ant-design/cssinjs": "^1.22.0",
|
|
38
|
+
"@ant-design/cssinjs-utils": "^1.1.1",
|
|
39
|
+
"@ant-design/icons": "^5.5.2",
|
|
40
|
+
"@babel/runtime": "^7.11.2",
|
|
41
|
+
"@core-rc/rc-select": "^0.0.8",
|
|
42
|
+
"@ctrl/tinycolor": "^3.6.1",
|
|
43
|
+
"@faker-js/faker": "^9.5.0",
|
|
44
|
+
"@floating-ui/react": "^0.27.5",
|
|
45
|
+
"@rc-component/color-picker": "^2.0.1",
|
|
46
|
+
"@rc-component/father-plugin": "^2.0.1",
|
|
47
|
+
"@rc-component/trigger": "^2.0.0",
|
|
48
|
+
"@rc-component/util": "^1.0.1",
|
|
49
|
+
"@types/react-resizable": "^3.0.8",
|
|
50
|
+
"@types/styled-components": "^5.1.34",
|
|
51
|
+
"@vitest/coverage-v8": "^2.0.5",
|
|
52
|
+
"antd": "^5.24.1",
|
|
53
|
+
"antd-style": "^3.7.1",
|
|
54
|
+
"becoxy-icons": "^2.0.1",
|
|
55
|
+
"classnames": "^2.3.1",
|
|
56
|
+
"dayjs": "^1.11.13",
|
|
57
|
+
"lodash": "^4.17.21",
|
|
58
|
+
"moment": "^2.30.1",
|
|
59
|
+
"postcss": "^8.4.35",
|
|
60
|
+
"rc-checkbox": "^3.5.0",
|
|
61
|
+
"rc-dropdown": "^4.2.1",
|
|
62
|
+
"rc-field-form": "^2.6.0",
|
|
63
|
+
"rc-master-ui": "^1.1.31",
|
|
64
|
+
"rc-select": "^14.16.3",
|
|
65
|
+
"rc-tooltip": "^6.3.0",
|
|
66
|
+
"rc-tree": "^5.10.1",
|
|
67
|
+
"rc-tree-select": "^5.24.5",
|
|
68
|
+
"react-hook-form": "^7.54.2",
|
|
69
|
+
"react-hot-toast": "^2.5.2",
|
|
70
|
+
"react-numeric-component": "^1.0.7",
|
|
71
|
+
"react-resizable": "^3.0.5",
|
|
72
|
+
"react-tooltip": "^5.28.1",
|
|
73
|
+
"sass": "^1.81.0",
|
|
74
|
+
"styled-components": "^6.1.15",
|
|
75
|
+
"sweetalert2": "^11.4.14",
|
|
76
|
+
"sweetalert2-react-content": "^5.0.0",
|
|
77
|
+
"throttle-debounce": "^5.0.2",
|
|
78
|
+
"vitest": "^2.0.5"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@babel/cli": "^7.26.4",
|
|
82
|
+
"@babel/preset-env": "^7.26.9",
|
|
83
|
+
"@rc-component/np": "^1.0.3",
|
|
84
|
+
"@testing-library/react": "^14.0.0",
|
|
85
|
+
"@types/jest": "^29.4.0",
|
|
86
|
+
"@types/react": "^18.0.26",
|
|
87
|
+
"@types/react-dom": "^18.0.10",
|
|
88
|
+
"@types/warning": "^3.0.0",
|
|
89
|
+
"cross-env": "^7.0.0",
|
|
90
|
+
"dumi": "^2.2.13",
|
|
91
|
+
"eslint": "^8.56.0",
|
|
92
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
93
|
+
"father": "^4.0.0",
|
|
94
|
+
"gh-pages": "^3.1.0",
|
|
95
|
+
"less": "^4.1.1",
|
|
96
|
+
"np": "^7.1.0",
|
|
97
|
+
"rc-test": "^7.0.9",
|
|
98
|
+
"react": "^18.2.0",
|
|
99
|
+
"react-dom": "^18.2.0",
|
|
100
|
+
"typescript": "^4.0.5"
|
|
101
|
+
},
|
|
102
|
+
"peerDependencies": {
|
|
103
|
+
"react": ">=16.9.0",
|
|
104
|
+
"react-dom": ">=16.9.0"
|
|
105
|
+
},
|
|
106
|
+
"umi": {
|
|
107
|
+
"configFile": "config.ts"
|
|
108
|
+
}
|
|
109
|
+
}
|