es-grid-template 1.2.3 → 1.2.5
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/assets/index.css +0 -20
- package/assets/index.scss +22 -4
- package/es/grid-component/ColumnsChoose.d.ts +1 -0
- package/es/grid-component/ColumnsChoose.js +351 -61
- package/es/grid-component/EditableCell.js +3 -1
- package/es/grid-component/InternalTable.js +8 -1
- package/es/grid-component/hooks/useColumns.js +3 -3
- package/es/grid-component/hooks/useForceUpdate.d.ts +2 -0
- package/es/grid-component/hooks/useForceUpdate.js +5 -0
- package/es/grid-component/hooks/utils.d.ts +3 -0
- package/es/grid-component/hooks/utils.js +83 -16
- package/es/grid-component/styles.scss +22 -4
- package/es/grid-component/table/Grid.js +2 -1
- package/es/grid-component/table/GridEdit.js +75 -10
- package/es/grid-component/type.d.ts +3 -1
- package/lib/grid-component/ColumnsChoose.d.ts +1 -0
- package/lib/grid-component/ColumnsChoose.js +350 -60
- package/lib/grid-component/EditableCell.js +2 -1
- package/lib/grid-component/InternalTable.js +8 -1
- package/lib/grid-component/hooks/useColumns.js +3 -3
- package/lib/grid-component/hooks/useForceUpdate.d.ts +2 -0
- package/lib/grid-component/hooks/useForceUpdate.js +13 -0
- package/lib/grid-component/hooks/utils.d.ts +3 -0
- package/lib/grid-component/hooks/utils.js +89 -18
- package/lib/grid-component/styles.scss +22 -4
- package/lib/grid-component/table/Grid.js +2 -1
- package/lib/grid-component/table/GridEdit.js +74 -9
- package/lib/grid-component/type.d.ts +3 -1
- package/package.json +106 -106
|
@@ -6,17 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.addRowIdArray = void 0;
|
|
8
8
|
exports.addRows8 = addRows8;
|
|
9
|
-
exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.convertLabelToTitle = exports.convertFlatColumn = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertArrayWithIndent = exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = void 0;
|
|
9
|
+
exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.convertLabelToTitle = exports.convertFlatColumn = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertColumns = exports.convertArrayWithIndent = exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = void 0;
|
|
10
10
|
exports.findAllChildrenKeys = findAllChildrenKeys;
|
|
11
11
|
exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemByKey = void 0;
|
|
12
12
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
13
|
-
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.removeColumns = exports.parseBooleanToValue = exports.newGuid = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isDisable = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
13
|
+
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.removeColumns = exports.parseBooleanToValue = exports.newGuid = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isEditable = exports.isDisable = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
14
14
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
15
15
|
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
16
16
|
var _uuid = require("uuid");
|
|
17
17
|
var _colors = require("@ant-design/colors");
|
|
18
18
|
var _rcMasterUi = require("rc-master-ui");
|
|
19
19
|
var _columns = require("./columns");
|
|
20
|
+
var _useColumns = require("./useColumns");
|
|
20
21
|
const newGuid = () => {
|
|
21
22
|
for (let i = 0; i < 20; i++) {
|
|
22
23
|
// @ts-ignore
|
|
@@ -163,9 +164,14 @@ const updateColumns = (columns, includes) => {
|
|
|
163
164
|
newColumn.children = updateColumns(newColumn.children, includes);
|
|
164
165
|
hasVisibleChild = newColumn.children.some(child => !child.hidden);
|
|
165
166
|
}
|
|
166
|
-
|
|
167
|
+
|
|
168
|
+
// newColumn.hidden = newColumn.key && !includes.includes(newColumn.key)
|
|
169
|
+
newColumn.hidden = newColumn.field && !includes.includes(newColumn.field);
|
|
170
|
+
// newColumn.fixed = newColumn.field && !includes.includes(newColumn.field) ? undefined : newColumn.fixed
|
|
171
|
+
|
|
167
172
|
if (newColumn.children && newColumn.children.length > 0) {
|
|
168
173
|
newColumn.hidden = !hasVisibleChild;
|
|
174
|
+
// newColumn.fixed = !hasVisibleChild ? undefined : newColumn.fixed
|
|
169
175
|
}
|
|
170
176
|
return newColumn;
|
|
171
177
|
});
|
|
@@ -526,18 +532,6 @@ const getFirstSelectCell = selectCells => {
|
|
|
526
532
|
col
|
|
527
533
|
};
|
|
528
534
|
};
|
|
529
|
-
|
|
530
|
-
// export const getLastSelectCell = (selectCells: any): {row: number, col: number} => {
|
|
531
|
-
//
|
|
532
|
-
// if (selectCells.size === 0) {
|
|
533
|
-
// return {row: 0, col: 0}
|
|
534
|
-
// }
|
|
535
|
-
// const lastValue = [...selectCells].pop();
|
|
536
|
-
//
|
|
537
|
-
// const [row, col] = lastValue.split("-").map(Number);
|
|
538
|
-
// return {row, col};
|
|
539
|
-
//
|
|
540
|
-
// }
|
|
541
535
|
exports.getFirstSelectCell = getFirstSelectCell;
|
|
542
536
|
const getRowsPasteIndex = pasteRows => {
|
|
543
537
|
if (!pasteRows) {
|
|
@@ -557,8 +551,25 @@ function addRows8(arr, n) {
|
|
|
557
551
|
const addedRows = [];
|
|
558
552
|
|
|
559
553
|
// Hàm kiểm tra kiểu date hợp lệ
|
|
560
|
-
const isValidDate =
|
|
561
|
-
|
|
554
|
+
const isValidDate = item => {
|
|
555
|
+
// console.log('!isNaN(Date.parse(d))', !isNaN(Date.parse(d)))
|
|
556
|
+
// return !isNaN(Date.parse(d))
|
|
557
|
+
|
|
558
|
+
if (typeof item === 'number') {
|
|
559
|
+
// return 'number'
|
|
560
|
+
return false;
|
|
561
|
+
}
|
|
562
|
+
if (typeof item === 'string') {
|
|
563
|
+
// Kiểm tra nếu là chuỗi ISO date hợp lệ
|
|
564
|
+
const date = new Date(item);
|
|
565
|
+
if (!isNaN(date.getTime()) && item.includes('T')) {
|
|
566
|
+
// return 'date'
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
// return 'string'
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
return !isNaN(Date.parse(item));
|
|
562
573
|
};
|
|
563
574
|
|
|
564
575
|
// Lấy giá trị mẫu của cột j từ hàng đầu tiên
|
|
@@ -768,4 +779,64 @@ const convertFlatColumn = array => {
|
|
|
768
779
|
});
|
|
769
780
|
return result;
|
|
770
781
|
};
|
|
771
|
-
exports.convertFlatColumn = convertFlatColumn;
|
|
782
|
+
exports.convertFlatColumn = convertFlatColumn;
|
|
783
|
+
const convertColumns = cols => {
|
|
784
|
+
return cols.map(col => {
|
|
785
|
+
if (col === _useColumns.SELECTION_COLUMN) {
|
|
786
|
+
return _useColumns.SELECTION_COLUMN;
|
|
787
|
+
}
|
|
788
|
+
const transformedColumn = {
|
|
789
|
+
...col,
|
|
790
|
+
dataIndex: col.field ?? col.dataIndex,
|
|
791
|
+
key: col.field ?? col.dataIndex ?? col.key,
|
|
792
|
+
// title: t ? t(col.columnGroupText ?? col.headerText ?? col.title) : col.columnGroupText ?? col.headerText ?? col.title,
|
|
793
|
+
// title: () => (<span>aaa</span>),
|
|
794
|
+
// title: () => (<HeaderContent column={{...col} as any} t={t}/>),
|
|
795
|
+
// title: () => (<span>{t ? t(col.columnGroupText ?? col.headerText ?? col.title) : col.columnGroupText ?? col.headerText ?? col.title}</span>),
|
|
796
|
+
ellipsis: col.ellipsis !== false,
|
|
797
|
+
align: col.textAlign ?? col.align,
|
|
798
|
+
fixed: col.frozen ? col.frozen.toLowerCase() : col.fixed
|
|
799
|
+
};
|
|
800
|
+
if (transformedColumn.children && transformedColumn.children?.length) {
|
|
801
|
+
return {
|
|
802
|
+
...transformedColumn,
|
|
803
|
+
children: convertColumns(transformedColumn.children)
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
if (["index", "#"].includes(col.field)) {
|
|
807
|
+
return {
|
|
808
|
+
...transformedColumn,
|
|
809
|
+
onCell: () => ({
|
|
810
|
+
className: 'cell-number'
|
|
811
|
+
}),
|
|
812
|
+
render: (_, __, rowIndex) => rowIndex + 1
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
if (col.key === 'command') {
|
|
816
|
+
return {
|
|
817
|
+
...transformedColumn,
|
|
818
|
+
onCell: () => ({
|
|
819
|
+
className: 'cell-number',
|
|
820
|
+
style: {
|
|
821
|
+
padding: '2px 8px'
|
|
822
|
+
}
|
|
823
|
+
})
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
return {
|
|
827
|
+
...transformedColumn
|
|
828
|
+
};
|
|
829
|
+
});
|
|
830
|
+
};
|
|
831
|
+
exports.convertColumns = convertColumns;
|
|
832
|
+
const checkChild = inputArray => {
|
|
833
|
+
return inputArray.some(item => item.children && item.children.length > 0);
|
|
834
|
+
};
|
|
835
|
+
exports.checkChild = checkChild;
|
|
836
|
+
const isEditable = (column, rowData) => {
|
|
837
|
+
if (column && typeof column.editEnable === 'function') {
|
|
838
|
+
return column.editEnable(rowData);
|
|
839
|
+
}
|
|
840
|
+
return column?.editEnable;
|
|
841
|
+
};
|
|
842
|
+
exports.isEditable = isEditable;
|
|
@@ -42,6 +42,14 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
42
42
|
//font-weight: 500;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
.ui-rc-table {
|
|
46
|
+
.#{$prefix}-table-cell {
|
|
47
|
+
&.#{$prefix}-table-selection-column {
|
|
48
|
+
//padding: 6px 8px !important;
|
|
49
|
+
//padding: 6px 8px !important;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
45
53
|
|
|
46
54
|
|
|
47
55
|
&.table-none-column-select {
|
|
@@ -57,9 +65,12 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
.#{$prefix}-table {
|
|
60
|
-
|
|
68
|
+
|
|
69
|
+
//line-height: 20px;
|
|
70
|
+
|
|
61
71
|
.#{$prefix}-table-cell {
|
|
62
|
-
min-height: 35px;
|
|
72
|
+
//min-height: 35px;
|
|
73
|
+
//height: 35px;
|
|
63
74
|
|
|
64
75
|
.#{$prefix}-table-filter-column {
|
|
65
76
|
.#{$prefix}-dropdown-trigger.#{$prefix}-table-filter-trigger {
|
|
@@ -324,6 +335,13 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
324
335
|
|
|
325
336
|
.#{$prefix}-table-wrapper {
|
|
326
337
|
|
|
338
|
+
.#{$prefix}-table.#{$prefix}-table-small {
|
|
339
|
+
.#{$prefix}-table-selection-column{
|
|
340
|
+
//padding: 8px 8px;
|
|
341
|
+
//padding: 6px 8px;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
327
345
|
&.grid-editable {
|
|
328
346
|
|
|
329
347
|
.#{$prefix}-table-row {
|
|
@@ -528,7 +546,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
528
546
|
.#{$prefix}-table.#{$prefix}-table-small {
|
|
529
547
|
.#{$prefix}-table-selection-column{
|
|
530
548
|
//padding: 8px 8px;
|
|
531
|
-
padding: 6px 8px;
|
|
549
|
+
//padding: 6px 8px;
|
|
532
550
|
}
|
|
533
551
|
}
|
|
534
552
|
|
|
@@ -620,7 +638,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
620
638
|
.#{$prefix}-table-row-expand-icon {
|
|
621
639
|
position: absolute;
|
|
622
640
|
//.ui-rc_content {
|
|
623
|
-
padding-left: $i * 10px;
|
|
641
|
+
//padding-left: $i * 10px;
|
|
624
642
|
//}
|
|
625
643
|
}
|
|
626
644
|
|
|
@@ -56,6 +56,7 @@ const GridEdit = props => {
|
|
|
56
56
|
defaultValue,
|
|
57
57
|
expandable,
|
|
58
58
|
onCellClick,
|
|
59
|
+
rowEditable,
|
|
59
60
|
...rest
|
|
60
61
|
} = props;
|
|
61
62
|
const {
|
|
@@ -92,8 +93,6 @@ const GridEdit = props => {
|
|
|
92
93
|
const [isSelectDragging, setSelectIsDragging] = (0, _react.useState)(false);
|
|
93
94
|
const [isPasteDragging, setIsPasteDragging] = (0, _react.useState)(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
|
|
94
95
|
|
|
95
|
-
// const [showDraggingPoint, setShowDraggingPoint] = useState(false);
|
|
96
|
-
|
|
97
96
|
const [rowsSelected, setRowsSelected] = (0, _react.useState)(new Set());
|
|
98
97
|
const [startSelectedCells, setStartSelectedCell] = (0, _react.useState)(null);
|
|
99
98
|
const [innerExpandedKeys, setInnerExpandedKeys] = _react.default.useState(() => {
|
|
@@ -266,10 +265,54 @@ const GridEdit = props => {
|
|
|
266
265
|
}
|
|
267
266
|
}
|
|
268
267
|
};
|
|
269
|
-
const
|
|
268
|
+
const handleInsertChild = item => {
|
|
269
|
+
const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
|
|
270
|
+
const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
|
|
271
|
+
const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
|
|
272
|
+
if (item.onClick) {
|
|
273
|
+
item.onClick({
|
|
274
|
+
toolbar: item
|
|
275
|
+
});
|
|
276
|
+
} else {
|
|
277
|
+
const newData = [...dataSource];
|
|
278
|
+
let newElement = {};
|
|
279
|
+
if (!record.children || record.children.length === 0) {
|
|
280
|
+
newElement = {
|
|
281
|
+
...record,
|
|
282
|
+
children: [{
|
|
283
|
+
...defaultRowValue,
|
|
284
|
+
parentId: record.rowId,
|
|
285
|
+
rowId
|
|
286
|
+
}]
|
|
287
|
+
};
|
|
288
|
+
} else {
|
|
289
|
+
newElement = {
|
|
290
|
+
...record,
|
|
291
|
+
children: [...record.children, {
|
|
292
|
+
...defaultRowValue,
|
|
293
|
+
parentId: record.rowId,
|
|
294
|
+
rowId
|
|
295
|
+
}]
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
const newDataSource = (0, _hooks.updateArrayByKey)(newData, newElement, rowKey);
|
|
299
|
+
triggerChangeData?.(newDataSource, 'INSERT_CHILDREN');
|
|
300
|
+
}
|
|
301
|
+
const key = getRowKey(record, dataSource.indexOf(record));
|
|
302
|
+
|
|
303
|
+
// let newExpandedKeys: Key[];
|
|
304
|
+
const hasKey = mergedExpandedKeys.has(key);
|
|
305
|
+
if (!hasKey) {
|
|
306
|
+
const newExpandedKeys = [...mergedExpandedKeys, key];
|
|
307
|
+
setInnerExpandedKeys(newExpandedKeys);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
const handleDeleteAll = () => {
|
|
311
|
+
triggerChangeData?.([], 'INSERT_BEFORE');
|
|
312
|
+
};
|
|
270
313
|
const toolbarItemsBottom = (0, _react.useMemo)(() => {
|
|
271
314
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
272
|
-
return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER').map(item => {
|
|
315
|
+
return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'INSERT_CHILDREN').map(item => {
|
|
273
316
|
if (item.key === 'ADD') {
|
|
274
317
|
return {
|
|
275
318
|
...item,
|
|
@@ -398,6 +441,24 @@ const GridEdit = props => {
|
|
|
398
441
|
}
|
|
399
442
|
};
|
|
400
443
|
}
|
|
444
|
+
if (item.key === 'INSERT_CHILDREN') {
|
|
445
|
+
return {
|
|
446
|
+
...item,
|
|
447
|
+
template: () => {
|
|
448
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
449
|
+
className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
|
|
450
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
451
|
+
style: {
|
|
452
|
+
color: '#28c76f',
|
|
453
|
+
borderColor: '#28c76f'
|
|
454
|
+
},
|
|
455
|
+
variant: 'outlined',
|
|
456
|
+
onClick: () => handleInsertChild(item),
|
|
457
|
+
className: "d-flex toolbar-button"
|
|
458
|
+
}, item.title ? t ? t(item.title) : item.title : t ? t('Insert item after') : 'Insert item after')));
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
}
|
|
401
462
|
if (item.key === 'DELETE') {
|
|
402
463
|
return {
|
|
403
464
|
...item,
|
|
@@ -958,8 +1019,8 @@ const GridEdit = props => {
|
|
|
958
1019
|
const newData = [...dataSource];
|
|
959
1020
|
|
|
960
1021
|
// @ts-ignore
|
|
961
|
-
const index = newData.findIndex(item => formData[rowKey] === item[rowKey]);
|
|
962
|
-
const rs = (0, _hooks.updateArrayByKey)(
|
|
1022
|
+
const index = (0, _hooks.flattenData)(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
|
|
1023
|
+
const rs = (0, _hooks.updateArrayByKey)(newData, row, rowKey);
|
|
963
1024
|
if (index > -1) {
|
|
964
1025
|
triggerChangeData?.(rs, 'onChange');
|
|
965
1026
|
}
|
|
@@ -1312,7 +1373,8 @@ const GridEdit = props => {
|
|
|
1312
1373
|
title: (0, _columns.getValueCell)(column, record[column.field], format),
|
|
1313
1374
|
'data-col-index': colIndex,
|
|
1314
1375
|
'data-row-index': rowNumber,
|
|
1315
|
-
editing: isEditing(record),
|
|
1376
|
+
editing: isEditing(record) && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record) !== false,
|
|
1377
|
+
// editing: isEditing(record) && rowEditable?.(record) !== false,
|
|
1316
1378
|
tabIndex: (rowIndex ?? 0) * columns.length + colIndex,
|
|
1317
1379
|
style: isPasteDragging ? {
|
|
1318
1380
|
cursor: "crosshair"
|
|
@@ -1331,7 +1393,7 @@ const GridEdit = props => {
|
|
|
1331
1393
|
onMouseUp: handleMouseUp
|
|
1332
1394
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1333
1395
|
className: 'ui-rc_content'
|
|
1334
|
-
}, (0, _columns.renderContent)(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && (0, _hooks.getLastSelectCell)(selectedCells).row === rowNumber && (0, _hooks.getLastSelectCell)(selectedCells).col === colIndex && !isSelectDragging &&
|
|
1396
|
+
}, (0, _columns.renderContent)(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && (0, _hooks.getLastSelectCell)(selectedCells).row === rowNumber && (0, _hooks.getLastSelectCell)(selectedCells).col === colIndex && (0, _hooks.isEditable)(column, record) !== false && !isSelectDragging &&
|
|
1335
1397
|
/*#__PURE__*/
|
|
1336
1398
|
// showDraggingPoint &&
|
|
1337
1399
|
_react.default.createElement("div", {
|
|
@@ -1420,7 +1482,8 @@ const GridEdit = props => {
|
|
|
1420
1482
|
rowSelectedHoverBg: '#eb4619',
|
|
1421
1483
|
cellFontSize: 12,
|
|
1422
1484
|
cellFontSizeSM: 13,
|
|
1423
|
-
headerBg: '#ffffff'
|
|
1485
|
+
headerBg: '#ffffff',
|
|
1486
|
+
cellPaddingBlockSM: 7
|
|
1424
1487
|
// cellPaddingBlock: 0,
|
|
1425
1488
|
// cellPaddingBlockSM: 0,
|
|
1426
1489
|
// cellPaddingInlineSM: 0,
|
|
@@ -1454,6 +1517,7 @@ const GridEdit = props => {
|
|
|
1454
1517
|
rowHoverable: false,
|
|
1455
1518
|
bottomToolbar: bottomToolbar,
|
|
1456
1519
|
expandable: {
|
|
1520
|
+
expandIconColumnIndex: (0, _hooks.checkChild)(dataSource) ? 3 : undefined,
|
|
1457
1521
|
...expandable,
|
|
1458
1522
|
expandedRowKeys: innerExpandedKeys,
|
|
1459
1523
|
expandIcon: args => {
|
|
@@ -1488,6 +1552,7 @@ const GridEdit = props => {
|
|
|
1488
1552
|
}
|
|
1489
1553
|
}
|
|
1490
1554
|
},
|
|
1555
|
+
triggerChangeColumns: triggerChangeColumns,
|
|
1491
1556
|
rowSelection: columns && columns.length === 0 ? undefined : {
|
|
1492
1557
|
type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
|
|
1493
1558
|
columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
|
|
@@ -46,7 +46,7 @@ export type ColumnSelectTable = {
|
|
|
46
46
|
};
|
|
47
47
|
export type IEditSelectSettings = {
|
|
48
48
|
fieldKey?: string;
|
|
49
|
-
options: any[];
|
|
49
|
+
options: any[] | ((rowData: any, field: string) => any[]);
|
|
50
50
|
/** get value form other field **/
|
|
51
51
|
fieldValue?: string;
|
|
52
52
|
/** get label form other field **/
|
|
@@ -114,6 +114,7 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
114
114
|
export type ColumnEditType<RecordType = AnyObject> = Omit<ColumnType<RecordType>, 'children'> & {
|
|
115
115
|
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
116
116
|
disable?: boolean | ((rowData: any) => boolean);
|
|
117
|
+
editEnable?: boolean | ((rowData: any) => boolean);
|
|
117
118
|
isClearable?: boolean;
|
|
118
119
|
maxDate?: any;
|
|
119
120
|
minDate?: any;
|
|
@@ -185,6 +186,7 @@ export interface TableEditProps<RecordType = AnyObject> extends Omit<TableProps<
|
|
|
185
186
|
onCellPaste?: ICellPasteModel<RecordType>;
|
|
186
187
|
onCellChange?: (args: CellChangeArgs<RecordType>, handleCallback: (rowData: any, index: any, value?: any) => void) => void;
|
|
187
188
|
onCellClick?: (args: ICellClick, callback?: any) => void;
|
|
189
|
+
rowEditable?: (rowData: RecordType) => boolean;
|
|
188
190
|
}
|
|
189
191
|
export type ICellClick = {
|
|
190
192
|
index: number;
|
package/package.json
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "es-grid-template",
|
|
3
|
-
"version": "1.2.
|
|
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.21",
|
|
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
|
-
"sass": "^1.81.0",
|
|
73
|
-
"styled-components": "^6.1.15",
|
|
74
|
-
"throttle-debounce": "^5.0.2",
|
|
75
|
-
"vitest": "^2.0.5"
|
|
76
|
-
},
|
|
77
|
-
"devDependencies": {
|
|
78
|
-
"@babel/cli": "^7.26.4",
|
|
79
|
-
"@babel/preset-env": "^7.26.9",
|
|
80
|
-
"@rc-component/np": "^1.0.3",
|
|
81
|
-
"@testing-library/react": "^14.0.0",
|
|
82
|
-
"@types/jest": "^29.4.0",
|
|
83
|
-
"@types/react": "^18.0.26",
|
|
84
|
-
"@types/react-dom": "^18.0.10",
|
|
85
|
-
"@types/warning": "^3.0.0",
|
|
86
|
-
"cross-env": "^7.0.0",
|
|
87
|
-
"dumi": "^2.2.13",
|
|
88
|
-
"eslint": "^8.56.0",
|
|
89
|
-
"eslint-plugin-unicorn": "^55.0.0",
|
|
90
|
-
"father": "^4.0.0",
|
|
91
|
-
"gh-pages": "^3.1.0",
|
|
92
|
-
"less": "^4.1.1",
|
|
93
|
-
"np": "^7.1.0",
|
|
94
|
-
"rc-test": "^7.0.9",
|
|
95
|
-
"react": "^18.2.0",
|
|
96
|
-
"react-dom": "^18.2.0",
|
|
97
|
-
"typescript": "^4.0.5"
|
|
98
|
-
},
|
|
99
|
-
"peerDependencies": {
|
|
100
|
-
"react": ">=16.9.0",
|
|
101
|
-
"react-dom": ">=16.9.0"
|
|
102
|
-
},
|
|
103
|
-
"umi": {
|
|
104
|
-
"configFile": "config.ts"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "es-grid-template",
|
|
3
|
+
"version": "1.2.5",
|
|
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.21",
|
|
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
|
+
"sass": "^1.81.0",
|
|
73
|
+
"styled-components": "^6.1.15",
|
|
74
|
+
"throttle-debounce": "^5.0.2",
|
|
75
|
+
"vitest": "^2.0.5"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@babel/cli": "^7.26.4",
|
|
79
|
+
"@babel/preset-env": "^7.26.9",
|
|
80
|
+
"@rc-component/np": "^1.0.3",
|
|
81
|
+
"@testing-library/react": "^14.0.0",
|
|
82
|
+
"@types/jest": "^29.4.0",
|
|
83
|
+
"@types/react": "^18.0.26",
|
|
84
|
+
"@types/react-dom": "^18.0.10",
|
|
85
|
+
"@types/warning": "^3.0.0",
|
|
86
|
+
"cross-env": "^7.0.0",
|
|
87
|
+
"dumi": "^2.2.13",
|
|
88
|
+
"eslint": "^8.56.0",
|
|
89
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
90
|
+
"father": "^4.0.0",
|
|
91
|
+
"gh-pages": "^3.1.0",
|
|
92
|
+
"less": "^4.1.1",
|
|
93
|
+
"np": "^7.1.0",
|
|
94
|
+
"rc-test": "^7.0.9",
|
|
95
|
+
"react": "^18.2.0",
|
|
96
|
+
"react-dom": "^18.2.0",
|
|
97
|
+
"typescript": "^4.0.5"
|
|
98
|
+
},
|
|
99
|
+
"peerDependencies": {
|
|
100
|
+
"react": ">=16.9.0",
|
|
101
|
+
"react-dom": ">=16.9.0"
|
|
102
|
+
},
|
|
103
|
+
"umi": {
|
|
104
|
+
"configFile": "config.ts"
|
|
105
|
+
}
|
|
106
|
+
}
|