@itwin/itwinui-react 3.18.3 → 3.19.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 (133) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/DEV-cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
  3. package/DEV-cjs/core/Menu/MenuItem.js +8 -7
  4. package/DEV-cjs/core/Select/Select.js +18 -10
  5. package/DEV-cjs/core/SideNavigation/SideNavigation.js +2 -2
  6. package/DEV-cjs/core/Table/ColumnHeader.js +7 -3
  7. package/DEV-cjs/core/Table/Table.js +65 -5
  8. package/DEV-cjs/core/Table/cells/DefaultCell.js +14 -9
  9. package/DEV-cjs/core/Table/columns/actionColumn.js +1 -0
  10. package/DEV-cjs/core/Table/columns/expanderColumn.js +25 -20
  11. package/DEV-cjs/core/Table/columns/selectionColumn.js +14 -8
  12. package/DEV-cjs/core/Table/hooks/useExpanderCell.js +10 -6
  13. package/DEV-cjs/core/Tag/Tag.js +8 -2
  14. package/DEV-cjs/core/ThemeProvider/ThemeProvider.js +46 -46
  15. package/DEV-cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
  16. package/DEV-cjs/styles.js +1 -1
  17. package/DEV-cjs/utils/components/index.js +1 -1
  18. package/DEV-cjs/utils/components/lineClamp.js +23 -0
  19. package/DEV-cjs/utils/functions/react.js +18 -4
  20. package/DEV-cjs/utils/hooks/useControlledState.js +5 -1
  21. package/DEV-cjs/utils/providers/FutureFlagsProvider.js +48 -0
  22. package/DEV-cjs/utils/providers/index.js +1 -0
  23. package/DEV-esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
  24. package/DEV-esm/core/Menu/MenuItem.js +8 -7
  25. package/DEV-esm/core/Select/Select.js +19 -10
  26. package/DEV-esm/core/SideNavigation/SideNavigation.js +2 -2
  27. package/DEV-esm/core/Table/ColumnHeader.js +8 -4
  28. package/DEV-esm/core/Table/Table.js +65 -5
  29. package/DEV-esm/core/Table/cells/DefaultCell.js +15 -10
  30. package/DEV-esm/core/Table/columns/actionColumn.js +1 -0
  31. package/DEV-esm/core/Table/columns/expanderColumn.js +25 -20
  32. package/DEV-esm/core/Table/columns/selectionColumn.js +14 -8
  33. package/DEV-esm/core/Table/hooks/useExpanderCell.js +10 -6
  34. package/DEV-esm/core/Tag/Tag.js +11 -3
  35. package/DEV-esm/core/ThemeProvider/ThemeProvider.js +48 -42
  36. package/DEV-esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
  37. package/DEV-esm/styles.js +1 -1
  38. package/DEV-esm/utils/components/index.js +1 -1
  39. package/DEV-esm/utils/components/lineClamp.js +13 -0
  40. package/DEV-esm/utils/functions/react.js +6 -1
  41. package/DEV-esm/utils/hooks/useControlledState.js +5 -1
  42. package/DEV-esm/utils/providers/FutureFlagsProvider.js +28 -0
  43. package/DEV-esm/utils/providers/index.js +1 -0
  44. package/cjs/core/Buttons/DropdownButton.d.ts +1 -1
  45. package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
  46. package/cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
  47. package/cjs/core/DropdownMenu/DropdownMenu.d.ts +1 -1
  48. package/cjs/core/Menu/MenuItem.d.ts +7 -1
  49. package/cjs/core/Menu/MenuItem.js +8 -7
  50. package/cjs/core/Popover/Popover.d.ts +5 -3
  51. package/cjs/core/Select/Select.js +18 -10
  52. package/cjs/core/SideNavigation/SideNavigation.js +2 -2
  53. package/cjs/core/Table/ColumnHeader.js +7 -3
  54. package/cjs/core/Table/Table.d.ts +2 -2
  55. package/cjs/core/Table/Table.js +65 -5
  56. package/cjs/core/Table/cells/DefaultCell.js +14 -9
  57. package/cjs/core/Table/columns/actionColumn.d.ts +1 -0
  58. package/cjs/core/Table/columns/actionColumn.js +1 -0
  59. package/cjs/core/Table/columns/expanderColumn.d.ts +2 -2
  60. package/cjs/core/Table/columns/expanderColumn.js +25 -20
  61. package/cjs/core/Table/columns/selectionColumn.d.ts +2 -2
  62. package/cjs/core/Table/columns/selectionColumn.js +14 -8
  63. package/cjs/core/Table/hooks/useExpanderCell.js +10 -6
  64. package/cjs/core/Tabs/Tabs.d.ts +4 -1
  65. package/cjs/core/Tag/Tag.js +8 -2
  66. package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -2
  67. package/cjs/core/ThemeProvider/ThemeProvider.d.ts +8 -18
  68. package/cjs/core/ThemeProvider/ThemeProvider.js +46 -46
  69. package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
  70. package/cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
  71. package/cjs/styles.js +1 -1
  72. package/cjs/utils/components/index.d.ts +1 -1
  73. package/cjs/utils/components/index.js +1 -1
  74. package/cjs/utils/components/lineClamp.d.ts +5 -0
  75. package/cjs/utils/components/lineClamp.js +23 -0
  76. package/cjs/utils/functions/react.d.ts +5 -0
  77. package/cjs/utils/functions/react.js +18 -4
  78. package/cjs/utils/hooks/useControlledState.d.ts +5 -2
  79. package/cjs/utils/hooks/useControlledState.js +5 -1
  80. package/cjs/utils/hooks/useGlobals.d.ts +0 -1
  81. package/cjs/utils/providers/FutureFlagsProvider.d.ts +37 -0
  82. package/cjs/utils/providers/FutureFlagsProvider.js +48 -0
  83. package/cjs/utils/providers/index.d.ts +1 -0
  84. package/cjs/utils/providers/index.js +1 -0
  85. package/esm/core/Buttons/DropdownButton.d.ts +1 -1
  86. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
  87. package/esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
  88. package/esm/core/DropdownMenu/DropdownMenu.d.ts +1 -1
  89. package/esm/core/Menu/MenuItem.d.ts +7 -1
  90. package/esm/core/Menu/MenuItem.js +8 -7
  91. package/esm/core/Popover/Popover.d.ts +5 -3
  92. package/esm/core/Select/Select.js +19 -10
  93. package/esm/core/SideNavigation/SideNavigation.js +2 -2
  94. package/esm/core/Table/ColumnHeader.js +8 -4
  95. package/esm/core/Table/Table.d.ts +2 -2
  96. package/esm/core/Table/Table.js +65 -5
  97. package/esm/core/Table/cells/DefaultCell.js +15 -10
  98. package/esm/core/Table/columns/actionColumn.d.ts +1 -0
  99. package/esm/core/Table/columns/actionColumn.js +1 -0
  100. package/esm/core/Table/columns/expanderColumn.d.ts +2 -2
  101. package/esm/core/Table/columns/expanderColumn.js +25 -20
  102. package/esm/core/Table/columns/selectionColumn.d.ts +2 -2
  103. package/esm/core/Table/columns/selectionColumn.js +14 -8
  104. package/esm/core/Table/hooks/useExpanderCell.js +10 -6
  105. package/esm/core/Tabs/Tabs.d.ts +4 -1
  106. package/esm/core/Tag/Tag.js +11 -3
  107. package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -2
  108. package/esm/core/ThemeProvider/ThemeProvider.d.ts +8 -18
  109. package/esm/core/ThemeProvider/ThemeProvider.js +48 -42
  110. package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
  111. package/esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
  112. package/esm/styles.js +1 -1
  113. package/esm/utils/components/index.d.ts +1 -1
  114. package/esm/utils/components/index.js +1 -1
  115. package/esm/utils/components/lineClamp.d.ts +5 -0
  116. package/esm/utils/components/lineClamp.js +13 -0
  117. package/esm/utils/functions/react.d.ts +5 -0
  118. package/esm/utils/functions/react.js +6 -1
  119. package/esm/utils/hooks/useControlledState.d.ts +5 -2
  120. package/esm/utils/hooks/useControlledState.js +5 -1
  121. package/esm/utils/hooks/useGlobals.d.ts +0 -1
  122. package/esm/utils/providers/FutureFlagsProvider.d.ts +37 -0
  123. package/esm/utils/providers/FutureFlagsProvider.js +28 -0
  124. package/esm/utils/providers/index.d.ts +1 -0
  125. package/esm/utils/providers/index.js +1 -0
  126. package/package.json +11 -5
  127. package/styles.css +10 -10
  128. package/DEV-cjs/utils/components/LineClamp.js +0 -50
  129. package/DEV-esm/utils/components/LineClamp.js +0 -36
  130. package/cjs/utils/components/LineClamp.d.ts +0 -5
  131. package/cjs/utils/components/LineClamp.js +0 -50
  132. package/esm/utils/components/LineClamp.d.ts +0 -5
  133. package/esm/utils/components/LineClamp.js +0 -36
@@ -100,6 +100,38 @@ const Table = (props) => {
100
100
  caption = 'Table',
101
101
  role,
102
102
  scrollToRow,
103
+ useControlledState,
104
+ autoResetExpanded,
105
+ autoResetFilters,
106
+ autoResetGlobalFilter,
107
+ autoResetHiddenColumns,
108
+ autoResetPage,
109
+ autoResetResize,
110
+ autoResetSelectedRows,
111
+ autoResetSortBy,
112
+ defaultCanFilter,
113
+ defaultCanSort,
114
+ defaultColumn: defaultColumnProp,
115
+ disableFilters,
116
+ disableGlobalFilter,
117
+ disableMultiSort,
118
+ disableSortRemove,
119
+ disabledMultiRemove,
120
+ expandSubRows,
121
+ globalFilter,
122
+ initialState,
123
+ isMultiSortEvent,
124
+ manualExpandedKey,
125
+ manualFilters,
126
+ manualGlobalFilter,
127
+ manualRowSelectedKey,
128
+ manualSortBy,
129
+ maxMultiSortColCount,
130
+ orderByFn,
131
+ pageCount,
132
+ sortTypes,
133
+ manualPagination,
134
+ paginateExpandedRows,
103
135
  ..._rest
104
136
  } = props;
105
137
  let { ariaRestAttributes, nonAriaRestAttributes } = _react.useMemo(
@@ -140,8 +172,9 @@ const Table = (props) => {
140
172
  maxWidth: 0,
141
173
  minWidth: 0,
142
174
  width: 0,
175
+ ...defaultColumnProp,
143
176
  }),
144
- [],
177
+ [defaultColumnProp],
145
178
  );
146
179
  let rowHeight = _react.useMemo(() => {
147
180
  if ('condensed' === density) return 50;
@@ -295,9 +328,36 @@ const Table = (props) => {
295
328
  );
296
329
  let instance = (0, _reacttable.useTable)(
297
330
  {
298
- manualPagination: !paginatorRenderer,
299
- paginateExpandedRows: false,
300
- ...props,
331
+ manualPagination: manualPagination ?? !paginatorRenderer,
332
+ paginateExpandedRows: paginateExpandedRows ?? false,
333
+ useControlledState,
334
+ autoResetExpanded,
335
+ autoResetFilters,
336
+ autoResetGlobalFilter,
337
+ autoResetHiddenColumns,
338
+ autoResetPage,
339
+ autoResetResize,
340
+ autoResetSelectedRows,
341
+ autoResetSortBy,
342
+ defaultCanFilter,
343
+ defaultCanSort,
344
+ disableFilters,
345
+ disableGlobalFilter,
346
+ disableMultiSort,
347
+ disableSortRemove,
348
+ disabledMultiRemove,
349
+ expandSubRows,
350
+ globalFilter,
351
+ isMultiSortEvent,
352
+ manualExpandedKey,
353
+ manualFilters,
354
+ manualGlobalFilter,
355
+ manualRowSelectedKey,
356
+ manualSortBy,
357
+ maxMultiSortColCount,
358
+ orderByFn,
359
+ pageCount: pageCount ?? -1,
360
+ sortTypes,
301
361
  columns,
302
362
  defaultColumn,
303
363
  disableSortBy: !isSortable,
@@ -308,7 +368,7 @@ const Table = (props) => {
308
368
  getSubRows: subComponent ? getSubRowsWithSubComponents : getSubRows,
309
369
  initialState: {
310
370
  pageSize,
311
- ...props.initialState,
371
+ ...initialState,
312
372
  },
313
373
  columnResizeMode,
314
374
  getRowId: subComponent ? getRowIdWithSubComponents : getRowId,
@@ -37,6 +37,10 @@ const DefaultCell = (props) => {
37
37
  );
38
38
  let isCellRendererChildrenCustom =
39
39
  _react.useContext(DefaultCellRendererPropsChildren) !== props.children;
40
+ let isDefaultTextCell =
41
+ 'string' == typeof props.cellProps.value &&
42
+ !isCustomCell &&
43
+ !isCellRendererChildrenCustom;
40
44
  let {
41
45
  cellElementProps: {
42
46
  className: cellElementClassName,
@@ -51,9 +55,7 @@ const DefaultCell = (props) => {
51
55
  className,
52
56
  style,
53
57
  status,
54
- clamp = 'string' == typeof cellProps.value &&
55
- !isCustomCell &&
56
- !isCellRendererChildrenCustom,
58
+ clamp = isDefaultTextCell,
57
59
  ...rest
58
60
  } = props;
59
61
  let { key: cellElementKey, ...cellElementPropsRest } = cellElementProps;
@@ -84,12 +86,14 @@ const DefaultCell = (props) => {
84
86
  _react.createElement(
85
87
  TableCellContent,
86
88
  {
87
- shouldRenderWrapper: isCellRendererChildrenCustom,
89
+ shouldRenderWrapper: isDefaultTextCell,
88
90
  },
89
91
  clamp
90
92
  ? _react.createElement(
91
- _index.LineClamp,
92
- null,
93
+ 'div',
94
+ {
95
+ className: _index.lineClamp.className,
96
+ },
93
97
  _react.createElement('slot', null),
94
98
  )
95
99
  : _react.createElement('slot', null),
@@ -129,15 +133,15 @@ if ('development' === process.env.NODE_ENV)
129
133
  const TableCellContent = (props) => {
130
134
  let { children, shouldRenderWrapper } = props;
131
135
  return shouldRenderWrapper
132
- ? children
133
- : _react.createElement(
136
+ ? _react.createElement(
134
137
  'div',
135
138
  {
136
139
  className: '_iui-table-cell-default-content',
137
140
  onClick: (e) => e.stopPropagation(),
138
141
  },
139
142
  children,
140
- );
143
+ )
144
+ : children;
141
145
  };
142
146
  const css = `
143
147
  ._iui-table-cell-default-content {
@@ -151,4 +155,5 @@ const css = `
151
155
  inset: -6px;
152
156
  z-index: -1;
153
157
  }
158
+ ${_index.lineClamp.css}
154
159
  `;
@@ -28,6 +28,7 @@ type ActionColumnProps = {
28
28
  export declare const ActionColumn: <T extends Record<string, unknown>>({ columnManager, }?: ActionColumnProps) => {
29
29
  id: string;
30
30
  disableResizing: boolean;
31
+ canResize: boolean;
31
32
  disableGroupBy: boolean;
32
33
  minWidth: number;
33
34
  width: number;
@@ -23,6 +23,7 @@ const ACTION_CELL_ID = 'iui-table-action';
23
23
  const ActionColumn = ({ columnManager = false } = {}) => ({
24
24
  id: ACTION_CELL_ID,
25
25
  disableResizing: true,
26
+ canResize: false,
26
27
  disableGroupBy: true,
27
28
  minWidth: 48,
28
29
  width: 48,
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { CellProps, CellRendererProps, Row } from '../../../react-table/react-table.js';
2
+ import type { CellRendererProps, Row } from '../../../react-table/react-table.js';
3
3
  export declare const EXPANDER_CELL_ID = "iui-table-expander";
4
4
  /**
5
5
  * Expander column that adds sub-content expander column to the Table.
@@ -39,6 +39,6 @@ export declare const ExpanderColumn: <T extends Record<string, unknown>>(props?:
39
39
  maxWidth: number;
40
40
  columnClassName: string;
41
41
  cellClassName: string;
42
- Cell: (props: CellProps<T>) => React.JSX.Element | null;
42
+ Cell: () => null;
43
43
  cellRenderer: (props: CellRendererProps<T>) => React.JSX.Element;
44
44
  };
@@ -35,30 +35,35 @@ const ExpanderColumn = (props = {}) => {
35
35
  maxWidth: 48,
36
36
  columnClassName: 'iui-slot',
37
37
  cellClassName: 'iui-slot',
38
- Cell: (props) => {
39
- let { row } = props;
40
- if (!subComponent?.(row)) return null;
38
+ Cell: () => null,
39
+ cellRenderer: (props) => {
40
+ let { row } = props.cellProps;
41
+ let children = subComponent?.(row)
42
+ ? _react.createElement(
43
+ _IconButton.IconButton,
44
+ {
45
+ 'aria-label': 'Toggle expandable content',
46
+ className: 'iui-table-row-expander',
47
+ styleType: 'borderless',
48
+ size: 'small',
49
+ onClick: (e) => {
50
+ e.stopPropagation();
51
+ row.toggleRowExpanded();
52
+ },
53
+ disabled: isDisabled?.(row.original),
54
+ 'aria-expanded': row.isExpanded,
55
+ },
56
+ _react.createElement(_index.SvgChevronRight, null),
57
+ )
58
+ : null;
41
59
  return _react.createElement(
42
- _IconButton.IconButton,
60
+ _index1.DefaultCell,
43
61
  {
44
- 'aria-label': 'Toggle expandable content',
45
- className: 'iui-table-row-expander',
46
- styleType: 'borderless',
47
- size: 'small',
48
- onClick: (e) => {
49
- e.stopPropagation();
50
- row.toggleRowExpanded();
51
- },
52
- disabled: isDisabled?.(props.row.original),
53
- 'aria-expanded': row.isExpanded,
62
+ ...props,
63
+ isDisabled: (rowData) => !!isDisabled?.(rowData),
54
64
  },
55
- _react.createElement(_index.SvgChevronRight, null),
65
+ children,
56
66
  );
57
67
  },
58
- cellRenderer: (props) =>
59
- _react.createElement(_index1.DefaultCell, {
60
- ...props,
61
- isDisabled: (rowData) => !!isDisabled?.(rowData),
62
- }),
63
68
  };
64
69
  };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { CellProps, CellRendererProps, HeaderProps } from '../../../react-table/react-table.js';
2
+ import type { CellRendererProps, HeaderProps } from '../../../react-table/react-table.js';
3
3
  export declare const SELECTION_CELL_ID = "iui-table-checkbox-selector";
4
4
  /**
5
5
  * Selection column that adds selection checkbox column to the Table.
@@ -28,6 +28,6 @@ export declare const SelectionColumn: <T extends Record<string, unknown>>(props?
28
28
  columnClassName: string;
29
29
  cellClassName: string;
30
30
  Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows, preFilteredFlatRows, state, }: HeaderProps<T>) => React.JSX.Element;
31
- Cell: ({ row, selectSubRows }: CellProps<T>) => React.JSX.Element;
31
+ Cell: () => null;
32
32
  cellRenderer: (props: CellRendererProps<T>) => React.JSX.Element;
33
33
  };
@@ -64,8 +64,10 @@ const SelectionColumn = (props = {}) => {
64
64
  onChange: () => toggleAllRowsSelected(nextToggleState),
65
65
  });
66
66
  },
67
- Cell: ({ row, selectSubRows = true }) =>
68
- _react.createElement(_Checkbox.Checkbox, {
67
+ Cell: () => null,
68
+ cellRenderer: (props) => {
69
+ let { row, selectSubRows = true } = props.cellProps;
70
+ let children = _react.createElement(_Checkbox.Checkbox, {
69
71
  ...row.getToggleRowSelectedProps(),
70
72
  style: {},
71
73
  title: '',
@@ -85,11 +87,15 @@ const SelectionColumn = (props = {}) => {
85
87
  );
86
88
  else row.toggleRowSelected(!row.isSelected);
87
89
  },
88
- }),
89
- cellRenderer: (props) =>
90
- _react.createElement(_index.DefaultCell, {
91
- ...props,
92
- isDisabled: (rowData) => !!isDisabled?.(rowData),
93
- }),
90
+ });
91
+ return _react.createElement(
92
+ _index.DefaultCell,
93
+ {
94
+ ...props,
95
+ isDisabled: (rowData) => !!isDisabled?.(rowData),
96
+ },
97
+ children,
98
+ );
99
+ },
94
100
  };
95
101
  };
@@ -11,6 +11,7 @@ Object.defineProperty(exports, 'useExpanderCell', {
11
11
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
12
12
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
13
13
  const _index = require('../columns/index.js');
14
+ const _DefaultCell = require('../cells/DefaultCell.js');
14
15
  const useExpanderCell =
15
16
  (subComponent, expanderCell, isRowDisabled) => (hooks) => {
16
17
  if (!subComponent) return;
@@ -26,14 +27,17 @@ const useExpanderCell =
26
27
  return [
27
28
  {
28
29
  ...expanderColumn,
29
- Cell: expanderCell
30
- ? (cellProps) =>
30
+ cellRenderer: expanderCell
31
+ ? (props) =>
31
32
  _react.createElement(
32
- _react.Fragment,
33
- null,
34
- expanderCell(cellProps),
33
+ _DefaultCell.DefaultCell,
34
+ {
35
+ ...props,
36
+ isDisabled: (rowData) => !!isRowDisabled?.(rowData),
37
+ },
38
+ expanderCell(props.cellProps),
35
39
  )
36
- : expanderColumn.Cell,
40
+ : expanderColumn.cellRenderer,
37
41
  },
38
42
  ...columns,
39
43
  ];
@@ -42,9 +42,12 @@ type TabsWrapperOwnProps = {
42
42
  */
43
43
  value?: string;
44
44
  /**
45
- * Function that gets called when active tab is changed.
45
+ * Function that gets called when active tab *changes* (uncontrolled mode) or should *change* (controlled mode).
46
46
  *
47
47
  * Should be used alongside `value` prop.
48
+ *
49
+ * If need to listen to each tab click, use `onClick` prop on `Tabs.Tab`.
50
+ * Similarly, for each focus, use `onFocus` prop on `Tabs.Tab`.
48
51
  */
49
52
  onValueChange?: (value: string) => void;
50
53
  /**
@@ -53,8 +53,11 @@ const Tag = _react.forwardRef((props, forwardedRef) => {
53
53
  _index.Box,
54
54
  {
55
55
  as: shouldUseLinkAction ? _LinkAction.LinkAction : 'span',
56
- onClick: shouldUseLinkAction ? onClick : void 0,
57
56
  ...labelProps,
57
+ onClick: (0, _index.mergeEventHandlers)(
58
+ labelProps?.onClick,
59
+ shouldUseLinkAction ? onClick : void 0,
60
+ ),
58
61
  className: (0, _classnames.default)(
59
62
  'iui-tag-label',
60
63
  labelProps?.className,
@@ -69,9 +72,12 @@ const Tag = _react.forwardRef((props, forwardedRef) => {
69
72
  {
70
73
  styleType: 'borderless',
71
74
  size: 'small',
72
- onClick: onRemove,
73
75
  'aria-label': 'Delete tag',
74
76
  ...removeButtonProps,
77
+ onClick: (0, _index.mergeEventHandlers)(
78
+ removeButtonProps?.onClick,
79
+ onRemove,
80
+ ),
75
81
  className: (0, _classnames.default)(
76
82
  'iui-tag-button',
77
83
  removeButtonProps?.className,
@@ -1,8 +1,7 @@
1
1
  import * as React from 'react';
2
- import type { FutureOptions, ThemeOptions, ThemeType } from './ThemeProvider.js';
2
+ import type { ThemeOptions, ThemeType } from './ThemeProvider.js';
3
3
  export declare const ThemeContext: React.Context<{
4
4
  theme?: ThemeType;
5
5
  themeOptions?: ThemeOptions;
6
6
  portalContainer?: HTMLElement | null;
7
- future?: FutureOptions;
8
7
  } | undefined>;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
2
+ import type { FutureOptions, PolymorphicForwardRefComponent } from '../../utils/index.js';
3
3
  export type ThemeOptions = {
4
4
  /**
5
5
  * Whether to apply high-contrast versions of light and dark themes.
@@ -7,18 +7,6 @@ export type ThemeOptions = {
7
7
  */
8
8
  highContrast?: boolean;
9
9
  };
10
- export type FutureOptions = {
11
- /**
12
- * @alpha
13
- *
14
- * If enabled, the theme resembles the future iTwinUI version's theme (including alphas) *whenever possible*.
15
- *
16
- * This is useful in making apps looks like future versions of iTwinUI to help with incremental adoption.
17
- *
18
- * **NOTE**: Since this is a theme bridge to *future* versions, the theme could have breaking changes.
19
- */
20
- themeBridge?: boolean;
21
- };
22
10
  export type ThemeType = 'light' | 'dark' | 'os';
23
11
  type RootProps = {
24
12
  /**
@@ -53,12 +41,8 @@ type RootProps = {
53
41
  */
54
42
  applyBackground?: boolean;
55
43
  };
56
- /**
57
- * Options to help with early adoption of features from future versions.
58
- */
59
- future?: FutureOptions;
60
44
  };
61
- type ThemeProviderOwnProps = Pick<RootProps, 'theme' | 'future'> & {
45
+ type ThemeProviderOwnProps = Pick<RootProps, 'theme'> & {
62
46
  themeOptions?: RootProps['themeOptions'];
63
47
  children: Required<React.ReactNode>;
64
48
  /**
@@ -89,6 +73,12 @@ type ThemeProviderOwnProps = Pick<RootProps, 'theme' | 'future'> & {
89
73
  * If true or false is passed, it will override the default behavior.
90
74
  */
91
75
  includeCss?: boolean;
76
+ /**
77
+ * Options to help with early adoption of features from future versions.
78
+ *
79
+ * All future options will be automatically inherited across nested ThemeProviders, unless explicitly overridden.
80
+ */
81
+ future?: true | FutureOptions;
92
82
  };
93
83
  /**
94
84
  * This component provides global state and applies theme to the entire tree
@@ -24,14 +24,14 @@ const _meta = require('../../utils/meta.js');
24
24
  const versionWithoutDots = _meta.meta.version.replace(/\./g, '');
25
25
  const OwnerDocumentContext = _react.createContext(void 0);
26
26
  const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
27
- var _themeOptions, _themeOptions1, _future;
27
+ var _themeOptions, _themeOptions1;
28
28
  let {
29
29
  theme: themeProp = 'inherit',
30
30
  children,
31
31
  themeOptions = {},
32
32
  portalContainer: portalContainerProp,
33
33
  includeCss = 'inherit' === themeProp,
34
- future = {},
34
+ future: futureProp = {},
35
35
  ...rest
36
36
  } = props;
37
37
  useInertPolyfill();
@@ -43,68 +43,69 @@ const ThemeProvider = _react.forwardRef((props, forwardedRef) => {
43
43
  (_themeOptions1 = themeOptions).highContrast ??
44
44
  (_themeOptions1.highContrast =
45
45
  'inherit' === themeProp ? parent.highContrast : void 0);
46
- (_future = future).themeBridge ??
47
- (_future.themeBridge = parent.context?.future?.themeBridge);
48
46
  let portalContainerFromParent = _react.useContext(
49
47
  _index.PortalContainerContext,
50
48
  );
51
- let contextValue = _react.useMemo(
49
+ let themeContextValue = _react.useMemo(
52
50
  () => ({
53
51
  theme,
54
52
  themeOptions,
55
- future,
56
53
  }),
57
- [theme, JSON.stringify(themeOptions), JSON.stringify(future)],
54
+ [theme, JSON.stringify(themeOptions)],
58
55
  );
59
56
  let [portalContainer, setPortalContainer] = _react.useState(
60
57
  portalContainerProp || null,
61
58
  );
62
59
  return _react.createElement(
63
- _index.PortalContainerContext.Provider,
60
+ _index.FutureFlagsProvider,
64
61
  {
65
- value: portalContainer,
62
+ value: futureProp,
66
63
  },
67
64
  _react.createElement(
68
- _index.HydrationProvider,
69
- null,
65
+ _index.PortalContainerContext.Provider,
66
+ {
67
+ value: portalContainer,
68
+ },
70
69
  _react.createElement(
71
- _ThemeContext.ThemeContext.Provider,
72
- {
73
- value: contextValue,
74
- },
70
+ _index.HydrationProvider,
71
+ null,
75
72
  _react.createElement(
76
- _Toaster.ToastProvider,
73
+ _ThemeContext.ThemeContext.Provider,
77
74
  {
78
- inherit: 'inherit' === themeProp && !portalContainerProp,
75
+ value: themeContextValue,
79
76
  },
80
- includeCss && rootElement
81
- ? _react.createElement(FallbackStyles, {
82
- root: rootElement,
83
- })
84
- : null,
85
77
  _react.createElement(
86
- MainRoot,
78
+ _Toaster.ToastProvider,
87
79
  {
88
- theme: theme,
89
- themeOptions: themeOptions,
90
- future: future,
91
- ref: (0, _index.useMergedRefs)(
92
- forwardedRef,
93
- setRootElement,
94
- useIuiDebugRef,
95
- ),
96
- ...rest,
80
+ inherit: 'inherit' === themeProp && !portalContainerProp,
97
81
  },
98
- children,
99
- _react.createElement(PortalContainer, {
100
- theme: theme,
101
- themeOptions: themeOptions,
102
- future: future,
103
- portalContainerProp: portalContainerProp,
104
- portalContainerFromParent: portalContainerFromParent,
105
- setPortalContainer: setPortalContainer,
106
- isInheritingTheme: 'inherit' === themeProp,
107
- }),
82
+ includeCss && rootElement
83
+ ? _react.createElement(FallbackStyles, {
84
+ root: rootElement,
85
+ })
86
+ : null,
87
+ _react.createElement(
88
+ MainRoot,
89
+ {
90
+ theme: theme,
91
+ themeOptions: themeOptions,
92
+ ref: (0, _index.useMergedRefs)(
93
+ forwardedRef,
94
+ setRootElement,
95
+ useIuiDebugRef,
96
+ ),
97
+ ...rest,
98
+ },
99
+ children,
100
+ _react.createElement(PortalContainer, {
101
+ theme: theme,
102
+ themeOptions: themeOptions,
103
+ portalContainerProp: portalContainerProp,
104
+ portalContainerFromParent: portalContainerFromParent,
105
+ setPortalContainer: setPortalContainer,
106
+ isInheritingTheme: 'inherit' === themeProp,
107
+ }),
108
+ ),
108
109
  ),
109
110
  ),
110
111
  ),
@@ -134,7 +135,7 @@ const MainRoot = _react.forwardRef((props, forwardedRef) => {
134
135
  );
135
136
  });
136
137
  const Root = _react.forwardRef((props, forwardedRef) => {
137
- let { theme, children, themeOptions, className, future, ...rest } = props;
138
+ let { theme, children, themeOptions, className, ...rest } = props;
138
139
  let prefersDark = (0, _index.useMediaQuery)('(prefers-color-scheme: dark)');
139
140
  let prefersHighContrast = (0, _index.useMediaQuery)(
140
141
  '(prefers-contrast: more)',
@@ -142,6 +143,7 @@ const Root = _react.forwardRef((props, forwardedRef) => {
142
143
  let shouldApplyDark = 'dark' === theme || ('os' === theme && prefersDark);
143
144
  let shouldApplyHC = themeOptions?.highContrast ?? prefersHighContrast;
144
145
  let shouldApplyBackground = themeOptions?.applyBackground;
146
+ let themeBridge = (0, _index.useFutureFlag)('themeBridge');
145
147
  return _react.createElement(
146
148
  _index.Box,
147
149
  {
@@ -154,7 +156,7 @@ const Root = _react.forwardRef((props, forwardedRef) => {
154
156
  ),
155
157
  'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
156
158
  'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
157
- 'data-iui-bridge': future?.themeBridge ? true : void 0,
159
+ 'data-iui-bridge': themeBridge ? 'true' : void 0,
158
160
  ref: forwardedRef,
159
161
  ...rest,
160
162
  },
@@ -205,7 +207,6 @@ const PortalContainer = _react.memo(
205
207
  isInheritingTheme,
206
208
  theme,
207
209
  themeOptions,
208
- future,
209
210
  }) => {
210
211
  let ownerDocument = _react.useContext(OwnerDocumentContext);
211
212
  let shouldSetupPortalContainer =
@@ -237,7 +238,6 @@ const PortalContainer = _react.memo(
237
238
  ...themeOptions,
238
239
  applyBackground: false,
239
240
  },
240
- future: future,
241
241
  'data-iui-portal': true,
242
242
  style: {
243
243
  display: 'contents',
@@ -14,6 +14,16 @@ type ToggleSwitchProps = {
14
14
  * @default 'right'
15
15
  */
16
16
  labelPosition?: 'left' | 'right';
17
+ /**
18
+ * Passes props to wrapper.
19
+ *
20
+ * By default, `className` and `style` are applied on the wrapper element, and all other DOM props are passed to
21
+ * `<input>` element.
22
+ *
23
+ * When `wrapperProps` is passed or when the `ToggleSwitch.consistentPropsSpread` future flag is enabled, `className`
24
+ * and `style` are applied on the `<input>` element, similar to other DOM props.
25
+ */
26
+ wrapperProps?: React.HTMLAttributes<HTMLElement>;
17
27
  } & ({
18
28
  /**
19
29
  * Size of the toggle switch.
@@ -32,6 +42,17 @@ type ToggleSwitchProps = {
32
42
  });
33
43
  /**
34
44
  * A switch for turning on and off.
45
+ *
46
+ * ---
47
+ *
48
+ * By default, `className` and `style` are applied on the wrapper element, and all other DOM props are passed to `<input>`
49
+ * element.
50
+ *
51
+ * When `wrapperProps` is passed or when the `ToggleSwitch.consistentPropsSpread` future flag is enabled, `className`
52
+ * and `style` are applied on the `<input>` element, similar to other DOM props.
53
+ *
54
+ * ---
55
+ *
35
56
  * @example
36
57
  * <caption>Basic toggle</caption>
37
58
  * <ToggleSwitch onChange={(e) => console.log(e.target.checked)} defaultChecked />