es-grid-template 1.7.47 → 1.8.0
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 +1 -3
- package/es/table-component/ColumnsChoose.js +9 -2
- package/es/table-component/InternalTable.js +1 -0
- package/es/table-component/TableContainer.d.ts +5 -1
- package/es/table-component/TableContainer.js +33 -3
- package/es/table-component/TableContainerEdit.js +87 -62
- package/es/table-component/body/EditableCell.js +34 -2
- package/es/table-component/body/TableBody.js +1 -1
- package/es/table-component/body/TableBodyCell.d.ts +7 -3
- package/es/table-component/body/TableBodyCell.js +268 -135
- package/es/table-component/body/TableBodyCellEdit.d.ts +2 -2
- package/es/table-component/body/TableBodyCellEdit.js +18 -13
- package/es/table-component/body/TableBodyRow.d.ts +2 -2
- package/es/table-component/body/TableBodyRow.js +45 -16
- package/es/table-component/components/command/Command.js +2 -0
- package/es/table-component/footer/TableFooter.js +1 -1
- package/es/table-component/footer/TableFooterCell.js +3 -2
- package/es/table-component/footer/TableFooterRow.js +4 -3
- package/es/table-component/header/TableHead.d.ts +1 -1
- package/es/table-component/header/TableHead.js +83 -20
- package/es/table-component/header/TableHeadCell.js +13 -8
- package/es/table-component/header/TableHeadCell2.d.ts +17 -0
- package/es/table-component/header/TableHeadCell2.js +331 -0
- package/es/table-component/header/TableHeadGroupCell.d.ts +17 -0
- package/es/table-component/header/TableHeadGroupCell.js +327 -0
- package/es/table-component/header/TableHeadRow.js +1 -1
- package/es/table-component/hook/utils.js +5 -2
- package/es/table-component/style.scss +26 -4
- package/es/table-component/table/Grid.js +19 -19
- package/es/table-component/table/TableWrapper.js +1 -1
- package/lib/grid-component/TempTable.js +1 -3
- package/lib/table-component/ColumnsChoose.js +9 -2
- package/lib/table-component/InternalTable.js +1 -0
- package/lib/table-component/TableContainer.d.ts +5 -1
- package/lib/table-component/TableContainer.js +32 -2
- package/lib/table-component/TableContainerEdit.js +87 -62
- package/lib/table-component/body/EditableCell.js +34 -2
- package/lib/table-component/body/TableBody.js +1 -1
- package/lib/table-component/body/TableBodyCell.d.ts +7 -3
- package/lib/table-component/body/TableBodyCell.js +267 -136
- package/lib/table-component/body/TableBodyCellEdit.d.ts +2 -2
- package/lib/table-component/body/TableBodyCellEdit.js +18 -13
- package/lib/table-component/body/TableBodyRow.d.ts +2 -2
- package/lib/table-component/body/TableBodyRow.js +45 -16
- package/lib/table-component/components/command/Command.js +2 -0
- package/lib/table-component/footer/TableFooter.js +1 -1
- package/lib/table-component/footer/TableFooterCell.js +3 -2
- package/lib/table-component/footer/TableFooterRow.js +4 -3
- package/lib/table-component/header/TableHead.d.ts +1 -1
- package/lib/table-component/header/TableHead.js +84 -20
- package/lib/table-component/header/TableHeadCell.js +13 -8
- package/lib/table-component/header/TableHeadCell2.d.ts +17 -0
- package/lib/table-component/header/TableHeadCell2.js +340 -0
- package/lib/table-component/header/TableHeadGroupCell.d.ts +17 -0
- package/lib/table-component/header/TableHeadGroupCell.js +336 -0
- package/lib/table-component/header/TableHeadRow.js +1 -1
- package/lib/table-component/hook/utils.js +5 -2
- package/lib/table-component/style.scss +26 -4
- package/lib/table-component/table/Grid.js +19 -19
- package/lib/table-component/table/TableWrapper.js +1 -1
- package/package.json +1 -1
|
@@ -1,58 +1,20 @@
|
|
|
1
1
|
import { flexRender } from "@tanstack/react-table";
|
|
2
2
|
import Space from "rc-master-ui/es/space";
|
|
3
3
|
import Command from "../components/command/Command";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import ReactDOMServer from 'react-dom/server';
|
|
5
|
+
import { getCommonPinningStyles } from "../hook/utils";
|
|
6
6
|
import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
|
|
7
|
-
import React, { useContext } from "react";
|
|
8
|
-
import { TableContext } from "../useContext";
|
|
9
7
|
import classNames from "classnames";
|
|
10
|
-
import
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { TableContext } from "../useContext";
|
|
11
10
|
const renderCellIndex = props => {
|
|
12
11
|
const {
|
|
13
12
|
parrents,
|
|
14
|
-
cell
|
|
15
|
-
expanded,
|
|
16
|
-
isDataTree,
|
|
17
|
-
setExpanded,
|
|
18
|
-
expandIconColumnIndex
|
|
13
|
+
cell
|
|
19
14
|
} = props;
|
|
20
15
|
return /*#__PURE__*/React.createElement("span", {
|
|
21
16
|
className: "ui-rc_cell-content"
|
|
22
|
-
},
|
|
23
|
-
className: "ui-rc-table-row-expand-trigger",
|
|
24
|
-
style: {
|
|
25
|
-
paddingLeft: `${cell.row.depth * 25}px`
|
|
26
|
-
}
|
|
27
|
-
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
28
|
-
// onClick: row.getToggleExpandedHandler(),
|
|
29
|
-
onClick: () => {
|
|
30
|
-
const keys = Object.keys(expanded);
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
const tmp = {
|
|
33
|
-
...expanded
|
|
34
|
-
};
|
|
35
|
-
if (keys.includes(cell.row.id)) {
|
|
36
|
-
delete tmp[cell.row.id];
|
|
37
|
-
setExpanded(tmp);
|
|
38
|
-
} else {
|
|
39
|
-
setExpanded(old => ({
|
|
40
|
-
...old,
|
|
41
|
-
[cell.row.id]: true
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
style: {
|
|
46
|
-
cursor: "pointer"
|
|
47
|
-
},
|
|
48
|
-
className: "ui-rc-table-row-expand"
|
|
49
|
-
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
50
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
51
|
-
}) : /*#__PURE__*/React.createElement("span", {
|
|
52
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
53
|
-
})) : /*#__PURE__*/React.createElement("span", {
|
|
54
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
55
|
-
}))), parrents.map(pr => {
|
|
17
|
+
}, parrents.map(pr => {
|
|
56
18
|
return `${pr.index + 1}.`;
|
|
57
19
|
}), cell.row.index + 1);
|
|
58
20
|
};
|
|
@@ -74,7 +36,7 @@ const renderCommand = args => {
|
|
|
74
36
|
visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
|
|
75
37
|
};
|
|
76
38
|
}) : [];
|
|
77
|
-
return /*#__PURE__*/React.createElement("
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
78
40
|
className: "ui-rc_cell-content"
|
|
79
41
|
}, /*#__PURE__*/React.createElement(Space, null, commands.filter(it => it.visible !== false).map(item => {
|
|
80
42
|
return /*#__PURE__*/React.createElement(Command, {
|
|
@@ -85,6 +47,7 @@ const renderCommand = args => {
|
|
|
85
47
|
onClick: () => {
|
|
86
48
|
commandClick?.({
|
|
87
49
|
id: item.id,
|
|
50
|
+
// rowId: getRowKey(record, index) as any,
|
|
88
51
|
rowId: record.rowId,
|
|
89
52
|
rowData: record,
|
|
90
53
|
index: cell.row.index,
|
|
@@ -110,10 +73,7 @@ const renderSelection = args => {
|
|
|
110
73
|
setIsSelectionChange
|
|
111
74
|
} = args;
|
|
112
75
|
return /*#__PURE__*/React.createElement("div", {
|
|
113
|
-
style: {
|
|
114
|
-
|
|
115
|
-
// paddingLeft: `${row.depth * 2}rem`,
|
|
116
|
-
}
|
|
76
|
+
style: {}
|
|
117
77
|
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
118
78
|
className: "ui-rc-table-row-expand-trigger",
|
|
119
79
|
style: {
|
|
@@ -159,11 +119,6 @@ const renderSelection = args => {
|
|
|
159
119
|
type: 'rowSelected',
|
|
160
120
|
rowData: row.original
|
|
161
121
|
});
|
|
162
|
-
// row.toggleSelected()
|
|
163
|
-
|
|
164
|
-
// table.setRowSelection({
|
|
165
|
-
// [row.id]: true
|
|
166
|
-
// })
|
|
167
122
|
}
|
|
168
123
|
})));
|
|
169
124
|
};
|
|
@@ -171,34 +126,222 @@ const TableBodyCell = props => {
|
|
|
171
126
|
const {
|
|
172
127
|
cell,
|
|
173
128
|
commandClick,
|
|
174
|
-
|
|
129
|
+
// tableId,
|
|
130
|
+
table,
|
|
131
|
+
isEditing
|
|
175
132
|
} = props;
|
|
176
133
|
const {
|
|
177
|
-
prefix,
|
|
178
|
-
setIsSelectionChange,
|
|
179
|
-
selectionSettings,
|
|
180
134
|
id,
|
|
135
|
+
prefix,
|
|
136
|
+
focusedCell,
|
|
137
|
+
setFocusedCell,
|
|
138
|
+
// endCell,
|
|
139
|
+
// startCell,
|
|
181
140
|
originData,
|
|
182
|
-
wrapSettings,
|
|
183
141
|
expanded,
|
|
184
142
|
setExpanded,
|
|
185
143
|
expandable,
|
|
186
|
-
isDataTree
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
144
|
+
isDataTree,
|
|
145
|
+
setIsSelectionChange,
|
|
146
|
+
selectionSettings,
|
|
147
|
+
wrapSettings
|
|
148
|
+
// dataSource
|
|
149
|
+
} = React.useContext(TableContext);
|
|
190
150
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex;
|
|
151
|
+
const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
|
|
152
|
+
const record = cell.row.original;
|
|
153
|
+
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
154
|
+
const tooltipContent = isOpenTooltip === false || columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
155
|
+
const allRows = table.getRowModel().flatRows;
|
|
156
|
+
const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
|
|
157
|
+
const colIndex = cell.column.getIndex();
|
|
191
158
|
const isPinned = cell.column.getIsPinned();
|
|
192
159
|
const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
193
160
|
const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
return
|
|
161
|
+
|
|
162
|
+
// const selectRowIds = React.useMemo(() => {
|
|
163
|
+
|
|
164
|
+
// return startCell && endCell ? getRowIdsBetween(table, startCell.rowId, endCell.rowId) : []
|
|
165
|
+
|
|
166
|
+
// }, [endCell, startCell, table])
|
|
167
|
+
|
|
168
|
+
const parrents = cell.row.getParentRows();
|
|
169
|
+
if (cell.column.id === "#") {
|
|
170
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
171
|
+
key: cell.id,
|
|
172
|
+
className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-index`, {
|
|
173
|
+
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
174
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
175
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
176
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
177
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
|
|
178
|
+
// [`${prefix}-grid-cell-index-selected`]: rowRange?.includes(cell.row.id),
|
|
179
|
+
// [`${prefix}-grid-cell-index-selected`]: selectRowIds?.includes(cell.row.id),
|
|
180
|
+
}),
|
|
181
|
+
style: {
|
|
182
|
+
display: 'flex',
|
|
183
|
+
// height: '36px',
|
|
184
|
+
userSelect: 'none',
|
|
185
|
+
width: cell.column.getSize(),
|
|
186
|
+
// flexBasis: cell.column.getSize(),
|
|
187
|
+
minWidth: cell.column.getSize(),
|
|
188
|
+
// flex: 1,
|
|
189
|
+
// maxWidth: cell.column.getSize(),
|
|
190
|
+
...getCommonPinningStyles(cell.column)
|
|
191
|
+
},
|
|
192
|
+
onMouseDown: () => {}
|
|
193
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
194
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
195
|
+
style: {
|
|
196
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
197
|
+
}
|
|
198
|
+
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
199
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
200
|
+
onClick: () => {
|
|
201
|
+
const keys = Object.keys(expanded);
|
|
202
|
+
// @ts-ignore
|
|
203
|
+
const tmp = {
|
|
204
|
+
...expanded
|
|
205
|
+
};
|
|
206
|
+
if (keys.includes(cell.row.id)) {
|
|
207
|
+
delete tmp[cell.row.id];
|
|
208
|
+
setExpanded(tmp);
|
|
209
|
+
} else {
|
|
210
|
+
setExpanded(old => ({
|
|
211
|
+
...old,
|
|
212
|
+
[cell.row.id]: true
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
style: {
|
|
217
|
+
cursor: "pointer"
|
|
218
|
+
},
|
|
219
|
+
className: "ui-rc-table-row-expand"
|
|
220
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
221
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
222
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
223
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
224
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
225
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
226
|
+
}))), renderCellIndex({
|
|
227
|
+
parrents,
|
|
228
|
+
cell
|
|
229
|
+
}));
|
|
230
|
+
}
|
|
231
|
+
if (cell.column.id === "command") {
|
|
232
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
233
|
+
key: cell.id,
|
|
234
|
+
className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-command`, {
|
|
235
|
+
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
236
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
237
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
238
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
239
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
|
|
240
|
+
}),
|
|
241
|
+
style: {
|
|
242
|
+
display: 'flex',
|
|
243
|
+
// height: '36px',
|
|
244
|
+
width: cell.column.getSize(),
|
|
245
|
+
minWidth: cell.column.getSize(),
|
|
246
|
+
// flex: 1,
|
|
247
|
+
// maxWidth: cell.column.getSize(),
|
|
248
|
+
...getCommonPinningStyles(cell.column)
|
|
249
|
+
}
|
|
250
|
+
}, renderCommand({
|
|
251
|
+
cell,
|
|
252
|
+
commandClick,
|
|
253
|
+
id,
|
|
254
|
+
data: originData
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
if (cell.column.id === "selection_column") {
|
|
258
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
259
|
+
key: cell.id,
|
|
260
|
+
className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-selection`, {
|
|
261
|
+
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
262
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
263
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
264
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
265
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
|
|
266
|
+
}),
|
|
267
|
+
style: {
|
|
268
|
+
display: 'flex',
|
|
269
|
+
// height: '36px',
|
|
270
|
+
width: cell.column.getSize(),
|
|
271
|
+
minWidth: cell.column.getSize(),
|
|
272
|
+
// flex: 1,
|
|
273
|
+
// maxWidth: cell.column.getSize(),
|
|
274
|
+
...getCommonPinningStyles(cell.column)
|
|
275
|
+
}
|
|
276
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
277
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
278
|
+
style: {
|
|
279
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
280
|
+
}
|
|
281
|
+
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
282
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
283
|
+
onClick: () => {
|
|
284
|
+
const keys = Object.keys(expanded);
|
|
285
|
+
// @ts-ignore
|
|
286
|
+
const tmp = {
|
|
287
|
+
...expanded
|
|
288
|
+
};
|
|
289
|
+
if (keys.includes(cell.row.id)) {
|
|
290
|
+
delete tmp[cell.row.id];
|
|
291
|
+
setExpanded(tmp);
|
|
292
|
+
} else {
|
|
293
|
+
setExpanded(old => ({
|
|
294
|
+
...old,
|
|
295
|
+
[cell.row.id]: true
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
style: {
|
|
300
|
+
cursor: "pointer"
|
|
301
|
+
},
|
|
302
|
+
className: "ui-rc-table-row-expand"
|
|
303
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
304
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
305
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
306
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
307
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
308
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
309
|
+
}))), cell.column.id === "selection_column" && renderSelection({
|
|
310
|
+
cell,
|
|
311
|
+
table,
|
|
312
|
+
selectionSettings,
|
|
313
|
+
setIsSelectionChange,
|
|
314
|
+
expanded,
|
|
315
|
+
isDataTree,
|
|
316
|
+
setExpanded,
|
|
317
|
+
expandIconColumnIndex
|
|
318
|
+
}));
|
|
319
|
+
}
|
|
320
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
198
321
|
key: cell.id,
|
|
322
|
+
ref: el => {
|
|
323
|
+
if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
|
|
324
|
+
el?.focus();
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
|
|
328
|
+
"data-col-index": colIndex,
|
|
329
|
+
"data-row-index": rowNumber,
|
|
330
|
+
"data-col-key": cell.column.id
|
|
331
|
+
// data-row-key={cell.row.id}
|
|
332
|
+
,
|
|
333
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
334
|
+
"data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent))
|
|
335
|
+
// data-tooltip-delay-show={500}
|
|
336
|
+
,
|
|
337
|
+
|
|
199
338
|
className: classNames(`${prefix}-grid-cell`, {
|
|
339
|
+
// [`${prefix}-grid-cell-ellipsis`]: true,
|
|
340
|
+
|
|
200
341
|
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
|
|
201
|
-
[`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
|
|
342
|
+
[`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
|
|
343
|
+
// [`${prefix}-grid-cell-selected`]: isCellSelected,
|
|
344
|
+
|
|
202
345
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
203
346
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
204
347
|
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
@@ -206,19 +349,63 @@ const TableBodyCell = props => {
|
|
|
206
349
|
}),
|
|
207
350
|
style: {
|
|
208
351
|
display: 'flex',
|
|
209
|
-
// flex: 1,
|
|
210
352
|
width: cell.column.getSize(),
|
|
211
|
-
|
|
353
|
+
minWidth: cell.column.getSize(),
|
|
354
|
+
// flex: 1,
|
|
355
|
+
// maxWidth: cell.column.getSize(),
|
|
356
|
+
// height: '36px',
|
|
212
357
|
...getCommonPinningStyles(cell.column)
|
|
213
358
|
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
359
|
+
onMouseDown: () => {},
|
|
360
|
+
onMouseEnter: e => {
|
|
361
|
+
if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
|
|
362
|
+
setIsOpenTooltip(true);
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
onMouseUp: () => {},
|
|
366
|
+
onKeyDown: e => {
|
|
367
|
+
const flatRows = table.getRowModel().flatRows;
|
|
368
|
+
if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
|
|
369
|
+
const nextIndex = cell.row.index + 1;
|
|
370
|
+
// const nextIndex = rowNumber + 1
|
|
371
|
+
|
|
372
|
+
const nextId = flatRows[nextIndex].id;
|
|
373
|
+
setFocusedCell?.({
|
|
374
|
+
colId: cell.column.id,
|
|
375
|
+
rowId: nextId
|
|
376
|
+
});
|
|
377
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
378
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
379
|
+
if (cellFocus) {
|
|
380
|
+
cellFocus.focus();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
384
|
+
const prevIndex = cell.row.index - 1;
|
|
385
|
+
const nextId = flatRows[prevIndex].id;
|
|
386
|
+
setFocusedCell?.({
|
|
387
|
+
colId: cell.column.id,
|
|
388
|
+
rowId: nextId
|
|
389
|
+
});
|
|
390
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
391
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
392
|
+
if (cellFocus) {
|
|
393
|
+
cellFocus.focus();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (e.ctrlKey && e.code === 'Space') {
|
|
397
|
+
cell.row.getToggleSelectedHandler()(e);
|
|
398
|
+
setIsSelectionChange({
|
|
399
|
+
isChange: true,
|
|
400
|
+
type: 'rowSelected',
|
|
401
|
+
rowData: record
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
onDoubleClick: () => {},
|
|
406
|
+
onClick: e => {
|
|
407
|
+
if (selectionSettings?.checkboxOnly !== true) {
|
|
408
|
+
cell.row.getToggleSelectedHandler()(e);
|
|
222
409
|
setIsSelectionChange({
|
|
223
410
|
isChange: true,
|
|
224
411
|
type: 'rowSelected',
|
|
@@ -226,29 +413,8 @@ const TableBodyCell = props => {
|
|
|
226
413
|
});
|
|
227
414
|
}
|
|
228
415
|
}
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
cell,
|
|
232
|
-
expanded,
|
|
233
|
-
isDataTree,
|
|
234
|
-
setExpanded,
|
|
235
|
-
expandIconColumnIndex
|
|
236
|
-
}), cell.column.id === "command" && renderCommand({
|
|
237
|
-
cell,
|
|
238
|
-
commandClick,
|
|
239
|
-
id,
|
|
240
|
-
data: originData
|
|
241
|
-
}), cell.column.id === "selection_column" && renderSelection({
|
|
242
|
-
cell,
|
|
243
|
-
table,
|
|
244
|
-
selectionSettings,
|
|
245
|
-
setIsSelectionChange,
|
|
246
|
-
expanded,
|
|
247
|
-
isDataTree,
|
|
248
|
-
setExpanded,
|
|
249
|
-
expandIconColumnIndex
|
|
250
|
-
}), !nonActionColumn.includes(cell.column.id) && (isFirstRightPinnedColumn ? /*#__PURE__*/React.createElement("span", {
|
|
251
|
-
className: "ui-rc_cell-content"
|
|
416
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
417
|
+
className: classNames('ui-rc_cell-content', {})
|
|
252
418
|
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
253
419
|
className: "ui-rc-table-row-expand-trigger",
|
|
254
420
|
style: {
|
|
@@ -282,39 +448,6 @@ const TableBodyCell = props => {
|
|
|
282
448
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
283
449
|
})) : /*#__PURE__*/React.createElement("span", {
|
|
284
450
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
285
|
-
}))), flexRender(cell.column.columnDef.cell, cell.getContext()))
|
|
286
|
-
className: "ui-rc-table-row-expand-trigger",
|
|
287
|
-
style: {
|
|
288
|
-
paddingLeft: `${cell.row.depth * 25}px`
|
|
289
|
-
}
|
|
290
|
-
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
291
|
-
// onClick: row.getToggleExpandedHandler(),
|
|
292
|
-
onClick: () => {
|
|
293
|
-
const keys = Object.keys(expanded);
|
|
294
|
-
// @ts-ignore
|
|
295
|
-
const tmp = {
|
|
296
|
-
...expanded
|
|
297
|
-
};
|
|
298
|
-
if (keys.includes(cell.row.id)) {
|
|
299
|
-
delete tmp[cell.row.id];
|
|
300
|
-
setExpanded(tmp);
|
|
301
|
-
} else {
|
|
302
|
-
setExpanded(old => ({
|
|
303
|
-
...old,
|
|
304
|
-
[cell.row.id]: true
|
|
305
|
-
}));
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
style: {
|
|
309
|
-
cursor: "pointer"
|
|
310
|
-
},
|
|
311
|
-
className: "ui-rc-table-row-expand"
|
|
312
|
-
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
313
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
314
|
-
}) : /*#__PURE__*/React.createElement("span", {
|
|
315
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
316
|
-
})) : /*#__PURE__*/React.createElement("span", {
|
|
317
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
318
|
-
}))), flexRender(cell.column.columnDef.cell, cell.getContext()))));
|
|
451
|
+
}))), flexRender(cell.column.columnDef.cell, cell.getContext())));
|
|
319
452
|
};
|
|
320
453
|
export default TableBodyCell;
|
|
@@ -4,8 +4,8 @@ import React from "react";
|
|
|
4
4
|
import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
|
|
5
5
|
interface TableBodyCellProps<T> {
|
|
6
6
|
table: Table<T>;
|
|
7
|
-
rowVirtualizer: Virtualizer<HTMLDivElement,
|
|
8
|
-
columnVirtualizer: Virtualizer<HTMLDivElement,
|
|
7
|
+
rowVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
8
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
9
9
|
tableId: string;
|
|
10
10
|
cell: Cell<T, unknown>;
|
|
11
11
|
commandClick?: (args: CommandClick<T>) => void;
|
|
@@ -744,9 +744,9 @@ const TableBodyCellEdit = props => {
|
|
|
744
744
|
}
|
|
745
745
|
};
|
|
746
746
|
if (cell.column.id === "#") {
|
|
747
|
-
return /*#__PURE__*/React.createElement("
|
|
747
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
748
748
|
key: cell.id,
|
|
749
|
-
className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-index`, {
|
|
749
|
+
className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-index editable`, {
|
|
750
750
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
751
751
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
752
752
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
@@ -762,7 +762,8 @@ const TableBodyCellEdit = props => {
|
|
|
762
762
|
width: cell.column.getSize(),
|
|
763
763
|
// flexBasis: cell.column.getSize(),
|
|
764
764
|
minWidth: cell.column.getSize(),
|
|
765
|
-
|
|
765
|
+
// flex: 1,
|
|
766
|
+
// maxWidth: cell.column.getSize(),
|
|
766
767
|
...getCommonPinningStyles(cell.column)
|
|
767
768
|
},
|
|
768
769
|
onMouseDown: () => {
|
|
@@ -831,9 +832,9 @@ const TableBodyCellEdit = props => {
|
|
|
831
832
|
}));
|
|
832
833
|
}
|
|
833
834
|
if (cell.column.id === "command") {
|
|
834
|
-
return /*#__PURE__*/React.createElement("
|
|
835
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
835
836
|
key: cell.id,
|
|
836
|
-
className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-command`, {
|
|
837
|
+
className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-command editable`, {
|
|
837
838
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
838
839
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
839
840
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
@@ -845,7 +846,8 @@ const TableBodyCellEdit = props => {
|
|
|
845
846
|
height: '36px',
|
|
846
847
|
width: cell.column.getSize(),
|
|
847
848
|
minWidth: cell.column.getSize(),
|
|
848
|
-
|
|
849
|
+
// flex: 1,
|
|
850
|
+
// maxWidth: cell.column.getSize(),
|
|
849
851
|
...getCommonPinningStyles(cell.column)
|
|
850
852
|
}
|
|
851
853
|
}, renderCommand({
|
|
@@ -856,9 +858,9 @@ const TableBodyCellEdit = props => {
|
|
|
856
858
|
}));
|
|
857
859
|
}
|
|
858
860
|
if (cell.column.id === "selection_column") {
|
|
859
|
-
return /*#__PURE__*/React.createElement("
|
|
861
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
860
862
|
key: cell.id,
|
|
861
|
-
className: classNames(`${prefix}-grid-cell cell-
|
|
863
|
+
className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-selection editable`, {
|
|
862
864
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
863
865
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
864
866
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
@@ -870,7 +872,8 @@ const TableBodyCellEdit = props => {
|
|
|
870
872
|
height: '36px',
|
|
871
873
|
width: cell.column.getSize(),
|
|
872
874
|
minWidth: cell.column.getSize(),
|
|
873
|
-
|
|
875
|
+
// flex: 1,
|
|
876
|
+
// maxWidth: cell.column.getSize(),
|
|
874
877
|
...getCommonPinningStyles(cell.column)
|
|
875
878
|
}
|
|
876
879
|
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
@@ -937,7 +940,7 @@ const TableBodyCellEdit = props => {
|
|
|
937
940
|
});
|
|
938
941
|
}
|
|
939
942
|
};
|
|
940
|
-
return /*#__PURE__*/React.createElement("
|
|
943
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
941
944
|
key: cell.id,
|
|
942
945
|
ref: el => {
|
|
943
946
|
if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
|
|
@@ -949,13 +952,14 @@ const TableBodyCellEdit = props => {
|
|
|
949
952
|
"data-row-index": rowNumber,
|
|
950
953
|
"data-col-key": cell.column.id,
|
|
951
954
|
"data-row-key": cell.row.id,
|
|
952
|
-
"data-tooltip-id": `${id}-tooltip-content
|
|
955
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
956
|
+
"data-tooltip-delay-show": 500
|
|
953
957
|
// data-tooltip-html={!isEditing && !hasValue && !message ? undefined : ReactDOMServer.renderToStaticMarkup(<>{rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : cellContent}</>)}
|
|
954
958
|
// data-tooltip-content={!isEditing && !message ? undefined : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : record[columnMeta.field ?? '']}
|
|
955
959
|
// data-tooltip-content={isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : record[columnMeta.field ?? '']}
|
|
956
960
|
,
|
|
957
961
|
"data-tooltip-html": isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, cellContent)),
|
|
958
|
-
className: classNames(`${prefix}-grid-cell cell-editable `, {
|
|
962
|
+
className: classNames(`${prefix}-grid-cell cell-editable editable `, {
|
|
959
963
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
960
964
|
'cell-editing': isEditing,
|
|
961
965
|
disable: !isEditable(cell.column.columnDef.meta, record),
|
|
@@ -978,7 +982,8 @@ const TableBodyCellEdit = props => {
|
|
|
978
982
|
display: 'flex',
|
|
979
983
|
width: cell.column.getSize(),
|
|
980
984
|
minWidth: cell.column.getSize(),
|
|
981
|
-
|
|
985
|
+
// flex: 1,
|
|
986
|
+
// maxWidth: cell.column.getSize(),
|
|
982
987
|
height: '36px',
|
|
983
988
|
...getCommonPinningStyles(cell.column),
|
|
984
989
|
cursor: isPasting ? 'crosshair' : undefined
|
|
@@ -5,9 +5,9 @@ import React from "react";
|
|
|
5
5
|
interface TableBodyRowProps<T> {
|
|
6
6
|
tableId: string;
|
|
7
7
|
table: Table<T>;
|
|
8
|
-
columnVirtualizer: Virtualizer<HTMLDivElement,
|
|
8
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
9
9
|
row: Row<T>;
|
|
10
|
-
rowVirtualizer: Virtualizer<HTMLDivElement,
|
|
10
|
+
rowVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
11
11
|
virtualPaddingLeft: number | undefined;
|
|
12
12
|
virtualPaddingRight: number | undefined;
|
|
13
13
|
virtualRow: VirtualItem;
|