@itwin/itwinui-react 3.15.5 → 3.16.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 (143) hide show
  1. package/CHANGELOG.md +32 -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/Header/HeaderDropdownButton.js +1 -7
  8. package/DEV-cjs/core/Panels/Panels.js +322 -0
  9. package/DEV-cjs/core/Panels/helpers.js +62 -0
  10. package/DEV-cjs/core/Radio/Radio.js +4 -6
  11. package/DEV-cjs/core/RadioTiles/RadioTileGroup.js +9 -2
  12. package/DEV-cjs/core/Select/SelectTag.js +9 -11
  13. package/DEV-cjs/core/Select/SelectTagContainer.js +2 -2
  14. package/DEV-cjs/core/Stepper/Stepper.js +1 -0
  15. package/DEV-cjs/core/Stepper/StepperStep.js +2 -1
  16. package/DEV-cjs/core/Table/Table.js +3 -4
  17. package/DEV-cjs/core/Table/TablePaginator.js +15 -3
  18. package/DEV-cjs/core/Table/actionHandlers/selectHandler.js +10 -7
  19. package/DEV-cjs/core/Table/columns/selectionColumn.js +6 -1
  20. package/DEV-cjs/core/Tree/Tree.js +1 -0
  21. package/DEV-cjs/index.js +4 -0
  22. package/DEV-cjs/styles.js +1 -1
  23. package/DEV-cjs/utils/components/MiddleTextTruncation.js +22 -4
  24. package/DEV-cjs/utils/components/OverflowContainer.js +170 -27
  25. package/DEV-cjs/utils/hooks/index.js +1 -1
  26. package/DEV-cjs/utils/hooks/useInstance.js +38 -0
  27. package/DEV-esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
  28. package/DEV-esm/core/Checkbox/Checkbox.js +5 -10
  29. package/DEV-esm/core/ComboBox/ComboBox.js +10 -6
  30. package/DEV-esm/core/DatePicker/DatePicker.js +11 -1
  31. package/DEV-esm/core/Dialog/Dialog.js +1 -1
  32. package/DEV-esm/core/Header/HeaderDropdownButton.js +1 -3
  33. package/DEV-esm/core/Panels/Panels.js +304 -0
  34. package/DEV-esm/core/Panels/helpers.js +42 -0
  35. package/DEV-esm/core/Radio/Radio.js +4 -9
  36. package/DEV-esm/core/RadioTiles/RadioTileGroup.js +8 -2
  37. package/DEV-esm/core/Select/SelectTag.js +9 -11
  38. package/DEV-esm/core/Select/SelectTagContainer.js +2 -2
  39. package/DEV-esm/core/Stepper/Stepper.js +1 -0
  40. package/DEV-esm/core/Stepper/StepperStep.js +2 -1
  41. package/DEV-esm/core/Table/Table.js +1 -5
  42. package/DEV-esm/core/Table/TablePaginator.js +16 -3
  43. package/DEV-esm/core/Table/actionHandlers/selectHandler.js +10 -7
  44. package/DEV-esm/core/Table/columns/selectionColumn.js +6 -1
  45. package/DEV-esm/core/Tree/Tree.js +1 -0
  46. package/DEV-esm/index.js +1 -0
  47. package/DEV-esm/styles.js +1 -1
  48. package/DEV-esm/utils/components/MiddleTextTruncation.js +22 -4
  49. package/DEV-esm/utils/components/OverflowContainer.js +143 -4
  50. package/DEV-esm/utils/hooks/index.js +1 -1
  51. package/DEV-esm/utils/hooks/useInstance.js +18 -0
  52. package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -2
  53. package/cjs/core/Checkbox/Checkbox.js +4 -6
  54. package/cjs/core/ComboBox/ComboBox.d.ts +13 -0
  55. package/cjs/core/ComboBox/ComboBox.js +10 -6
  56. package/cjs/core/DatePicker/DatePicker.d.ts +2 -2
  57. package/cjs/core/DatePicker/DatePicker.js +2 -1
  58. package/cjs/core/Dialog/Dialog.js +1 -1
  59. package/cjs/core/Dialog/DialogContext.d.ts +6 -2
  60. package/cjs/core/Header/HeaderDropdownButton.js +1 -7
  61. package/cjs/core/Panels/Panels.d.ts +174 -0
  62. package/cjs/core/Panels/Panels.js +315 -0
  63. package/cjs/core/Panels/helpers.d.ts +23 -0
  64. package/cjs/core/Panels/helpers.js +61 -0
  65. package/cjs/core/ProgressIndicators/ProgressLinear.d.ts +1 -1
  66. package/cjs/core/Radio/Radio.js +4 -6
  67. package/cjs/core/RadioTiles/RadioTileGroup.d.ts +3 -1
  68. package/cjs/core/RadioTiles/RadioTileGroup.js +9 -2
  69. package/cjs/core/Select/SelectTag.d.ts +3 -1
  70. package/cjs/core/Select/SelectTag.js +9 -11
  71. package/cjs/core/Select/SelectTagContainer.js +2 -2
  72. package/cjs/core/Stepper/Stepper.d.ts +4 -0
  73. package/cjs/core/Stepper/Stepper.js +1 -0
  74. package/cjs/core/Stepper/StepperStep.d.ts +4 -0
  75. package/cjs/core/Stepper/StepperStep.js +2 -1
  76. package/cjs/core/Table/Table.d.ts +1 -0
  77. package/cjs/core/Table/Table.js +3 -4
  78. package/cjs/core/Table/TablePaginator.js +15 -3
  79. package/cjs/core/Table/actionHandlers/selectHandler.js +10 -7
  80. package/cjs/core/Table/columns/selectionColumn.js +6 -1
  81. package/cjs/core/Tree/Tree.d.ts +2 -1
  82. package/cjs/core/Tree/Tree.js +1 -0
  83. package/cjs/index.d.ts +1 -0
  84. package/cjs/index.js +4 -0
  85. package/cjs/styles.js +1 -1
  86. package/cjs/utils/components/MiddleTextTruncation.d.ts +5 -7
  87. package/cjs/utils/components/MiddleTextTruncation.js +22 -4
  88. package/cjs/utils/components/OverflowContainer.d.ts +1 -0
  89. package/cjs/utils/components/OverflowContainer.js +170 -27
  90. package/cjs/utils/hooks/index.d.ts +1 -1
  91. package/cjs/utils/hooks/index.js +1 -1
  92. package/cjs/utils/hooks/useInstance.d.ts +22 -0
  93. package/cjs/utils/hooks/useInstance.js +38 -0
  94. package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
  95. package/esm/core/Checkbox/Checkbox.js +5 -10
  96. package/esm/core/ComboBox/ComboBox.d.ts +13 -0
  97. package/esm/core/ComboBox/ComboBox.js +10 -6
  98. package/esm/core/DatePicker/DatePicker.d.ts +2 -2
  99. package/esm/core/DatePicker/DatePicker.js +4 -1
  100. package/esm/core/Dialog/Dialog.js +1 -1
  101. package/esm/core/Dialog/DialogContext.d.ts +6 -2
  102. package/esm/core/Header/HeaderDropdownButton.js +1 -3
  103. package/esm/core/Panels/Panels.d.ts +174 -0
  104. package/esm/core/Panels/Panels.js +297 -0
  105. package/esm/core/Panels/helpers.d.ts +23 -0
  106. package/esm/core/Panels/helpers.js +41 -0
  107. package/esm/core/ProgressIndicators/ProgressLinear.d.ts +1 -1
  108. package/esm/core/Radio/Radio.js +4 -9
  109. package/esm/core/RadioTiles/RadioTileGroup.d.ts +3 -1
  110. package/esm/core/RadioTiles/RadioTileGroup.js +8 -2
  111. package/esm/core/Select/SelectTag.d.ts +3 -1
  112. package/esm/core/Select/SelectTag.js +9 -11
  113. package/esm/core/Select/SelectTagContainer.js +2 -2
  114. package/esm/core/Stepper/Stepper.d.ts +4 -0
  115. package/esm/core/Stepper/Stepper.js +1 -0
  116. package/esm/core/Stepper/StepperStep.d.ts +4 -0
  117. package/esm/core/Stepper/StepperStep.js +2 -1
  118. package/esm/core/Table/Table.d.ts +1 -0
  119. package/esm/core/Table/Table.js +1 -5
  120. package/esm/core/Table/TablePaginator.js +16 -3
  121. package/esm/core/Table/actionHandlers/selectHandler.js +10 -7
  122. package/esm/core/Table/columns/selectionColumn.js +6 -1
  123. package/esm/core/Tree/Tree.d.ts +2 -1
  124. package/esm/core/Tree/Tree.js +1 -0
  125. package/esm/index.d.ts +1 -0
  126. package/esm/index.js +1 -0
  127. package/esm/styles.js +1 -1
  128. package/esm/utils/components/MiddleTextTruncation.d.ts +5 -7
  129. package/esm/utils/components/MiddleTextTruncation.js +22 -4
  130. package/esm/utils/components/OverflowContainer.d.ts +1 -0
  131. package/esm/utils/components/OverflowContainer.js +143 -4
  132. package/esm/utils/hooks/index.d.ts +1 -1
  133. package/esm/utils/hooks/index.js +1 -1
  134. package/esm/utils/hooks/useInstance.d.ts +22 -0
  135. package/esm/utils/hooks/useInstance.js +18 -0
  136. package/package.json +2 -2
  137. package/styles.css +8 -8
  138. package/DEV-cjs/utils/hooks/useOverflow.js +0 -76
  139. package/DEV-esm/utils/hooks/useOverflow.js +0 -63
  140. package/cjs/utils/hooks/useOverflow.d.ts +0 -23
  141. package/cjs/utils/hooks/useOverflow.js +0 -76
  142. package/esm/utils/hooks/useOverflow.d.ts +0 -23
  143. package/esm/utils/hooks/useOverflow.js +0 -63
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2362](https://github.com/iTwin/iTwinUI/pull/2362): `Select` with "small" size now has the same height (`24px`) as other input elements with "small" size (e.g. `ComboBox`)
8
+ - [#2370](https://github.com/iTwin/iTwinUI/pull/2370): Fixed `Panels` animations not working in some rare cases.
9
+ - [#2374](https://github.com/iTwin/iTwinUI/pull/2374): Fixed `HeaderButton`'s `startIcon` and `endIcon` fill color.
10
+ - [#2359](https://github.com/iTwin/iTwinUI/pull/2359): `Tooltip` now remains visible when hovered up to `4px` outside its border.
11
+
12
+ ## 3.16.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#2001](https://github.com/iTwin/iTwinUI/pull/2001): Added a new generic `unstable_Panels` component for easy setup of nested screens/panels. Example uses: multi-layered menus, wizards, settings screens, etc.
17
+ - This API is temporarily marked as **unstable** to collect [feedback](https://github.com/iTwin/iTwinUI/discussions/2348) for some time to tailor the generic component specifically to users' needs.
18
+ - [#2345](https://github.com/iTwin/iTwinUI/pull/2345): `Stepper` now allows passing custom icon or content in each step circle using a `stepContent` property in each item of the `steps` array.
19
+ - [#2294](https://github.com/iTwin/iTwinUI/pull/2294): `ComboBox` with `multiple` enabled now offers a `clearFilterOnOptionToggle` prop to control whether the filter is cleared or not when an option is toggled. Default value is `true` (i.e. no breaking change).
20
+ - [#2299](https://github.com/iTwin/iTwinUI/pull/2299)/[5d313a7](https://github.com/iTwin/iTwinUI/commit/5d313a763b5b5996664a3af14c8270e40dc07b72): Added new `tileContainer` prop to `RadioTileGroup` to allow further customization of inner DOM elements.
21
+
22
+ ### Patch Changes
23
+
24
+ - [#2337](https://github.com/iTwin/iTwinUI/pull/2337): Fixed a `Table` bug where row items could not be focused via the `Tab` key.
25
+ - [#2317](https://github.com/iTwin/iTwinUI/pull/2317): Fixed duplicate data returned from `Table`'s `onSelect` prop.
26
+ - [#2316](https://github.com/iTwin/iTwinUI/pull/2316): `TablePaginator`'s page buttons no longer get overlapped by neighboring paginator elements.
27
+ - [#2327](https://github.com/iTwin/iTwinUI/pull/2327): Fixed a `Tree` bug where the `size` prop was not respected when virtualization was enabled.
28
+ - [#2311](https://github.com/iTwin/iTwinUI/pull/2311): Updated the default value of `Dialog`'s `setFocus` prop to be based on the value of the `trapFocus` prop.
29
+ - [#2154](https://github.com/iTwin/iTwinUI/pull/2154): Fixed bugs and improved performance in components with overflow support (e.g. `ComboBox`, `Select`, `ButtonGroup`, `Breadcrumbs`, etc.)
30
+ - [#2339](https://github.com/iTwin/iTwinUI/pull/2339): Improved the accessibility of `MiddleTextTruncation` so that the entire untruncated text is part of the accessibility tree.
31
+ - [#2334](https://github.com/iTwin/iTwinUI/pull/2334): `DatePicker` with `enableRangeSelect` now allows `startDate` and `endDate` to _both_ be `undefined` (e.g. when there is no initial range). Passing `Date` to just _one_ of them is not allowed.
32
+ - [#2347](https://github.com/iTwin/iTwinUI/pull/2347): `InputWithDecorations.Input` now properly gets `cursor: not-allowed` when disabled.
33
+ - [#2323](https://github.com/iTwin/iTwinUI/pull/2323): Ensured that the `useToaster` wrapper does not block clicks when used within other portal containers (e.g. from AppUI).
34
+
3
35
  ## 3.15.5
4
36
 
5
37
  ### Patch Changes
@@ -15,7 +15,7 @@ const _classnames = _interop_require_default._(require('classnames'));
15
15
  const _index = require('../../utils/index.js');
16
16
  const _Button = require('../Buttons/Button.js');
17
17
  const _Anchor = require('../Typography/Anchor.js');
18
- const BreadcrumbsComponent = _react.forwardRef((props, ref) => {
18
+ const BreadcrumbsComponent = _react.forwardRef((props, forwardedRef) => {
19
19
  let {
20
20
  children: childrenProp,
21
21
  currentIndex = _react.Children.count(childrenProp) - 1,
@@ -33,7 +33,7 @@ const BreadcrumbsComponent = _react.forwardRef((props, ref) => {
33
33
  {
34
34
  as: 'nav',
35
35
  className: (0, _classnames.default)('iui-breadcrumbs', className),
36
- ref: ref,
36
+ ref: forwardedRef,
37
37
  'aria-label': 'Breadcrumb',
38
38
  ...rest,
39
39
  },
@@ -46,11 +46,11 @@ const Checkbox = _react.forwardRef((props, ref) => {
46
46
  'iui-checkbox',
47
47
  {
48
48
  'iui-checkbox-visibility': 'eyeball' === variant,
49
- 'iui-loading': isLoading,
50
49
  },
51
50
  className,
52
51
  ),
53
52
  style: style,
53
+ 'data-iui-loading': isLoading ? 'true' : void 0,
54
54
  disabled: disabled || isLoading,
55
55
  type: 'checkbox',
56
56
  ref: refs,
@@ -71,13 +71,11 @@ const Checkbox = _react.forwardRef((props, ref) => {
71
71
  as: 'label',
72
72
  className: (0, _classnames.default)(
73
73
  'iui-checkbox-wrapper',
74
- {
75
- 'iui-disabled': disabled,
76
- [`iui-${status}`]: !!status,
77
- 'iui-loading': isLoading,
78
- },
79
74
  wrapperClassName,
80
75
  ),
76
+ 'data-iui-disabled': disabled ? 'true' : void 0,
77
+ 'data-iui-status': status,
78
+ 'data-iui-loading': isLoading ? 'true' : void 0,
81
79
  ...restWrapperProps,
82
80
  },
83
81
  checkbox,
@@ -51,6 +51,7 @@ const ComboBox = _react.forwardRef((props, forwardedRef) => {
51
51
  onHide: onHideProp,
52
52
  id = inputProps?.id ? `iui-${inputProps.id}-cb` : idPrefix,
53
53
  defaultValue,
54
+ clearFilterOnOptionToggle = true,
54
55
  ...rest
55
56
  } = props;
56
57
  let inputRef = _react.useRef(null);
@@ -204,7 +205,6 @@ const ComboBox = _react.forwardRef((props, forwardedRef) => {
204
205
  preventScroll: true,
205
206
  });
206
207
  if (optionsRef.current[__originalIndex]?.disabled) return;
207
- setIsInputDirty(false);
208
208
  if (multiple) {
209
209
  let actionType = isMenuItemSelected(__originalIndex)
210
210
  ? 'removed'
@@ -222,7 +222,10 @@ const ComboBox = _react.forwardRef((props, forwardedRef) => {
222
222
  .filter(Boolean)
223
223
  .join(', '),
224
224
  );
225
- setInputValue('');
225
+ if (clearFilterOnOptionToggle) {
226
+ setInputValue('');
227
+ setIsInputDirty(false);
228
+ }
226
229
  } else {
227
230
  setSelectedIndexes(__originalIndex);
228
231
  hide();
@@ -230,13 +233,14 @@ const ComboBox = _react.forwardRef((props, forwardedRef) => {
230
233
  }
231
234
  },
232
235
  [
233
- selectedChangeHandler,
234
- isMenuItemSelected,
236
+ optionsRef,
235
237
  multiple,
238
+ isMenuItemSelected,
239
+ selectedChangeHandler,
240
+ setSelectedIndexes,
236
241
  onChangeHandler,
237
- optionsRef,
242
+ clearFilterOnOptionToggle,
238
243
  hide,
239
- setSelectedIndexes,
240
244
  ],
241
245
  );
242
246
  let getMenuItem = _react.useCallback(
@@ -148,6 +148,14 @@ const DatePicker = _react.forwardRef((props, forwardedRef) => {
148
148
  showDatesOutsideMonth = true,
149
149
  ...rest
150
150
  } = props;
151
+ let logWarning = (0, _index.useWarningLogger)();
152
+ {
153
+ let onlyOneRangePropPassed = (startDate ? 1 : 0) + (endDate ? 1 : 0) === 1;
154
+ if (enableRangeSelect && onlyOneRangePropPassed)
155
+ logWarning(
156
+ '`DatePicker` with `enableRangeSelect` needs *both* `startDate` and `endDate` to either be `Date` or `undefined`. Passing `Date` to just one of them is not allowed.',
157
+ );
158
+ }
151
159
  let monthNames = localizedNames?.months ?? defaultMonths;
152
160
  let shortDays = localizedNames?.shortDays ?? defaultShortDays;
153
161
  let longDays = localizedNames?.days ?? defaultLongDays;
@@ -192,7 +200,7 @@ const DatePicker = _react.forwardRef((props, forwardedRef) => {
192
200
  let popoverInitialFocusContext = _react.useContext(
193
201
  _Popover.PopoverInitialFocusContext,
194
202
  );
195
- _react.useLayoutEffect(() => {
203
+ (0, _index.useLayoutEffect)(() => {
196
204
  if (setFocus && popoverInitialFocusContext)
197
205
  popoverInitialFocusContext.setInitialFocus(-1);
198
206
  }, [popoverInitialFocusContext, setFocus]);
@@ -23,7 +23,7 @@ const _reacttransitiongroup = require('react-transition-group');
23
23
  const DialogComponent = _react.forwardRef((props, ref) => {
24
24
  let {
25
25
  trapFocus = false,
26
- setFocus = false,
26
+ setFocus = trapFocus,
27
27
  preventDocumentScroll = false,
28
28
  isOpen = false,
29
29
  isDismissible = true,
@@ -8,15 +8,13 @@ Object.defineProperty(exports, 'HeaderDropdownButton', {
8
8
  return HeaderDropdownButton;
9
9
  },
10
10
  });
11
- const _interop_require_default = require('@swc/helpers/_/_interop_require_default');
12
11
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
13
- const _classnames = _interop_require_default._(require('classnames'));
14
12
  const _react = _interop_require_wildcard._(require('react'));
15
13
  const _DropdownMenu = require('../DropdownMenu/DropdownMenu.js');
16
14
  const _index = require('../../utils/index.js');
17
15
  const _HeaderBasicButton = require('./HeaderBasicButton.js');
18
16
  const HeaderDropdownButton = _react.forwardRef((props, ref) => {
19
- let { menuItems, className, children, ...rest } = props;
17
+ let { menuItems, children, ...rest } = props;
20
18
  let [isMenuOpen, setIsMenuOpen] = _react.useState(false);
21
19
  let [menuWidth, setMenuWidth] = _react.useState(0);
22
20
  let buttonRef = _react.useRef(null);
@@ -36,10 +34,6 @@ const HeaderDropdownButton = _react.forwardRef((props, ref) => {
36
34
  _react.createElement(
37
35
  _HeaderBasicButton.HeaderBasicButton,
38
36
  {
39
- className: (0, _classnames.default)(
40
- 'iui-header-breadcrumb-button',
41
- className,
42
- ),
43
37
  ref: refs,
44
38
  'aria-label': 'Dropdown',
45
39
  endIcon: isMenuOpen
@@ -0,0 +1,322 @@
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
+ Panels: function () {
14
+ return Panels;
15
+ },
16
+ PanelsWrapper: function () {
17
+ return PanelsWrapper;
18
+ },
19
+ PanelsWrapperContext: function () {
20
+ return PanelsWrapperContext;
21
+ },
22
+ });
23
+ const _interop_require_default = require('@swc/helpers/_/_interop_require_default');
24
+ const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
25
+ const _react = _interop_require_wildcard._(require('react'));
26
+ const _reactdom = _interop_require_wildcard._(require('react-dom'));
27
+ const _index = require('../../utils/index.js');
28
+ const _IconButton = require('../Buttons/IconButton.js');
29
+ const _Flex = require('../Flex/Flex.js');
30
+ const _Text = require('../Typography/Text.js');
31
+ const _classnames = _interop_require_default._(require('classnames'));
32
+ const _helpers = require('./helpers.js');
33
+ const PanelsWrapper = _react.forwardRef((props, forwardedRef) => {
34
+ let {
35
+ children,
36
+ className,
37
+ onActiveIdChange: onActiveIdChangeProp,
38
+ instance,
39
+ ...rest
40
+ } = props;
41
+ let onActiveIdChange = (0, _index.useLatestRef)(onActiveIdChangeProp);
42
+ let ref = _react.useRef(null);
43
+ let [activePanelId, setActivePanelId] = _react.useState(void 0);
44
+ let [triggers, setTriggers] = _react.useState({});
45
+ let panels = _react.useRef(new Set());
46
+ let [shouldFocus, setShouldFocus] = _react.useState(void 0);
47
+ let motionOk = (0, _index.useMediaQuery)(
48
+ '(prefers-reduced-motion: no-preference)',
49
+ );
50
+ let changeActivePanel = _react.useCallback(
51
+ (newActiveId) => {
52
+ if (!panels.current.has(newActiveId) || newActiveId === activePanelId)
53
+ return;
54
+ _reactdom.flushSync(() => setActivePanelId(newActiveId));
55
+ onActiveIdChange.current?.(newActiveId);
56
+ ref.current
57
+ ?.getRootNode()
58
+ .getElementById(newActiveId)
59
+ ?.scrollIntoView({
60
+ block: 'nearest',
61
+ inline: 'center',
62
+ behavior: motionOk ? 'smooth' : 'instant',
63
+ });
64
+ },
65
+ [activePanelId, motionOk, onActiveIdChange],
66
+ );
67
+ return _react.createElement(
68
+ PanelsWrapperContext.Provider,
69
+ {
70
+ value: _react.useMemo(
71
+ () => ({
72
+ activePanelId,
73
+ setActivePanelId,
74
+ changeActivePanel,
75
+ triggers,
76
+ setTriggers,
77
+ shouldFocus,
78
+ setShouldFocus,
79
+ panels,
80
+ }),
81
+ [
82
+ activePanelId,
83
+ changeActivePanel,
84
+ setActivePanelId,
85
+ setTriggers,
86
+ shouldFocus,
87
+ triggers,
88
+ ],
89
+ ),
90
+ },
91
+ _react.createElement(
92
+ _helpers.PanelsInstanceProvider,
93
+ {
94
+ instance: instance,
95
+ },
96
+ _react.createElement(
97
+ _index.Box,
98
+ {
99
+ ref: (0, _index.useMergedRefs)(ref, forwardedRef),
100
+ ...rest,
101
+ className: (0, _classnames.default)('iui-panel-wrapper', className),
102
+ },
103
+ children,
104
+ ),
105
+ ),
106
+ );
107
+ });
108
+ PanelsWrapper.displayName = 'Panels.Wrapper';
109
+ const PanelsWrapperContext = _react.createContext(void 0);
110
+ PanelsWrapperContext.displayName = 'PanelsWrapperContext';
111
+ const Panel = _react.forwardRef((props, forwardedRef) => {
112
+ let { id, children, className, ...rest } = props;
113
+ let { activePanelId, triggers, panels, setActivePanelId } = (0,
114
+ _index.useSafeContext)(PanelsWrapperContext);
115
+ let associatedTrigger = _react.useMemo(() => triggers[id], [id, triggers]);
116
+ let previousActivePanelId = useDelayed(activePanelId) || activePanelId;
117
+ let isMounted = [activePanelId, previousActivePanelId].includes(id);
118
+ let isTransitioning =
119
+ activePanelId === id && activePanelId !== previousActivePanelId;
120
+ let isInert = previousActivePanelId === id && activePanelId !== id;
121
+ (0, _index.useLayoutEffect)(() => {
122
+ let isFirstPanel = null == activePanelId && 0 === panels.current.size;
123
+ if (isFirstPanel) setActivePanelId(id);
124
+ let panelsCurrent = panels.current;
125
+ if (!panelsCurrent.has(id)) panelsCurrent.add(id);
126
+ return () => {
127
+ panelsCurrent.delete(id);
128
+ };
129
+ }, [activePanelId, id, panels, setActivePanelId]);
130
+ return _react.createElement(
131
+ PanelContext.Provider,
132
+ {
133
+ value: _react.useMemo(
134
+ () => ({
135
+ id,
136
+ associatedTrigger,
137
+ }),
138
+ [associatedTrigger, id],
139
+ ),
140
+ },
141
+ isMounted &&
142
+ _react.createElement(
143
+ _index.Box,
144
+ {
145
+ ref: forwardedRef,
146
+ id: id,
147
+ className: (0, _classnames.default)('iui-panel', className),
148
+ 'aria-labelledby': `${id}-header-title`,
149
+ role: 'group',
150
+ inert: isInert ? '' : void 0,
151
+ 'data-iui-transitioning': isTransitioning ? 'true' : void 0,
152
+ ...rest,
153
+ },
154
+ children,
155
+ ),
156
+ );
157
+ });
158
+ Panel.displayName = 'Panels.Panel';
159
+ const PanelContext = _react.createContext(void 0);
160
+ PanelContext.displayName = 'PanelContext';
161
+ const PanelTrigger = (props) => {
162
+ let { children, for: forProp } = props;
163
+ let {
164
+ changeActivePanel,
165
+ triggers,
166
+ setTriggers,
167
+ activePanelId: activePanel,
168
+ shouldFocus,
169
+ setShouldFocus,
170
+ panels,
171
+ } = (0, _index.useSafeContext)(PanelsWrapperContext);
172
+ let { id: panelId } = (0, _index.useSafeContext)(PanelContext);
173
+ let fallbackId = _react.useId();
174
+ let triggerId = children.props.id || fallbackId;
175
+ let onClick = _react.useCallback(() => {
176
+ if (null == activePanel) return;
177
+ setShouldFocus({
178
+ fromPanelId: activePanel,
179
+ toPanelId: forProp,
180
+ direction: 'forward',
181
+ });
182
+ changeActivePanel?.(forProp);
183
+ }, [activePanel, changeActivePanel, forProp, setShouldFocus]);
184
+ let focusRef = _react.useCallback(
185
+ (el) => {
186
+ if (
187
+ shouldFocus?.direction === 'backward' &&
188
+ shouldFocus?.toPanelId === panelId &&
189
+ shouldFocus?.fromPanelId === forProp
190
+ ) {
191
+ el?.focus({
192
+ preventScroll: true,
193
+ });
194
+ setShouldFocus(void 0);
195
+ }
196
+ },
197
+ [forProp, panelId, setShouldFocus, shouldFocus],
198
+ );
199
+ let logWarning = (0, _index.useWarningLogger)();
200
+ _react.useEffect(() => {
201
+ if (!panels.current.has(forProp))
202
+ logWarning(
203
+ `Panels.Trigger's \`for\` prop ("${forProp}") corresponds to no Panel.`,
204
+ );
205
+ }, [forProp, logWarning, panels, triggers]);
206
+ _react.useEffect(() => {
207
+ setTriggers((oldTriggers) => {
208
+ let triggersMatch = oldTriggers[forProp];
209
+ if (
210
+ null == triggersMatch ||
211
+ panelId !== triggersMatch.panelId ||
212
+ triggerId !== triggersMatch.triggerId
213
+ )
214
+ return {
215
+ ...oldTriggers,
216
+ [forProp]: {
217
+ panelId,
218
+ triggerId,
219
+ },
220
+ };
221
+ return oldTriggers;
222
+ });
223
+ }, [forProp, panelId, setTriggers, triggerId]);
224
+ return (0, _index.cloneElementWithRef)(children, (children) => ({
225
+ ...children.props,
226
+ id: triggerId,
227
+ ref: focusRef,
228
+ onClick: (0, _index.mergeEventHandlers)(children.props.onClick, onClick),
229
+ 'aria-expanded': activePanel === forProp,
230
+ 'aria-controls': forProp,
231
+ }));
232
+ };
233
+ PanelTrigger.displayName = 'Panels.Trigger';
234
+ const PanelHeader = _react.forwardRef((props, forwardedRef) => {
235
+ let { titleProps, children, ...rest } = props;
236
+ let { shouldFocus, setShouldFocus } = (0, _index.useSafeContext)(
237
+ PanelsWrapperContext,
238
+ );
239
+ let { id: panelId, associatedTrigger: panelAssociatedTrigger } = (0,
240
+ _index.useSafeContext)(PanelContext);
241
+ let focusRef = _react.useCallback(
242
+ (el) => {
243
+ if (
244
+ shouldFocus?.direction === 'forward' &&
245
+ shouldFocus.toPanelId === panelId
246
+ ) {
247
+ el?.focus({
248
+ preventScroll: true,
249
+ });
250
+ setShouldFocus(void 0);
251
+ }
252
+ },
253
+ [panelId, setShouldFocus, shouldFocus?.direction, shouldFocus?.toPanelId],
254
+ );
255
+ return _react.createElement(
256
+ _Flex.Flex,
257
+ {
258
+ ref: forwardedRef,
259
+ ...rest,
260
+ },
261
+ panelAssociatedTrigger && _react.createElement(PanelBackButton, null),
262
+ _react.createElement(
263
+ _Text.Text,
264
+ {
265
+ id: `${panelId}-header-title`,
266
+ as: 'h2',
267
+ tabIndex: -1,
268
+ ref: focusRef,
269
+ ...titleProps,
270
+ },
271
+ children,
272
+ ),
273
+ );
274
+ });
275
+ PanelHeader.displayName = 'Panels.Header';
276
+ const PanelBackButton = _react.forwardRef((props, forwardedRef) => {
277
+ let { children, onClick, ...rest } = props;
278
+ let { instance: panelInstance } = (0, _index.useSafeContext)(
279
+ _helpers.PanelsInstanceContext,
280
+ );
281
+ return _react.createElement(
282
+ _IconButton.IconButton,
283
+ {
284
+ ref: forwardedRef,
285
+ 'aria-label': 'Previous panel',
286
+ styleType: 'borderless',
287
+ size: 'small',
288
+ 'data-iui-shift': 'left',
289
+ ...rest,
290
+ onClick: (0, _index.mergeEventHandlers)(
291
+ _react.useCallback(() => panelInstance?.goBack(), [panelInstance]),
292
+ onClick,
293
+ ),
294
+ },
295
+ children || _react.createElement(_index.SvgChevronLeft, null),
296
+ );
297
+ });
298
+ PanelBackButton.displayName = 'Panels.BackButton';
299
+ const Panels = {
300
+ Wrapper: PanelsWrapper,
301
+ Panel,
302
+ Trigger: PanelTrigger,
303
+ Header: PanelHeader,
304
+ useInstance: _index.useInstance,
305
+ };
306
+ function useDelayed(
307
+ value,
308
+ { delay } = {
309
+ delay: 500,
310
+ },
311
+ ) {
312
+ let [delayed, setDelayed] = _react.useState(void 0);
313
+ let timeout = _react.useRef(void 0);
314
+ _react.useEffect(() => {
315
+ if (0 === delay) setDelayed(value);
316
+ else timeout.current = setTimeout(() => setDelayed(value), delay);
317
+ return () => {
318
+ clearTimeout(timeout.current);
319
+ };
320
+ }, [value, delay]);
321
+ return delayed;
322
+ }
@@ -0,0 +1,62 @@
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
+ PanelsInstanceContext: function () {
14
+ return PanelsInstanceContext;
15
+ },
16
+ PanelsInstanceProvider: function () {
17
+ return PanelsInstanceProvider;
18
+ },
19
+ });
20
+ const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
21
+ const _react = _interop_require_wildcard._(require('react'));
22
+ const _index = require('../../utils/index.js');
23
+ const _Panels = require('./Panels.js');
24
+ const PanelsInstanceContext = _react.createContext(void 0);
25
+ PanelsInstanceContext.displayName = 'PanelsInstanceContext';
26
+ const PanelsInstanceProvider = (props) => {
27
+ let { children, instance: instanceProp } = props;
28
+ let instanceBackup = _Panels.Panels.useInstance();
29
+ let instance = instanceProp || instanceBackup;
30
+ let { activePanelId, changeActivePanel, triggers, setShouldFocus } = (0,
31
+ _index.useSafeContext)(_Panels.PanelsWrapperContext);
32
+ let goBack = _react.useCallback(async () => {
33
+ if (null == activePanelId) return;
34
+ let trigger = triggers[activePanelId];
35
+ if (null != trigger.triggerId) {
36
+ setShouldFocus({
37
+ fromPanelId: activePanelId,
38
+ toPanelId: trigger.panelId,
39
+ direction: 'backward',
40
+ });
41
+ changeActivePanel(trigger.panelId);
42
+ }
43
+ }, [activePanelId, changeActivePanel, setShouldFocus, triggers]);
44
+ (0, _index.useSynchronizeInstance)(
45
+ instance,
46
+ _react.useMemo(
47
+ () => ({
48
+ goBack,
49
+ }),
50
+ [goBack],
51
+ ),
52
+ );
53
+ return _react.createElement(
54
+ PanelsInstanceContext.Provider,
55
+ {
56
+ value: {
57
+ instance,
58
+ },
59
+ },
60
+ children,
61
+ );
62
+ };
@@ -28,7 +28,7 @@ const Radio = _react.forwardRef((props, ref) => {
28
28
  let refs = (0, _index.useMergedRefs)(inputElementRef, ref);
29
29
  let radio = _react.createElement(_index.Box, {
30
30
  as: 'input',
31
- className: (0, _classnames.default)('iui-radio', className),
31
+ className: (0, _classnames.default)('iui-checkbox', 'iui-radio', className),
32
32
  style: style,
33
33
  disabled: disabled,
34
34
  type: 'radio',
@@ -42,13 +42,11 @@ const Radio = _react.forwardRef((props, ref) => {
42
42
  as: 'label',
43
43
  ...wrapperProps,
44
44
  className: (0, _classnames.default)(
45
- 'iui-radio-wrapper',
46
- {
47
- 'iui-disabled': disabled,
48
- [`iui-${status}`]: !!status,
49
- },
45
+ 'iui-checkbox-wrapper',
50
46
  wrapperProps?.className,
51
47
  ),
48
+ 'data-iui-status': status,
49
+ 'data-iui-disabled': disabled ? 'true' : void 0,
52
50
  },
53
51
  radio,
54
52
  label &&
@@ -8,12 +8,14 @@ Object.defineProperty(exports, 'RadioTileGroup', {
8
8
  return RadioTileGroup;
9
9
  },
10
10
  });
11
+ const _interop_require_default = require('@swc/helpers/_/_interop_require_default');
11
12
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
12
13
  const _react = _interop_require_wildcard._(require('react'));
13
14
  const _InputGroup = require('../InputGroup/InputGroup.js');
14
15
  const _index = require('../../utils/index.js');
16
+ const _classnames = _interop_require_default._(require('classnames'));
15
17
  const RadioTileGroup = _react.forwardRef((props, forwardedRef) => {
16
- let { children, label, ...rest } = props;
18
+ let { children, label, tileContainerProps, ...rest } = props;
17
19
  return _react.createElement(
18
20
  _InputGroup.InputGroup,
19
21
  {
@@ -24,7 +26,12 @@ const RadioTileGroup = _react.forwardRef((props, forwardedRef) => {
24
26
  _react.createElement(
25
27
  _index.Box,
26
28
  {
27
- className: 'iui-radio-tile-container',
29
+ as: 'div',
30
+ ...tileContainerProps,
31
+ className: (0, _classnames.default)(
32
+ 'iui-radio-tile-container',
33
+ tileContainerProps?.className,
34
+ ),
28
35
  },
29
36
  children,
30
37
  ),
@@ -12,24 +12,22 @@ const _interop_require_default = require('@swc/helpers/_/_interop_require_defaul
12
12
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
13
13
  const _classnames = _interop_require_default._(require('classnames'));
14
14
  const _react = _interop_require_wildcard._(require('react'));
15
- const _index = require('../../utils/index.js');
15
+ const _Tag = require('../Tag/Tag.js');
16
16
  const SelectTag = _react.forwardRef((props, forwardedRef) => {
17
17
  let { className, label, ...rest } = props;
18
18
  return _react.createElement(
19
- _index.Box,
19
+ _Tag.Tag,
20
20
  {
21
- as: 'span',
22
21
  className: (0, _classnames.default)('iui-select-tag', className),
22
+ labelProps: {
23
+ className: 'iui-select-tag-label',
24
+ },
25
+ removeButtonProps: {
26
+ className: 'iui-select-tag-button',
27
+ },
23
28
  ref: forwardedRef,
24
29
  ...rest,
25
30
  },
26
- _react.createElement(
27
- _index.Box,
28
- {
29
- as: 'span',
30
- className: 'iui-select-tag-label',
31
- },
32
- label,
33
- ),
31
+ label,
34
32
  );
35
33
  });