es-grid-template 1.8.59 → 1.8.60
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/ColumnsChoose.js +4 -321
- package/es/grid-component/InternalTable.js +48 -53
- package/es/grid-component/TableGrid.js +18 -14
- package/es/grid-component/TempTable.js +0 -4
- package/es/grid-component/hooks/useColumns.d.ts +3 -1
- package/es/grid-component/hooks/utils.d.ts +1 -0
- package/es/grid-component/hooks/utils.js +25 -1
- package/es/grid-component/table/GridEdit.js +8 -4
- package/es/grid-component/table/Group.js +22 -6
- package/es/grid-component/table/InfiniteTable.js +1 -1
- package/es/grid-component/type.d.ts +8 -2
- package/lib/grid-component/ColumnsChoose.js +4 -321
- package/lib/grid-component/InternalTable.js +47 -52
- package/lib/grid-component/TableGrid.js +18 -14
- package/lib/grid-component/TempTable.js +0 -4
- package/lib/grid-component/hooks/utils.d.ts +1 -0
- package/lib/grid-component/hooks/utils.js +28 -3
- package/lib/grid-component/table/GridEdit.js +8 -4
- package/lib/grid-component/table/Group.js +22 -6
- package/lib/grid-component/table/InfiniteTable.js +1 -1
- package/lib/grid-component/type.d.ts +8 -2
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
require("react-resizable/css/styles.css");
|
|
11
11
|
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
12
12
|
var _hooks = require("./hooks");
|
|
13
|
+
var _server = _interopRequireDefault(require("react-dom/server"));
|
|
13
14
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
14
15
|
require("dayjs/locale/es");
|
|
15
16
|
require("dayjs/locale/vi");
|
|
@@ -250,30 +251,22 @@ const InternalTable = props => {
|
|
|
250
251
|
active: -1,
|
|
251
252
|
over: -1
|
|
252
253
|
});
|
|
253
|
-
const [tooltipContent, setTooltipContent] =
|
|
254
|
+
// const [tooltipContent, setTooltipContent] = useState<any>('')
|
|
255
|
+
|
|
254
256
|
const [filterStates, setFilterState] = _react.default.useState(null);
|
|
255
257
|
const [isFullScreen, setIsFullScreen] = _react.default.useState(false);
|
|
258
|
+
const [isOpenTooltip, setIsOpenTooltip] = _react.default.useState(false);
|
|
256
259
|
const mergedData = _react.default.useMemo(() => {
|
|
257
|
-
if (
|
|
260
|
+
if (groupSetting && groupSetting.client !== false) {
|
|
258
261
|
return (0, _hooks.groupArrayByColumns)(dataSource, groupColumns);
|
|
259
262
|
}
|
|
260
263
|
return (0, _hooks.addRowIdArray)(dataSource);
|
|
261
|
-
}, [dataSource,
|
|
264
|
+
}, [dataSource, groupColumns, groupSetting?.client]);
|
|
262
265
|
|
|
263
266
|
// ========================= Keys =========================
|
|
264
267
|
const [mergedFilterKeys, setMergedFilterKeys] = (0, _useMergedState.default)((0, _hooks.getAllRowKey)(mergedData), {
|
|
265
268
|
value: undefined
|
|
266
269
|
});
|
|
267
|
-
//
|
|
268
|
-
// const originData = React.useMemo(() => {
|
|
269
|
-
//
|
|
270
|
-
// if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
271
|
-
// return groupArrayByColumns(dataSource, groupColumns)
|
|
272
|
-
// }
|
|
273
|
-
// return addRowIdArray(dataSource)
|
|
274
|
-
//
|
|
275
|
-
// }, [dataSource, groupAble, groupColumns, groupSetting])
|
|
276
|
-
|
|
277
270
|
const [columns, setColumns] = _react.default.useState([]);
|
|
278
271
|
_react.default.useEffect(() => {
|
|
279
272
|
const totalHeight = propsHeight;
|
|
@@ -452,7 +445,7 @@ const InternalTable = props => {
|
|
|
452
445
|
wrapSettings: wrapSettings
|
|
453
446
|
})),
|
|
454
447
|
// ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
455
|
-
ellipsis: column.ellipsis !== false
|
|
448
|
+
ellipsis: column.ellipsis !== false || wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
456
449
|
// ellipsis: false,
|
|
457
450
|
// ellipsis: column.ellipsis !== false,
|
|
458
451
|
|
|
@@ -568,6 +561,10 @@ const InternalTable = props => {
|
|
|
568
561
|
${wrapSettings && wrapSettings.wrapMode === 'Content' ? 'ui-rc-table-cell-ellipsis' : ''}`
|
|
569
562
|
}),
|
|
570
563
|
onCell: (data, index) => {
|
|
564
|
+
const tooltipContent = isOpenTooltip === false ? '' : column?.tooltipDescription ? typeof column.tooltipDescription === 'function' ? column.tooltipDescription({
|
|
565
|
+
value: data[column.field ?? ''],
|
|
566
|
+
record: data
|
|
567
|
+
}) : column.tooltipDescription : column.template && typeof column.template !== 'function' ? column.template : data[column.field ?? ''];
|
|
571
568
|
return {
|
|
572
569
|
id: `${column.field}`,
|
|
573
570
|
colSpan: groupColumns && data.children && column.field === firstNonGroupColumn?.field ? 2 : groupColumns && data.children && nonGroupColumns[1].field === column.field ? 0 : 1,
|
|
@@ -578,7 +575,23 @@ const InternalTable = props => {
|
|
|
578
575
|
'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field
|
|
579
576
|
}),
|
|
580
577
|
// 'data-tooltip-id': "tooltip-cell-content"
|
|
581
|
-
'data-tooltip-id': `${id}-tooltip-cell-content
|
|
578
|
+
'data-tooltip-id': `${id}-tooltip-cell-content`,
|
|
579
|
+
"data-tooltip-html": _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tooltipContent)),
|
|
580
|
+
onMouseEnter: e => {
|
|
581
|
+
if (e.target.firstChild?.clientWidth <= e.target.firstChild?.scrollWidth) {
|
|
582
|
+
if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
|
|
583
|
+
setIsOpenTooltip(true);
|
|
584
|
+
} else {
|
|
585
|
+
setIsOpenTooltip(false);
|
|
586
|
+
}
|
|
587
|
+
} else {
|
|
588
|
+
if (e.target.clientWidth < e.target.scrollWidth) {
|
|
589
|
+
setIsOpenTooltip(true);
|
|
590
|
+
} else {
|
|
591
|
+
setIsOpenTooltip(false);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
582
595
|
};
|
|
583
596
|
},
|
|
584
597
|
render: (value, record, rowIndex) => {
|
|
@@ -600,6 +613,10 @@ const InternalTable = props => {
|
|
|
600
613
|
}
|
|
601
614
|
return /*#__PURE__*/_react.default.createElement("span", null, currentGroupColumn?.headerText, ": ", (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat));
|
|
602
615
|
}
|
|
616
|
+
if (groupAble && record.children && column.sumGroup === true && column.type === 'number') {
|
|
617
|
+
const sumValue = (0, _hooks.sumByField)((0, _hooks.filterDataByColumns4)(record.children, [], []), column?.field);
|
|
618
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, sumValue);
|
|
619
|
+
}
|
|
603
620
|
return (0, _columns.renderContent)(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
604
621
|
},
|
|
605
622
|
// defaultSortOrder: 'ascend',
|
|
@@ -921,10 +938,7 @@ const InternalTable = props => {
|
|
|
921
938
|
const handleFullScreen = () => {
|
|
922
939
|
setIsFullScreen(!isFullScreen);
|
|
923
940
|
};
|
|
924
|
-
|
|
925
|
-
// const TableComponent = infiniteScroll ? InfiniteTable : (groupAble ? Group : editAble ? GridEdit : Grid)
|
|
926
|
-
const TableComponent = groupAble ? _Group.default : _Grid.default;
|
|
927
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, true && /*#__PURE__*/_react.default.createElement(_core.DndContext, {
|
|
941
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
|
|
928
942
|
sensors: sensors,
|
|
929
943
|
modifiers: [_modifiers.restrictToHorizontalAxis],
|
|
930
944
|
onDragEnd: onDragEnd,
|
|
@@ -935,7 +949,7 @@ const InternalTable = props => {
|
|
|
935
949
|
strategy: _sortable.horizontalListSortingStrategy
|
|
936
950
|
}, /*#__PURE__*/_react.default.createElement(DragIndexContext.Provider, {
|
|
937
951
|
value: dragIndex
|
|
938
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
952
|
+
}, /*#__PURE__*/_react.default.createElement(_Group.default, (0, _extends2.default)({}, rest, {
|
|
939
953
|
t: t,
|
|
940
954
|
id: id,
|
|
941
955
|
locale: locale,
|
|
@@ -963,34 +977,23 @@ const InternalTable = props => {
|
|
|
963
977
|
groupColumns: groupColumns,
|
|
964
978
|
commandClick: triggerCommandClick,
|
|
965
979
|
summary: summary,
|
|
966
|
-
pagination: pagination
|
|
967
|
-
// scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
|
|
968
|
-
// scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
|
|
969
|
-
,
|
|
970
|
-
|
|
980
|
+
pagination: pagination,
|
|
971
981
|
scroll: scrollHeight - (summary ? 1 : 1) < 0 ? {
|
|
972
982
|
y: 500
|
|
973
983
|
} : {
|
|
974
984
|
y: scrollHeight - (summary ? 1 : 1)
|
|
975
985
|
} // scroll height auto, không quá 600
|
|
976
|
-
|
|
977
|
-
// height={isFullScreen ? windowSize.innerHeight - 100 : propsHeight}
|
|
978
986
|
,
|
|
979
987
|
height: propsHeight,
|
|
980
|
-
scrollHeight: scrollHeight
|
|
981
|
-
components
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
}
|
|
988
|
-
},
|
|
989
|
-
setTooltipContent: setTooltipContent,
|
|
988
|
+
scrollHeight: scrollHeight
|
|
989
|
+
// components={{
|
|
990
|
+
// header: { cell: ResizableTitle },
|
|
991
|
+
// body: { cell: TableBodyCell }
|
|
992
|
+
// }}
|
|
993
|
+
,
|
|
994
|
+
|
|
990
995
|
onFilter: val => {
|
|
991
996
|
handleOnFilter(val);
|
|
992
|
-
// triggerFilter?.(convertFilters(val))
|
|
993
|
-
// onFilter?.(convertFilters(val))
|
|
994
997
|
},
|
|
995
998
|
setMergedFilterKeys: setMergedFilterKeys,
|
|
996
999
|
mergedFilterKeys: mergedFilterKeys,
|
|
@@ -998,10 +1001,6 @@ const InternalTable = props => {
|
|
|
998
1001
|
onChange: handleChange,
|
|
999
1002
|
handleFullScreen: handleFullScreen,
|
|
1000
1003
|
isFullScreen: isFullScreen
|
|
1001
|
-
|
|
1002
|
-
// onChange={(paging, filters, sorter) => {
|
|
1003
|
-
// handleChange(sorter)
|
|
1004
|
-
// }}
|
|
1005
1004
|
})))), /*#__PURE__*/_react.default.createElement(_core.DragOverlay, {
|
|
1006
1005
|
style: {
|
|
1007
1006
|
minWidth: 100,
|
|
@@ -1053,7 +1052,7 @@ const InternalTable = props => {
|
|
|
1053
1052
|
strategy: _sortable.horizontalListSortingStrategy
|
|
1054
1053
|
}, /*#__PURE__*/_react.default.createElement(DragIndexContext.Provider, {
|
|
1055
1054
|
value: dragIndex
|
|
1056
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
1055
|
+
}, /*#__PURE__*/_react.default.createElement(_Grid.default, (0, _extends2.default)({}, rest, {
|
|
1057
1056
|
t: t,
|
|
1058
1057
|
id: _faker.faker.string.alpha(20),
|
|
1059
1058
|
locale: locale,
|
|
@@ -1099,8 +1098,10 @@ const InternalTable = props => {
|
|
|
1099
1098
|
body: {
|
|
1100
1099
|
cell: TableBodyCell
|
|
1101
1100
|
}
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1101
|
+
}
|
|
1102
|
+
// setTooltipContent={setTooltipContent}
|
|
1103
|
+
,
|
|
1104
|
+
|
|
1104
1105
|
onFilter: val => {
|
|
1105
1106
|
handleOnFilter(val);
|
|
1106
1107
|
// triggerFilter?.(convertFilters(val))
|
|
@@ -1137,12 +1138,6 @@ const InternalTable = props => {
|
|
|
1137
1138
|
id: `${id}-tooltip-cell-content`,
|
|
1138
1139
|
style: {
|
|
1139
1140
|
zIndex: 1999
|
|
1140
|
-
},
|
|
1141
|
-
render: () => {
|
|
1142
|
-
if (tooltipContent) {
|
|
1143
|
-
return /*#__PURE__*/_react.default.createElement("span", null, typeof tooltipContent === 'function' ? tooltipContent() : tooltipContent);
|
|
1144
|
-
}
|
|
1145
|
-
return undefined;
|
|
1146
1141
|
}
|
|
1147
1142
|
}));
|
|
1148
1143
|
};
|
|
@@ -62,7 +62,7 @@ const TableGrid = props => {
|
|
|
62
62
|
rowHoverable,
|
|
63
63
|
title,
|
|
64
64
|
format,
|
|
65
|
-
|
|
65
|
+
virtualRow = true,
|
|
66
66
|
t,
|
|
67
67
|
lang,
|
|
68
68
|
contextMenuOpen,
|
|
@@ -322,14 +322,18 @@ const TableGrid = props => {
|
|
|
322
322
|
'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
|
|
323
323
|
}, styles.customTable),
|
|
324
324
|
bordered: true,
|
|
325
|
-
virtual:
|
|
325
|
+
virtual: virtualRow,
|
|
326
326
|
columns: columns,
|
|
327
327
|
rowKey: rowKey,
|
|
328
328
|
rowHoverable: rowHoverable,
|
|
329
329
|
size: "small",
|
|
330
330
|
scroll: scroll ? scroll : {
|
|
331
331
|
y: 500
|
|
332
|
-
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// scroll={{ x: 'max-content', y: 700 }}
|
|
335
|
+
,
|
|
336
|
+
|
|
333
337
|
onRow: (data, index) => {
|
|
334
338
|
return {
|
|
335
339
|
onDoubleClick: handleRowDoubleClick(data, index),
|
|
@@ -380,16 +384,6 @@ const TableGrid = props => {
|
|
|
380
384
|
, {
|
|
381
385
|
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
382
386
|
mode: 'scroll'
|
|
383
|
-
})), fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
|
|
384
|
-
fontSize: 16,
|
|
385
|
-
onClick: () => handleFullScreen?.(),
|
|
386
|
-
"data-tooltip-id": "tooltip-icon",
|
|
387
|
-
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
388
|
-
}) : /*#__PURE__*/_react.default.createElement(_becoxyIcons.Maximize, {
|
|
389
|
-
fontSize: 16,
|
|
390
|
-
onClick: () => handleFullScreen?.(),
|
|
391
|
-
"data-tooltip-id": "tooltip-icon",
|
|
392
|
-
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
393
387
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
394
388
|
style: {
|
|
395
389
|
display: 'flex',
|
|
@@ -405,7 +399,17 @@ const TableGrid = props => {
|
|
|
405
399
|
// @ts-ignore
|
|
406
400
|
,
|
|
407
401
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
408
|
-
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate,
|
|
402
|
+
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
|
|
403
|
+
fontSize: 16,
|
|
404
|
+
onClick: () => handleFullScreen?.(),
|
|
405
|
+
"data-tooltip-id": "tooltip-icon",
|
|
406
|
+
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
407
|
+
}) : /*#__PURE__*/_react.default.createElement(_becoxyIcons.Maximize, {
|
|
408
|
+
fontSize: 16,
|
|
409
|
+
onClick: () => handleFullScreen?.(),
|
|
410
|
+
"data-tooltip-id": "tooltip-icon",
|
|
411
|
+
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
412
|
+
})), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
|
|
409
413
|
columns: columns,
|
|
410
414
|
t: t,
|
|
411
415
|
columnsGroup: groupColumns,
|
|
@@ -17,11 +17,7 @@ const TempTable = props => {
|
|
|
17
17
|
editAble,
|
|
18
18
|
...rest
|
|
19
19
|
} = props;
|
|
20
|
-
|
|
21
|
-
// const TabComponent = groupAble ? InternalTable : Table
|
|
22
20
|
const TabComponent = groupAble ? _InternalTable.default : _tableComponent.default;
|
|
23
|
-
// const TabComponent = InternalTable
|
|
24
|
-
|
|
25
21
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(TabComponent, (0, _extends2.default)({}, rest, {
|
|
26
22
|
groupAble: groupAble,
|
|
27
23
|
editAble: editAble
|
|
@@ -160,6 +160,7 @@ export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
|
|
|
160
160
|
export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
|
|
161
161
|
export declare const isRangeCell: (selectedCells: any, type: string, rowIndex: number, colIndex: number) => boolean;
|
|
162
162
|
export declare const isSelectedCell: (selectedCells: any, rowIndex: number, colIndex: number) => any;
|
|
163
|
+
export declare function groupAndSum(data: any[], columns: any[], groupField?: string): unknown[];
|
|
163
164
|
export declare function groupArrayByColumns(data: any[], columns: string[] | undefined): any;
|
|
164
165
|
export declare const isFormattedNumber: (str: string) => boolean;
|
|
165
166
|
export declare const detectSeparators: (str: string) => {
|
|
@@ -25,6 +25,7 @@ exports.getCellsByPosition2 = getCellsByPosition2;
|
|
|
25
25
|
exports.getFormat = exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getDateRangeFormat = exports.getColumnsVisible = void 0;
|
|
26
26
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
27
27
|
exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
28
|
+
exports.groupAndSum = groupAndSum;
|
|
28
29
|
exports.groupArrayByColumns = groupArrayByColumns;
|
|
29
30
|
exports.hideDraggingPoint = void 0;
|
|
30
31
|
exports.invalidDate = invalidDate;
|
|
@@ -39,8 +40,8 @@ exports.isRightMostInRegion = isRightMostInRegion;
|
|
|
39
40
|
exports.isTopMostInRegion = exports.isSelectedCell = void 0;
|
|
40
41
|
exports.mergeWithFilter = mergeWithFilter;
|
|
41
42
|
exports.mergeWithFilter2 = mergeWithFilter2;
|
|
42
|
-
exports.
|
|
43
|
-
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.unFlattenData = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sumByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeVietnameseTones = exports.removeInvisibleColumns = void 0;
|
|
43
|
+
exports.removeColumns = exports.removeClassCellIndexSelected = exports.removeClassBorderPasteCell = exports.removeBorderPasteClass = exports.removeBorderClass2 = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveBorderSelectedCell = exports.onRemoveBgSelectedCell = exports.onRemoveBgCellIndex = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.onAddBgCellIndex = exports.newGuid = exports.mergedSets = void 0;
|
|
44
|
+
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.unFlattenData = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sumByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeVietnameseTones = exports.removeInvisibleColumns = exports.removeFieldRecursive = void 0;
|
|
44
45
|
exports.updateDataByFilter = updateDataByFilter;
|
|
45
46
|
exports.updateOrInsert = updateOrInsert;
|
|
46
47
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
@@ -2473,6 +2474,29 @@ const isSelectedCell = (selectedCells, rowIndex, colIndex) => {
|
|
|
2473
2474
|
return selectedCells.has(key);
|
|
2474
2475
|
};
|
|
2475
2476
|
exports.isSelectedCell = isSelectedCell;
|
|
2477
|
+
function groupAndSum(data, columns, groupField = "name") {
|
|
2478
|
+
const sumFields = columns.filter(col => col.sumGroup).map(col => col.field);
|
|
2479
|
+
const groups = {};
|
|
2480
|
+
data.forEach(item => {
|
|
2481
|
+
const key = item[groupField];
|
|
2482
|
+
if (!groups[key]) {
|
|
2483
|
+
groups[key] = {
|
|
2484
|
+
[groupField]: key
|
|
2485
|
+
};
|
|
2486
|
+
|
|
2487
|
+
// khởi tạo các trường sum = 0
|
|
2488
|
+
sumFields.forEach(field => {
|
|
2489
|
+
groups[key][field] = 0;
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
// cộng dồn các field có sumGroup
|
|
2494
|
+
sumFields.forEach(field => {
|
|
2495
|
+
groups[key][field] += Number(item[field] || 0);
|
|
2496
|
+
});
|
|
2497
|
+
});
|
|
2498
|
+
return Object.values(groups);
|
|
2499
|
+
}
|
|
2476
2500
|
function groupArrayByColumns(data, columns) {
|
|
2477
2501
|
const result = [];
|
|
2478
2502
|
const checkEmpty = d => {
|
|
@@ -2768,7 +2792,8 @@ const removeInvisibleColumns = columns => {
|
|
|
2768
2792
|
exports.removeInvisibleColumns = removeInvisibleColumns;
|
|
2769
2793
|
const sumByField = (data, field) => {
|
|
2770
2794
|
return data.reduce((total, item) => {
|
|
2771
|
-
if (item[field] != null) {
|
|
2795
|
+
// if (item[field] != null) {
|
|
2796
|
+
if (typeof item[field] === 'number' && !isNaN(item[field])) {
|
|
2772
2797
|
return total + item[field];
|
|
2773
2798
|
} else if (item.children && item.children.length > 0) {
|
|
2774
2799
|
return total + sumByField(item.children, field);
|
|
@@ -246,7 +246,7 @@ const GridEdit = props => {
|
|
|
246
246
|
contextMenuItems: propsContext,
|
|
247
247
|
showDefaultContext,
|
|
248
248
|
validate,
|
|
249
|
-
setTooltipContent,
|
|
249
|
+
// setTooltipContent,
|
|
250
250
|
onBlur,
|
|
251
251
|
locale,
|
|
252
252
|
mergedFilterKeys,
|
|
@@ -1905,7 +1905,8 @@ const GridEdit = props => {
|
|
|
1905
1905
|
};
|
|
1906
1906
|
const handleEdit = (record, col, editType, rowIndex, e) => {
|
|
1907
1907
|
(0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
|
|
1908
|
-
|
|
1908
|
+
|
|
1909
|
+
// setTooltipContent('')
|
|
1909
1910
|
|
|
1910
1911
|
// @ts-ignore
|
|
1911
1912
|
// setEditingKey(record[rowKey])
|
|
@@ -2374,7 +2375,9 @@ const GridEdit = props => {
|
|
|
2374
2375
|
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
2375
2376
|
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
2376
2377
|
const rowError = dataErrors.find(it => it.index === rowNumber);
|
|
2377
|
-
|
|
2378
|
+
|
|
2379
|
+
// const cellError = rowError && column.field && rowError[column.field]?.field === column.field ? rowError[column.field] : null
|
|
2380
|
+
|
|
2378
2381
|
const handleClick = event => {
|
|
2379
2382
|
if (!(record[rowKey] === editingKey.current) && record[rowKey] !== editingKey.current && (0, _hooks.isEditable)(column, record)) {
|
|
2380
2383
|
handleEdit(record, column, (0, _hooks.getEditType)(column, record), rowNumber, event);
|
|
@@ -2390,7 +2393,8 @@ const GridEdit = props => {
|
|
|
2390
2393
|
}),
|
|
2391
2394
|
onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
|
|
2392
2395
|
onMouseEnter: event => {
|
|
2393
|
-
setTooltipContent(cellError ? cellError.message : '')
|
|
2396
|
+
// setTooltipContent(cellError ? cellError.message : '')
|
|
2397
|
+
|
|
2394
2398
|
handleMouseEnter(rowNumber, colIndex, event);
|
|
2395
2399
|
|
|
2396
2400
|
// hoveredRow.current = rowNumber
|
|
@@ -13,6 +13,7 @@ var _hooks = require("../hooks");
|
|
|
13
13
|
var _ColumnsGroup = require("../ColumnsGroup/ColumnsGroup");
|
|
14
14
|
var _columns = require("../hooks/columns");
|
|
15
15
|
var _becoxyIcons = require("becoxy-icons");
|
|
16
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
16
17
|
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); }
|
|
17
18
|
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; }
|
|
18
19
|
const Group = props => {
|
|
@@ -51,11 +52,12 @@ const Group = props => {
|
|
|
51
52
|
return [];
|
|
52
53
|
});
|
|
53
54
|
_react.default.useEffect(() => {
|
|
54
|
-
if (defaultExpandedRowKeys) {
|
|
55
|
-
setInnerExpandedKeys(defaultExpandedRowKeys);
|
|
56
|
-
}
|
|
57
55
|
if (defaultExpandAllRows) {
|
|
58
56
|
setInnerExpandedKeys((0, _hooks.findAllChildrenKeys)(dataSource, getRowKey, childrenColumnName) ?? []);
|
|
57
|
+
} else {
|
|
58
|
+
if (defaultExpandedRowKeys) {
|
|
59
|
+
setInnerExpandedKeys(defaultExpandedRowKeys);
|
|
60
|
+
}
|
|
59
61
|
}
|
|
60
62
|
}, [defaultExpandedRowKeys, defaultExpandAllRows, dataSource]);
|
|
61
63
|
const mergedExpandedKeys = _react.default.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
|
|
@@ -105,11 +107,11 @@ const Group = props => {
|
|
|
105
107
|
columnsGrouped: groupColumns,
|
|
106
108
|
onSubmit: handleOnGroup
|
|
107
109
|
}), /*#__PURE__*/_react.default.createElement(_react.Fragment, null, innerExpandedKeys.length > 0 ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Collapse2, {
|
|
108
|
-
fontSize:
|
|
110
|
+
fontSize: 16,
|
|
109
111
|
color: '#555555',
|
|
110
112
|
onClick: handleCollapseAllGroup
|
|
111
113
|
}) : /*#__PURE__*/_react.default.createElement(_becoxyIcons.Expand2, {
|
|
112
|
-
fontSize:
|
|
114
|
+
fontSize: 16,
|
|
113
115
|
color: '#555555',
|
|
114
116
|
onClick: handleExpandAllGroup
|
|
115
117
|
})));
|
|
@@ -122,6 +124,20 @@ const Group = props => {
|
|
|
122
124
|
position: 'relative'
|
|
123
125
|
},
|
|
124
126
|
id: id
|
|
127
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.ConfigProvider, {
|
|
128
|
+
theme: {
|
|
129
|
+
components: {
|
|
130
|
+
Table: {
|
|
131
|
+
rowHoverBg: '#eb461912',
|
|
132
|
+
rowSelectedBg: '#eb4619',
|
|
133
|
+
rowSelectedHoverBg: '#eb4619',
|
|
134
|
+
cellFontSize: 12,
|
|
135
|
+
cellFontSizeSM: 13,
|
|
136
|
+
headerBg: '#ffffff',
|
|
137
|
+
cellPaddingBlockSM: 7
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
125
141
|
}, /*#__PURE__*/_react.default.createElement(_TableGrid.default, (0, _extends2.default)({}, rest, {
|
|
126
142
|
t: t,
|
|
127
143
|
id: id,
|
|
@@ -183,6 +199,6 @@ const Group = props => {
|
|
|
183
199
|
groupToolbar: groupToolbar,
|
|
184
200
|
groupColumns: groupColumns,
|
|
185
201
|
isFullScreen: isFullScreen
|
|
186
|
-
}))));
|
|
202
|
+
})))));
|
|
187
203
|
};
|
|
188
204
|
var _default = exports.default = Group;
|
|
@@ -118,7 +118,10 @@ export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>,
|
|
|
118
118
|
headerTextAlign?: ITextAlign;
|
|
119
119
|
template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
|
|
120
120
|
showTooltip?: boolean;
|
|
121
|
-
tooltipDescription?: ReactNode | ReactElement | ((
|
|
121
|
+
tooltipDescription?: ReactNode | ReactElement | ((args: {
|
|
122
|
+
value: any;
|
|
123
|
+
record: RecordType;
|
|
124
|
+
}) => ReactNode | ReactElement);
|
|
122
125
|
headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnTable<RecordType>) => React.ReactNode | React.ReactElement);
|
|
123
126
|
commandItems?: CommandItem[];
|
|
124
127
|
children?: ColumnTable<RecordType>[];
|
|
@@ -136,6 +139,7 @@ export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>,
|
|
|
136
139
|
editFromSettings?: IEditFromSettings;
|
|
137
140
|
fixedType?: FixedType;
|
|
138
141
|
headerTextWrap?: boolean;
|
|
142
|
+
sumGroup?: boolean;
|
|
139
143
|
allowSelection?: boolean | ((rowData: RecordType) => boolean);
|
|
140
144
|
onCellStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Cell<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
|
|
141
145
|
onCellHeaderStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
|
|
@@ -195,7 +199,7 @@ export type Sort = {
|
|
|
195
199
|
field: string;
|
|
196
200
|
order: 'ascend' | 'descend' | null;
|
|
197
201
|
};
|
|
198
|
-
export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary' | 'pagination' | 'locale'> {
|
|
202
|
+
export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary' | 'pagination' | 'locale' | 'virtual'> {
|
|
199
203
|
editAble?: boolean;
|
|
200
204
|
infiniteScroll?: boolean;
|
|
201
205
|
theme?: {
|
|
@@ -203,6 +207,8 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
|
|
|
203
207
|
backgroundColor?: string;
|
|
204
208
|
color?: string;
|
|
205
209
|
};
|
|
210
|
+
virtualRow?: boolean;
|
|
211
|
+
virtualColumns?: boolean;
|
|
206
212
|
next?: () => void;
|
|
207
213
|
locale?: Locale;
|
|
208
214
|
groupAble?: boolean;
|