@itwin/itwinui-react 1.48.1 → 2.0.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/README.md +4 -22
  2. package/cjs/core/Alert/Alert.d.ts +7 -6
  3. package/cjs/core/Alert/Alert.js +12 -7
  4. package/cjs/core/Avatar/Avatar.d.ts +69 -0
  5. package/cjs/core/{UserIcon/UserIcon.js → Avatar/Avatar.js} +15 -11
  6. package/cjs/core/Avatar/index.d.ts +4 -0
  7. package/cjs/core/{UserIcon → Avatar}/index.js +5 -4
  8. package/cjs/core/AvatarGroup/AvatarGroup.d.ts +70 -0
  9. package/cjs/core/{UserIconGroup/UserIconGroup.js → AvatarGroup/AvatarGroup.js} +23 -19
  10. package/cjs/core/AvatarGroup/index.d.ts +4 -0
  11. package/cjs/core/{UserIconGroup → AvatarGroup}/index.js +5 -4
  12. package/cjs/core/Badge/Badge.js +2 -4
  13. package/cjs/core/ButtonGroup/ButtonGroup.d.ts +1 -1
  14. package/cjs/core/Buttons/Button/Button.js +5 -14
  15. package/cjs/core/Buttons/DropdownButton/DropdownButton.js +1 -1
  16. package/cjs/core/Buttons/IconButton/IconButton.js +3 -9
  17. package/cjs/core/Buttons/IdeasButton/IdeasButton.js +1 -1
  18. package/cjs/core/Buttons/SplitButton/SplitButton.js +4 -6
  19. package/cjs/core/Checkbox/Checkbox.d.ts +1 -29
  20. package/cjs/core/Checkbox/Checkbox.js +3 -3
  21. package/cjs/core/ColorPicker/ColorBuilder.js +16 -27
  22. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  23. package/cjs/core/ColorPicker/ColorSwatch.js +1 -6
  24. package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +1 -1
  25. package/cjs/core/ComboBox/ComboBoxMenu.js +2 -4
  26. package/cjs/core/Dialog/Dialog.d.ts +4 -4
  27. package/cjs/core/Dialog/Dialog.js +1 -1
  28. package/cjs/core/Dialog/DialogBackdrop.d.ts +1 -1
  29. package/cjs/core/Dialog/DialogBackdrop.js +5 -2
  30. package/cjs/core/Dialog/DialogMain.d.ts +1 -1
  31. package/cjs/core/Dialog/DialogMain.js +7 -1
  32. package/cjs/core/Dialog/DialogTitleBar.d.ts +1 -1
  33. package/cjs/core/ExpandableBlock/ExpandableBlock.js +4 -4
  34. package/cjs/core/Header/Header.d.ts +16 -6
  35. package/cjs/core/Header/Header.js +7 -9
  36. package/cjs/core/Header/HeaderBasicButton.d.ts +6 -0
  37. package/cjs/core/Header/HeaderBasicButton.js +52 -0
  38. package/cjs/core/Header/HeaderBreadcrumbs.js +6 -4
  39. package/cjs/core/Header/HeaderButton.d.ts +3 -2
  40. package/cjs/core/Header/HeaderButton.js +10 -18
  41. package/cjs/core/Header/HeaderDropdownButton.d.ts +6 -0
  42. package/cjs/core/Header/HeaderDropdownButton.js +56 -0
  43. package/cjs/core/Header/HeaderLogo.js +3 -3
  44. package/cjs/core/Header/HeaderSplitButton.d.ts +6 -0
  45. package/cjs/core/Header/HeaderSplitButton.js +56 -0
  46. package/cjs/core/Input/Input.d.ts +1 -1
  47. package/cjs/core/Input/Input.js +3 -4
  48. package/cjs/core/InputGroup/InputGroup.d.ts +1 -1
  49. package/cjs/core/InputGroup/InputGroup.js +1 -1
  50. package/cjs/core/Label/Label.d.ts +1 -1
  51. package/cjs/core/Label/Label.js +1 -1
  52. package/cjs/core/LabeledInput/LabeledInput.d.ts +2 -2
  53. package/cjs/core/LabeledInput/LabeledInput.js +1 -1
  54. package/cjs/core/LabeledSelect/LabeledSelect.d.ts +1 -1
  55. package/cjs/core/LabeledSelect/LabeledSelect.js +1 -1
  56. package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +1 -1
  57. package/cjs/core/LabeledTextarea/LabeledTextarea.js +1 -1
  58. package/cjs/core/Radio/Radio.d.ts +1 -29
  59. package/cjs/core/Radio/Radio.js +3 -3
  60. package/cjs/core/RadioTiles/RadioTileGroup.d.ts +1 -1
  61. package/cjs/core/RadioTiles/RadioTileGroup.js +1 -1
  62. package/cjs/core/Select/Select.d.ts +1 -1
  63. package/cjs/core/Select/Select.js +9 -12
  64. package/cjs/core/Select/SelectTag.d.ts +1 -1
  65. package/cjs/core/Select/SelectTag.js +1 -1
  66. package/cjs/core/SideNavigation/SidenavButton.js +1 -2
  67. package/cjs/core/Stepper/Stepper.d.ts +40 -0
  68. package/cjs/core/{Wizard/Wizard.js → Stepper/Stepper.js} +11 -28
  69. package/cjs/core/{Wizard/Step.d.ts → Stepper/StepperStep.d.ts} +6 -7
  70. package/cjs/core/{Wizard/Step.js → Stepper/StepperStep.js} +10 -10
  71. package/cjs/core/Stepper/Wizard.d.ts +46 -0
  72. package/cjs/core/Stepper/Wizard.js +55 -0
  73. package/cjs/core/Stepper/WorkflowDiagram.d.ts +6 -0
  74. package/cjs/core/Stepper/WorkflowDiagram.js +43 -0
  75. package/cjs/core/Stepper/WorkflowDiagramStep.d.ts +5 -0
  76. package/cjs/core/Stepper/WorkflowDiagramStep.js +42 -0
  77. package/cjs/core/Stepper/index.d.ts +8 -0
  78. package/cjs/core/{Wizard → Stepper}/index.js +5 -1
  79. package/cjs/core/Surface/Surface.js +2 -4
  80. package/cjs/core/Table/SubRowExpander.js +1 -1
  81. package/cjs/core/Table/Table.d.ts +5 -4
  82. package/cjs/core/Table/Table.js +30 -21
  83. package/cjs/core/Table/TableCell.js +4 -4
  84. package/cjs/core/Table/TablePaginator.js +14 -15
  85. package/cjs/core/Table/TableRowMemoized.d.ts +2 -0
  86. package/cjs/core/Table/TableRowMemoized.js +10 -13
  87. package/cjs/core/Table/cells/DefaultCell.js +4 -9
  88. package/cjs/core/Table/columns/actionColumn.js +1 -1
  89. package/cjs/core/Table/columns/expanderColumn.js +1 -1
  90. package/cjs/core/Table/filters/BaseFilter.js +1 -1
  91. package/cjs/core/Table/filters/FilterToggle.js +1 -1
  92. package/cjs/core/Table/hooks/useColumnDragAndDrop.js +4 -4
  93. package/cjs/core/Table/hooks/useResizeColumns.js +110 -106
  94. package/cjs/core/Tabs/Tab.d.ts +0 -8
  95. package/cjs/core/Tabs/Tab.js +1 -5
  96. package/cjs/core/Tabs/Tabs.js +8 -11
  97. package/cjs/core/Tabs/index.d.ts +2 -2
  98. package/cjs/core/Tabs/index.js +1 -2
  99. package/cjs/core/Textarea/Textarea.d.ts +1 -1
  100. package/cjs/core/Textarea/Textarea.js +2 -2
  101. package/cjs/core/ThemeProvider/ThemeProvider.d.ts +27 -17
  102. package/cjs/core/ThemeProvider/ThemeProvider.js +64 -7
  103. package/cjs/core/Tile/Tile.d.ts +19 -1
  104. package/cjs/core/Tile/Tile.js +35 -12
  105. package/cjs/core/Toast/Toast.d.ts +3 -3
  106. package/cjs/core/Toast/Toast.js +3 -3
  107. package/cjs/core/Toast/ToastWrapper.d.ts +1 -1
  108. package/cjs/core/Toast/ToastWrapper.js +1 -1
  109. package/cjs/core/Tree/TreeNode.js +1 -7
  110. package/cjs/core/index.d.ts +8 -8
  111. package/cjs/core/index.js +13 -10
  112. package/cjs/core/utils/components/Popover.d.ts +2 -2
  113. package/cjs/core/utils/components/Popover.js +1 -1
  114. package/cjs/core/utils/components/Resizer.d.ts +5 -0
  115. package/cjs/core/utils/components/Resizer.js +7 -1
  116. package/cjs/core/utils/components/VisuallyHidden.d.ts +1 -0
  117. package/cjs/core/utils/components/VisuallyHidden.js +1 -0
  118. package/cjs/core/utils/functions/colors.d.ts +1 -1
  119. package/cjs/core/utils/functions/colors.js +1 -1
  120. package/cjs/core/utils/hooks/index.d.ts +1 -0
  121. package/cjs/core/utils/hooks/index.js +1 -0
  122. package/cjs/core/utils/hooks/useIsomorphicLayoutEffect.d.ts +7 -0
  123. package/cjs/core/utils/hooks/useIsomorphicLayoutEffect.js +17 -0
  124. package/cjs/core/utils/hooks/useMediaQuery.js +2 -1
  125. package/cjs/core/utils/hooks/useTheme.d.ts +20 -3
  126. package/cjs/core/utils/hooks/useTheme.js +57 -58
  127. package/esm/core/Alert/Alert.d.ts +7 -6
  128. package/esm/core/Alert/Alert.js +12 -7
  129. package/esm/core/Avatar/Avatar.d.ts +69 -0
  130. package/esm/core/{UserIcon/UserIcon.js → Avatar/Avatar.js} +13 -9
  131. package/esm/core/Avatar/index.d.ts +4 -0
  132. package/esm/core/{UserIcon → Avatar}/index.js +2 -2
  133. package/esm/core/AvatarGroup/AvatarGroup.d.ts +70 -0
  134. package/esm/core/{UserIconGroup/UserIconGroup.js → AvatarGroup/AvatarGroup.js} +21 -17
  135. package/esm/core/AvatarGroup/index.d.ts +4 -0
  136. package/esm/core/{UserIconGroup → AvatarGroup}/index.js +2 -2
  137. package/esm/core/Badge/Badge.js +3 -5
  138. package/esm/core/ButtonGroup/ButtonGroup.d.ts +1 -1
  139. package/esm/core/Buttons/Button/Button.js +5 -14
  140. package/esm/core/Buttons/DropdownButton/DropdownButton.js +1 -1
  141. package/esm/core/Buttons/IconButton/IconButton.js +3 -9
  142. package/esm/core/Buttons/IdeasButton/IdeasButton.js +1 -1
  143. package/esm/core/Buttons/SplitButton/SplitButton.js +4 -6
  144. package/esm/core/Checkbox/Checkbox.d.ts +1 -29
  145. package/esm/core/Checkbox/Checkbox.js +3 -3
  146. package/esm/core/ColorPicker/ColorBuilder.js +17 -28
  147. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  148. package/esm/core/ColorPicker/ColorSwatch.js +2 -7
  149. package/esm/core/ComboBox/ComboBoxDropdown.d.ts +1 -1
  150. package/esm/core/ComboBox/ComboBoxMenu.js +2 -4
  151. package/esm/core/Dialog/Dialog.d.ts +4 -4
  152. package/esm/core/Dialog/Dialog.js +1 -1
  153. package/esm/core/Dialog/DialogBackdrop.d.ts +1 -1
  154. package/esm/core/Dialog/DialogBackdrop.js +5 -2
  155. package/esm/core/Dialog/DialogMain.d.ts +1 -1
  156. package/esm/core/Dialog/DialogMain.js +7 -1
  157. package/esm/core/Dialog/DialogTitleBar.d.ts +1 -1
  158. package/esm/core/ExpandableBlock/ExpandableBlock.js +4 -4
  159. package/esm/core/Header/Header.d.ts +16 -6
  160. package/esm/core/Header/Header.js +7 -9
  161. package/esm/core/Header/HeaderBasicButton.d.ts +6 -0
  162. package/esm/core/Header/HeaderBasicButton.js +46 -0
  163. package/esm/core/Header/HeaderBreadcrumbs.js +6 -4
  164. package/esm/core/Header/HeaderButton.d.ts +3 -2
  165. package/esm/core/Header/HeaderButton.js +10 -18
  166. package/esm/core/Header/HeaderDropdownButton.d.ts +6 -0
  167. package/esm/core/Header/HeaderDropdownButton.js +50 -0
  168. package/esm/core/Header/HeaderLogo.js +3 -3
  169. package/esm/core/Header/HeaderSplitButton.d.ts +6 -0
  170. package/esm/core/Header/HeaderSplitButton.js +50 -0
  171. package/esm/core/Input/Input.d.ts +1 -1
  172. package/esm/core/Input/Input.js +3 -4
  173. package/esm/core/InputGroup/InputGroup.d.ts +1 -1
  174. package/esm/core/InputGroup/InputGroup.js +1 -1
  175. package/esm/core/Label/Label.d.ts +1 -1
  176. package/esm/core/Label/Label.js +1 -1
  177. package/esm/core/LabeledInput/LabeledInput.d.ts +2 -2
  178. package/esm/core/LabeledInput/LabeledInput.js +1 -1
  179. package/esm/core/LabeledSelect/LabeledSelect.d.ts +1 -1
  180. package/esm/core/LabeledSelect/LabeledSelect.js +1 -1
  181. package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +1 -1
  182. package/esm/core/LabeledTextarea/LabeledTextarea.js +1 -1
  183. package/esm/core/Radio/Radio.d.ts +1 -29
  184. package/esm/core/Radio/Radio.js +3 -3
  185. package/esm/core/RadioTiles/RadioTileGroup.d.ts +1 -1
  186. package/esm/core/RadioTiles/RadioTileGroup.js +1 -1
  187. package/esm/core/Select/Select.d.ts +1 -1
  188. package/esm/core/Select/Select.js +9 -12
  189. package/esm/core/Select/SelectTag.d.ts +1 -1
  190. package/esm/core/Select/SelectTag.js +1 -1
  191. package/esm/core/SideNavigation/SidenavButton.js +1 -2
  192. package/esm/core/Stepper/Stepper.d.ts +40 -0
  193. package/esm/core/{Wizard/Wizard.js → Stepper/Stepper.js} +10 -27
  194. package/esm/core/{Wizard/Step.d.ts → Stepper/StepperStep.d.ts} +6 -7
  195. package/esm/core/{Wizard/Step.js → Stepper/StepperStep.js} +8 -8
  196. package/esm/core/Stepper/Wizard.d.ts +46 -0
  197. package/esm/core/Stepper/Wizard.js +49 -0
  198. package/esm/core/Stepper/WorkflowDiagram.d.ts +6 -0
  199. package/esm/core/Stepper/WorkflowDiagram.js +37 -0
  200. package/esm/core/Stepper/WorkflowDiagramStep.d.ts +5 -0
  201. package/esm/core/Stepper/WorkflowDiagramStep.js +35 -0
  202. package/esm/core/Stepper/index.d.ts +8 -0
  203. package/esm/core/{Wizard → Stepper}/index.js +2 -0
  204. package/esm/core/Surface/Surface.js +3 -5
  205. package/esm/core/Table/SubRowExpander.js +1 -1
  206. package/esm/core/Table/Table.d.ts +5 -4
  207. package/esm/core/Table/Table.js +30 -21
  208. package/esm/core/Table/TableCell.js +4 -4
  209. package/esm/core/Table/TablePaginator.js +14 -15
  210. package/esm/core/Table/TableRowMemoized.d.ts +2 -0
  211. package/esm/core/Table/TableRowMemoized.js +10 -13
  212. package/esm/core/Table/cells/DefaultCell.js +4 -9
  213. package/esm/core/Table/columns/actionColumn.js +1 -1
  214. package/esm/core/Table/columns/expanderColumn.js +1 -1
  215. package/esm/core/Table/filters/BaseFilter.js +1 -1
  216. package/esm/core/Table/filters/FilterToggle.js +1 -1
  217. package/esm/core/Table/hooks/useColumnDragAndDrop.js +4 -4
  218. package/esm/core/Table/hooks/useResizeColumns.js +110 -106
  219. package/esm/core/Tabs/Tab.d.ts +0 -8
  220. package/esm/core/Tabs/Tab.js +0 -4
  221. package/esm/core/Tabs/Tabs.js +9 -12
  222. package/esm/core/Tabs/index.d.ts +2 -2
  223. package/esm/core/Tabs/index.js +1 -1
  224. package/esm/core/Textarea/Textarea.d.ts +1 -1
  225. package/esm/core/Textarea/Textarea.js +2 -2
  226. package/esm/core/ThemeProvider/ThemeProvider.d.ts +27 -17
  227. package/esm/core/ThemeProvider/ThemeProvider.js +64 -6
  228. package/esm/core/Tile/Tile.d.ts +19 -1
  229. package/esm/core/Tile/Tile.js +36 -13
  230. package/esm/core/Toast/Toast.d.ts +3 -3
  231. package/esm/core/Toast/Toast.js +3 -3
  232. package/esm/core/Toast/ToastWrapper.d.ts +1 -1
  233. package/esm/core/Toast/ToastWrapper.js +1 -1
  234. package/esm/core/Tree/TreeNode.js +2 -8
  235. package/esm/core/index.d.ts +8 -8
  236. package/esm/core/index.js +4 -4
  237. package/esm/core/utils/components/Popover.d.ts +2 -2
  238. package/esm/core/utils/components/Popover.js +1 -1
  239. package/esm/core/utils/components/Resizer.d.ts +5 -0
  240. package/esm/core/utils/components/Resizer.js +7 -1
  241. package/esm/core/utils/components/VisuallyHidden.d.ts +1 -0
  242. package/esm/core/utils/components/VisuallyHidden.js +1 -0
  243. package/esm/core/utils/functions/colors.d.ts +1 -1
  244. package/esm/core/utils/functions/colors.js +1 -1
  245. package/esm/core/utils/hooks/index.d.ts +1 -0
  246. package/esm/core/utils/hooks/index.js +1 -0
  247. package/esm/core/utils/hooks/useIsomorphicLayoutEffect.d.ts +7 -0
  248. package/esm/core/utils/hooks/useIsomorphicLayoutEffect.js +11 -0
  249. package/esm/core/utils/hooks/useMediaQuery.js +2 -1
  250. package/esm/core/utils/hooks/useTheme.d.ts +20 -3
  251. package/esm/core/utils/hooks/useTheme.js +56 -57
  252. package/package.json +3 -2
  253. package/cjs/core/UserIcon/UserIcon.d.ts +0 -57
  254. package/cjs/core/UserIcon/index.d.ts +0 -4
  255. package/cjs/core/UserIconGroup/UserIconGroup.d.ts +0 -62
  256. package/cjs/core/UserIconGroup/index.d.ts +0 -4
  257. package/cjs/core/Wizard/Wizard.d.ts +0 -54
  258. package/cjs/core/Wizard/index.d.ts +0 -4
  259. package/esm/core/UserIcon/UserIcon.d.ts +0 -57
  260. package/esm/core/UserIcon/index.d.ts +0 -4
  261. package/esm/core/UserIconGroup/UserIconGroup.d.ts +0 -62
  262. package/esm/core/UserIconGroup/index.d.ts +0 -4
  263. package/esm/core/Wizard/Wizard.d.ts +0 -54
  264. package/esm/core/Wizard/index.d.ts +0 -4
@@ -1,9 +1,13 @@
1
1
  import '@itwin/itwinui-css/css/global.css';
2
+ import '@itwin/itwinui-variables/index.css';
2
3
  export declare type ThemeOptions = {
3
4
  /**
4
5
  * Document to which the theme will be applied.
5
6
  * Can be specified to handle popup windows.
6
7
  * @default document
8
+ *
9
+ * @deprecated This prop will continue to work in `useTheme` but
10
+ * we recommend rendering `ThemeProvider` in the correct document instead.
7
11
  */
8
12
  ownerDocument?: Document;
9
13
  /**
@@ -13,10 +17,23 @@ export declare type ThemeOptions = {
13
17
  highContrast?: boolean;
14
18
  };
15
19
  export declare type ThemeType = 'light' | 'dark' | 'os';
20
+ export declare type UseThemeProps = {
21
+ /**
22
+ * Theme to be applied. If not set, light theme will be used.
23
+ */
24
+ theme?: ThemeType;
25
+ /**
26
+ * Options that can be specified to override default theming behavior.
27
+ */
28
+ themeOptions?: ThemeOptions;
29
+ };
16
30
  /**
17
- * Hook that applies styling and theme to all components.
18
- * Defaults to light theme if none provided or set elsewhere.
31
+ * Hook that conditionally applies styling and theme to all components.
32
+ * Defaults to light theme if none provided.
33
+ *
34
+ * If ThemeProvider is used as an ancestor, this hook will not do anything.
35
+ *
19
36
  * @param theme Light, dark, or based on OS setting.
20
37
  * @param themeOptions Options that override default theming behavior.
21
38
  */
22
- export declare const useTheme: (theme?: ThemeType, themeOptions?: ThemeOptions) => void;
39
+ export declare const useTheme: (theme?: UseThemeProps['theme'], themeOptions?: UseThemeProps['themeOptions']) => void;
@@ -9,78 +9,77 @@ exports.useTheme = void 0;
9
9
  * See LICENSE.md in the project root for license terms and full copyright notice.
10
10
  *--------------------------------------------------------------------------------------------*/
11
11
  var react_1 = __importDefault(require("react"));
12
+ var ThemeProvider_1 = require("../../ThemeProvider/ThemeProvider");
13
+ var functions_1 = require("../functions");
14
+ var useIsomorphicLayoutEffect_1 = require("./useIsomorphicLayoutEffect");
12
15
  require("@itwin/itwinui-css/css/global.css");
13
- var dom_1 = require("../functions/dom");
14
- var useMediaQuery_1 = require("./useMediaQuery");
16
+ require("@itwin/itwinui-variables/index.css");
15
17
  /**
16
- * Hook that applies styling and theme to all components.
17
- * Defaults to light theme if none provided or set elsewhere.
18
+ * Hook that conditionally applies styling and theme to all components.
19
+ * Defaults to light theme if none provided.
20
+ *
21
+ * If ThemeProvider is used as an ancestor, this hook will not do anything.
22
+ *
18
23
  * @param theme Light, dark, or based on OS setting.
19
24
  * @param themeOptions Options that override default theming behavior.
20
25
  */
21
26
  var useTheme = function (theme, themeOptions) {
22
27
  var _a;
23
- var ownerDocument = (_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.ownerDocument) !== null && _a !== void 0 ? _a : (0, dom_1.getDocument)();
24
- var prefersHighContrast = (0, useMediaQuery_1.useMediaQuery)('(prefers-contrast: more)');
25
- var highContrast = react_1.default.useMemo(function () { var _a; return !!((_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast) !== null && _a !== void 0 ? _a : prefersHighContrast); }, [prefersHighContrast, themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast]);
26
- react_1.default.useLayoutEffect(function () {
27
- if (!(ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.classList.contains('iui-body'))) {
28
- ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.classList.add('iui-body');
29
- }
30
- }, [ownerDocument]);
31
- react_1.default.useLayoutEffect(function () {
32
- var _a, _b, _c, _d, _e;
33
- if (!ownerDocument) {
28
+ var themeContext = react_1.default.useContext(ThemeProvider_1.ThemeContext);
29
+ var ownerDocument = (_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.ownerDocument) !== null && _a !== void 0 ? _a : (0, functions_1.getDocument)();
30
+ (0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(function () {
31
+ // exit early if theme was already set by provider
32
+ if (themeContext || !ownerDocument) {
34
33
  return;
35
34
  }
36
- var prefersDarkMediaQuery = (_b = (_a = (0, dom_1.getWindow)()) === null || _a === void 0 ? void 0 : _a.matchMedia) === null || _b === void 0 ? void 0 : _b.call(_a, '(prefers-color-scheme: dark)');
37
- var addOSTheme = function (_a) {
38
- var isDark = _a.matches;
39
- if (isDark) {
40
- applyTheme('dark', { ownerDocument: ownerDocument, highContrast: highContrast });
41
- }
42
- else {
43
- applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
44
- }
45
- };
35
+ ownerDocument.body.classList.toggle('iui-root', true);
46
36
  switch (theme) {
47
37
  case 'light':
48
- (_c = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _c === void 0 ? void 0 : _c.call(prefersDarkMediaQuery, 'change', addOSTheme);
49
- applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
50
- break;
51
38
  case 'dark':
52
- (_d = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _d === void 0 ? void 0 : _d.call(prefersDarkMediaQuery, 'change', addOSTheme);
53
- applyTheme('dark', { ownerDocument: ownerDocument, highContrast: highContrast });
54
- break;
55
- case 'os':
56
- if (prefersDarkMediaQuery != undefined) {
57
- addOSTheme(prefersDarkMediaQuery);
58
- (_e = prefersDarkMediaQuery.addEventListener) === null || _e === void 0 ? void 0 : _e.call(prefersDarkMediaQuery, 'change', addOSTheme);
59
- }
60
- else {
61
- applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
62
- }
63
- break;
64
- default:
65
- if (ownerDocument.documentElement.className.indexOf('iui-theme') === -1) {
66
- applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
39
+ case 'os': {
40
+ return handleTheme(theme, ownerDocument, themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast);
41
+ }
42
+ default: {
43
+ // set light theme by default
44
+ if (ownerDocument.documentElement.dataset.iuiTheme == null) {
45
+ return handleTheme('light', ownerDocument, themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast);
67
46
  }
47
+ return;
48
+ }
68
49
  }
69
- return function () {
70
- var _a;
71
- (_a = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(prefersDarkMediaQuery, 'change', addOSTheme);
72
- };
73
- }, [highContrast, ownerDocument, theme]);
50
+ }, [theme, themeContext, themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast, ownerDocument]);
74
51
  };
75
52
  exports.useTheme = useTheme;
76
- var applyTheme = function (theme, _a) {
77
- var ownerDocument = _a.ownerDocument, highContrast = _a.highContrast;
78
- var classList = ownerDocument.documentElement.classList;
79
- var currentTheme = Array.from(classList).find(function (cls) {
80
- return cls.startsWith('iui-theme');
81
- });
82
- if (currentTheme) {
83
- classList.remove(currentTheme);
84
- }
85
- classList.add("iui-theme-".concat(theme).concat(highContrast ? '-hc' : ''));
53
+ /**
54
+ * Helper function to apply the specified theme, or detect the OS theme.
55
+ * Returns a cleanup function to remove the change handlers.
56
+ */
57
+ var handleTheme = function (theme, ownerDocument, highContrast) {
58
+ var _a, _b, _c, _d, _e;
59
+ var root = ownerDocument.documentElement;
60
+ var _window = (_a = ownerDocument.defaultView) !== null && _a !== void 0 ? _a : (0, functions_1.getWindow)();
61
+ var applyThemeAttributes = function (isDark, isHC) {
62
+ if (isDark === void 0) { isDark = false; }
63
+ if (isHC === void 0) { isHC = false; }
64
+ root.dataset.iuiTheme = isDark ? 'dark' : 'light';
65
+ root.dataset.iuiContrast = isHC ? 'high' : 'default';
66
+ };
67
+ var prefersDarkQuery = (_b = _window === null || _window === void 0 ? void 0 : _window.matchMedia) === null || _b === void 0 ? void 0 : _b.call(_window, '(prefers-color-scheme: dark)');
68
+ var prefersHCQuery = (_c = _window === null || _window === void 0 ? void 0 : _window.matchMedia) === null || _c === void 0 ? void 0 : _c.call(_window, '(prefers-contrast: more)');
69
+ var changeHandler = function () {
70
+ var isDark = theme === 'dark' || (theme === 'os' && (prefersDarkQuery === null || prefersDarkQuery === void 0 ? void 0 : prefersDarkQuery.matches));
71
+ var isHC = highContrast !== null && highContrast !== void 0 ? highContrast : prefersHCQuery === null || prefersHCQuery === void 0 ? void 0 : prefersHCQuery.matches;
72
+ applyThemeAttributes(isDark, isHC);
73
+ };
74
+ // call handler once to set initial theme
75
+ changeHandler();
76
+ // add listeners in supported browsers
77
+ (_d = prefersDarkQuery === null || prefersDarkQuery === void 0 ? void 0 : prefersDarkQuery.addEventListener) === null || _d === void 0 ? void 0 : _d.call(prefersDarkQuery, 'change', changeHandler);
78
+ (_e = prefersHCQuery === null || prefersHCQuery === void 0 ? void 0 : prefersHCQuery.addEventListener) === null || _e === void 0 ? void 0 : _e.call(prefersHCQuery, 'change', changeHandler);
79
+ // return cleanup function to remove event listeners (should be returned from useEffect)
80
+ return function () {
81
+ var _a, _b;
82
+ (_a = prefersDarkQuery === null || prefersDarkQuery === void 0 ? void 0 : prefersDarkQuery.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(prefersDarkQuery, 'change', changeHandler);
83
+ (_b = prefersHCQuery === null || prefersHCQuery === void 0 ? void 0 : prefersHCQuery.removeEventListener) === null || _b === void 0 ? void 0 : _b.call(prefersHCQuery, 'change', changeHandler);
84
+ };
86
85
  };
@@ -15,11 +15,6 @@ export declare type AlertProps = {
15
15
  * Props for the clickable text. Used for providing `href` and other attributes.
16
16
  */
17
17
  clickableTextProps?: React.ComponentPropsWithRef<'a'>;
18
- /**
19
- * Action handler for the clickable text.
20
- * @deprecated `clickableTextProps` should be used instead.
21
- */
22
- onClick?: () => void;
23
18
  /**
24
19
  * Action handler for close.
25
20
  */
@@ -41,7 +36,13 @@ export declare type AlertProps = {
41
36
  * <Alert type='positive'>This is a positive alert.</Alert>
42
37
  * <Alert type='warning'>This is a warning alert.</Alert>
43
38
  * <Alert type='negative'>This is a negative alert.</Alert>
44
- * <Alert type='positive' clickableText="I am a clickable text" onClick={()=>alert("Pressed")}>This is a positive alert with a clickable text</Alert>
39
+ * <Alert
40
+ * type='positive'
41
+ * clickableText="I am a clickable text"
42
+ * clickableTextProps={{ href: 'https://www.example.com' }}
43
+ * >
44
+ * This is a positive alert with a clickable text
45
+ * </Alert>
45
46
  */
46
47
  export declare const Alert: (props: AlertProps) => JSX.Element;
47
48
  export default Alert;
@@ -29,7 +29,6 @@ import cx from 'classnames';
29
29
  import React from 'react';
30
30
  import { useTheme, StatusIconMap } from '../utils';
31
31
  import '@itwin/itwinui-css/css/alert.css';
32
- import { IconButton } from '../Buttons/IconButton';
33
32
  /**
34
33
  * A small box to quickly grab user attention and communicate a brief message
35
34
  * @example
@@ -37,18 +36,24 @@ import { IconButton } from '../Buttons/IconButton';
37
36
  * <Alert type='positive'>This is a positive alert.</Alert>
38
37
  * <Alert type='warning'>This is a warning alert.</Alert>
39
38
  * <Alert type='negative'>This is a negative alert.</Alert>
40
- * <Alert type='positive' clickableText="I am a clickable text" onClick={()=>alert("Pressed")}>This is a positive alert with a clickable text</Alert>
39
+ * <Alert
40
+ * type='positive'
41
+ * clickableText="I am a clickable text"
42
+ * clickableTextProps={{ href: 'https://www.example.com' }}
43
+ * >
44
+ * This is a positive alert with a clickable text
45
+ * </Alert>
41
46
  */
42
47
  export var Alert = function (props) {
43
- var children = props.children, className = props.className, _a = props.type, type = _a === void 0 ? 'informational' : _a, clickableText = props.clickableText, clickableTextProps = props.clickableTextProps, onClick = props.onClick, onClose = props.onClose, style = props.style, _b = props.isSticky, isSticky = _b === void 0 ? false : _b, rest = __rest(props, ["children", "className", "type", "clickableText", "clickableTextProps", "onClick", "onClose", "style", "isSticky"]);
48
+ var children = props.children, className = props.className, _a = props.type, type = _a === void 0 ? 'informational' : _a, clickableText = props.clickableText, clickableTextProps = props.clickableTextProps, onClose = props.onClose, style = props.style, _b = props.isSticky, isSticky = _b === void 0 ? false : _b, rest = __rest(props, ["children", "className", "type", "clickableText", "clickableTextProps", "onClose", "style", "isSticky"]);
44
49
  useTheme();
45
50
  var StatusIcon = StatusIconMap[type];
46
- return (React.createElement("div", __assign({ className: cx('iui-alert', "iui-".concat(type), { 'iui-sticky': isSticky }, className), style: style }, rest),
51
+ return (React.createElement("div", __assign({ className: cx("iui-alert-".concat(type), { 'iui-sticky': isSticky }, className), style: style }, rest),
47
52
  React.createElement(StatusIcon, { className: 'iui-alert-icon' }),
48
53
  React.createElement("span", { className: 'iui-alert-message' },
49
54
  children,
50
- clickableText && (React.createElement("a", __assign({ onClick: onClick }, clickableTextProps, { className: cx('iui-alert-link', clickableTextProps === null || clickableTextProps === void 0 ? void 0 : clickableTextProps.className) }), clickableText))),
51
- onClose && (React.createElement(IconButton, { styleType: 'borderless', size: 'small', onClick: onClose, "aria-label": 'Close' },
52
- React.createElement(SvgCloseSmall, { "aria-hidden": true })))));
55
+ clickableText && (React.createElement("a", __assign({}, clickableTextProps, { className: cx('iui-alert-link', clickableTextProps === null || clickableTextProps === void 0 ? void 0 : clickableTextProps.className) }), clickableText))),
56
+ onClose && (React.createElement("button", { onClick: onClose, "aria-label": 'Close', type: 'button', className: 'iui-alert-button' },
57
+ React.createElement(SvgCloseSmall, { "aria-hidden": true, className: 'iui-alert-button-icon' })))));
53
58
  };
54
59
  export default Alert;
@@ -0,0 +1,69 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from '../utils';
3
+ import '@itwin/itwinui-css/css/avatar.css';
4
+ export declare type AvatarStatus = 'online' | 'busy' | 'away' | 'offline';
5
+ /**
6
+ * @deprecated Since v2, this has been renamed to `AvatarStatus` (Use with `Avatar`)
7
+ */
8
+ export declare type UserIconStatus = AvatarStatus;
9
+ export declare type StatusTitles = {
10
+ [key in Exclude<AvatarStatus, ''>]: string;
11
+ };
12
+ export declare type AvatarProps = {
13
+ /**
14
+ * Size of a avatar.
15
+ * @default 'small'
16
+ */
17
+ size?: 'small' | 'medium' | 'large' | 'x-large';
18
+ /**
19
+ * Status/Availability of a user.
20
+ */
21
+ status?: AvatarStatus;
22
+ /**
23
+ * Text which will appear when hovering over the icon.
24
+ */
25
+ title?: string;
26
+ /**
27
+ * Abbreviation to be displayed.
28
+ */
29
+ abbreviation?: string;
30
+ /**
31
+ * User image to be displayed. MUST be an <img> element!
32
+ */
33
+ image?: JSX.Element;
34
+ /**
35
+ * Color of the icon. You can use `getUserColor` function to generate color from user name or email.
36
+ * @default 'white'
37
+ */
38
+ backgroundColor?: string;
39
+ /**
40
+ * Translated status messages shown on hover.
41
+ */
42
+ translatedStatusTitles?: StatusTitles;
43
+ } & Omit<CommonProps, 'title'>;
44
+ /**
45
+ * @deprecated Since v2, this has been renamed to `AvatarProps` (Use with `Avatar`)
46
+ */
47
+ export declare type UserIconProps = AvatarProps;
48
+ export declare const defaultStatusTitles: StatusTitles;
49
+ /**
50
+ * Basic avatar component
51
+ * @example
52
+ * <caption>Small icon with abbreviation</caption>
53
+ * <Avatar size='small' title='Terry Rivers' abbreviation='TR' backgroundColor='green'/>
54
+ * @example
55
+ * <caption>Medium icon with image</caption>
56
+ * <Avatar size='medium' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
57
+ * @example
58
+ * <caption>Large icon with status</caption>
59
+ * <Avatar size='large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' status='online' />
60
+ * @example
61
+ * <caption>X-large icon with image</caption>
62
+ * <Avatar size='x-large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
63
+ */
64
+ export declare const Avatar: (props: AvatarProps) => JSX.Element;
65
+ /**
66
+ * @deprecated Since v2, this has been renamed to `Avatar`
67
+ */
68
+ export declare const UserIcon: (props: AvatarProps) => JSX.Element;
69
+ export default Avatar;
@@ -27,7 +27,7 @@ var __rest = (this && this.__rest) || function (s, e) {
27
27
  import cx from 'classnames';
28
28
  import React from 'react';
29
29
  import { useTheme } from '../utils';
30
- import '@itwin/itwinui-css/css/user-icon.css';
30
+ import '@itwin/itwinui-css/css/avatar.css';
31
31
  export var defaultStatusTitles = {
32
32
  away: 'Away',
33
33
  busy: 'Busy',
@@ -35,29 +35,33 @@ export var defaultStatusTitles = {
35
35
  online: 'Online',
36
36
  };
37
37
  /**
38
- * Basic user icon component
38
+ * Basic avatar component
39
39
  * @example
40
40
  * <caption>Small icon with abbreviation</caption>
41
- * <UserIcon size='small' title='Terry Rivers' abbreviation='TR' backgroundColor='green'/>
41
+ * <Avatar size='small' title='Terry Rivers' abbreviation='TR' backgroundColor='green'/>
42
42
  * @example
43
43
  * <caption>Medium icon with image</caption>
44
- * <UserIcon size='medium' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
44
+ * <Avatar size='medium' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
45
45
  * @example
46
46
  * <caption>Large icon with status</caption>
47
- * <UserIcon size='large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' status='online' />
47
+ * <Avatar size='large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' status='online' />
48
48
  * @example
49
49
  * <caption>X-large icon with image</caption>
50
- * <UserIcon size='x-large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
50
+ * <Avatar size='x-large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
51
51
  */
52
- export var UserIcon = function (props) {
52
+ export var Avatar = function (props) {
53
53
  var _a, _b;
54
54
  var _c = props.size, size = _c === void 0 ? 'small' : _c, status = props.status, abbreviation = props.abbreviation, image = props.image, _d = props.backgroundColor, backgroundColor = _d === void 0 ? 'white' : _d, title = props.title, translatedStatusTitles = props.translatedStatusTitles, className = props.className, style = props.style, rest = __rest(props, ["size", "status", "abbreviation", "image", "backgroundColor", "title", "translatedStatusTitles", "className", "style"]);
55
55
  useTheme();
56
56
  var statusTitles = __assign(__assign({}, defaultStatusTitles), translatedStatusTitles);
57
- return (React.createElement("span", __assign({ className: cx('iui-user-icon', (_a = {}, _a["iui-".concat(size)] = size !== 'medium', _a), className), title: title, style: style }, rest), image !== null && image !== void 0 ? image : (React.createElement("abbr", { className: 'iui-initials', style: { backgroundColor: backgroundColor } }, abbreviation === null || abbreviation === void 0 ? void 0 : abbreviation.substring(0, 2))),
57
+ return (React.createElement("span", __assign({ className: cx('iui-avatar', (_a = {}, _a["iui-".concat(size)] = size !== 'medium', _a), className), title: title, style: style }, rest), image !== null && image !== void 0 ? image : (React.createElement("abbr", { className: 'iui-initials', style: { backgroundColor: backgroundColor } }, abbreviation === null || abbreviation === void 0 ? void 0 : abbreviation.substring(0, 2))),
58
58
  React.createElement("span", { className: 'iui-stroke' }),
59
59
  status && (React.createElement("span", { title: statusTitles[status], className: cx('iui-status', (_b = {},
60
60
  _b["iui-".concat(status)] = !!status,
61
61
  _b)), "aria-label": statusTitles[status] }))));
62
62
  };
63
- export default UserIcon;
63
+ /**
64
+ * @deprecated Since v2, this has been renamed to `Avatar`
65
+ */
66
+ export var UserIcon = Avatar;
67
+ export default Avatar;
@@ -0,0 +1,4 @@
1
+ export { Avatar, UserIcon } from './Avatar';
2
+ export type { AvatarProps, StatusTitles, AvatarStatus, UserIconProps, UserIconStatus, } from './Avatar';
3
+ declare const _default: "./Avatar";
4
+ export default _default;
@@ -2,5 +2,5 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- export { UserIcon } from './UserIcon';
6
- export default './UserIcon';
5
+ export { Avatar, UserIcon } from './Avatar';
6
+ export default './Avatar';
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import { CommonProps } from '../utils';
3
+ import '@itwin/itwinui-css/css/avatar.css';
4
+ export declare type AvatarGroupProps = {
5
+ /**
6
+ * Max number of avatars unstacked.
7
+ * @default 5
8
+ */
9
+ maxIcons?: number;
10
+ /**
11
+ * If true, group will be stacked to take less space.
12
+ * @default true
13
+ */
14
+ stacked?: boolean;
15
+ /**
16
+ * If true, group will be animated on hover.
17
+ * @default false
18
+ */
19
+ animated?: boolean;
20
+ /**
21
+ * Size of avatars and count avatars.
22
+ * @default 'small'
23
+ */
24
+ iconSize?: 'small' | 'medium' | 'large' | 'x-large';
25
+ /**
26
+ * Avatars in the group.
27
+ */
28
+ children: React.ReactNode;
29
+ /**
30
+ * Count Avatar props.
31
+ */
32
+ countIconProps?: React.ComponentPropsWithRef<'div'>;
33
+ } & Omit<CommonProps, 'title'>;
34
+ /**
35
+ * @deprecated Since v2, this has been renamed to `AvatarGroupProps` (Use with `AvatarGroup`)
36
+ */
37
+ export declare type UserIconGroupProps = AvatarGroupProps;
38
+ /**
39
+ * Group Avatars together.
40
+ *
41
+ * Avatars stacking is based on `maxAvatars` count. If you provide 8 Avatars and keep default 5 `maxAvatars` count,
42
+ * this component will show 5 Avatars and Count Avatar with "3" in it.
43
+ *
44
+ * You can add custom Count Avatar behavior by using `countAvatarProps`.
45
+ *
46
+ * @example
47
+ * <AvatarGroup avatarSize='medium'>
48
+ * <Avatar
49
+ * abbreviation="TR"
50
+ * backgroundColor={getUserColor("Terry Rivers")}
51
+ * title="Terry Rivers"
52
+ * />
53
+ * <Avatar
54
+ * abbreviation="RM"
55
+ * backgroundColor={getUserColor("Robin Mercer")}
56
+ * title="Robin Mercer"
57
+ * />
58
+ * <Avatar
59
+ * abbreviation="JM"
60
+ * backgroundColor={getUserColor("Jean Mullins")}
61
+ * title="Jean Mullins"
62
+ * />
63
+ * </AvatarGroup>
64
+ */
65
+ export declare const AvatarGroup: (props: AvatarGroupProps) => JSX.Element;
66
+ /**
67
+ * @deprecated Since v2, this has been renamed to `AvatarGroup`
68
+ */
69
+ export declare const UserIconGroup: (props: AvatarGroupProps) => JSX.Element;
70
+ export default AvatarGroup;
@@ -27,42 +27,42 @@ var __rest = (this && this.__rest) || function (s, e) {
27
27
  import React from 'react';
28
28
  import cx from 'classnames';
29
29
  import { useTheme } from '../utils';
30
- import '@itwin/itwinui-css/css/user-icon.css';
30
+ import '@itwin/itwinui-css/css/avatar.css';
31
31
  /**
32
- * Group User Icons together.
32
+ * Group Avatars together.
33
33
  *
34
- * User Icons stacking is based on `maxIcons` count. If you provide 8 User Icons and keep default 5 `maxIcons` count,
35
- * this component will show 5 User Icons and User Count Icon with "3" in it.
34
+ * Avatars stacking is based on `maxAvatars` count. If you provide 8 Avatars and keep default 5 `maxAvatars` count,
35
+ * this component will show 5 Avatars and Count Avatar with "3" in it.
36
36
  *
37
- * You can add custom User Count Icon behavior by using `countIconProps`.
37
+ * You can add custom Count Avatar behavior by using `countAvatarProps`.
38
38
  *
39
39
  * @example
40
- * <UserIconGroup iconSize='medium'>
41
- * <UserIcon
40
+ * <AvatarGroup avatarSize='medium'>
41
+ * <Avatar
42
42
  * abbreviation="TR"
43
43
  * backgroundColor={getUserColor("Terry Rivers")}
44
44
  * title="Terry Rivers"
45
45
  * />
46
- * <UserIcon
46
+ * <Avatar
47
47
  * abbreviation="RM"
48
48
  * backgroundColor={getUserColor("Robin Mercer")}
49
49
  * title="Robin Mercer"
50
50
  * />
51
- * <UserIcon
51
+ * <Avatar
52
52
  * abbreviation="JM"
53
53
  * backgroundColor={getUserColor("Jean Mullins")}
54
54
  * title="Jean Mullins"
55
55
  * />
56
- * </UserIconGroup>
56
+ * </AvatarGroup>
57
57
  */
58
- export var UserIconGroup = function (props) {
58
+ export var AvatarGroup = function (props) {
59
59
  var _a;
60
60
  var maxLength = 99;
61
61
  var children = props.children, _b = props.animated, animated = _b === void 0 ? false : _b, _c = props.stacked, stacked = _c === void 0 ? true : _c, _d = props.maxIcons, maxIcons = _d === void 0 ? 5 : _d, _e = props.iconSize, iconSize = _e === void 0 ? 'small' : _e, countIconProps = props.countIconProps, className = props.className, rest = __rest(props, ["children", "animated", "stacked", "maxIcons", "iconSize", "countIconProps", "className"]);
62
62
  var childrenArray = React.Children.toArray(children);
63
63
  var childrenLength = childrenArray.length;
64
64
  useTheme();
65
- var getUserIconList = function (count) {
65
+ var getAvatarList = function (count) {
66
66
  return childrenArray.slice(0, count).map(function (child) {
67
67
  return React.cloneElement(child, {
68
68
  status: undefined,
@@ -71,17 +71,21 @@ export var UserIconGroup = function (props) {
71
71
  });
72
72
  };
73
73
  return (React.createElement(React.Fragment, null,
74
- React.createElement("div", __assign({ className: cx('iui-user-icon-list', {
74
+ React.createElement("div", __assign({ className: cx('iui-avatar-list', {
75
75
  'iui-animated': animated,
76
76
  'iui-stacked': stacked,
77
77
  }, className) }, rest),
78
- childrenArray.length <= maxIcons + 1 && getUserIconList(maxIcons + 1),
78
+ childrenArray.length <= maxIcons + 1 && getAvatarList(maxIcons + 1),
79
79
  childrenArray.length > maxIcons + 1 && (React.createElement(React.Fragment, null,
80
- getUserIconList(maxIcons),
81
- React.createElement("div", __assign({}, countIconProps, { className: cx('iui-user-icon', (_a = {}, _a["iui-".concat(iconSize)] = iconSize !== 'medium', _a), 'iui-user-icon-count', countIconProps === null || countIconProps === void 0 ? void 0 : countIconProps.className) }),
80
+ getAvatarList(maxIcons),
81
+ React.createElement("div", __assign({}, countIconProps, { className: cx('iui-avatar', (_a = {}, _a["iui-".concat(iconSize)] = iconSize !== 'medium', _a), 'iui-avatar-count', countIconProps === null || countIconProps === void 0 ? void 0 : countIconProps.className) }),
82
82
  React.createElement("abbr", { className: 'iui-initials' }, childrenLength <= maxLength
83
83
  ? "".concat(childrenLength - maxIcons)
84
84
  : "".concat(maxLength, "+")),
85
85
  React.createElement("span", { className: 'iui-stroke' })))))));
86
86
  };
87
- export default UserIconGroup;
87
+ /**
88
+ * @deprecated Since v2, this has been renamed to `AvatarGroup`
89
+ */
90
+ export var UserIconGroup = AvatarGroup;
91
+ export default AvatarGroup;
@@ -0,0 +1,4 @@
1
+ export { AvatarGroup, UserIconGroup } from './AvatarGroup';
2
+ export type { AvatarGroupProps, UserIconGroupProps } from './AvatarGroup';
3
+ declare const _default: "./AvatarGroup";
4
+ export default _default;
@@ -2,5 +2,5 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- export { UserIconGroup } from './UserIconGroup';
6
- export default './UserIconGroup';
5
+ export { AvatarGroup, UserIconGroup } from './AvatarGroup';
6
+ export default './AvatarGroup';
@@ -26,7 +26,7 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  *--------------------------------------------------------------------------------------------*/
27
27
  import React from 'react';
28
28
  import cx from 'classnames';
29
- import { useTheme, getWindow, isSoftBackground, SoftBackgrounds, } from '../utils';
29
+ import { useTheme, isSoftBackground, SoftBackgrounds, } from '../utils';
30
30
  import '@itwin/itwinui-css/css/badge.css';
31
31
  /**
32
32
  * Helper function that returns one of the preset badge color values.
@@ -56,12 +56,10 @@ var getBadgeColorValue = function (color) {
56
56
  * <Badge backgroundColor="positive">Label</Badge>
57
57
  */
58
58
  export var Badge = function (props) {
59
- var _a, _b, _c;
60
59
  var backgroundColor = props.backgroundColor, style = props.style, className = props.className, children = props.children, rest = __rest(props, ["backgroundColor", "style", "className", "children"]);
61
60
  useTheme();
62
- var _style = backgroundColor &&
63
- ((_c = (_b = (_a = 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, "--iui-badge-background-color: ".concat(backgroundColor)))
64
- ? __assign({ '--iui-badge-background-color': getBadgeColorValue(backgroundColor) }, style) : __assign({ backgroundColor: getBadgeColorValue(backgroundColor) }, style);
61
+ var _style = backgroundColor
62
+ ? __assign({ '--iui-badge-background-color': getBadgeColorValue(backgroundColor) }, style) : __assign({}, style);
65
63
  return (React.createElement("span", __assign({ className: cx('iui-badge', className), style: _style }, rest), children));
66
64
  };
67
65
  export default Badge;
@@ -54,5 +54,5 @@ export declare type ButtonGroupProps = {
54
54
  * {buttons}
55
55
  * </ButtonGroup>
56
56
  */
57
- export declare const ButtonGroup: React.ForwardRefExoticComponent<Pick<ButtonGroupProps, "orientation" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "overflowButton" | "overflowPlacement"> & React.RefAttributes<HTMLDivElement>>;
57
+ export declare const ButtonGroup: React.ForwardRefExoticComponent<Pick<ButtonGroupProps, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "orientation" | "overflowButton" | "overflowPlacement"> & React.RefAttributes<HTMLDivElement>>;
58
58
  export default ButtonGroup;
@@ -38,20 +38,11 @@ import '@itwin/itwinui-css/css/button.css';
38
38
  * <Button startIcon={<SvgAdd />}>New</Button>
39
39
  */
40
40
  export var Button = React.forwardRef(function (props, ref) {
41
- var _a;
42
- var children = props.children, className = props.className, size = props.size, style = props.style, _b = props.styleType, styleType = _b === void 0 ? 'default' : _b, _c = props.type, type = _c === void 0 ? 'button' : _c, startIcon = props.startIcon, endIcon = props.endIcon, _d = props.as, Element = _d === void 0 ? 'button' : _d, rest = __rest(props, ["children", "className", "size", "style", "styleType", "type", "startIcon", "endIcon", "as"]);
41
+ var children = props.children, className = props.className, size = props.size, style = props.style, _a = props.styleType, styleType = _a === void 0 ? 'default' : _a, _b = props.type, type = _b === void 0 ? 'button' : _b, startIcon = props.startIcon, endIcon = props.endIcon, _c = props.as, Element = _c === void 0 ? 'button' : _c, rest = __rest(props, ["children", "className", "size", "style", "styleType", "type", "startIcon", "endIcon", "as"]);
43
42
  useTheme();
44
- return (React.createElement(Element, __assign({ ref: ref, className: cx('iui-button', "iui-".concat(styleType), (_a = {},
45
- _a["iui-".concat(size)] = !!size,
46
- _a), className), style: style, type: type }, rest),
47
- startIcon &&
48
- React.cloneElement(startIcon, {
49
- className: cx('iui-button-icon', startIcon.props.className),
50
- }),
51
- children && React.createElement("span", { className: 'iui-button-label' }, children),
52
- endIcon &&
53
- React.cloneElement(endIcon, {
54
- className: cx('iui-button-icon', endIcon.props.className),
55
- })));
43
+ return (React.createElement(Element, __assign({ ref: ref, className: cx('iui-button', className), "data-iui-variant": styleType !== 'default' ? styleType : undefined, "data-iui-size": size, style: style, type: type }, rest),
44
+ startIcon && (React.createElement("span", { className: 'iui-button-icon', "aria-hidden": true }, startIcon)),
45
+ children && React.createElement("span", null, children),
46
+ endIcon && (React.createElement("span", { className: 'iui-button-icon', "aria-hidden": true }, endIcon))));
56
47
  });
57
48
  export default Button;
@@ -54,6 +54,6 @@ export var DropdownButton = React.forwardRef(function (props, ref) {
54
54
  }
55
55
  }, [children, size, styleType]);
56
56
  return (React.createElement(DropdownMenu, { menuItems: menuItems, style: { minWidth: menuWidth }, onShow: function () { return setIsMenuOpen(true); }, onHide: function () { return setIsMenuOpen(false); } },
57
- React.createElement(Button, __assign({ className: cx('iui-dropdown', className), size: size, styleType: styleType, endIcon: isMenuOpen ? (React.createElement(SvgCaretUpSmall, { "aria-hidden": true })) : (React.createElement(SvgCaretDownSmall, { "aria-hidden": true })), ref: refs, "aria-label": 'Dropdown' }, rest), children)));
57
+ React.createElement(Button, __assign({ className: cx('iui-button-dropdown', className), size: size, styleType: styleType, endIcon: isMenuOpen ? (React.createElement(SvgCaretUpSmall, { "aria-hidden": true })) : (React.createElement(SvgCaretDownSmall, { "aria-hidden": true })), ref: refs, "aria-label": 'Dropdown' }, rest), children)));
58
58
  });
59
59
  export default DropdownButton;