@itwin/itwinui-react 3.0.0-dev.6 → 3.0.0-dev.8

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 (283) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/cjs/core/Alert/Alert.d.ts +20 -9
  3. package/cjs/core/Alert/Alert.js +48 -10
  4. package/cjs/core/Avatar/Avatar.d.ts +3 -2
  5. package/cjs/core/Avatar/Avatar.js +21 -19
  6. package/cjs/core/AvatarGroup/AvatarGroup.js +3 -8
  7. package/cjs/core/ButtonGroup/ButtonGroup.js +41 -36
  8. package/cjs/core/Buttons/Button/Button.d.ts +15 -2
  9. package/cjs/core/Buttons/Button/Button.js +23 -9
  10. package/cjs/core/Buttons/DropdownButton/DropdownButton.js +1 -1
  11. package/cjs/core/Buttons/IconButton/IconButton.d.ts +5 -1
  12. package/cjs/core/Buttons/IconButton/IconButton.js +27 -38
  13. package/cjs/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
  14. package/cjs/core/Buttons/SplitButton/SplitButton.js +25 -13
  15. package/cjs/core/Carousel/Carousel.d.ts +6 -4
  16. package/cjs/core/Carousel/Carousel.js +2 -2
  17. package/cjs/core/Carousel/CarouselDot.js +1 -3
  18. package/cjs/core/Carousel/CarouselNavigation.d.ts +6 -4
  19. package/cjs/core/ColorPicker/ColorBuilder.js +2 -1
  20. package/cjs/core/ColorPicker/ColorInputPanel.js +172 -231
  21. package/cjs/core/ComboBox/ComboBox.js +3 -3
  22. package/cjs/core/ComboBox/ComboBoxDropdown.js +4 -9
  23. package/cjs/core/ComboBox/ComboBoxEndIcon.js +3 -22
  24. package/cjs/core/ComboBox/ComboBoxInput.js +1 -1
  25. package/cjs/core/ComboBox/ComboBoxMenu.d.ts +2 -2
  26. package/cjs/core/ComboBox/ComboBoxMenu.js +5 -5
  27. package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
  28. package/cjs/core/ComboBox/ComboBoxMenuItem.js +8 -6
  29. package/cjs/core/ComboBox/helpers.d.ts +1 -2
  30. package/cjs/core/DatePicker/DatePicker.d.ts +30 -8
  31. package/cjs/core/DatePicker/DatePicker.js +47 -6
  32. package/cjs/core/Dialog/Dialog.js +10 -17
  33. package/cjs/core/Dialog/DialogContext.d.ts +3 -4
  34. package/cjs/core/Dialog/DialogMain.js +5 -5
  35. package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
  36. package/cjs/core/ExpandableBlock/ExpandableBlock.js +39 -18
  37. package/cjs/core/FileUpload/FileUpload.d.ts +4 -0
  38. package/cjs/core/FileUpload/FileUpload.js +24 -3
  39. package/cjs/core/Header/HeaderBasicButton.js +3 -16
  40. package/cjs/core/Header/HeaderDropdownButton.js +1 -1
  41. package/cjs/core/Header/HeaderSplitButton.js +3 -4
  42. package/cjs/core/Input/Input.d.ts +4 -0
  43. package/cjs/core/Input/Input.js +2 -1
  44. package/cjs/core/InputGrid/InputGrid.d.ts +25 -0
  45. package/cjs/core/InputGrid/InputGrid.js +39 -0
  46. package/cjs/core/InputGrid/index.d.ts +3 -0
  47. package/cjs/core/InputGrid/index.js +15 -0
  48. package/cjs/core/InputGroup/InputGroup.d.ts +13 -0
  49. package/cjs/core/InputGroup/InputGroup.js +35 -9
  50. package/cjs/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
  51. package/cjs/core/InputWithDecorations/InputWithDecorations.js +81 -0
  52. package/cjs/core/InputWithDecorations/index.d.ts +3 -0
  53. package/cjs/core/InputWithDecorations/index.js +15 -0
  54. package/cjs/core/Label/Label.d.ts +5 -0
  55. package/cjs/core/Label/Label.js +2 -0
  56. package/cjs/core/LabeledInput/LabeledInput.d.ts +22 -16
  57. package/cjs/core/LabeledInput/LabeledInput.js +52 -29
  58. package/cjs/core/LabeledSelect/LabeledSelect.d.ts +17 -7
  59. package/cjs/core/LabeledSelect/LabeledSelect.js +36 -17
  60. package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
  61. package/cjs/core/LabeledTextarea/LabeledTextarea.js +12 -45
  62. package/cjs/core/Menu/Menu.d.ts +1 -1
  63. package/cjs/core/Menu/Menu.js +1 -1
  64. package/cjs/core/Menu/MenuDivider.d.ts +2 -1
  65. package/cjs/core/Menu/MenuDivider.js +1 -1
  66. package/cjs/core/Menu/MenuItem.d.ts +1 -1
  67. package/cjs/core/Menu/MenuItem.js +1 -0
  68. package/cjs/core/Menu/MenuItemSkeleton.d.ts +1 -1
  69. package/cjs/core/Menu/MenuItemSkeleton.js +0 -1
  70. package/cjs/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
  71. package/cjs/core/ProgressIndicators/ProgressLinear.js +9 -1
  72. package/cjs/core/SearchBox/SearchBox.js +1 -1
  73. package/cjs/core/Select/Select.d.ts +4 -0
  74. package/cjs/core/Select/Select.js +12 -11
  75. package/cjs/core/SideNavigation/SideNavigation.d.ts +16 -0
  76. package/cjs/core/SideNavigation/SideNavigation.js +42 -9
  77. package/cjs/core/Slider/Slider.d.ts +24 -0
  78. package/cjs/core/Slider/Slider.js +58 -10
  79. package/cjs/core/Slider/Thumb.js +3 -2
  80. package/cjs/core/Slider/Track.d.ts +1 -1
  81. package/cjs/core/Slider/Track.js +17 -6
  82. package/cjs/core/StatusMessage/StatusMessage.d.ts +12 -2
  83. package/cjs/core/StatusMessage/StatusMessage.js +23 -9
  84. package/cjs/core/Stepper/Stepper.d.ts +26 -1
  85. package/cjs/core/Stepper/Stepper.js +35 -6
  86. package/cjs/core/Stepper/StepperStep.d.ts +17 -0
  87. package/cjs/core/Stepper/StepperStep.js +33 -8
  88. package/cjs/core/Stepper/WorkflowDiagram.d.ts +11 -1
  89. package/cjs/core/Stepper/WorkflowDiagram.js +23 -10
  90. package/cjs/core/Stepper/WorkflowDiagramStep.d.ts +6 -1
  91. package/cjs/core/Stepper/WorkflowDiagramStep.js +9 -2
  92. package/cjs/core/Table/SubRowExpander.js +3 -1
  93. package/cjs/core/Table/Table.js +0 -1
  94. package/cjs/core/Table/TableCell.js +1 -1
  95. package/cjs/core/Table/TablePaginator.js +1 -3
  96. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
  97. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +46 -18
  98. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
  99. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
  100. package/cjs/core/Tabs/Tab.js +1 -2
  101. package/cjs/core/Textarea/Textarea.d.ts +7 -1
  102. package/cjs/core/Textarea/Textarea.js +6 -11
  103. package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
  104. package/cjs/core/ThemeProvider/ThemeProvider.d.ts +23 -3
  105. package/cjs/core/ThemeProvider/ThemeProvider.js +56 -23
  106. package/cjs/core/Tile/Tile.d.ts +142 -17
  107. package/cjs/core/Tile/Tile.js +107 -16
  108. package/cjs/core/Toast/Toast.d.ts +12 -4
  109. package/cjs/core/Toast/Toast.js +24 -13
  110. package/cjs/core/Tooltip/Tooltip.d.ts +35 -28
  111. package/cjs/core/Tooltip/Tooltip.js +116 -118
  112. package/cjs/core/TransferList/TransferList.js +4 -12
  113. package/cjs/core/Tree/TreeNode.js +1 -1
  114. package/cjs/core/index.d.ts +2 -0
  115. package/cjs/core/index.js +20 -4
  116. package/cjs/core/utils/components/ButtonBase.d.ts +14 -0
  117. package/cjs/core/utils/components/ButtonBase.js +46 -0
  118. package/cjs/core/utils/components/Icon.d.ts +5 -0
  119. package/cjs/core/utils/components/Icon.js +8 -1
  120. package/cjs/core/utils/components/InputContainer.d.ts +0 -1
  121. package/cjs/core/utils/components/InputContainer.js +14 -34
  122. package/cjs/core/utils/components/InputFlexContainer.d.ts +1 -0
  123. package/cjs/core/utils/components/InputFlexContainer.js +3 -1
  124. package/cjs/core/utils/components/Popover.js +5 -3
  125. package/cjs/core/utils/components/Portal.d.ts +27 -0
  126. package/cjs/core/utils/components/Portal.js +43 -0
  127. package/cjs/core/utils/components/VirtualScroll.js +4 -4
  128. package/cjs/core/utils/components/index.d.ts +2 -0
  129. package/cjs/core/utils/components/index.js +2 -0
  130. package/cjs/core/utils/functions/colors.d.ts +1 -1
  131. package/cjs/core/utils/functions/colors.js +1 -13
  132. package/cjs/core/utils/functions/index.d.ts +1 -0
  133. package/cjs/core/utils/functions/index.js +1 -0
  134. package/cjs/core/utils/functions/react.d.ts +8 -0
  135. package/cjs/core/utils/functions/react.js +40 -0
  136. package/cjs/core/utils/hooks/index.d.ts +1 -0
  137. package/cjs/core/utils/hooks/index.js +1 -0
  138. package/cjs/core/utils/hooks/useControlledState.d.ts +13 -0
  139. package/cjs/core/utils/hooks/useControlledState.js +39 -0
  140. package/cjs/core/utils/hooks/useGlobals.d.ts +1 -1
  141. package/cjs/styles.js +11 -35
  142. package/esm/core/Alert/Alert.d.ts +20 -9
  143. package/esm/core/Alert/Alert.js +49 -10
  144. package/esm/core/Avatar/Avatar.d.ts +3 -2
  145. package/esm/core/Avatar/Avatar.js +21 -17
  146. package/esm/core/AvatarGroup/AvatarGroup.js +3 -8
  147. package/esm/core/ButtonGroup/ButtonGroup.js +41 -36
  148. package/esm/core/Buttons/Button/Button.d.ts +15 -2
  149. package/esm/core/Buttons/Button/Button.js +18 -10
  150. package/esm/core/Buttons/DropdownButton/DropdownButton.js +1 -1
  151. package/esm/core/Buttons/IconButton/IconButton.d.ts +5 -1
  152. package/esm/core/Buttons/IconButton/IconButton.js +25 -37
  153. package/esm/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
  154. package/esm/core/Buttons/SplitButton/SplitButton.js +31 -14
  155. package/esm/core/Carousel/Carousel.d.ts +6 -4
  156. package/esm/core/Carousel/Carousel.js +8 -3
  157. package/esm/core/Carousel/CarouselDot.js +2 -4
  158. package/esm/core/Carousel/CarouselNavigation.d.ts +6 -4
  159. package/esm/core/ColorPicker/ColorBuilder.js +2 -1
  160. package/esm/core/ColorPicker/ColorInputPanel.js +173 -232
  161. package/esm/core/ComboBox/ComboBox.js +3 -3
  162. package/esm/core/ComboBox/ComboBoxDropdown.js +4 -9
  163. package/esm/core/ComboBox/ComboBoxEndIcon.js +4 -25
  164. package/esm/core/ComboBox/ComboBoxInput.js +1 -1
  165. package/esm/core/ComboBox/ComboBoxMenu.d.ts +2 -2
  166. package/esm/core/ComboBox/ComboBoxMenu.js +5 -5
  167. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
  168. package/esm/core/ComboBox/ComboBoxMenuItem.js +9 -7
  169. package/esm/core/ComboBox/helpers.d.ts +1 -2
  170. package/esm/core/DatePicker/DatePicker.d.ts +30 -8
  171. package/esm/core/DatePicker/DatePicker.js +33 -6
  172. package/esm/core/Dialog/Dialog.js +11 -23
  173. package/esm/core/Dialog/DialogContext.d.ts +3 -4
  174. package/esm/core/Dialog/DialogMain.js +5 -5
  175. package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
  176. package/esm/core/ExpandableBlock/ExpandableBlock.js +41 -20
  177. package/esm/core/FileUpload/FileUpload.d.ts +4 -0
  178. package/esm/core/FileUpload/FileUpload.js +26 -3
  179. package/esm/core/Header/HeaderBasicButton.js +4 -17
  180. package/esm/core/Header/HeaderDropdownButton.js +1 -1
  181. package/esm/core/Header/HeaderSplitButton.js +9 -5
  182. package/esm/core/Input/Input.d.ts +4 -0
  183. package/esm/core/Input/Input.js +2 -1
  184. package/esm/core/InputGrid/InputGrid.d.ts +25 -0
  185. package/esm/core/InputGrid/InputGrid.js +35 -0
  186. package/esm/core/InputGrid/index.d.ts +3 -0
  187. package/esm/core/InputGrid/index.js +6 -0
  188. package/esm/core/InputGroup/InputGroup.d.ts +13 -0
  189. package/esm/core/InputGroup/InputGroup.js +34 -10
  190. package/esm/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
  191. package/esm/core/InputWithDecorations/InputWithDecorations.js +80 -0
  192. package/esm/core/InputWithDecorations/index.d.ts +3 -0
  193. package/esm/core/InputWithDecorations/index.js +6 -0
  194. package/esm/core/Label/Label.d.ts +5 -0
  195. package/esm/core/Label/Label.js +2 -0
  196. package/esm/core/LabeledInput/LabeledInput.d.ts +22 -16
  197. package/esm/core/LabeledInput/LabeledInput.js +53 -29
  198. package/esm/core/LabeledSelect/LabeledSelect.d.ts +17 -7
  199. package/esm/core/LabeledSelect/LabeledSelect.js +37 -18
  200. package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
  201. package/esm/core/LabeledTextarea/LabeledTextarea.js +14 -45
  202. package/esm/core/Menu/Menu.d.ts +1 -1
  203. package/esm/core/Menu/Menu.js +1 -1
  204. package/esm/core/Menu/MenuDivider.d.ts +2 -1
  205. package/esm/core/Menu/MenuDivider.js +1 -1
  206. package/esm/core/Menu/MenuItem.d.ts +1 -1
  207. package/esm/core/Menu/MenuItem.js +1 -0
  208. package/esm/core/Menu/MenuItemSkeleton.d.ts +1 -1
  209. package/esm/core/Menu/MenuItemSkeleton.js +0 -1
  210. package/esm/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
  211. package/esm/core/ProgressIndicators/ProgressLinear.js +9 -1
  212. package/esm/core/SearchBox/SearchBox.js +1 -1
  213. package/esm/core/Select/Select.d.ts +4 -0
  214. package/esm/core/Select/Select.js +12 -11
  215. package/esm/core/SideNavigation/SideNavigation.d.ts +16 -0
  216. package/esm/core/SideNavigation/SideNavigation.js +33 -9
  217. package/esm/core/Slider/Slider.d.ts +24 -0
  218. package/esm/core/Slider/Slider.js +43 -10
  219. package/esm/core/Slider/Thumb.js +3 -2
  220. package/esm/core/Slider/Track.d.ts +1 -1
  221. package/esm/core/Slider/Track.js +14 -6
  222. package/esm/core/StatusMessage/StatusMessage.d.ts +12 -2
  223. package/esm/core/StatusMessage/StatusMessage.js +23 -16
  224. package/esm/core/Stepper/Stepper.d.ts +26 -1
  225. package/esm/core/Stepper/Stepper.js +32 -6
  226. package/esm/core/Stepper/StepperStep.d.ts +17 -0
  227. package/esm/core/Stepper/StepperStep.js +27 -8
  228. package/esm/core/Stepper/WorkflowDiagram.d.ts +11 -1
  229. package/esm/core/Stepper/WorkflowDiagram.js +10 -7
  230. package/esm/core/Stepper/WorkflowDiagramStep.d.ts +6 -1
  231. package/esm/core/Stepper/WorkflowDiagramStep.js +6 -2
  232. package/esm/core/Table/SubRowExpander.js +3 -1
  233. package/esm/core/Table/Table.js +0 -1
  234. package/esm/core/Table/TableCell.js +1 -1
  235. package/esm/core/Table/TablePaginator.js +2 -3
  236. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
  237. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +45 -17
  238. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
  239. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
  240. package/esm/core/Tabs/Tab.js +2 -3
  241. package/esm/core/Textarea/Textarea.d.ts +7 -1
  242. package/esm/core/Textarea/Textarea.js +6 -11
  243. package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
  244. package/esm/core/ThemeProvider/ThemeProvider.d.ts +23 -3
  245. package/esm/core/ThemeProvider/ThemeProvider.js +65 -24
  246. package/esm/core/Tile/Tile.d.ts +142 -17
  247. package/esm/core/Tile/Tile.js +107 -16
  248. package/esm/core/Toast/Toast.d.ts +12 -4
  249. package/esm/core/Toast/Toast.js +26 -13
  250. package/esm/core/Tooltip/Tooltip.d.ts +35 -28
  251. package/esm/core/Tooltip/Tooltip.js +119 -116
  252. package/esm/core/TransferList/TransferList.js +4 -9
  253. package/esm/core/Tree/TreeNode.js +1 -1
  254. package/esm/core/index.d.ts +2 -0
  255. package/esm/core/index.js +2 -0
  256. package/esm/core/utils/components/ButtonBase.d.ts +14 -0
  257. package/esm/core/utils/components/ButtonBase.js +42 -0
  258. package/esm/core/utils/components/Icon.d.ts +5 -0
  259. package/esm/core/utils/components/Icon.js +8 -1
  260. package/esm/core/utils/components/InputContainer.d.ts +0 -1
  261. package/esm/core/utils/components/InputContainer.js +14 -30
  262. package/esm/core/utils/components/InputFlexContainer.d.ts +1 -0
  263. package/esm/core/utils/components/InputFlexContainer.js +3 -1
  264. package/esm/core/utils/components/Popover.js +5 -3
  265. package/esm/core/utils/components/Portal.d.ts +27 -0
  266. package/esm/core/utils/components/Portal.js +36 -0
  267. package/esm/core/utils/components/VirtualScroll.js +4 -4
  268. package/esm/core/utils/components/index.d.ts +2 -0
  269. package/esm/core/utils/components/index.js +2 -0
  270. package/esm/core/utils/functions/colors.d.ts +1 -1
  271. package/esm/core/utils/functions/colors.js +1 -13
  272. package/esm/core/utils/functions/index.d.ts +1 -0
  273. package/esm/core/utils/functions/index.js +1 -0
  274. package/esm/core/utils/functions/react.d.ts +8 -0
  275. package/esm/core/utils/functions/react.js +35 -0
  276. package/esm/core/utils/hooks/index.d.ts +1 -0
  277. package/esm/core/utils/hooks/index.js +1 -0
  278. package/esm/core/utils/hooks/useControlledState.d.ts +13 -0
  279. package/esm/core/utils/hooks/useControlledState.js +34 -0
  280. package/esm/core/utils/hooks/useGlobals.d.ts +1 -1
  281. package/esm/styles.js +11 -35
  282. package/package.json +3 -3
  283. package/styles.css +49 -46
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.Portal = void 0;
4
+ const tslib_1 = require('tslib');
5
+ /*---------------------------------------------------------------------------------------------
6
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
7
+ * See LICENSE.md in the project root for license terms and full copyright notice.
8
+ *--------------------------------------------------------------------------------------------*/
9
+ const React = tslib_1.__importStar(require('react'));
10
+ const ReactDOM = tslib_1.__importStar(require('react-dom'));
11
+ const ThemeContext_js_1 = require('../../ThemeProvider/ThemeContext.js');
12
+ const dom_js_1 = require('../functions/dom.js');
13
+ const useIsClient_js_1 = require('../hooks/useIsClient.js');
14
+ // ----------------------------------------------------------------------------
15
+ /**
16
+ * Helper component that portals children according to the following conditions:
17
+ * - renders null on server
18
+ * - if `portal` is set to true, renders into nearest ThemeContext.portalContainer
19
+ * - if `portal` is set to false, renders as-is without portal
20
+ * - otherwise renders into `portal.to` (can be an element or a function)
21
+ *
22
+ * @private
23
+ */
24
+ const Portal = (props) => {
25
+ const { portal = true, children } = props;
26
+ const isClient = (0, useIsClient_js_1.useIsClient)();
27
+ const portalTo = usePortalTo(portal);
28
+ if (!isClient) {
29
+ return null;
30
+ }
31
+ return portalTo ? ReactDOM.createPortal(children, portalTo) : children;
32
+ };
33
+ exports.Portal = Portal;
34
+ // ----------------------------------------------------------------------------
35
+ const usePortalTo = (portal) => {
36
+ const themeInfo = React.useContext(ThemeContext_js_1.ThemeContext);
37
+ if (typeof portal === 'boolean') {
38
+ return portal
39
+ ? themeInfo?.portalContainer ?? (0, dom_js_1.getDocument)()?.body
40
+ : null;
41
+ }
42
+ return typeof portal.to === 'function' ? portal.to() : portal.to;
43
+ };
@@ -36,8 +36,8 @@ const getElementHeightWithMargins = (element) => {
36
36
  return undefined;
37
37
  }
38
38
  const margin =
39
- parseFloat(getElementStyle(element, 'margin-top')) +
40
- parseFloat(getElementStyle(element, 'margin-bottom'));
39
+ parseFloat(getElementStyle(element, 'margin-block-start')) +
40
+ parseFloat(getElementStyle(element, 'margin-block-end'));
41
41
  return getElementHeight(element) + (isNaN(margin) ? 0 : margin);
42
42
  };
43
43
  const getNumberOfNodesInHeight = (childHeight, totalHeight) => {
@@ -350,13 +350,13 @@ const useVirtualization = (props) => {
350
350
  return {
351
351
  outerProps: {
352
352
  style: {
353
- minHeight:
353
+ minBlockSize:
354
354
  itemsLength > 1
355
355
  ? Math.max(itemsLength - 2, 0) * childHeight.current.middle +
356
356
  childHeight.current.first +
357
357
  childHeight.current.last
358
358
  : childHeight.current.middle,
359
- minWidth: '100%',
359
+ minInlineSize: '100%',
360
360
  ...style,
361
361
  },
362
362
  ...rest,
@@ -13,3 +13,5 @@ export * from './Divider.js';
13
13
  export * from './LinkAction.js';
14
14
  export * from './AutoclearingHiddenLiveRegion.js';
15
15
  export * from './Box.js';
16
+ export * from './ButtonBase.js';
17
+ export * from './Portal.js';
@@ -20,3 +20,5 @@ tslib_1.__exportStar(require('./Divider.js'), exports);
20
20
  tslib_1.__exportStar(require('./LinkAction.js'), exports);
21
21
  tslib_1.__exportStar(require('./AutoclearingHiddenLiveRegion.js'), exports);
22
22
  tslib_1.__exportStar(require('./Box.js'), exports);
23
+ tslib_1.__exportStar(require('./ButtonBase.js'), exports);
24
+ tslib_1.__exportStar(require('./Portal.js'), exports);
@@ -17,4 +17,4 @@ export declare const isSoftBackground: (value: string) => value is "skyblue" | "
17
17
  * Generate color from user name or email.
18
18
  * Recommended to use for `backgroundColor` in `Avatar` component.
19
19
  */
20
- export declare const getUserColor: (emailOrName: string) => string;
20
+ export declare const getUserColor: (emailOrName: string) => "var(--iui-color-background-skyblue)" | "var(--iui-color-background-celery)" | "var(--iui-color-background-froly)" | "var(--iui-color-background-steelblue)" | "var(--iui-color-background-sunglow)" | "var(--iui-color-background-seabuckthorn)" | "var(--iui-color-background-montecarlo)" | "var(--iui-color-background-poloblue)" | "var(--iui-color-background-bouquet)" | "var(--iui-color-background-ash)" | "var(--iui-color-background-oak)";
@@ -26,19 +26,7 @@ const isSoftBackground = (value) => {
26
26
  return Object.keys(exports.SoftBackgrounds).includes(value);
27
27
  };
28
28
  exports.isSoftBackground = isSoftBackground;
29
- const USER_COLORS = [
30
- '#6AB9EC',
31
- '#B1C854',
32
- '#F7706C',
33
- '#4585A5',
34
- '#FFC335',
35
- '#F7963E',
36
- '#73C7C1',
37
- '#85A9CF',
38
- '#A3779F',
39
- '#C8C2B4',
40
- '#A47854',
41
- ];
29
+ const USER_COLORS = Object.values(exports.SoftBackgrounds);
42
30
  /**
43
31
  * Generate color from user name or email.
44
32
  * Recommended to use for `backgroundColor` in `Avatar` component.
@@ -6,3 +6,4 @@ export * from './focusable.js';
6
6
  export * from './supports.js';
7
7
  export * from './polymorphic.js';
8
8
  export * from './import.js';
9
+ export * from './react.js';
@@ -13,3 +13,4 @@ tslib_1.__exportStar(require('./focusable.js'), exports);
13
13
  tslib_1.__exportStar(require('./supports.js'), exports);
14
14
  tslib_1.__exportStar(require('./polymorphic.js'), exports);
15
15
  tslib_1.__exportStar(require('./import.js'), exports);
16
+ tslib_1.__exportStar(require('./react.js'), exports);
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Wrapper over `cloneElement` that automatically checks for `isValidElement`
4
+ * and automatically merges `children.ref` with the ref passed in props.
5
+ *
6
+ * @private
7
+ */
8
+ export declare const cloneElementWithRef: (children: React.ReactNode, getProps: (children: JSX.Element) => Record<string, unknown>) => string | number | true | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null;
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.cloneElementWithRef = void 0;
4
+ const tslib_1 = require('tslib');
5
+ /*---------------------------------------------------------------------------------------------
6
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
7
+ * See LICENSE.md in the project root for license terms and full copyright notice.
8
+ *--------------------------------------------------------------------------------------------*/
9
+ const React = tslib_1.__importStar(require('react'));
10
+ const useMergedRefs_js_1 = require('../hooks/useMergedRefs.js');
11
+ /**
12
+ * Wrapper over `cloneElement` that automatically checks for `isValidElement`
13
+ * and automatically merges `children.ref` with the ref passed in props.
14
+ *
15
+ * @private
16
+ */
17
+ const cloneElementWithRef = (children, getProps) => {
18
+ if (!children) {
19
+ return null;
20
+ }
21
+ if (!React.isValidElement(children)) {
22
+ return children;
23
+ }
24
+ const props = getProps(children);
25
+ const ref = (0, useMergedRefs_js_1.mergeRefs)(
26
+ ...[
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ 'ref' in children ? children.ref : null,
29
+ 'ref' in props ? props.ref : null,
30
+ ].filter(Boolean),
31
+ );
32
+ return React.cloneElement(children, {
33
+ ...props,
34
+ // we already checked ref above and handled null, so ts-ignore is ok
35
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
36
+ // @ts-ignore
37
+ ref,
38
+ });
39
+ };
40
+ exports.cloneElementWithRef = cloneElementWithRef;
@@ -11,3 +11,4 @@ export * from './useLatestRef.js';
11
11
  export * from './useIsomorphicLayoutEffect.js';
12
12
  export * from './useIsClient.js';
13
13
  export * from './useId.js';
14
+ export * from './useControlledState.js';
@@ -18,3 +18,4 @@ tslib_1.__exportStar(require('./useLatestRef.js'), exports);
18
18
  tslib_1.__exportStar(require('./useIsomorphicLayoutEffect.js'), exports);
19
19
  tslib_1.__exportStar(require('./useIsClient.js'), exports);
20
20
  tslib_1.__exportStar(require('./useId.js'), exports);
21
+ tslib_1.__exportStar(require('./useControlledState.js'), exports);
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Wrapper over `useState` that always gives preference to the
4
+ * controlled state (which often comes from a prop).
5
+ *
6
+ * This is helpful when a component needs to support both uncontrolled
7
+ * and controlled states. If controlled value/setter is not passed,
8
+ * then it will work just like a regular `useState`.
9
+ *
10
+ * @example
11
+ * const [state, setState] = useControlledState(null, props.value, props.onChange);
12
+ */
13
+ export declare const useControlledState: <T>(initialValue: T, controlledState: T, setControlledState?: React.Dispatch<React.SetStateAction<T>> | undefined) => readonly [T, React.Dispatch<React.SetStateAction<T>>];
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.useControlledState = void 0;
4
+ const tslib_1 = require('tslib');
5
+ /*---------------------------------------------------------------------------------------------
6
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
7
+ * See LICENSE.md in the project root for license terms and full copyright notice.
8
+ *--------------------------------------------------------------------------------------------*/
9
+ const React = tslib_1.__importStar(require('react'));
10
+ /**
11
+ * Wrapper over `useState` that always gives preference to the
12
+ * controlled state (which often comes from a prop).
13
+ *
14
+ * This is helpful when a component needs to support both uncontrolled
15
+ * and controlled states. If controlled value/setter is not passed,
16
+ * then it will work just like a regular `useState`.
17
+ *
18
+ * @example
19
+ * const [state, setState] = useControlledState(null, props.value, props.onChange);
20
+ */
21
+ const useControlledState = (
22
+ initialValue,
23
+ controlledState,
24
+ setControlledState,
25
+ ) => {
26
+ const [uncontrolledState, setUncontrolledState] =
27
+ React.useState(initialValue);
28
+ const state =
29
+ controlledState !== undefined ? controlledState : uncontrolledState;
30
+ const setState = React.useCallback(
31
+ (value) => {
32
+ setUncontrolledState(value);
33
+ setControlledState?.(value);
34
+ },
35
+ [setControlledState, setUncontrolledState],
36
+ );
37
+ return [state, setState];
38
+ };
39
+ exports.useControlledState = useControlledState;
@@ -9,7 +9,7 @@ import { ThemeContext } from '../../ThemeProvider/ThemeContext.js';
9
9
  export declare const useGlobals: () => {
10
10
  theme?: import("../../index.js").ThemeType | undefined;
11
11
  themeOptions?: import("../../ThemeProvider/ThemeProvider.js").ThemeOptions | undefined;
12
- portalContainerRef?: React.RefObject<HTMLElement> | undefined;
12
+ portalContainer?: HTMLElement | null | undefined;
13
13
  } | undefined;
14
14
  /** Shows console error if ThemeProvider is not used */
15
15
  export declare const useThemeProviderWarning: (themeContext: React.ContextType<typeof ThemeContext>) => void;
package/cjs/styles.js CHANGED
@@ -11,13 +11,6 @@ const styles = {
11
11
  'iui-anchor': '_iui3-anchor',
12
12
  'iui-anchor-external': '_iui3-anchor-external',
13
13
  'iui-avatar': '_iui3-avatar',
14
- 'iui-stroke': '_iui3-stroke',
15
- 'iui-initials': '_iui3-initials',
16
- 'iui-status': '_iui3-status',
17
- 'iui-online': '_iui3-online',
18
- 'iui-away': '_iui3-away',
19
- 'iui-busy': '_iui3-busy',
20
- 'iui-offline': '_iui3-offline',
21
14
  'iui-avatar-count': '_iui3-avatar-count',
22
15
  'iui-small': '_iui3-small',
23
16
  'iui-large': '_iui3-large',
@@ -41,8 +34,9 @@ const styles = {
41
34
  'iui-button-dropdown': '_iui3-button-dropdown',
42
35
  'iui-button-split': '_iui3-button-split',
43
36
  'iui-button-group': '_iui3-button-group',
44
- 'iui-input-container': '_iui3-input-container',
37
+ 'iui-input-flex-container': '_iui3-input-flex-container',
45
38
  'iui-input': '_iui3-input',
39
+ 'iui-input-grid': '_iui3-input-grid',
46
40
  'iui-disabled': '_iui3-disabled',
47
41
  'iui-button-group-vertical': '_iui3-button-group-vertical',
48
42
  'iui-button-group-overflow-x': '_iui3-button-group-overflow-x',
@@ -185,36 +179,18 @@ const styles = {
185
179
  'iui-information-body-content': '_iui3-information-body-content',
186
180
  'iui-input-label': '_iui3-input-label',
187
181
  'iui-inline': '_iui3-inline',
188
- 'iui-required': '_iui3-required',
189
182
  'iui-input-with-icon': '_iui3-input-with-icon',
190
183
  'iui-select-tag-container': '_iui3-select-tag-container',
191
184
  'iui-end-icon': '_iui3-end-icon',
192
- 'iui-actionable': '_iui3-actionable',
193
185
  'iui-open': '_iui3-open',
194
- 'iui-inline-icon': '_iui3-inline-icon',
195
- 'iui-with-message': '_iui3-with-message',
196
- 'iui-input-icon': '_iui3-input-icon',
186
+ 'iui-required': '_iui3-required',
197
187
  'iui-input-group': '_iui3-input-group',
188
+ 'iui-status-message': '_iui3-status-message',
189
+ 'iui-select-button': '_iui3-select-button',
190
+ 'iui-input-group-wrapper': '_iui3-input-group-wrapper',
198
191
  'iui-toggle-switch-wrapper': '_iui3-toggle-switch-wrapper',
199
192
  'iui-radio-wrapper': '_iui3-radio-wrapper',
200
- 'iui-inline-label': '_iui3-inline-label',
201
- 'iui-label': '_iui3-label',
202
- 'iui-message': '_iui3-message',
203
- 'iui-select-button': '_iui3-select-button',
204
- 'iui-input-flex-container': '_iui3-input-flex-container',
205
193
  'iui-keyboard': '_iui3-keyboard',
206
- 'iui-location-marker': '_iui3-location-marker',
207
- 'iui-location-marker-default': '_iui3-location-marker-default',
208
- 'iui-location-marker-default-pin': '_iui3-location-marker-default-pin',
209
- 'iui-location-marker-default-pin-dot':
210
- '_iui3-location-marker-default-pin-dot',
211
- 'iui-location-marker-data-rich': '_iui3-location-marker-data-rich',
212
- 'iui-location-marker-data-rich-body': '_iui3-location-marker-data-rich-body',
213
- 'iui-location-marker-data-rich-icon': '_iui3-location-marker-data-rich-icon',
214
- 'iui-location-marker-data-rich-icon-monochrome':
215
- '_iui3-location-marker-data-rich-icon-monochrome',
216
- 'iui-location-marker-me': '_iui3-location-marker-me',
217
- 'iui-location-marker-me-dot': '_iui3-location-marker-me-dot',
218
194
  'iui-list': '_iui3-list',
219
195
  'iui-menu': '_iui3-menu',
220
196
  'iui-header-menu-icon': '_iui3-header-menu-icon',
@@ -243,10 +219,10 @@ const styles = {
243
219
  'iui-overlay-exiting': '_iui3-overlay-exiting',
244
220
  closeAnimation,
245
221
  'iui-progress-indicator-radial': '_iui3-progress-indicator-radial',
246
- 'iui-ux8sxma': '_iui3-ux8sxma',
222
+ 'iui-ubn95wp': '_iui3-ubn95wp',
247
223
  'iui-progress-indicator-linear-label':
248
224
  '_iui3-progress-indicator-linear-label',
249
- 'iui-ux8sxmt': '_iui3-ux8sxmt',
225
+ 'iui-ubn95xj': '_iui3-ubn95xj',
250
226
  'iui-radio': '_iui3-radio',
251
227
  'iui-radio-tile': '_iui3-radio-tile',
252
228
  'iui-radio-tile-icon': '_iui3-radio-tile-icon',
@@ -313,6 +289,7 @@ const styles = {
313
289
  'iui-table-body': '_iui3-table-body',
314
290
  'iui-table-header-wrapper': '_iui3-table-header-wrapper',
315
291
  'iui-slot': '_iui3-slot',
292
+ 'iui-actionable': '_iui3-actionable',
316
293
  'iui-table-filter-button': '_iui3-table-filter-button',
317
294
  'iui-table-resizer': '_iui3-table-resizer',
318
295
  'iui-table-resizer-bar': '_iui3-table-resizer-bar',
@@ -409,6 +386,7 @@ const styles = {
409
386
  'iui-placement-bottom-start': '_iui3-placement-bottom-start',
410
387
  'iui-placement-bottom-end': '_iui3-placement-bottom-end',
411
388
  'iui-status-area': '_iui3-status-area',
389
+ 'iui-message': '_iui3-message',
412
390
  'iui-toast-anchor': '_iui3-toast-anchor',
413
391
  'iui-informational': '_iui3-informational',
414
392
  'iui-label-on-left': '_iui3-label-on-left',
@@ -416,11 +394,8 @@ const styles = {
416
394
  'iui-toggle-switch-icon': '_iui3-toggle-switch-icon',
417
395
  'iui-toggle-switch': '_iui3-toggle-switch',
418
396
  'iui-toggle-switch-label': '_iui3-toggle-switch-label',
419
- 'iui-tooltip-container': '_iui3-tooltip-container',
420
397
  'iui-tooltip': '_iui3-tooltip',
421
- 'iui-tooltip-visible': '_iui3-tooltip-visible',
422
398
  'iui-transfer-list-wrapper': '_iui3-transfer-list-wrapper',
423
- 'iui-transfer-list-listbox-label': '_iui3-transfer-list-listbox-label',
424
399
  'iui-transfer-list-listbox-wrapper': '_iui3-transfer-list-listbox-wrapper',
425
400
  'iui-transfer-list-listbox': '_iui3-transfer-list-listbox',
426
401
  'iui-transfer-list-toolbar': '_iui3-transfer-list-toolbar',
@@ -438,6 +413,7 @@ const styles = {
438
413
  'iui-tree-node-content-label': '_iui3-tree-node-content-label',
439
414
  'iui-tree-node-content-title': '_iui3-tree-node-content-title',
440
415
  'iui-tree-node-content-caption': '_iui3-tree-node-content-caption',
416
+ 'iui-button-base': '_iui3-button-base',
441
417
  'iui-svg-icon': '_iui3-svg-icon',
442
418
  'iui-notification-marker': '_iui3-notification-marker',
443
419
  pulse,
@@ -12,20 +12,26 @@ type AlertOwnProps = {
12
12
  */
13
13
  isSticky?: boolean;
14
14
  };
15
+ type AlertLegacyProps = {
16
+ /** @deprecated Use `Alert.Action` subcomponent. */
17
+ clickableText?: React.ReactNode;
18
+ /** @deprecated Use `Alert.Action` subcomponent. */
19
+ clickableTextProps?: React.ComponentPropsWithoutRef<'a'>;
20
+ /** @deprecated Use `Alert.CloseButton` subcomponent. */
21
+ onClose?: () => void;
22
+ };
15
23
  /**
16
24
  * A small box to quickly grab user attention and communicate a brief message
17
25
  * @example
18
- * <Alert>
19
- * <Alert.Message>This is an alert.</Alert.Message>
20
- * </Alert>
26
+ * <Alert>This is an alert.</Alert>
21
27
  * @example
22
- * <Alert type='informational'>
28
+ * <Alert.Wrapper type='informational'>
23
29
  * <Alert.Icon />
24
30
  * <Alert.Message>This is an informational alert.</Alert.Message>
25
31
  * <Alert.CloseButton onClick={() => {}} />
26
- * </Alert>
32
+ * </Alert.Wrapper>
27
33
  * @example
28
- * <Alert type='positive'>
34
+ * <Alert.Wrapper type='positive'>
29
35
  * <Alert.Icon>
30
36
  * <SvgSmileyHappy />
31
37
  * </Alert.Icon>
@@ -36,17 +42,22 @@ type AlertOwnProps = {
36
42
  * <Alert.CloseButton onClick={() => {}}>
37
43
  * <SvgCollapse />
38
44
  * </Alert.CloseButton>
39
- * </Alert>
45
+ * </Alert.Wrapper>
40
46
  */
41
- export declare const Alert: PolymorphicForwardRefComponent<"div", AlertOwnProps> & {
47
+ export declare const Alert: PolymorphicForwardRefComponent<"div", AlertOwnProps & AlertLegacyProps> & {
48
+ /**
49
+ * Alert wrapper subcomponent
50
+ */
51
+ Wrapper: PolymorphicForwardRefComponent<"div", AlertOwnProps>;
42
52
  /**
43
53
  * Alert icon subcomponent
44
54
  */
45
55
  Icon: PolymorphicForwardRefComponent<"span", Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
46
56
  ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
47
- }, "fill" | "as" | "key" | "size" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
57
+ }, "fill" | "as" | "key" | "size" | keyof React.HTMLAttributes<HTMLSpanElement> | "padded"> & {
48
58
  size?: "small" | "large" | "auto" | "medium" | import("../utils/types.js").AnyString | undefined;
49
59
  fill?: "default" | "informational" | "negative" | "positive" | "warning" | import("../utils/types.js").AnyString | undefined;
60
+ padded?: boolean | undefined;
50
61
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
51
62
  as?: "span" | undefined;
52
63
  }>;
@@ -11,10 +11,47 @@ import {
11
11
  StatusIconMap,
12
12
  SvgCloseSmall,
13
13
  Box,
14
+ ButtonBase,
14
15
  } from '../utils/index.js';
15
16
  import { IconButton } from '../Buttons/index.js';
16
17
  const AlertContext = React.createContext(undefined);
17
- const AlertComponent = React.forwardRef((props, ref) => {
18
+ // ----------------------------------------------------------------------------
19
+ // Alert component
20
+ const AlertComponent = React.forwardRef((props, forwardedRef) => {
21
+ const {
22
+ children,
23
+ type = 'informational',
24
+ isSticky = false,
25
+ clickableText,
26
+ clickableTextProps,
27
+ onClose,
28
+ ...rest
29
+ } = props;
30
+ return React.createElement(
31
+ Alert.Wrapper,
32
+ { type: type, isSticky: isSticky, ref: forwardedRef, ...rest },
33
+ React.createElement(Alert.Icon, null),
34
+ React.createElement(
35
+ Alert.Message,
36
+ null,
37
+ children,
38
+ clickableText
39
+ ? React.createElement(
40
+ Alert.Action,
41
+ { ...clickableTextProps },
42
+ clickableText,
43
+ )
44
+ : null,
45
+ ),
46
+ onClose
47
+ ? React.createElement(Alert.CloseButton, { onClick: onClose })
48
+ : null,
49
+ );
50
+ });
51
+ AlertComponent.displayName = 'Alert';
52
+ // ----------------------------------------------------------------------------
53
+ // Alert.Wrapper component
54
+ const AlertWrapper = React.forwardRef((props, ref) => {
18
55
  const {
19
56
  children,
20
57
  className,
@@ -34,7 +71,7 @@ const AlertComponent = React.forwardRef((props, ref) => {
34
71
  React.createElement(AlertContext.Provider, { value: { type } }, children),
35
72
  );
36
73
  });
37
- AlertComponent.displayName = 'Alert';
74
+ AlertWrapper.displayName = 'Alert.Wrapper';
38
75
  // ----------------------------------------------------------------------------
39
76
  // Alert.Icon component
40
77
  const AlertIcon = React.forwardRef((props, ref) => {
@@ -57,7 +94,7 @@ AlertMessage.displayName = 'Alert.Message';
57
94
  const AlertAction = React.forwardRef((props, ref) => {
58
95
  const { children, className, ...rest } = props;
59
96
  return React.createElement(
60
- Box,
97
+ ButtonBase,
61
98
  {
62
99
  as: !!props.href ? 'a' : 'button',
63
100
  className: cx('iui-alert-link', className),
@@ -88,17 +125,15 @@ AlertCloseButton.displayName = 'Alert.CloseButton';
88
125
  /**
89
126
  * A small box to quickly grab user attention and communicate a brief message
90
127
  * @example
91
- * <Alert>
92
- * <Alert.Message>This is an alert.</Alert.Message>
93
- * </Alert>
128
+ * <Alert>This is an alert.</Alert>
94
129
  * @example
95
- * <Alert type='informational'>
130
+ * <Alert.Wrapper type='informational'>
96
131
  * <Alert.Icon />
97
132
  * <Alert.Message>This is an informational alert.</Alert.Message>
98
133
  * <Alert.CloseButton onClick={() => {}} />
99
- * </Alert>
134
+ * </Alert.Wrapper>
100
135
  * @example
101
- * <Alert type='positive'>
136
+ * <Alert.Wrapper type='positive'>
102
137
  * <Alert.Icon>
103
138
  * <SvgSmileyHappy />
104
139
  * </Alert.Icon>
@@ -109,9 +144,13 @@ AlertCloseButton.displayName = 'Alert.CloseButton';
109
144
  * <Alert.CloseButton onClick={() => {}}>
110
145
  * <SvgCollapse />
111
146
  * </Alert.CloseButton>
112
- * </Alert>
147
+ * </Alert.Wrapper>
113
148
  */
114
149
  export const Alert = Object.assign(AlertComponent, {
150
+ /**
151
+ * Alert wrapper subcomponent
152
+ */
153
+ Wrapper: AlertWrapper,
115
154
  /**
116
155
  * Alert icon subcomponent
117
156
  */
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
- import type { PolymorphicForwardRefComponent } from '../utils/index.js';
2
+ import { SoftBackgrounds } from '../utils/index.js';
3
+ import type { AnyString, PolymorphicForwardRefComponent } from '../utils/index.js';
3
4
  export type AvatarStatus = 'online' | 'busy' | 'away' | 'offline';
4
5
  type StatusTitles = {
5
6
  [key in Exclude<AvatarStatus, ''>]: string;
@@ -29,7 +30,7 @@ type AvatarProps = {
29
30
  /**
30
31
  * Color of the icon. You can use `getUserColor` function to generate color from user name or email. If not provided, default background color from CSS styling will be used (hsl(72, 51%, 56%) / olive green).
31
32
  */
32
- backgroundColor?: string;
33
+ backgroundColor?: keyof typeof SoftBackgrounds | AnyString;
33
34
  /**
34
35
  * Translated status messages shown on hover.
35
36
  */
@@ -4,7 +4,21 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import cx from 'classnames';
6
6
  import * as React from 'react';
7
- import { Box } from '../utils/index.js';
7
+ import {
8
+ Box,
9
+ VisuallyHidden,
10
+ SoftBackgrounds,
11
+ isSoftBackground,
12
+ } from '../utils/index.js';
13
+ /**
14
+ * Helper function that returns one of the preset badge color values.
15
+ */
16
+ const getBackground = (color) => {
17
+ if (!color) {
18
+ return '';
19
+ }
20
+ return isSoftBackground(color) ? SoftBackgrounds[color] : color;
21
+ };
8
22
  export const defaultStatusTitles = {
9
23
  away: 'Away',
10
24
  busy: 'Busy',
@@ -49,27 +63,17 @@ export const Avatar = React.forwardRef((props, ref) => {
49
63
  { [`iui-${size}`]: size !== 'medium' },
50
64
  className,
51
65
  ),
66
+ 'data-iui-status': status,
52
67
  title: title,
53
- style: { backgroundColor, ...style },
68
+ style: { backgroundColor: getBackground(backgroundColor), ...style },
54
69
  ref: ref,
55
70
  ...rest,
56
71
  },
57
- !image &&
58
- React.createElement(
59
- Box,
60
- { as: 'abbr', className: 'iui-initials' },
61
- abbreviation?.substring(0, 2),
62
- ),
72
+ !image ? abbreviation?.substring(0, 2) : null,
63
73
  image,
64
- React.createElement(Box, { as: 'span', className: 'iui-stroke' }),
65
- status &&
66
- React.createElement(Box, {
67
- as: 'span',
68
- title: statusTitles[status],
69
- className: cx('iui-status', {
70
- [`iui-${status}`]: !!status,
71
- }),
72
- }),
74
+ status
75
+ ? React.createElement(VisuallyHidden, null, statusTitles[status])
76
+ : null,
73
77
  );
74
78
  });
75
79
  export default Avatar;
@@ -85,14 +85,9 @@ export const AvatarGroup = React.forwardRef((props, ref) => {
85
85
  countIconProps?.className,
86
86
  ),
87
87
  },
88
- React.createElement(
89
- Box,
90
- { as: 'abbr', className: 'iui-initials' },
91
- childrenLength <= maxLength
92
- ? `${childrenLength - maxIcons}`
93
- : `${maxLength}+`,
94
- ),
95
- React.createElement(Box, { className: 'iui-stroke' }),
88
+ childrenLength <= maxLength
89
+ ? `${childrenLength - maxIcons}`
90
+ : `${maxLength}+`,
96
91
  ),
97
92
  ),
98
93
  );