@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
@@ -47,7 +47,6 @@ const ColorPickerContext_js_1 = require("./ColorPickerContext.js");
47
47
  * </ColorPicker>
48
48
  */
49
49
  exports.ColorInputPanel = React.forwardRef((props, ref) => {
50
- var _a, _b, _c, _d, _f, _g, _h, _j;
51
50
  const { defaultColorFormat, allowedColorFormats = ['hsl', 'rgb', 'hex'], className, ...rest } = props;
52
51
  const inputsContainerRef = React.useRef(null);
53
52
  const { activeColor, applyHsvColorChange, hsvColor, showAlpha } = (0, ColorPickerContext_js_1.useColorPickerContext)();
@@ -58,14 +57,13 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
58
57
  // need to use state since input may have parsing error
59
58
  const [input, setInput] = React.useState(['', '', '', '']);
60
59
  React.useEffect(() => {
61
- var _a, _b;
62
60
  if (currentFormat === 'hsl') {
63
61
  const hsl = activeColor.toHslColor();
64
62
  setInput([
65
63
  index_js_3.ColorValue.getFormattedColorNumber(hsvColor.h),
66
64
  index_js_3.ColorValue.getFormattedColorNumber(hsl.s),
67
65
  index_js_3.ColorValue.getFormattedColorNumber(hsl.l),
68
- index_js_3.ColorValue.getFormattedColorNumber((_a = hsl.a) !== null && _a !== void 0 ? _a : activeColor.getAlpha() / 255, 2),
66
+ index_js_3.ColorValue.getFormattedColorNumber(hsl.a ?? activeColor.getAlpha() / 255, 2),
69
67
  ]);
70
68
  }
71
69
  else if (currentFormat === 'rgb') {
@@ -74,7 +72,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
74
72
  rgb.r.toString(),
75
73
  rgb.g.toString(),
76
74
  rgb.b.toString(),
77
- index_js_3.ColorValue.getFormattedColorNumber((_b = rgb.a) !== null && _b !== void 0 ? _b : activeColor.getAlpha() / 255, 2),
75
+ index_js_3.ColorValue.getFormattedColorNumber(rgb.a ?? activeColor.getAlpha() / 255, 2),
78
76
  ]);
79
77
  }
80
78
  else {
@@ -84,9 +82,8 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
84
82
  }, [activeColor, hsvColor.h, currentFormat, showAlpha]);
85
83
  const [validHexInput, setValidHexInput] = React.useState(true);
86
84
  const swapColorFormat = React.useCallback(() => {
87
- var _a;
88
- const newFormat = (_a = allowedColorFormats[(allowedColorFormats.indexOf(currentFormat) + 1) %
89
- allowedColorFormats.length]) !== null && _a !== void 0 ? _a : allowedColorFormats[0];
85
+ const newFormat = allowedColorFormats[(allowedColorFormats.indexOf(currentFormat) + 1) %
86
+ allowedColorFormats.length] ?? allowedColorFormats[0];
90
87
  setCurrentFormat(newFormat);
91
88
  }, [currentFormat, allowedColorFormats]);
92
89
  const isFocusInside = (focused) => !!(focused &&
@@ -167,7 +164,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
167
164
  React.createElement(index_js_3.InputContainer, { status: Number(input[0]) < 0 || Number(input[0]) > 360
168
165
  ? 'negative'
169
166
  : undefined },
170
- React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '359', step: '.1', placeholder: 'H', value: (_a = input[0]) !== null && _a !== void 0 ? _a : '', onChange: (event) => {
167
+ React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '359', step: '.1', placeholder: 'H', value: input[0] ?? '', onChange: (event) => {
171
168
  setInput([event.target.value, input[1], input[2], input[3]]);
172
169
  }, onKeyDown: (event) => {
173
170
  if (event.key === 'Enter') {
@@ -183,7 +180,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
183
180
  React.createElement(index_js_3.InputContainer, { status: Number(input[1]) < 0 || Number(input[1]) > 100
184
181
  ? 'negative'
185
182
  : undefined },
186
- React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'S', value: (_b = input[1]) !== null && _b !== void 0 ? _b : '', onChange: (event) => {
183
+ React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'S', value: input[1] ?? '', onChange: (event) => {
187
184
  setInput([input[0], event.target.value, input[2], input[3]]);
188
185
  }, onKeyDown: (event) => {
189
186
  if (event.key === 'Enter') {
@@ -199,7 +196,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
199
196
  React.createElement(index_js_3.InputContainer, { status: Number(input[2]) < 0 || Number(input[2]) > 100
200
197
  ? 'negative'
201
198
  : undefined },
202
- React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'L', value: (_c = input[2]) !== null && _c !== void 0 ? _c : '', onChange: (event) => {
199
+ React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'L', value: input[2] ?? '', onChange: (event) => {
203
200
  setInput([input[0], input[1], event.target.value, input[3]]);
204
201
  }, onKeyDown: (event) => {
205
202
  if (event.key === 'Enter') {
@@ -215,7 +212,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
215
212
  showAlpha && (React.createElement(index_js_3.InputContainer, { status: Number(input[3]) < 0 || Number(input[3]) > 1
216
213
  ? 'negative'
217
214
  : undefined },
218
- React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value: (_d = input[3]) !== null && _d !== void 0 ? _d : '', onChange: (event) => {
215
+ React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value: input[3] ?? '', onChange: (event) => {
219
216
  setInput([input[0], input[1], input[2], event.target.value]);
220
217
  }, onKeyDown: (event) => {
221
218
  if (event.key === 'Enter') {
@@ -232,7 +229,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
232
229
  React.createElement(index_js_3.InputContainer, { status: Number(input[0]) < 0 || Number(input[0]) > 255
233
230
  ? 'negative'
234
231
  : undefined },
235
- React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'R', value: (_f = input[0]) !== null && _f !== void 0 ? _f : '', onChange: (event) => {
232
+ React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'R', value: input[0] ?? '', onChange: (event) => {
236
233
  setInput([event.target.value, input[1], input[2], input[3]]);
237
234
  }, onKeyDown: (event) => {
238
235
  if (event.key === 'Enter') {
@@ -248,7 +245,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
248
245
  React.createElement(index_js_3.InputContainer, { status: Number(input[1]) < 0 || Number(input[1]) > 255
249
246
  ? 'negative'
250
247
  : undefined },
251
- React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'G', value: (_g = input[1]) !== null && _g !== void 0 ? _g : '', onChange: (event) => {
248
+ React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'G', value: input[1] ?? '', onChange: (event) => {
252
249
  setInput([input[0], event.target.value, input[2], input[3]]);
253
250
  }, onKeyDown: (event) => {
254
251
  if (event.key === 'Enter') {
@@ -264,7 +261,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
264
261
  React.createElement(index_js_3.InputContainer, { status: Number(input[2]) < 0 || Number(input[2]) > 255
265
262
  ? 'negative'
266
263
  : undefined },
267
- React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'B', value: (_h = input[2]) !== null && _h !== void 0 ? _h : '', onChange: (event) => {
264
+ React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'B', value: input[2] ?? '', onChange: (event) => {
268
265
  setInput([input[0], input[1], event.target.value, input[3]]);
269
266
  }, onKeyDown: (event) => {
270
267
  if (event.key === 'Enter') {
@@ -280,7 +277,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
280
277
  showAlpha && (React.createElement(index_js_3.InputContainer, { status: Number(input[3]) < 0 || Number(input[3]) > 1
281
278
  ? 'negative'
282
279
  : undefined },
283
- React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value: (_j = input[3]) !== null && _j !== void 0 ? _j : '', onChange: (event) => {
280
+ React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value: input[3] ?? '', onChange: (event) => {
284
281
  setInput([input[0], input[1], input[2], event.target.value]);
285
282
  }, onKeyDown: (event) => {
286
283
  if (event.key === 'Enter') {
@@ -54,9 +54,8 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
54
54
  const [focusedIndex, setFocusedIndex] = React.useState();
55
55
  // callback ref to set tabindex=0 on first child if none of the swatches are tabbable
56
56
  const setDefaultTabIndex = (el) => {
57
- var _a;
58
57
  if (el && !el.querySelector('[tabindex="0"]')) {
59
- (_a = el.firstElementChild) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
58
+ el.firstElementChild?.setAttribute('tabindex', '0');
60
59
  }
61
60
  };
62
61
  const paletteRef = React.useRef(null);
@@ -70,7 +69,7 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
70
69
  if (!swatches.length) {
71
70
  return;
72
71
  }
73
- const currentIndex = swatches.findIndex((swatch) => { var _a; return swatch === ((_a = paletteRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.activeElement); });
72
+ const currentIndex = swatches.findIndex((swatch) => swatch === paletteRef.current?.ownerDocument.activeElement);
74
73
  if (currentIndex < 0) {
75
74
  return;
76
75
  }
@@ -112,10 +111,9 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
112
111
  };
113
112
  // call focus() when focusedIndex changes
114
113
  React.useEffect(() => {
115
- var _a;
116
114
  if (focusedIndex != null) {
117
115
  const swatches = (0, index_js_1.getFocusableElements)(paletteRef.current);
118
- (_a = swatches[focusedIndex]) === null || _a === void 0 ? void 0 : _a.focus();
116
+ swatches[focusedIndex]?.focus();
119
117
  }
120
118
  }, [focusedIndex]);
121
119
  return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-color-palette-wrapper', className), ref: ref, ...rest },
@@ -127,7 +125,7 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
127
125
  const color = (0, ColorPicker_js_1.getColorValue)(_color);
128
126
  return (React.createElement(ColorSwatch_js_1.ColorSwatch, { key: index, color: color, onClick: (event) => {
129
127
  event.preventDefault();
130
- onChangeComplete === null || onChangeComplete === void 0 ? void 0 : onChangeComplete(color);
128
+ onChangeComplete?.(color);
131
129
  setActiveColor(color);
132
130
  }, isActive: color.equals(activeColor) }));
133
131
  }))));
@@ -84,13 +84,13 @@ exports.ColorPicker = React.forwardRef((props, forwardedRef) => {
84
84
  const applyHsvColorChange = React.useCallback((newColor, selectionChanged, newColorValue) => {
85
85
  // save the HSV values
86
86
  setHsvColor(newColor);
87
- const newActiveColor = newColorValue !== null && newColorValue !== void 0 ? newColorValue : index_js_1.ColorValue.create(newColor);
87
+ const newActiveColor = newColorValue ?? index_js_1.ColorValue.create(newColor);
88
88
  // Only update selected color when dragging is done
89
89
  if (selectionChanged) {
90
- onChangeComplete === null || onChangeComplete === void 0 ? void 0 : onChangeComplete(newActiveColor);
90
+ onChangeComplete?.(newActiveColor);
91
91
  }
92
92
  else {
93
- onChange === null || onChange === void 0 ? void 0 : onChange(newActiveColor);
93
+ onChange?.(newActiveColor);
94
94
  }
95
95
  activeColorTbgr.current = newActiveColor.toTbgr();
96
96
  // this converts it to store in tbgr
@@ -53,8 +53,7 @@ const isSingleOnChange = (onChange, multiple) => {
53
53
  };
54
54
  /** Returns either `option.id` or derives a stable id using `idPrefix` and `option.label` (without whitespace) */
55
55
  const getOptionId = (option, idPrefix) => {
56
- var _a;
57
- return (_a = option.id) !== null && _a !== void 0 ? _a : `${idPrefix}-option-${option.label.replace(/\s/g, '-')}`;
56
+ return option.id ?? `${idPrefix}-option-${option.label.replace(/\s/g, '-')}`;
58
57
  };
59
58
  /**
60
59
  * ComboBox component that allows typing a value to filter the options in dropdown list.
@@ -70,13 +69,11 @@ const getOptionId = (option, idPrefix) => {
70
69
  * />
71
70
  */
72
71
  const ComboBox = (props) => {
73
- var _a, _b;
74
72
  const { options, value: valueProp, onChange, filterFunction, inputProps, dropdownMenuProps, emptyStateMessage = 'No options found', itemRenderer, enableVirtualization = false, multiple = false, onShow, onHide, ...rest } = props;
75
73
  // Generate a stateful random id if not specified
76
- const [id] = React.useState(() => {
77
- var _a, _b;
78
- return (_b = (_a = props.id) !== null && _a !== void 0 ? _a : ((inputProps === null || inputProps === void 0 ? void 0 : inputProps.id) && `${inputProps.id}-cb`)) !== null && _b !== void 0 ? _b : `iui-cb-${(0, index_js_3.getRandomValue)(10)}`;
79
- });
74
+ const [id] = React.useState(() => props.id ??
75
+ (inputProps?.id && `${inputProps.id}-cb`) ??
76
+ `iui-cb-${(0, index_js_3.getRandomValue)(10)}`);
80
77
  // Refs get set in subcomponents
81
78
  const inputRef = React.useRef(null);
82
79
  const menuRef = React.useRef(null);
@@ -102,7 +99,7 @@ const ComboBox = (props) => {
102
99
  const getSelectedIndexes = React.useCallback(() => {
103
100
  if (isMultipleEnabled(valueProp, multiple)) {
104
101
  const indexArray = [];
105
- valueProp === null || valueProp === void 0 ? void 0 : valueProp.forEach((value) => {
102
+ valueProp?.forEach((value) => {
106
103
  const indexToAdd = options.findIndex((option) => option.value === value);
107
104
  if (indexToAdd > -1) {
108
105
  indexArray.push(indexToAdd);
@@ -121,10 +118,9 @@ const ComboBox = (props) => {
121
118
  focusedIndex: -1,
122
119
  });
123
120
  (0, index_js_3.useIsomorphicLayoutEffect)(() => {
124
- var _a, _b;
125
121
  // When the dropdown opens
126
122
  if (isOpen) {
127
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); // Focus the input
123
+ inputRef.current?.focus(); // Focus the input
128
124
  // Reset the filtered list (does not reset when multiple enabled)
129
125
  if (!multiple) {
130
126
  setFilteredOptions(optionsRef.current);
@@ -138,7 +134,7 @@ const ComboBox = (props) => {
138
134
  // Reset the input value if not multiple
139
135
  if (!isMultipleEnabled(selected, multiple)) {
140
136
  setInputValue(selected != undefined && selected >= 0
141
- ? (_b = optionsRef.current[selected]) === null || _b === void 0 ? void 0 : _b.label
137
+ ? optionsRef.current[selected]?.label
142
138
  : '');
143
139
  }
144
140
  }
@@ -153,9 +149,9 @@ const ComboBox = (props) => {
153
149
  // Update filtered options to the latest value options according to input value
154
150
  const [filteredOptions, setFilteredOptions] = React.useState(options);
155
151
  React.useEffect(() => {
156
- var _a;
157
152
  if (inputValue) {
158
- setFilteredOptions((_a = filterFunction === null || filterFunction === void 0 ? void 0 : filterFunction(options, inputValue)) !== null && _a !== void 0 ? _a : options.filter((option) => option.label.toLowerCase().includes(inputValue.toLowerCase())));
153
+ setFilteredOptions(filterFunction?.(options, inputValue) ??
154
+ options.filter((option) => option.label.toLowerCase().includes(inputValue.toLowerCase())));
159
155
  }
160
156
  else {
161
157
  setFilteredOptions(options);
@@ -165,18 +161,18 @@ const ComboBox = (props) => {
165
161
  // eslint-disable-next-line react-hooks/exhaustive-deps
166
162
  }, [options]);
167
163
  // Filter options based on input value
168
- const [inputValue, setInputValue] = React.useState((_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.value) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '');
164
+ const [inputValue, setInputValue] = React.useState(inputProps?.value?.toString() ?? '');
169
165
  const [liveRegionSelection, setLiveRegionSelection] = React.useState('');
170
166
  const handleOnInput = React.useCallback((event) => {
171
- var _a, _b;
172
167
  const { value } = event.currentTarget;
173
168
  setInputValue(value);
174
169
  dispatch({ type: 'open' }); // reopen when typing
175
- setFilteredOptions((_a = filterFunction === null || filterFunction === void 0 ? void 0 : filterFunction(optionsRef.current, value)) !== null && _a !== void 0 ? _a : optionsRef.current.filter((option) => option.label.toLowerCase().includes(value.toLowerCase())));
170
+ setFilteredOptions(filterFunction?.(optionsRef.current, value) ??
171
+ optionsRef.current.filter((option) => option.label.toLowerCase().includes(value.toLowerCase())));
176
172
  if (focusedIndex != -1) {
177
173
  dispatch({ type: 'focus', value: -1 });
178
174
  }
179
- (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onChange) === null || _b === void 0 ? void 0 : _b.call(inputProps, event);
175
+ inputProps?.onChange?.(event);
180
176
  }, [filterFunction, focusedIndex, inputProps, optionsRef]);
181
177
  // When the value prop changes, update the selected index/indices
182
178
  React.useEffect(() => {
@@ -225,23 +221,21 @@ const ComboBox = (props) => {
225
221
  }, [selected]);
226
222
  // Calls user defined onChange
227
223
  const onChangeHandler = React.useCallback((__originalIndex, actionType, newArray) => {
228
- var _a, _b, _c, _d;
229
224
  if (isSingleOnChange(onChangeProp.current, multiple)) {
230
- (_a = onChangeProp.current) === null || _a === void 0 ? void 0 : _a.call(onChangeProp, (_b = optionsRef.current[__originalIndex]) === null || _b === void 0 ? void 0 : _b.value);
225
+ onChangeProp.current?.(optionsRef.current[__originalIndex]?.value);
231
226
  }
232
227
  else {
233
228
  actionType &&
234
229
  newArray &&
235
- ((_c = onChangeProp.current) === null || _c === void 0 ? void 0 : _c.call(onChangeProp, newArray === null || newArray === void 0 ? void 0 : newArray.map((item) => { var _a; return (_a = optionsRef.current[item]) === null || _a === void 0 ? void 0 : _a.value; }), {
236
- value: (_d = optionsRef.current[__originalIndex]) === null || _d === void 0 ? void 0 : _d.value,
230
+ onChangeProp.current?.(newArray?.map((item) => optionsRef.current[item]?.value), {
231
+ value: optionsRef.current[__originalIndex]?.value,
237
232
  type: actionType,
238
- }));
233
+ });
239
234
  }
240
235
  }, [multiple, onChangeProp, optionsRef]);
241
236
  const onClickHandler = React.useCallback((__originalIndex) => {
242
- var _a, _b;
243
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); // return focus to input
244
- if ((_b = optionsRef.current[__originalIndex]) === null || _b === void 0 ? void 0 : _b.disabled) {
237
+ inputRef.current?.focus({ preventScroll: true }); // return focus to input
238
+ if (optionsRef.current[__originalIndex]?.disabled) {
245
239
  return;
246
240
  }
247
241
  if (isMultipleEnabled(selected, multiple)) {
@@ -253,7 +247,7 @@ const ComboBox = (props) => {
253
247
  onChangeHandler(__originalIndex, actionType, newArray);
254
248
  // update live region
255
249
  setLiveRegionSelection(newArray
256
- .map((item) => { var _a; return (_a = optionsRef.current[item]) === null || _a === void 0 ? void 0 : _a.label; })
250
+ .map((item) => optionsRef.current[item]?.label)
257
251
  .filter(Boolean)
258
252
  .join(', '));
259
253
  }
@@ -274,7 +268,7 @@ const ComboBox = (props) => {
274
268
  const optionId = getOptionId(option, id);
275
269
  const { __originalIndex } = optionsExtraInfoRef.current[optionId];
276
270
  const { icon, startIcon: startIconProp, ...restOptions } = option;
277
- const startIcon = startIconProp !== null && startIconProp !== void 0 ? startIconProp : icon;
271
+ const startIcon = startIconProp ?? icon;
278
272
  const customItem = itemRenderer
279
273
  ? itemRenderer(option, {
280
274
  isFocused: focusedIndex === __originalIndex,
@@ -285,9 +279,8 @@ const ComboBox = (props) => {
285
279
  : null;
286
280
  return customItem ? (React.cloneElement(customItem, {
287
281
  onClick: (e) => {
288
- var _a, _b;
289
282
  onClickHandler(__originalIndex);
290
- (_b = (_a = customItem.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
283
+ customItem.props.onClick?.(e);
291
284
  },
292
285
  // ComboBox.MenuItem handles scrollIntoView, data-iui-index and focused through context
293
286
  // but we still need to pass them here for backwards compatibility with MenuItem
@@ -296,7 +289,7 @@ const ComboBox = (props) => {
296
289
  'data-iui-filtered-index': filteredIndex,
297
290
  ref: (0, index_js_3.mergeRefs)(customItem.props.ref, (el) => {
298
291
  if (!enableVirtualization && focusedIndex === __originalIndex) {
299
- el === null || el === void 0 ? void 0 : el.scrollIntoView({ block: 'nearest' });
292
+ el?.scrollIntoView({ block: 'nearest' });
300
293
  }
301
294
  }),
302
295
  })) : (React.createElement(ComboBoxMenuItem_js_1.ComboBoxMenuItem, { key: optionId, id: optionId, startIcon: startIcon, ...restOptions, isSelected: isMenuItemSelected(__originalIndex), onClick: () => {
@@ -326,7 +319,7 @@ const ComboBox = (props) => {
326
319
  getMenuItem,
327
320
  multiple,
328
321
  } },
329
- React.createElement(ComboBoxInputContainer_js_1.ComboBoxInputContainer, { disabled: inputProps === null || inputProps === void 0 ? void 0 : inputProps.disabled, ...rest },
322
+ React.createElement(ComboBoxInputContainer_js_1.ComboBoxInputContainer, { disabled: inputProps?.disabled, ...rest },
330
323
  React.createElement(React.Fragment, null,
331
324
  React.createElement(ComboBoxInput_js_1.ComboBoxInput, { value: inputValue, ...inputProps, onChange: handleOnInput, selectTags: isMultipleEnabled(selected, multiple)
332
325
  ? selected.map((index) => {
@@ -334,7 +327,7 @@ const ComboBox = (props) => {
334
327
  return (React.createElement(SelectTag_js_1.default, { key: item.label, label: item.label }));
335
328
  })
336
329
  : undefined })),
337
- React.createElement(ComboBoxEndIcon_js_1.ComboBoxEndIcon, { disabled: inputProps === null || inputProps === void 0 ? void 0 : inputProps.disabled, isOpen: isOpen }),
330
+ React.createElement(ComboBoxEndIcon_js_1.ComboBoxEndIcon, { disabled: inputProps?.disabled, isOpen: isOpen }),
338
331
  multiple ? (React.createElement(index_js_3.AutoclearingHiddenLiveRegion, { text: liveRegionSelection })) : null),
339
332
  React.createElement(ComboBoxDropdown_js_1.ComboBoxDropdown, { ...dropdownMenuProps, onShow: onShow, onHide: onHide },
340
333
  React.createElement(ComboBoxMenu_js_1.ComboBoxMenu, null, filteredOptions.length > 0 && !enableVirtualization
@@ -43,8 +43,7 @@ exports.ComboBoxDropdown = React.forwardRef((props, forwardedRef) => {
43
43
  }
44
44
  }, [dispatch, props.visible]);
45
45
  return (React.createElement(index_js_1.Popover, { placement: 'bottom-start', visible: isOpen, onClickOutside: React.useCallback((_, { target }) => {
46
- var _a;
47
- if (!((_a = toggleButtonRef.current) === null || _a === void 0 ? void 0 : _a.contains(target))) {
46
+ if (!toggleButtonRef.current?.contains(target)) {
48
47
  dispatch({ type: 'close' });
49
48
  }
50
49
  }, [dispatch, toggleButtonRef]), animation: 'shift-away', duration: 200, reference: inputRef, ref: forwardedRef, content: children, ...rest }));
@@ -46,6 +46,6 @@ exports.ComboBoxEndIcon = React.forwardRef((props, forwardedRef) => {
46
46
  'iui-open': isOpen,
47
47
  }, className), onClick: (0, index_js_1.mergeEventHandlers)(onClickProp, () => {
48
48
  dispatch({ type: isOpen ? 'close' : 'open' });
49
- }), ...rest }, children !== null && children !== void 0 ? children : React.createElement(index_js_1.SvgCaretDownSmall, { "aria-hidden": true })));
49
+ }), ...rest }, children ?? React.createElement(index_js_1.SvgCaretDownSmall, { "aria-hidden": true })));
50
50
  });
51
51
  exports.ComboBoxEndIcon.displayName = 'ComboBoxEndIcon';
@@ -39,18 +39,16 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
39
39
  const dispatch = (0, index_js_2.useSafeContext)(helpers_js_1.ComboBoxActionContext);
40
40
  const { inputRef, menuRef, optionsExtraInfoRef } = (0, index_js_2.useSafeContext)(helpers_js_1.ComboBoxRefsContext);
41
41
  const refs = (0, index_js_2.useMergedRefs)(inputRef, forwardedRef);
42
- const focusedIndexRef = React.useRef(focusedIndex !== null && focusedIndex !== void 0 ? focusedIndex : -1);
42
+ const focusedIndexRef = React.useRef(focusedIndex ?? -1);
43
43
  React.useEffect(() => {
44
- focusedIndexRef.current = focusedIndex !== null && focusedIndex !== void 0 ? focusedIndex : -1;
44
+ focusedIndexRef.current = focusedIndex ?? -1;
45
45
  }, [focusedIndex]);
46
46
  const getIdFromIndex = (index) => {
47
- var _a, _b, _c;
48
- return ((_c = (_b = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-iui-index="${index}"]`)) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '');
47
+ return (menuRef.current?.querySelector(`[data-iui-index="${index}"]`)?.id ?? '');
49
48
  };
50
49
  const handleKeyDown = React.useCallback((event) => {
51
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
52
- onKeyDownProp === null || onKeyDownProp === void 0 ? void 0 : onKeyDownProp(event);
53
- const length = (_a = Object.keys(optionsExtraInfoRef.current).length) !== null && _a !== void 0 ? _a : 0;
50
+ onKeyDownProp?.(event);
51
+ const length = Object.keys(optionsExtraInfoRef.current).length ?? 0;
54
52
  if (event.altKey) {
55
53
  return;
56
54
  }
@@ -64,22 +62,23 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
64
62
  return;
65
63
  }
66
64
  if (focusedIndexRef.current === -1) {
67
- const currentElement = (_b = menuRef.current) === null || _b === void 0 ? void 0 : _b.querySelector('[data-iui-index]');
65
+ const currentElement = menuRef.current?.querySelector('[data-iui-index]');
68
66
  return dispatch({
69
67
  type: 'focus',
70
- value: Number((_c = currentElement === null || currentElement === void 0 ? void 0 : currentElement.getAttribute('data-iui-index')) !== null && _c !== void 0 ? _c : 0),
68
+ value: Number(currentElement?.getAttribute('data-iui-index') ?? 0),
71
69
  });
72
70
  }
73
71
  // If virtualization is enabled, dont let round scrolling
74
72
  if (enableVirtualization &&
75
- !((_e = (_d = menuRef.current) === null || _d === void 0 ? void 0 : _d.querySelector(`[data-iui-index="${focusedIndexRef.current}"]`)) === null || _e === void 0 ? void 0 : _e.nextElementSibling)) {
73
+ !menuRef.current?.querySelector(`[data-iui-index="${focusedIndexRef.current}"]`)?.nextElementSibling) {
76
74
  return;
77
75
  }
78
76
  let nextIndex = focusedIndexRef.current;
79
77
  do {
80
- const currentElement = (_f = menuRef.current) === null || _f === void 0 ? void 0 : _f.querySelector(`[data-iui-index="${nextIndex}"]`);
81
- const nextElement = (_g = currentElement === null || currentElement === void 0 ? void 0 : currentElement.nextElementSibling) !== null && _g !== void 0 ? _g : (_h = menuRef.current) === null || _h === void 0 ? void 0 : _h.querySelector('[data-iui-index]');
82
- nextIndex = Number(nextElement === null || nextElement === void 0 ? void 0 : nextElement.getAttribute('data-iui-index'));
78
+ const currentElement = menuRef.current?.querySelector(`[data-iui-index="${nextIndex}"]`);
79
+ const nextElement = currentElement?.nextElementSibling ??
80
+ menuRef.current?.querySelector('[data-iui-index]');
81
+ nextIndex = Number(nextElement?.getAttribute('data-iui-index'));
83
82
  if (nextElement) {
84
83
  return dispatch({ type: 'focus', value: nextIndex });
85
84
  }
@@ -96,20 +95,22 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
96
95
  }
97
96
  // If virtualization is enabled, dont let round scrolling
98
97
  if (enableVirtualization &&
99
- !((_k = (_j = menuRef.current) === null || _j === void 0 ? void 0 : _j.querySelector(`[data-iui-index="${focusedIndexRef.current}"]`)) === null || _k === void 0 ? void 0 : _k.previousElementSibling)) {
98
+ !menuRef.current?.querySelector(`[data-iui-index="${focusedIndexRef.current}"]`)?.previousElementSibling) {
100
99
  return;
101
100
  }
102
101
  if (focusedIndexRef.current === -1) {
103
102
  return dispatch({
104
103
  type: 'focus',
105
- value: (_m = (_l = Object.values(optionsExtraInfoRef.current)) === null || _l === void 0 ? void 0 : _l[length - 1].__originalIndex) !== null && _m !== void 0 ? _m : -1,
104
+ value: Object.values(optionsExtraInfoRef.current)?.[length - 1]
105
+ .__originalIndex ?? -1,
106
106
  });
107
107
  }
108
108
  let prevIndex = focusedIndexRef.current;
109
109
  do {
110
- const currentElement = (_o = menuRef.current) === null || _o === void 0 ? void 0 : _o.querySelector(`[data-iui-index="${prevIndex}"]`);
111
- const prevElement = (_p = currentElement === null || currentElement === void 0 ? void 0 : currentElement.previousElementSibling) !== null && _p !== void 0 ? _p : (_q = menuRef.current) === null || _q === void 0 ? void 0 : _q.querySelector('[data-iui-index]:last-of-type');
112
- prevIndex = Number(prevElement === null || prevElement === void 0 ? void 0 : prevElement.getAttribute('data-iui-index'));
110
+ const currentElement = menuRef.current?.querySelector(`[data-iui-index="${prevIndex}"]`);
111
+ const prevElement = currentElement?.previousElementSibling ??
112
+ menuRef.current?.querySelector('[data-iui-index]:last-of-type');
113
+ prevIndex = Number(prevElement?.getAttribute('data-iui-index'));
113
114
  if (prevElement) {
114
115
  return dispatch({ type: 'focus', value: prevIndex });
115
116
  }
@@ -120,7 +121,7 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
120
121
  event.preventDefault();
121
122
  if (isOpen) {
122
123
  if (focusedIndexRef.current > -1) {
123
- onClickHandler === null || onClickHandler === void 0 ? void 0 : onClickHandler(focusedIndexRef.current);
124
+ onClickHandler?.(focusedIndexRef.current);
124
125
  }
125
126
  }
126
127
  else {
@@ -148,7 +149,7 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
148
149
  ]);
149
150
  const handleFocus = React.useCallback((event) => {
150
151
  dispatch({ type: 'open' });
151
- onFocusProp === null || onFocusProp === void 0 ? void 0 : onFocusProp(event);
152
+ onFocusProp?.(event);
152
153
  }, [dispatch, onFocusProp]);
153
154
  const handleClick = React.useCallback(() => {
154
155
  if (!isOpen) {
@@ -37,7 +37,7 @@ const index_js_1 = require("../Menu/index.js");
37
37
  const index_js_2 = require("../Surface/index.js");
38
38
  const index_js_3 = require("../utils/index.js");
39
39
  const helpers_js_1 = require("./helpers.js");
40
- const isOverflowOverlaySupported = () => { var _a, _b, _c; return (_c = (_b = (_a = (0, index_js_3.getWindow)()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, 'overflow: overlay'); };
40
+ const isOverflowOverlaySupported = () => (0, index_js_3.getWindow)()?.CSS?.supports?.('overflow: overlay');
41
41
  const VirtualizedComboBoxMenu = React.forwardRef(({ children, className, style, ...rest }, forwardedRef) => {
42
42
  const { minWidth, id, filteredOptions, getMenuItem, focusedIndex } = (0, index_js_3.useSafeContext)(helpers_js_1.ComboBoxStateContext);
43
43
  const { menuRef } = (0, index_js_3.useSafeContext)(helpers_js_1.ComboBoxRefsContext);
@@ -46,12 +46,11 @@ const VirtualizedComboBoxMenu = React.forwardRef(({ children, className, style,
46
46
  : children, // Here is expected empty state content
47
47
  [filteredOptions, getMenuItem, children]);
48
48
  const focusedVisibleIndex = React.useMemo(() => {
49
- var _a, _b;
50
- const currentElement = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-iui-index="${focusedIndex}"]`);
49
+ const currentElement = menuRef.current?.querySelector(`[data-iui-index="${focusedIndex}"]`);
51
50
  if (!currentElement) {
52
51
  return focusedIndex;
53
52
  }
54
- return Number((_b = currentElement.getAttribute('data-iui-filtered-index')) !== null && _b !== void 0 ? _b : focusedIndex);
53
+ return Number(currentElement.getAttribute('data-iui-filtered-index') ?? focusedIndex);
55
54
  }, [focusedIndex, menuRef]);
56
55
  const { outerProps, innerProps, visibleChildren } = (0, index_js_3.useVirtualization)({
57
56
  // 'Fool' VirtualScroll by passing length 1
@@ -37,11 +37,11 @@ exports.ComboBoxMenuItem = React.memo(React.forwardRef((props, forwardedRef) =>
37
37
  const { focusedIndex, enableVirtualization } = (0, index_js_1.useSafeContext)(helpers_js_1.ComboBoxStateContext);
38
38
  const focusRef = (el) => {
39
39
  if (!enableVirtualization && focusedIndex === index) {
40
- el === null || el === void 0 ? void 0 : el.scrollIntoView({ block: 'nearest' });
40
+ el?.scrollIntoView({ block: 'nearest' });
41
41
  }
42
42
  };
43
43
  const refs = (0, index_js_1.useMergedRefs)(forwardedRef, focusRef);
44
- return (React.createElement(ListItem_js_1.ListItem, { actionable: true, size: size, active: isSelected, disabled: disabled, focused: focusedIndex === index, ref: refs, onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(value), role: role, tabIndex: role === 'presentation' ? undefined : -1, "aria-selected": isSelected, "aria-disabled": disabled, "data-iui-index": index, ...rest },
44
+ return (React.createElement(ListItem_js_1.ListItem, { actionable: true, size: size, active: isSelected, disabled: disabled, focused: focusedIndex === index, ref: refs, onClick: () => onClick?.(value), role: role, tabIndex: role === 'presentation' ? undefined : -1, "aria-selected": isSelected, "aria-disabled": disabled, "data-iui-index": index, ...rest },
45
45
  startIcon && (React.createElement(ListItem_js_1.ListItem.Icon, { as: 'span', "aria-hidden": true }, startIcon)),
46
46
  React.createElement(ListItem_js_1.ListItem.Content, null,
47
47
  children,
@@ -30,7 +30,6 @@ exports.ComboBoxActionContext = exports.ComboBoxStateContext = exports.ComboBoxR
30
30
  *--------------------------------------------------------------------------------------------*/
31
31
  const React = __importStar(require("react"));
32
32
  const comboBoxReducer = (state, action) => {
33
- var _a, _b, _c, _d, _e;
34
33
  switch (action.type) {
35
34
  case 'open': {
36
35
  return { ...state, isOpen: true };
@@ -44,8 +43,8 @@ const comboBoxReducer = (state, action) => {
44
43
  }
45
44
  return {
46
45
  ...state,
47
- selected: (_a = action.value) !== null && _a !== void 0 ? _a : state.selected,
48
- focusedIndex: (_b = action.value) !== null && _b !== void 0 ? _b : state.focusedIndex,
46
+ selected: action.value ?? state.selected,
47
+ focusedIndex: action.value ?? state.focusedIndex,
49
48
  };
50
49
  }
51
50
  case 'multiselect': {
@@ -58,12 +57,12 @@ const comboBoxReducer = (state, action) => {
58
57
  if (Array.isArray(state.selected)) {
59
58
  return {
60
59
  ...state,
61
- focusedIndex: (_c = action.value) !== null && _c !== void 0 ? _c : -1,
60
+ focusedIndex: action.value ?? -1,
62
61
  };
63
62
  }
64
63
  return {
65
64
  ...state,
66
- focusedIndex: (_e = (_d = action.value) !== null && _d !== void 0 ? _d : state.selected) !== null && _e !== void 0 ? _e : -1,
65
+ focusedIndex: action.value ?? state.selected ?? -1,
67
66
  };
68
67
  }
69
68
  default: {