@itwin/itwinui-react 3.2.4 → 3.3.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/cjs/core/ComboBox/ComboBox.d.ts +3 -1
  3. package/cjs/core/ComboBox/ComboBox.js +3 -4
  4. package/cjs/core/ComboBox/ComboBoxInputContainer.js +1 -1
  5. package/cjs/core/Dialog/DialogContent.d.ts +1 -2
  6. package/cjs/core/Dialog/DialogContent.js +1 -42
  7. package/cjs/core/Dialog/DialogContext.d.ts +1 -0
  8. package/cjs/core/Dialog/DialogMain.js +2 -24
  9. package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +7 -4
  10. package/cjs/core/ExpandableBlock/ExpandableBlock.js +25 -12
  11. package/cjs/core/InputGrid/InputGrid.d.ts +7 -5
  12. package/cjs/core/InputGrid/InputGrid.js +175 -6
  13. package/cjs/core/InputGroup/InputGroup.d.ts +1 -1
  14. package/cjs/core/InputGroup/InputGroup.js +4 -13
  15. package/cjs/core/LabeledInput/LabeledInput.d.ts +1 -2
  16. package/cjs/core/LabeledInput/LabeledInput.js +11 -8
  17. package/cjs/core/LabeledSelect/LabeledSelect.d.ts +18 -0
  18. package/cjs/core/LabeledSelect/LabeledSelect.js +5 -20
  19. package/cjs/core/List/ListItem.d.ts +10 -0
  20. package/cjs/core/List/ListItem.js +14 -0
  21. package/cjs/core/Menu/MenuItem.d.ts +1 -1
  22. package/cjs/core/Modal/Modal.d.ts +3 -4
  23. package/cjs/core/Select/Select.js +2 -2
  24. package/cjs/core/StatusMessage/StatusMessage.d.ts +4 -2
  25. package/cjs/core/StatusMessage/StatusMessage.js +3 -1
  26. package/cjs/core/Table/Table.js +4 -0
  27. package/cjs/core/Table/TableCell.js +7 -22
  28. package/cjs/core/Table/columns/selectionColumn.d.ts +1 -1
  29. package/cjs/core/Table/columns/selectionColumn.js +3 -3
  30. package/cjs/core/Table/utils.d.ts +6 -0
  31. package/cjs/core/Table/utils.js +18 -1
  32. package/cjs/core/utils/components/InputWithIcon.d.ts +2 -0
  33. package/cjs/core/utils/components/InputWithIcon.js +11 -0
  34. package/cjs/core/utils/components/Portal.d.ts +5 -1
  35. package/cjs/core/utils/components/Portal.js +6 -2
  36. package/cjs/core/utils/components/index.d.ts +1 -0
  37. package/cjs/core/utils/components/index.js +1 -0
  38. package/esm/core/ComboBox/ComboBox.d.ts +3 -1
  39. package/esm/core/ComboBox/ComboBox.js +3 -3
  40. package/esm/core/ComboBox/ComboBoxInputContainer.js +2 -2
  41. package/esm/core/Dialog/DialogContent.d.ts +1 -2
  42. package/esm/core/Dialog/DialogContent.js +2 -17
  43. package/esm/core/Dialog/DialogContext.d.ts +1 -0
  44. package/esm/core/Dialog/DialogMain.js +3 -25
  45. package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +7 -4
  46. package/esm/core/ExpandableBlock/ExpandableBlock.js +26 -13
  47. package/esm/core/InputGrid/InputGrid.d.ts +7 -5
  48. package/esm/core/InputGrid/InputGrid.js +176 -7
  49. package/esm/core/InputGroup/InputGroup.d.ts +1 -1
  50. package/esm/core/InputGroup/InputGroup.js +5 -14
  51. package/esm/core/LabeledInput/LabeledInput.d.ts +1 -2
  52. package/esm/core/LabeledInput/LabeledInput.js +8 -9
  53. package/esm/core/LabeledSelect/LabeledSelect.d.ts +18 -0
  54. package/esm/core/LabeledSelect/LabeledSelect.js +5 -19
  55. package/esm/core/List/ListItem.d.ts +10 -0
  56. package/esm/core/List/ListItem.js +14 -0
  57. package/esm/core/Menu/MenuItem.d.ts +1 -1
  58. package/esm/core/Modal/Modal.d.ts +3 -4
  59. package/esm/core/Select/Select.js +3 -3
  60. package/esm/core/StatusMessage/StatusMessage.d.ts +4 -2
  61. package/esm/core/StatusMessage/StatusMessage.js +3 -1
  62. package/esm/core/Table/Table.js +5 -1
  63. package/esm/core/Table/TableCell.js +8 -23
  64. package/esm/core/Table/columns/selectionColumn.d.ts +1 -1
  65. package/esm/core/Table/columns/selectionColumn.js +3 -3
  66. package/esm/core/Table/utils.d.ts +6 -0
  67. package/esm/core/Table/utils.js +16 -0
  68. package/esm/core/utils/components/InputWithIcon.d.ts +2 -0
  69. package/esm/core/utils/components/InputWithIcon.js +8 -0
  70. package/esm/core/utils/components/Portal.d.ts +5 -1
  71. package/esm/core/utils/components/Portal.js +6 -2
  72. package/esm/core/utils/components/index.d.ts +1 -0
  73. package/esm/core/utils/components/index.js +1 -0
  74. package/package.json +3 -3
  75. package/styles.css +10 -10
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import * as React from 'react';
6
6
  import cx from 'classnames';
7
- import { getCellStyle, getStickyStyle } from './utils.js';
7
+ import { getCellStyle, getStickyStyle, getSubRowStyle } from './utils.js';
8
8
  import { SubRowExpander } from './SubRowExpander.js';
9
9
  import { SELECTION_CELL_ID } from './columns/index.js';
10
10
  import { DefaultCell } from './cells/index.js';
@@ -13,34 +13,19 @@ export const TableCell = (props) => {
13
13
  const { cell, cellIndex, isDisabled, tableHasSubRows, tableInstance, expanderCell, density, } = props;
14
14
  const hasSubRowExpander = cellIndex ===
15
15
  cell.row.cells.findIndex((c) => c.column.id !== SELECTION_CELL_ID);
16
- const getSubRowStyle = () => {
17
- if (!tableHasSubRows || !hasSubRowExpander) {
18
- return undefined;
19
- }
20
- // If it doesn't have sub-rows then shift by another level to align with expandable rows on the same depth
21
- const dynamicMargin = cell.row.depth + (cell.row.canExpand ? 0 : 1);
22
- let cellPadding = 16;
23
- let expanderMargin = 8;
24
- if (density === 'condensed') {
25
- cellPadding = 12;
26
- expanderMargin = 4;
27
- }
28
- else if (density === 'extra-condensed') {
29
- cellPadding = 8;
30
- expanderMargin = 4;
31
- }
32
- const multiplier = 26 + expanderMargin; // 26 = expander width
33
- return {
34
- paddingInlineStart: cellPadding + dynamicMargin * multiplier,
35
- };
36
- };
37
16
  const cellElementProps = cell.getCellProps({
38
17
  className: cx('iui-table-cell', cell.column.cellClassName, {
39
18
  'iui-table-cell-sticky': !!cell.column.sticky,
40
19
  }),
41
20
  style: {
42
21
  ...getCellStyle(cell.column, !!tableInstance.state.isTableResizing),
43
- ...getSubRowStyle(),
22
+ ...(tableHasSubRows &&
23
+ hasSubRowExpander &&
24
+ getSubRowStyle({
25
+ density,
26
+ // If it doesn't have sub-rows then shift by another level to align with expandable rows on the same depth
27
+ depth: cell.row.depth + (cell.row.canExpand ? 0 : 1),
28
+ })),
44
29
  ...getStickyStyle(cell.column, tableInstance.visibleColumns),
45
30
  },
46
31
  });
@@ -27,7 +27,7 @@ export declare const SelectionColumn: <T extends Record<string, unknown>>(props?
27
27
  maxWidth: number;
28
28
  columnClassName: string;
29
29
  cellClassName: string;
30
- Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows, initialRows, state, }: HeaderProps<T>) => React.JSX.Element;
30
+ Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows, preFilteredFlatRows, state, }: HeaderProps<T>) => React.JSX.Element;
31
31
  Cell: ({ row }: CellProps<T>) => React.JSX.Element;
32
32
  cellRenderer: (props: CellRendererProps<T>) => React.JSX.Element;
33
33
  };
@@ -31,9 +31,9 @@ export const SelectionColumn = (props = {}) => {
31
31
  maxWidth: densityWidth,
32
32
  columnClassName: 'iui-slot',
33
33
  cellClassName: 'iui-slot',
34
- Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows, initialRows, state, }) => {
35
- const disabled = rows.every((row) => isDisabled?.(row.original));
36
- const checked = initialRows.every((row) => state.selectedRowIds[row.id] || isDisabled?.(row.original));
34
+ Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows, preFilteredFlatRows, state, }) => {
35
+ const disabled = preFilteredFlatRows.every((row) => isDisabled?.(row.original));
36
+ const checked = preFilteredFlatRows.every((row) => state.selectedRowIds[row.id] || isDisabled?.(row.original));
37
37
  const indeterminate = !checked && Object.keys(state.selectedRowIds).length > 0;
38
38
  return (React.createElement(Checkbox, { ...getToggleAllRowsSelectedProps(), style: {}, title: '' // Removes default title that comes from react-table
39
39
  , checked: checked && !disabled, indeterminate: indeterminate, disabled: disabled, onChange: () => toggleAllRowsSelected(!rows.some((row) => row.isSelected)) }));
@@ -1,3 +1,9 @@
1
1
  import type { ColumnInstance } from '../../react-table/react-table.js';
2
2
  export declare const getCellStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, isTableResizing: boolean) => React.CSSProperties | undefined;
3
3
  export declare const getStickyStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, columnList: ColumnInstance<T>[]) => React.CSSProperties;
4
+ export declare const getSubRowStyle: ({ density, depth }: {
5
+ density?: string | undefined;
6
+ depth?: number | undefined;
7
+ }) => {
8
+ paddingInlineStart: number;
9
+ };
@@ -43,3 +43,19 @@ export const getStickyStyle = (column, columnList) => {
43
43
  '--iui-table-sticky-right': column.sticky === 'right' ? `${right}px` : undefined,
44
44
  };
45
45
  };
46
+ export const getSubRowStyle = ({ density = 'default', depth = 1 }) => {
47
+ let cellPadding = 16;
48
+ let expanderMargin = 8;
49
+ if (density === 'condensed') {
50
+ cellPadding = 12;
51
+ expanderMargin = 4;
52
+ }
53
+ else if (density === 'extra-condensed') {
54
+ cellPadding = 8;
55
+ expanderMargin = 4;
56
+ }
57
+ const multiplier = 26 + expanderMargin; // 26 = expander width
58
+ return {
59
+ paddingInlineStart: cellPadding + depth * multiplier,
60
+ };
61
+ };
@@ -0,0 +1,2 @@
1
+ /** @private */
2
+ export declare const InputWithIcon: import("../props.js").PolymorphicForwardRefComponent<"div", {}>;
@@ -0,0 +1,8 @@
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 { polymorphic } from '../functions/polymorphic.js';
6
+ /** @private */
7
+ export const InputWithIcon = polymorphic.div('iui-input-with-icon');
8
+ InputWithIcon.displayName = 'InputWithIcon';
@@ -9,10 +9,12 @@ export type PortalProps = {
9
9
  *
10
10
  * Otherwise, it will portal to the element passed to `to`.
11
11
  *
12
+ * If `to`/`to()` === `null`/`undefined`, the default behavior will be used (i.e. as if `portal` is not passed).
13
+ *
12
14
  * @default true
13
15
  */
14
16
  portal?: boolean | {
15
- to: HTMLElement | (() => HTMLElement);
17
+ to: HTMLElement | null | undefined | (() => HTMLElement | null | undefined);
16
18
  };
17
19
  };
18
20
  /**
@@ -21,6 +23,8 @@ export type PortalProps = {
21
23
  * - if `portal` is set to true, renders into nearest ThemeContext.portalContainer
22
24
  * - if `portal` is set to false, renders as-is without portal
23
25
  * - otherwise renders into `portal.to` (can be an element or a function)
26
+ * - If `to`/`to()` === `null`/`undefined`, the default behavior will be used (i.e. as if `portal` is not passed).
27
+ * - E.g. `portal={{ to: () => document.querySelector('.may-not-exist') }}`.
24
28
  *
25
29
  * @private
26
30
  */
@@ -14,6 +14,8 @@ import { useIsClient } from '../hooks/useIsClient.js';
14
14
  * - if `portal` is set to true, renders into nearest ThemeContext.portalContainer
15
15
  * - if `portal` is set to false, renders as-is without portal
16
16
  * - otherwise renders into `portal.to` (can be an element or a function)
17
+ * - If `to`/`to()` === `null`/`undefined`, the default behavior will be used (i.e. as if `portal` is not passed).
18
+ * - E.g. `portal={{ to: () => document.querySelector('.may-not-exist') }}`.
17
19
  *
18
20
  * @private
19
21
  */
@@ -29,8 +31,10 @@ export const Portal = (props) => {
29
31
  // ----------------------------------------------------------------------------
30
32
  const usePortalTo = (portal) => {
31
33
  const themeInfo = React.useContext(ThemeContext);
34
+ const defaultPortalTo = themeInfo?.portalContainer ?? getDocument()?.body;
32
35
  if (typeof portal === 'boolean') {
33
- return portal ? themeInfo?.portalContainer ?? getDocument()?.body : null;
36
+ return portal ? defaultPortalTo : null;
34
37
  }
35
- return typeof portal.to === 'function' ? portal.to() : portal.to;
38
+ const portalTo = typeof portal.to === 'function' ? portal.to() : portal.to;
39
+ return portalTo ?? defaultPortalTo;
36
40
  };
@@ -2,6 +2,7 @@ export * from './Resizer.js';
2
2
  export * from './FocusTrap.js';
3
3
  export * from './InputContainer.js';
4
4
  export * from './InputFlexContainer.js';
5
+ export * from './InputWithIcon.js';
5
6
  export * from './WithCSSTransition.js';
6
7
  export * from './MiddleTextTruncation.js';
7
8
  export * from './VirtualScroll.js';
@@ -6,6 +6,7 @@ export * from './Resizer.js';
6
6
  export * from './FocusTrap.js';
7
7
  export * from './InputContainer.js';
8
8
  export * from './InputFlexContainer.js';
9
+ export * from './InputWithIcon.js';
9
10
  export * from './WithCSSTransition.js';
10
11
  export * from './MiddleTextTruncation.js';
11
12
  export * from './VirtualScroll.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "3.2.4",
3
+ "version": "3.3.1",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -85,7 +85,7 @@
85
85
  "tslib": "^2.6.0"
86
86
  },
87
87
  "devDependencies": {
88
- "@itwin/itwinui-css": "^2.1.0",
88
+ "@itwin/itwinui-css": "^2.2.1",
89
89
  "@itwin/itwinui-variables": "3.0.0",
90
90
  "@swc/cli": "^0.1.62",
91
91
  "@swc/core": "^1.3.68",
@@ -112,7 +112,7 @@
112
112
  "ts-jest": "^29.0.0",
113
113
  "ts-node": "^10.0.0",
114
114
  "typescript": "~5.1.6",
115
- "vite": "^4.5.1"
115
+ "vite": "^5.0.12"
116
116
  },
117
117
  "peerDependencies": {
118
118
  "react": ">= 17.0.0 < 19.0.0",