@itwin/itwinui-react 3.15.4 → 3.15.5
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/CHANGELOG.md +7 -0
- package/DEV-cjs/core/Table/Table.js +61 -43
- package/DEV-cjs/styles.js +1 -1
- package/DEV-esm/core/Table/Table.js +61 -43
- package/DEV-esm/styles.js +1 -1
- package/cjs/core/NonIdealState/NonIdealState.d.ts +15 -11
- package/cjs/core/Table/Table.js +61 -43
- package/cjs/styles.js +1 -1
- package/esm/core/NonIdealState/NonIdealState.d.ts +15 -11
- package/esm/core/Table/Table.js +61 -43
- package/esm/styles.js +1 -1
- package/package.json +1 -1
- package/styles.css +8 -8
package/esm/core/Table/Table.js
CHANGED
|
@@ -53,6 +53,7 @@ let singleRowSelectedAction = 'singleRowSelected';
|
|
|
53
53
|
let shiftRowSelectedAction = 'shiftRowSelected';
|
|
54
54
|
export const tableResizeStartAction = 'tableResizeStart';
|
|
55
55
|
let tableResizeEndAction = 'tableResizeEnd';
|
|
56
|
+
let iuiId = Symbol('iui-id');
|
|
56
57
|
let flattenColumns = (columns) => {
|
|
57
58
|
let flatColumns = [];
|
|
58
59
|
columns.forEach((column) => {
|
|
@@ -105,6 +106,7 @@ export const Table = (props) => {
|
|
|
105
106
|
headerProps,
|
|
106
107
|
bodyProps,
|
|
107
108
|
emptyTableContentProps,
|
|
109
|
+
getRowId,
|
|
108
110
|
...rest
|
|
109
111
|
} = props;
|
|
110
112
|
useGlobals();
|
|
@@ -240,16 +242,30 @@ export const Table = (props) => {
|
|
|
240
242
|
),
|
|
241
243
|
[data, getSubRows],
|
|
242
244
|
);
|
|
243
|
-
let [rowHasParent] = React.useState(() => new WeakSet());
|
|
244
245
|
let getSubRowsWithSubComponents = React.useCallback(
|
|
245
|
-
(originalRow) => {
|
|
246
|
-
if (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
246
|
+
(originalRow, relativeIndex) => {
|
|
247
|
+
if (originalRow[iuiId]) return [];
|
|
248
|
+
if (originalRow.subRows) return originalRow.subRows;
|
|
249
|
+
return [
|
|
250
|
+
{
|
|
251
|
+
[iuiId]: `subcomponent-${relativeIndex}`,
|
|
252
|
+
...originalRow,
|
|
253
|
+
},
|
|
254
|
+
];
|
|
255
|
+
},
|
|
256
|
+
[],
|
|
257
|
+
);
|
|
258
|
+
let getRowIdWithSubComponents = React.useCallback(
|
|
259
|
+
(originalRow, relativeIndex, parent) => {
|
|
260
|
+
let defaultRowId = parent
|
|
261
|
+
? `${parent.id}.${relativeIndex}`
|
|
262
|
+
: `${relativeIndex}`;
|
|
263
|
+
let rowIdFromUser = getRowId?.(originalRow, relativeIndex, parent);
|
|
264
|
+
if (void 0 !== rowIdFromUser && originalRow[iuiId])
|
|
265
|
+
return `${rowIdFromUser}-${defaultRowId}`;
|
|
266
|
+
return rowIdFromUser ?? defaultRowId;
|
|
251
267
|
},
|
|
252
|
-
[
|
|
268
|
+
[getRowId],
|
|
253
269
|
);
|
|
254
270
|
let instance = useTable(
|
|
255
271
|
{
|
|
@@ -269,6 +285,7 @@ export const Table = (props) => {
|
|
|
269
285
|
...props.initialState,
|
|
270
286
|
},
|
|
271
287
|
columnResizeMode,
|
|
288
|
+
getRowId: subComponent ? getRowIdWithSubComponents : getRowId,
|
|
272
289
|
},
|
|
273
290
|
useFlexLayout,
|
|
274
291
|
useResizeColumns(ownerDocument),
|
|
@@ -461,51 +478,52 @@ export const Table = (props) => {
|
|
|
461
478
|
(index, virtualItem, virtualizer) => {
|
|
462
479
|
let row = page[index];
|
|
463
480
|
prepareRow(row);
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
481
|
+
let isRowASubComponent = !!row.original[iuiId] && !!subComponent;
|
|
482
|
+
if (isRowASubComponent)
|
|
483
|
+
return React.createElement(
|
|
484
|
+
TableExpandableContentMemoized,
|
|
485
|
+
{
|
|
486
|
+
key: row.getRowProps().key,
|
|
487
|
+
virtualItem: virtualItem,
|
|
488
|
+
ref: enableVirtualization
|
|
489
|
+
? virtualizer?.measureElement
|
|
490
|
+
: tableRowRef(row),
|
|
491
|
+
isDisabled: !!isRowDisabled?.(row.original),
|
|
492
|
+
},
|
|
493
|
+
subComponent(row),
|
|
494
|
+
);
|
|
495
|
+
return React.createElement(TableRowMemoized, {
|
|
496
|
+
row: row,
|
|
497
|
+
rowProps: rowProps,
|
|
498
|
+
isLast: index === page.length - 1,
|
|
499
|
+
onRowInViewport: onRowInViewportRef,
|
|
500
|
+
onBottomReached: onBottomReachedRef,
|
|
501
|
+
intersectionMargin: intersectionMargin,
|
|
502
|
+
state: state,
|
|
503
|
+
key: row.getRowProps().key,
|
|
504
|
+
onClick: onRowClickHandler,
|
|
505
|
+
subComponent: subComponent,
|
|
506
|
+
isDisabled: !!isRowDisabled?.(row.original),
|
|
507
|
+
tableHasSubRows: hasAnySubRows,
|
|
508
|
+
tableInstance: instance,
|
|
509
|
+
expanderCell: expanderCell,
|
|
510
|
+
scrollContainerRef: tableRef.current,
|
|
511
|
+
tableRowRef: enableVirtualization ? void 0 : tableRowRef(row),
|
|
512
|
+
density: density,
|
|
513
|
+
virtualItem: virtualItem,
|
|
514
|
+
virtualizer: virtualizer,
|
|
515
|
+
});
|
|
498
516
|
},
|
|
499
517
|
[
|
|
500
518
|
page,
|
|
501
519
|
prepareRow,
|
|
520
|
+
subComponent,
|
|
502
521
|
rowProps,
|
|
503
522
|
onRowInViewportRef,
|
|
504
523
|
onBottomReachedRef,
|
|
505
524
|
intersectionMargin,
|
|
506
525
|
state,
|
|
507
526
|
onRowClickHandler,
|
|
508
|
-
subComponent,
|
|
509
527
|
isRowDisabled,
|
|
510
528
|
hasAnySubRows,
|
|
511
529
|
instance,
|
package/esm/styles.js
CHANGED