es-grid-template 1.3.9 → 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/EditableCell.js +9 -8
- package/es/grid-component/InternalTable.js +26 -4
- package/es/grid-component/TableGrid.js +44 -41
- package/es/grid-component/hooks/useColumns.d.ts +1 -0
- package/es/grid-component/hooks/useColumns.js +12 -4
- package/es/grid-component/hooks/useLazyKVMap.d.ts +4 -0
- package/es/grid-component/hooks/useLazyKVMap.js +35 -0
- package/es/grid-component/hooks/utils.d.ts +16 -1
- package/es/grid-component/hooks/utils.js +25 -4
- package/es/grid-component/styles.scss +13 -13
- package/es/grid-component/table/GridEdit.js +42 -22
- package/lib/grid-component/EditableCell.js +9 -8
- package/lib/grid-component/InternalTable.js +28 -4
- package/lib/grid-component/TableGrid.js +43 -40
- package/lib/grid-component/hooks/useColumns.d.ts +1 -0
- package/lib/grid-component/hooks/useColumns.js +11 -3
- package/lib/grid-component/hooks/useLazyKVMap.d.ts +4 -0
- package/lib/grid-component/hooks/useLazyKVMap.js +43 -0
- package/lib/grid-component/hooks/utils.d.ts +16 -1
- package/lib/grid-component/hooks/utils.js +27 -5
- package/lib/grid-component/styles.scss +13 -13
- package/lib/grid-component/table/GridEdit.js +41 -21
- package/package.json +2 -2
|
@@ -35,7 +35,10 @@ const filterTreeNode = (input, treeNode) => {
|
|
|
35
35
|
title,
|
|
36
36
|
value
|
|
37
37
|
} = treeNode;
|
|
38
|
-
|
|
38
|
+
if (typeof title === "string" || typeof title === 'number') {
|
|
39
|
+
return title.toString().toLowerCase().includes(input.toLowerCase()) || value.toLowerCase().includes(input.toLowerCase());
|
|
40
|
+
}
|
|
41
|
+
return value.toLowerCase().includes(input.toLowerCase());
|
|
39
42
|
};
|
|
40
43
|
const EditableCell = props => {
|
|
41
44
|
const {
|
|
@@ -560,19 +563,17 @@ const EditableCell = props => {
|
|
|
560
563
|
// autoFocus={true}
|
|
561
564
|
,
|
|
562
565
|
virtual: true,
|
|
563
|
-
allowClear: true
|
|
566
|
+
allowClear: true,
|
|
567
|
+
showSearch: true
|
|
564
568
|
// maxTagTextLength={column?.editSelectSettings?.showItems}
|
|
565
569
|
,
|
|
566
570
|
maxTagCount: column?.editSelectSettings?.showItems,
|
|
567
571
|
maxTagPlaceholder: 2,
|
|
568
572
|
treeTitleRender: column?.editSelectSettings?.formatOptionLabel,
|
|
569
573
|
showCheckedStrategy: SHOW_PARENT,
|
|
570
|
-
multiple: column?.editSelectSettings?.selectMode === 'checkbox' || column?.editSelectSettings?.isMulti
|
|
571
|
-
fieldNames:
|
|
572
|
-
|
|
573
|
-
value: keySelect,
|
|
574
|
-
children: 'children'
|
|
575
|
-
},
|
|
574
|
+
multiple: column?.editSelectSettings?.selectMode === 'checkbox' || column?.editSelectSettings?.isMulti
|
|
575
|
+
// fieldNames={{label: inputKey ? inputKey : 'title', value: keySelect, children: 'children'}}
|
|
576
|
+
,
|
|
576
577
|
treeCheckable: column?.editSelectSettings?.selectMode === 'checkbox',
|
|
577
578
|
filterTreeNode: filterTreeNode,
|
|
578
579
|
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _react =
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _reactResizable = require("react-resizable");
|
|
11
11
|
require("react-resizable/css/styles.css");
|
|
12
12
|
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
@@ -24,6 +24,9 @@ var _columns = require("./hooks/columns");
|
|
|
24
24
|
var _Group = _interopRequireDefault(require("./table/Group"));
|
|
25
25
|
var _sweetalert = _interopRequireDefault(require("sweetalert2"));
|
|
26
26
|
var _sweetalert2ReactContent = _interopRequireDefault(require("sweetalert2-react-content"));
|
|
27
|
+
var _reactTooltip = require("react-tooltip");
|
|
28
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
29
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
30
|
_dayjs.default.extend(_customParseFormat.default);
|
|
28
31
|
const MySwal = (0, _sweetalert2ReactContent.default)(_sweetalert.default);
|
|
29
32
|
|
|
@@ -89,8 +92,8 @@ const InternalTable = props => {
|
|
|
89
92
|
...rest
|
|
90
93
|
} = props;
|
|
91
94
|
const rowKey = _react.default.useMemo(() => {
|
|
92
|
-
return
|
|
93
|
-
}, [
|
|
95
|
+
return propRowKey ?? 'rowId';
|
|
96
|
+
}, [propRowKey]);
|
|
94
97
|
const local = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
|
|
95
98
|
const buddhistLocale = {
|
|
96
99
|
...local,
|
|
@@ -101,6 +104,7 @@ const InternalTable = props => {
|
|
|
101
104
|
|
|
102
105
|
// const [filterStates, setFilterState] = React.useState<any>(null)
|
|
103
106
|
// const [isFilter, setIsFilter] = React.useState<boolean>(false);
|
|
107
|
+
// const [cellTooltip, seCellTooltip] = React.useState<any>(undefined);
|
|
104
108
|
|
|
105
109
|
const mergerdData = _react.default.useMemo(() => {
|
|
106
110
|
// return filterDataByColumns2(addRowIdArray(dataSource), filterStates)
|
|
@@ -147,6 +151,11 @@ const InternalTable = props => {
|
|
|
147
151
|
// @ts-ignore
|
|
148
152
|
return record => record?.[rowKey];
|
|
149
153
|
}, [rowKey]);
|
|
154
|
+
|
|
155
|
+
// const onMouseHover = (record: any, col: ColumnTable) => {
|
|
156
|
+
//
|
|
157
|
+
// }
|
|
158
|
+
|
|
150
159
|
const [transformSelectionColumns] = (0, _useColumns.default)({
|
|
151
160
|
locale,
|
|
152
161
|
t,
|
|
@@ -161,6 +170,7 @@ const InternalTable = props => {
|
|
|
161
170
|
groupSetting,
|
|
162
171
|
groupColumns,
|
|
163
172
|
handleResize
|
|
173
|
+
// onMouseHover
|
|
164
174
|
});
|
|
165
175
|
const mergedColumns = _react.default.useMemo(() => {
|
|
166
176
|
return transformSelectionColumns(columns);
|
|
@@ -389,7 +399,7 @@ const InternalTable = props => {
|
|
|
389
399
|
}
|
|
390
400
|
};
|
|
391
401
|
const TableComponent = groupAble ? _Group.default : editAble ? _GridEdit.default : _Grid.default;
|
|
392
|
-
return /*#__PURE__*/_react.default.createElement(TableComponent, (0, _extends2.default)({}, rest, {
|
|
402
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(TableComponent, (0, _extends2.default)({}, rest, {
|
|
393
403
|
t: t,
|
|
394
404
|
locale: locale,
|
|
395
405
|
tableRef: tableRef,
|
|
@@ -424,6 +434,20 @@ const InternalTable = props => {
|
|
|
424
434
|
// isFilter={isFilter}
|
|
425
435
|
// setIsFilter={setIsFilter}
|
|
426
436
|
// onScroll={onScroll}
|
|
437
|
+
})), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
438
|
+
id: "tooltip-cell-content",
|
|
439
|
+
style: {
|
|
440
|
+
zIndex: 1999
|
|
441
|
+
}
|
|
442
|
+
// content={'sssss'}
|
|
443
|
+
// content={cellTooltip}
|
|
444
|
+
// render={() => {
|
|
445
|
+
// return (
|
|
446
|
+
// <span>
|
|
447
|
+
// aaaa
|
|
448
|
+
// </span>
|
|
449
|
+
// )
|
|
450
|
+
// }}
|
|
427
451
|
}));
|
|
428
452
|
};
|
|
429
453
|
var _default = exports.default = InternalTable;
|
|
@@ -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'}}
|
|
@@ -13,6 +13,7 @@ interface UseColumnsConfig<RecordType> {
|
|
|
13
13
|
groupSetting?: IGroupSetting;
|
|
14
14
|
groupColumns?: string[];
|
|
15
15
|
rowKey?: any;
|
|
16
|
+
onMouseHover?: any;
|
|
16
17
|
}
|
|
17
18
|
declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig<RecordType>) => readonly [any];
|
|
18
19
|
export default useColumns;
|
|
@@ -48,6 +48,7 @@ const useColumns = config => {
|
|
|
48
48
|
sortMultiple,
|
|
49
49
|
format,
|
|
50
50
|
handleResize,
|
|
51
|
+
// onMouseHover,
|
|
51
52
|
groupAble,
|
|
52
53
|
groupColumns,
|
|
53
54
|
groupSetting,
|
|
@@ -284,11 +285,16 @@ const useColumns = config => {
|
|
|
284
285
|
className: (0, _classnames.default)(transformedColumn?.onCell?.(data, index).className ?? '', {
|
|
285
286
|
'cell-group': groupColumns && data.children,
|
|
286
287
|
'cell-group-fixed': groupColumns && data.children && col.field === firstNonGroupColumn?.field
|
|
287
|
-
})
|
|
288
|
+
}),
|
|
289
|
+
'data-tooltip-id': "tooltip-cell-content"
|
|
290
|
+
// onMouseEnter: () => {
|
|
291
|
+
// onMouseHover(data, col as any)
|
|
292
|
+
// },
|
|
288
293
|
};
|
|
289
294
|
},
|
|
290
295
|
render: (value, record, rowIndex) => {
|
|
291
|
-
const
|
|
296
|
+
const colFormat = typeof col.format === 'function' ? col.format(record) : col.format;
|
|
297
|
+
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
292
298
|
if (groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
293
299
|
if (record.children) {
|
|
294
300
|
return (0, _columns.renderContent)(col, value, record, rowIndex, cellFormat);
|
|
@@ -312,7 +318,9 @@ const useColumns = config => {
|
|
|
312
318
|
});
|
|
313
319
|
};
|
|
314
320
|
return convertColumns(cloneColumns);
|
|
315
|
-
}, [
|
|
321
|
+
}, [groupColumns, getColumnSearchProps, sortMultiple, groupSetting, groupAble, t, dataSource, rowKey, handleResize, format]
|
|
322
|
+
// format, getColumnSearchProps, sortMultiple, groupSetting, groupAble, t, groupColumns, , handleResize, , t, cellHover
|
|
323
|
+
);
|
|
316
324
|
return [transformColumns];
|
|
317
325
|
};
|
|
318
326
|
var _default = exports.default = useColumns;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnyObject, GetRowKey } from "../type";
|
|
2
|
+
import type { Key } from "react";
|
|
3
|
+
declare const useLazyKVMap: <RecordType extends AnyObject = AnyObject>(data: readonly RecordType[], childrenColumnName: string, getRowKey: GetRowKey<RecordType>) => readonly [(key: Key) => RecordType];
|
|
4
|
+
export default useLazyKVMap;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
|
11
|
+
|
|
12
|
+
// import type { AnyObject } from '../../_util/type';
|
|
13
|
+
// import type { GetRowKey, Key } from '../interface';
|
|
14
|
+
|
|
15
|
+
const useLazyKVMap = (data, childrenColumnName, getRowKey) => {
|
|
16
|
+
const mapCacheRef = React.useRef({});
|
|
17
|
+
function getRecordByKey(key) {
|
|
18
|
+
if (!mapCacheRef.current || mapCacheRef.current.data !== data || mapCacheRef.current.childrenColumnName !== childrenColumnName || mapCacheRef.current.getRowKey !== getRowKey) {
|
|
19
|
+
const kvMap = new Map();
|
|
20
|
+
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
function dig(records) {
|
|
23
|
+
records.forEach((record, index) => {
|
|
24
|
+
const rowKey = getRowKey(record, index);
|
|
25
|
+
kvMap.set(rowKey, record);
|
|
26
|
+
if (record && typeof record === 'object' && childrenColumnName in record) {
|
|
27
|
+
dig(record[childrenColumnName] || []);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
dig(data);
|
|
32
|
+
mapCacheRef.current = {
|
|
33
|
+
data,
|
|
34
|
+
childrenColumnName,
|
|
35
|
+
kvMap,
|
|
36
|
+
getRowKey
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return mapCacheRef.current.kvMap?.get(key);
|
|
40
|
+
}
|
|
41
|
+
return [getRecordByKey];
|
|
42
|
+
};
|
|
43
|
+
var _default = exports.default = useLazyKVMap;
|
|
@@ -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) {
|
|
@@ -327,13 +347,15 @@ const convertLabelToTitle = data => {
|
|
|
327
347
|
label,
|
|
328
348
|
title,
|
|
329
349
|
value,
|
|
350
|
+
key,
|
|
330
351
|
...rest
|
|
331
352
|
} = item;
|
|
332
353
|
const newItem = {
|
|
333
354
|
...rest,
|
|
334
355
|
value,
|
|
335
|
-
|
|
336
|
-
|
|
356
|
+
label,
|
|
357
|
+
key: key ?? value,
|
|
358
|
+
title: title ?? label
|
|
337
359
|
};
|
|
338
360
|
if (item.children) {
|
|
339
361
|
newItem.children = convertLabelToTitle(item.children);
|
|
@@ -1640,7 +1662,7 @@ const removeBorderClass2 = (className, id) => {
|
|
|
1640
1662
|
}
|
|
1641
1663
|
};
|
|
1642
1664
|
exports.removeBorderClass2 = removeBorderClass2;
|
|
1643
|
-
const onAddBgSelectedCell = (selectedCells, id) => {
|
|
1665
|
+
const onAddBgSelectedCell = (selectedCells, id, isFocusCellIndex) => {
|
|
1644
1666
|
const selectors = Array.from(selectedCells).map(pos => {
|
|
1645
1667
|
const [row1, col1] = pos.split('-');
|
|
1646
1668
|
return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
|
|
@@ -1655,7 +1677,7 @@ const onAddBgSelectedCell = (selectedCells, id) => {
|
|
|
1655
1677
|
const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
|
|
1656
1678
|
const rowsSelectors = rowsArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
|
|
1657
1679
|
const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
|
|
1658
|
-
if (cellsIndex) {
|
|
1680
|
+
if (cellsIndex && isFocusCellIndex !== false) {
|
|
1659
1681
|
cellsIndex.forEach(cell => {
|
|
1660
1682
|
cell.classList.add('focus');
|
|
1661
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) => {
|
|
@@ -1938,6 +1943,7 @@ const GridEdit = props => {
|
|
|
1938
1943
|
onCell: (record, rowIndex) => {
|
|
1939
1944
|
const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
|
|
1940
1945
|
return {
|
|
1946
|
+
...column?.onCell?.(record, rowIndex),
|
|
1941
1947
|
onKeyDown: event => {
|
|
1942
1948
|
const key = getRowKey(record, dataSource.indexOf(record));
|
|
1943
1949
|
if (event.key === 'Control' && event.ctrlKey) {} else {
|
|
@@ -1978,14 +1984,18 @@ const GridEdit = props => {
|
|
|
1978
1984
|
}
|
|
1979
1985
|
}
|
|
1980
1986
|
if (event.key === 'Tab') {
|
|
1981
|
-
if (
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
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
|
+
}
|
|
1986
1996
|
}
|
|
1987
1997
|
}
|
|
1988
|
-
if (event.key === 'ArrowRight' && colIndex + 1 !==
|
|
1998
|
+
if (event.key === 'ArrowRight' && colIndex + 1 !== visibleCols.length) {
|
|
1989
1999
|
if (editingKey !== '') {} else {
|
|
1990
2000
|
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
1991
2001
|
}
|
|
@@ -2058,9 +2068,17 @@ const GridEdit = props => {
|
|
|
2058
2068
|
rowsSelected.current = new Set();
|
|
2059
2069
|
}
|
|
2060
2070
|
},
|
|
2071
|
+
// onMouseEnter: () => {
|
|
2072
|
+
//
|
|
2073
|
+
// },
|
|
2074
|
+
|
|
2061
2075
|
onClick: () => {
|
|
2062
2076
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
2063
2077
|
setEditingKey('');
|
|
2078
|
+
} else {
|
|
2079
|
+
if (editingKey) {
|
|
2080
|
+
handleCellClick(rowNumber, record, column);
|
|
2081
|
+
}
|
|
2064
2082
|
}
|
|
2065
2083
|
},
|
|
2066
2084
|
className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : `rc-ui-cell-editable cell-editable ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}`,
|
|
@@ -2073,14 +2091,14 @@ const GridEdit = props => {
|
|
|
2073
2091
|
title: (0, _columns.getValueCell)(column, record[column.field], format),
|
|
2074
2092
|
'data-col-index': colIndex,
|
|
2075
2093
|
'data-row-index': rowNumber,
|
|
2076
|
-
|
|
2094
|
+
'data-tooltip-id': "tooltip-cell-content",
|
|
2077
2095
|
// 'data-tooltip-content': 'tooltip-cell-content',
|
|
2078
2096
|
// 'data-tooltip-delay-show': 1000,
|
|
2079
2097
|
// 'data-tooltip-content': getValueCell(column, record[column.field as any], format),
|
|
2080
2098
|
editing: isEditing(record) && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record),
|
|
2081
2099
|
cellEditing,
|
|
2082
2100
|
t,
|
|
2083
|
-
tabIndex: (rowIndex ?? 0) *
|
|
2101
|
+
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex,
|
|
2084
2102
|
style: isPasteDragging ? {
|
|
2085
2103
|
cursor: "crosshair"
|
|
2086
2104
|
} : {}
|
|
@@ -2111,6 +2129,8 @@ const GridEdit = props => {
|
|
|
2111
2129
|
},
|
|
2112
2130
|
render: (value, record, rowIndex) => {
|
|
2113
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);
|
|
2114
2134
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
2115
2135
|
className: (0, _classnames.default)('ui-rc_cell-content', {
|
|
2116
2136
|
// disable: !isEditable(column as any, record)
|
|
@@ -2132,7 +2152,7 @@ const GridEdit = props => {
|
|
|
2132
2152
|
// }}
|
|
2133
2153
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
2134
2154
|
className: 'ui-rc_content'
|
|
2135
|
-
}, (0, _columns.renderContent)(column, value, record, rowIndex,
|
|
2155
|
+
}, (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat)),
|
|
2136
2156
|
// selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
|
|
2137
2157
|
// getLastSelectCell(selectedCells.current).col === colIndex &&
|
|
2138
2158
|
// isEditable(column as any, record) &&
|