es-grid-template 1.8.71 → 1.8.73
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/TempTable.js +2 -1
- package/es/grid-component/type.d.ts +1 -3
- package/es/group-component/ColumnsChoose.d.ts +13 -0
- package/es/group-component/ColumnsChoose.js +211 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
- package/es/group-component/ColumnsGroup/index.d.ts +1 -0
- package/es/group-component/ColumnsGroup/index.js +1 -0
- package/es/group-component/ContextMenu.d.ts +19 -0
- package/es/group-component/ContextMenu.js +74 -0
- package/es/group-component/InternalTable.d.ts +8 -0
- package/es/group-component/InternalTable.js +224 -0
- package/es/group-component/TableContainer.d.ts +49 -0
- package/es/group-component/TableContainer.js +375 -0
- package/es/group-component/TableContainerEdit.d.ts +48 -0
- package/es/group-component/TableContainerEdit.js +2068 -0
- package/es/group-component/body/EditableCell.d.ts +16 -0
- package/es/group-component/body/EditableCell.js +1066 -0
- package/es/group-component/body/TableBody.d.ts +14 -0
- package/es/group-component/body/TableBody.js +82 -0
- package/es/group-component/body/TableBodyCell.d.ts +12 -0
- package/es/group-component/body/TableBodyCell.js +587 -0
- package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/es/group-component/body/TableBodyCellEdit.js +1398 -0
- package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/es/group-component/body/TableBodyCellEmpty.js +149 -0
- package/es/group-component/body/TableBodyRow.d.ts +21 -0
- package/es/group-component/body/TableBodyRow.js +199 -0
- package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
- package/es/group-component/components/ControlCheckbox.d.ts +13 -0
- package/es/group-component/components/ControlCheckbox.js +84 -0
- package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/es/group-component/components/EditForm/EditForm.js +394 -0
- package/es/group-component/components/EditForm/index.d.ts +1 -0
- package/es/group-component/components/EditForm/index.js +1 -0
- package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/es/group-component/components/InputControl/InputControl.js +118 -0
- package/es/group-component/components/InputControl/index.d.ts +1 -0
- package/es/group-component/components/InputControl/index.js +1 -0
- package/es/group-component/components/async-select/index.d.ts +11 -0
- package/es/group-component/components/async-select/index.js +38 -0
- package/es/group-component/components/async-table-select/index.d.ts +11 -0
- package/es/group-component/components/async-table-select/index.js +40 -0
- package/es/group-component/components/checkbox-control/index.d.ts +13 -0
- package/es/group-component/components/checkbox-control/index.js +40 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
- package/es/group-component/components/command/Command.d.ts +10 -0
- package/es/group-component/components/command/Command.js +35 -0
- package/es/group-component/components/number/index.d.ts +12 -0
- package/es/group-component/components/number/index.js +42 -0
- package/es/group-component/components/number-range/index.d.ts +13 -0
- package/es/group-component/components/number-range/index.js +79 -0
- package/es/group-component/features/operator.d.ts +24 -0
- package/es/group-component/features/operator.js +62 -0
- package/es/group-component/footer/TableFooter.d.ts +7 -0
- package/es/group-component/footer/TableFooter.js +34 -0
- package/es/group-component/footer/TableFooterCell.d.ts +7 -0
- package/es/group-component/footer/TableFooterCell.js +66 -0
- package/es/group-component/footer/TableFooterRow.d.ts +8 -0
- package/es/group-component/footer/TableFooterRow.js +30 -0
- package/es/group-component/header/TableHead.d.ts +15 -0
- package/es/group-component/header/TableHead.js +98 -0
- package/es/group-component/header/TableHeadCell.d.ts +15 -0
- package/es/group-component/header/TableHeadCell.js +310 -0
- package/es/group-component/header/TableHeadCell2.d.ts +17 -0
- package/es/group-component/header/TableHeadCell2.js +321 -0
- package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/es/group-component/header/TableHeadGroupCell.js +94 -0
- package/es/group-component/header/TableHeadRow.d.ts +15 -0
- package/es/group-component/header/TableHeadRow.js +52 -0
- package/es/group-component/header/renderFilter.d.ts +20 -0
- package/es/group-component/header/renderFilter.js +291 -0
- package/es/group-component/hook/convert.d.ts +1 -0
- package/es/group-component/hook/convert.js +28 -0
- package/es/group-component/hook/useColumns.d.ts +28 -0
- package/es/group-component/hook/useColumns.js +306 -0
- package/es/group-component/hook/useFilterOperator.d.ts +7 -0
- package/es/group-component/hook/useFilterOperator.js +33 -0
- package/es/group-component/hook/utils.d.ts +220 -0
- package/es/group-component/hook/utils.js +2340 -0
- package/es/group-component/index.d.ts +2 -0
- package/es/group-component/index.js +2 -0
- package/es/group-component/style.d.ts +22 -0
- package/es/group-component/style.js +48 -0
- package/es/group-component/style.scss +1438 -0
- package/es/group-component/table/Grid.d.ts +33 -0
- package/es/group-component/table/Grid.js +439 -0
- package/es/group-component/table/TableWrapper.d.ts +33 -0
- package/es/group-component/table/TableWrapper.js +250 -0
- package/es/group-component/useContext.d.ts +100 -0
- package/es/group-component/useContext.js +21 -0
- package/es/table-component/InternalTable.js +9 -2
- package/es/table-component/TableContainer.d.ts +1 -0
- package/es/table-component/TableContainer.js +6 -2
- package/es/table-component/TableContainerEdit.d.ts +1 -0
- package/es/table-component/TableContainerEdit.js +4 -2
- package/es/table-component/body/TableBodyCell.js +49 -40
- package/es/table-component/body/TableBodyCellEdit.js +9 -6
- package/es/table-component/body/TableBodyRow.js +4 -1
- package/es/table-component/header/TableHeadCell2.js +39 -3
- package/es/table-component/hook/utils.d.ts +1 -0
- package/es/table-component/hook/utils.js +15 -7
- package/es/table-component/style.js +1 -1
- package/es/table-component/table/Grid.d.ts +1 -0
- package/es/table-component/table/Grid.js +10 -3
- package/es/table-component/useContext.d.ts +6 -0
- package/es/table-component/useContext.js +2 -1
- package/es/table-virtuoso/InternalTable.js +2 -2
- package/es/table-virtuoso/body/TableBodyCell.js +2 -7
- package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
- package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/es/table-virtuoso/body/TableBodyRow.js +43 -1
- package/es/table-virtuoso/hook/utils.d.ts +1 -0
- package/es/table-virtuoso/hook/utils.js +29 -0
- package/es/table-virtuoso/style.js +3 -1
- package/es/table-virtuoso/table/Grid.js +2 -2
- package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/es/table-virtuoso/table/TableWrapper.js +24 -5
- package/es/table-virtuoso/useContext.d.ts +6 -3
- package/es/table-virtuoso/useContext.js +18 -0
- package/lib/grid-component/TempTable.js +2 -1
- package/lib/grid-component/type.d.ts +1 -3
- package/lib/group-component/ColumnsChoose.d.ts +13 -0
- package/lib/group-component/ColumnsChoose.js +221 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
- package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
- package/lib/group-component/ColumnsGroup/index.js +16 -0
- package/lib/group-component/ContextMenu.d.ts +19 -0
- package/lib/group-component/ContextMenu.js +83 -0
- package/lib/group-component/InternalTable.d.ts +8 -0
- package/lib/group-component/InternalTable.js +233 -0
- package/lib/group-component/TableContainer.d.ts +49 -0
- package/lib/group-component/TableContainer.js +382 -0
- package/lib/group-component/TableContainerEdit.d.ts +48 -0
- package/lib/group-component/TableContainerEdit.js +2075 -0
- package/lib/group-component/body/EditableCell.d.ts +16 -0
- package/lib/group-component/body/EditableCell.js +1075 -0
- package/lib/group-component/body/TableBody.d.ts +14 -0
- package/lib/group-component/body/TableBody.js +91 -0
- package/lib/group-component/body/TableBodyCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyCell.js +595 -0
- package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
- package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
- package/lib/group-component/body/TableBodyRow.d.ts +21 -0
- package/lib/group-component/body/TableBodyRow.js +206 -0
- package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
- package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
- package/lib/group-component/components/ControlCheckbox.js +92 -0
- package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/lib/group-component/components/EditForm/EditForm.js +404 -0
- package/lib/group-component/components/EditForm/index.d.ts +1 -0
- package/lib/group-component/components/EditForm/index.js +16 -0
- package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/lib/group-component/components/InputControl/InputControl.js +127 -0
- package/lib/group-component/components/InputControl/index.d.ts +1 -0
- package/lib/group-component/components/InputControl/index.js +16 -0
- package/lib/group-component/components/async-select/index.d.ts +11 -0
- package/lib/group-component/components/async-select/index.js +47 -0
- package/lib/group-component/components/async-table-select/index.d.ts +11 -0
- package/lib/group-component/components/async-table-select/index.js +49 -0
- package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
- package/lib/group-component/components/checkbox-control/index.js +48 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
- package/lib/group-component/components/command/Command.d.ts +10 -0
- package/lib/group-component/components/command/Command.js +44 -0
- package/lib/group-component/components/number/index.d.ts +12 -0
- package/lib/group-component/components/number/index.js +50 -0
- package/lib/group-component/components/number-range/index.d.ts +13 -0
- package/lib/group-component/components/number-range/index.js +87 -0
- package/lib/group-component/features/operator.d.ts +24 -0
- package/lib/group-component/features/operator.js +67 -0
- package/lib/group-component/footer/TableFooter.d.ts +7 -0
- package/lib/group-component/footer/TableFooter.js +44 -0
- package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
- package/lib/group-component/footer/TableFooterCell.js +75 -0
- package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
- package/lib/group-component/footer/TableFooterRow.js +37 -0
- package/lib/group-component/header/TableHead.d.ts +15 -0
- package/lib/group-component/header/TableHead.js +107 -0
- package/lib/group-component/header/TableHeadCell.d.ts +15 -0
- package/lib/group-component/header/TableHeadCell.js +319 -0
- package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
- package/lib/group-component/header/TableHeadCell2.js +330 -0
- package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/lib/group-component/header/TableHeadGroupCell.js +103 -0
- package/lib/group-component/header/TableHeadRow.d.ts +15 -0
- package/lib/group-component/header/TableHeadRow.js +59 -0
- package/lib/group-component/header/renderFilter.d.ts +20 -0
- package/lib/group-component/header/renderFilter.js +301 -0
- package/lib/group-component/hook/convert.d.ts +1 -0
- package/lib/group-component/hook/convert.js +34 -0
- package/lib/group-component/hook/useColumns.d.ts +28 -0
- package/lib/group-component/hook/useColumns.js +318 -0
- package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
- package/lib/group-component/hook/useFilterOperator.js +40 -0
- package/lib/group-component/hook/utils.d.ts +220 -0
- package/lib/group-component/hook/utils.js +2468 -0
- package/lib/group-component/index.d.ts +2 -0
- package/lib/group-component/index.js +9 -0
- package/lib/group-component/style.d.ts +22 -0
- package/lib/group-component/style.js +55 -0
- package/lib/group-component/style.scss +1438 -0
- package/lib/group-component/table/Grid.d.ts +33 -0
- package/lib/group-component/table/Grid.js +444 -0
- package/lib/group-component/table/TableWrapper.d.ts +33 -0
- package/lib/group-component/table/TableWrapper.js +259 -0
- package/lib/group-component/useContext.d.ts +100 -0
- package/lib/group-component/useContext.js +27 -0
- package/lib/table-component/InternalTable.js +9 -2
- package/lib/table-component/TableContainer.d.ts +1 -0
- package/lib/table-component/TableContainer.js +6 -2
- package/lib/table-component/TableContainerEdit.d.ts +1 -0
- package/lib/table-component/TableContainerEdit.js +4 -2
- package/lib/table-component/body/TableBodyCell.js +49 -40
- package/lib/table-component/body/TableBodyCellEdit.js +9 -6
- package/lib/table-component/body/TableBodyRow.js +4 -1
- package/lib/table-component/header/TableHeadCell2.js +38 -2
- package/lib/table-component/hook/utils.d.ts +1 -0
- package/lib/table-component/hook/utils.js +16 -7
- package/lib/table-component/style.js +1 -1
- package/lib/table-component/table/Grid.d.ts +1 -0
- package/lib/table-component/table/Grid.js +10 -3
- package/lib/table-component/useContext.d.ts +6 -0
- package/lib/table-component/useContext.js +2 -1
- package/lib/table-virtuoso/InternalTable.js +2 -2
- package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
- package/lib/table-virtuoso/hook/utils.d.ts +1 -0
- package/lib/table-virtuoso/hook/utils.js +32 -1
- package/lib/table-virtuoso/style.js +3 -1
- package/lib/table-virtuoso/table/Grid.js +2 -2
- package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/lib/table-virtuoso/table/TableWrapper.js +24 -5
- package/lib/table-virtuoso/useContext.d.ts +6 -3
- package/lib/table-virtuoso/useContext.js +18 -0
- package/package.json +1 -1
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _useContext = require("./useContext");
|
|
12
|
+
var _pagination = _interopRequireDefault(require("rc-master-ui/es/pagination"));
|
|
13
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
14
|
+
var _becoxyIcons = require("becoxy-icons");
|
|
15
|
+
var _ColumnsChoose = require("./ColumnsChoose");
|
|
16
|
+
var _reactNumericComponent = require("react-numeric-component");
|
|
17
|
+
var _TableWrapper = _interopRequireDefault(require("./table/TableWrapper"));
|
|
18
|
+
var _utils = require("./hook/utils");
|
|
19
|
+
var _reactVirtual = require("@tanstack/react-virtual");
|
|
20
|
+
var _utils2 = require("../table-component/hook/utils");
|
|
21
|
+
var _ColumnsGroup = require("./ColumnsGroup");
|
|
22
|
+
const TableContainer = props => {
|
|
23
|
+
const {
|
|
24
|
+
t,
|
|
25
|
+
table,
|
|
26
|
+
id,
|
|
27
|
+
prefix,
|
|
28
|
+
commandClick,
|
|
29
|
+
editAble,
|
|
30
|
+
rowKey,
|
|
31
|
+
format,
|
|
32
|
+
dataSource,
|
|
33
|
+
originData,
|
|
34
|
+
expandable,
|
|
35
|
+
wrapSettings,
|
|
36
|
+
recordDoubleClick,
|
|
37
|
+
// triggerFilter,
|
|
38
|
+
selectionSettings,
|
|
39
|
+
isSelectionChange,
|
|
40
|
+
setIsSelectionChange,
|
|
41
|
+
onContextMenu,
|
|
42
|
+
contextMenuItems,
|
|
43
|
+
setSorterChange,
|
|
44
|
+
setFilterChange,
|
|
45
|
+
height,
|
|
46
|
+
minHeight,
|
|
47
|
+
showToolbar,
|
|
48
|
+
toolbarItems,
|
|
49
|
+
actionTemplate,
|
|
50
|
+
pagination,
|
|
51
|
+
fullScreen,
|
|
52
|
+
showColumnChoose,
|
|
53
|
+
summary,
|
|
54
|
+
locale,
|
|
55
|
+
groupColumns,
|
|
56
|
+
columns,
|
|
57
|
+
propsColumns,
|
|
58
|
+
triggerChangeColumns,
|
|
59
|
+
columnHidden,
|
|
60
|
+
expanded,
|
|
61
|
+
setExpanded,
|
|
62
|
+
showEmptyText,
|
|
63
|
+
infiniteScroll,
|
|
64
|
+
next,
|
|
65
|
+
loading,
|
|
66
|
+
windowSize,
|
|
67
|
+
contextMenuOpen,
|
|
68
|
+
contextMenuClick,
|
|
69
|
+
contextMenuHidden,
|
|
70
|
+
isFullScreen,
|
|
71
|
+
setIsFullScreen,
|
|
72
|
+
isDataTree,
|
|
73
|
+
setColumns,
|
|
74
|
+
columnSizing,
|
|
75
|
+
columnSizingInfo,
|
|
76
|
+
rowClassName,
|
|
77
|
+
onRowStyles,
|
|
78
|
+
onRowFooterStyles,
|
|
79
|
+
onRowHeaderStyles,
|
|
80
|
+
title,
|
|
81
|
+
dataSourceFilter,
|
|
82
|
+
groupSetting,
|
|
83
|
+
triggerGroupColumns
|
|
84
|
+
} = props;
|
|
85
|
+
const tableContainerRef = _react.default.useRef(null);
|
|
86
|
+
const containerRef = _react.default.useRef(null);
|
|
87
|
+
const bottomToolbarRef = _react.default.useRef(null);
|
|
88
|
+
const topToolbarRef = _react.default.useRef(null);
|
|
89
|
+
const [tableHeight, settableHeight] = _react.default.useState(0);
|
|
90
|
+
const [focusedCell, setFocusedCell] = _react.default.useState(undefined);
|
|
91
|
+
_react.default.useEffect(() => {
|
|
92
|
+
// const totalHeight = minHeight ?? height
|
|
93
|
+
const totalHeight = (0, _utils.getTableHeight)(height, minHeight);
|
|
94
|
+
if (totalHeight) {
|
|
95
|
+
const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
|
|
96
|
+
const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
|
|
97
|
+
settableHeight(totalHeight - topHeight - bottomHeight);
|
|
98
|
+
}
|
|
99
|
+
}, [id, height, editAble, minHeight]);
|
|
100
|
+
_react.default.useEffect(() => {
|
|
101
|
+
const handleClickOutside = () => {
|
|
102
|
+
setFocusedCell(undefined);
|
|
103
|
+
setIsSelectionChange(prev => ({
|
|
104
|
+
...prev,
|
|
105
|
+
isChange: false
|
|
106
|
+
}));
|
|
107
|
+
};
|
|
108
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
109
|
+
return () => {
|
|
110
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
111
|
+
};
|
|
112
|
+
}, []);
|
|
113
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
114
|
+
const fixedLeftColumns = table.getState().columnPinning.left ? visibleColumns.filter(vc => table.getState().columnPinning.left?.includes(vc.id)) : [];
|
|
115
|
+
const fixedRightColumns = table.getState().columnPinning.right ? visibleColumns.filter(vc => table.getState().columnPinning.right?.includes(vc.id)) : [];
|
|
116
|
+
|
|
117
|
+
//we are using a slightly different virtualization strategy for columns (compared to virtual rows) in order to support dynamic row heights
|
|
118
|
+
const columnVirtualizer = (0, _reactVirtual.useVirtualizer)({
|
|
119
|
+
count: visibleColumns.length,
|
|
120
|
+
estimateSize: index => visibleColumns[index].getSize(),
|
|
121
|
+
//estimate width of each column for accurate scrollbar dragging
|
|
122
|
+
getScrollElement: () => tableContainerRef.current,
|
|
123
|
+
horizontal: true,
|
|
124
|
+
// measureElement(element) {
|
|
125
|
+
|
|
126
|
+
// return element?.getBoundingClientRect().width;
|
|
127
|
+
// },
|
|
128
|
+
|
|
129
|
+
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
|
|
130
|
+
overscan: 3 //how many columns to render on each side off screen each way (adjust this for performance)
|
|
131
|
+
});
|
|
132
|
+
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
133
|
+
const cacheColumns = columnVirtualizer.measurementsCache;
|
|
134
|
+
const rightCols = table.getState().columnPinning.right?.length ? [...cacheColumns].slice(-(table.getState().columnPinning.right?.length ?? 0)) : [];
|
|
135
|
+
const leftCols = [...cacheColumns].slice(0, table.getState().columnPinning.left?.length ?? 0);
|
|
136
|
+
const rightWidth = (0, _utils.sumSize)(rightCols);
|
|
137
|
+
const leftWidth = (0, _utils.sumSize)(leftCols);
|
|
138
|
+
|
|
139
|
+
//different virtualization strategy for columns - instead of absolute and translateY, we add empty columns to the left and right
|
|
140
|
+
let virtualPaddingLeft;
|
|
141
|
+
let virtualPaddingRight;
|
|
142
|
+
const pdRight = columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0);
|
|
143
|
+
if (columnVirtualizer && virtualColumns?.length) {
|
|
144
|
+
virtualPaddingLeft = fixedLeftColumns && fixedLeftColumns.length > 0 ? (virtualColumns[0]?.start ?? 0) - leftWidth > 0 ? (virtualColumns[0]?.start ?? 0) - leftWidth : 0 : virtualColumns[0]?.start ?? 0;
|
|
145
|
+
|
|
146
|
+
// virtualPaddingLeft = leftCols.length === rss.length ? (virtualColumns[0]?.start ?? 0) : 0;
|
|
147
|
+
// columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0) - rightWidth > 0 ? columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0) - rightWidth : 0;
|
|
148
|
+
virtualPaddingRight = fixedRightColumns && fixedRightColumns.length > 0 ? pdRight - rightWidth > 0 ? pdRight - rightWidth : 0 : pdRight;
|
|
149
|
+
// virtualPaddingRight = columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0)
|
|
150
|
+
}
|
|
151
|
+
const columnSizingState = table.getState().columnSizing;
|
|
152
|
+
_react.default.useEffect(() => {
|
|
153
|
+
requestAnimationFrame(() => {
|
|
154
|
+
columnVirtualizer.measure();
|
|
155
|
+
});
|
|
156
|
+
}, [columnSizingState, columnVirtualizer]);
|
|
157
|
+
_react.default.useEffect(() => {
|
|
158
|
+
if (!tableContainerRef.current) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// const containerWidth = tableContainerRef.current.offsetWidth
|
|
163
|
+
// const totalWidth = table.getTotalSize()
|
|
164
|
+
|
|
165
|
+
// if (totalWidth && totalWidth <= containerWidth) {
|
|
166
|
+
|
|
167
|
+
// return
|
|
168
|
+
|
|
169
|
+
// }
|
|
170
|
+
|
|
171
|
+
if (columnSizingInfo.isResizingColumn === false) {
|
|
172
|
+
const aa = (0, _utils.updateColumnWidthsRecursive)(propsColumns, columnSizing);
|
|
173
|
+
setColumns(aa);
|
|
174
|
+
|
|
175
|
+
// requestAnimationFrame(() => {
|
|
176
|
+
|
|
177
|
+
// columnVirtualizer.measure()
|
|
178
|
+
// })
|
|
179
|
+
}
|
|
180
|
+
}, [columnSizingInfo]);
|
|
181
|
+
const triggerCommandClick = args => {
|
|
182
|
+
// const { id: idCommand, rowId, rowData, index } = args
|
|
183
|
+
|
|
184
|
+
// const tmpData = [...dataSource]
|
|
185
|
+
|
|
186
|
+
if (commandClick) {
|
|
187
|
+
commandClick({
|
|
188
|
+
...args,
|
|
189
|
+
rows: originData
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const handleOnGroup = value => {
|
|
194
|
+
triggerGroupColumns?.(value);
|
|
195
|
+
};
|
|
196
|
+
const handleCollapseAllGroup = () => {
|
|
197
|
+
setExpanded({});
|
|
198
|
+
};
|
|
199
|
+
const handleExpandAllGroup = () => {
|
|
200
|
+
const allKeys = (0, _utils2.findAllChildrenKeys2)(dataSource, rowKey, 'children');
|
|
201
|
+
setExpanded((0, _utils2.convertToObjTrue)(allKeys));
|
|
202
|
+
};
|
|
203
|
+
const groupToolbar = () => {
|
|
204
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
205
|
+
style: {
|
|
206
|
+
display: 'flex',
|
|
207
|
+
gap: '10px',
|
|
208
|
+
marginRight: 10
|
|
209
|
+
}
|
|
210
|
+
}, groupSetting?.showGroupIcon !== false && /*#__PURE__*/_react.default.createElement(_ColumnsGroup.ColumnsGroup, {
|
|
211
|
+
t: t
|
|
212
|
+
// defaultGroupColumns={['name']}
|
|
213
|
+
,
|
|
214
|
+
unClearableLevel: groupSetting?.unClearableLevel
|
|
215
|
+
// unClearableLevel={2}
|
|
216
|
+
,
|
|
217
|
+
columns: propsColumns ? (0, _utils2.flatColumns2)(propsColumns) : [],
|
|
218
|
+
columnsGrouped: groupColumns,
|
|
219
|
+
onSubmit: handleOnGroup
|
|
220
|
+
}), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !(0, _utils2.isObjEmpty)(expanded) ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Collapse2, {
|
|
221
|
+
fontSize: 16,
|
|
222
|
+
color: '#555555',
|
|
223
|
+
onClick: handleCollapseAllGroup
|
|
224
|
+
}) : /*#__PURE__*/_react.default.createElement(_becoxyIcons.Expand2, {
|
|
225
|
+
fontSize: 16,
|
|
226
|
+
color: '#555555',
|
|
227
|
+
onClick: handleExpandAllGroup
|
|
228
|
+
})));
|
|
229
|
+
};
|
|
230
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
231
|
+
ref: containerRef,
|
|
232
|
+
id: id
|
|
233
|
+
}, (showToolbar !== false || fullScreen !== false || title) && /*#__PURE__*/_react.default.createElement("div", {
|
|
234
|
+
ref: topToolbarRef,
|
|
235
|
+
className: (0, _classnames.default)(`${prefix}-grid-top-toolbar`, {})
|
|
236
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
237
|
+
style: {
|
|
238
|
+
textAlign: 'center'
|
|
239
|
+
}
|
|
240
|
+
}, typeof title === 'function' ? title?.(originData) : title), /*#__PURE__*/_react.default.createElement("div", {
|
|
241
|
+
style: {
|
|
242
|
+
display: 'flex',
|
|
243
|
+
justifyContent: 'space-between',
|
|
244
|
+
alignItems: 'center',
|
|
245
|
+
gap: '.75rem'
|
|
246
|
+
}
|
|
247
|
+
}, groupToolbar(), /*#__PURE__*/_react.default.createElement("div", {
|
|
248
|
+
style: {
|
|
249
|
+
flex: 1,
|
|
250
|
+
overflow: 'hidden'
|
|
251
|
+
}
|
|
252
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
|
|
253
|
+
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
254
|
+
mode: 'scroll'
|
|
255
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
256
|
+
style: {
|
|
257
|
+
display: 'flex',
|
|
258
|
+
justifyContent: 'space-between',
|
|
259
|
+
alignItems: 'center',
|
|
260
|
+
gap: '.75rem'
|
|
261
|
+
}
|
|
262
|
+
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
|
|
263
|
+
showSizeChanger: true,
|
|
264
|
+
responsive: true,
|
|
265
|
+
size: 'small',
|
|
266
|
+
rootClassName: 'top-pagination',
|
|
267
|
+
showTotal: (totalItems, range) =>
|
|
268
|
+
// @ts-ignore
|
|
269
|
+
`${range[0]}-${range[1]} / ${totalItems} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
270
|
+
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
|
|
271
|
+
fontSize: 16,
|
|
272
|
+
onClick: () => {
|
|
273
|
+
setIsFullScreen(!isFullScreen);
|
|
274
|
+
},
|
|
275
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
276
|
+
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
277
|
+
}) : /*#__PURE__*/_react.default.createElement(_becoxyIcons.Maximize, {
|
|
278
|
+
fontSize: 16,
|
|
279
|
+
onClick: () => {
|
|
280
|
+
setIsFullScreen(!isFullScreen);
|
|
281
|
+
},
|
|
282
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
283
|
+
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
284
|
+
})), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
|
|
285
|
+
columnHidden: columnHidden,
|
|
286
|
+
columns: columns,
|
|
287
|
+
originColumns: propsColumns,
|
|
288
|
+
t: t,
|
|
289
|
+
columnsGroup: groupColumns,
|
|
290
|
+
triggerChangeColumns: triggerChangeColumns
|
|
291
|
+
})))), /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
|
|
292
|
+
value: {
|
|
293
|
+
t,
|
|
294
|
+
locale,
|
|
295
|
+
prefix,
|
|
296
|
+
id,
|
|
297
|
+
rowKey,
|
|
298
|
+
format,
|
|
299
|
+
expandable,
|
|
300
|
+
expanded,
|
|
301
|
+
setExpanded,
|
|
302
|
+
dataSource,
|
|
303
|
+
originData,
|
|
304
|
+
// triggerFilter,
|
|
305
|
+
wrapSettings,
|
|
306
|
+
recordDoubleClick,
|
|
307
|
+
selectionSettings,
|
|
308
|
+
isSelectionChange,
|
|
309
|
+
setIsSelectionChange,
|
|
310
|
+
onContextMenu,
|
|
311
|
+
setSorterChange,
|
|
312
|
+
setFilterChange,
|
|
313
|
+
windowSize,
|
|
314
|
+
isDataTree,
|
|
315
|
+
focusedCell,
|
|
316
|
+
setFocusedCell,
|
|
317
|
+
rowClassName,
|
|
318
|
+
onRowStyles,
|
|
319
|
+
onRowFooterStyles,
|
|
320
|
+
onRowHeaderStyles,
|
|
321
|
+
table,
|
|
322
|
+
pagination,
|
|
323
|
+
dataSourceFilter,
|
|
324
|
+
groupColumns
|
|
325
|
+
}
|
|
326
|
+
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
|
|
327
|
+
contextMenuItems: contextMenuItems,
|
|
328
|
+
height: tableHeight,
|
|
329
|
+
minHeight: minHeight,
|
|
330
|
+
id: id,
|
|
331
|
+
prefix: prefix,
|
|
332
|
+
table: table,
|
|
333
|
+
tableContainerRef: tableContainerRef,
|
|
334
|
+
commandClick: triggerCommandClick,
|
|
335
|
+
contextMenuClick: contextMenuClick,
|
|
336
|
+
contextMenuHidden: contextMenuHidden,
|
|
337
|
+
contextMenuOpen: contextMenuOpen,
|
|
338
|
+
editAble: editAble,
|
|
339
|
+
showEmptyText: showEmptyText,
|
|
340
|
+
summary: summary,
|
|
341
|
+
dataSource: dataSource,
|
|
342
|
+
infiniteScroll: infiniteScroll,
|
|
343
|
+
next: next,
|
|
344
|
+
loading: loading,
|
|
345
|
+
columnVirtualizer: columnVirtualizer,
|
|
346
|
+
virtualPaddingLeft: virtualPaddingLeft,
|
|
347
|
+
virtualPaddingRight: virtualPaddingRight,
|
|
348
|
+
fixedLeftColumns: fixedLeftColumns,
|
|
349
|
+
fixedRightColumns: fixedRightColumns
|
|
350
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
351
|
+
ref: bottomToolbarRef
|
|
352
|
+
}, pagination && !infiniteScroll && /*#__PURE__*/_react.default.createElement(_pagination.default
|
|
353
|
+
// style={{padding: '0.75rem 1rem'}}
|
|
354
|
+
, (0, _extends2.default)({
|
|
355
|
+
pageSizeOptions: [20, 50, 100, 1000, 10000]
|
|
356
|
+
}, pagination, {
|
|
357
|
+
rootClassName: 'pagination-template',
|
|
358
|
+
showSizeChanger: true,
|
|
359
|
+
responsive: true,
|
|
360
|
+
size: 'small',
|
|
361
|
+
total: pagination.total,
|
|
362
|
+
pageSize: pagination.onChange ? pagination.pageSize : table.getState().pagination.pageSize,
|
|
363
|
+
showTotal: (totalItems, range) => `${(0, _reactNumericComponent.numericFormatter)((range[0] ?? 0).toString(), {
|
|
364
|
+
thousandSeparator: '.'
|
|
365
|
+
})}-${(0, _reactNumericComponent.numericFormatter)((range[1] ?? 0).toString(), {
|
|
366
|
+
thousandSeparator: '.'
|
|
367
|
+
})} / ${(0, _reactNumericComponent.numericFormatter)((totalItems ?? 0).toString(), {
|
|
368
|
+
thousandSeparator: '.'
|
|
369
|
+
})} items`,
|
|
370
|
+
onChange: (page, pageSize1) => {
|
|
371
|
+
if (pagination.onChange) {
|
|
372
|
+
pagination.onChange(page, pageSize1);
|
|
373
|
+
table.setPageIndex(page - 1);
|
|
374
|
+
table.setPageSize(pageSize1);
|
|
375
|
+
} else {
|
|
376
|
+
table.setPageIndex(page - 1);
|
|
377
|
+
table.setPageSize(pageSize1);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}))));
|
|
381
|
+
};
|
|
382
|
+
var _default = exports.default = TableContainer;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { ColumnDef, ColumnSizingInfoState, ColumnSizingState, Table } from "@tanstack/react-table";
|
|
4
|
+
import type { ColumnsTable, TableProps } from "./../grid-component/type";
|
|
5
|
+
type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
6
|
+
table: Table<T>;
|
|
7
|
+
prefix: string;
|
|
8
|
+
id: string;
|
|
9
|
+
rowKey: any;
|
|
10
|
+
originData: T[];
|
|
11
|
+
propsColumns: ColumnsTable;
|
|
12
|
+
isSelectionChange?: {
|
|
13
|
+
isChange: boolean;
|
|
14
|
+
type: string;
|
|
15
|
+
rowData: T;
|
|
16
|
+
rowsData: T[];
|
|
17
|
+
};
|
|
18
|
+
setIsSelectionChange: Dispatch<SetStateAction<{
|
|
19
|
+
isChange: boolean;
|
|
20
|
+
type: string;
|
|
21
|
+
rowData: T;
|
|
22
|
+
rowsData: T[];
|
|
23
|
+
}>>;
|
|
24
|
+
setSorterChange: Dispatch<SetStateAction<boolean>>;
|
|
25
|
+
setFilterChange: Dispatch<SetStateAction<boolean>>;
|
|
26
|
+
onContextMenu?: (data: T) => (event: any) => void;
|
|
27
|
+
isDataTree: boolean;
|
|
28
|
+
windowSize: {
|
|
29
|
+
innerHeight: number;
|
|
30
|
+
innerWidth: number;
|
|
31
|
+
};
|
|
32
|
+
mergedFilterKeys?: any;
|
|
33
|
+
setMergedFilterKeys?: any;
|
|
34
|
+
setExpanded?: any;
|
|
35
|
+
expanded?: any;
|
|
36
|
+
columns: ColumnDef<T>[];
|
|
37
|
+
triggerChangeColumns: any;
|
|
38
|
+
columnHidden: any;
|
|
39
|
+
isFullScreen: boolean;
|
|
40
|
+
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
41
|
+
setColumnSizing: Dispatch<SetStateAction<any>>;
|
|
42
|
+
setColumns: Dispatch<SetStateAction<any>>;
|
|
43
|
+
columnSizingInfo: ColumnSizingInfoState;
|
|
44
|
+
columnSizing: ColumnSizingState;
|
|
45
|
+
triggerGroupColumns?: (groupedColumns: string[]) => void;
|
|
46
|
+
};
|
|
47
|
+
declare const TableContainerEdit: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
|
|
48
|
+
export default TableContainerEdit;
|