@itwin/itwinui-react 2.5.0 → 2.6.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/cjs/core/ComboBox/ComboBox.js +4 -1
  3. package/cjs/core/FileUpload/FileEmptyCard.d.ts +29 -0
  4. package/cjs/core/FileUpload/FileEmptyCard.js +50 -0
  5. package/cjs/core/FileUpload/FileUploadCard.d.ts +116 -0
  6. package/cjs/core/FileUpload/FileUploadCard.js +144 -0
  7. package/cjs/core/FileUpload/FileUploadTemplate.d.ts +1 -1
  8. package/cjs/core/FileUpload/FileUploadTemplate.js +4 -3
  9. package/cjs/core/FileUpload/index.d.ts +4 -0
  10. package/cjs/core/FileUpload/index.js +5 -1
  11. package/cjs/core/Header/HeaderLogo.d.ts +8 -11
  12. package/cjs/core/Header/HeaderLogo.js +7 -12
  13. package/cjs/core/Table/SubRowExpander.d.ts +1 -0
  14. package/cjs/core/Table/SubRowExpander.js +4 -2
  15. package/cjs/core/Table/Table.js +3 -2
  16. package/cjs/core/Table/TableCell.d.ts +1 -0
  17. package/cjs/core/Table/TableCell.js +15 -4
  18. package/cjs/core/Table/TableRowMemoized.d.ts +2 -0
  19. package/cjs/core/Table/TableRowMemoized.js +4 -3
  20. package/cjs/core/Table/columns/selectionColumn.d.ts +1 -0
  21. package/cjs/core/Table/columns/selectionColumn.js +5 -4
  22. package/cjs/core/Table/hooks/useSelectionCell.d.ts +1 -1
  23. package/cjs/core/Table/hooks/useSelectionCell.js +5 -2
  24. package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +12 -2
  25. package/cjs/core/ToggleSwitch/ToggleSwitch.js +2 -2
  26. package/cjs/core/index.d.ts +2 -2
  27. package/cjs/core/index.js +5 -3
  28. package/cjs/core/utils/hooks/index.d.ts +1 -0
  29. package/cjs/core/utils/hooks/index.js +1 -0
  30. package/cjs/core/utils/hooks/useId.d.ts +5 -0
  31. package/cjs/core/utils/hooks/useId.js +20 -0
  32. package/cjs/core/utils/icons/SvgDocument.d.ts +2 -0
  33. package/cjs/core/utils/icons/SvgDocument.js +36 -0
  34. package/cjs/core/utils/icons/index.d.ts +1 -0
  35. package/cjs/core/utils/icons/index.js +1 -0
  36. package/esm/core/ComboBox/ComboBox.js +4 -1
  37. package/esm/core/FileUpload/FileEmptyCard.d.ts +29 -0
  38. package/esm/core/FileUpload/FileEmptyCard.js +44 -0
  39. package/esm/core/FileUpload/FileUploadCard.d.ts +116 -0
  40. package/esm/core/FileUpload/FileUploadCard.js +138 -0
  41. package/esm/core/FileUpload/FileUploadTemplate.d.ts +1 -1
  42. package/esm/core/FileUpload/FileUploadTemplate.js +4 -3
  43. package/esm/core/FileUpload/index.d.ts +4 -0
  44. package/esm/core/FileUpload/index.js +2 -0
  45. package/esm/core/Header/HeaderLogo.d.ts +8 -11
  46. package/esm/core/Header/HeaderLogo.js +7 -11
  47. package/esm/core/Table/SubRowExpander.d.ts +1 -0
  48. package/esm/core/Table/SubRowExpander.js +4 -2
  49. package/esm/core/Table/Table.js +3 -2
  50. package/esm/core/Table/TableCell.d.ts +1 -0
  51. package/esm/core/Table/TableCell.js +15 -4
  52. package/esm/core/Table/TableRowMemoized.d.ts +2 -0
  53. package/esm/core/Table/TableRowMemoized.js +4 -3
  54. package/esm/core/Table/columns/selectionColumn.d.ts +1 -0
  55. package/esm/core/Table/columns/selectionColumn.js +5 -4
  56. package/esm/core/Table/hooks/useSelectionCell.d.ts +1 -1
  57. package/esm/core/Table/hooks/useSelectionCell.js +5 -2
  58. package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +12 -2
  59. package/esm/core/ToggleSwitch/ToggleSwitch.js +2 -2
  60. package/esm/core/index.d.ts +2 -2
  61. package/esm/core/index.js +1 -1
  62. package/esm/core/utils/hooks/index.d.ts +1 -0
  63. package/esm/core/utils/hooks/index.js +1 -0
  64. package/esm/core/utils/hooks/useId.d.ts +5 -0
  65. package/esm/core/utils/hooks/useId.js +14 -0
  66. package/esm/core/utils/icons/SvgDocument.d.ts +2 -0
  67. package/esm/core/utils/icons/SvgDocument.js +9 -0
  68. package/esm/core/utils/icons/index.d.ts +1 -0
  69. package/esm/core/utils/icons/index.js +1 -0
  70. package/package.json +2 -2
@@ -3,6 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import React from 'react';
6
+ import cx from 'classnames';
6
7
  import { useTheme, SvgUpload } from '../utils';
7
8
  import '@itwin/itwinui-css/css/file-upload.css';
8
9
  /**
@@ -12,10 +13,10 @@ import '@itwin/itwinui-css/css/file-upload.css';
12
13
  * <FileUploadTemplate onChange={(e) => console.log(e.target.files)} />
13
14
  */
14
15
  export const FileUploadTemplate = (props) => {
15
- const { onChange, acceptMultiple = true, acceptType, label = 'Choose a file', subtitle = 'or drag & drop it here.', children, } = props;
16
+ const { onChange, acceptMultiple = true, acceptType, label = 'Choose a file', subtitle = 'or drag & drop it here.', children, className, ...rest } = props;
16
17
  useTheme();
17
- return (React.createElement(React.Fragment, null,
18
- React.createElement(SvgUpload, { className: 'iui-icon', "aria-hidden": true }),
18
+ return (React.createElement("div", { className: cx('iui-file-upload-template', className), ...rest },
19
+ React.createElement(SvgUpload, { className: 'iui-template-icon', "aria-hidden": true }),
19
20
  React.createElement("div", { className: 'iui-template-text' },
20
21
  React.createElement("label", { className: 'iui-anchor' },
21
22
  React.createElement("input", { className: 'iui-browse-input', type: 'file', onChange: onChange, multiple: acceptMultiple, accept: acceptType }),
@@ -4,3 +4,7 @@ declare const _default: "./FileUpload";
4
4
  export default _default;
5
5
  export { FileUploadTemplate } from './FileUploadTemplate';
6
6
  export type { FileUploadTemplateProps } from './FileUploadTemplate';
7
+ export { FileUploadCard } from './FileUploadCard';
8
+ export type { FileUploadCardProps, FileUploadCardIconProps, FileUploadCardInfoProps, FileUploadCardTitleProps, FileUploadCardDescriptionProps, FileUploadCardActionProps, FileUploadCardInputLabelProps, FileUploadCardInputProps, } from './FileUploadCard';
9
+ export { FileEmptyCard } from './FileEmptyCard';
10
+ export type { FileEmptyCardProps, FileEmptyCardIconProps, FileEmptyCardTextProps, } from './FileEmptyCard';
@@ -5,3 +5,5 @@
5
5
  export { FileUpload } from './FileUpload';
6
6
  export default './FileUpload';
7
7
  export { FileUploadTemplate } from './FileUploadTemplate';
8
+ export { FileUploadCard } from './FileUploadCard';
9
+ export { FileEmptyCard } from './FileEmptyCard';
@@ -1,21 +1,18 @@
1
- import React from 'react';
2
- import { CommonProps } from '../utils';
1
+ /// <reference types="react" />
2
+ import type { PolymorphicForwardRefComponent, PolymorphicComponentProps } from '../utils';
3
3
  import '@itwin/itwinui-css/css/header.css';
4
- export declare type HeaderLogoProps = {
4
+ declare type HeaderLogoOwnProps = {
5
5
  /**
6
6
  * Logo shown before the main content.
7
7
  */
8
8
  logo: JSX.Element;
9
9
  /**
10
10
  * Click event handler.
11
- * Will update the Logo to have mouse and keyboard interaction if provided.
11
+ * If passed, the component will be rendered as a `<button>` rather than `<div>`.
12
12
  */
13
- onClick?: () => void;
14
- /**
15
- * Expects the app name, is put on the right of the logo.
16
- */
17
- children?: React.ReactNode;
18
- } & CommonProps;
13
+ onClick?: (e: unknown) => void;
14
+ };
15
+ export declare type HeaderLogoProps = PolymorphicComponentProps<'div', HeaderLogoOwnProps>;
19
16
  /**
20
17
  * Header Title section
21
18
  * @example
@@ -24,5 +21,5 @@ export declare type HeaderLogoProps = {
24
21
  * <HeaderLogo logo={<img src='image.png' />} />
25
22
  * <HeaderLogo logo={<img src='data:image/png;base64,...' />}>Downloaded Image</HeaderLogo>
26
23
  */
27
- export declare const HeaderLogo: (props: HeaderLogoProps) => JSX.Element;
24
+ export declare const HeaderLogo: PolymorphicForwardRefComponent<"div", HeaderLogoOwnProps>;
28
25
  export default HeaderLogo;
@@ -14,22 +14,18 @@ import '@itwin/itwinui-css/css/header.css';
14
14
  * <HeaderLogo logo={<img src='image.png' />} />
15
15
  * <HeaderLogo logo={<img src='data:image/png;base64,...' />}>Downloaded Image</HeaderLogo>
16
16
  */
17
- export const HeaderLogo = (props) => {
18
- const { className, children, logo, onClick, ...rest } = props;
19
- const keyDownHandler = (e) => {
20
- if (onClick &&
21
- (e.key === 'Enter' || e.key === ' ' || e.key === 'Spacebar')) {
22
- e.preventDefault();
23
- onClick();
24
- }
25
- };
17
+ export const HeaderLogo = React.forwardRef((props, ref) => {
18
+ const { className, children, logo, onClick, as: Element = !!onClick ? 'button' : 'div', ...rest } = props;
26
19
  useTheme();
27
- return (React.createElement("div", { className: cx('iui-header-brand', className), role: onClick && 'button', tabIndex: onClick && 0, onKeyDown: keyDownHandler, onClick: onClick, ...rest },
20
+ return (React.createElement(Element, { className: cx('iui-header-brand', className), onClick: onClick,
21
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- TS complains here but it's ok; it is an implementation detail
22
+ // @ts-ignore
23
+ ref: ref, ...rest },
28
24
  React.isValidElement(logo)
29
25
  ? React.cloneElement(logo, {
30
26
  className: cx('iui-header-brand-icon', logo.props.className),
31
27
  })
32
28
  : undefined,
33
29
  children && React.createElement("span", { className: 'iui-header-brand-label' }, children)));
34
- };
30
+ });
35
31
  export default HeaderLogo;
@@ -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
  };
@@ -19,7 +19,12 @@ export declare type ToggleSwitchProps = {
19
19
  * Icon inside the toggle switch. Shown only when toggle is checked.
20
20
  */
21
21
  icon?: JSX.Element;
22
- } & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'>;
22
+ /**
23
+ * Size of the toggle switch.
24
+ * @default 'default'
25
+ */
26
+ size?: 'default' | 'small';
27
+ } & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'>;
23
28
  /**
24
29
  * A switch for turning on and off.
25
30
  * @example
@@ -57,5 +62,10 @@ export declare const ToggleSwitch: React.ForwardRefExoticComponent<{
57
62
  * Icon inside the toggle switch. Shown only when toggle is checked.
58
63
  */
59
64
  icon?: JSX.Element | undefined;
60
- } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> & React.RefAttributes<HTMLInputElement>>;
65
+ /**
66
+ * Size of the toggle switch.
67
+ * @default 'default'
68
+ */
69
+ size?: "small" | "default" | undefined;
70
+ } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & React.RefAttributes<HTMLInputElement>>;
61
71
  export default ToggleSwitch;
@@ -25,7 +25,7 @@ import '@itwin/itwinui-css/css/toggle-switch.css';
25
25
  * <ToggleSwitch label='With icon toggle' icon={<svg viewBox='0 0 16 16'><path d='M1 1v14h14V1H1zm13 1.7v10.6L8.7 8 14 2.7zM8 7.3L2.7 2h10.6L8 7.3zm-.7.7L2 13.3V2.7L7.3 8zm.7.7l5.3 5.3H2.7L8 8.7z' /></svg>} />
26
26
  */
27
27
  export const ToggleSwitch = React.forwardRef((props, ref) => {
28
- const { disabled = false, labelPosition = 'right', icon, label, setFocus = false, className, style, ...rest } = props;
28
+ const { disabled = false, labelPosition = 'right', icon, label, setFocus = false, className, style, size = 'default', ...rest } = props;
29
29
  useTheme();
30
30
  const inputElementRef = React.useRef(null);
31
31
  const refs = useMergedRefs(inputElementRef, ref);
@@ -39,7 +39,7 @@ export const ToggleSwitch = React.forwardRef((props, ref) => {
39
39
  'iui-disabled': disabled,
40
40
  'iui-label-on-right': label && labelPosition === 'right',
41
41
  'iui-label-on-left': label && labelPosition === 'left',
42
- }, className), style: style },
42
+ }, className), "data-iui-size": size, style: style },
43
43
  React.createElement("input", { className: 'iui-toggle-switch', type: 'checkbox', role: 'switch', disabled: disabled, ref: refs, ...rest }),
44
44
  icon &&
45
45
  React.cloneElement(icon, {
@@ -34,8 +34,8 @@ export { ExpandableBlock } from './ExpandableBlock';
34
34
  export type { ExpandableBlockProps } from './ExpandableBlock';
35
35
  export { Fieldset } from './Fieldset';
36
36
  export type { FieldsetProps } from './Fieldset';
37
- export { FileUpload, FileUploadTemplate } from './FileUpload';
38
- export type { FileUploadProps, FileUploadTemplateProps } from './FileUpload';
37
+ export { FileUpload, FileUploadTemplate, FileUploadCard, FileEmptyCard, } from './FileUpload';
38
+ export type { FileUploadProps, FileUploadTemplateProps, FileUploadCardProps, FileUploadCardIconProps, FileUploadCardInfoProps, FileUploadCardTitleProps, FileUploadCardDescriptionProps, FileUploadCardActionProps, FileUploadCardInputLabelProps, FileUploadCardInputProps, FileEmptyCardProps, FileEmptyCardIconProps, FileEmptyCardTextProps, } from './FileUpload';
39
39
  export { Footer, defaultFooterElements } from './Footer';
40
40
  export type { FooterProps, FooterElement, TitleTranslations } from './Footer';
41
41
  export { Header, HeaderBreadcrumbs, HeaderButton, HeaderLogo } from './Header';
package/esm/core/index.js CHANGED
@@ -20,7 +20,7 @@ export { DropdownMenu } from './DropdownMenu';
20
20
  export { ErrorPage, NonIdealState } from './NonIdealState';
21
21
  export { ExpandableBlock } from './ExpandableBlock';
22
22
  export { Fieldset } from './Fieldset';
23
- export { FileUpload, FileUploadTemplate } from './FileUpload';
23
+ export { FileUpload, FileUploadTemplate, FileUploadCard, FileEmptyCard, } from './FileUpload';
24
24
  export { Footer, defaultFooterElements } from './Footer';
25
25
  export { Header, HeaderBreadcrumbs, HeaderButton, HeaderLogo } from './Header';
26
26
  export { VerticalTabs, Tabs, Tab, HorizontalTabs } from './Tabs';
@@ -10,3 +10,4 @@ export * from './useSafeContext';
10
10
  export * from './useLatestRef';
11
11
  export * from './useIsomorphicLayoutEffect';
12
12
  export * from './useIsThemeAlreadySet';
13
+ export * from './useId';
@@ -14,3 +14,4 @@ export * from './useSafeContext';
14
14
  export * from './useLatestRef';
15
15
  export * from './useIsomorphicLayoutEffect';
16
16
  export * from './useIsThemeAlreadySet';
17
+ export * from './useId';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ /**
3
+ * Return custom useId function as a fallback for React.useId
4
+ */
5
+ export declare const useId: typeof React.useId;
@@ -0,0 +1,14 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ var _a;
6
+ import React from 'react';
7
+ import { getRandomValue } from '../functions/numbers';
8
+ /**
9
+ * Return custom useId function as a fallback for React.useId
10
+ */
11
+ export const useId = (_a = React.useId) !== null && _a !== void 0 ? _a : (() => {
12
+ const [id] = React.useState(() => `iui-${getRandomValue(10)}`);
13
+ return id;
14
+ });
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare const SvgDocument: (props: React.ComponentProps<'svg'>) => JSX.Element;
@@ -0,0 +1,9 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import * as React from 'react';
6
+ export const SvgDocument = (props) => {
7
+ return (React.createElement("svg", { viewBox: '0 0 16 16', ...props },
8
+ React.createElement("path", { d: 'M10 0H2v16h12V4h-4zm1 0v3h3z' })));
9
+ };
@@ -27,3 +27,4 @@ export * from './SvgNew';
27
27
  export * from './SvgFilter';
28
28
  export * from './SvgFilterHollow';
29
29
  export * from './SvgCalendar';
30
+ export * from './SvgDocument';
@@ -31,3 +31,4 @@ export * from './SvgNew';
31
31
  export * from './SvgFilter';
32
32
  export * from './SvgFilterHollow';
33
33
  export * from './SvgCalendar';
34
+ export * from './SvgDocument';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "main": "cjs/index.js",
@@ -62,7 +62,7 @@
62
62
  "dev:types": "concurrently \"tsc -p tsconfig.cjs.json --emitDeclarationOnly --watch --preserveWatchOutput\" \"tsc -p tsconfig.esm.json --emitDeclarationOnly --watch --preserveWatchOutput\""
63
63
  },
64
64
  "dependencies": {
65
- "@itwin/itwinui-css": "^1.6.0",
65
+ "@itwin/itwinui-css": "^1.7.0",
66
66
  "@itwin/itwinui-illustrations-react": "^2.0.0",
67
67
  "@itwin/itwinui-variables": "^2.0.0",
68
68
  "@tippyjs/react": "^4.2.6",