@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
@@ -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;
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Wrapper over `useState` that always gives preference to the
4
+ * uncontrolled state (which often comes from a prop).
5
+ */
6
+ export declare const useUncontrolledState: <T>(uncontrolledState: T) => readonly [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>];
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.useUncontrolledState = 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
+ * uncontrolled state (which often comes from a prop).
13
+ */
14
+ const useUncontrolledState = (uncontrolledState) => {
15
+ const [controlledState, setControlledState] = React.useState();
16
+ return [uncontrolledState ?? controlledState, setControlledState];
17
+ };
18
+ exports.useUncontrolledState = useUncontrolledState;
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',
@@ -243,10 +236,10 @@ const styles = {
243
236
  'iui-overlay-exiting': '_iui3-overlay-exiting',
244
237
  closeAnimation,
245
238
  'iui-progress-indicator-radial': '_iui3-progress-indicator-radial',
246
- 'iui-ux8sxma': '_iui3-ux8sxma',
239
+ 'iui-u8bwhh6': '_iui3-u8bwhh6',
247
240
  'iui-progress-indicator-linear-label':
248
241
  '_iui3-progress-indicator-linear-label',
249
- 'iui-ux8sxmt': '_iui3-ux8sxmt',
242
+ 'iui-u8bwhhv': '_iui3-u8bwhhv',
250
243
  'iui-radio': '_iui3-radio',
251
244
  'iui-radio-tile': '_iui3-radio-tile',
252
245
  'iui-radio-tile-icon': '_iui3-radio-tile-icon',
@@ -438,6 +431,7 @@ const styles = {
438
431
  'iui-tree-node-content-label': '_iui3-tree-node-content-label',
439
432
  'iui-tree-node-content-title': '_iui3-tree-node-content-title',
440
433
  'iui-tree-node-content-caption': '_iui3-tree-node-content-caption',
434
+ 'iui-button-base': '_iui3-button-base',
441
435
  'iui-svg-icon': '_iui3-svg-icon',
442
436
  'iui-notification-marker': '_iui3-notification-marker',
443
437
  pulse,
@@ -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
  );
@@ -1,4 +1,5 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
+ import { ButtonBase } from '../../utils/index.js';
2
3
  import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
3
4
  export type ButtonProps = {
4
5
  /**
@@ -19,7 +20,19 @@ export type ButtonProps = {
19
20
  * Icon shown after the main button content.
20
21
  */
21
22
  endIcon?: JSX.Element;
22
- };
23
+ /**
24
+ * Passes props to the button label.
25
+ */
26
+ labelProps?: React.ComponentProps<'span'>;
27
+ /**
28
+ * Passes props to the start icon.
29
+ */
30
+ startIconProps?: React.ComponentProps<'span'>;
31
+ /**
32
+ * Passes props to the end icon.
33
+ */
34
+ endIconProps?: React.ComponentProps<'span'>;
35
+ } & Pick<React.ComponentProps<typeof ButtonBase>, 'htmlDisabled'>;
23
36
  /**
24
37
  * Generic button component
25
38
  * @example
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import cx from 'classnames';
6
6
  import * as React from 'react';
7
- import { Box } from '../../utils/index.js';
7
+ import { Box, ButtonBase } from '../../utils/index.js';
8
8
  /**
9
9
  * Generic button component
10
10
  * @example
@@ -19,36 +19,44 @@ export const Button = React.forwardRef((props, ref) => {
19
19
  children,
20
20
  className,
21
21
  size,
22
- style,
23
22
  styleType = 'default',
24
- type = 'button',
25
23
  startIcon,
26
24
  endIcon,
25
+ labelProps,
26
+ startIconProps,
27
+ endIconProps,
27
28
  ...rest
28
29
  } = props;
29
30
  return React.createElement(
30
- Box,
31
+ ButtonBase,
31
32
  {
32
- as: 'button',
33
33
  ref: ref,
34
34
  className: cx('iui-button', className),
35
35
  'data-iui-variant': styleType !== 'default' ? styleType : undefined,
36
36
  'data-iui-size': size,
37
- style: style,
38
- type: type,
39
37
  ...rest,
40
38
  },
41
39
  startIcon &&
42
40
  React.createElement(
43
41
  Box,
44
- { as: 'span', className: 'iui-button-icon', 'aria-hidden': true },
42
+ {
43
+ as: 'span',
44
+ 'aria-hidden': true,
45
+ ...startIconProps,
46
+ className: cx('iui-button-icon', startIconProps?.className),
47
+ },
45
48
  startIcon,
46
49
  ),
47
- children && React.createElement('span', null, children),
50
+ children && React.createElement('span', { ...labelProps }, children),
48
51
  endIcon &&
49
52
  React.createElement(
50
53
  Box,
51
- { as: 'span', className: 'iui-button-icon', 'aria-hidden': true },
54
+ {
55
+ as: 'span',
56
+ 'aria-hidden': true,
57
+ ...endIconProps,
58
+ className: cx('iui-button-icon', endIconProps?.className),
59
+ },
52
60
  endIcon,
53
61
  ),
54
62
  );
@@ -52,7 +52,7 @@ export const DropdownButton = React.forwardRef((props, ref) => {
52
52
  setIsMenuOpen(false);
53
53
  dropdownMenuProps?.onHide?.(i);
54
54
  },
55
- style: { minWidth: menuWidth, ...dropdownMenuProps?.style },
55
+ style: { minInlineSize: menuWidth, ...dropdownMenuProps?.style },
56
56
  },
57
57
  React.createElement(
58
58
  Button,
@@ -11,7 +11,11 @@ export type IconButtonProps = {
11
11
  * Name of the button, shown in a tooltip and exposed to assistive technologies.
12
12
  */
13
13
  label?: React.ReactNode;
14
- } & Omit<ButtonProps, 'startIcon' | 'endIcon'>;
14
+ /**
15
+ * Passes props to IconButton icon.
16
+ */
17
+ iconProps?: React.ComponentProps<'span'>;
18
+ } & Omit<ButtonProps, 'startIcon' | 'endIcon' | 'startIconProps' | 'endIconProps' | 'labelProps'>;
15
19
  /**
16
20
  * Icon button
17
21
  * @example
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import cx from 'classnames';
6
6
  import * as React from 'react';
7
- import { VisuallyHidden, Popover, Box } from '../../utils/index.js';
7
+ import { VisuallyHidden, Popover, Box, ButtonBase } from '../../utils/index.js';
8
8
  /**
9
9
  * Icon button
10
10
  * @example
@@ -18,30 +18,33 @@ export const IconButton = React.forwardRef((props, ref) => {
18
18
  children,
19
19
  styleType = 'default',
20
20
  size,
21
- type = 'button',
22
21
  className,
23
22
  label,
23
+ iconProps,
24
24
  ...rest
25
25
  } = props;
26
26
  return React.createElement(
27
27
  IconButtonTooltip,
28
28
  { label: label },
29
29
  React.createElement(
30
- Box,
30
+ ButtonBase,
31
31
  {
32
- as: 'button',
33
32
  ref: ref,
34
33
  className: cx('iui-button', className),
35
34
  'data-iui-variant': styleType !== 'default' ? styleType : undefined,
36
35
  'data-iui-size': size,
37
36
  'data-iui-active': isActive,
38
37
  'aria-pressed': isActive,
39
- type: type,
40
38
  ...rest,
41
39
  },
42
40
  React.createElement(
43
41
  Box,
44
- { as: 'span', className: 'iui-button-icon', 'aria-hidden': true },
42
+ {
43
+ as: 'span',
44
+ 'aria-hidden': true,
45
+ ...iconProps,
46
+ className: cx('iui-button-icon', iconProps?.className),
47
+ },
45
48
  children,
46
49
  ),
47
50
  label ? React.createElement(VisuallyHidden, null, label) : null,
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ButtonProps } from '../Button/Button.js';
3
+ import { IconButton } from '../IconButton/index.js';
3
4
  import type { Placement } from 'tippy.js';
4
5
  import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
5
6
  export type SplitButtonProps = ButtonProps & {
@@ -18,6 +19,14 @@ export type SplitButtonProps = ButtonProps & {
18
19
  * Content of primary button.
19
20
  */
20
21
  children: React.ReactNode;
22
+ /**
23
+ * Passes props to SplitButton wrapper.
24
+ */
25
+ wrapperProps?: React.ComponentProps<'div'>;
26
+ /**
27
+ * Passes props to SplitButton menu button.
28
+ */
29
+ menuButtonProps?: React.ComponentProps<typeof IconButton>;
21
30
  };
22
31
  /**
23
32
  * Split button component with a DropdownMenu.
@@ -31,31 +31,35 @@ export const SplitButton = React.forwardRef((props, forwardedRef) => {
31
31
  styleType = 'default',
32
32
  size,
33
33
  children,
34
- style,
35
- title,
34
+ wrapperProps,
35
+ menuButtonProps,
36
36
  ...rest
37
37
  } = props;
38
38
  const [isMenuOpen, setIsMenuOpen] = React.useState(false);
39
39
  const [menuWidth, setMenuWidth] = React.useState(0);
40
- const ref = React.useRef(null);
40
+ const wrapperRef = React.useRef(null);
41
41
  React.useEffect(() => {
42
- if (ref.current) {
43
- setMenuWidth(ref.current.offsetWidth);
42
+ if (wrapperRef.current) {
43
+ setMenuWidth(wrapperRef.current.offsetWidth);
44
44
  }
45
45
  }, [children, size]);
46
46
  return React.createElement(
47
47
  Box,
48
48
  {
49
- className: cx(className, 'iui-button-split', {
50
- 'iui-disabled': props.disabled,
51
- }),
52
- style: style,
53
- title: title,
54
- ref: ref,
49
+ ...wrapperProps,
50
+ className: cx(
51
+ 'iui-button-split',
52
+ {
53
+ 'iui-disabled': props.disabled,
54
+ },
55
+ wrapperProps?.className,
56
+ ),
57
+ ref: wrapperRef,
55
58
  },
56
59
  React.createElement(
57
60
  Button,
58
61
  {
62
+ className: className,
59
63
  styleType: styleType,
60
64
  size: size,
61
65
  onClick: onClick,
@@ -69,13 +73,18 @@ export const SplitButton = React.forwardRef((props, forwardedRef) => {
69
73
  {
70
74
  placement: menuPlacement,
71
75
  menuItems: menuItems,
72
- style: { minWidth: menuWidth },
76
+ style: { minInlineSize: menuWidth },
73
77
  onShow: React.useCallback(() => setIsMenuOpen(true), []),
74
78
  onHide: React.useCallback(() => setIsMenuOpen(false), []),
75
79
  },
76
80
  React.createElement(
77
81
  IconButton,
78
- { styleType: styleType, size: size, disabled: props.disabled },
82
+ {
83
+ styleType: styleType,
84
+ size: size,
85
+ disabled: props.disabled,
86
+ ...menuButtonProps,
87
+ },
79
88
  isMenuOpen
80
89
  ? React.createElement(SvgCaretUpSmall, null)
81
90
  : React.createElement(SvgCaretDownSmall, null),
@@ -38,18 +38,20 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
38
38
  Navigation: PolymorphicForwardRefComponent<"nav", {}> & {
39
39
  PreviousButton: PolymorphicForwardRefComponent<"button", Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
40
40
  ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
41
- }, "label" | "as" | "size" | "styleType" | "isActive"> & {
41
+ }, "label" | "as" | "size" | "htmlDisabled" | "styleType" | "isActive" | "iconProps"> & {
42
42
  isActive?: boolean | undefined;
43
43
  label?: React.ReactNode;
44
- } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon"> & {
44
+ iconProps?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | undefined;
45
+ } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
45
46
  as?: "button" | undefined;
46
47
  }>;
47
48
  NextButton: PolymorphicForwardRefComponent<"button", Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
48
49
  ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
49
- }, "label" | "as" | "size" | "styleType" | "isActive"> & {
50
+ }, "label" | "as" | "size" | "htmlDisabled" | "styleType" | "isActive" | "iconProps"> & {
50
51
  isActive?: boolean | undefined;
51
52
  label?: React.ReactNode;
52
- } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon"> & {
53
+ iconProps?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | undefined;
54
+ } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
53
55
  as?: "button" | undefined;
54
56
  }>;
55
57
  };
@@ -4,7 +4,12 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import * as React from 'react';
6
6
  import cx from 'classnames';
7
- import { getRandomValue, useMergedRefs, Box } from '../utils/index.js';
7
+ import {
8
+ getRandomValue,
9
+ useMergedRefs,
10
+ Box,
11
+ useLatestRef,
12
+ } from '../utils/index.js';
8
13
  import { CarouselContext } from './CarouselContext.js';
9
14
  import { CarouselSlider } from './CarouselSlider.js';
10
15
  import { CarouselSlide } from './CarouselSlide.js';
@@ -70,10 +75,10 @@ const CarouselComponent = React.forwardRef((props, ref) => {
70
75
  }
71
76
  }
72
77
  };
73
- const userOnSlideChange = React.useRef(onSlideChange);
78
+ const userOnSlideChange = useLatestRef(onSlideChange);
74
79
  React.useEffect(() => {
75
80
  userOnSlideChange.current?.(currentIndex);
76
- }, [currentIndex]);
81
+ }, [userOnSlideChange, currentIndex]);
77
82
  return React.createElement(
78
83
  Box,
79
84
  {
@@ -4,16 +4,14 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import * as React from 'react';
6
6
  import cx from 'classnames';
7
- import { Box } from '../utils/index.js';
7
+ import { ButtonBase } from '../utils/index.js';
8
8
  /**
9
9
  * `CarouselDot` is the actual "dot" component used to activate a slide on clicking.
10
10
  * It should be used as a child of `CarouselDotsList`.
11
11
  */
12
12
  export const CarouselDot = React.forwardRef((props, ref) => {
13
13
  const { isActive, isSmaller, isSmall, className, ...rest } = props;
14
- return React.createElement(Box, {
15
- as: 'button',
16
- type: 'button',
14
+ return React.createElement(ButtonBase, {
17
15
  role: 'tab',
18
16
  tabIndex: -1,
19
17
  className: cx(
@@ -9,18 +9,20 @@ import type { PolymorphicForwardRefComponent } from '../utils/index.js';
9
9
  export declare const CarouselNavigation: PolymorphicForwardRefComponent<"nav", {}> & {
10
10
  PreviousButton: PolymorphicForwardRefComponent<"button", Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
11
11
  ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
12
- }, "label" | "as" | "size" | "styleType" | "isActive"> & {
12
+ }, "label" | "as" | "size" | "htmlDisabled" | "styleType" | "isActive" | "iconProps"> & {
13
13
  isActive?: boolean | undefined;
14
14
  label?: React.ReactNode;
15
- } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon"> & {
15
+ iconProps?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | undefined;
16
+ } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
16
17
  as?: "button" | undefined;
17
18
  }>;
18
19
  NextButton: PolymorphicForwardRefComponent<"button", Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
19
20
  ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
20
- }, "label" | "as" | "size" | "styleType" | "isActive"> & {
21
+ }, "label" | "as" | "size" | "htmlDisabled" | "styleType" | "isActive" | "iconProps"> & {
21
22
  isActive?: boolean | undefined;
22
23
  label?: React.ReactNode;
23
- } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon"> & {
24
+ iconProps?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | undefined;
25
+ } & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
24
26
  as?: "button" | undefined;
25
27
  }>;
26
28
  };
@@ -245,7 +245,8 @@ export const ColorBuilder = React.forwardRef((props, ref) => {
245
245
  React.createElement(Box, {
246
246
  className: 'iui-color-dot',
247
247
  style: {
248
- '--iui-color-dot-inset': `${squareTop.toString()}% auto auto ${squareLeft.toString()}%`,
248
+ '--iui-color-dot-inset-block': `${squareTop.toString()}% auto`,
249
+ '--iui-color-dot-inset-inline': `${squareLeft.toString()}% auto`,
249
250
  },
250
251
  onPointerDown: () => {
251
252
  setColorDotActive(true);
@@ -197,7 +197,7 @@ export const ComboBoxInput = React.forwardRef((props, forwardedRef) => {
197
197
  spellCheck: false,
198
198
  autoCapitalize: 'none',
199
199
  autoCorrect: 'off',
200
- style: multiple ? { paddingLeft: tagContainerWidth + 18 } : {},
200
+ style: multiple ? { paddingInlineStart: tagContainerWidth + 18 } : {},
201
201
  'aria-describedby': multiple ? `${id}-selected-live` : undefined,
202
202
  ...rest,
203
203
  }),
@@ -47,11 +47,11 @@ const VirtualizedComboBoxMenu = React.forwardRef(
47
47
  scrollToIndex: focusedVisibleIndex,
48
48
  });
49
49
  const surfaceStyles = {
50
- minWidth,
50
+ minInlineSize: minWidth,
51
51
  // set as constant because we don't want it shifting when items are unmounted
52
- maxWidth: minWidth,
52
+ maxInlineSize: minWidth,
53
53
  // max-height must be on the outermost element for virtual scroll
54
- maxHeight: 'calc((var(--iui-component-height) - 1px) * 8.5)',
54
+ maxBlockSize: 'calc((var(--iui-component-height) - 1px) * 8.5)',
55
55
  overflowY: isOverflowOverlaySupported() ? 'overlay' : 'auto',
56
56
  ...style,
57
57
  };
@@ -86,8 +86,8 @@ export const ComboBoxMenu = React.forwardRef((props, forwardedRef) => {
86
86
  const refs = useMergedRefs(menuRef, forwardedRef);
87
87
  const styles = React.useMemo(
88
88
  () => ({
89
- minWidth,
90
- maxWidth: `min(${minWidth * 2}px, 90vw)`,
89
+ minInlineSize: minWidth,
90
+ maxInlineSize: `min(${minWidth * 2}px, 90vw)`,
91
91
  }),
92
92
  [minWidth],
93
93
  );
@@ -11,6 +11,7 @@ import {
11
11
  SvgChevronRightDouble,
12
12
  isBefore,
13
13
  Box,
14
+ useId,
14
15
  } from '../utils/index.js';
15
16
  import { IconButton } from '../Buttons/IconButton/index.js';
16
17
  import { TimePicker } from '../TimePicker/index.js';
@@ -409,6 +410,7 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
409
410
  }
410
411
  return dayClass;
411
412
  };
413
+ const dateTableId = useId();
412
414
  return React.createElement(
413
415
  Box,
414
416
  { className: cx('iui-date-picker', className), ref: forwardedRef, ...rest },
@@ -447,6 +449,7 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
447
449
  {
448
450
  as: 'span',
449
451
  className: 'iui-calendar-month',
452
+ id: dateTableId,
450
453
  title: monthNames[displayedMonthIndex],
451
454
  },
452
455
  monthNames[displayedMonthIndex],
@@ -485,7 +488,11 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
485
488
  ),
486
489
  React.createElement(
487
490
  'div',
488
- { onKeyDown: handleCalendarKeyDown, role: 'listbox' },
491
+ {
492
+ onKeyDown: handleCalendarKeyDown,
493
+ role: 'listbox',
494
+ 'aria-labelledby': dateTableId,
495
+ },
489
496
  weeks.map((weekDays, weekIndex) => {
490
497
  return React.createElement(
491
498
  Box,
@@ -43,7 +43,7 @@ const DialogComponent = React.forwardRef((props, ref) => {
43
43
  typeof portal !== 'boolean'
44
44
  ? portal.to
45
45
  : portal
46
- ? context?.portalContainerRef?.current ?? getDocument()?.body
46
+ ? context?.portalContainer || getDocument()?.body
47
47
  : null;
48
48
  const dialog = React.createElement(Box, {
49
49
  className: cx('iui-dialog-wrapper', className),
@@ -121,10 +121,10 @@ export const DialogMain = React.forwardRef((props, ref) => {
121
121
  const [translateX, translateY] = getTranslateValues(dialogRef.current);
122
122
  setStyle((oldStyle) => ({
123
123
  ...oldStyle,
124
- width: rect?.width,
125
- height: rect?.height,
126
- left: dialogRef.current?.offsetLeft,
127
- top: dialogRef.current?.offsetTop,
124
+ inlineSize: rect?.width,
125
+ blockSize: rect?.height,
126
+ insetInlineStart: dialogRef.current?.offsetLeft,
127
+ insetBlockStart: dialogRef.current?.offsetTop,
128
128
  transform: `translate(${translateX}px,${translateY}px)`,
129
129
  }));
130
130
  }, [isDraggable, isOpen]);
@@ -166,7 +166,7 @@ export const DialogMain = React.forwardRef((props, ref) => {
166
166
  onResizeStart: () => {
167
167
  if (!hasBeenResized.current) {
168
168
  hasBeenResized.current = true;
169
- setResizeStyle({ maxWidth: '100%' });
169
+ setResizeStyle({ maxInlineSize: '100%' });
170
170
  }
171
171
  },
172
172
  onResizeEnd: setResizeStyle,