@itwin/itwinui-react 2.5.0 → 2.5.1

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9ad85ff2: The different density settings for table will now also affect horizontal spacing.
8
+
3
9
  ## 2.5.0
4
10
 
5
11
  ### Minor Changes
@@ -5,6 +5,7 @@ export declare type SubRowExpanderProps<T extends Record<string, unknown>> = {
5
5
  expanderCell?: (cellProps: CellProps<T>) => React.ReactNode;
6
6
  isDisabled: boolean;
7
7
  cellProps: CellProps<T>;
8
+ density?: 'default' | 'condensed' | 'extra-condensed';
8
9
  };
9
10
  export declare const SubRowExpander: <T extends Record<string, unknown>>(props: SubRowExpanderProps<T>) => JSX.Element;
10
11
  export default SubRowExpander;
@@ -12,8 +12,10 @@ const react_1 = __importDefault(require("react"));
12
12
  const utils_1 = require("../utils");
13
13
  const Buttons_1 = require("../Buttons");
14
14
  const SubRowExpander = (props) => {
15
- const { cell, isDisabled, cellProps, expanderCell } = props;
16
- return (react_1.default.createElement(react_1.default.Fragment, null, expanderCell ? (expanderCell(cellProps)) : (react_1.default.createElement(Buttons_1.IconButton, { style: { marginRight: 8 }, className: 'iui-table-row-expander', styleType: 'borderless', size: 'small', onClick: (e) => {
15
+ const { cell, isDisabled, cellProps, expanderCell, density } = props;
16
+ return (react_1.default.createElement(react_1.default.Fragment, null, expanderCell ? (expanderCell(cellProps)) : (react_1.default.createElement(Buttons_1.IconButton, { style: {
17
+ marginRight: density === 'default' || density === undefined ? 8 : 4,
18
+ }, className: 'iui-table-row-expander', styleType: 'borderless', size: 'small', onClick: (e) => {
17
19
  e.stopPropagation();
18
20
  cell.row.toggleRowExpanded();
19
21
  }, disabled: isDisabled }, react_1.default.createElement(utils_1.SvgChevronRight, { style: {
@@ -204,7 +204,7 @@ const Table = (props) => {
204
204
  getSubRows,
205
205
  initialState: { pageSize, ...props.initialState },
206
206
  columnResizeMode,
207
- }, react_table_1.useFlexLayout, (0, hooks_1.useResizeColumns)(ownerDocument), react_table_1.useFilters, (0, hooks_1.useSubRowFiltering)(hasAnySubRows), react_table_1.useGlobalFilter, react_table_1.useSortBy, react_table_1.useExpanded, react_table_1.usePagination, react_table_1.useRowSelect, hooks_1.useSubRowSelection, (0, hooks_1.useExpanderCell)(subComponent, expanderCell, isRowDisabled), (0, hooks_1.useSelectionCell)(isSelectable, selectionMode, isRowDisabled), react_table_1.useColumnOrder, (0, hooks_1.useColumnDragAndDrop)(enableColumnReordering), hooks_1.useStickyColumns);
207
+ }, react_table_1.useFlexLayout, (0, hooks_1.useResizeColumns)(ownerDocument), react_table_1.useFilters, (0, hooks_1.useSubRowFiltering)(hasAnySubRows), react_table_1.useGlobalFilter, react_table_1.useSortBy, react_table_1.useExpanded, react_table_1.usePagination, react_table_1.useRowSelect, hooks_1.useSubRowSelection, (0, hooks_1.useExpanderCell)(subComponent, expanderCell, isRowDisabled), (0, hooks_1.useSelectionCell)(isSelectable, selectionMode, isRowDisabled, density), react_table_1.useColumnOrder, (0, hooks_1.useColumnDragAndDrop)(enableColumnReordering), hooks_1.useStickyColumns);
208
208
  const { getTableProps, rows, headerGroups: _headerGroups, getTableBodyProps, prepareRow, state, allColumns, dispatch, page, gotoPage, setPageSize, flatHeaders, visibleColumns, setGlobalFilter, } = instance;
209
209
  let headerGroups = _headerGroups;
210
210
  if (columns.length === 1 && 'columns' in columns[0]) {
@@ -342,7 +342,7 @@ const Table = (props) => {
342
342
  const getPreparedRow = react_1.default.useCallback((index) => {
343
343
  const row = page[index];
344
344
  prepareRow(row);
345
- return (react_1.default.createElement(TableRowMemoized_1.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 === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRef.current, tableRowRef: enableVirtualization ? undefined : tableRowRef(row) }));
345
+ return (react_1.default.createElement(TableRowMemoized_1.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 === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRef.current, tableRowRef: enableVirtualization ? undefined : tableRowRef(row), density: density }));
346
346
  }, [
347
347
  page,
348
348
  prepareRow,
@@ -357,6 +357,7 @@ const Table = (props) => {
357
357
  expanderCell,
358
358
  enableVirtualization,
359
359
  tableRowRef,
360
+ density,
360
361
  ]);
361
362
  const virtualizedItemRenderer = react_1.default.useCallback((index) => getPreparedRow(index), [getPreparedRow]);
362
363
  const updateStickyState = () => {
@@ -7,6 +7,7 @@ export declare type TableCellProps<T extends Record<string, unknown>> = {
7
7
  tableHasSubRows: boolean;
8
8
  tableInstance: TableInstance<T>;
9
9
  expanderCell?: (cellProps: CellProps<T>) => React.ReactNode;
10
+ density?: 'default' | 'condensed' | 'extra-condensed';
10
11
  };
11
12
  export declare const TableCell: <T extends Record<string, unknown>>(props: TableCellProps<T>) => JSX.Element;
12
13
  export default TableCell;
@@ -15,7 +15,7 @@ const SubRowExpander_1 = require("./SubRowExpander");
15
15
  const columns_1 = require("./columns");
16
16
  const cells_1 = require("./cells");
17
17
  const TableCell = (props) => {
18
- const { cell, cellIndex, isDisabled, tableHasSubRows, tableInstance, expanderCell, } = props;
18
+ const { cell, cellIndex, isDisabled, tableHasSubRows, tableInstance, expanderCell, density, } = props;
19
19
  const hasSubRowExpander = cellIndex ===
20
20
  cell.row.cells.findIndex((c) => c.column.id !== columns_1.SELECTION_CELL_ID);
21
21
  const getSubRowStyle = () => {
@@ -23,9 +23,20 @@ const TableCell = (props) => {
23
23
  return undefined;
24
24
  }
25
25
  // If it doesn't have sub-rows then shift by another level to align with expandable rows on the same depth
26
- // 16 = initial_cell_padding, 35 = 27 + 8 = expander_width + margin
26
+ const dynamicMargin = cell.row.depth + (cell.row.canExpand ? 0 : 1);
27
+ let cellPadding = 16;
28
+ let expanderMargin = 8;
29
+ if (density === 'condensed') {
30
+ cellPadding = 12;
31
+ expanderMargin = 4;
32
+ }
33
+ else if (density === 'extra-condensed') {
34
+ cellPadding = 8;
35
+ expanderMargin = 4;
36
+ }
37
+ const multiplier = 26 + expanderMargin; // 26 = expander width
27
38
  return {
28
- paddingLeft: 16 + (cell.row.depth + (cell.row.canExpand ? 0 : 1)) * 35,
39
+ paddingLeft: cellPadding + dynamicMargin * multiplier,
29
40
  };
30
41
  };
31
42
  const cellElementProps = cell.getCellProps({
@@ -43,7 +54,7 @@ const TableCell = (props) => {
43
54
  ...{ cell, row: cell.row, value: cell.value, column: cell.column },
44
55
  };
45
56
  const cellContent = (react_1.default.createElement(react_1.default.Fragment, null,
46
- tableHasSubRows && hasSubRowExpander && cell.row.canExpand && (react_1.default.createElement(SubRowExpander_1.SubRowExpander, { cell: cell, isDisabled: isDisabled, cellProps: cellProps, expanderCell: expanderCell })),
57
+ tableHasSubRows && hasSubRowExpander && cell.row.canExpand && (react_1.default.createElement(SubRowExpander_1.SubRowExpander, { cell: cell, isDisabled: isDisabled, cellProps: cellProps, expanderCell: expanderCell, density: density })),
47
58
  cell.render('Cell')));
48
59
  const cellRendererProps = {
49
60
  cellElementProps,
@@ -25,6 +25,7 @@ export declare const TableRow: <T extends Record<string, unknown>>(props: {
25
25
  expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
26
26
  bodyRef: HTMLDivElement | null;
27
27
  tableRowRef?: React.Ref<HTMLDivElement> | undefined;
28
+ density?: "default" | "condensed" | "extra-condensed" | undefined;
28
29
  }) => JSX.Element;
29
30
  export declare const TableRowMemoized: <T extends Record<string, unknown>>(props: {
30
31
  row: Row<T>;
@@ -45,4 +46,5 @@ export declare const TableRowMemoized: <T extends Record<string, unknown>>(props
45
46
  expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
46
47
  bodyRef: HTMLDivElement | null;
47
48
  tableRowRef?: React.Ref<HTMLDivElement> | undefined;
49
+ density?: "default" | "condensed" | "extra-condensed" | undefined;
48
50
  }) => JSX.Element;
@@ -20,7 +20,7 @@ const TableCell_1 = require("./TableCell");
20
20
  */
21
21
  const TableRow = (props) => {
22
22
  var _a;
23
- const { row, rowProps, isLast, onRowInViewport, onBottomReached, intersectionMargin, onClick, subComponent, isDisabled, tableHasSubRows, tableInstance, expanderCell, bodyRef, tableRowRef, } = props;
23
+ const { row, rowProps, isLast, onRowInViewport, onBottomReached, intersectionMargin, onClick, subComponent, isDisabled, tableHasSubRows, tableInstance, expanderCell, bodyRef, tableRowRef, density, } = props;
24
24
  const onIntersect = react_1.default.useCallback(() => {
25
25
  var _a, _b;
26
26
  (_a = onRowInViewport.current) === null || _a === void 0 ? void 0 : _a.call(onRowInViewport, row.original);
@@ -62,7 +62,7 @@ const TableRow = (props) => {
62
62
  (_a = mergedProps === null || mergedProps === void 0 ? void 0 : mergedProps.onClick) === null || _a === void 0 ? void 0 : _a.call(mergedProps, event);
63
63
  onClick === null || onClick === void 0 ? void 0 : onClick(event, row);
64
64
  } }, row.cells.map((cell, index) => {
65
- return (react_1.default.createElement(TableCell_1.TableCell, { key: cell.getCellProps().key, cell: cell, cellIndex: index, isDisabled: isDisabled, tableHasSubRows: tableHasSubRows, tableInstance: tableInstance, expanderCell: expanderCell }));
65
+ return (react_1.default.createElement(TableCell_1.TableCell, { key: cell.getCellProps().key, cell: cell, cellIndex: index, isDisabled: isDisabled, tableHasSubRows: tableHasSubRows, tableInstance: tableInstance, expanderCell: expanderCell, density: density }));
66
66
  })),
67
67
  subComponent && (react_1.default.createElement(utils_1.WithCSSTransition, { in: row.isExpanded },
68
68
  react_1.default.createElement("div", { className: (0, classnames_1.default)('iui-table-row', 'iui-table-expanded-content'), "aria-disabled": isDisabled }, subComponent(row))))));
@@ -104,5 +104,6 @@ exports.TableRowMemoized = react_1.default.memo(exports.TableRow, (prevProp, nex
104
104
  prevProp.state.sticky.isScrolledToLeft ===
105
105
  nextProp.state.sticky.isScrolledToLeft &&
106
106
  prevProp.state.sticky.isScrolledToRight ===
107
- nextProp.state.sticky.isScrolledToRight;
107
+ nextProp.state.sticky.isScrolledToRight &&
108
+ prevProp.density === nextProp.density;
108
109
  });
@@ -16,6 +16,7 @@ export declare const SELECTION_CELL_ID = "iui-table-checkbox-selector";
16
16
  export declare const SelectionColumn: <T extends Record<string, unknown>>(props?: {
17
17
  /** Function that returns whether row checkbox should be disabled. */
18
18
  isDisabled?: ((rowData: T) => boolean) | undefined;
19
+ density?: "default" | "condensed" | "extra-condensed" | undefined;
19
20
  }) => {
20
21
  id: string;
21
22
  disableResizing: boolean;
@@ -25,15 +25,16 @@ exports.SELECTION_CELL_ID = 'iui-table-checkbox-selector';
25
25
  * ], [isCheckboxDisabled]);
26
26
  */
27
27
  const SelectionColumn = (props = {}) => {
28
- const { isDisabled } = props;
28
+ const { isDisabled, density } = props;
29
+ const densityWidth = density === 'condensed' ? 42 : density === 'extra-condensed' ? 34 : 48;
29
30
  return {
30
31
  id: exports.SELECTION_CELL_ID,
31
32
  disableResizing: true,
32
33
  disableGroupBy: true,
33
34
  disableReordering: true,
34
- minWidth: 48,
35
- width: 48,
36
- maxWidth: 48,
35
+ minWidth: densityWidth,
36
+ width: densityWidth,
37
+ maxWidth: densityWidth,
37
38
  columnClassName: 'iui-slot',
38
39
  cellClassName: 'iui-slot',
39
40
  Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows, initialRows, state, }) => {
@@ -1,2 +1,2 @@
1
1
  import { Hooks } from 'react-table';
2
- export declare const useSelectionCell: <T extends Record<string, unknown>>(isSelectable: boolean, selectionMode: 'multi' | 'single', isRowDisabled?: ((rowData: T) => boolean) | undefined) => (hooks: Hooks<T>) => void;
2
+ export declare const useSelectionCell: <T extends Record<string, unknown>>(isSelectable: boolean, selectionMode: 'multi' | 'single', isRowDisabled?: ((rowData: T) => boolean) | undefined, density?: 'default' | 'condensed' | 'extra-condensed') => (hooks: Hooks<T>) => void;
@@ -2,13 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSelectionCell = void 0;
4
4
  const columns_1 = require("../columns");
5
- const useSelectionCell = (isSelectable, selectionMode, isRowDisabled) => (hooks) => {
5
+ const useSelectionCell = (isSelectable, selectionMode, isRowDisabled, density = 'default') => (hooks) => {
6
6
  if (!isSelectable) {
7
7
  return;
8
8
  }
9
9
  hooks.allColumns.push((columns) => selectionMode === 'single' ||
10
10
  columns.find((c) => c.id === columns_1.SELECTION_CELL_ID)
11
11
  ? columns
12
- : [(0, columns_1.SelectionColumn)({ isDisabled: isRowDisabled }), ...columns]);
12
+ : [
13
+ (0, columns_1.SelectionColumn)({ isDisabled: isRowDisabled, density: density }),
14
+ ...columns,
15
+ ]);
13
16
  };
14
17
  exports.useSelectionCell = useSelectionCell;
@@ -5,6 +5,7 @@ export declare type SubRowExpanderProps<T extends Record<string, unknown>> = {
5
5
  expanderCell?: (cellProps: CellProps<T>) => React.ReactNode;
6
6
  isDisabled: boolean;
7
7
  cellProps: CellProps<T>;
8
+ density?: 'default' | 'condensed' | 'extra-condensed';
8
9
  };
9
10
  export declare const SubRowExpander: <T extends Record<string, unknown>>(props: SubRowExpanderProps<T>) => JSX.Element;
10
11
  export default SubRowExpander;
@@ -6,8 +6,10 @@ import React from 'react';
6
6
  import { SvgChevronRight } from '../utils';
7
7
  import { IconButton } from '../Buttons';
8
8
  export const SubRowExpander = (props) => {
9
- const { cell, isDisabled, cellProps, expanderCell } = props;
10
- return (React.createElement(React.Fragment, null, expanderCell ? (expanderCell(cellProps)) : (React.createElement(IconButton, { style: { marginRight: 8 }, className: 'iui-table-row-expander', styleType: 'borderless', size: 'small', onClick: (e) => {
9
+ const { cell, isDisabled, cellProps, expanderCell, density } = props;
10
+ return (React.createElement(React.Fragment, null, expanderCell ? (expanderCell(cellProps)) : (React.createElement(IconButton, { style: {
11
+ marginRight: density === 'default' || density === undefined ? 8 : 4,
12
+ }, className: 'iui-table-row-expander', styleType: 'borderless', size: 'small', onClick: (e) => {
11
13
  e.stopPropagation();
12
14
  cell.row.toggleRowExpanded();
13
15
  }, disabled: isDisabled }, React.createElement(SvgChevronRight, { style: {
@@ -198,7 +198,7 @@ export const Table = (props) => {
198
198
  getSubRows,
199
199
  initialState: { pageSize, ...props.initialState },
200
200
  columnResizeMode,
201
- }, useFlexLayout, useResizeColumns(ownerDocument), useFilters, useSubRowFiltering(hasAnySubRows), useGlobalFilter, useSortBy, useExpanded, usePagination, useRowSelect, useSubRowSelection, useExpanderCell(subComponent, expanderCell, isRowDisabled), useSelectionCell(isSelectable, selectionMode, isRowDisabled), useColumnOrder, useColumnDragAndDrop(enableColumnReordering), useStickyColumns);
201
+ }, useFlexLayout, useResizeColumns(ownerDocument), useFilters, useSubRowFiltering(hasAnySubRows), useGlobalFilter, useSortBy, useExpanded, usePagination, useRowSelect, useSubRowSelection, useExpanderCell(subComponent, expanderCell, isRowDisabled), useSelectionCell(isSelectable, selectionMode, isRowDisabled, density), useColumnOrder, useColumnDragAndDrop(enableColumnReordering), useStickyColumns);
202
202
  const { getTableProps, rows, headerGroups: _headerGroups, getTableBodyProps, prepareRow, state, allColumns, dispatch, page, gotoPage, setPageSize, flatHeaders, visibleColumns, setGlobalFilter, } = instance;
203
203
  let headerGroups = _headerGroups;
204
204
  if (columns.length === 1 && 'columns' in columns[0]) {
@@ -336,7 +336,7 @@ export const Table = (props) => {
336
336
  const getPreparedRow = React.useCallback((index) => {
337
337
  const row = page[index];
338
338
  prepareRow(row);
339
- 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 === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRef.current, tableRowRef: enableVirtualization ? undefined : tableRowRef(row) }));
339
+ 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 === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRef.current, tableRowRef: enableVirtualization ? undefined : tableRowRef(row), density: density }));
340
340
  }, [
341
341
  page,
342
342
  prepareRow,
@@ -351,6 +351,7 @@ export const Table = (props) => {
351
351
  expanderCell,
352
352
  enableVirtualization,
353
353
  tableRowRef,
354
+ density,
354
355
  ]);
355
356
  const virtualizedItemRenderer = React.useCallback((index) => getPreparedRow(index), [getPreparedRow]);
356
357
  const updateStickyState = () => {
@@ -7,6 +7,7 @@ export declare type TableCellProps<T extends Record<string, unknown>> = {
7
7
  tableHasSubRows: boolean;
8
8
  tableInstance: TableInstance<T>;
9
9
  expanderCell?: (cellProps: CellProps<T>) => React.ReactNode;
10
+ density?: 'default' | 'condensed' | 'extra-condensed';
10
11
  };
11
12
  export declare const TableCell: <T extends Record<string, unknown>>(props: TableCellProps<T>) => JSX.Element;
12
13
  export default TableCell;
@@ -9,7 +9,7 @@ import { SubRowExpander } from './SubRowExpander';
9
9
  import { SELECTION_CELL_ID } from './columns';
10
10
  import { DefaultCell } from './cells';
11
11
  export const TableCell = (props) => {
12
- const { cell, cellIndex, isDisabled, tableHasSubRows, tableInstance, expanderCell, } = props;
12
+ const { cell, cellIndex, isDisabled, tableHasSubRows, tableInstance, expanderCell, density, } = props;
13
13
  const hasSubRowExpander = cellIndex ===
14
14
  cell.row.cells.findIndex((c) => c.column.id !== SELECTION_CELL_ID);
15
15
  const getSubRowStyle = () => {
@@ -17,9 +17,20 @@ export const TableCell = (props) => {
17
17
  return undefined;
18
18
  }
19
19
  // If it doesn't have sub-rows then shift by another level to align with expandable rows on the same depth
20
- // 16 = initial_cell_padding, 35 = 27 + 8 = expander_width + margin
20
+ const dynamicMargin = cell.row.depth + (cell.row.canExpand ? 0 : 1);
21
+ let cellPadding = 16;
22
+ let expanderMargin = 8;
23
+ if (density === 'condensed') {
24
+ cellPadding = 12;
25
+ expanderMargin = 4;
26
+ }
27
+ else if (density === 'extra-condensed') {
28
+ cellPadding = 8;
29
+ expanderMargin = 4;
30
+ }
31
+ const multiplier = 26 + expanderMargin; // 26 = expander width
21
32
  return {
22
- paddingLeft: 16 + (cell.row.depth + (cell.row.canExpand ? 0 : 1)) * 35,
33
+ paddingLeft: cellPadding + dynamicMargin * multiplier,
23
34
  };
24
35
  };
25
36
  const cellElementProps = cell.getCellProps({
@@ -37,7 +48,7 @@ export const TableCell = (props) => {
37
48
  ...{ cell, row: cell.row, value: cell.value, column: cell.column },
38
49
  };
39
50
  const cellContent = (React.createElement(React.Fragment, null,
40
- tableHasSubRows && hasSubRowExpander && cell.row.canExpand && (React.createElement(SubRowExpander, { cell: cell, isDisabled: isDisabled, cellProps: cellProps, expanderCell: expanderCell })),
51
+ tableHasSubRows && hasSubRowExpander && cell.row.canExpand && (React.createElement(SubRowExpander, { cell: cell, isDisabled: isDisabled, cellProps: cellProps, expanderCell: expanderCell, density: density })),
41
52
  cell.render('Cell')));
42
53
  const cellRendererProps = {
43
54
  cellElementProps,
@@ -25,6 +25,7 @@ export declare const TableRow: <T extends Record<string, unknown>>(props: {
25
25
  expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
26
26
  bodyRef: HTMLDivElement | null;
27
27
  tableRowRef?: React.Ref<HTMLDivElement> | undefined;
28
+ density?: "default" | "condensed" | "extra-condensed" | undefined;
28
29
  }) => JSX.Element;
29
30
  export declare const TableRowMemoized: <T extends Record<string, unknown>>(props: {
30
31
  row: Row<T>;
@@ -45,4 +46,5 @@ export declare const TableRowMemoized: <T extends Record<string, unknown>>(props
45
46
  expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
46
47
  bodyRef: HTMLDivElement | null;
47
48
  tableRowRef?: React.Ref<HTMLDivElement> | undefined;
49
+ density?: "default" | "condensed" | "extra-condensed" | undefined;
48
50
  }) => JSX.Element;
@@ -14,7 +14,7 @@ import { TableCell } from './TableCell';
14
14
  */
15
15
  export const TableRow = (props) => {
16
16
  var _a;
17
- const { row, rowProps, isLast, onRowInViewport, onBottomReached, intersectionMargin, onClick, subComponent, isDisabled, tableHasSubRows, tableInstance, expanderCell, bodyRef, tableRowRef, } = props;
17
+ const { row, rowProps, isLast, onRowInViewport, onBottomReached, intersectionMargin, onClick, subComponent, isDisabled, tableHasSubRows, tableInstance, expanderCell, bodyRef, tableRowRef, density, } = props;
18
18
  const onIntersect = React.useCallback(() => {
19
19
  var _a, _b;
20
20
  (_a = onRowInViewport.current) === null || _a === void 0 ? void 0 : _a.call(onRowInViewport, row.original);
@@ -56,7 +56,7 @@ export const TableRow = (props) => {
56
56
  (_a = mergedProps === null || mergedProps === void 0 ? void 0 : mergedProps.onClick) === null || _a === void 0 ? void 0 : _a.call(mergedProps, event);
57
57
  onClick === null || onClick === void 0 ? void 0 : onClick(event, row);
58
58
  } }, row.cells.map((cell, index) => {
59
- return (React.createElement(TableCell, { key: cell.getCellProps().key, cell: cell, cellIndex: index, isDisabled: isDisabled, tableHasSubRows: tableHasSubRows, tableInstance: tableInstance, expanderCell: expanderCell }));
59
+ return (React.createElement(TableCell, { key: cell.getCellProps().key, cell: cell, cellIndex: index, isDisabled: isDisabled, tableHasSubRows: tableHasSubRows, tableInstance: tableInstance, expanderCell: expanderCell, density: density }));
60
60
  })),
61
61
  subComponent && (React.createElement(WithCSSTransition, { in: row.isExpanded },
62
62
  React.createElement("div", { className: cx('iui-table-row', 'iui-table-expanded-content'), "aria-disabled": isDisabled }, subComponent(row))))));
@@ -97,5 +97,6 @@ export const TableRowMemoized = React.memo(TableRow, (prevProp, nextProp) => {
97
97
  prevProp.state.sticky.isScrolledToLeft ===
98
98
  nextProp.state.sticky.isScrolledToLeft &&
99
99
  prevProp.state.sticky.isScrolledToRight ===
100
- nextProp.state.sticky.isScrolledToRight;
100
+ nextProp.state.sticky.isScrolledToRight &&
101
+ prevProp.density === nextProp.density;
101
102
  });
@@ -16,6 +16,7 @@ export declare const SELECTION_CELL_ID = "iui-table-checkbox-selector";
16
16
  export declare const SelectionColumn: <T extends Record<string, unknown>>(props?: {
17
17
  /** Function that returns whether row checkbox should be disabled. */
18
18
  isDisabled?: ((rowData: T) => boolean) | undefined;
19
+ density?: "default" | "condensed" | "extra-condensed" | undefined;
19
20
  }) => {
20
21
  id: string;
21
22
  disableResizing: boolean;
@@ -19,15 +19,16 @@ export const SELECTION_CELL_ID = 'iui-table-checkbox-selector';
19
19
  * ], [isCheckboxDisabled]);
20
20
  */
21
21
  export const SelectionColumn = (props = {}) => {
22
- const { isDisabled } = props;
22
+ const { isDisabled, density } = props;
23
+ const densityWidth = density === 'condensed' ? 42 : density === 'extra-condensed' ? 34 : 48;
23
24
  return {
24
25
  id: SELECTION_CELL_ID,
25
26
  disableResizing: true,
26
27
  disableGroupBy: true,
27
28
  disableReordering: true,
28
- minWidth: 48,
29
- width: 48,
30
- maxWidth: 48,
29
+ minWidth: densityWidth,
30
+ width: densityWidth,
31
+ maxWidth: densityWidth,
31
32
  columnClassName: 'iui-slot',
32
33
  cellClassName: 'iui-slot',
33
34
  Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows, initialRows, state, }) => {
@@ -1,2 +1,2 @@
1
1
  import { Hooks } from 'react-table';
2
- export declare const useSelectionCell: <T extends Record<string, unknown>>(isSelectable: boolean, selectionMode: 'multi' | 'single', isRowDisabled?: ((rowData: T) => boolean) | undefined) => (hooks: Hooks<T>) => void;
2
+ export declare const useSelectionCell: <T extends Record<string, unknown>>(isSelectable: boolean, selectionMode: 'multi' | 'single', isRowDisabled?: ((rowData: T) => boolean) | undefined, density?: 'default' | 'condensed' | 'extra-condensed') => (hooks: Hooks<T>) => void;
@@ -1,10 +1,13 @@
1
1
  import { SelectionColumn, SELECTION_CELL_ID } from '../columns';
2
- export const useSelectionCell = (isSelectable, selectionMode, isRowDisabled) => (hooks) => {
2
+ export const useSelectionCell = (isSelectable, selectionMode, isRowDisabled, density = 'default') => (hooks) => {
3
3
  if (!isSelectable) {
4
4
  return;
5
5
  }
6
6
  hooks.allColumns.push((columns) => selectionMode === 'single' ||
7
7
  columns.find((c) => c.id === SELECTION_CELL_ID)
8
8
  ? columns
9
- : [SelectionColumn({ isDisabled: isRowDisabled }), ...columns]);
9
+ : [
10
+ SelectionColumn({ isDisabled: isRowDisabled, density: density }),
11
+ ...columns,
12
+ ]);
10
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "main": "cjs/index.js",