@itwin/itwinui-react 3.0.0-dev.1 → 3.0.0-dev.2

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 (211) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/cjs/core/Alert/Alert.d.ts +47 -28
  3. package/cjs/core/Alert/Alert.js +73 -21
  4. package/cjs/core/Avatar/Avatar.js +1 -1
  5. package/cjs/core/AvatarGroup/AvatarGroup.js +1 -1
  6. package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
  7. package/cjs/core/ButtonGroup/ButtonGroup.js +1 -4
  8. package/cjs/core/Buttons/DropdownButton/DropdownButton.js +3 -5
  9. package/cjs/core/Carousel/Carousel.d.ts +2 -2
  10. package/cjs/core/Carousel/Carousel.js +3 -5
  11. package/cjs/core/Carousel/CarouselDotsList.js +8 -10
  12. package/cjs/core/Carousel/CarouselNavigation.d.ts +2 -2
  13. package/cjs/core/Carousel/CarouselNavigation.js +3 -5
  14. package/cjs/core/Carousel/CarouselSlider.js +10 -15
  15. package/cjs/core/ColorPicker/ColorBuilder.js +7 -10
  16. package/cjs/core/ColorPicker/ColorInputPanel.js +12 -15
  17. package/cjs/core/ColorPicker/ColorPalette.js +4 -6
  18. package/cjs/core/ColorPicker/ColorPicker.js +3 -3
  19. package/cjs/core/ComboBox/ComboBox.js +25 -32
  20. package/cjs/core/ComboBox/ComboBoxDropdown.js +1 -2
  21. package/cjs/core/ComboBox/ComboBoxEndIcon.js +1 -1
  22. package/cjs/core/ComboBox/ComboBoxInput.js +21 -20
  23. package/cjs/core/ComboBox/ComboBoxMenu.js +3 -4
  24. package/cjs/core/ComboBox/ComboBoxMenuItem.js +2 -2
  25. package/cjs/core/ComboBox/helpers.js +4 -5
  26. package/cjs/core/DatePicker/DatePicker.js +32 -32
  27. package/cjs/core/Dialog/Dialog.js +11 -4
  28. package/cjs/core/Dialog/DialogBackdrop.js +1 -1
  29. package/cjs/core/Dialog/DialogContext.d.ts +11 -0
  30. package/cjs/core/Dialog/DialogMain.js +16 -22
  31. package/cjs/core/DropdownMenu/DropdownMenu.js +6 -8
  32. package/cjs/core/ExpandableBlock/ExpandableBlock.js +2 -2
  33. package/cjs/core/FileUpload/FileEmptyCard.js +1 -1
  34. package/cjs/core/FileUpload/FileUpload.js +3 -6
  35. package/cjs/core/FileUpload/FileUploadCard.js +9 -10
  36. package/cjs/core/InformationPanel/InformationPanel.js +1 -4
  37. package/cjs/core/LabeledInput/LabeledInput.js +1 -1
  38. package/cjs/core/LabeledTextarea/LabeledTextarea.js +1 -1
  39. package/cjs/core/Menu/Menu.js +3 -4
  40. package/cjs/core/Menu/MenuItem.js +8 -11
  41. package/cjs/core/Modal/Modal.d.ts +8 -9
  42. package/cjs/core/Modal/Modal.js +7 -17
  43. package/cjs/core/SearchBox/SearchBox.js +12 -12
  44. package/cjs/core/Select/Select.js +12 -17
  45. package/cjs/core/SideNavigation/SideNavigation.js +2 -2
  46. package/cjs/core/Slider/Slider.js +16 -19
  47. package/cjs/core/Slider/Thumb.js +1 -1
  48. package/cjs/core/StatusMessage/StatusMessage.js +1 -1
  49. package/cjs/core/Stepper/Stepper.js +1 -1
  50. package/cjs/core/Stepper/StepperStep.js +1 -1
  51. package/cjs/core/Table/Table.js +15 -15
  52. package/cjs/core/Table/TablePaginator.js +2 -3
  53. package/cjs/core/Table/TableRowMemoized.js +38 -45
  54. package/cjs/core/Table/actionHandlers/expandHandler.js +3 -3
  55. package/cjs/core/Table/actionHandlers/filterHandler.js +4 -5
  56. package/cjs/core/Table/actionHandlers/selectHandler.js +6 -6
  57. package/cjs/core/Table/cells/DefaultCell.js +1 -1
  58. package/cjs/core/Table/cells/EditableCell.js +6 -12
  59. package/cjs/core/Table/columns/actionColumn.js +3 -6
  60. package/cjs/core/Table/columns/expanderColumn.js +3 -3
  61. package/cjs/core/Table/columns/selectionColumn.js +4 -4
  62. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
  63. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
  64. package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
  65. package/cjs/core/Table/filters/TextFilter/TextFilter.js +1 -2
  66. package/cjs/core/Table/hooks/useResizeColumns.js +16 -22
  67. package/cjs/core/Table/hooks/useScrollToRow.js +1 -2
  68. package/cjs/core/Table/hooks/useStickyColumns.js +3 -5
  69. package/cjs/core/Table/hooks/useSubRowFiltering.js +2 -4
  70. package/cjs/core/Tabs/Tabs.js +13 -16
  71. package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
  72. package/cjs/core/ThemeProvider/ThemeProvider.d.ts +2 -3
  73. package/cjs/core/ThemeProvider/ThemeProvider.js +11 -13
  74. package/cjs/core/Tile/Tile.js +2 -3
  75. package/cjs/core/TimePicker/TimePicker.js +13 -13
  76. package/cjs/core/Toast/Toast.js +2 -3
  77. package/cjs/core/Toast/Toaster.js +6 -11
  78. package/cjs/core/TransferList/TransferList.js +3 -4
  79. package/cjs/core/Tree/Tree.js +9 -13
  80. package/cjs/core/Tree/TreeNode.js +9 -10
  81. package/cjs/core/utils/color/ColorValue.js +9 -15
  82. package/cjs/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
  83. package/cjs/core/utils/components/FocusTrap.js +4 -4
  84. package/cjs/core/utils/components/MiddleTextTruncation.js +1 -2
  85. package/cjs/core/utils/components/Popover.js +5 -8
  86. package/cjs/core/utils/components/Resizer.js +7 -6
  87. package/cjs/core/utils/components/VirtualScroll.js +14 -21
  88. package/cjs/core/utils/functions/dom.js +5 -5
  89. package/cjs/core/utils/functions/polymorphic.js +1 -1
  90. package/cjs/core/utils/functions/supports.js +1 -1
  91. package/cjs/core/utils/hooks/index.d.ts +0 -1
  92. package/cjs/core/utils/hooks/index.js +0 -1
  93. package/cjs/core/utils/hooks/useContainerWidth.js +1 -1
  94. package/cjs/core/utils/hooks/useDragAndDrop.js +8 -10
  95. package/cjs/core/utils/hooks/useEventListener.js +1 -1
  96. package/cjs/core/utils/hooks/useGlobals.d.ts +9 -2
  97. package/cjs/core/utils/hooks/useGlobals.js +6 -4
  98. package/cjs/core/utils/hooks/useId.js +1 -2
  99. package/cjs/core/utils/hooks/useIntersection.js +2 -3
  100. package/cjs/core/utils/hooks/useMediaQuery.js +6 -8
  101. package/cjs/core/utils/hooks/useOverflow.js +1 -2
  102. package/cjs/core/utils/hooks/useResizeObserver.js +3 -4
  103. package/cjs/styles.js +1 -4
  104. package/esm/core/Alert/Alert.d.ts +47 -28
  105. package/esm/core/Alert/Alert.js +74 -22
  106. package/esm/core/Avatar/Avatar.js +1 -1
  107. package/esm/core/AvatarGroup/AvatarGroup.js +1 -1
  108. package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
  109. package/esm/core/ButtonGroup/ButtonGroup.js +1 -4
  110. package/esm/core/Buttons/DropdownButton/DropdownButton.js +3 -5
  111. package/esm/core/Carousel/Carousel.d.ts +2 -2
  112. package/esm/core/Carousel/Carousel.js +3 -5
  113. package/esm/core/Carousel/CarouselDotsList.js +8 -10
  114. package/esm/core/Carousel/CarouselNavigation.d.ts +2 -2
  115. package/esm/core/Carousel/CarouselNavigation.js +3 -5
  116. package/esm/core/Carousel/CarouselSlider.js +10 -15
  117. package/esm/core/ColorPicker/ColorBuilder.js +7 -10
  118. package/esm/core/ColorPicker/ColorInputPanel.js +12 -15
  119. package/esm/core/ColorPicker/ColorPalette.js +4 -6
  120. package/esm/core/ColorPicker/ColorPicker.js +3 -3
  121. package/esm/core/ComboBox/ComboBox.js +25 -32
  122. package/esm/core/ComboBox/ComboBoxDropdown.js +1 -2
  123. package/esm/core/ComboBox/ComboBoxEndIcon.js +1 -1
  124. package/esm/core/ComboBox/ComboBoxInput.js +21 -20
  125. package/esm/core/ComboBox/ComboBoxMenu.js +3 -4
  126. package/esm/core/ComboBox/ComboBoxMenuItem.js +2 -2
  127. package/esm/core/ComboBox/helpers.js +4 -5
  128. package/esm/core/DatePicker/DatePicker.js +32 -32
  129. package/esm/core/Dialog/Dialog.js +12 -5
  130. package/esm/core/Dialog/DialogBackdrop.js +1 -1
  131. package/esm/core/Dialog/DialogContext.d.ts +11 -0
  132. package/esm/core/Dialog/DialogMain.js +16 -22
  133. package/esm/core/DropdownMenu/DropdownMenu.js +6 -8
  134. package/esm/core/ExpandableBlock/ExpandableBlock.js +2 -2
  135. package/esm/core/FileUpload/FileEmptyCard.js +1 -1
  136. package/esm/core/FileUpload/FileUpload.js +3 -6
  137. package/esm/core/FileUpload/FileUploadCard.js +9 -10
  138. package/esm/core/InformationPanel/InformationPanel.js +1 -4
  139. package/esm/core/LabeledInput/LabeledInput.js +1 -1
  140. package/esm/core/LabeledTextarea/LabeledTextarea.js +1 -1
  141. package/esm/core/Menu/Menu.js +3 -4
  142. package/esm/core/Menu/MenuItem.js +8 -11
  143. package/esm/core/Modal/Modal.d.ts +8 -9
  144. package/esm/core/Modal/Modal.js +3 -10
  145. package/esm/core/SearchBox/SearchBox.js +12 -12
  146. package/esm/core/Select/Select.js +12 -17
  147. package/esm/core/SideNavigation/SideNavigation.js +2 -2
  148. package/esm/core/Slider/Slider.js +16 -19
  149. package/esm/core/Slider/Thumb.js +1 -1
  150. package/esm/core/StatusMessage/StatusMessage.js +1 -1
  151. package/esm/core/Stepper/Stepper.js +1 -1
  152. package/esm/core/Stepper/StepperStep.js +1 -1
  153. package/esm/core/Table/Table.js +15 -15
  154. package/esm/core/Table/TablePaginator.js +2 -3
  155. package/esm/core/Table/TableRowMemoized.js +38 -45
  156. package/esm/core/Table/actionHandlers/expandHandler.js +3 -3
  157. package/esm/core/Table/actionHandlers/filterHandler.js +4 -5
  158. package/esm/core/Table/actionHandlers/selectHandler.js +6 -6
  159. package/esm/core/Table/cells/DefaultCell.js +1 -1
  160. package/esm/core/Table/cells/EditableCell.js +6 -12
  161. package/esm/core/Table/columns/actionColumn.js +3 -6
  162. package/esm/core/Table/columns/expanderColumn.js +3 -3
  163. package/esm/core/Table/columns/selectionColumn.js +4 -4
  164. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
  165. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
  166. package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
  167. package/esm/core/Table/filters/TextFilter/TextFilter.js +1 -2
  168. package/esm/core/Table/hooks/useResizeColumns.js +16 -22
  169. package/esm/core/Table/hooks/useScrollToRow.js +1 -2
  170. package/esm/core/Table/hooks/useStickyColumns.js +3 -5
  171. package/esm/core/Table/hooks/useSubRowFiltering.js +2 -4
  172. package/esm/core/Tabs/Tabs.js +13 -16
  173. package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
  174. package/esm/core/ThemeProvider/ThemeProvider.d.ts +2 -3
  175. package/esm/core/ThemeProvider/ThemeProvider.js +12 -14
  176. package/esm/core/Tile/Tile.js +2 -3
  177. package/esm/core/TimePicker/TimePicker.js +13 -13
  178. package/esm/core/Toast/Toast.js +2 -3
  179. package/esm/core/Toast/Toaster.js +6 -11
  180. package/esm/core/TransferList/TransferList.js +3 -4
  181. package/esm/core/Tree/Tree.js +9 -13
  182. package/esm/core/Tree/TreeNode.js +9 -10
  183. package/esm/core/utils/color/ColorValue.js +9 -15
  184. package/esm/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
  185. package/esm/core/utils/components/FocusTrap.js +4 -4
  186. package/esm/core/utils/components/MiddleTextTruncation.js +1 -2
  187. package/esm/core/utils/components/Popover.js +5 -8
  188. package/esm/core/utils/components/Resizer.js +7 -6
  189. package/esm/core/utils/components/VirtualScroll.js +14 -21
  190. package/esm/core/utils/functions/dom.js +5 -5
  191. package/esm/core/utils/functions/polymorphic.js +1 -1
  192. package/esm/core/utils/functions/supports.js +1 -1
  193. package/esm/core/utils/hooks/index.d.ts +0 -1
  194. package/esm/core/utils/hooks/index.js +0 -1
  195. package/esm/core/utils/hooks/useContainerWidth.js +1 -1
  196. package/esm/core/utils/hooks/useDragAndDrop.js +8 -10
  197. package/esm/core/utils/hooks/useEventListener.js +1 -1
  198. package/esm/core/utils/hooks/useGlobals.d.ts +9 -2
  199. package/esm/core/utils/hooks/useGlobals.js +6 -4
  200. package/esm/core/utils/hooks/useId.js +1 -2
  201. package/esm/core/utils/hooks/useIntersection.js +2 -3
  202. package/esm/core/utils/hooks/useMediaQuery.js +6 -8
  203. package/esm/core/utils/hooks/useOverflow.js +1 -2
  204. package/esm/core/utils/hooks/useResizeObserver.js +3 -4
  205. package/esm/styles.js +1 -4
  206. package/package.json +2 -2
  207. package/styles.css +18 -20
  208. package/cjs/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
  209. package/cjs/core/utils/hooks/useIsThemeAlreadySet.js +0 -54
  210. package/esm/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
  211. package/esm/core/utils/hooks/useIsThemeAlreadySet.js +0 -27
@@ -3,6 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import * as React from 'react';
6
+ import * as ReactDOM from 'react-dom';
6
7
  import cx from 'classnames';
7
8
  import { DialogTitleBar } from './DialogTitleBar.js';
8
9
  import { DialogContent } from './DialogContent.js';
@@ -10,11 +11,18 @@ import { DialogBackdrop } from './DialogBackdrop.js';
10
11
  import { DialogContext } from './DialogContext.js';
11
12
  import { DialogButtonBar } from './DialogButtonBar.js';
12
13
  import { DialogMain } from './DialogMain.js';
13
- import { useMergedRefs, Box } from '../utils/index.js';
14
+ import { useMergedRefs, Box, useGlobals, getDocument, useIsClient, } from '../utils/index.js';
14
15
  const DialogComponent = React.forwardRef((props, ref) => {
15
- const { trapFocus = false, setFocus = false, preventDocumentScroll = false, isOpen = false, isDismissible = true, closeOnEsc = true, closeOnExternalClick = false, onClose, isDraggable = false, isResizable = false, relativeTo = 'viewport', placement, className, ...rest } = props;
16
+ const { trapFocus = false, setFocus = false, preventDocumentScroll = false, isOpen = false, isDismissible = true, closeOnEsc = true, closeOnExternalClick = false, onClose, isDraggable = false, isResizable = false, relativeTo = 'viewport', placement, className, portal = false, ...rest } = props;
16
17
  const dialogRootRef = React.useRef(null);
17
- const refs = useMergedRefs(ref, dialogRootRef);
18
+ const context = useGlobals();
19
+ const isClient = useIsClient();
20
+ const portalTo = typeof portal !== 'boolean'
21
+ ? portal.to
22
+ : portal
23
+ ? context?.portalContainerRef?.current ?? getDocument()?.body
24
+ : null;
25
+ const dialog = (React.createElement(Box, { className: cx('iui-dialog-wrapper', className), "data-iui-relative": relativeTo === 'container', ref: useMergedRefs(ref, dialogRootRef), ...rest }));
18
26
  return (React.createElement(DialogContext.Provider, { value: {
19
27
  isOpen,
20
28
  onClose,
@@ -29,8 +37,7 @@ const DialogComponent = React.forwardRef((props, ref) => {
29
37
  relativeTo,
30
38
  dialogRootRef,
31
39
  placement,
32
- } },
33
- React.createElement(Box, { className: cx('iui-dialog-wrapper', className), "data-iui-relative": relativeTo === 'container', ref: refs, ...rest })));
40
+ } }, portalTo && isClient ? ReactDOM.createPortal(dialog, portalTo) : dialog));
34
41
  });
35
42
  /**
36
43
  * Dialog component.
@@ -27,7 +27,7 @@ export const DialogBackdrop = React.forwardRef((props, ref) => {
27
27
  if (isDismissible && closeOnExternalClick && onClose) {
28
28
  onClose(event);
29
29
  }
30
- onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
30
+ onMouseDown?.(event);
31
31
  };
32
32
  return (React.createElement(Backdrop, { isVisible: isVisible, className: cx({ 'iui-backdrop-fixed': relativeTo === 'viewport' }, className), ref: refs, onMouseDown: handleMouseDown, style: {
33
33
  pointerEvents: 'auto',
@@ -61,6 +61,17 @@ export declare type DialogContextProps = {
61
61
  * @default 'viewport'
62
62
  */
63
63
  relativeTo?: 'container' | 'viewport';
64
+ /**
65
+ * If true, the dialog will be portaled into a <div> inside the nearest `ThemeProvider`.
66
+ * Recommended to set to true when for modal dialogs that use `relativeTo='viewport'`.
67
+ *
68
+ * Can be set to an object with a `to` property to portal into a specific element.
69
+ *
70
+ * @default false
71
+ */
72
+ portal?: boolean | {
73
+ to: HTMLElement;
74
+ };
64
75
  /**
65
76
  * Dialog root ref. For internal use.
66
77
  */
@@ -45,8 +45,7 @@ export const DialogMain = React.forwardRef((props, ref) => {
45
45
  }, [isOpen]);
46
46
  // Prevents document from scrolling when the dialog is open.
47
47
  React.useEffect(() => {
48
- var _a;
49
- const ownerDocument = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument;
48
+ const ownerDocument = dialogRef.current?.ownerDocument;
50
49
  // If there is no `ownerDocument` or `preventDocumentScroll` is false or
51
50
  // document body originally has `overflow: hidden` (possibly from other/parent dialog), then do nothing.
52
51
  if (!ownerDocument ||
@@ -73,7 +72,7 @@ export const DialogMain = React.forwardRef((props, ref) => {
73
72
  if (isDismissible && closeOnEsc && event.key === 'Escape' && onClose) {
74
73
  onClose(event);
75
74
  }
76
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
75
+ onKeyDown?.(event);
77
76
  };
78
77
  const { onPointerDown, transform } = useDragAndDrop(dialogRef, dialogContext.dialogRootRef, isDraggable);
79
78
  const handlePointerDown = React.useCallback((event) => {
@@ -83,23 +82,19 @@ export const DialogMain = React.forwardRef((props, ref) => {
83
82
  }, [isDraggable, onPointerDown]);
84
83
  // Prevents dialog from moving when window is being resized
85
84
  useIsomorphicLayoutEffect(() => {
86
- var _a;
87
85
  if (!isDraggable || !isOpen) {
88
86
  return;
89
87
  }
90
- const rect = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
88
+ const rect = dialogRef.current?.getBoundingClientRect();
91
89
  const [translateX, translateY] = getTranslateValues(dialogRef.current);
92
- setStyle((oldStyle) => {
93
- var _a, _b;
94
- return ({
95
- ...oldStyle,
96
- width: rect === null || rect === void 0 ? void 0 : rect.width,
97
- height: rect === null || rect === void 0 ? void 0 : rect.height,
98
- left: (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.offsetLeft,
99
- top: (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.offsetTop,
100
- transform: `translate(${translateX}px,${translateY}px)`,
101
- });
102
- });
90
+ setStyle((oldStyle) => ({
91
+ ...oldStyle,
92
+ width: rect?.width,
93
+ height: rect?.height,
94
+ left: dialogRef.current?.offsetLeft,
95
+ top: dialogRef.current?.offsetTop,
96
+ transform: `translate(${translateX}px,${translateY}px)`,
97
+ }));
103
98
  }, [isDraggable, isOpen]);
104
99
  const setResizeStyle = React.useCallback((newStyle) => {
105
100
  setStyle((oldStyle) => ({
@@ -131,15 +126,14 @@ export const DialogMain = React.forwardRef((props, ref) => {
131
126
  }, timeout: { exit: 600 },
132
127
  // Focuses dialog when opened
133
128
  onEntered: () => {
134
- var _a, _b;
135
- previousFocusedElement.current = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.activeElement;
136
- setFocus && ((_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true }));
129
+ previousFocusedElement.current = dialogRef.current?.ownerDocument
130
+ .activeElement;
131
+ setFocus && dialogRef.current?.focus({ preventScroll: true });
137
132
  },
138
133
  // Brings back focus to the previously focused element when closed
139
134
  onExit: () => {
140
- var _a, _b, _c;
141
- if ((_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.contains((_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.ownerDocument.activeElement)) {
142
- (_c = previousFocusedElement.current) === null || _c === void 0 ? void 0 : _c.focus();
135
+ if (dialogRef.current?.contains(dialogRef.current?.ownerDocument.activeElement)) {
136
+ previousFocusedElement.current?.focus();
143
137
  }
144
138
  }, unmountOnExit: true, nodeRef: dialogRef },
145
139
  React.createElement(DialogDragContext.Provider, { value: { onPointerDown: handlePointerDown } },
@@ -26,29 +26,27 @@ import { Menu } from '../Menu/index.js';
26
26
  */
27
27
  export const DropdownMenu = (props) => {
28
28
  const { menuItems, children, className, style, role = 'menu', visible, placement = 'bottom-start', onShow, onHide, trigger, id, ...rest } = props;
29
- const [isVisible, setIsVisible] = React.useState(visible !== null && visible !== void 0 ? visible : false);
29
+ const [isVisible, setIsVisible] = React.useState(visible ?? false);
30
30
  React.useEffect(() => {
31
- setIsVisible(visible !== null && visible !== void 0 ? visible : false);
31
+ setIsVisible(visible ?? false);
32
32
  }, [visible]);
33
33
  const open = React.useCallback(() => setIsVisible(true), []);
34
34
  const close = React.useCallback(() => setIsVisible(false), []);
35
35
  const targetRef = React.useRef(null);
36
36
  const onShowHandler = React.useCallback((instance) => {
37
37
  setIsVisible(true);
38
- onShow === null || onShow === void 0 ? void 0 : onShow(instance);
38
+ onShow?.(instance);
39
39
  }, [onShow]);
40
40
  const onHideHandler = React.useCallback((instance) => {
41
- var _a;
42
41
  setIsVisible(false);
43
- (_a = targetRef.current) === null || _a === void 0 ? void 0 : _a.focus();
44
- onHide === null || onHide === void 0 ? void 0 : onHide(instance);
42
+ targetRef.current?.focus();
43
+ onHide?.(instance);
45
44
  }, [onHide]);
46
45
  return (React.createElement(Popover, { content: React.createElement(Menu, { className: className, style: style, role: role, id: id }, React.useMemo(() => menuItems(close), [menuItems, close])), visible: trigger === undefined ? isVisible : undefined, onClickOutside: close, placement: placement, onShow: onShowHandler, onHide: onHideHandler, trigger: visible === undefined ? trigger : undefined, ...rest }, React.cloneElement(children, {
47
46
  ref: mergeRefs(targetRef, props.children.ref),
48
47
  onClick: (args) => {
49
- var _a, _b;
50
48
  trigger === undefined && (isVisible ? close() : open());
51
- (_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, args);
49
+ children.props.onClick?.(args);
52
50
  },
53
51
  })));
54
52
  };
@@ -16,7 +16,7 @@ import { StatusIconMap, WithCSSTransition, SvgChevronRight, Icon, Box, } from '.
16
16
  */
17
17
  export const ExpandableBlock = React.forwardRef((props, ref) => {
18
18
  const { caption, children, className, title, onToggle, style, isExpanded = false, endIcon, status, size = 'default', styleType = 'default', disabled = false, ...rest } = props;
19
- const icon = endIcon !== null && endIcon !== void 0 ? endIcon : (status && StatusIconMap[status]());
19
+ const icon = endIcon ?? (status && StatusIconMap[status]());
20
20
  const [expanded, setExpanded] = React.useState(isExpanded);
21
21
  React.useEffect(() => {
22
22
  setExpanded(isExpanded);
@@ -26,7 +26,7 @@ export const ExpandableBlock = React.forwardRef((props, ref) => {
26
26
  return;
27
27
  }
28
28
  setExpanded(!expanded);
29
- onToggle === null || onToggle === void 0 ? void 0 : onToggle(!expanded);
29
+ onToggle?.(!expanded);
30
30
  };
31
31
  const onKeyDown = (event) => {
32
32
  if (event.altKey || disabled) {
@@ -18,7 +18,7 @@ const FileEmptyCardText = polymorphic.span('iui-file-card-empty-action');
18
18
  // FileEmptyCard component
19
19
  const FileEmptyCardComponent = React.forwardRef((props, ref) => {
20
20
  const { children, className, ...rest } = props;
21
- return (React.createElement(Box, { className: cx('iui-file-card-empty', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : (React.createElement(React.Fragment, null,
21
+ return (React.createElement(Box, { className: cx('iui-file-card-empty', className), ref: ref, ...rest }, children ?? (React.createElement(React.Fragment, null,
22
22
  React.createElement(FileEmptyCard.Icon, null),
23
23
  React.createElement(FileEmptyCard.Text, null,
24
24
  React.createElement(FileUploadCard.InputLabel, null, "Choose a file"),
@@ -22,31 +22,28 @@ export const FileUpload = React.forwardRef((props, ref) => {
22
22
  e.stopPropagation();
23
23
  };
24
24
  const onDragEnterHandler = (e) => {
25
- var _a, _b, _c;
26
25
  e.preventDefault();
27
26
  e.stopPropagation();
28
27
  // only set active if a file is dragged over
29
- if (!isDragActive && ((_c = (_b = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.kind) === 'file') {
28
+ if (!isDragActive && e.dataTransfer?.items?.[0]?.kind === 'file') {
30
29
  setIsDragActive(true);
31
30
  }
32
31
  };
33
32
  const onDragLeaveHandler = (e) => {
34
- var _a;
35
33
  e.preventDefault();
36
34
  e.stopPropagation();
37
35
  // only set inactive if secondary target is outside the component
38
36
  if (isDragActive &&
39
- !((_a = fileUploadRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.relatedTarget))) {
37
+ !fileUploadRef.current?.contains(e.relatedTarget)) {
40
38
  setIsDragActive(false);
41
39
  }
42
40
  };
43
41
  const onDropHandler = (e) => {
44
- var _a;
45
42
  e.preventDefault();
46
43
  e.stopPropagation();
47
44
  if (isDragActive) {
48
45
  setIsDragActive(false);
49
- onFileDropped((_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files);
46
+ onFileDropped(e.dataTransfer?.files);
50
47
  }
51
48
  };
52
49
  return (React.createElement(Box, { className: cx('iui-file-upload', { 'iui-drag': isDragActive }, className), onDragEnter: onDragEnterHandler, onDragOver: onDragOverHandler, onDragLeave: onDragLeaveHandler, onDrop: onDropHandler, ref: refs, ...rest },
@@ -35,7 +35,7 @@ const FileUploadCardTitle = React.forwardRef((props, ref) => {
35
35
  const { children, className, ...rest } = props;
36
36
  const { files } = useSafeContext(FileUploadCardContext);
37
37
  const title = files.length > 1 ? files.length + ' files selected' : files[0].name;
38
- return (React.createElement(Box, { as: 'span', className: cx('iui-file-card-title', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : title));
38
+ return (React.createElement(Box, { as: 'span', className: cx('iui-file-card-title', className), ref: ref, ...rest }, children ?? title));
39
39
  });
40
40
  FileUploadCardTitle.displayName = 'FileUploadCard.Title';
41
41
  // ----------------------------------------------------------------------------
@@ -49,7 +49,7 @@ const FileUploadCardDescription = React.forwardRef((props, ref) => {
49
49
  if (files.length > 2) {
50
50
  description += ', and ' + (files.length - 2) + ' others';
51
51
  }
52
- return (React.createElement(Box, { as: 'span', className: cx('iui-file-card-description', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : description));
52
+ return (React.createElement(Box, { as: 'span', className: cx('iui-file-card-description', className), ref: ref, ...rest }, children ?? description));
53
53
  });
54
54
  FileUploadCardDescription.displayName = 'FileUploadCard.Description';
55
55
  // ----------------------------------------------------------------------------
@@ -70,8 +70,7 @@ const FileUploadCardInput = React.forwardRef((props, ref) => {
70
70
  const { children, onChange, id, ...rest } = props;
71
71
  const { files, onFilesChange, setInternalFiles, inputId, setInputId } = useSafeContext(FileUploadCardContext);
72
72
  const setNativeFilesRef = React.useCallback((node) => {
73
- var _a;
74
- if (!node || !((_a = getWindow()) === null || _a === void 0 ? void 0 : _a.DataTransfer)) {
73
+ if (!node || !getWindow()?.DataTransfer) {
75
74
  return;
76
75
  }
77
76
  const dataTransfer = new DataTransfer();
@@ -88,19 +87,18 @@ const FileUploadCardInput = React.forwardRef((props, ref) => {
88
87
  return (React.createElement(React.Fragment, null,
89
88
  React.createElement(VisuallyHidden, { as: 'input', type: 'file', unhideOnFocus: false, onChange: mergeEventHandlers(onChange, (e) => {
90
89
  const _files = Array.from(e.currentTarget.files || []);
91
- onFilesChange === null || onFilesChange === void 0 ? void 0 : onFilesChange(_files);
90
+ onFilesChange?.(_files);
92
91
  setInternalFiles(_files);
93
- }), ref: refs, id: id !== null && id !== void 0 ? id : inputId, ...rest }),
92
+ }), ref: refs, id: id ?? inputId, ...rest }),
94
93
  children));
95
94
  });
96
95
  FileUploadCardInput.displayName = 'FileUploadCard.Input';
97
96
  const FileUploadCardComponent = React.forwardRef((props, ref) => {
98
- var _a;
99
97
  const { className, children, files: filesProp, onFilesChange, emptyCard = React.createElement(FileEmptyCard, null), input, ...rest } = props;
100
98
  const [internalFiles, setInternalFiles] = React.useState();
101
99
  const uid = useId();
102
100
  const [inputId, setInputId] = React.useState(uid);
103
- const files = (_a = filesProp !== null && filesProp !== void 0 ? filesProp : internalFiles) !== null && _a !== void 0 ? _a : [];
101
+ const files = filesProp ?? internalFiles ?? [];
104
102
  return (React.createElement(FileUploadCardContext.Provider, { value: {
105
103
  files,
106
104
  onFilesChange,
@@ -108,13 +106,14 @@ const FileUploadCardComponent = React.forwardRef((props, ref) => {
108
106
  inputId,
109
107
  setInputId,
110
108
  } },
111
- (files === null || files === void 0 ? void 0 : files.length) ? (React.createElement(Box, { className: cx('iui-file-card', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : (React.createElement(React.Fragment, null,
109
+ files?.length ? (React.createElement(Box, { className: cx('iui-file-card', className), ref: ref, ...rest }, children ?? (React.createElement(React.Fragment, null,
112
110
  React.createElement(FileUploadCard.Icon, null),
113
111
  React.createElement(FileUploadCard.Info, null,
114
112
  React.createElement(FileUploadCard.Title, null),
115
113
  React.createElement(FileUploadCard.Description, null)),
116
114
  React.createElement(FileUploadCard.Action, null,
117
- React.createElement(FileUploadCard.InputLabel, null, "Replace")))))) : (emptyCard), input !== null && input !== void 0 ? input : React.createElement(FileUploadCard.Input, null)));
115
+ React.createElement(FileUploadCard.InputLabel, null, "Replace")))))) : (emptyCard),
116
+ input ?? React.createElement(FileUploadCard.Input, null)));
118
117
  });
119
118
  /**
120
119
  * Default card to be used with the `FileUpload` wrapper component for single-file uploading.
@@ -40,10 +40,7 @@ export const InformationPanel = React.forwardRef((props, ref) => {
40
40
  e.preventDefault();
41
41
  e.stopPropagation();
42
42
  infoPanelRef.current.ownerDocument.addEventListener('pointermove', onResize);
43
- infoPanelRef.current.ownerDocument.addEventListener('pointerup', () => {
44
- var _a;
45
- return (_a = infoPanelRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.removeEventListener('pointermove', onResize);
46
- }, { once: true });
43
+ infoPanelRef.current.ownerDocument.addEventListener('pointerup', () => infoPanelRef.current?.ownerDocument.removeEventListener('pointermove', onResize), { once: true });
47
44
  };
48
45
  const onResize = React.useCallback((e) => {
49
46
  e.preventDefault();
@@ -16,7 +16,7 @@ import { StatusIconMap, InputContainer, useId } from '../utils/index.js';
16
16
  export const LabeledInput = React.forwardRef((props, ref) => {
17
17
  const uid = useId();
18
18
  const { className, disabled = false, label, message, status, svgIcon, style, inputClassName, inputStyle, displayStyle = 'default', iconDisplayStyle = displayStyle === 'default' ? 'block' : 'inline', required = false, id = uid, ...rest } = props;
19
- const icon = svgIcon !== null && svgIcon !== void 0 ? svgIcon : (status && StatusIconMap[status]());
19
+ const icon = svgIcon ?? (status && StatusIconMap[status]());
20
20
  return (React.createElement(InputContainer, { label: label, disabled: disabled, required: required, status: status, message: message, icon: icon, isLabelInline: displayStyle === 'inline', isIconInline: iconDisplayStyle === 'inline', className: className, style: style, inputId: id },
21
21
  React.createElement(Input, { disabled: disabled, className: inputClassName, style: inputStyle, required: required, ref: ref, id: id, ...rest })));
22
22
  });
@@ -29,7 +29,7 @@ import { Textarea } from '../Textarea/index.js';
29
29
  export const LabeledTextarea = React.forwardRef((props, ref) => {
30
30
  const uid = useId();
31
31
  const { className, style, disabled = false, label, message, status, textareaClassName, textareaStyle, displayStyle = 'default', iconDisplayStyle = displayStyle === 'default' ? 'block' : 'inline', svgIcon, required = false, id = uid, ...textareaProps } = props;
32
- const icon = svgIcon !== null && svgIcon !== void 0 ? svgIcon : (status && StatusIconMap[status]());
32
+ const icon = svgIcon ?? (status && StatusIconMap[status]());
33
33
  return (React.createElement(InputContainer, { label: label, disabled: disabled, required: required, status: status, message: message, icon: icon, isLabelInline: displayStyle === 'inline', isIconInline: iconDisplayStyle === 'inline', className: className, style: style, inputId: id },
34
34
  React.createElement(Textarea, { disabled: disabled, className: textareaClassName, style: textareaStyle, required: required, id: id, ...textareaProps, ref: ref })));
35
35
  });
@@ -19,10 +19,9 @@ export const Menu = React.forwardRef((props, ref) => {
19
19
  return focusableItems.filter((i) => !focusableItems.some((p) => p.contains(i.parentElement)));
20
20
  }, []);
21
21
  React.useEffect(() => {
22
- var _a;
23
22
  const items = getFocusableNodes();
24
23
  if (focusedIndex != null) {
25
- (_a = items === null || items === void 0 ? void 0 : items[focusedIndex]) === null || _a === void 0 ? void 0 : _a.focus();
24
+ items?.[focusedIndex]?.focus();
26
25
  return;
27
26
  }
28
27
  const selectedIndex = items.findIndex((el) => el.getAttribute('aria-selected') === 'true');
@@ -35,10 +34,10 @@ export const Menu = React.forwardRef((props, ref) => {
35
34
  return;
36
35
  }
37
36
  const items = getFocusableNodes();
38
- if (!(items === null || items === void 0 ? void 0 : items.length)) {
37
+ if (!items?.length) {
39
38
  return;
40
39
  }
41
- const currentIndex = focusedIndex !== null && focusedIndex !== void 0 ? focusedIndex : 0;
40
+ const currentIndex = focusedIndex ?? 0;
42
41
  switch (event.key) {
43
42
  case 'ArrowDown': {
44
43
  setFocusedIndex(Math.min(currentIndex + 1, items.length - 1));
@@ -20,10 +20,9 @@ export const MenuItem = React.forwardRef((props, ref) => {
20
20
  const { ref: parentMenuItemRef } = React.useContext(MenuItemContext);
21
21
  const subMenuRef = React.useRef(null);
22
22
  const [isSubmenuVisible, setIsSubmenuVisible] = React.useState(false);
23
- const startIcon = startIconProp !== null && startIconProp !== void 0 ? startIconProp : icon;
24
- const endIcon = endIconProp !== null && endIconProp !== void 0 ? endIconProp : badge;
23
+ const startIcon = startIconProp ?? icon;
24
+ const endIcon = endIconProp ?? badge;
25
25
  const onKeyDown = (event) => {
26
- var _a;
27
26
  if (event.altKey) {
28
27
  return;
29
28
  }
@@ -31,7 +30,7 @@ export const MenuItem = React.forwardRef((props, ref) => {
31
30
  case 'Enter':
32
31
  case ' ':
33
32
  case 'Spacebar': {
34
- !disabled && (onClick === null || onClick === void 0 ? void 0 : onClick(value));
33
+ !disabled && onClick?.(value);
35
34
  event.preventDefault();
36
35
  break;
37
36
  }
@@ -44,7 +43,7 @@ export const MenuItem = React.forwardRef((props, ref) => {
44
43
  break;
45
44
  }
46
45
  case 'ArrowLeft': {
47
- (_a = parentMenuItemRef === null || parentMenuItemRef === void 0 ? void 0 : parentMenuItemRef.current) === null || _a === void 0 ? void 0 : _a.focus();
46
+ parentMenuItemRef?.current?.focus();
48
47
  event.stopPropagation();
49
48
  event.preventDefault();
50
49
  break;
@@ -53,10 +52,9 @@ export const MenuItem = React.forwardRef((props, ref) => {
53
52
  break;
54
53
  }
55
54
  };
56
- const listItem = (React.createElement(ListItem, { actionable: true, size: size, active: isSelected, disabled: disabled, onClick: () => !disabled && (onClick === null || onClick === void 0 ? void 0 : onClick(value)), ref: refs, role: role, tabIndex: disabled || role === 'presentation' ? undefined : -1, "aria-selected": isSelected, "aria-haspopup": subMenuItems.length > 0, "aria-disabled": disabled, onKeyDown: onKeyDown, onMouseEnter: () => setIsSubmenuVisible(true), onMouseLeave: (e) => {
57
- var _a;
55
+ const listItem = (React.createElement(ListItem, { actionable: true, size: size, active: isSelected, disabled: disabled, onClick: () => !disabled && onClick?.(value), ref: refs, role: role, tabIndex: disabled || role === 'presentation' ? undefined : -1, "aria-selected": isSelected, "aria-haspopup": subMenuItems.length > 0, "aria-disabled": disabled, onKeyDown: onKeyDown, onMouseEnter: () => setIsSubmenuVisible(true), onMouseLeave: (e) => {
58
56
  if (!(e.relatedTarget instanceof Node) ||
59
- !((_a = subMenuRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.relatedTarget))) {
57
+ !subMenuRef.current?.contains(e.relatedTarget)) {
60
58
  setIsSubmenuVisible(false);
61
59
  }
62
60
  }, ...rest },
@@ -69,10 +67,9 @@ export const MenuItem = React.forwardRef((props, ref) => {
69
67
  endIcon && (React.createElement(ListItem.Icon, { as: 'span', "aria-hidden": true }, endIcon))));
70
68
  return subMenuItems.length === 0 ? (listItem) : (React.createElement(MenuItemContext.Provider, { value: { ref: menuItemRef } },
71
69
  React.createElement(Popover, { placement: 'right-start', visible: isSubmenuVisible, appendTo: 'parent', content: React.createElement("div", { onMouseLeave: () => setIsSubmenuVisible(false), onBlur: (e) => {
72
- var _a, _b;
73
70
  !!(e.relatedTarget instanceof Node) &&
74
- !((_a = subMenuRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.relatedTarget)) &&
75
- !((_b = subMenuRef.current) === null || _b === void 0 ? void 0 : _b.isEqualNode(e.relatedTarget)) &&
71
+ !subMenuRef.current?.contains(e.relatedTarget) &&
72
+ !subMenuRef.current?.isEqualNode(e.relatedTarget) &&
76
73
  setIsSubmenuVisible(false);
77
74
  } },
78
75
  React.createElement(Menu, { ref: subMenuRef }, subMenuItems)) }, listItem)));
@@ -30,16 +30,15 @@ declare type ModalProps = {
30
30
  */
31
31
  onKeyDown?: React.KeyboardEventHandler;
32
32
  /**
33
- * Id of the root where the modal will be rendered in.
34
- * @default 'iui-react-portal-container'
35
- */
36
- modalRootId?: string;
37
- /**
38
- * Document where the modal will be rendered.
39
- * Can be specified to render in a different document (e.g. a popup window).
40
- * @default document
33
+ * If true, the dialog will be portaled into a <div> inside the nearest `ThemeProvider`.
34
+ *
35
+ * Can be set to an object with a `to` property to portal into a specific element.
36
+ *
37
+ * @default true
41
38
  */
42
- ownerDocument?: Document;
39
+ portal?: boolean | {
40
+ to: HTMLElement;
41
+ };
43
42
  /**
44
43
  * Content of the modal.
45
44
  */
@@ -3,8 +3,6 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import * as React from 'react';
6
- import ReactDOM from 'react-dom';
7
- import { getContainer, getDocument } from '../utils/index.js';
8
6
  import { Dialog } from '../Dialog/index.js';
9
7
  /**
10
8
  * Modal component which can wrap any content.
@@ -28,16 +26,11 @@ import { Dialog } from '../Dialog/index.js';
28
26
  * </Modal>
29
27
  */
30
28
  export const Modal = React.forwardRef((props, forwardedRef) => {
31
- const { isOpen = false, isDismissible = true, closeOnEsc = true, closeOnExternalClick = true, onClose, title, children, modalRootId = 'iui-react-portal-container', ownerDocument = getDocument(), ...rest } = props;
32
- const [container, setContainer] = React.useState();
33
- React.useEffect(() => {
34
- setContainer(getContainer(modalRootId, ownerDocument));
35
- return () => setContainer(undefined);
36
- }, [ownerDocument, modalRootId]);
37
- return !!container ? (ReactDOM.createPortal(React.createElement(Dialog, { isOpen: isOpen, closeOnEsc: closeOnEsc, closeOnExternalClick: closeOnExternalClick, isDismissible: isDismissible, onClose: onClose, preventDocumentScroll: true, trapFocus: true, setFocus: true, ref: forwardedRef },
29
+ const { isOpen = false, isDismissible = true, closeOnEsc = true, closeOnExternalClick = true, onClose, title, children, portal = true, ...rest } = props;
30
+ return (React.createElement(Dialog, { isOpen: isOpen, closeOnEsc: closeOnEsc, closeOnExternalClick: closeOnExternalClick, isDismissible: isDismissible, onClose: onClose, preventDocumentScroll: true, trapFocus: true, setFocus: true, ref: forwardedRef, portal: portal },
38
31
  React.createElement(Dialog.Backdrop, null),
39
32
  React.createElement(Dialog.Main, { "aria-modal": true, ...rest },
40
33
  React.createElement(Dialog.TitleBar, { titleText: title }),
41
- children)), container)) : (React.createElement(React.Fragment, null));
34
+ children)));
42
35
  });
43
36
  export default Modal;
@@ -14,16 +14,16 @@ const SearchBoxComponent = React.forwardRef((props, ref) => {
14
14
  const inputRef = React.useRef(null);
15
15
  const openButtonRef = React.useRef(null);
16
16
  const [localExpanded, setLocalExpanded] = React.useState(isExpandedProp);
17
- const isExpanded = isExpandedProp !== null && isExpandedProp !== void 0 ? isExpandedProp : localExpanded;
17
+ const isExpanded = isExpandedProp ?? localExpanded;
18
18
  const onCollapse = () => {
19
19
  setLocalExpanded(false);
20
- onCollapseProp === null || onCollapseProp === void 0 ? void 0 : onCollapseProp();
21
- queueMicrotask(() => { var _a; return (_a = openButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); });
20
+ onCollapseProp?.();
21
+ queueMicrotask(() => openButtonRef.current?.focus({ preventScroll: true }));
22
22
  };
23
23
  const onExpand = () => {
24
24
  setLocalExpanded(true);
25
- onExpandProp === null || onExpandProp === void 0 ? void 0 : onExpandProp();
26
- queueMicrotask(() => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); });
25
+ onExpandProp?.();
26
+ queueMicrotask(() => inputRef.current?.focus({ preventScroll: true }));
27
27
  };
28
28
  return (React.createElement(SearchBoxContext.Provider, { value: {
29
29
  size,
@@ -37,7 +37,7 @@ const SearchBoxComponent = React.forwardRef((props, ref) => {
37
37
  isExpanded,
38
38
  expandable,
39
39
  } },
40
- React.createElement(InputFlexContainer, { ref: ref, className: cx('iui-searchbox', { 'iui-expandable-searchbox': expandable }, className), "data-iui-size": size, isDisabled: isDisabled, "data-iui-expanded": isExpanded, ...rest }, children !== null && children !== void 0 ? children : (React.createElement(React.Fragment, null,
40
+ React.createElement(InputFlexContainer, { ref: ref, className: cx('iui-searchbox', { 'iui-expandable-searchbox': expandable }, className), "data-iui-size": size, isDisabled: isDisabled, "data-iui-expanded": isExpanded, ...rest }, children ?? (React.createElement(React.Fragment, null,
41
41
  React.createElement(SearchBoxCollapsedState, null,
42
42
  React.createElement(SearchBoxExpandButton, null)),
43
43
  React.createElement(SearchBoxExpandedState, null,
@@ -51,7 +51,7 @@ const SearchBoxCollapsedState = ({ children, }) => {
51
51
  if (!expandable || isExpanded) {
52
52
  return null;
53
53
  }
54
- return React.createElement(React.Fragment, null, children !== null && children !== void 0 ? children : React.createElement(SearchBoxExpandButton, null));
54
+ return React.createElement(React.Fragment, null, children ?? React.createElement(SearchBoxExpandButton, null));
55
55
  };
56
56
  SearchBoxCollapsedState.displayName = 'SearchBox.CollapsedState';
57
57
  // ----------------------------------------------------------------------------
@@ -66,7 +66,7 @@ SearchBoxExpandedState.displayName = 'SearchBox.ExpandedState';
66
66
  // ----------------------------------------------------------------------------
67
67
  const SearchBoxIcon = React.forwardRef((props, ref) => {
68
68
  const { className, children, ...rest } = props;
69
- return (React.createElement(Icon, { "aria-hidden": true, className: cx('iui-search-icon', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : React.createElement(SvgSearch, null)));
69
+ return (React.createElement(Icon, { "aria-hidden": true, className: cx('iui-search-icon', className), ref: ref, ...rest }, children ?? React.createElement(SvgSearch, null)));
70
70
  });
71
71
  SearchBoxIcon.displayName = 'SearchBox.Icon';
72
72
  // ----------------------------------------------------------------------------
@@ -78,28 +78,28 @@ const SearchBoxInput = React.forwardRef((props, ref) => {
78
78
  setInputId(idProp);
79
79
  }
80
80
  }, [idProp, inputId, setInputId]);
81
- return (React.createElement(Box, { as: 'input', id: idProp !== null && idProp !== void 0 ? idProp : inputId, ref: useMergedRefs(ref, inputRef), role: 'searchbox', type: 'text', className: cx('iui-search-input', className), disabled: isDisabled, ...rest }));
81
+ return (React.createElement(Box, { as: 'input', id: idProp ?? inputId, ref: useMergedRefs(ref, inputRef), role: 'searchbox', type: 'text', className: cx('iui-search-input', className), disabled: isDisabled, ...rest }));
82
82
  });
83
83
  SearchBoxInput.displayName = 'SearchBox.Input';
84
84
  // ----------------------------------------------------------------------------
85
85
  const SearchBoxButton = React.forwardRef((props, ref) => {
86
86
  const { children, ...rest } = props;
87
87
  const { size: sizeContext, isDisabled } = useSafeContext(SearchBoxContext);
88
- return (React.createElement(IconButton, { styleType: 'borderless', size: sizeContext, ref: ref, disabled: isDisabled, ...rest }, children !== null && children !== void 0 ? children : React.createElement(SvgSearch, null)));
88
+ return (React.createElement(IconButton, { styleType: 'borderless', size: sizeContext, ref: ref, disabled: isDisabled, ...rest }, children ?? React.createElement(SvgSearch, null)));
89
89
  });
90
90
  SearchBoxButton.displayName = 'SearchBox.Button';
91
91
  // ----------------------------------------------------------------------------
92
92
  const SearchBoxCollapseButton = React.forwardRef((props, ref) => {
93
93
  const { children, onClick: onClickProp, ...rest } = props;
94
94
  const { onCollapse, size: sizeContext, isDisabled, } = useSafeContext(SearchBoxContext);
95
- return (React.createElement(SearchBoxButton, { ref: ref, "aria-label": 'Close searchbox', size: sizeContext, disabled: isDisabled, onClick: mergeEventHandlers(onClickProp, onCollapse), ...rest }, children !== null && children !== void 0 ? children : React.createElement(SvgCloseSmall, null)));
95
+ return (React.createElement(SearchBoxButton, { ref: ref, "aria-label": 'Close searchbox', size: sizeContext, disabled: isDisabled, onClick: mergeEventHandlers(onClickProp, onCollapse), ...rest }, children ?? React.createElement(SvgCloseSmall, null)));
96
96
  });
97
97
  SearchBoxCollapseButton.displayName = 'SearchBox.CollapseButton';
98
98
  // ----------------------------------------------------------------------------
99
99
  const SearchBoxExpandButton = React.forwardRef((props, ref) => {
100
100
  const { children, className, onClick: onClickProp, ...rest } = props;
101
101
  const { onExpand, size: sizeContext, isDisabled, openButtonRef, } = useSafeContext(SearchBoxContext);
102
- return (React.createElement(SearchBoxButton, { ref: useMergedRefs(ref, openButtonRef), className: cx('iui-searchbox-open-button', className), "aria-label": 'Expand searchbox', size: sizeContext, disabled: isDisabled, onClick: mergeEventHandlers(onClickProp, onExpand), ...rest }, children !== null && children !== void 0 ? children : React.createElement(SvgSearch, null)));
102
+ return (React.createElement(SearchBoxButton, { ref: useMergedRefs(ref, openButtonRef), className: cx('iui-searchbox-open-button', className), "aria-label": 'Expand searchbox', size: sizeContext, disabled: isDisabled, onClick: mergeEventHandlers(onClickProp, onExpand), ...rest }, children ?? React.createElement(SvgSearch, null)));
103
103
  });
104
104
  SearchBoxExpandButton.displayName = 'SearchBox.ExpandButton';
105
105
  // ----------------------------------------------------------------------------