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

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 (145) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/cjs/core/Avatar/Avatar.d.ts +3 -2
  3. package/cjs/core/Avatar/Avatar.js +21 -19
  4. package/cjs/core/AvatarGroup/AvatarGroup.js +3 -8
  5. package/cjs/core/Buttons/Button/Button.d.ts +15 -2
  6. package/cjs/core/Buttons/Button/Button.js +23 -9
  7. package/cjs/core/Buttons/DropdownButton/DropdownButton.js +1 -1
  8. package/cjs/core/Buttons/IconButton/IconButton.d.ts +5 -1
  9. package/cjs/core/Buttons/IconButton/IconButton.js +11 -5
  10. package/cjs/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
  11. package/cjs/core/Buttons/SplitButton/SplitButton.js +22 -13
  12. package/cjs/core/Carousel/Carousel.d.ts +6 -4
  13. package/cjs/core/Carousel/Carousel.js +2 -2
  14. package/cjs/core/Carousel/CarouselDot.js +1 -3
  15. package/cjs/core/Carousel/CarouselNavigation.d.ts +6 -4
  16. package/cjs/core/ColorPicker/ColorBuilder.js +2 -1
  17. package/cjs/core/ComboBox/ComboBoxInput.js +1 -1
  18. package/cjs/core/ComboBox/ComboBoxMenu.js +5 -5
  19. package/cjs/core/DatePicker/DatePicker.js +7 -1
  20. package/cjs/core/Dialog/Dialog.js +1 -2
  21. package/cjs/core/Dialog/DialogMain.js +5 -5
  22. package/cjs/core/ExpandableBlock/ExpandableBlock.js +1 -3
  23. package/cjs/core/FileUpload/FileUpload.d.ts +4 -0
  24. package/cjs/core/FileUpload/FileUpload.js +24 -3
  25. package/cjs/core/Header/HeaderBasicButton.js +3 -16
  26. package/cjs/core/Header/HeaderDropdownButton.js +1 -1
  27. package/cjs/core/Header/HeaderSplitButton.js +2 -4
  28. package/cjs/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
  29. package/cjs/core/ProgressIndicators/ProgressLinear.js +9 -1
  30. package/cjs/core/Select/Select.js +2 -2
  31. package/cjs/core/SideNavigation/SideNavigation.d.ts +16 -0
  32. package/cjs/core/SideNavigation/SideNavigation.js +40 -9
  33. package/cjs/core/Slider/Slider.d.ts +24 -0
  34. package/cjs/core/Slider/Slider.js +58 -10
  35. package/cjs/core/Slider/Thumb.js +2 -2
  36. package/cjs/core/Slider/Track.d.ts +1 -1
  37. package/cjs/core/Slider/Track.js +17 -6
  38. package/cjs/core/Stepper/Stepper.d.ts +26 -1
  39. package/cjs/core/Stepper/Stepper.js +35 -6
  40. package/cjs/core/Stepper/StepperStep.d.ts +17 -0
  41. package/cjs/core/Stepper/StepperStep.js +33 -8
  42. package/cjs/core/Stepper/WorkflowDiagram.d.ts +11 -1
  43. package/cjs/core/Stepper/WorkflowDiagram.js +23 -10
  44. package/cjs/core/Stepper/WorkflowDiagramStep.d.ts +6 -1
  45. package/cjs/core/Stepper/WorkflowDiagramStep.js +9 -2
  46. package/cjs/core/Table/SubRowExpander.js +1 -1
  47. package/cjs/core/Table/Table.js +0 -1
  48. package/cjs/core/Table/TableCell.js +1 -1
  49. package/cjs/core/Table/TablePaginator.js +1 -3
  50. package/cjs/core/Tabs/Tab.js +1 -2
  51. package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
  52. package/cjs/core/ThemeProvider/ThemeProvider.d.ts +23 -3
  53. package/cjs/core/ThemeProvider/ThemeProvider.js +56 -23
  54. package/cjs/core/Tile/Tile.d.ts +3 -2
  55. package/cjs/core/Toast/Toast.js +4 -9
  56. package/cjs/core/Tooltip/Tooltip.d.ts +1 -1
  57. package/cjs/core/Tooltip/Tooltip.js +1 -2
  58. package/cjs/core/Tree/TreeNode.js +1 -1
  59. package/cjs/core/utils/components/ButtonBase.d.ts +14 -0
  60. package/cjs/core/utils/components/ButtonBase.js +46 -0
  61. package/cjs/core/utils/components/Popover.js +5 -3
  62. package/cjs/core/utils/components/VirtualScroll.js +4 -4
  63. package/cjs/core/utils/components/index.d.ts +1 -0
  64. package/cjs/core/utils/components/index.js +1 -0
  65. package/cjs/core/utils/functions/colors.d.ts +1 -1
  66. package/cjs/core/utils/functions/colors.js +1 -13
  67. package/cjs/core/utils/hooks/index.d.ts +1 -0
  68. package/cjs/core/utils/hooks/index.js +1 -0
  69. package/cjs/core/utils/hooks/useGlobals.d.ts +1 -1
  70. package/cjs/core/utils/hooks/useUncontrolledState.d.ts +6 -0
  71. package/cjs/core/utils/hooks/useUncontrolledState.js +18 -0
  72. package/cjs/styles.js +3 -9
  73. package/esm/core/Avatar/Avatar.d.ts +3 -2
  74. package/esm/core/Avatar/Avatar.js +21 -17
  75. package/esm/core/AvatarGroup/AvatarGroup.js +3 -8
  76. package/esm/core/Buttons/Button/Button.d.ts +15 -2
  77. package/esm/core/Buttons/Button/Button.js +18 -10
  78. package/esm/core/Buttons/DropdownButton/DropdownButton.js +1 -1
  79. package/esm/core/Buttons/IconButton/IconButton.d.ts +5 -1
  80. package/esm/core/Buttons/IconButton/IconButton.js +9 -6
  81. package/esm/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
  82. package/esm/core/Buttons/SplitButton/SplitButton.js +22 -13
  83. package/esm/core/Carousel/Carousel.d.ts +6 -4
  84. package/esm/core/Carousel/Carousel.js +8 -3
  85. package/esm/core/Carousel/CarouselDot.js +2 -4
  86. package/esm/core/Carousel/CarouselNavigation.d.ts +6 -4
  87. package/esm/core/ColorPicker/ColorBuilder.js +2 -1
  88. package/esm/core/ComboBox/ComboBoxInput.js +1 -1
  89. package/esm/core/ComboBox/ComboBoxMenu.js +5 -5
  90. package/esm/core/DatePicker/DatePicker.js +8 -1
  91. package/esm/core/Dialog/Dialog.js +1 -1
  92. package/esm/core/Dialog/DialogMain.js +5 -5
  93. package/esm/core/ExpandableBlock/ExpandableBlock.js +2 -3
  94. package/esm/core/FileUpload/FileUpload.d.ts +4 -0
  95. package/esm/core/FileUpload/FileUpload.js +26 -3
  96. package/esm/core/Header/HeaderBasicButton.js +4 -17
  97. package/esm/core/Header/HeaderDropdownButton.js +1 -1
  98. package/esm/core/Header/HeaderSplitButton.js +8 -5
  99. package/esm/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
  100. package/esm/core/ProgressIndicators/ProgressLinear.js +9 -1
  101. package/esm/core/Select/Select.js +2 -2
  102. package/esm/core/SideNavigation/SideNavigation.d.ts +16 -0
  103. package/esm/core/SideNavigation/SideNavigation.js +31 -9
  104. package/esm/core/Slider/Slider.d.ts +24 -0
  105. package/esm/core/Slider/Slider.js +43 -10
  106. package/esm/core/Slider/Thumb.js +2 -2
  107. package/esm/core/Slider/Track.d.ts +1 -1
  108. package/esm/core/Slider/Track.js +14 -6
  109. package/esm/core/Stepper/Stepper.d.ts +26 -1
  110. package/esm/core/Stepper/Stepper.js +32 -6
  111. package/esm/core/Stepper/StepperStep.d.ts +17 -0
  112. package/esm/core/Stepper/StepperStep.js +27 -8
  113. package/esm/core/Stepper/WorkflowDiagram.d.ts +11 -1
  114. package/esm/core/Stepper/WorkflowDiagram.js +10 -7
  115. package/esm/core/Stepper/WorkflowDiagramStep.d.ts +6 -1
  116. package/esm/core/Stepper/WorkflowDiagramStep.js +6 -2
  117. package/esm/core/Table/SubRowExpander.js +1 -1
  118. package/esm/core/Table/Table.js +0 -1
  119. package/esm/core/Table/TableCell.js +1 -1
  120. package/esm/core/Table/TablePaginator.js +2 -3
  121. package/esm/core/Tabs/Tab.js +2 -3
  122. package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
  123. package/esm/core/ThemeProvider/ThemeProvider.d.ts +23 -3
  124. package/esm/core/ThemeProvider/ThemeProvider.js +64 -24
  125. package/esm/core/Tile/Tile.d.ts +3 -2
  126. package/esm/core/Toast/Toast.js +5 -9
  127. package/esm/core/Tooltip/Tooltip.d.ts +1 -1
  128. package/esm/core/Tooltip/Tooltip.js +1 -1
  129. package/esm/core/Tree/TreeNode.js +1 -1
  130. package/esm/core/utils/components/ButtonBase.d.ts +14 -0
  131. package/esm/core/utils/components/ButtonBase.js +42 -0
  132. package/esm/core/utils/components/Popover.js +5 -3
  133. package/esm/core/utils/components/VirtualScroll.js +4 -4
  134. package/esm/core/utils/components/index.d.ts +1 -0
  135. package/esm/core/utils/components/index.js +1 -0
  136. package/esm/core/utils/functions/colors.d.ts +1 -1
  137. package/esm/core/utils/functions/colors.js +1 -13
  138. package/esm/core/utils/hooks/index.d.ts +1 -0
  139. package/esm/core/utils/hooks/index.js +1 -0
  140. package/esm/core/utils/hooks/useGlobals.d.ts +1 -1
  141. package/esm/core/utils/hooks/useUncontrolledState.d.ts +6 -0
  142. package/esm/core/utils/hooks/useUncontrolledState.js +13 -0
  143. package/esm/styles.js +3 -9
  144. package/package.json +2 -2
  145. package/styles.css +37 -37
@@ -21,6 +21,10 @@ exports.StepperStep = React.forwardRef((props, forwardedRef) => {
21
21
  description,
22
22
  className,
23
23
  style,
24
+ stepProps,
25
+ trackContentProps,
26
+ circleProps,
27
+ nameProps,
24
28
  ...rest
25
29
  } = props;
26
30
  const isPast = currentStepNumber > index;
@@ -46,17 +50,17 @@ exports.StepperStep = React.forwardRef((props, forwardedRef) => {
46
50
  index_js_2.Box,
47
51
  {
48
52
  as: 'li',
53
+ ...stepProps,
49
54
  className: (0, classnames_1.default)(
50
55
  'iui-stepper-step',
51
- {
52
- 'iui-current': isActive,
53
- 'iui-clickable': isClickable,
54
- },
56
+ { 'iui-current': isActive, 'iui-clickable': isClickable },
55
57
  className,
58
+ stepProps?.className,
56
59
  ),
57
60
  style: {
58
- width: type === 'default' ? `${100 / totalSteps}%` : undefined,
61
+ inlineSize: type === 'default' ? `${100 / totalSteps}%` : undefined,
59
62
  ...style,
63
+ ...stepProps?.style,
60
64
  },
61
65
  onClick: onCompletedClick,
62
66
  onKeyDown: onKeyDown,
@@ -67,17 +71,38 @@ exports.StepperStep = React.forwardRef((props, forwardedRef) => {
67
71
  },
68
72
  React.createElement(
69
73
  index_js_2.Box,
70
- { className: 'iui-stepper-track-content' },
74
+ {
75
+ as: 'div',
76
+ ...trackContentProps,
77
+ className: (0, classnames_1.default)(
78
+ 'iui-stepper-track-content',
79
+ trackContentProps?.className,
80
+ ),
81
+ },
71
82
  React.createElement(
72
83
  index_js_2.Box,
73
- { as: 'span', className: 'iui-stepper-circle' },
84
+ {
85
+ as: 'span',
86
+ ...circleProps,
87
+ className: (0, classnames_1.default)(
88
+ 'iui-stepper-circle',
89
+ circleProps?.className,
90
+ ),
91
+ },
74
92
  index + 1,
75
93
  ),
76
94
  ),
77
95
  type === 'default' &&
78
96
  React.createElement(
79
97
  index_js_2.Box,
80
- { as: 'span', className: 'iui-stepper-step-name' },
98
+ {
99
+ as: 'span',
100
+ ...nameProps,
101
+ className: (0, classnames_1.default)(
102
+ 'iui-stepper-step-name',
103
+ nameProps?.className,
104
+ ),
105
+ },
81
106
  title,
82
107
  ),
83
108
  );
@@ -1,5 +1,15 @@
1
+ import * as React from 'react';
1
2
  import type { PolymorphicForwardRefComponent } from '../utils/index.js';
2
3
  import type { StepperProps } from './Stepper.js';
3
- type WorkflowDiagramProps = Pick<StepperProps, 'steps'>;
4
+ type WorkflowDiagramProps = Pick<StepperProps, 'steps'> & {
5
+ /**
6
+ * Allows props to be passed for diagram.
7
+ */
8
+ contentProps?: (index: number) => React.ComponentProps<'span'>;
9
+ /**
10
+ * Allows props to be passed for diagram wrapper.
11
+ */
12
+ wrapperProps?: React.ComponentProps<'div'>;
13
+ };
4
14
  export declare const WorkflowDiagram: PolymorphicForwardRefComponent<"ol", WorkflowDiagramProps>;
5
15
  export default WorkflowDiagram;
@@ -7,25 +7,38 @@ const tslib_1 = require('tslib');
7
7
  * See LICENSE.md in the project root for license terms and full copyright notice.
8
8
  *--------------------------------------------------------------------------------------------*/
9
9
  const React = tslib_1.__importStar(require('react'));
10
+ const classnames_1 = tslib_1.__importDefault(require('classnames'));
10
11
  const index_js_1 = require('../utils/index.js');
11
12
  const WorkflowDiagramStep_js_1 = require('./WorkflowDiagramStep.js');
12
13
  exports.WorkflowDiagram = React.forwardRef(
13
14
  // TODO: Remove this ref cast. ref and rest props should be applied on the same element
14
15
  (props, ref) => {
15
- const { steps, ...rest } = props;
16
+ const { steps, className, contentProps, wrapperProps, ...rest } = props;
16
17
  return React.createElement(
17
18
  index_js_1.Box,
18
- { ref: ref },
19
+ { as: 'div', ...wrapperProps, ref: ref },
19
20
  React.createElement(
20
21
  index_js_1.Box,
21
- { as: 'ol', className: 'iui-workflow-diagram', ...rest },
22
- steps.map((s, index) =>
23
- React.createElement(WorkflowDiagramStep_js_1.WorkflowDiagramStep, {
24
- key: index,
25
- title: s.name,
26
- description: s.description,
27
- }),
28
- ),
22
+ {
23
+ as: 'ol',
24
+ className: (0, classnames_1.default)(
25
+ 'iui-workflow-diagram',
26
+ className,
27
+ ),
28
+ ...rest,
29
+ },
30
+ steps.map((s, index) => {
31
+ const thisContentProps = contentProps?.(index);
32
+ return React.createElement(
33
+ WorkflowDiagramStep_js_1.WorkflowDiagramStep,
34
+ {
35
+ contentProps: thisContentProps,
36
+ key: index,
37
+ title: s.name,
38
+ description: s.description,
39
+ },
40
+ );
41
+ }),
29
42
  ),
30
43
  );
31
44
  },
@@ -1,5 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { type CommonProps } from '../utils/index.js';
3
3
  import type { StepperStepProps } from './StepperStep.js';
4
- export type WorkflowDiagramStepProps = Pick<StepperStepProps, 'title' | 'description'> & Omit<CommonProps, 'title'>;
4
+ export type WorkflowDiagramStepProps = {
5
+ /**
6
+ * Allows props to be passed for diagram content.
7
+ */
8
+ contentProps?: React.ComponentProps<'span'>;
9
+ } & Pick<StepperStepProps, 'title' | 'description'> & Omit<CommonProps, 'title'>;
5
10
  export declare const WorkflowDiagramStep: (props: WorkflowDiagramStepProps) => React.JSX.Element;
@@ -11,7 +11,7 @@ const React = tslib_1.__importStar(require('react'));
11
11
  const index_js_1 = require('../Tooltip/index.js');
12
12
  const index_js_2 = require('../utils/index.js');
13
13
  const WorkflowDiagramStep = (props) => {
14
- const { title, description, className, style, ...rest } = props;
14
+ const { title, description, className, style, contentProps, ...rest } = props;
15
15
  const stepShape = React.createElement(
16
16
  index_js_2.Box,
17
17
  {
@@ -25,7 +25,14 @@ const WorkflowDiagramStep = (props) => {
25
25
  },
26
26
  React.createElement(
27
27
  index_js_2.Box,
28
- { as: 'span', className: 'iui-workflow-diagram-content' },
28
+ {
29
+ as: 'span',
30
+ ...contentProps,
31
+ className: (0, classnames_1.default)(
32
+ 'iui-workflow-diagram-content',
33
+ contentProps?.className,
34
+ ),
35
+ },
29
36
  title,
30
37
  ),
31
38
  );
@@ -20,7 +20,7 @@ const SubRowExpander = (props) => {
20
20
  index_js_2.IconButton,
21
21
  {
22
22
  style: {
23
- marginRight:
23
+ marginInlineEnd:
24
24
  density === 'default' || density === undefined ? 8 : 4,
25
25
  },
26
26
  className: 'iui-table-row-expander',
@@ -792,7 +792,6 @@ const Table = (props) => {
792
792
  React.createElement(index_js_1.ProgressRadial, {
793
793
  indeterminate: true,
794
794
  size: 'small',
795
- style: { float: 'none', marginLeft: 0 },
796
795
  }),
797
796
  ),
798
797
  ),
@@ -45,7 +45,7 @@ const TableCell = (props) => {
45
45
  }
46
46
  const multiplier = 26 + expanderMargin; // 26 = expander width
47
47
  return {
48
- paddingLeft: cellPadding + dynamicMargin * multiplier,
48
+ paddingInlineStart: cellPadding + dynamicMargin * multiplier,
49
49
  };
50
50
  };
51
51
  const cellElementProps = cell.getCellProps({
@@ -82,11 +82,9 @@ const TablePaginator = (props) => {
82
82
  const pageButton = React.useCallback(
83
83
  (index, tabIndex = index === focusedIndex ? 0 : -1) =>
84
84
  React.createElement(
85
- index_js_4.Box,
85
+ index_js_4.ButtonBase,
86
86
  {
87
- as: 'button',
88
87
  key: index,
89
- type: 'button',
90
88
  className: (0, classnames_1.default)(
91
89
  'iui-table-paginator-page-button',
92
90
  {
@@ -28,9 +28,8 @@ exports.Tab = React.forwardRef((props, forwardedRef) => {
28
28
  ...rest
29
29
  } = props;
30
30
  return React.createElement(
31
- index_js_1.Box,
31
+ index_js_1.ButtonBase,
32
32
  {
33
- as: 'button',
34
33
  className: (0, classnames_1.default)(
35
34
  'iui-tab',
36
35
  { 'iui-active': active },
@@ -3,5 +3,5 @@ import type { ThemeOptions, ThemeType } from './ThemeProvider.js';
3
3
  export declare const ThemeContext: React.Context<{
4
4
  theme?: ThemeType | undefined;
5
5
  themeOptions?: ThemeOptions | undefined;
6
- portalContainerRef?: React.RefObject<HTMLElement> | undefined;
6
+ portalContainer?: HTMLElement | null | undefined;
7
7
  } | undefined>;
@@ -44,11 +44,31 @@ type RootProps = {
44
44
  type ThemeProviderOwnProps = Pick<RootProps, 'theme'> & {
45
45
  themeOptions?: RootProps['themeOptions'];
46
46
  children: Required<React.ReactNode>;
47
+ /**
48
+ * The element used as the portal for floating elements (Tooltip, Toast, DropdownMenu, Dialog, etc).
49
+ *
50
+ * Defaults to a `<div>` rendered at the end of the ThemeProvider.
51
+ *
52
+ * When passing an element, it is recommended to use state.
53
+ *
54
+ * @example
55
+ * const [myPortal, setMyPortal] = React.useState(null);
56
+ *
57
+ * <div ref={setMyPortal} />
58
+ * <ThemeProvider
59
+ * portalContainer={myPortal}
60
+ * >
61
+ * ...
62
+ * </ThemeProvider>
63
+ */
64
+ portalContainer?: HTMLElement;
47
65
  };
48
66
  /**
49
- * This component provides global styles and applies theme to the entire tree
50
- * that it is wrapping around. The `theme` prop is optional and defaults to the
51
- * light theme.
67
+ * This component provides global state and applies theme to the entire tree
68
+ * that it is wrapping around.
69
+ *
70
+ * The `theme` prop defaults to "inherit", which looks upwards for closest ThemeProvider
71
+ * and falls back to "light" theme if one is not found.
52
72
  *
53
73
  * If you want to theme the entire app, you should use this component at the root. You can also
54
74
  * use this component to apply a different theme to only a part of the tree.
@@ -7,14 +7,17 @@ const tslib_1 = require('tslib');
7
7
  * See LICENSE.md in the project root for license terms and full copyright notice.
8
8
  *--------------------------------------------------------------------------------------------*/
9
9
  const React = tslib_1.__importStar(require('react'));
10
+ const ReactDOM = tslib_1.__importStar(require('react-dom'));
10
11
  const classnames_1 = tslib_1.__importDefault(require('classnames'));
11
12
  const index_js_1 = require('../utils/index.js');
12
13
  const ThemeContext_js_1 = require('./ThemeContext.js');
13
14
  const Toaster_js_1 = require('../Toast/Toaster.js');
14
15
  /**
15
- * This component provides global styles and applies theme to the entire tree
16
- * that it is wrapping around. The `theme` prop is optional and defaults to the
17
- * light theme.
16
+ * This component provides global state and applies theme to the entire tree
17
+ * that it is wrapping around.
18
+ *
19
+ * The `theme` prop defaults to "inherit", which looks upwards for closest ThemeProvider
20
+ * and falls back to "light" theme if one is not found.
18
21
  *
19
22
  * If you want to theme the entire app, you should use this component at the root. You can also
20
23
  * use this component to apply a different theme to only a part of the tree.
@@ -37,18 +40,22 @@ const Toaster_js_1 = require('../Toast/Toaster.js');
37
40
  * <App />
38
41
  * </ThemeProvider>
39
42
  */
40
- exports.ThemeProvider = React.forwardRef((props, ref) => {
41
- const { theme: themeProp, children, themeOptions, ...rest } = props;
42
- const portalContainerRef = React.useRef(null);
43
- const parentContext = React.useContext(ThemeContext_js_1.ThemeContext);
44
- const theme =
45
- themeProp === 'inherit' ? parentContext?.theme ?? 'light' : themeProp;
46
- const shouldApplyBackground =
47
- themeOptions?.applyBackground ??
48
- (themeProp === 'inherit' ? false : !parentContext);
43
+ exports.ThemeProvider = React.forwardRef((props, forwardedRef) => {
44
+ const {
45
+ theme: themeProp = 'inherit',
46
+ children,
47
+ themeOptions,
48
+ portalContainer: portalContainerProp,
49
+ ...rest
50
+ } = props;
51
+ const [portalContainer, setPortalContainer] = (0,
52
+ index_js_1.useUncontrolledState)(portalContainerProp || null);
53
+ const [parentTheme, rootRef] = useParentTheme();
54
+ const theme = themeProp === 'inherit' ? parentTheme || 'light' : themeProp;
55
+ const shouldApplyBackground = themeOptions?.applyBackground ?? !parentTheme;
49
56
  const contextValue = React.useMemo(
50
- () => ({ theme, themeOptions, portalContainerRef }),
51
- [theme, themeOptions],
57
+ () => ({ theme, themeOptions, portalContainer }),
58
+ [theme, themeOptions, portalContainer],
52
59
  );
53
60
  return React.createElement(
54
61
  ThemeContext_js_1.ThemeContext.Provider,
@@ -59,23 +66,29 @@ exports.ThemeProvider = React.forwardRef((props, ref) => {
59
66
  theme: theme,
60
67
  shouldApplyBackground: shouldApplyBackground,
61
68
  themeOptions: themeOptions,
62
- ref: ref,
69
+ ref: (0, index_js_1.useMergedRefs)(forwardedRef, rootRef),
63
70
  ...rest,
64
71
  },
65
72
  React.createElement(
66
73
  Toaster_js_1.ToastProvider,
67
74
  null,
68
75
  children,
69
- React.createElement(
70
- 'div',
71
- { ref: portalContainerRef },
72
- React.createElement(Toaster_js_1.Toaster, null),
73
- ),
76
+ portalContainerProp
77
+ ? ReactDOM.createPortal(
78
+ React.createElement(Toaster_js_1.Toaster, null),
79
+ portalContainerProp,
80
+ )
81
+ : React.createElement(
82
+ 'div',
83
+ { ref: setPortalContainer },
84
+ React.createElement(Toaster_js_1.Toaster, null),
85
+ ),
74
86
  ),
75
87
  ),
76
88
  );
77
89
  });
78
90
  exports.default = exports.ThemeProvider;
91
+ // ----------------------------------------------------------------------------
79
92
  const Root = React.forwardRef((props, forwardedRef) => {
80
93
  const {
81
94
  theme,
@@ -85,8 +98,6 @@ const Root = React.forwardRef((props, forwardedRef) => {
85
98
  className,
86
99
  ...rest
87
100
  } = props;
88
- const ref = React.useRef(null);
89
- const mergedRefs = (0, index_js_1.useMergedRefs)(ref, forwardedRef);
90
101
  const prefersDark = (0, index_js_1.useMediaQuery)(
91
102
  '(prefers-color-scheme: dark)',
92
103
  );
@@ -105,9 +116,31 @@ const Root = React.forwardRef((props, forwardedRef) => {
105
116
  ),
106
117
  'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
107
118
  'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
108
- ref: mergedRefs,
119
+ ref: forwardedRef,
109
120
  ...rest,
110
121
  },
111
122
  children,
112
123
  );
113
124
  });
125
+ // ----------------------------------------------------------------------------
126
+ /**
127
+ * Returns theme from either parent context or by reading the closest
128
+ * data-iui-theme attribute if context is not found.
129
+ */
130
+ const useParentTheme = () => {
131
+ const parentContext = React.useContext(ThemeContext_js_1.ThemeContext);
132
+ const rootRef = React.useRef(null);
133
+ const [parentThemeState, setParentTheme] = React.useState(
134
+ parentContext?.theme,
135
+ );
136
+ (0, index_js_1.useIsomorphicLayoutEffect)(() => {
137
+ setParentTheme(
138
+ (old) =>
139
+ old ||
140
+ rootRef.current?.parentElement
141
+ ?.closest('[data-iui-theme]')
142
+ ?.getAttribute('data-iui-theme'),
143
+ );
144
+ }, []);
145
+ return [parentContext?.theme ?? parentThemeState, rootRef];
146
+ };
@@ -125,10 +125,11 @@ export declare const Tile: PolymorphicForwardRefComponent<"div", TileOwnProps> &
125
125
  */
126
126
  IconButton: PolymorphicForwardRefComponent<"button", Omit<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
127
127
  ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
128
- }, "label" | "as" | "size" | "styleType" | "isActive"> & {
128
+ }, "label" | "as" | "size" | "htmlDisabled" | "styleType" | "isActive" | "iconProps"> & {
129
129
  isActive?: boolean | undefined;
130
130
  label?: React.ReactNode;
131
- } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon"> & {
131
+ iconProps?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | undefined;
132
+ } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
132
133
  as?: "button" | undefined;
133
134
  }, "ref">>;
134
135
  /**
@@ -48,9 +48,9 @@ const Toast = (props) => {
48
48
  const [margin, setMargin] = React.useState(0);
49
49
  const marginStyle = () => {
50
50
  if (placementPosition === 'top') {
51
- return { marginBottom: margin };
51
+ return { marginBlockEnd: margin };
52
52
  }
53
- return { marginTop: margin };
53
+ return { marginBlockStart: margin };
54
54
  };
55
55
  React.useEffect(() => {
56
56
  if (type === 'temporary') {
@@ -194,13 +194,8 @@ const ToastPresentation = (props) => {
194
194
  React.createElement(index_js_1.Box, { className: 'iui-message' }, content),
195
195
  link &&
196
196
  React.createElement(
197
- index_js_1.Box,
198
- {
199
- as: 'button',
200
- className: 'iui-toast-anchor',
201
- ...link,
202
- title: undefined,
203
- },
197
+ index_js_1.ButtonBase,
198
+ { className: 'iui-toast-anchor', ...link, title: undefined },
204
199
  link.title,
205
200
  ),
206
201
  (type === 'persisting' || hasCloseButton) &&
@@ -55,7 +55,7 @@ type TooltipOwnProps = {
55
55
  children?: React.ReactNode;
56
56
  /**
57
57
  * Element to portal tooltip to.
58
- * Portals to ThemeProvider portalContainerRef by default.
58
+ * Portals to ThemeProvider portalContainer by default.
59
59
  * @default true;
60
60
  */
61
61
  portal?: boolean | {
@@ -124,8 +124,7 @@ exports.Tooltip = React.forwardRef((props, forwardRef) => {
124
124
  typeof portal !== 'boolean'
125
125
  ? portal.to
126
126
  : portal
127
- ? context?.portalContainerRef?.current ??
128
- (0, index_js_1.getDocument)()?.body
127
+ ? context?.portalContainer || (0, index_js_1.getDocument)()?.body
129
128
  : null;
130
129
  const contentBox = React.createElement(
131
130
  index_js_1.Box,
@@ -229,7 +229,7 @@ const TreeNode = (props) => {
229
229
  as: 'ul',
230
230
  className: 'iui-sub-tree',
231
231
  role: 'group',
232
- 'aria-owns': subNodeIds.join(','),
232
+ 'aria-owns': subNodeIds.join(' '),
233
233
  }),
234
234
  );
235
235
  };
@@ -0,0 +1,14 @@
1
+ import type { PolymorphicForwardRefComponent } from '../props.js';
2
+ export declare const ButtonBase: PolymorphicForwardRefComponent<"button", ButtonBaseProps>;
3
+ type ButtonBaseProps = {
4
+ /**
5
+ * Custom `disabled` prop that keeps the button focusable, prevents
6
+ * clicks, applied disabled styling, and adds `aria-disabled`.
7
+ */
8
+ disabled?: boolean;
9
+ /**
10
+ * Built-in html `disabled` attribute
11
+ */
12
+ htmlDisabled?: boolean;
13
+ };
14
+ export {};
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.ButtonBase = 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 classnames_1 = tslib_1.__importDefault(require('classnames'));
11
+ const Box_js_1 = require('./Box.js');
12
+ const useIsClient_js_1 = require('../hooks/useIsClient.js');
13
+ exports.ButtonBase = React.forwardRef((props, forwardedRef) => {
14
+ const {
15
+ as: asProp = 'button',
16
+ disabled: disabledProp,
17
+ htmlDisabled,
18
+ ...rest
19
+ } = props;
20
+ const isClient = (0, useIsClient_js_1.useIsClient)();
21
+ const ariaDisabled =
22
+ disabledProp &&
23
+ !htmlDisabled && // htmlDisabled prop takes preference
24
+ isClient && // progressively enhance after first render
25
+ asProp === 'button'; // ignore if not button, e.g. links
26
+ const handleIfEnabled = (handler) => (e) => {
27
+ if (disabledProp) {
28
+ return;
29
+ }
30
+ handler?.(e);
31
+ };
32
+ return React.createElement(Box_js_1.Box, {
33
+ as: asProp,
34
+ type: asProp === 'button' ? 'button' : undefined,
35
+ ref: forwardedRef,
36
+ 'aria-disabled': ariaDisabled ? 'true' : undefined,
37
+ 'data-iui-disabled': disabledProp ? 'true' : undefined,
38
+ disabled: htmlDisabled ?? (!isClient && disabledProp) ? true : undefined,
39
+ ...rest,
40
+ className: (0, classnames_1.default)('iui-button-base', props.className),
41
+ onClick: handleIfEnabled(props.onClick),
42
+ onPointerDown: handleIfEnabled(props.onPointerDown),
43
+ onPointerUp: handleIfEnabled(props.onPointerUp),
44
+ });
45
+ });
46
+ exports.ButtonBase.displayName = 'ButtonBase';
@@ -40,8 +40,7 @@ exports.Popover = React.forwardRef((props, ref) => {
40
40
  const computedProps = {
41
41
  allowHTML: true,
42
42
  animation: false,
43
- appendTo: (el) =>
44
- themeInfo?.portalContainerRef?.current || el.ownerDocument.body,
43
+ appendTo: (el) => themeInfo?.portalContainer || el.ownerDocument.body,
45
44
  arrow: false,
46
45
  duration: 0,
47
46
  interactive: true,
@@ -66,7 +65,10 @@ exports.Popover = React.forwardRef((props, ref) => {
66
65
  ...props.popperOptions,
67
66
  modifiers: [
68
67
  { name: 'flip' },
69
- { name: 'preventOverflow', options: { padding: 0 } },
68
+ {
69
+ name: 'preventOverflow',
70
+ options: { padding: 0 },
71
+ },
70
72
  ...(props.popperOptions?.modifiers || []),
71
73
  ],
72
74
  },
@@ -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,4 @@ 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';
@@ -20,3 +20,4 @@ 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);
@@ -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.
@@ -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 './useUncontrolledState.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('./useUncontrolledState.js'), exports);