@itwin/itwinui-react 3.6.2 → 3.7.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/CHANGELOG.md +18 -1
- package/cjs/core/Alert/Alert.js +3 -1
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -1
- package/cjs/core/Footer/Footer.js +2 -1
- package/cjs/core/Table/SubRowExpander.d.ts +1 -0
- package/cjs/core/Table/SubRowExpander.js +2 -2
- package/cjs/core/Table/Table.js +37 -45
- package/cjs/core/Table/TableCell.js +3 -3
- package/cjs/core/Table/TableRowMemoized.d.ts +2 -2
- package/cjs/core/Table/TableRowMemoized.js +7 -6
- package/cjs/core/Table/cells/DefaultCell.d.ts +6 -0
- package/cjs/core/Table/cells/DefaultCell.js +9 -5
- package/cjs/core/Table/filters/FilterToggle.js +1 -1
- package/cjs/core/Toast/Toast.js +1 -1
- package/esm/core/Alert/Alert.js +4 -2
- package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -1
- package/esm/core/Footer/Footer.js +2 -1
- package/esm/core/Table/SubRowExpander.d.ts +1 -0
- package/esm/core/Table/SubRowExpander.js +2 -2
- package/esm/core/Table/Table.js +38 -46
- package/esm/core/Table/TableCell.js +3 -3
- package/esm/core/Table/TableRowMemoized.d.ts +2 -2
- package/esm/core/Table/TableRowMemoized.js +7 -6
- package/esm/core/Table/cells/DefaultCell.d.ts +6 -0
- package/esm/core/Table/cells/DefaultCell.js +10 -6
- package/esm/core/Table/filters/FilterToggle.js +1 -1
- package/esm/core/Toast/Toast.js +1 -1
- package/package.json +1 -1
- package/styles.css +14 -35
package/esm/core/Table/Table.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as React from 'react';
|
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
import { actions as TableActions, useFlexLayout, useFilters, useRowSelect, useSortBy, useTable, useExpanded, usePagination, useColumnOrder, useGlobalFilter, } from 'react-table';
|
|
8
8
|
import { ProgressRadial } from '../ProgressIndicators/ProgressRadial.js';
|
|
9
|
-
import { useGlobals, useResizeObserver, SvgSortDown, SvgSortUp, useLayoutEffect, Box, createWarningLogger, ShadowRoot, } from '../utils/index.js';
|
|
9
|
+
import { useGlobals, useResizeObserver, SvgSortDown, SvgSortUp, useLayoutEffect, Box, createWarningLogger, ShadowRoot, LineClamp, useMergedRefs, } from '../utils/index.js';
|
|
10
10
|
import { getCellStyle, getStickyStyle, getSubRowStyle } from './utils.js';
|
|
11
11
|
import { TableRowMemoized } from './TableRowMemoized.js';
|
|
12
12
|
import { FilterToggle } from './filters/index.js';
|
|
@@ -19,6 +19,10 @@ const singleRowSelectedAction = 'singleRowSelected';
|
|
|
19
19
|
const shiftRowSelectedAction = 'shiftRowSelected';
|
|
20
20
|
export const tableResizeStartAction = 'tableResizeStart';
|
|
21
21
|
const tableResizeEndAction = 'tableResizeEnd';
|
|
22
|
+
const COLUMN_MIN_WIDTHS = {
|
|
23
|
+
default: 72,
|
|
24
|
+
withExpander: 108, // expander column should be wider to accommodate the expander icon
|
|
25
|
+
};
|
|
22
26
|
const logWarningInDev = createWarningLogger();
|
|
23
27
|
const flattenColumns = (columns) => {
|
|
24
28
|
const flatColumns = [];
|
|
@@ -287,15 +291,11 @@ export const Table = (props) => {
|
|
|
287
291
|
instance.selectedFlatRows,
|
|
288
292
|
selectionMode,
|
|
289
293
|
]);
|
|
290
|
-
const
|
|
291
|
-
const bodyRef = React.useRef(null);
|
|
294
|
+
const tableRef = React.useRef(null);
|
|
292
295
|
const { scrollToIndex, tableRowRef } = useScrollToRow({ ...props, page });
|
|
293
296
|
const columnRefs = React.useRef({});
|
|
294
297
|
const previousTableWidth = React.useRef(0);
|
|
295
298
|
const onTableResize = React.useCallback(({ width }) => {
|
|
296
|
-
// Handle header properties, regardless of whether the table is resizable
|
|
297
|
-
setHeaderScrollWidth(headerRef.current?.scrollWidth ?? 0);
|
|
298
|
-
setHeaderClientWidth(headerRef.current?.clientWidth ?? 0);
|
|
299
299
|
// Handle table properties, but only when table is resizable
|
|
300
300
|
if (!isResizable) {
|
|
301
301
|
return;
|
|
@@ -325,8 +325,6 @@ export const Table = (props) => {
|
|
|
325
325
|
isResizable,
|
|
326
326
|
]);
|
|
327
327
|
const [resizeRef] = useResizeObserver(onTableResize);
|
|
328
|
-
const [headerScrollWidth, setHeaderScrollWidth] = React.useState(0);
|
|
329
|
-
const [headerClientWidth, setHeaderClientWidth] = React.useState(0);
|
|
330
328
|
// Flexbox handles columns resize so we take new column widths before browser repaints.
|
|
331
329
|
useLayoutEffect(() => {
|
|
332
330
|
if (state.isTableResizing) {
|
|
@@ -343,7 +341,7 @@ export const Table = (props) => {
|
|
|
343
341
|
const getPreparedRow = React.useCallback((index) => {
|
|
344
342
|
const row = page[index];
|
|
345
343
|
prepareRow(row);
|
|
346
|
-
return (React.createElement(TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!isRowDisabled?.(row.original), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell,
|
|
344
|
+
return (React.createElement(TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!isRowDisabled?.(row.original), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, scrollContainerRef: tableRef.current, tableRowRef: enableVirtualization ? undefined : tableRowRef(row), density: density }));
|
|
347
345
|
}, [
|
|
348
346
|
page,
|
|
349
347
|
prepareRow,
|
|
@@ -362,18 +360,18 @@ export const Table = (props) => {
|
|
|
362
360
|
]);
|
|
363
361
|
const virtualizedItemRenderer = React.useCallback((index) => getPreparedRow(index), [getPreparedRow]);
|
|
364
362
|
const updateStickyState = () => {
|
|
365
|
-
if (!
|
|
363
|
+
if (!tableRef.current || flatHeaders.every((header) => !header.sticky)) {
|
|
366
364
|
return;
|
|
367
365
|
}
|
|
368
|
-
if (
|
|
366
|
+
if (tableRef.current.scrollLeft !== 0) {
|
|
369
367
|
dispatch({ type: TableActions.setScrolledRight, value: true });
|
|
370
368
|
}
|
|
371
369
|
else {
|
|
372
370
|
dispatch({ type: TableActions.setScrolledRight, value: false });
|
|
373
371
|
}
|
|
374
372
|
// If scrolled a bit to the left looking from the right side
|
|
375
|
-
if (
|
|
376
|
-
|
|
373
|
+
if (tableRef.current.scrollLeft !==
|
|
374
|
+
tableRef.current.scrollWidth - tableRef.current.clientWidth) {
|
|
377
375
|
dispatch({ type: TableActions.setScrolledLeft, value: true });
|
|
378
376
|
}
|
|
379
377
|
else {
|
|
@@ -387,16 +385,16 @@ export const Table = (props) => {
|
|
|
387
385
|
}, []);
|
|
388
386
|
const isHeaderDirectClick = React.useRef(false);
|
|
389
387
|
return (React.createElement(React.Fragment, null,
|
|
390
|
-
React.createElement(Box, { ref: (element) => {
|
|
388
|
+
React.createElement(Box, { ref: useMergedRefs(tableRef, (element) => {
|
|
391
389
|
ownerDocument.current = element?.ownerDocument;
|
|
392
390
|
resizeRef(element);
|
|
393
|
-
}, id: id, ...getTableProps({
|
|
391
|
+
}), id: id, ...getTableProps({
|
|
394
392
|
className: cx('iui-table', className),
|
|
395
393
|
style: {
|
|
396
394
|
minWidth: 0,
|
|
397
395
|
...style,
|
|
398
396
|
},
|
|
399
|
-
}), "data-iui-size": density === 'default' ? undefined : density, ...ariaDataAttributes },
|
|
397
|
+
}), onScroll: () => updateStickyState(), "data-iui-size": density === 'default' ? undefined : density, ...ariaDataAttributes },
|
|
400
398
|
headerGroups.map((headerGroup) => {
|
|
401
399
|
// There may be a better solution for this, but for now I'm filtering out the placeholder cells using header.id
|
|
402
400
|
headerGroup.headers = headerGroup.headers.filter((header) => !header.id.includes('iui-table-checkbox-selector_placeholder') &&
|
|
@@ -404,18 +402,19 @@ export const Table = (props) => {
|
|
|
404
402
|
const headerGroupProps = headerGroup.getHeaderGroupProps({
|
|
405
403
|
className: 'iui-table-row',
|
|
406
404
|
});
|
|
407
|
-
return (React.createElement(Box, { as: 'div',
|
|
408
|
-
if (headerRef.current && bodyRef.current) {
|
|
409
|
-
bodyRef.current.scrollLeft = headerRef.current.scrollLeft;
|
|
410
|
-
updateStickyState();
|
|
411
|
-
}
|
|
412
|
-
}, key: headerGroupProps.key, ...headerWrapperProps, className: cx('iui-table-header-wrapper', headerWrapperProps?.className) },
|
|
405
|
+
return (React.createElement(Box, { as: 'div', key: headerGroupProps.key, ...headerWrapperProps, className: cx('iui-table-header-wrapper', headerWrapperProps?.className) },
|
|
413
406
|
React.createElement(Box, { as: 'div', ...headerProps, className: cx('iui-table-header', headerProps?.className) },
|
|
414
407
|
React.createElement(Box, { ...headerGroupProps }, headerGroup.headers.map((column, index) => {
|
|
415
408
|
const { onClick, ...restSortProps } = column.getSortByToggleProps();
|
|
416
409
|
const columnHasExpanders = hasAnySubRows &&
|
|
417
410
|
index ===
|
|
418
411
|
headerGroup.headers.findIndex((c) => c.id !== SELECTION_CELL_ID);
|
|
412
|
+
// override "undefined" or zero min-width with default value
|
|
413
|
+
if ([undefined, 0].includes(column.minWidth)) {
|
|
414
|
+
column.minWidth = columnHasExpanders
|
|
415
|
+
? COLUMN_MIN_WIDTHS.withExpander
|
|
416
|
+
: COLUMN_MIN_WIDTHS.default;
|
|
417
|
+
}
|
|
419
418
|
const columnProps = column.getHeaderProps({
|
|
420
419
|
...restSortProps,
|
|
421
420
|
className: cx('iui-table-cell', {
|
|
@@ -427,7 +426,8 @@ export const Table = (props) => {
|
|
|
427
426
|
...getCellStyle(column, !!state.isTableResizing),
|
|
428
427
|
...(columnHasExpanders && getSubRowStyle({ density })),
|
|
429
428
|
...getStickyStyle(column, visibleColumns),
|
|
430
|
-
flexWrap: '
|
|
429
|
+
flexWrap: 'wrap',
|
|
430
|
+
columnGap: 'var(--iui-size-xs)',
|
|
431
431
|
},
|
|
432
432
|
});
|
|
433
433
|
return (React.createElement(Box, { ...columnProps, ...column.getDragAndDropProps(), key: columnProps.key, title: undefined, ref: (el) => {
|
|
@@ -449,55 +449,47 @@ export const Table = (props) => {
|
|
|
449
449
|
column.toggleSortBy();
|
|
450
450
|
}
|
|
451
451
|
} },
|
|
452
|
+
React.createElement(ShadowRoot, null,
|
|
453
|
+
typeof column.Header === 'string' ? (React.createElement(LineClamp, null,
|
|
454
|
+
React.createElement("slot", null))) : (React.createElement("slot", null)),
|
|
455
|
+
React.createElement("slot", { name: 'actions' }),
|
|
456
|
+
React.createElement("slot", { name: 'resizers' }),
|
|
457
|
+
React.createElement("slot", { name: 'shadows' })),
|
|
452
458
|
column.render('Header'),
|
|
453
459
|
(showFilterButton(column) ||
|
|
454
|
-
showSortButton(column)) && (React.createElement(Box, { className: 'iui-table-header-actions-container', onKeyDown: (e) => e.stopPropagation() },
|
|
460
|
+
showSortButton(column)) && (React.createElement(Box, { className: 'iui-table-header-actions-container', onKeyDown: (e) => e.stopPropagation(), slot: 'actions' },
|
|
455
461
|
showFilterButton(column) && (React.createElement(FilterToggle, { column: column })),
|
|
456
462
|
showSortButton(column) && (React.createElement(Box, { className: 'iui-table-cell-end-icon' }, column.isSortedDesc ||
|
|
457
463
|
(!column.isSorted && column.sortDescFirst) ? (React.createElement(SvgSortDown, { className: 'iui-table-sort', "aria-hidden": true })) : (React.createElement(SvgSortUp, { className: 'iui-table-sort', "aria-hidden": true })))))),
|
|
458
464
|
isResizable &&
|
|
459
465
|
column.isResizerVisible &&
|
|
460
466
|
(index !== headerGroup.headers.length - 1 ||
|
|
461
|
-
columnResizeMode === 'expand') && (React.createElement(Box, { ...column.getResizerProps(), className: 'iui-table-resizer' },
|
|
467
|
+
columnResizeMode === 'expand') && (React.createElement(Box, { ...column.getResizerProps(), className: 'iui-table-resizer', slot: 'resizers' },
|
|
462
468
|
React.createElement(Box, { className: 'iui-table-resizer-bar' }))),
|
|
463
469
|
enableColumnReordering &&
|
|
464
|
-
!column.disableReordering && (React.createElement(Box, { className: 'iui-table-reorder-bar' })),
|
|
470
|
+
!column.disableReordering && (React.createElement(Box, { className: 'iui-table-reorder-bar', slot: 'resizers' })),
|
|
465
471
|
column.sticky === 'left' &&
|
|
466
|
-
state.sticky.isScrolledToRight && (React.createElement(Box, { className: 'iui-table-cell-shadow-right' })),
|
|
472
|
+
state.sticky.isScrolledToRight && (React.createElement(Box, { className: 'iui-table-cell-shadow-right', slot: 'shadows' })),
|
|
467
473
|
column.sticky === 'right' &&
|
|
468
|
-
state.sticky.isScrolledToLeft && (React.createElement(Box, { className: 'iui-table-cell-shadow-left' }))));
|
|
474
|
+
state.sticky.isScrolledToLeft && (React.createElement(Box, { className: 'iui-table-cell-shadow-left', slot: 'shadows' }))));
|
|
469
475
|
})))));
|
|
470
476
|
}),
|
|
471
|
-
React.createElement(Box, { ...bodyProps, ...getTableBodyProps({
|
|
477
|
+
React.createElement(Box, { as: 'div', ...bodyProps, ...getTableBodyProps({
|
|
472
478
|
className: cx('iui-table-body', {
|
|
473
479
|
'iui-zebra-striping': styleType === 'zebra-rows',
|
|
474
480
|
}, bodyProps?.className),
|
|
475
481
|
style: { outline: 0 },
|
|
476
|
-
}),
|
|
477
|
-
if (headerRef.current && bodyRef.current) {
|
|
478
|
-
headerRef.current.scrollLeft = bodyRef.current.scrollLeft;
|
|
479
|
-
updateStickyState();
|
|
480
|
-
}
|
|
481
|
-
}, tabIndex: -1, "aria-multiselectable": (isSelectable && selectionMode === 'multi') || undefined },
|
|
482
|
-
React.createElement(ShadowRoot, null,
|
|
483
|
-
React.createElement("slot", null),
|
|
484
|
-
rows.length === 0 && headerScrollWidth > headerClientWidth && (React.createElement("div", { "aria-hidden": true, style: {
|
|
485
|
-
// This ensures that the table-body is always the same width as the table-header,
|
|
486
|
-
// even if the table has no rows. See https://github.com/iTwin/iTwinUI/pull/1725
|
|
487
|
-
width: headerScrollWidth,
|
|
488
|
-
height: 0.1,
|
|
489
|
-
} }))),
|
|
482
|
+
}), tabIndex: -1, "aria-multiselectable": (isSelectable && selectionMode === 'multi') || undefined },
|
|
490
483
|
data.length !== 0 && (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualScroll, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer, scrollToIndex: scrollToIndex })) : (page.map((_, index) => getPreparedRow(index))))),
|
|
491
484
|
isLoading && data.length === 0 && (React.createElement(Box, { as: 'div', ...emptyTableContentProps, className: cx('iui-table-empty', emptyTableContentProps?.className) },
|
|
492
485
|
React.createElement(ProgressRadial, { indeterminate: true }))),
|
|
493
|
-
isLoading && data.length !== 0 && (React.createElement(Box, { className: 'iui-table-row', "data-iui-loading": 'true' },
|
|
494
|
-
React.createElement(Box, { className: 'iui-table-cell' },
|
|
495
|
-
React.createElement(ProgressRadial, { indeterminate: true, size: 'small' })))),
|
|
496
486
|
!isLoading && data.length === 0 && !areFiltersSet && (React.createElement(Box, { as: 'div', ...emptyTableContentProps, className: cx('iui-table-empty', emptyTableContentProps?.className) },
|
|
497
487
|
React.createElement("div", null, emptyTableContent))),
|
|
498
488
|
!isLoading &&
|
|
499
489
|
(data.length === 0 || rows.length === 0) &&
|
|
500
490
|
areFiltersSet && (React.createElement(Box, { as: 'div', ...emptyTableContentProps, className: cx('iui-table-empty', emptyTableContentProps?.className) },
|
|
501
491
|
React.createElement("div", null, emptyFilteredTableContent)))),
|
|
492
|
+
isLoading && data.length !== 0 && (React.createElement(Box, { className: 'iui-table-body-extra', "data-iui-loading": 'true' },
|
|
493
|
+
React.createElement(ProgressRadial, { indeterminate: true, size: 'small' }))),
|
|
502
494
|
paginatorRenderer?.(paginatorRendererProps))));
|
|
503
495
|
};
|
|
@@ -34,7 +34,7 @@ export const TableCell = (props) => {
|
|
|
34
34
|
...{ cell, row: cell.row, value: cell.value, column: cell.column },
|
|
35
35
|
};
|
|
36
36
|
const cellContent = (React.createElement(React.Fragment, null,
|
|
37
|
-
tableHasSubRows && hasSubRowExpander && cell.row.canExpand && (React.createElement(SubRowExpander, { cell: cell, isDisabled: isDisabled, cellProps: cellProps, expanderCell: expanderCell, density: density })),
|
|
37
|
+
tableHasSubRows && hasSubRowExpander && cell.row.canExpand && (React.createElement(SubRowExpander, { cell: cell, isDisabled: isDisabled, cellProps: cellProps, expanderCell: expanderCell, density: density, slot: 'start' })),
|
|
38
38
|
cell.render('Cell')));
|
|
39
39
|
const cellRendererProps = {
|
|
40
40
|
cellElementProps,
|
|
@@ -42,9 +42,9 @@ export const TableCell = (props) => {
|
|
|
42
42
|
children: (React.createElement(React.Fragment, null,
|
|
43
43
|
cellContent,
|
|
44
44
|
cell.column.sticky === 'left' &&
|
|
45
|
-
tableInstance.state.sticky.isScrolledToRight && (React.createElement(Box, { className: 'iui-table-cell-shadow-right' })),
|
|
45
|
+
tableInstance.state.sticky.isScrolledToRight && (React.createElement(Box, { className: 'iui-table-cell-shadow-right', slot: 'shadows' })),
|
|
46
46
|
cell.column.sticky === 'right' &&
|
|
47
|
-
tableInstance.state.sticky.isScrolledToLeft && (React.createElement(Box, { className: 'iui-table-cell-shadow-left' })))),
|
|
47
|
+
tableInstance.state.sticky.isScrolledToLeft && (React.createElement(Box, { className: 'iui-table-cell-shadow-left', slot: 'shadows' })))),
|
|
48
48
|
};
|
|
49
49
|
return (React.createElement(React.Fragment, null, cell.column.cellRenderer ? (cell.column.cellRenderer({
|
|
50
50
|
...cellRendererProps,
|
|
@@ -23,7 +23,7 @@ export declare const TableRow: <T extends Record<string, unknown>>(props: {
|
|
|
23
23
|
tableHasSubRows: boolean;
|
|
24
24
|
tableInstance: TableInstance<T>;
|
|
25
25
|
expanderCell?: ((cellProps: CellProps<T>) => React.ReactNode) | undefined;
|
|
26
|
-
|
|
26
|
+
scrollContainerRef: HTMLDivElement | null;
|
|
27
27
|
tableRowRef?: React.Ref<HTMLDivElement> | undefined;
|
|
28
28
|
density?: "default" | "condensed" | "extra-condensed" | undefined;
|
|
29
29
|
}) => React.JSX.Element;
|
|
@@ -44,7 +44,7 @@ export declare const TableRowMemoized: <T extends Record<string, unknown>>(props
|
|
|
44
44
|
tableHasSubRows: boolean;
|
|
45
45
|
tableInstance: TableInstance<T>;
|
|
46
46
|
expanderCell?: ((cellProps: CellProps<T>) => React.ReactNode) | undefined;
|
|
47
|
-
|
|
47
|
+
scrollContainerRef: HTMLDivElement | null;
|
|
48
48
|
tableRowRef?: React.Ref<HTMLDivElement> | undefined;
|
|
49
49
|
density?: "default" | "condensed" | "extra-condensed" | undefined;
|
|
50
50
|
}) => React.JSX.Element;
|
|
@@ -13,20 +13,21 @@ import { TableCell } from './TableCell.js';
|
|
|
13
13
|
* When adding new features check whether it changes state that affects row. If it does then add equality check to `React.memo`.
|
|
14
14
|
*/
|
|
15
15
|
export const TableRow = (props) => {
|
|
16
|
-
const { row, rowProps, isLast, onRowInViewport, onBottomReached, intersectionMargin, onClick, subComponent, isDisabled, tableHasSubRows, tableInstance, expanderCell,
|
|
16
|
+
const { row, rowProps, isLast, onRowInViewport, onBottomReached, intersectionMargin, onClick, subComponent, isDisabled, tableHasSubRows, tableInstance, expanderCell, scrollContainerRef, tableRowRef, density, } = props;
|
|
17
17
|
const onIntersect = React.useCallback(() => {
|
|
18
18
|
onRowInViewport.current?.(row.original);
|
|
19
19
|
isLast && onBottomReached.current?.();
|
|
20
20
|
}, [isLast, onBottomReached, onRowInViewport, row.original]);
|
|
21
21
|
const intersectionRoot = React.useMemo(() => {
|
|
22
|
-
const
|
|
22
|
+
const isTableScrollable = (scrollContainerRef?.scrollHeight ?? 0) >
|
|
23
|
+
(scrollContainerRef?.offsetHeight ?? 0);
|
|
23
24
|
// If table body is scrollable, make it the intersection root
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
25
|
+
if (isTableScrollable) {
|
|
26
|
+
return scrollContainerRef;
|
|
26
27
|
}
|
|
27
28
|
// Otherwise, make the viewport the intersection root
|
|
28
29
|
return undefined;
|
|
29
|
-
}, [
|
|
30
|
+
}, [scrollContainerRef]);
|
|
30
31
|
const intersectionRef = useIntersection(onIntersect, {
|
|
31
32
|
rootMargin: `${intersectionMargin}px`,
|
|
32
33
|
root: intersectionRoot,
|
|
@@ -84,7 +85,7 @@ export const TableRowMemoized = React.memo(TableRow, (prevProp, nextProp) => pre
|
|
|
84
85
|
prevProp.rowProps === nextProp.rowProps &&
|
|
85
86
|
prevProp.expanderCell === nextProp.expanderCell &&
|
|
86
87
|
prevProp.tableHasSubRows === nextProp.tableHasSubRows &&
|
|
87
|
-
prevProp.
|
|
88
|
+
prevProp.scrollContainerRef === nextProp.scrollContainerRef &&
|
|
88
89
|
prevProp.state.columnOrder === nextProp.state.columnOrder &&
|
|
89
90
|
!nextProp.state.columnResizing.isResizingColumn &&
|
|
90
91
|
prevProp.state.isTableResizing === nextProp.state.isTableResizing &&
|
|
@@ -13,6 +13,12 @@ export type DefaultCellProps<T extends Record<string, unknown>> = {
|
|
|
13
13
|
* Status of the cell.
|
|
14
14
|
*/
|
|
15
15
|
status?: 'positive' | 'negative' | 'warning';
|
|
16
|
+
/**
|
|
17
|
+
* Should the contents of the cell be clamped after a certain number of lines?
|
|
18
|
+
*
|
|
19
|
+
* Will be enabled by default if the cell content is a string.
|
|
20
|
+
*/
|
|
21
|
+
clamp?: boolean;
|
|
16
22
|
} & CellRendererProps<T> & React.ComponentPropsWithoutRef<'div'>;
|
|
17
23
|
/**
|
|
18
24
|
* Default cell.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import cx from 'classnames';
|
|
7
|
-
import { Box } from '../../utils/index.js';
|
|
7
|
+
import { Box, LineClamp, ShadowRoot } from '../../utils/index.js';
|
|
8
8
|
/**
|
|
9
9
|
* Default cell.
|
|
10
10
|
* It should be passed to `cellRenderer`.
|
|
@@ -17,11 +17,15 @@ import { Box } from '../../utils/index.js';
|
|
|
17
17
|
* }
|
|
18
18
|
*/
|
|
19
19
|
export const DefaultCell = (props) => {
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
-
const { cellElementProps: { className: cellElementClassName, style: cellElementStyle, ...cellElementProps }, children, startIcon, endIcon, cellProps, isDisabled, className, style, status, ...rest } = props;
|
|
20
|
+
const { cellElementProps: { className: cellElementClassName, style: cellElementStyle, ...cellElementProps }, children, startIcon, endIcon, cellProps, isDisabled, className, style, status, clamp = typeof cellProps.value === 'string', ...rest } = props;
|
|
23
21
|
return (React.createElement(Box, { ...cellElementProps, ...rest, className: cx(cellElementClassName, className), "aria-disabled": isDisabled?.(cellProps.row.original) || undefined, "data-iui-status": status, style: { ...cellElementStyle, ...style } },
|
|
24
|
-
|
|
22
|
+
React.createElement(ShadowRoot, null,
|
|
23
|
+
React.createElement("slot", { name: 'start' }),
|
|
24
|
+
clamp ? (React.createElement(LineClamp, null,
|
|
25
|
+
React.createElement("slot", null))) : (React.createElement("slot", null)),
|
|
26
|
+
React.createElement("slot", { name: 'end' }),
|
|
27
|
+
React.createElement("slot", { name: 'shadows' })),
|
|
28
|
+
startIcon && (React.createElement(Box, { className: 'iui-table-cell-start-icon', slot: 'start' }, startIcon)),
|
|
25
29
|
children,
|
|
26
|
-
endIcon && React.createElement(Box, { className: 'iui-table-cell-end-icon' }, endIcon)));
|
|
30
|
+
endIcon && (React.createElement(Box, { className: 'iui-table-cell-end-icon', slot: 'end' }, endIcon))));
|
|
27
31
|
};
|
|
@@ -28,5 +28,5 @@ export const FilterToggle = (props) => {
|
|
|
28
28
|
React.createElement(IconButton, { styleType: 'borderless', isActive: isVisible || isColumnFiltered, className: cx('iui-table-filter-button', className), "aria-label": 'Filter', onClick: (e) => {
|
|
29
29
|
// Prevents from triggering sort
|
|
30
30
|
e.stopPropagation();
|
|
31
|
-
}, ...rest }, isColumnFiltered ? React.createElement(SvgFilter, null) : React.createElement(SvgFilterHollow, null))))));
|
|
31
|
+
}, "data-iui-shift": 'left', ...rest }, isColumnFiltered ? React.createElement(SvgFilter, null) : React.createElement(SvgFilterHollow, null))))));
|
|
32
32
|
};
|
package/esm/core/Toast/Toast.js
CHANGED
|
@@ -122,7 +122,7 @@ export const ToastPresentation = React.forwardRef((props, forwardedRef) => {
|
|
|
122
122
|
return (React.createElement(Box, { className: cx(`iui-toast iui-${category}`, className), ref: forwardedRef, ...rest },
|
|
123
123
|
React.createElement(Box, { className: 'iui-status-area' }, React.createElement(StatusIcon, { className: 'iui-icon' })),
|
|
124
124
|
React.createElement(Box, { as: 'div', ...contentProps, className: cx('iui-message', contentProps?.className) }, content),
|
|
125
|
-
link && (React.createElement(ButtonBase, { className: 'iui-toast-anchor',
|
|
125
|
+
link && (React.createElement(ButtonBase, { ...link, className: cx('iui-anchor', 'iui-toast-anchor', link.className), title: undefined, "data-iui-status": category, "data-iui-underline": true }, link.title)),
|
|
126
126
|
(type === 'persisting' || hasCloseButton) && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
|
|
127
127
|
React.createElement(SvgCloseSmall, null)))));
|
|
128
128
|
});
|