@itwin/itwinui-react 3.15.4 → 3.16.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 (137) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/DEV-cjs/core/Breadcrumbs/Breadcrumbs.js +2 -2
  3. package/DEV-cjs/core/Checkbox/Checkbox.js +4 -6
  4. package/DEV-cjs/core/ComboBox/ComboBox.js +10 -6
  5. package/DEV-cjs/core/DatePicker/DatePicker.js +9 -1
  6. package/DEV-cjs/core/Dialog/Dialog.js +1 -1
  7. package/DEV-cjs/core/Panels/Panels.js +319 -0
  8. package/DEV-cjs/core/Panels/helpers.js +62 -0
  9. package/DEV-cjs/core/Radio/Radio.js +4 -6
  10. package/DEV-cjs/core/RadioTiles/RadioTileGroup.js +9 -2
  11. package/DEV-cjs/core/Select/SelectTag.js +9 -11
  12. package/DEV-cjs/core/Select/SelectTagContainer.js +2 -2
  13. package/DEV-cjs/core/Stepper/Stepper.js +1 -0
  14. package/DEV-cjs/core/Stepper/StepperStep.js +2 -1
  15. package/DEV-cjs/core/Table/Table.js +64 -47
  16. package/DEV-cjs/core/Table/TablePaginator.js +15 -3
  17. package/DEV-cjs/core/Table/actionHandlers/selectHandler.js +10 -7
  18. package/DEV-cjs/core/Table/columns/selectionColumn.js +6 -1
  19. package/DEV-cjs/core/Tree/Tree.js +1 -0
  20. package/DEV-cjs/index.js +4 -0
  21. package/DEV-cjs/styles.js +1 -1
  22. package/DEV-cjs/utils/components/MiddleTextTruncation.js +22 -4
  23. package/DEV-cjs/utils/components/OverflowContainer.js +170 -27
  24. package/DEV-cjs/utils/hooks/index.js +1 -1
  25. package/DEV-cjs/utils/hooks/useInstance.js +38 -0
  26. package/DEV-esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
  27. package/DEV-esm/core/Checkbox/Checkbox.js +5 -10
  28. package/DEV-esm/core/ComboBox/ComboBox.js +10 -6
  29. package/DEV-esm/core/DatePicker/DatePicker.js +11 -1
  30. package/DEV-esm/core/Dialog/Dialog.js +1 -1
  31. package/DEV-esm/core/Panels/Panels.js +301 -0
  32. package/DEV-esm/core/Panels/helpers.js +42 -0
  33. package/DEV-esm/core/Radio/Radio.js +4 -9
  34. package/DEV-esm/core/RadioTiles/RadioTileGroup.js +8 -2
  35. package/DEV-esm/core/Select/SelectTag.js +9 -11
  36. package/DEV-esm/core/Select/SelectTagContainer.js +2 -2
  37. package/DEV-esm/core/Stepper/Stepper.js +1 -0
  38. package/DEV-esm/core/Stepper/StepperStep.js +2 -1
  39. package/DEV-esm/core/Table/Table.js +61 -47
  40. package/DEV-esm/core/Table/TablePaginator.js +16 -3
  41. package/DEV-esm/core/Table/actionHandlers/selectHandler.js +10 -7
  42. package/DEV-esm/core/Table/columns/selectionColumn.js +6 -1
  43. package/DEV-esm/core/Tree/Tree.js +1 -0
  44. package/DEV-esm/index.js +1 -0
  45. package/DEV-esm/styles.js +1 -1
  46. package/DEV-esm/utils/components/MiddleTextTruncation.js +22 -4
  47. package/DEV-esm/utils/components/OverflowContainer.js +143 -4
  48. package/DEV-esm/utils/hooks/index.js +1 -1
  49. package/DEV-esm/utils/hooks/useInstance.js +18 -0
  50. package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -2
  51. package/cjs/core/Checkbox/Checkbox.js +4 -6
  52. package/cjs/core/ComboBox/ComboBox.d.ts +13 -0
  53. package/cjs/core/ComboBox/ComboBox.js +10 -6
  54. package/cjs/core/DatePicker/DatePicker.d.ts +2 -2
  55. package/cjs/core/DatePicker/DatePicker.js +2 -1
  56. package/cjs/core/Dialog/Dialog.js +1 -1
  57. package/cjs/core/Dialog/DialogContext.d.ts +6 -2
  58. package/cjs/core/NonIdealState/NonIdealState.d.ts +15 -11
  59. package/cjs/core/Panels/Panels.d.ts +174 -0
  60. package/cjs/core/Panels/Panels.js +312 -0
  61. package/cjs/core/Panels/helpers.d.ts +23 -0
  62. package/cjs/core/Panels/helpers.js +61 -0
  63. package/cjs/core/Radio/Radio.js +4 -6
  64. package/cjs/core/RadioTiles/RadioTileGroup.d.ts +3 -1
  65. package/cjs/core/RadioTiles/RadioTileGroup.js +9 -2
  66. package/cjs/core/Select/SelectTag.d.ts +3 -1
  67. package/cjs/core/Select/SelectTag.js +9 -11
  68. package/cjs/core/Select/SelectTagContainer.js +2 -2
  69. package/cjs/core/Stepper/Stepper.d.ts +4 -0
  70. package/cjs/core/Stepper/Stepper.js +1 -0
  71. package/cjs/core/Stepper/StepperStep.d.ts +4 -0
  72. package/cjs/core/Stepper/StepperStep.js +2 -1
  73. package/cjs/core/Table/Table.d.ts +1 -0
  74. package/cjs/core/Table/Table.js +64 -47
  75. package/cjs/core/Table/TablePaginator.js +15 -3
  76. package/cjs/core/Table/actionHandlers/selectHandler.js +10 -7
  77. package/cjs/core/Table/columns/selectionColumn.js +6 -1
  78. package/cjs/core/Tree/Tree.js +1 -0
  79. package/cjs/index.d.ts +1 -0
  80. package/cjs/index.js +4 -0
  81. package/cjs/styles.js +1 -1
  82. package/cjs/utils/components/MiddleTextTruncation.d.ts +5 -7
  83. package/cjs/utils/components/MiddleTextTruncation.js +22 -4
  84. package/cjs/utils/components/OverflowContainer.d.ts +1 -0
  85. package/cjs/utils/components/OverflowContainer.js +170 -27
  86. package/cjs/utils/hooks/index.d.ts +1 -1
  87. package/cjs/utils/hooks/index.js +1 -1
  88. package/cjs/utils/hooks/useInstance.d.ts +22 -0
  89. package/cjs/utils/hooks/useInstance.js +38 -0
  90. package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
  91. package/esm/core/Checkbox/Checkbox.js +5 -10
  92. package/esm/core/ComboBox/ComboBox.d.ts +13 -0
  93. package/esm/core/ComboBox/ComboBox.js +10 -6
  94. package/esm/core/DatePicker/DatePicker.d.ts +2 -2
  95. package/esm/core/DatePicker/DatePicker.js +4 -1
  96. package/esm/core/Dialog/Dialog.js +1 -1
  97. package/esm/core/Dialog/DialogContext.d.ts +6 -2
  98. package/esm/core/NonIdealState/NonIdealState.d.ts +15 -11
  99. package/esm/core/Panels/Panels.d.ts +174 -0
  100. package/esm/core/Panels/Panels.js +294 -0
  101. package/esm/core/Panels/helpers.d.ts +23 -0
  102. package/esm/core/Panels/helpers.js +41 -0
  103. package/esm/core/Radio/Radio.js +4 -9
  104. package/esm/core/RadioTiles/RadioTileGroup.d.ts +3 -1
  105. package/esm/core/RadioTiles/RadioTileGroup.js +8 -2
  106. package/esm/core/Select/SelectTag.d.ts +3 -1
  107. package/esm/core/Select/SelectTag.js +9 -11
  108. package/esm/core/Select/SelectTagContainer.js +2 -2
  109. package/esm/core/Stepper/Stepper.d.ts +4 -0
  110. package/esm/core/Stepper/Stepper.js +1 -0
  111. package/esm/core/Stepper/StepperStep.d.ts +4 -0
  112. package/esm/core/Stepper/StepperStep.js +2 -1
  113. package/esm/core/Table/Table.d.ts +1 -0
  114. package/esm/core/Table/Table.js +61 -47
  115. package/esm/core/Table/TablePaginator.js +16 -3
  116. package/esm/core/Table/actionHandlers/selectHandler.js +10 -7
  117. package/esm/core/Table/columns/selectionColumn.js +6 -1
  118. package/esm/core/Tree/Tree.js +1 -0
  119. package/esm/index.d.ts +1 -0
  120. package/esm/index.js +1 -0
  121. package/esm/styles.js +1 -1
  122. package/esm/utils/components/MiddleTextTruncation.d.ts +5 -7
  123. package/esm/utils/components/MiddleTextTruncation.js +22 -4
  124. package/esm/utils/components/OverflowContainer.d.ts +1 -0
  125. package/esm/utils/components/OverflowContainer.js +143 -4
  126. package/esm/utils/hooks/index.d.ts +1 -1
  127. package/esm/utils/hooks/index.js +1 -1
  128. package/esm/utils/hooks/useInstance.d.ts +22 -0
  129. package/esm/utils/hooks/useInstance.js +18 -0
  130. package/package.json +2 -2
  131. package/styles.css +8 -8
  132. package/DEV-cjs/utils/hooks/useOverflow.js +0 -76
  133. package/DEV-esm/utils/hooks/useOverflow.js +0 -63
  134. package/cjs/utils/hooks/useOverflow.d.ts +0 -23
  135. package/cjs/utils/hooks/useOverflow.js +0 -76
  136. package/esm/utils/hooks/useOverflow.d.ts +0 -23
  137. package/esm/utils/hooks/useOverflow.js +0 -63
@@ -12,48 +12,191 @@ const _interop_require_default = require('@swc/helpers/_/_interop_require_defaul
12
12
  const _react = _interop_require_default._(require('react'));
13
13
  const _useMergedRefs = require('../hooks/useMergedRefs.js');
14
14
  const _Box = require('./Box.js');
15
- const _useOverflow = require('../hooks/useOverflow.js');
15
+ const _useIsomorphicLayoutEffect = require('../hooks/useIsomorphicLayoutEffect.js');
16
16
  const _useSafeContext = require('../hooks/useSafeContext.js');
17
- const OverflowContainerComponent = _react.default.forwardRef((props, ref) => {
18
- let { itemsCount, children, overflowOrientation, ...rest } = props;
19
- let [containerRef, visibleCount] = (0, _useOverflow.useOverflow)(
20
- itemsCount,
21
- false,
22
- overflowOrientation,
23
- );
24
- let overflowContainerContextValue = _react.default.useMemo(
25
- () => ({
26
- visibleCount,
17
+ const _dev = require('../functions/dev.js');
18
+ const _useResizeObserver = require('../hooks/useResizeObserver.js');
19
+ const OverflowContainerMain = _react.default.forwardRef(
20
+ (props, forwardedRef) => {
21
+ let { itemsCount, children, overflowOrientation, ...rest } = props;
22
+ let [containerRef, visibleCount] = useOverflow(
27
23
  itemsCount,
28
- }),
29
- [itemsCount, visibleCount],
30
- );
31
- return _react.default.createElement(
32
- OverflowContainerContext.Provider,
33
- {
34
- value: overflowContainerContextValue,
35
- },
36
- _react.default.createElement(
37
- _Box.Box,
24
+ overflowOrientation,
25
+ );
26
+ let overflowContainerContextValue = _react.default.useMemo(
27
+ () => ({
28
+ visibleCount,
29
+ itemsCount,
30
+ }),
31
+ [itemsCount, visibleCount],
32
+ );
33
+ return _react.default.createElement(
34
+ OverflowContainerContext.Provider,
38
35
  {
39
- ref: (0, _useMergedRefs.useMergedRefs)(ref, containerRef),
40
- ...rest,
36
+ value: overflowContainerContextValue,
41
37
  },
42
- children,
43
- ),
44
- );
45
- });
38
+ _react.default.createElement(
39
+ _Box.Box,
40
+ {
41
+ ref: (0, _useMergedRefs.useMergedRefs)(forwardedRef, containerRef),
42
+ ...rest,
43
+ },
44
+ children,
45
+ ),
46
+ );
47
+ },
48
+ );
46
49
  const OverflowContainerOverflowNode = (props) => {
47
50
  let { children } = props;
48
51
  let { visibleCount, itemsCount } = useOverflowContainerContext();
49
52
  let isOverflowing = visibleCount < itemsCount;
50
53
  return isOverflowing ? children : null;
51
54
  };
55
+ const OverflowContainerComponent = _react.default.forwardRef(
56
+ (props, forwardedRef) => {
57
+ let { itemsCount, overflowOrientation = 'horizontal', ...rest } = props;
58
+ let [size, setSize] = _react.default.useState(null);
59
+ let [resizeRef] = (0, _useResizeObserver.useResizeObserver)(setSize);
60
+ let ref = (0, _useMergedRefs.useMergedRefs)(resizeRef, forwardedRef);
61
+ let key = `${itemsCount}${
62
+ 'vertical' === overflowOrientation ? size?.height : size?.width
63
+ }`;
64
+ return _react.default.createElement(OverflowContainerMain, {
65
+ ...rest,
66
+ key: key,
67
+ ref: ref,
68
+ itemsCount: itemsCount,
69
+ overflowOrientation: overflowOrientation,
70
+ });
71
+ },
72
+ );
52
73
  const OverflowContainer = Object.assign(OverflowContainerComponent, {
53
74
  OverflowNode: OverflowContainerOverflowNode,
54
75
  useContext: useOverflowContainerContext,
55
76
  });
56
77
  const OverflowContainerContext = _react.default.createContext(void 0);
78
+ const useOverflow = (itemsCount, orientation = 'horizontal') => {
79
+ let [guessState, dispatch] = _react.default.useReducer(
80
+ overflowGuessReducer,
81
+ {
82
+ itemsCount,
83
+ },
84
+ overflowGuessReducerInitialState,
85
+ );
86
+ let containerRef = _react.default.useRef(null);
87
+ let isGuessing = _react.default.useRef(false);
88
+ (0, _useIsomorphicLayoutEffect.useLayoutEffect)(() => {
89
+ let { minGuess, maxGuess, isStabilized, visibleCount } = guessState;
90
+ if (isStabilized) return;
91
+ guessVisibleCount();
92
+ function guessVisibleCount() {
93
+ if (isStabilized || isGuessing.current || _dev.isUnitTest) return;
94
+ try {
95
+ isGuessing.current = true;
96
+ if (null == containerRef.current) return;
97
+ let dimension = 'horizontal' === orientation ? 'Width' : 'Height';
98
+ let availableSize = containerRef.current[`offset${dimension}`];
99
+ let requiredSize = containerRef.current[`scroll${dimension}`];
100
+ let isOverflowing = availableSize < requiredSize;
101
+ if (
102
+ 0 === itemsCount ||
103
+ (1 === visibleCount && isOverflowing) ||
104
+ (visibleCount === itemsCount && !isOverflowing) ||
105
+ (maxGuess - minGuess === 1 && visibleCount === minGuess)
106
+ ) {
107
+ dispatch({
108
+ type: 'stabilize',
109
+ });
110
+ return;
111
+ }
112
+ if (maxGuess === visibleCount && !isOverflowing) {
113
+ dispatch({
114
+ type: 'shiftGuessRangeForward',
115
+ });
116
+ return;
117
+ }
118
+ isOverflowing
119
+ ? dispatch({
120
+ type: 'decreaseMaxGuess',
121
+ currentState: guessState,
122
+ })
123
+ : dispatch({
124
+ type: 'increaseMinGuess',
125
+ currentState: guessState,
126
+ });
127
+ } finally {
128
+ isGuessing.current = false;
129
+ }
130
+ }
131
+ }, [guessState, itemsCount, orientation]);
132
+ return [containerRef, guessState.visibleCount];
133
+ };
134
+ const STARTING_MAX_ITEMS_COUNT = 32;
135
+ const overflowGuessReducerInitialState = ({ itemsCount }) => {
136
+ let initialVisibleCount = Math.min(itemsCount, STARTING_MAX_ITEMS_COUNT);
137
+ return _dev.isUnitTest
138
+ ? {
139
+ isStabilized: true,
140
+ minGuess: null,
141
+ maxGuess: null,
142
+ itemsCount,
143
+ visibleCount: itemsCount,
144
+ }
145
+ : {
146
+ isStabilized: false,
147
+ minGuess: 0,
148
+ maxGuess: initialVisibleCount,
149
+ itemsCount,
150
+ visibleCount: initialVisibleCount,
151
+ };
152
+ };
153
+ const overflowGuessReducer = (state, action) => {
154
+ let getSafeVisibleCount = ({ visibleCount, itemsCount }) =>
155
+ Math.min(itemsCount, visibleCount);
156
+ switch (action.type) {
157
+ case 'decreaseMaxGuess':
158
+ case 'increaseMinGuess':
159
+ if (state.isStabilized) return state;
160
+ let newMinGuess = state.minGuess;
161
+ let newMaxGuess = state.maxGuess;
162
+ if ('decreaseMaxGuess' === action.type)
163
+ newMaxGuess = action.currentState.visibleCount;
164
+ else newMinGuess = action.currentState.visibleCount;
165
+ let newVisibleCount = Math.floor((newMinGuess + newMaxGuess) / 2);
166
+ return {
167
+ ...state,
168
+ isStabilized: false,
169
+ minGuess: newMinGuess,
170
+ maxGuess: newMaxGuess,
171
+ visibleCount: getSafeVisibleCount({
172
+ visibleCount: newVisibleCount,
173
+ itemsCount: state.itemsCount,
174
+ }),
175
+ };
176
+ case 'shiftGuessRangeForward':
177
+ if (state.isStabilized) return state;
178
+ let doubleOfMaxGuess = 2 * state.maxGuess;
179
+ return {
180
+ ...state,
181
+ isStabilized: false,
182
+ minGuess: state.maxGuess,
183
+ maxGuess: doubleOfMaxGuess,
184
+ visibleCount: getSafeVisibleCount({
185
+ visibleCount: doubleOfMaxGuess,
186
+ itemsCount: state.itemsCount,
187
+ }),
188
+ };
189
+ case 'stabilize':
190
+ return {
191
+ ...state,
192
+ isStabilized: true,
193
+ minGuess: null,
194
+ maxGuess: null,
195
+ };
196
+ default:
197
+ return state;
198
+ }
199
+ };
57
200
  function useOverflowContainerContext() {
58
201
  let overflowContainerContext = (0, _useSafeContext.useSafeContext)(
59
202
  OverflowContainerContext,
@@ -1,6 +1,5 @@
1
1
  export * from './useEventListener.js';
2
2
  export * from './useMergedRefs.js';
3
- export * from './useOverflow.js';
4
3
  export * from './useResizeObserver.js';
5
4
  export * from './useContainerWidth.js';
6
5
  export * from './useGlobals.js';
@@ -14,4 +13,5 @@ export * from './useId.js';
14
13
  export * from './useControlledState.js';
15
14
  export * from './useSyncExternalStore.js';
16
15
  export * from './useVirtualScroll.js';
16
+ export * from './useInstance.js';
17
17
  export * from './useWarningLogger.js';
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', {
5
5
  const _export_star = require('@swc/helpers/_/_export_star');
6
6
  _export_star._(require('./useEventListener.js'), exports);
7
7
  _export_star._(require('./useMergedRefs.js'), exports);
8
- _export_star._(require('./useOverflow.js'), exports);
9
8
  _export_star._(require('./useResizeObserver.js'), exports);
10
9
  _export_star._(require('./useContainerWidth.js'), exports);
11
10
  _export_star._(require('./useGlobals.js'), exports);
@@ -19,4 +18,5 @@ _export_star._(require('./useId.js'), exports);
19
18
  _export_star._(require('./useControlledState.js'), exports);
20
19
  _export_star._(require('./useSyncExternalStore.js'), exports);
21
20
  _export_star._(require('./useVirtualScroll.js'), exports);
21
+ _export_star._(require('./useInstance.js'), exports);
22
22
  _export_star._(require('./useWarningLogger.js'), exports);
@@ -0,0 +1,22 @@
1
+ declare class Instance {
2
+ }
3
+ export declare const useInstance: () => Instance;
4
+ /**
5
+ * Synchronizes the instance with the provided properties.
6
+ *
7
+ * @param instance Instance created by `useInstance`.
8
+ * @param properties Memoized object containing properties to be synchronized.
9
+ *
10
+ * @example
11
+ * const instance = useInstance();
12
+ *
13
+ * const properties = React.useMemo(() => ({
14
+ * show: () => console.log('show'),
15
+ * }), []);
16
+ *
17
+ * useSynchronizeInstance(instance, properties);
18
+ *
19
+ * instance.show(); // logs 'show'
20
+ */
21
+ export declare const useSynchronizeInstance: <T>(instance: T, properties: T) => T;
22
+ export {};
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', {
3
+ value: true,
4
+ });
5
+ function _export(target, all) {
6
+ for (var name in all)
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name],
10
+ });
11
+ }
12
+ _export(exports, {
13
+ useInstance: function () {
14
+ return useInstance;
15
+ },
16
+ useSynchronizeInstance: function () {
17
+ return useSynchronizeInstance;
18
+ },
19
+ });
20
+ const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
21
+ const _react = _interop_require_wildcard._(require('react'));
22
+ const _useSyncExternalStore = require('./useSyncExternalStore.js');
23
+ class Instance {}
24
+ const useInstance = () => _react.useMemo(() => new Instance(), []);
25
+ const useSynchronizeInstance = (instance, properties) => {
26
+ let synchronize = _react.useCallback(() => {
27
+ if (!(instance instanceof Instance)) return () => {};
28
+ Object.assign(instance, properties);
29
+ return () => {
30
+ for (let key in properties) delete instance[key];
31
+ };
32
+ }, [instance, properties]);
33
+ return (0, _useSyncExternalStore.useSyncExternalStore)(
34
+ synchronize,
35
+ () => instance,
36
+ () => instance,
37
+ );
38
+ };
@@ -8,7 +8,7 @@ import {
8
8
  } from '../../utils/index.js';
9
9
  import { Button } from '../Buttons/Button.js';
10
10
  import { Anchor } from '../Typography/Anchor.js';
11
- let BreadcrumbsComponent = React.forwardRef((props, ref) => {
11
+ let BreadcrumbsComponent = React.forwardRef((props, forwardedRef) => {
12
12
  let {
13
13
  children: childrenProp,
14
14
  currentIndex = React.Children.count(childrenProp) - 1,
@@ -26,7 +26,7 @@ let BreadcrumbsComponent = React.forwardRef((props, ref) => {
26
26
  {
27
27
  as: 'nav',
28
28
  className: cx('iui-breadcrumbs', className),
29
- ref: ref,
29
+ ref: forwardedRef,
30
30
  'aria-label': 'Breadcrumb',
31
31
  ...rest,
32
32
  },
@@ -34,11 +34,11 @@ export const Checkbox = React.forwardRef((props, ref) => {
34
34
  'iui-checkbox',
35
35
  {
36
36
  'iui-checkbox-visibility': 'eyeball' === variant,
37
- 'iui-loading': isLoading,
38
37
  },
39
38
  className,
40
39
  ),
41
40
  style: style,
41
+ 'data-iui-loading': isLoading ? 'true' : void 0,
42
42
  disabled: disabled || isLoading,
43
43
  type: 'checkbox',
44
44
  ref: refs,
@@ -57,15 +57,10 @@ export const Checkbox = React.forwardRef((props, ref) => {
57
57
  Box,
58
58
  {
59
59
  as: 'label',
60
- className: cx(
61
- 'iui-checkbox-wrapper',
62
- {
63
- 'iui-disabled': disabled,
64
- [`iui-${status}`]: !!status,
65
- 'iui-loading': isLoading,
66
- },
67
- wrapperClassName,
68
- ),
60
+ className: cx('iui-checkbox-wrapper', wrapperClassName),
61
+ 'data-iui-disabled': disabled ? 'true' : void 0,
62
+ 'data-iui-status': status,
63
+ 'data-iui-loading': isLoading ? 'true' : void 0,
69
64
  ...restWrapperProps,
70
65
  },
71
66
  checkbox,
@@ -33,11 +33,24 @@ export type ComboboxMultipleTypeProps<T> = {
33
33
  * Callback fired when selected value changes.
34
34
  */
35
35
  onChange?: (value: T) => void;
36
+ /**
37
+ * Only applicable when `multiple` is enabled.
38
+ *
39
+ * If `true`, toggling an option will clear the filter.
40
+ * Useful when users would likely want to re-filter after toggling an option.
41
+ *
42
+ * If `false`, the filter will remain as-is after toggling an option.
43
+ * Useful when users would likely want to toggle multiple options from the _same_ filtered results.
44
+ *
45
+ * @default true
46
+ */
47
+ clearFilterOnOptionToggle?: never;
36
48
  } | {
37
49
  multiple: true;
38
50
  value?: T[] | null | undefined;
39
51
  defaultValue?: T[] | null;
40
52
  onChange?: (value: T[], event: MultipleOnChangeProps<T>) => void;
53
+ clearFilterOnOptionToggle?: boolean;
41
54
  };
42
55
  export type ComboBoxProps<T> = {
43
56
  /**
@@ -47,6 +47,7 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
47
47
  onHide: onHideProp,
48
48
  id = inputProps?.id ? `iui-${inputProps.id}-cb` : idPrefix,
49
49
  defaultValue,
50
+ clearFilterOnOptionToggle = true,
50
51
  ...rest
51
52
  } = props;
52
53
  let inputRef = React.useRef(null);
@@ -200,7 +201,6 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
200
201
  preventScroll: true,
201
202
  });
202
203
  if (optionsRef.current[__originalIndex]?.disabled) return;
203
- setIsInputDirty(false);
204
204
  if (multiple) {
205
205
  let actionType = isMenuItemSelected(__originalIndex)
206
206
  ? 'removed'
@@ -218,7 +218,10 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
218
218
  .filter(Boolean)
219
219
  .join(', '),
220
220
  );
221
- setInputValue('');
221
+ if (clearFilterOnOptionToggle) {
222
+ setInputValue('');
223
+ setIsInputDirty(false);
224
+ }
222
225
  } else {
223
226
  setSelectedIndexes(__originalIndex);
224
227
  hide();
@@ -226,13 +229,14 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
226
229
  }
227
230
  },
228
231
  [
229
- selectedChangeHandler,
230
- isMenuItemSelected,
232
+ optionsRef,
231
233
  multiple,
234
+ isMenuItemSelected,
235
+ selectedChangeHandler,
236
+ setSelectedIndexes,
232
237
  onChangeHandler,
233
- optionsRef,
238
+ clearFilterOnOptionToggle,
234
239
  hide,
235
- setSelectedIndexes,
236
240
  ],
237
241
  );
238
242
  let getMenuItem = React.useCallback(
@@ -29,8 +29,8 @@ export type DateRangePickerProps = {
29
29
  onChange?: (date: Date) => void;
30
30
  } | {
31
31
  enableRangeSelect: true;
32
- startDate: Date;
33
- endDate: Date;
32
+ startDate?: Date;
33
+ endDate?: Date;
34
34
  onChange?: (startDate: Date, endDate: Date) => void;
35
35
  };
36
36
  type DatePickerProps = {
@@ -8,6 +8,8 @@ import {
8
8
  isBefore,
9
9
  Box,
10
10
  useId,
11
+ useLayoutEffect,
12
+ useWarningLogger,
11
13
  } from '../../utils/index.js';
12
14
  import { IconButton } from '../Buttons/IconButton.js';
13
15
  import { TimePicker } from '../TimePicker/TimePicker.js';
@@ -135,6 +137,7 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
135
137
  showDatesOutsideMonth = true,
136
138
  ...rest
137
139
  } = props;
140
+ let logWarning = useWarningLogger();
138
141
  let monthNames = localizedNames?.months ?? defaultMonths;
139
142
  let shortDays = localizedNames?.shortDays ?? defaultShortDays;
140
143
  let longDays = localizedNames?.days ?? defaultLongDays;
@@ -177,7 +180,7 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
177
180
  );
178
181
  }, [date, setMonthAndYear, startDate, endDate, enableRangeSelect]);
179
182
  let popoverInitialFocusContext = React.useContext(PopoverInitialFocusContext);
180
- React.useLayoutEffect(() => {
183
+ useLayoutEffect(() => {
181
184
  if (setFocus && popoverInitialFocusContext)
182
185
  popoverInitialFocusContext.setInitialFocus(-1);
183
186
  }, [popoverInitialFocusContext, setFocus]);
@@ -11,7 +11,7 @@ import { Transition } from 'react-transition-group';
11
11
  let DialogComponent = React.forwardRef((props, ref) => {
12
12
  let {
13
13
  trapFocus = false,
14
- setFocus = false,
14
+ setFocus = trapFocus,
15
15
  preventDocumentScroll = false,
16
16
  isOpen = false,
17
17
  isDismissible = true,
@@ -30,13 +30,17 @@ export type DialogContextProps = {
30
30
  */
31
31
  closeOnEsc?: boolean;
32
32
  /**
33
- * Traps the focus inside the dialog. This is useful when the dialog is modal.
33
+ * Prevents focus from leaving the dialog. This is useful when the dialog is modal.
34
+ *
35
+ * Setting this prop to `true` will also set `setFocus` to `true`.
36
+ *
34
37
  * @default false
35
38
  */
36
39
  trapFocus?: boolean;
37
40
  /**
38
41
  * If true, focuses the dialog.
39
- * @default false
42
+ *
43
+ * Defaults to `true` if `trapFocus` is set to `true`, otherwise defaults to `false`.
40
44
  */
41
45
  setFocus?: boolean;
42
46
  /**
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
3
3
  type NonIdealStateProps = {
4
4
  /**
5
- * An svg component, preferably from @itwin/itwinui-illustrations-react.
5
+ * An svg component, preferably from `@itwin/itwinui-illustrations-react`.
6
6
  *
7
7
  * @example
8
8
  * import { Svg404 } from '@itwin/itwinui-illustrations-react';
@@ -10,13 +10,17 @@ type NonIdealStateProps = {
10
10
  */
11
11
  svg: React.ReactNode;
12
12
  /**
13
- * Primary heading for the error page
13
+ * Primary heading for the `NonIdealState`
14
14
  */
15
15
  heading?: React.ReactNode;
16
16
  /**
17
17
  * Secondary text to explain the error
18
18
  * Can include html in order to provide a hyperlink
19
- * E.g. `Please visit <a href="https://www.bentley.com/help">our support page</a> for help.`
19
+ *
20
+ * @example
21
+ * <>
22
+ * Please visit <Anchor href="https://www.bentley.com/help">our support page</Anchor> for help.
23
+ * </>
20
24
  */
21
25
  description?: React.ReactNode;
22
26
  /**
@@ -24,13 +28,13 @@ type NonIdealStateProps = {
24
28
  * Typically should be a primary and secondary button.
25
29
  *
26
30
  * @example
27
- * <ErrorPage
28
- * actions={
29
- * <>
30
- * <Button styleType={'high-visibility'}>Retry</Button>
31
- * <Button>Contact us</Button>
32
- * </>
33
- * }
31
+ * <NonIdealState
32
+ * actions={
33
+ * <>
34
+ * <Button styleType={'high-visibility'}>Retry</Button>
35
+ * <Button>Contact us</Button>
36
+ * </>
37
+ * }
34
38
  * />
35
39
  */
36
40
  actions?: React.ReactNode;
@@ -53,7 +57,7 @@ type NonIdealStateProps = {
53
57
  };
54
58
  /**
55
59
  * A stylized display to communicate common http errors and other non-ideal states.
56
- * Works well with svgs from @itwin/itwinui-illustrations-react.
60
+ * Works well with svgs from `@itwin/itwinui-illustrations-react`.
57
61
  *
58
62
  * @example
59
63
  * <NonIdealState svg={<Svg404 />} heading='Not found' />