es-grid-template 1.8.64 → 1.8.65
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/ColumnsGroup/ColumnsGroup.js +4 -1
- package/es/grid-component/TempTable.js +2 -2
- package/es/grid-component/hooks/utils.d.ts +2 -8
- package/es/grid-component/hooks/utils.js +175 -144
- package/es/grid-component/index.d.ts +1 -1
- package/es/grid-component/index.js +0 -4
- package/es/grid-component/type.d.ts +7 -0
- package/es/table-component/type.d.ts +8 -0
- package/es/table-virtuoso/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/table-virtuoso/ColumnsGroup/ColumnsGroup.js +232 -0
- package/es/table-virtuoso/ColumnsGroup/index.d.ts +1 -0
- package/es/table-virtuoso/ColumnsGroup/index.js +1 -0
- package/es/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
- package/es/table-virtuoso/InternalTable.js +413 -0
- package/es/table-virtuoso/body/TableBody.d.ts +14 -0
- package/es/table-virtuoso/body/TableBody.js +84 -0
- package/es/table-virtuoso/body/TableBodyCell.d.ts +14 -0
- package/es/table-virtuoso/body/TableBodyCell.js +466 -0
- package/es/table-virtuoso/body/TableBodyRow.d.ts +13 -0
- package/es/table-virtuoso/body/TableBodyRow.js +116 -0
- package/es/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
- package/es/table-virtuoso/footer/TableFooterCell.js +54 -0
- package/es/table-virtuoso/header/TableHeadCell.d.ts +14 -0
- package/es/table-virtuoso/header/TableHeadCell.js +265 -0
- package/es/table-virtuoso/header/renderFilter.d.ts +20 -0
- package/es/table-virtuoso/header/renderFilter.js +289 -0
- package/es/table-virtuoso/hook/constant.d.ts +73 -0
- package/es/table-virtuoso/hook/constant.js +240 -0
- package/es/table-virtuoso/hook/convert.d.ts +1 -0
- package/es/table-virtuoso/hook/convert.js +28 -0
- package/es/table-virtuoso/hook/useColumns.d.ts +28 -0
- package/es/table-virtuoso/hook/useColumns.js +302 -0
- package/es/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
- package/es/table-virtuoso/hook/useFilterOperator.js +33 -0
- package/es/table-virtuoso/hook/utils.d.ts +159 -0
- package/es/table-virtuoso/hook/utils.js +2263 -0
- package/es/table-virtuoso/index.d.ts +2 -0
- package/es/table-virtuoso/index.js +2 -0
- package/es/table-virtuoso/style.d.ts +22 -0
- package/es/table-virtuoso/style.js +11 -0
- package/es/table-virtuoso/style.scss +1440 -0
- package/es/table-virtuoso/table/Grid.d.ts +37 -0
- package/es/table-virtuoso/table/Grid.js +302 -0
- package/es/table-virtuoso/table/TableContainer.d.ts +49 -0
- package/es/table-virtuoso/table/TableContainer.js +305 -0
- package/es/table-virtuoso/table/TableWrapper.d.ts +20 -0
- package/es/table-virtuoso/table/TableWrapper.js +158 -0
- package/es/table-virtuoso/type.d.ts +0 -0
- package/es/table-virtuoso/type.js +785 -0
- package/es/table-virtuoso/useContext.d.ts +97 -0
- package/es/table-virtuoso/useContext.js +21 -0
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +4 -1
- package/lib/grid-component/TempTable.js +2 -2
- package/lib/grid-component/hooks/utils.d.ts +2 -8
- package/lib/grid-component/hooks/utils.js +176 -152
- package/lib/grid-component/index.d.ts +1 -1
- package/lib/grid-component/index.js +0 -3
- package/lib/grid-component/type.d.ts +7 -0
- package/lib/table-component/type.d.ts +8 -0
- package/lib/table-virtuoso/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/table-virtuoso/ColumnsGroup/ColumnsGroup.js +243 -0
- package/lib/table-virtuoso/ColumnsGroup/index.d.ts +1 -0
- package/lib/table-virtuoso/ColumnsGroup/index.js +16 -0
- package/lib/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
- package/lib/table-virtuoso/InternalTable.js +422 -0
- package/lib/table-virtuoso/body/TableBody.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBody.js +95 -0
- package/lib/table-virtuoso/body/TableBodyCell.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBodyCell.js +473 -0
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +13 -0
- package/lib/table-virtuoso/body/TableBodyRow.js +124 -0
- package/lib/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
- package/lib/table-virtuoso/footer/TableFooterCell.js +63 -0
- package/lib/table-virtuoso/header/TableHeadCell.d.ts +14 -0
- package/lib/table-virtuoso/header/TableHeadCell.js +274 -0
- package/lib/table-virtuoso/header/renderFilter.d.ts +20 -0
- package/lib/table-virtuoso/header/renderFilter.js +299 -0
- package/lib/table-virtuoso/hook/constant.d.ts +73 -0
- package/lib/table-virtuoso/hook/constant.js +247 -0
- package/lib/table-virtuoso/hook/convert.d.ts +1 -0
- package/lib/table-virtuoso/hook/convert.js +34 -0
- package/lib/table-virtuoso/hook/useColumns.d.ts +28 -0
- package/lib/table-virtuoso/hook/useColumns.js +315 -0
- package/lib/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
- package/lib/table-virtuoso/hook/useFilterOperator.js +40 -0
- package/lib/table-virtuoso/hook/utils.d.ts +159 -0
- package/lib/table-virtuoso/hook/utils.js +2389 -0
- package/lib/table-virtuoso/index.d.ts +2 -0
- package/lib/table-virtuoso/index.js +9 -0
- package/lib/table-virtuoso/style.d.ts +22 -0
- package/lib/table-virtuoso/style.js +18 -0
- package/lib/table-virtuoso/style.scss +1440 -0
- package/lib/table-virtuoso/table/Grid.d.ts +37 -0
- package/lib/table-virtuoso/table/Grid.js +311 -0
- package/lib/table-virtuoso/table/TableContainer.d.ts +49 -0
- package/lib/table-virtuoso/table/TableContainer.js +313 -0
- package/lib/table-virtuoso/table/TableWrapper.d.ts +20 -0
- package/lib/table-virtuoso/table/TableWrapper.js +164 -0
- package/lib/table-virtuoso/type.d.ts +0 -0
- package/lib/table-virtuoso/type.js +786 -0
- package/lib/table-virtuoso/useContext.d.ts +97 -0
- package/lib/table-virtuoso/useContext.js +27 -0
- package/package.json +2 -1
- package/es/grid-component/ConvertColumnTable.d.ts +0 -7
- package/es/grid-component/ConvertColumnTable.js +0 -144
- package/es/grid-component/InternalTable.js +0 -1170
- package/es/grid-component/table/Grid.d.ts +0 -23
- package/es/grid-component/table/Grid.js +0 -49
- package/es/grid-component/table/GridEdit.d.ts +0 -23
- package/es/grid-component/table/GridEdit.js +0 -2726
- package/es/grid-component/table/Group.d.ts +0 -21
- package/es/grid-component/table/Group.js +0 -195
- package/es/grid-component/table/InfiniteTable.d.ts +0 -23
- package/es/grid-component/table/InfiniteTable.js +0 -101
- package/lib/grid-component/ConvertColumnTable.d.ts +0 -7
- package/lib/grid-component/ConvertColumnTable.js +0 -153
- package/lib/grid-component/InternalTable.js +0 -1178
- package/lib/grid-component/table/Grid.d.ts +0 -23
- package/lib/grid-component/table/Grid.js +0 -58
- package/lib/grid-component/table/GridEdit.d.ts +0 -23
- package/lib/grid-component/table/GridEdit.js +0 -2723
- package/lib/grid-component/table/Group.d.ts +0 -21
- package/lib/grid-component/table/Group.js +0 -204
- package/lib/grid-component/table/InfiniteTable.d.ts +0 -23
- package/lib/grid-component/table/InfiniteTable.js +0 -109
|
@@ -0,0 +1,313 @@
|
|
|
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 _pagination = _interopRequireDefault(require("rc-master-ui/es/pagination"));
|
|
12
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
13
|
+
var _becoxyIcons = require("becoxy-icons");
|
|
14
|
+
var _reactNumericComponent = require("react-numeric-component");
|
|
15
|
+
var _TableWrapper = _interopRequireDefault(require("./TableWrapper"));
|
|
16
|
+
var _ColumnsChoose = require("../../table-component/ColumnsChoose");
|
|
17
|
+
var _utils = require("../hook/utils");
|
|
18
|
+
var _useContext = require("../useContext");
|
|
19
|
+
var _utils2 = require("../../table-component/hook/utils");
|
|
20
|
+
var _ColumnsGroup = require("../ColumnsGroup");
|
|
21
|
+
// import type { Dispatch, SetStateAction } from 'react'
|
|
22
|
+
|
|
23
|
+
// import { ColumnsGroup } from '../../grid-component/ColumnsGroup';
|
|
24
|
+
|
|
25
|
+
const TableContainer = props => {
|
|
26
|
+
const {
|
|
27
|
+
t,
|
|
28
|
+
table,
|
|
29
|
+
id,
|
|
30
|
+
prefix,
|
|
31
|
+
// commandClick,
|
|
32
|
+
editAble,
|
|
33
|
+
rowKey,
|
|
34
|
+
format,
|
|
35
|
+
dataSource,
|
|
36
|
+
originData,
|
|
37
|
+
expandable,
|
|
38
|
+
wrapSettings,
|
|
39
|
+
recordDoubleClick,
|
|
40
|
+
// triggerFilter,
|
|
41
|
+
selectionSettings,
|
|
42
|
+
isSelectionChange,
|
|
43
|
+
setIsSelectionChange,
|
|
44
|
+
onContextMenu,
|
|
45
|
+
// contextMenuItems,
|
|
46
|
+
setSorterChange,
|
|
47
|
+
setFilterChange,
|
|
48
|
+
height,
|
|
49
|
+
minHeight,
|
|
50
|
+
showToolbar,
|
|
51
|
+
toolbarItems,
|
|
52
|
+
actionTemplate,
|
|
53
|
+
pagination,
|
|
54
|
+
fullScreen,
|
|
55
|
+
showColumnChoose,
|
|
56
|
+
// summary,
|
|
57
|
+
locale,
|
|
58
|
+
groupColumns,
|
|
59
|
+
columns,
|
|
60
|
+
propsColumns,
|
|
61
|
+
triggerChangeColumns,
|
|
62
|
+
triggerGroupColumns,
|
|
63
|
+
columnHidden,
|
|
64
|
+
expanded,
|
|
65
|
+
setExpanded,
|
|
66
|
+
// showEmptyText,
|
|
67
|
+
infiniteScroll,
|
|
68
|
+
// next,
|
|
69
|
+
// loading,
|
|
70
|
+
windowSize,
|
|
71
|
+
// contextMenuOpen,
|
|
72
|
+
// contextMenuClick,
|
|
73
|
+
// contextMenuHidden,
|
|
74
|
+
isFullScreen,
|
|
75
|
+
setIsFullScreen,
|
|
76
|
+
isDataTree,
|
|
77
|
+
// setColumns,
|
|
78
|
+
// columnSizing,
|
|
79
|
+
// columnSizingInfo,
|
|
80
|
+
rowClassName,
|
|
81
|
+
onRowStyles,
|
|
82
|
+
onRowFooterStyles,
|
|
83
|
+
onRowHeaderStyles,
|
|
84
|
+
title,
|
|
85
|
+
groupSetting
|
|
86
|
+
} = props;
|
|
87
|
+
const tableContainerRef = _react.default.useRef(null);
|
|
88
|
+
const containerRef = _react.default.useRef(null);
|
|
89
|
+
const bottomToolbarRef = _react.default.useRef(null);
|
|
90
|
+
const topToolbarRef = _react.default.useRef(null);
|
|
91
|
+
const [tableHeight, settableHeight] = _react.default.useState(0);
|
|
92
|
+
_react.default.useEffect(() => {
|
|
93
|
+
// const totalHeight = minHeight ?? height
|
|
94
|
+
const totalHeight = (0, _utils.getTableHeight)(height, minHeight);
|
|
95
|
+
if (totalHeight) {
|
|
96
|
+
const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
|
|
97
|
+
const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
|
|
98
|
+
settableHeight(totalHeight - topHeight - bottomHeight);
|
|
99
|
+
}
|
|
100
|
+
}, [id, height, editAble, minHeight]);
|
|
101
|
+
_react.default.useEffect(() => {
|
|
102
|
+
const handleClickOutside = () => {
|
|
103
|
+
|
|
104
|
+
// setFocusedCell(undefined)
|
|
105
|
+
// setIsSelectionChange((prev) => (
|
|
106
|
+
// {
|
|
107
|
+
// ...prev,
|
|
108
|
+
// isChange: false
|
|
109
|
+
// }
|
|
110
|
+
// ))
|
|
111
|
+
};
|
|
112
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
113
|
+
return () => {
|
|
114
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
115
|
+
};
|
|
116
|
+
}, []);
|
|
117
|
+
|
|
118
|
+
// React.useEffect(() => {
|
|
119
|
+
|
|
120
|
+
// if (!tableContainerRef.current) {
|
|
121
|
+
// return
|
|
122
|
+
// }
|
|
123
|
+
|
|
124
|
+
// if (columnSizingInfo.isResizingColumn === false) {
|
|
125
|
+
|
|
126
|
+
// const aa = updateColumnWidthsRecursive(propsColumns, columnSizing)
|
|
127
|
+
|
|
128
|
+
// setColumns(aa)
|
|
129
|
+
|
|
130
|
+
// }
|
|
131
|
+
|
|
132
|
+
// }, [columnSizingInfo])
|
|
133
|
+
|
|
134
|
+
// const triggerCommandClick = (args: Omit<CommandClick<RecordType>, 'rows'>) => {
|
|
135
|
+
|
|
136
|
+
// // const { id: idCommand, rowId, rowData, index } = args
|
|
137
|
+
|
|
138
|
+
// // const tmpData = [...dataSource]
|
|
139
|
+
|
|
140
|
+
// if (commandClick) {
|
|
141
|
+
// commandClick({
|
|
142
|
+
// ...args,
|
|
143
|
+
// rows: originData
|
|
144
|
+
// })
|
|
145
|
+
// }
|
|
146
|
+
|
|
147
|
+
// }
|
|
148
|
+
|
|
149
|
+
const handleOnGroup = value => {
|
|
150
|
+
triggerGroupColumns?.(value);
|
|
151
|
+
};
|
|
152
|
+
const groupToolbar = () => {
|
|
153
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
154
|
+
style: {
|
|
155
|
+
display: 'flex',
|
|
156
|
+
gap: '10px',
|
|
157
|
+
marginRight: 10
|
|
158
|
+
}
|
|
159
|
+
}, groupSetting?.showGroupIcon !== false && /*#__PURE__*/_react.default.createElement(_ColumnsGroup.ColumnsGroup, {
|
|
160
|
+
t: t
|
|
161
|
+
// defaultGroupColumns={['name']}
|
|
162
|
+
,
|
|
163
|
+
unClearableLevel: groupSetting?.unClearableLevel
|
|
164
|
+
// unClearableLevel={2}
|
|
165
|
+
,
|
|
166
|
+
columns: propsColumns ? (0, _utils2.flatColumns2)(propsColumns) : [],
|
|
167
|
+
columnsGrouped: groupColumns,
|
|
168
|
+
onSubmit: handleOnGroup
|
|
169
|
+
}), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null));
|
|
170
|
+
};
|
|
171
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
172
|
+
ref: containerRef,
|
|
173
|
+
id: id
|
|
174
|
+
}, (showToolbar !== false || fullScreen !== false || title) && /*#__PURE__*/_react.default.createElement("div", {
|
|
175
|
+
ref: topToolbarRef,
|
|
176
|
+
className: (0, _classnames.default)(`${prefix}-grid-top-toolbar`, {})
|
|
177
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
178
|
+
style: {
|
|
179
|
+
textAlign: 'center'
|
|
180
|
+
}
|
|
181
|
+
}, typeof title === 'function' ? title?.(originData) : title), /*#__PURE__*/_react.default.createElement("div", {
|
|
182
|
+
style: {
|
|
183
|
+
display: 'flex',
|
|
184
|
+
justifyContent: 'space-between',
|
|
185
|
+
alignItems: 'center',
|
|
186
|
+
gap: '.75rem'
|
|
187
|
+
}
|
|
188
|
+
}, groupToolbar(), /*#__PURE__*/_react.default.createElement("div", {
|
|
189
|
+
style: {
|
|
190
|
+
flex: 1,
|
|
191
|
+
overflow: 'hidden'
|
|
192
|
+
}
|
|
193
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
|
|
194
|
+
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
195
|
+
mode: 'scroll'
|
|
196
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
197
|
+
style: {
|
|
198
|
+
display: 'flex',
|
|
199
|
+
justifyContent: 'space-between',
|
|
200
|
+
alignItems: 'center',
|
|
201
|
+
gap: '.75rem'
|
|
202
|
+
}
|
|
203
|
+
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
|
|
204
|
+
showSizeChanger: true,
|
|
205
|
+
responsive: true,
|
|
206
|
+
size: 'small',
|
|
207
|
+
rootClassName: 'top-pagination',
|
|
208
|
+
showTotal: (totalItems, range) =>
|
|
209
|
+
// @ts-ignore
|
|
210
|
+
`${range[0]}-${range[1]} / ${totalItems} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
211
|
+
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
|
|
212
|
+
fontSize: 16,
|
|
213
|
+
onClick: () => {
|
|
214
|
+
setIsFullScreen(!isFullScreen);
|
|
215
|
+
},
|
|
216
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
217
|
+
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
218
|
+
}) : /*#__PURE__*/_react.default.createElement(_becoxyIcons.Maximize, {
|
|
219
|
+
fontSize: 16,
|
|
220
|
+
onClick: () => {
|
|
221
|
+
setIsFullScreen(!isFullScreen);
|
|
222
|
+
},
|
|
223
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
224
|
+
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
225
|
+
})), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
|
|
226
|
+
columnHidden: columnHidden,
|
|
227
|
+
columns: columns,
|
|
228
|
+
originColumns: propsColumns,
|
|
229
|
+
t: t,
|
|
230
|
+
columnsGroup: groupColumns,
|
|
231
|
+
triggerChangeColumns: triggerChangeColumns
|
|
232
|
+
})))), /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
|
|
233
|
+
value: {
|
|
234
|
+
t,
|
|
235
|
+
locale,
|
|
236
|
+
prefix,
|
|
237
|
+
id,
|
|
238
|
+
rowKey,
|
|
239
|
+
format,
|
|
240
|
+
expandable,
|
|
241
|
+
expanded,
|
|
242
|
+
setExpanded,
|
|
243
|
+
dataSource,
|
|
244
|
+
originData,
|
|
245
|
+
// triggerFilter,
|
|
246
|
+
wrapSettings,
|
|
247
|
+
recordDoubleClick,
|
|
248
|
+
selectionSettings,
|
|
249
|
+
isSelectionChange,
|
|
250
|
+
setIsSelectionChange,
|
|
251
|
+
onContextMenu,
|
|
252
|
+
setSorterChange,
|
|
253
|
+
setFilterChange,
|
|
254
|
+
windowSize,
|
|
255
|
+
isDataTree,
|
|
256
|
+
// focusedCell,
|
|
257
|
+
// setFocusedCell,
|
|
258
|
+
rowClassName,
|
|
259
|
+
onRowStyles,
|
|
260
|
+
onRowFooterStyles,
|
|
261
|
+
onRowHeaderStyles,
|
|
262
|
+
table,
|
|
263
|
+
pagination,
|
|
264
|
+
groupSetting
|
|
265
|
+
// visible,
|
|
266
|
+
// setVisible,
|
|
267
|
+
// selectedKeys,
|
|
268
|
+
// setSelectedKeys,
|
|
269
|
+
// currentFilter,
|
|
270
|
+
// setCurrentFilter
|
|
271
|
+
}
|
|
272
|
+
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
|
|
273
|
+
tableContainerRef: tableContainerRef,
|
|
274
|
+
prefix: prefix,
|
|
275
|
+
id: id,
|
|
276
|
+
height: tableHeight,
|
|
277
|
+
minHeight: minHeight,
|
|
278
|
+
dataSource: dataSource,
|
|
279
|
+
table: table,
|
|
280
|
+
columns: columns
|
|
281
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
282
|
+
ref: bottomToolbarRef
|
|
283
|
+
}, pagination && !infiniteScroll && /*#__PURE__*/_react.default.createElement(_pagination.default
|
|
284
|
+
// style={{padding: '0.75rem 1rem'}}
|
|
285
|
+
, (0, _extends2.default)({
|
|
286
|
+
pageSizeOptions: [20, 50, 100, 1000, 10000]
|
|
287
|
+
}, pagination, {
|
|
288
|
+
rootClassName: 'pagination-template',
|
|
289
|
+
showSizeChanger: true,
|
|
290
|
+
responsive: true,
|
|
291
|
+
size: 'small',
|
|
292
|
+
total: pagination.total,
|
|
293
|
+
pageSize: pagination.onChange ? pagination.pageSize : table.getState().pagination.pageSize,
|
|
294
|
+
showTotal: (totalItems, range) => `${(0, _reactNumericComponent.numericFormatter)((range[0] ?? 0).toString(), {
|
|
295
|
+
thousandSeparator: '.'
|
|
296
|
+
})}-${(0, _reactNumericComponent.numericFormatter)((range[1] ?? 0).toString(), {
|
|
297
|
+
thousandSeparator: '.'
|
|
298
|
+
})} / ${(0, _reactNumericComponent.numericFormatter)((totalItems ?? 0).toString(), {
|
|
299
|
+
thousandSeparator: '.'
|
|
300
|
+
})} items`,
|
|
301
|
+
onChange: (page, pageSize1) => {
|
|
302
|
+
if (pagination.onChange) {
|
|
303
|
+
pagination.onChange(page, pageSize1);
|
|
304
|
+
table.setPageIndex(page - 1);
|
|
305
|
+
table.setPageSize(pageSize1);
|
|
306
|
+
} else {
|
|
307
|
+
table.setPageIndex(page - 1);
|
|
308
|
+
table.setPageSize(pageSize1);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}))));
|
|
312
|
+
};
|
|
313
|
+
var _default = exports.default = TableContainer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColumnDef, Table } from "@tanstack/react-table";
|
|
3
|
+
type Props<T> = {
|
|
4
|
+
tableContainerRef: React.RefObject<HTMLDivElement>;
|
|
5
|
+
table: Table<T>;
|
|
6
|
+
prefix: string;
|
|
7
|
+
id: string;
|
|
8
|
+
columns: ColumnDef<T>[];
|
|
9
|
+
height: number;
|
|
10
|
+
minHeight?: number;
|
|
11
|
+
dataSource: T[];
|
|
12
|
+
summary?: boolean;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
editAble?: boolean;
|
|
15
|
+
showEmptyText?: boolean;
|
|
16
|
+
contextMenuClick?: any;
|
|
17
|
+
next?: () => void;
|
|
18
|
+
};
|
|
19
|
+
declare const TableWrapper: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
20
|
+
export default TableWrapper;
|
|
@@ -0,0 +1,164 @@
|
|
|
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 = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactVirtuoso = require("react-virtuoso");
|
|
11
|
+
require("@tanstack/react-table");
|
|
12
|
+
var _TableHeadCell = _interopRequireDefault(require("../header/TableHeadCell"));
|
|
13
|
+
var _useContext = require("../useContext");
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
var _TableBodyRow = _interopRequireDefault(require("../body/TableBodyRow"));
|
|
16
|
+
var _TableFooterCell = _interopRequireDefault(require("../footer/TableFooterCell"));
|
|
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); }
|
|
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; }
|
|
19
|
+
/* eslint-disable @typescript-eslint/no-shadow */
|
|
20
|
+
|
|
21
|
+
// import type { Dispatch, SetStateAction } from 'react';
|
|
22
|
+
|
|
23
|
+
// import type { ColumnsTable, TableProps } from '../type';
|
|
24
|
+
|
|
25
|
+
// type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
26
|
+
|
|
27
|
+
const TableWrapper = props => {
|
|
28
|
+
const {
|
|
29
|
+
table,
|
|
30
|
+
// columns,
|
|
31
|
+
height,
|
|
32
|
+
id
|
|
33
|
+
} = props;
|
|
34
|
+
const {
|
|
35
|
+
prefix
|
|
36
|
+
} = (0, _react.useContext)(_useContext.TableContext); //onRowHeaderStyles
|
|
37
|
+
|
|
38
|
+
// ref cho scroll container
|
|
39
|
+
const scrollRef = (0, _react.useRef)(null);
|
|
40
|
+
const {
|
|
41
|
+
rows
|
|
42
|
+
} = table.getRowModel();
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
44
|
+
className: (0, _classnames.default)(`${prefix}-grid-container`, {})
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
46
|
+
ref: scrollRef,
|
|
47
|
+
style: {
|
|
48
|
+
overflow: "auto",
|
|
49
|
+
// border: "1px solid #ccc",
|
|
50
|
+
height,
|
|
51
|
+
position: "relative"
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/_react.default.createElement(_reactVirtuoso.TableVirtuoso, {
|
|
54
|
+
data: table.getRowModel().rows,
|
|
55
|
+
totalCount: rows.length,
|
|
56
|
+
components: {
|
|
57
|
+
Table: ({
|
|
58
|
+
style,
|
|
59
|
+
...props
|
|
60
|
+
}) => {
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement("table", (0, _extends2.default)({}, props, {
|
|
62
|
+
style: {
|
|
63
|
+
...style,
|
|
64
|
+
width: "100%",
|
|
65
|
+
tableLayout: "fixed"
|
|
66
|
+
// borderCollapse: "collapse",
|
|
67
|
+
// borderSpacing: 0
|
|
68
|
+
}
|
|
69
|
+
// className={classNames(`${prefix}-grid-container`, {
|
|
70
|
+
// 'ui-rc-table-ping-right':
|
|
71
|
+
// tableContainerRef &&
|
|
72
|
+
// (tableContainerRef.current?.scrollLeft ?? 0) >= 0 &&
|
|
73
|
+
// (tableContainerRef.current?.scrollLeft ?? 0) + (tableContainerRef.current?.clientWidth ?? 0) <
|
|
74
|
+
// (tableContainerRef.current?.scrollWidth ?? 0),
|
|
75
|
+
|
|
76
|
+
// 'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
|
|
77
|
+
// })}
|
|
78
|
+
}));
|
|
79
|
+
},
|
|
80
|
+
TableHead: props => /*#__PURE__*/_react.default.createElement("thead", (0, _extends2.default)({}, props, {
|
|
81
|
+
className: `${prefix}-grid-thead`
|
|
82
|
+
})),
|
|
83
|
+
TableFoot: props => /*#__PURE__*/_react.default.createElement("tfoot", (0, _extends2.default)({}, props, {
|
|
84
|
+
className: `${prefix}-grid-tfoot`
|
|
85
|
+
})),
|
|
86
|
+
TableRow: props => {
|
|
87
|
+
const index = props["data-index"];
|
|
88
|
+
const row = rows[index];
|
|
89
|
+
return /*#__PURE__*/_react.default.createElement(_TableBodyRow.default, (0, _extends2.default)({
|
|
90
|
+
tableId: id,
|
|
91
|
+
row: row,
|
|
92
|
+
table: table
|
|
93
|
+
}, props));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// overscan={{
|
|
98
|
+
// main: 10,
|
|
99
|
+
// reverse: 20
|
|
100
|
+
// }}
|
|
101
|
+
|
|
102
|
+
// atBottomThreshold={200}
|
|
103
|
+
// atTopThreshold={200}
|
|
104
|
+
,
|
|
105
|
+
increaseViewportBy: {
|
|
106
|
+
top: 200,
|
|
107
|
+
bottom: 200
|
|
108
|
+
},
|
|
109
|
+
fixedHeaderContent: () => {
|
|
110
|
+
return table.getHeaderGroups().map((headerGroup, index) => {
|
|
111
|
+
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
112
|
+
key: headerGroup.id,
|
|
113
|
+
"data-index": headerGroup.id
|
|
114
|
+
}, headerGroup.headers.map(header => {
|
|
115
|
+
const columnRelativeDepth = header.depth - header.column.depth;
|
|
116
|
+
if (columnRelativeDepth > 1) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
let rowSpan = 1;
|
|
120
|
+
if (header.isPlaceholder) {
|
|
121
|
+
const leafs = header.getLeafHeaders();
|
|
122
|
+
rowSpan = leafs[leafs.length - 1].depth - header.depth;
|
|
123
|
+
}
|
|
124
|
+
return /*#__PURE__*/_react.default.createElement(_TableHeadCell.default, {
|
|
125
|
+
key: header.id,
|
|
126
|
+
header: header,
|
|
127
|
+
table: table,
|
|
128
|
+
colSpan: header.colSpan,
|
|
129
|
+
rowSpan: rowSpan,
|
|
130
|
+
rowIndex: index
|
|
131
|
+
});
|
|
132
|
+
}));
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
fixedFooterContent: () => {
|
|
136
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
137
|
+
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
138
|
+
className: "ui-rc-grid-footer-row"
|
|
139
|
+
}, visibleColumns.map(header => {
|
|
140
|
+
return /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
|
|
141
|
+
key: header.id,
|
|
142
|
+
column: header
|
|
143
|
+
});
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// itemContent={(index) => {
|
|
148
|
+
|
|
149
|
+
// const row = rows[index]
|
|
150
|
+
// return (
|
|
151
|
+
|
|
152
|
+
// <TableBodyRow
|
|
153
|
+
// tableId={id}
|
|
154
|
+
// row={row}
|
|
155
|
+
// table={table}
|
|
156
|
+
// // {...props}
|
|
157
|
+
|
|
158
|
+
// />
|
|
159
|
+
|
|
160
|
+
// )
|
|
161
|
+
// }}
|
|
162
|
+
})));
|
|
163
|
+
};
|
|
164
|
+
var _default = exports.default = TableWrapper;
|
|
File without changes
|