es-grid-template 1.7.33 → 1.7.35
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/table-component/InternalTable.js +23 -9
- package/es/table-component/TableContainer.d.ts +1 -0
- package/es/table-component/TableContainer.js +4 -2
- package/es/table-component/TableContainerEdit.d.ts +1 -0
- package/es/table-component/TableContainerEdit.js +33 -2
- package/es/table-component/body/EditableCell.js +3 -2
- package/es/table-component/body/TableBodyCell.js +165 -9
- package/es/table-component/body/TableBodyCellEdit.js +19 -13
- package/es/table-component/body/TableBodyRow.js +0 -8
- package/es/table-component/header/TableHeadCell.js +2 -2
- package/es/table-component/hook/utils.d.ts +2 -1
- package/es/table-component/hook/utils.js +22 -4
- package/es/table-component/style.scss +20 -14
- package/es/table-component/table/Grid.d.ts +3 -2
- package/es/table-component/type.d.ts +9 -1
- package/es/table-component/useContext.d.ts +6 -3
- package/es/table-component/useContext.js +3 -1
- package/lib/table-component/InternalTable.js +22 -8
- package/lib/table-component/TableContainer.d.ts +1 -0
- package/lib/table-component/TableContainer.js +4 -2
- package/lib/table-component/TableContainerEdit.d.ts +1 -0
- package/lib/table-component/TableContainerEdit.js +33 -2
- package/lib/table-component/body/EditableCell.js +3 -2
- package/lib/table-component/body/TableBodyCell.js +165 -9
- package/lib/table-component/body/TableBodyCellEdit.js +19 -13
- package/lib/table-component/body/TableBodyRow.js +0 -8
- package/lib/table-component/header/TableHeadCell.js +2 -2
- package/lib/table-component/hook/utils.d.ts +2 -1
- package/lib/table-component/hook/utils.js +25 -7
- package/lib/table-component/style.scss +20 -14
- package/lib/table-component/table/Grid.d.ts +3 -2
- package/lib/table-component/type.d.ts +9 -1
- package/lib/table-component/useContext.d.ts +6 -3
- package/lib/table-component/useContext.js +3 -1
- package/package.json +1 -1
|
@@ -33,7 +33,7 @@ import { addRowIdArray, convertToObj,
|
|
|
33
33
|
// convertFilters,
|
|
34
34
|
filterDataByColumns, flatColumns2,
|
|
35
35
|
// filterDataByColumns,
|
|
36
|
-
getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayByColumns } from "./hook/utils";
|
|
36
|
+
getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayByColumns, isTree } from "./hook/utils";
|
|
37
37
|
// import GridEdit from './table/GridEdit'
|
|
38
38
|
import { convertToTanStackColumns } from "./hook/useColumns";
|
|
39
39
|
import { convertColumns } from "./hook/convert";
|
|
@@ -51,8 +51,8 @@ export const SELECTION_COLUMN = {};
|
|
|
51
51
|
const InternalTable = props => {
|
|
52
52
|
const {
|
|
53
53
|
t,
|
|
54
|
-
|
|
55
|
-
columns,
|
|
54
|
+
columns: propsColumns,
|
|
55
|
+
// columns,
|
|
56
56
|
lang,
|
|
57
57
|
locale,
|
|
58
58
|
dataSource,
|
|
@@ -126,6 +126,10 @@ const InternalTable = props => {
|
|
|
126
126
|
const [filterStates, setFilterState] = React.useState(null);
|
|
127
127
|
const [sorterStates, setSorterStates] = React.useState([]);
|
|
128
128
|
const [isFullScreen, setIsFullScreen] = React.useState(false);
|
|
129
|
+
const [columns, setColumns] = React.useState([]);
|
|
130
|
+
React.useEffect(() => {
|
|
131
|
+
setColumns(propsColumns);
|
|
132
|
+
}, [propsColumns]);
|
|
129
133
|
const [expanded, setExpanded] = React.useState({});
|
|
130
134
|
const convertData = React.useMemo(() => {
|
|
131
135
|
if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
@@ -146,6 +150,9 @@ const InternalTable = props => {
|
|
|
146
150
|
|
|
147
151
|
// return convertToTanStackColumns<RecordType>(columns, expanded, setExpanded, expandable)
|
|
148
152
|
}, [t, columns, format, editAble]);
|
|
153
|
+
const isDataTree = React.useMemo(() => {
|
|
154
|
+
return isTree(dataSource);
|
|
155
|
+
}, [dataSource]);
|
|
149
156
|
const columnPinning = React.useMemo(() => {
|
|
150
157
|
return {
|
|
151
158
|
left: getFixedFields(columns, 'left'),
|
|
@@ -166,10 +173,14 @@ const InternalTable = props => {
|
|
|
166
173
|
const [columnsHiddenKeys, setColumnsHiddenKeys] = useMergedState(undefined, {
|
|
167
174
|
value: undefined
|
|
168
175
|
});
|
|
169
|
-
const triggerChangeColumns = (cols, keys) => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
const triggerChangeColumns = (cols, keys, type) => {
|
|
177
|
+
if (type === 'cellClick') {
|
|
178
|
+
setColumns(cols);
|
|
179
|
+
} else {
|
|
180
|
+
const aa = flatColumns2(columns).map(it => it.field);
|
|
181
|
+
const rsss = getDiffent2Array(aa, keys);
|
|
182
|
+
setColumnsHiddenKeys(rsss);
|
|
183
|
+
}
|
|
173
184
|
};
|
|
174
185
|
|
|
175
186
|
// const contextMenuItems = React.useMemo(() => {
|
|
@@ -277,7 +288,9 @@ const InternalTable = props => {
|
|
|
277
288
|
setExpanded: setExpanded,
|
|
278
289
|
isFullScreen: isFullScreen,
|
|
279
290
|
setIsFullScreen: setIsFullScreen,
|
|
280
|
-
windowSize: windowSize
|
|
291
|
+
windowSize: windowSize,
|
|
292
|
+
height: height,
|
|
293
|
+
isDataTree: isDataTree
|
|
281
294
|
})), /*#__PURE__*/React.createElement(Modal, {
|
|
282
295
|
open: isFullScreen,
|
|
283
296
|
footer: null,
|
|
@@ -340,7 +353,8 @@ const InternalTable = props => {
|
|
|
340
353
|
isFullScreen: isFullScreen,
|
|
341
354
|
setIsFullScreen: setIsFullScreen,
|
|
342
355
|
height: windowSize.innerHeight - 70,
|
|
343
|
-
windowSize: windowSize
|
|
356
|
+
windowSize: windowSize,
|
|
357
|
+
isDataTree: isDataTree
|
|
344
358
|
})))));
|
|
345
359
|
};
|
|
346
360
|
export default InternalTable;
|
|
@@ -31,6 +31,7 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
31
31
|
columnHidden: any;
|
|
32
32
|
isFullScreen: boolean;
|
|
33
33
|
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
34
|
+
isDataTree: boolean;
|
|
34
35
|
};
|
|
35
36
|
declare const TableContainer: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
|
|
36
37
|
export default TableContainer;
|
|
@@ -69,7 +69,8 @@ const TableContainer = props => {
|
|
|
69
69
|
contextMenuClick,
|
|
70
70
|
contextMenuHidden,
|
|
71
71
|
isFullScreen,
|
|
72
|
-
setIsFullScreen
|
|
72
|
+
setIsFullScreen,
|
|
73
|
+
isDataTree
|
|
73
74
|
} = props;
|
|
74
75
|
const tableContainerRef = React.useRef(null);
|
|
75
76
|
const containerRef = React.useRef(null);
|
|
@@ -207,7 +208,8 @@ const TableContainer = props => {
|
|
|
207
208
|
onContextMenu,
|
|
208
209
|
setSorterChange,
|
|
209
210
|
setFilterChange,
|
|
210
|
-
windowSize
|
|
211
|
+
windowSize,
|
|
212
|
+
isDataTree
|
|
211
213
|
}
|
|
212
214
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
213
215
|
contextMenuItems: contextMenuItems,
|
|
@@ -18,6 +18,7 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
18
18
|
setFilterChange: Dispatch<SetStateAction<boolean>>;
|
|
19
19
|
onContextMenu?: (data: T) => (event: any) => void;
|
|
20
20
|
tableHeight?: number;
|
|
21
|
+
isDataTree: boolean;
|
|
21
22
|
windowSize: {
|
|
22
23
|
innerHeight: number;
|
|
23
24
|
innerWidth: number;
|
|
@@ -115,7 +115,9 @@ const TableContainerEdit = props => {
|
|
|
115
115
|
contextMenuClick,
|
|
116
116
|
contextMenuHidden,
|
|
117
117
|
showDefaultContext,
|
|
118
|
-
commandSettings
|
|
118
|
+
commandSettings,
|
|
119
|
+
isDataTree,
|
|
120
|
+
onCellClick
|
|
119
121
|
} = props;
|
|
120
122
|
const containerRef = React.useRef(null);
|
|
121
123
|
const bottomToolbarRef = React.useRef(null);
|
|
@@ -1441,6 +1443,33 @@ const TableContainerEdit = props => {
|
|
|
1441
1443
|
}
|
|
1442
1444
|
contextMenuClick?.(args);
|
|
1443
1445
|
};
|
|
1446
|
+
const handleCellClick = (rowNumber, record, column, rowId, cellValue) => {
|
|
1447
|
+
const cellClickCallback = newOptions => {
|
|
1448
|
+
if (newOptions) {
|
|
1449
|
+
const newElem = {
|
|
1450
|
+
...column,
|
|
1451
|
+
editSelectSettings: {
|
|
1452
|
+
...(column?.editSelectSettings ? {
|
|
1453
|
+
...column?.editSelectSettings
|
|
1454
|
+
} : {}),
|
|
1455
|
+
options: newOptions
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
const rrr = updateArrayByKey([...columns], newElem, 'field');
|
|
1459
|
+
triggerChangeColumns?.(rrr, 'click');
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
if (onCellClick) {
|
|
1463
|
+
onCellClick({
|
|
1464
|
+
index: rowNumber,
|
|
1465
|
+
rowId,
|
|
1466
|
+
cellValue,
|
|
1467
|
+
type: "Editing",
|
|
1468
|
+
field: column.field,
|
|
1469
|
+
rowData: record
|
|
1470
|
+
}, cellClickCallback);
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1444
1473
|
return /*#__PURE__*/React.createElement("div", {
|
|
1445
1474
|
ref: containerRef,
|
|
1446
1475
|
id: id
|
|
@@ -1503,6 +1532,7 @@ const TableContainerEdit = props => {
|
|
|
1503
1532
|
}, /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
1504
1533
|
value: {
|
|
1505
1534
|
t,
|
|
1535
|
+
isDataTree,
|
|
1506
1536
|
locale,
|
|
1507
1537
|
prefix,
|
|
1508
1538
|
id,
|
|
@@ -1552,7 +1582,8 @@ const TableContainerEdit = props => {
|
|
|
1552
1582
|
handleDeleteContent,
|
|
1553
1583
|
handleAddMulti,
|
|
1554
1584
|
dataErrors,
|
|
1555
|
-
windowSize
|
|
1585
|
+
windowSize,
|
|
1586
|
+
handleCellClick
|
|
1556
1587
|
}
|
|
1557
1588
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
1558
1589
|
contextMenuItems: contextMenuItems,
|
|
@@ -48,7 +48,7 @@ const filterTreeNode = (input, treeNode) => {
|
|
|
48
48
|
};
|
|
49
49
|
const EditableCell = props => {
|
|
50
50
|
const {
|
|
51
|
-
t,
|
|
51
|
+
// t,
|
|
52
52
|
// editing,
|
|
53
53
|
dataIndex,
|
|
54
54
|
editType,
|
|
@@ -69,7 +69,8 @@ const EditableCell = props => {
|
|
|
69
69
|
errors,
|
|
70
70
|
id,
|
|
71
71
|
startCell,
|
|
72
|
-
rowKey
|
|
72
|
+
rowKey,
|
|
73
|
+
t
|
|
73
74
|
} = useContext(TableContext);
|
|
74
75
|
const datePickerRef = React.useRef(null);
|
|
75
76
|
const dateTimePickerRef = React.useRef(null);
|
|
@@ -11,11 +11,48 @@ import ReactDOMServer from 'react-dom/server';
|
|
|
11
11
|
const renderCellIndex = props => {
|
|
12
12
|
const {
|
|
13
13
|
parrents,
|
|
14
|
-
cell
|
|
14
|
+
cell,
|
|
15
|
+
expanded,
|
|
16
|
+
isDataTree,
|
|
17
|
+
setExpanded,
|
|
18
|
+
expandIconColumnIndex
|
|
15
19
|
} = props;
|
|
16
20
|
return /*#__PURE__*/React.createElement("span", {
|
|
17
21
|
className: "ui-rc_cell-content"
|
|
18
|
-
},
|
|
22
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
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 => {
|
|
19
56
|
return `${pr.index + 1}.`;
|
|
20
57
|
}), cell.row.index + 1);
|
|
21
58
|
};
|
|
@@ -61,6 +98,13 @@ const renderSelection = args => {
|
|
|
61
98
|
const {
|
|
62
99
|
row
|
|
63
100
|
} = args.cell;
|
|
101
|
+
const {
|
|
102
|
+
cell,
|
|
103
|
+
expandIconColumnIndex,
|
|
104
|
+
isDataTree,
|
|
105
|
+
expanded,
|
|
106
|
+
setExpanded
|
|
107
|
+
} = args;
|
|
64
108
|
const {
|
|
65
109
|
selectionSettings,
|
|
66
110
|
setIsSelectionChange
|
|
@@ -70,7 +114,40 @@ const renderSelection = args => {
|
|
|
70
114
|
|
|
71
115
|
// paddingLeft: `${row.depth * 2}rem`,
|
|
72
116
|
}
|
|
73
|
-
},
|
|
117
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
119
|
+
style: {
|
|
120
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
121
|
+
}
|
|
122
|
+
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
123
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
124
|
+
onClick: () => {
|
|
125
|
+
const keys = Object.keys(expanded);
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
const tmp = {
|
|
128
|
+
...expanded
|
|
129
|
+
};
|
|
130
|
+
if (keys.includes(cell.row.id)) {
|
|
131
|
+
delete tmp[cell.row.id];
|
|
132
|
+
setExpanded(tmp);
|
|
133
|
+
} else {
|
|
134
|
+
setExpanded(old => ({
|
|
135
|
+
...old,
|
|
136
|
+
[cell.row.id]: true
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
style: {
|
|
141
|
+
cursor: "pointer"
|
|
142
|
+
},
|
|
143
|
+
className: "ui-rc-table-row-expand"
|
|
144
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
145
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
146
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
147
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
148
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
149
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
150
|
+
}))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Checkbox, {
|
|
74
151
|
checked: row.getIsSelected() || row.getIsAllSubRowsSelected(),
|
|
75
152
|
indeterminate: row.getIsSomeSelected() && selectionSettings && selectionSettings.mode === 'checkbox' && selectionSettings.type !== 'single'
|
|
76
153
|
// indeterminate={row.getIsSomeSelected() }
|
|
@@ -102,10 +179,15 @@ const TableBodyCell = props => {
|
|
|
102
179
|
selectionSettings,
|
|
103
180
|
id,
|
|
104
181
|
originData,
|
|
105
|
-
wrapSettings
|
|
182
|
+
wrapSettings,
|
|
183
|
+
expanded,
|
|
184
|
+
setExpanded,
|
|
185
|
+
expandable,
|
|
186
|
+
isDataTree
|
|
106
187
|
} = useContext(TableContext);
|
|
107
188
|
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
108
189
|
const parrents = cell.row.getParentRows();
|
|
190
|
+
const expandIconColumnIndex = expandable?.expandIconColumnIndex;
|
|
109
191
|
const isPinned = cell.column.getIsPinned();
|
|
110
192
|
const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
111
193
|
const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
@@ -119,8 +201,8 @@ const TableBodyCell = props => {
|
|
|
119
201
|
[`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
|
|
120
202
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
121
203
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
122
|
-
[`${prefix}-grid-cell-text-center`]: columnMeta?.
|
|
123
|
-
[`${prefix}-grid-cell-text-right`]: columnMeta?.
|
|
204
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
205
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
|
|
124
206
|
}),
|
|
125
207
|
style: {
|
|
126
208
|
display: 'flex',
|
|
@@ -146,7 +228,11 @@ const TableBodyCell = props => {
|
|
|
146
228
|
}
|
|
147
229
|
}, cell.column.id === "#" && renderCellIndex({
|
|
148
230
|
parrents,
|
|
149
|
-
cell
|
|
231
|
+
cell,
|
|
232
|
+
expanded,
|
|
233
|
+
isDataTree,
|
|
234
|
+
setExpanded,
|
|
235
|
+
expandIconColumnIndex
|
|
150
236
|
}), cell.column.id === "command" && renderCommand({
|
|
151
237
|
cell,
|
|
152
238
|
commandClick,
|
|
@@ -156,9 +242,79 @@ const TableBodyCell = props => {
|
|
|
156
242
|
cell,
|
|
157
243
|
table,
|
|
158
244
|
selectionSettings,
|
|
159
|
-
setIsSelectionChange
|
|
245
|
+
setIsSelectionChange,
|
|
246
|
+
expanded,
|
|
247
|
+
isDataTree,
|
|
248
|
+
setExpanded,
|
|
249
|
+
expandIconColumnIndex
|
|
160
250
|
}), !nonActionColumn.includes(cell.column.id) && (isFirstRightPinnedColumn ? /*#__PURE__*/React.createElement("span", {
|
|
161
251
|
className: "ui-rc_cell-content"
|
|
162
|
-
},
|
|
252
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
254
|
+
style: {
|
|
255
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
256
|
+
}
|
|
257
|
+
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
258
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
259
|
+
onClick: () => {
|
|
260
|
+
const keys = Object.keys(expanded);
|
|
261
|
+
// @ts-ignore
|
|
262
|
+
const tmp = {
|
|
263
|
+
...expanded
|
|
264
|
+
};
|
|
265
|
+
if (keys.includes(cell.row.id)) {
|
|
266
|
+
delete tmp[cell.row.id];
|
|
267
|
+
setExpanded(tmp);
|
|
268
|
+
} else {
|
|
269
|
+
setExpanded(old => ({
|
|
270
|
+
...old,
|
|
271
|
+
[cell.row.id]: true
|
|
272
|
+
}));
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
style: {
|
|
276
|
+
cursor: "pointer"
|
|
277
|
+
},
|
|
278
|
+
className: "ui-rc-table-row-expand"
|
|
279
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
280
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
281
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
282
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
283
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
284
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
285
|
+
}))), flexRender(cell.column.columnDef.cell, cell.getContext())) : /*#__PURE__*/React.createElement(React.Fragment, null, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
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()))));
|
|
163
319
|
};
|
|
164
320
|
export default TableBodyCell;
|
|
@@ -127,9 +127,11 @@ const TableBodyCellEdit = props => {
|
|
|
127
127
|
dataErrors,
|
|
128
128
|
expanded,
|
|
129
129
|
setExpanded,
|
|
130
|
-
expandable
|
|
130
|
+
expandable,
|
|
131
|
+
isDataTree,
|
|
132
|
+
handleCellClick
|
|
131
133
|
} = React.useContext(TableContext);
|
|
132
|
-
const expandIconColumnIndex = expandable?.expandIconColumnIndex
|
|
134
|
+
const expandIconColumnIndex = expandable?.expandIconColumnIndex;
|
|
133
135
|
const record = cell.row.original;
|
|
134
136
|
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
135
137
|
const cellContent = columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
@@ -414,6 +416,7 @@ const TableBodyCellEdit = props => {
|
|
|
414
416
|
setEditingKey?.(record[rowKey]);
|
|
415
417
|
// setTooltipContent('')
|
|
416
418
|
|
|
419
|
+
handleCellClick?.(rowNumber, record, columnMeta, record[rowKey], record[columnMeta.field ?? '']);
|
|
417
420
|
reset?.();
|
|
418
421
|
|
|
419
422
|
// const formattedRecord = { ...record };
|
|
@@ -652,8 +655,8 @@ const TableBodyCellEdit = props => {
|
|
|
652
655
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
653
656
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
654
657
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
655
|
-
[`${prefix}-grid-cell-text-center`]: columnMeta?.
|
|
656
|
-
[`${prefix}-grid-cell-text-right`]: columnMeta?.
|
|
658
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
659
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right',
|
|
657
660
|
// [`${prefix}-grid-cell-index-selected`]: rowRange?.includes(cell.row.id),
|
|
658
661
|
[`${prefix}-grid-cell-index-selected`]: selectRowIds?.includes(cell.row.id)
|
|
659
662
|
}),
|
|
@@ -684,7 +687,7 @@ const TableBodyCellEdit = props => {
|
|
|
684
687
|
// reset?.()
|
|
685
688
|
}
|
|
686
689
|
}
|
|
687
|
-
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/React.createElement("div", {
|
|
690
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
688
691
|
className: "ui-rc-table-row-expand-trigger",
|
|
689
692
|
style: {
|
|
690
693
|
paddingLeft: `${cell.row.depth * 25}px`
|
|
@@ -729,8 +732,8 @@ const TableBodyCellEdit = props => {
|
|
|
729
732
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
730
733
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
731
734
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
732
|
-
[`${prefix}-grid-cell-text-center`]: columnMeta?.
|
|
733
|
-
[`${prefix}-grid-cell-text-right`]: columnMeta?.
|
|
735
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
736
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
|
|
734
737
|
}),
|
|
735
738
|
style: {
|
|
736
739
|
display: 'flex',
|
|
@@ -754,8 +757,8 @@ const TableBodyCellEdit = props => {
|
|
|
754
757
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
755
758
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
756
759
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
757
|
-
[`${prefix}-grid-cell-text-center`]: columnMeta?.
|
|
758
|
-
[`${prefix}-grid-cell-text-right`]: columnMeta?.
|
|
760
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
761
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
|
|
759
762
|
}),
|
|
760
763
|
style: {
|
|
761
764
|
display: 'flex',
|
|
@@ -765,7 +768,7 @@ const TableBodyCellEdit = props => {
|
|
|
765
768
|
// maxWidth: cell.column.getSize(),
|
|
766
769
|
...getCommonPinningStyles(cell.column)
|
|
767
770
|
}
|
|
768
|
-
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/React.createElement("div", {
|
|
771
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
769
772
|
className: "ui-rc-table-row-expand-trigger",
|
|
770
773
|
style: {
|
|
771
774
|
paddingLeft: `${cell.row.depth * 25}px`
|
|
@@ -856,8 +859,8 @@ const TableBodyCellEdit = props => {
|
|
|
856
859
|
'cell-paste-border-left': isInRangePaste && isLeftPaste,
|
|
857
860
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
858
861
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
859
|
-
[`${prefix}-grid-cell-text-center`]: columnMeta?.
|
|
860
|
-
[`${prefix}-grid-cell-text-right`]: columnMeta?.
|
|
862
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
863
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
|
|
861
864
|
}),
|
|
862
865
|
style: {
|
|
863
866
|
display: 'flex',
|
|
@@ -874,6 +877,9 @@ const TableBodyCellEdit = props => {
|
|
|
874
877
|
rowId: cell.row.id,
|
|
875
878
|
colId: cell.column.id
|
|
876
879
|
});
|
|
880
|
+
if (canEdit) {
|
|
881
|
+
handleCellClick?.(rowNumber, record, columnMeta, record[rowKey], record[columnMeta.field ?? '']);
|
|
882
|
+
}
|
|
877
883
|
} else {
|
|
878
884
|
handleMouseDown(cell.row.id, cell.column.id);
|
|
879
885
|
if (editingKey) {
|
|
@@ -991,7 +997,7 @@ const TableBodyCellEdit = props => {
|
|
|
991
997
|
className: classNames('ui-rc_cell-content', {
|
|
992
998
|
'select-cell': ['select', 'selectTable', 'asyncSelect'].includes(getEditType(columnMeta, record))
|
|
993
999
|
})
|
|
994
|
-
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/React.createElement("div", {
|
|
1000
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
995
1001
|
className: "ui-rc-table-row-expand-trigger",
|
|
996
1002
|
style: {
|
|
997
1003
|
paddingLeft: `${cell.row.depth * 25}px`
|
|
@@ -27,15 +27,7 @@ const TableBodyRow = ({
|
|
|
27
27
|
recordDoubleClick
|
|
28
28
|
} = React.useContext(TableContext);
|
|
29
29
|
const visibleCells = row.getVisibleCells();
|
|
30
|
-
|
|
31
|
-
// console.log('visibleCells', visibleCells)
|
|
32
|
-
|
|
33
30
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
34
|
-
|
|
35
|
-
// console.log('virtualColumns', virtualColumns)
|
|
36
|
-
|
|
37
|
-
// table.options.set
|
|
38
|
-
|
|
39
31
|
return /*#__PURE__*/React.createElement("tr", {
|
|
40
32
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
41
33
|
,
|
|
@@ -41,7 +41,7 @@ const TableHeadCell = props => {
|
|
|
41
41
|
locale
|
|
42
42
|
} = useContext(TableContext);
|
|
43
43
|
const isPinned = header.column.getIsPinned();
|
|
44
|
-
|
|
44
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && header.column.getIsLastColumn('left');
|
|
45
45
|
const isFirstRightPinnedColumn = isPinned === 'right' && header.column.getIsFirstColumn('right');
|
|
46
46
|
const [selectedKeys, setSelectedKeys] = React.useState([]);
|
|
47
47
|
const [visible, setVisible] = React.useState(false);
|
|
@@ -212,7 +212,7 @@ const TableHeadCell = props => {
|
|
|
212
212
|
className: classNames(`${prefix}-grid-cell`, {
|
|
213
213
|
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
214
214
|
[`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
|
|
215
|
-
|
|
215
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
216
216
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
217
217
|
[`${prefix}-grid-cell-text-center`]: originalColumn?.headerTextAlign === 'center',
|
|
218
218
|
[`${prefix}-grid-cell-text-right`]: originalColumn?.headerTextAlign === 'right'
|
|
@@ -40,7 +40,7 @@ export declare function groupArrayByColumns(arr: any[], columns: string[] | unde
|
|
|
40
40
|
export declare const flatColumns2: <RecordType>(columns: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
|
|
41
41
|
export declare const checkThousandSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
|
|
42
42
|
export declare const checkDecimalSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
|
|
43
|
-
export declare
|
|
43
|
+
export declare const getFixedFields: <T>(columns: ColumnsTable<T>, type: 'left' | 'right') => string[];
|
|
44
44
|
export declare function areStringArraysEqual(a: string[], b: string[]): boolean;
|
|
45
45
|
export declare const getDefaultOperator: (col: ColumnTable) => FilterOperator;
|
|
46
46
|
export declare function isEqualSet(setA: any, setB: any): boolean;
|
|
@@ -131,3 +131,4 @@ export declare const convertToObj: (arr: any) => {
|
|
|
131
131
|
[k: string]: any;
|
|
132
132
|
};
|
|
133
133
|
export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
|
|
134
|
+
export declare function isTree(arr: any[]): boolean;
|
|
@@ -305,11 +305,11 @@ export const checkDecimalSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
305
305
|
return '.';
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
|
-
export
|
|
308
|
+
export const getFixedFields = (columns, type) => {
|
|
309
309
|
const result = [];
|
|
310
310
|
function traverse(cols) {
|
|
311
311
|
for (const col of cols) {
|
|
312
|
-
if ((col.fixed ?? col.fixedType) === type && col.field && (col.visible !== false || col.hidden
|
|
312
|
+
if ((col.fixed ?? col.fixedType) === type && col.field && (col.visible !== false || col.hidden)) {
|
|
313
313
|
result.push(col.field);
|
|
314
314
|
}
|
|
315
315
|
if (col.children && col.children.length > 0) {
|
|
@@ -319,7 +319,7 @@ export function getFixedFields(columns, type) {
|
|
|
319
319
|
}
|
|
320
320
|
traverse(columns);
|
|
321
321
|
return result;
|
|
322
|
-
}
|
|
322
|
+
};
|
|
323
323
|
export function areStringArraysEqual(a, b) {
|
|
324
324
|
if (a.length !== b.length) return false;
|
|
325
325
|
const sortedA = [...a].sort();
|
|
@@ -1865,4 +1865,22 @@ export const convertToObj = arr => {
|
|
|
1865
1865
|
};
|
|
1866
1866
|
export const getDiffent2Array = (a, b) => {
|
|
1867
1867
|
return [...a.filter(x => !b.includes(x)), ...b.filter(x => !a.includes(x))];
|
|
1868
|
-
};
|
|
1868
|
+
};
|
|
1869
|
+
export function isTree(arr) {
|
|
1870
|
+
if (!Array.isArray(arr)) return false;
|
|
1871
|
+
function checkNode(node) {
|
|
1872
|
+
if (typeof node !== "object" || node === null) return false;
|
|
1873
|
+
if ("children" in node) {
|
|
1874
|
+
if (!Array.isArray(node.children)) return false;
|
|
1875
|
+
if (node.children.length === 0) return false;
|
|
1876
|
+
for (const child of node.children) {
|
|
1877
|
+
if (!checkNode(child)) return false;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
return true;
|
|
1881
|
+
}
|
|
1882
|
+
for (const item of arr) {
|
|
1883
|
+
if (!checkNode(item)) return false;
|
|
1884
|
+
}
|
|
1885
|
+
return true;
|
|
1886
|
+
}
|