@itwin/itwinui-react 3.0.0-dev.12 → 3.0.0-dev.14

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 (71) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/cjs/core/Carousel/Carousel.d.ts +12 -5
  3. package/cjs/core/Carousel/Carousel.js +9 -39
  4. package/cjs/core/Carousel/CarouselContext.d.ts +0 -4
  5. package/cjs/core/Carousel/CarouselDot.js +1 -1
  6. package/cjs/core/Carousel/CarouselDotsList.js +26 -2
  7. package/cjs/core/Carousel/CarouselNavigation.d.ts +1 -1
  8. package/cjs/core/Carousel/CarouselNavigation.js +4 -17
  9. package/cjs/core/Carousel/CarouselSlide.d.ts +1 -1
  10. package/cjs/core/Carousel/CarouselSlide.js +12 -2
  11. package/cjs/core/Carousel/CarouselSlider.d.ts +1 -1
  12. package/cjs/core/Carousel/CarouselSlider.js +2 -2
  13. package/cjs/core/ColorPicker/ColorBuilder.js +2 -0
  14. package/cjs/core/ColorPicker/ColorInputPanel.js +24 -4
  15. package/cjs/core/ColorPicker/ColorPalette.js +2 -80
  16. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  17. package/cjs/core/ColorPicker/ColorSwatch.js +25 -15
  18. package/cjs/core/LabeledSelect/LabeledSelect.d.ts +1 -1
  19. package/cjs/core/LabeledSelect/LabeledSelect.js +3 -3
  20. package/cjs/core/Select/Select.d.ts +1 -1
  21. package/cjs/core/Select/Select.js +6 -4
  22. package/cjs/core/Slider/Slider.d.ts +2 -6
  23. package/cjs/core/Slider/Slider.js +8 -22
  24. package/cjs/core/Slider/Thumb.d.ts +1 -2
  25. package/cjs/core/Slider/Thumb.js +1 -5
  26. package/cjs/core/Tabs/Tabs.d.ts +222 -52
  27. package/cjs/core/Tabs/Tabs.js +429 -375
  28. package/cjs/core/ThemeProvider/ThemeProvider.js +3 -1
  29. package/cjs/core/Tile/Tile.js +11 -10
  30. package/cjs/core/utils/hooks/useOverflow.js +3 -1
  31. package/cjs/index.d.ts +1 -2
  32. package/cjs/index.js +1 -2
  33. package/cjs/styles.js +10 -10
  34. package/esm/core/Carousel/Carousel.d.ts +12 -5
  35. package/esm/core/Carousel/Carousel.js +9 -39
  36. package/esm/core/Carousel/CarouselContext.d.ts +0 -4
  37. package/esm/core/Carousel/CarouselDot.js +1 -1
  38. package/esm/core/Carousel/CarouselDotsList.js +26 -2
  39. package/esm/core/Carousel/CarouselNavigation.d.ts +1 -1
  40. package/esm/core/Carousel/CarouselNavigation.js +5 -22
  41. package/esm/core/Carousel/CarouselSlide.d.ts +1 -1
  42. package/esm/core/Carousel/CarouselSlide.js +15 -3
  43. package/esm/core/Carousel/CarouselSlider.d.ts +1 -1
  44. package/esm/core/Carousel/CarouselSlider.js +2 -2
  45. package/esm/core/ColorPicker/ColorBuilder.js +2 -0
  46. package/esm/core/ColorPicker/ColorInputPanel.js +25 -5
  47. package/esm/core/ColorPicker/ColorPalette.js +3 -83
  48. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  49. package/esm/core/ColorPicker/ColorSwatch.js +18 -12
  50. package/esm/core/LabeledSelect/LabeledSelect.d.ts +1 -1
  51. package/esm/core/LabeledSelect/LabeledSelect.js +3 -2
  52. package/esm/core/Select/Select.d.ts +1 -1
  53. package/esm/core/Select/Select.js +3 -3
  54. package/esm/core/Slider/Slider.d.ts +2 -6
  55. package/esm/core/Slider/Slider.js +8 -19
  56. package/esm/core/Slider/Thumb.d.ts +1 -2
  57. package/esm/core/Slider/Thumb.js +1 -5
  58. package/esm/core/Tabs/Tabs.d.ts +222 -52
  59. package/esm/core/Tabs/Tabs.js +424 -368
  60. package/esm/core/ThemeProvider/ThemeProvider.js +3 -1
  61. package/esm/core/Tile/Tile.js +11 -10
  62. package/esm/core/utils/hooks/useOverflow.js +3 -1
  63. package/esm/index.d.ts +1 -2
  64. package/esm/index.js +1 -2
  65. package/esm/styles.js +10 -10
  66. package/package.json +2 -2
  67. package/styles.css +33 -47
  68. package/cjs/core/Tabs/Tab.d.ts +0 -40
  69. package/cjs/core/Tabs/Tab.js +0 -65
  70. package/esm/core/Tabs/Tab.d.ts +0 -40
  71. package/esm/core/Tabs/Tab.js +0 -57
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.0-dev.14
4
+
5
+ ### Major Changes
6
+
7
+ - [#1626](https://github.com/iTwin/iTwinUI/pull/1626): Improved carousel accessibility and changed the markup so that the dots are present before the slides.
8
+ - [#1469](https://github.com/iTwin/iTwinUI/pull/1469): Updated internal DOM structure in Slider.
9
+
10
+ ### Patch Changes
11
+
12
+ - [#1632](https://github.com/iTwin/iTwinUI/pull/1632): Adjusted gap between adjacent icons in searchbox.
13
+
14
+ ## 3.0.0-dev.13
15
+
16
+ ### Major Changes
17
+
18
+ - [#1548](https://github.com/iTwin/iTwinUI/pull/1548): Tabs are now always scrollable. Deprecated `overflowOptions` prop.
19
+
20
+ ### Minor Changes
21
+
22
+ - [#1548](https://github.com/iTwin/iTwinUI/pull/1548): Added composition API to Tab. Subcomponents: Wrapper, TabList, Tab, TabLabel, TabIcon, TabDescription, Actions, Panel.
23
+
24
+ ### Patch Changes
25
+
26
+ - [#1618](https://github.com/iTwin/iTwinUI/pull/1618): Improved accessibility of ColorPicker/ColorPalette/ColorSwatch.
27
+
3
28
  ## 3.0.0-dev.12
4
29
 
5
30
  ### Minor Changes
@@ -223,6 +248,24 @@
223
248
  - Updated dependencies:
224
249
  - @itwin/itwinui-css@2.0.0-dev.0
225
250
 
251
+ ## 2.12.14
252
+
253
+ ### Patch Changes
254
+
255
+ - [#1643](https://github.com/iTwin/iTwinUI/pull/1643): Fixed an issue where ProgressRadial was not respecting explicit size.
256
+
257
+ ## 2.12.13
258
+
259
+ ### Patch Changes
260
+
261
+ - [#1634](https://github.com/iTwin/iTwinUI/pull/1634): Fix overflow visible items count when item is larger than container.
262
+
263
+ ## 2.12.12
264
+
265
+ ### Patch Changes
266
+
267
+ - [#1625](https://github.com/iTwin/iTwinUI/pull/1625): Fixed an issue where components rendered in a popout window were throwing a stylesheet-related error.
268
+
226
269
  ## 2.12.11
227
270
 
228
271
  ### Patch Changes
@@ -14,7 +14,8 @@ type CarouselProps = {
14
14
  };
15
15
  /**
16
16
  * The Carousel component consists of a set of slides, normally displayed one at a time. A navigation section is
17
- * located below the slides, consisting of "dots" and "previous"/"next" buttons, used for changing slides.
17
+ * shown below the slides, consisting of "dots" and "previous"/"next" buttons, used for changing slides; this navigation
18
+ * section must be present _before_ the slides in DOM order, even though it is visually shown below the slides.
18
19
  *
19
20
  * The currently shown slide can also be changed using the left/right arrow keys or by dragging on a touch device.
20
21
  *
@@ -22,20 +23,23 @@ type CarouselProps = {
22
23
  *
23
24
  * @example
24
25
  * <Carousel>
26
+ * <Carousel.Navigation />
25
27
  * <Carousel.Slider>
26
28
  * <Carousel.Slide>...</Carousel.Slide>
27
29
  * <Carousel.Slide>...</Carousel.Slide>
28
30
  * <Carousel.Slide>...</Carousel.Slide>
29
31
  * </Carousel.Slider>
30
- * <Carousel.Navigation />
31
32
  * </Carousel>
32
33
  */
33
34
  export declare const Carousel: PolymorphicForwardRefComponent<"section", CarouselProps> & {
34
- Slider: PolymorphicForwardRefComponent<"ol", {}>;
35
- Slide: PolymorphicForwardRefComponent<"li", {
35
+ Slider: PolymorphicForwardRefComponent<"div", {}>;
36
+ Slide: PolymorphicForwardRefComponent<"div", {
36
37
  index?: number | undefined;
37
38
  }>;
38
- Navigation: PolymorphicForwardRefComponent<"nav", {}> & {
39
+ /**
40
+ * Contains the dots and previous/next buttons for navigating the slides. Must be present _before_ the slides in DOM.
41
+ */
42
+ Navigation: PolymorphicForwardRefComponent<"div", {}> & {
39
43
  PreviousButton: PolymorphicForwardRefComponent<"button", Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
40
44
  ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
41
45
  }, "label" | "as" | "size" | "htmlDisabled" | "styleType" | "isActive" | "iconProps"> & {
@@ -55,6 +59,9 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
55
59
  as?: "button" | undefined;
56
60
  }>;
57
61
  };
62
+ /**
63
+ * Contains the dots for activating the slides. Must be present _before_ the slides in DOM.
64
+ */
58
65
  DotsList: PolymorphicForwardRefComponent<"div", {
59
66
  length?: number | undefined;
60
67
  currentIndex?: number | undefined;
@@ -38,42 +38,9 @@ const CarouselComponent = React.forwardRef((props, ref) => {
38
38
  scrollToSlide.current(userActiveIndex, {
39
39
  instant: justMounted.current,
40
40
  });
41
- // re-focus the carousel for keyboard nav, but not on first mount
42
- // because it shows outline and might interfere with other components
43
- if (!justMounted.current) {
44
- carouselRef.current?.focus({ preventScroll: true });
45
- }
46
41
  justMounted.current = false;
47
42
  }, [userActiveIndex]);
48
43
  const [slideCount, setSlideCount] = React.useState(0);
49
- const [keysPressed, setKeysPressed] = React.useState({});
50
- const handleKeyDown = (event) => {
51
- if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
52
- return;
53
- }
54
- const key = event.key;
55
- if (key === 'ArrowLeft' || key === 'ArrowRight') {
56
- setKeysPressed((old) => ({ ...old, [key]: true }));
57
- }
58
- };
59
- const handleKeyUp = (event) => {
60
- switch (event.key) {
61
- case 'ArrowLeft': {
62
- setKeysPressed((old) => ({ ...old, ArrowLeft: false }));
63
- const prevIndex = (slideCount + currentIndex - 1) % slideCount;
64
- scrollToSlide.current(prevIndex);
65
- setCurrentIndex(prevIndex);
66
- break;
67
- }
68
- case 'ArrowRight': {
69
- setKeysPressed((old) => ({ ...old, ArrowRight: false }));
70
- const nextIndex = (slideCount + currentIndex + 1) % slideCount;
71
- scrollToSlide.current(nextIndex);
72
- setCurrentIndex(nextIndex);
73
- break;
74
- }
75
- }
76
- };
77
44
  const userOnSlideChange = (0, index_js_1.useLatestRef)(onSlideChange);
78
45
  React.useEffect(() => {
79
46
  userOnSlideChange.current?.(currentIndex);
@@ -83,9 +50,6 @@ const CarouselComponent = React.forwardRef((props, ref) => {
83
50
  {
84
51
  as: 'section',
85
52
  'aria-roledescription': 'carousel',
86
- tabIndex: 0,
87
- onKeyDown: handleKeyDown,
88
- onKeyUp: handleKeyUp,
89
53
  ref: refs,
90
54
  className: (0, classnames_1.default)('iui-carousel', className),
91
55
  ...rest,
@@ -99,7 +63,6 @@ const CarouselComponent = React.forwardRef((props, ref) => {
99
63
  setCurrentIndex,
100
64
  slideCount,
101
65
  setSlideCount,
102
- keysPressed,
103
66
  idPrefix: id,
104
67
  isManuallyUpdating,
105
68
  scrollToSlide,
@@ -111,7 +74,8 @@ const CarouselComponent = React.forwardRef((props, ref) => {
111
74
  });
112
75
  /**
113
76
  * The Carousel component consists of a set of slides, normally displayed one at a time. A navigation section is
114
- * located below the slides, consisting of "dots" and "previous"/"next" buttons, used for changing slides.
77
+ * shown below the slides, consisting of "dots" and "previous"/"next" buttons, used for changing slides; this navigation
78
+ * section must be present _before_ the slides in DOM order, even though it is visually shown below the slides.
115
79
  *
116
80
  * The currently shown slide can also be changed using the left/right arrow keys or by dragging on a touch device.
117
81
  *
@@ -119,18 +83,24 @@ const CarouselComponent = React.forwardRef((props, ref) => {
119
83
  *
120
84
  * @example
121
85
  * <Carousel>
86
+ * <Carousel.Navigation />
122
87
  * <Carousel.Slider>
123
88
  * <Carousel.Slide>...</Carousel.Slide>
124
89
  * <Carousel.Slide>...</Carousel.Slide>
125
90
  * <Carousel.Slide>...</Carousel.Slide>
126
91
  * </Carousel.Slider>
127
- * <Carousel.Navigation />
128
92
  * </Carousel>
129
93
  */
130
94
  exports.Carousel = Object.assign(CarouselComponent, {
131
95
  Slider: CarouselSlider_js_1.CarouselSlider,
132
96
  Slide: CarouselSlide_js_1.CarouselSlide,
97
+ /**
98
+ * Contains the dots and previous/next buttons for navigating the slides. Must be present _before_ the slides in DOM.
99
+ */
133
100
  Navigation: CarouselNavigation_js_1.CarouselNavigation,
101
+ /**
102
+ * Contains the dots for activating the slides. Must be present _before_ the slides in DOM.
103
+ */
134
104
  DotsList: CarouselDotsList_js_1.CarouselDotsList,
135
105
  Dot: CarouselDot_js_1.CarouselDot,
136
106
  });
@@ -16,10 +16,6 @@ export declare const CarouselContext: React.Context<{
16
16
  * State updater for slideCount.
17
17
  */
18
18
  setSlideCount: (length: number | ((old: number) => void)) => void;
19
- /**
20
- * Stateful value of the left/right arrow keys currently pressed.
21
- */
22
- keysPressed: Record<string, boolean>;
23
19
  /**
24
20
  * Prefix used for setting id for internal carousel components.
25
21
  */
@@ -17,7 +17,7 @@ exports.CarouselDot = React.forwardRef((props, ref) => {
17
17
  const { isActive, isSmaller, isSmall, className, ...rest } = props;
18
18
  return React.createElement(index_js_1.ButtonBase, {
19
19
  role: 'tab',
20
- tabIndex: -1,
20
+ tabIndex: isActive ? 0 : -1,
21
21
  className: (0, classnames_1.default)(
22
22
  'iui-carousel-navigation-dot',
23
23
  {
@@ -53,6 +53,7 @@ exports.CarouselDotsList = React.forwardRef((props, ref) => {
53
53
  context.setCurrentIndex(index);
54
54
  context.scrollToSlide.current(index);
55
55
  }
56
+ listRef.current?.children[index]?.focus();
56
57
  onSlideChange?.(index);
57
58
  },
58
59
  [context, onSlideChange],
@@ -105,13 +106,12 @@ exports.CarouselDotsList = React.forwardRef((props, ref) => {
105
106
  index < firstVisibleDotIndex || index > lastVisibleDotIndex;
106
107
  return React.createElement(CarouselDot_js_1.CarouselDot, {
107
108
  key: index,
108
- 'aria-label': `Slide ${index}`,
109
+ 'aria-label': `Slide ${index + 1}`,
109
110
  isActive: index === currentIndex,
110
111
  onClick: () => handleSlideChange(index),
111
112
  isSmall: isSecondSmallDot,
112
113
  isSmaller: isFirstSmallDot || isClipped,
113
114
  id: idPrefix && `${idPrefix}--dot-${index}`,
114
- 'aria-controls': idPrefix && `${idPrefix}--slide-${index}`,
115
115
  });
116
116
  });
117
117
  }, [
@@ -138,6 +138,27 @@ exports.CarouselDotsList = React.forwardRef((props, ref) => {
138
138
  justMounted.current = false;
139
139
  }
140
140
  }, [currentIndex, firstVisibleDotIndex, slideCount, visibleCount, width]);
141
+ const handleKeyDown = (event) => {
142
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
143
+ return;
144
+ }
145
+ const key = event.key;
146
+ if (key === 'ArrowLeft' || key === 'ArrowRight') {
147
+ event.preventDefault();
148
+ }
149
+ };
150
+ const handleKeyUp = (event) => {
151
+ switch (event.key) {
152
+ case 'ArrowLeft': {
153
+ handleSlideChange((slideCount + currentIndex - 1) % slideCount);
154
+ break;
155
+ }
156
+ case 'ArrowRight': {
157
+ handleSlideChange((slideCount + currentIndex + 1) % slideCount);
158
+ break;
159
+ }
160
+ }
161
+ };
141
162
  return React.createElement(
142
163
  React.Fragment,
143
164
  null,
@@ -151,6 +172,9 @@ exports.CarouselDotsList = React.forwardRef((props, ref) => {
151
172
  role: 'tablist',
152
173
  'aria-label': 'Slides',
153
174
  ref: refs,
175
+ onKeyDown: handleKeyDown,
176
+ onKeyUp: handleKeyUp,
177
+ tabIndex: -1,
154
178
  ...rest,
155
179
  },
156
180
  children ?? dots,
@@ -6,7 +6,7 @@ import type { PolymorphicForwardRefComponent } from '../utils/index.js';
6
6
  *
7
7
  * `children` can be specified to override what is shown in this navigation section.
8
8
  */
9
- export declare const CarouselNavigation: PolymorphicForwardRefComponent<"nav", {}> & {
9
+ export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {}> & {
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
12
  }, "label" | "as" | "size" | "htmlDisabled" | "styleType" | "isActive" | "iconProps"> & {
@@ -17,7 +17,6 @@ const CarouselNavigationComponent = React.forwardRef((props, ref) => {
17
17
  return React.createElement(
18
18
  index_js_1.Box,
19
19
  {
20
- as: 'nav',
21
20
  className: (0, classnames_1.default)(
22
21
  'iui-carousel-navigation',
23
22
  className,
@@ -49,20 +48,14 @@ const PreviousButton = React.forwardRef((props, ref) => {
49
48
  if (!context) {
50
49
  throw new Error('CarouselNavigation should be used inside Carousel');
51
50
  }
52
- const {
53
- slideCount,
54
- currentIndex,
55
- setCurrentIndex,
56
- keysPressed,
57
- scrollToSlide,
58
- } = context;
51
+ const { slideCount, currentIndex, setCurrentIndex, scrollToSlide } = context;
59
52
  return React.createElement(
60
53
  IconButton_js_1.IconButton,
61
54
  {
62
55
  styleType: 'borderless',
63
56
  size: 'small',
64
57
  tabIndex: -1,
65
- 'data-pressed': keysPressed['ArrowLeft'] || undefined,
58
+ 'aria-label': 'Previous',
66
59
  ref: ref,
67
60
  ...props,
68
61
  onClick: (e) => {
@@ -81,20 +74,14 @@ const NextButton = React.forwardRef((props, ref) => {
81
74
  if (!context) {
82
75
  throw new Error('CarouselNavigation should be used inside Carousel');
83
76
  }
84
- const {
85
- slideCount,
86
- currentIndex,
87
- setCurrentIndex,
88
- keysPressed,
89
- scrollToSlide,
90
- } = context;
77
+ const { slideCount, currentIndex, setCurrentIndex, scrollToSlide } = context;
91
78
  return React.createElement(
92
79
  IconButton_js_1.IconButton,
93
80
  {
94
81
  styleType: 'borderless',
95
82
  size: 'small',
96
83
  tabIndex: -1,
97
- 'data-pressed': keysPressed['ArrowRight'] || undefined,
84
+ 'aria-label': 'Next',
98
85
  ref: ref,
99
86
  ...props,
100
87
  onClick: (e) => {
@@ -12,5 +12,5 @@ type CarouselSlideProps = {
12
12
  * It is recommended that the slide content bring its own dimensions (esp. height) and that
13
13
  * the dimensions should be the same for all slides.
14
14
  */
15
- export declare const CarouselSlide: PolymorphicForwardRefComponent<"li", CarouselSlideProps>;
15
+ export declare const CarouselSlide: PolymorphicForwardRefComponent<"div", CarouselSlideProps>;
16
16
  export {};
@@ -22,7 +22,7 @@ exports.CarouselSlide = React.forwardRef((props, ref) => {
22
22
  if (!context || index == null) {
23
23
  throw new Error('CarouselSlide must be used within Carousel');
24
24
  }
25
- const { isManuallyUpdating, setCurrentIndex } = context;
25
+ const { isManuallyUpdating, currentIndex, setCurrentIndex } = context;
26
26
  const updateActiveIndexOnScroll = React.useCallback(() => {
27
27
  // only update index if scroll was triggered by browser
28
28
  if (!isManuallyUpdating.current) {
@@ -38,15 +38,25 @@ exports.CarouselSlide = React.forwardRef((props, ref) => {
38
38
  return React.createElement(
39
39
  index_js_1.Box,
40
40
  {
41
- as: 'li',
42
41
  className: (0, classnames_1.default)(
43
42
  'iui-carousel-slider-item',
44
43
  className,
45
44
  ),
46
45
  role: 'tabpanel',
47
46
  'aria-roledescription': 'slide',
47
+ tabIndex: index === currentIndex ? 0 : undefined,
48
48
  ref: refs,
49
+ inert: index !== currentIndex ? '' : undefined,
49
50
  ...rest,
51
+ onKeyDown: (0, index_js_1.mergeEventHandlers)(
52
+ props.onKeyDown,
53
+ (event) => {
54
+ // prevent default browser scrolling on arrow keys because focus will get lost when slide switches
55
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
56
+ event.preventDefault();
57
+ }
58
+ },
59
+ ),
50
60
  },
51
61
  children,
52
62
  );
@@ -2,4 +2,4 @@ import type { PolymorphicForwardRefComponent } from '../utils/index.js';
2
2
  /**
3
3
  * `CarouselSlider` is the scrollable list that should consist of `CarouselSlide` components.
4
4
  */
5
- export declare const CarouselSlider: PolymorphicForwardRefComponent<"ol", {}>;
5
+ export declare const CarouselSlider: PolymorphicForwardRefComponent<"div", {}>;
@@ -27,6 +27,7 @@ exports.CarouselSlider = React.forwardRef((props, ref) => {
27
27
  React.isValidElement(child)
28
28
  ? React.cloneElement(child, {
29
29
  id: `${idPrefix}--slide-${index}`,
30
+ 'aria-labelledby': `${idPrefix}--dot-${index}`,
30
31
  index,
31
32
  })
32
33
  : child,
@@ -65,11 +66,10 @@ exports.CarouselSlider = React.forwardRef((props, ref) => {
65
66
  return React.createElement(
66
67
  index_js_1.Box,
67
68
  {
68
- as: 'ol',
69
- 'aria-live': 'polite',
70
69
  className: (0, classnames_1.default)('iui-carousel-slider', className),
71
70
  ref: refs,
72
71
  onScroll: handleOnScroll,
72
+ tabIndex: -1,
73
73
  ...rest,
74
74
  },
75
75
  items,
@@ -282,6 +282,7 @@ exports.ColorBuilder = React.forwardRef((props, ref) => {
282
282
  },
283
283
  min: 0,
284
284
  max: 359,
285
+ thumbProps: () => ({ 'aria-label': 'Hue' }),
285
286
  }),
286
287
  showAlpha &&
287
288
  React.createElement(Slider_js_1.Slider, {
@@ -303,6 +304,7 @@ exports.ColorBuilder = React.forwardRef((props, ref) => {
303
304
  style: {
304
305
  '--iui-color-picker-selected-color': hueColorString,
305
306
  },
307
+ thumbProps: () => ({ 'aria-label': 'Opacity' }),
306
308
  }),
307
309
  );
308
310
  });
@@ -144,6 +144,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
144
144
  maxLength: showAlpha ? 9 : 7,
145
145
  minLength: 1,
146
146
  placeholder: 'HEX',
147
+ 'aria-label': 'Hex',
147
148
  value: input[0],
148
149
  onChange: (event) => {
149
150
  const value = event.target.value.startsWith('#')
@@ -173,6 +174,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
173
174
  max: '359',
174
175
  step: '.1',
175
176
  placeholder: 'H',
177
+ 'aria-label': 'Hue',
176
178
  value: input[0] ?? '',
177
179
  onChange: (event) => {
178
180
  setInput([event.target.value, input[1], input[2], input[3]]);
@@ -199,6 +201,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
199
201
  max: '100',
200
202
  step: '.1',
201
203
  placeholder: 'S',
204
+ 'aria-label': 'Saturation',
202
205
  value: input[1] ?? '',
203
206
  onChange: (event) => {
204
207
  setInput([input[0], event.target.value, input[2], input[3]]);
@@ -225,6 +228,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
225
228
  max: '100',
226
229
  step: '.1',
227
230
  placeholder: 'L',
231
+ 'aria-label': 'Lightness',
228
232
  value: input[2] ?? '',
229
233
  onChange: (event) => {
230
234
  setInput([input[0], input[1], event.target.value, input[3]]);
@@ -252,6 +256,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
252
256
  max: '1',
253
257
  step: '.01',
254
258
  placeholder: 'A',
259
+ 'aria-label': 'Alpha',
255
260
  value: input[3] ?? '',
256
261
  onChange: (event) => {
257
262
  setInput([input[0], input[1], input[2], event.target.value]);
@@ -281,6 +286,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
281
286
  min: '0',
282
287
  max: '255',
283
288
  placeholder: 'R',
289
+ 'aria-label': 'Red',
284
290
  value: input[0] ?? '',
285
291
  onChange: (event) => {
286
292
  setInput([event.target.value, input[1], input[2], input[3]]);
@@ -306,6 +312,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
306
312
  min: '0',
307
313
  max: '255',
308
314
  placeholder: 'G',
315
+ 'aria-label': 'Green',
309
316
  value: input[1] ?? '',
310
317
  onChange: (event) => {
311
318
  setInput([input[0], event.target.value, input[2], input[3]]);
@@ -331,6 +338,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
331
338
  min: '0',
332
339
  max: '255',
333
340
  placeholder: 'B',
341
+ 'aria-label': 'Blue',
334
342
  value: input[2] ?? '',
335
343
  onChange: (event) => {
336
344
  setInput([input[0], input[1], event.target.value, input[3]]);
@@ -358,6 +366,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
358
366
  max: '1',
359
367
  step: '.01',
360
368
  placeholder: 'A',
369
+ 'aria-label': 'Alpha',
361
370
  value: input[3] ?? '',
362
371
  onChange: (event) => {
363
372
  setInput([input[0], input[1], input[2], event.target.value]);
@@ -378,6 +387,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
378
387
  Number(input[3]) < 0 || Number(input[3]) > 1 ? 'negative' : undefined,
379
388
  }),
380
389
  );
390
+ const labelId = (0, index_js_1.useId)();
381
391
  return React.createElement(
382
392
  index_js_1.Box,
383
393
  {
@@ -390,8 +400,8 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
390
400
  },
391
401
  React.createElement(
392
402
  index_js_1.Box,
393
- { className: 'iui-color-picker-section-label' },
394
- showAlpha && currentFormat != 'hex'
403
+ { className: 'iui-color-picker-section-label', id: labelId },
404
+ showAlpha && currentFormat !== 'hex'
395
405
  ? currentFormat.toUpperCase() + 'A'
396
406
  : currentFormat.toUpperCase(),
397
407
  ),
@@ -401,12 +411,22 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
401
411
  allowedColorFormats.length > 1 &&
402
412
  React.createElement(
403
413
  IconButton_js_1.IconButton,
404
- { styleType: 'borderless', onClick: swapColorFormat, size: 'small' },
414
+ {
415
+ styleType: 'borderless',
416
+ onClick: swapColorFormat,
417
+ size: 'small',
418
+ label: 'Switch format',
419
+ },
405
420
  React.createElement(index_js_1.SvgSwap, null),
406
421
  ),
407
422
  React.createElement(
408
423
  index_js_1.Box,
409
- { ref: inputsContainerRef, className: 'iui-color-input-fields' },
424
+ {
425
+ ref: inputsContainerRef,
426
+ className: 'iui-color-input-fields',
427
+ role: currentFormat !== 'hex' ? 'group' : undefined,
428
+ 'aria-labelledby': currentFormat !== 'hex' ? labelId : undefined,
429
+ },
410
430
  currentFormat === 'hex' && hexInputField,
411
431
  currentFormat === 'rgb' && rgbInputs,
412
432
  currentFormat === 'hsl' && hslInputs,
@@ -27,79 +27,6 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
27
27
  const { colors, label, className, children, ...rest } = props;
28
28
  const { activeColor, setActiveColor, onChangeComplete } = (0,
29
29
  ColorPickerContext_js_1.useColorPickerContext)();
30
- const [focusedIndex, setFocusedIndex] = React.useState();
31
- // callback ref to set tabindex=0 on first child if none of the swatches are tabbable
32
- const setDefaultTabIndex = (el) => {
33
- if (el && !el.querySelector('[tabindex="0"]')) {
34
- el.firstElementChild?.setAttribute('tabindex', '0');
35
- }
36
- };
37
- const paletteRef = React.useRef(null);
38
- const paletteRefs = (0, index_js_1.useMergedRefs)(
39
- paletteRef,
40
- setDefaultTabIndex,
41
- );
42
- // Color palette arrow key navigation
43
- const handleKeyDown = (event) => {
44
- if (event.altKey) {
45
- return;
46
- }
47
- const swatches = (0, index_js_1.getFocusableElements)(paletteRef.current);
48
- if (!swatches.length) {
49
- return;
50
- }
51
- const currentIndex = swatches.findIndex(
52
- (swatch) => swatch === paletteRef.current?.ownerDocument.activeElement,
53
- );
54
- if (currentIndex < 0) {
55
- return;
56
- }
57
- let newIndex = -1;
58
- switch (event.key) {
59
- case 'ArrowDown': {
60
- // Look for next ColorSwatch with same offsetLeft value
61
- newIndex = swatches.findIndex(
62
- (swatch, index) =>
63
- index > currentIndex &&
64
- swatch.offsetLeft === swatches[currentIndex].offsetLeft,
65
- );
66
- break;
67
- }
68
- case 'ArrowUp': {
69
- // Look backwards for next ColorSwatch with same offsetLeft value
70
- for (let i = currentIndex - 1; i >= 0; i--) {
71
- if (swatches[i].offsetLeft === swatches[currentIndex].offsetLeft) {
72
- newIndex = i;
73
- break;
74
- }
75
- }
76
- break;
77
- }
78
- case 'ArrowLeft':
79
- newIndex = Math.max(currentIndex - 1, 0);
80
- break;
81
- case 'ArrowRight':
82
- newIndex = Math.min(currentIndex + 1, swatches.length - 1);
83
- break;
84
- case 'Enter':
85
- case ' ':
86
- case 'Spacebar':
87
- swatches[currentIndex].click();
88
- event.preventDefault();
89
- return;
90
- }
91
- if (newIndex >= 0 && newIndex < swatches.length) {
92
- setFocusedIndex(newIndex);
93
- event.preventDefault();
94
- }
95
- };
96
- // call focus() when focusedIndex changes
97
- React.useEffect(() => {
98
- if (focusedIndex != null) {
99
- const swatches = (0, index_js_1.getFocusableElements)(paletteRef.current);
100
- swatches[focusedIndex]?.focus();
101
- }
102
- }, [focusedIndex]);
103
30
  return React.createElement(
104
31
  index_js_1.Box,
105
32
  {
@@ -118,11 +45,7 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
118
45
  ),
119
46
  React.createElement(
120
47
  index_js_1.Box,
121
- {
122
- className: 'iui-color-palette',
123
- onKeyDown: handleKeyDown,
124
- ref: paletteRefs,
125
- },
48
+ { className: 'iui-color-palette' },
126
49
  children,
127
50
  colors &&
128
51
  colors.map((_color, index) => {
@@ -130,8 +53,7 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
130
53
  return React.createElement(ColorSwatch_js_1.ColorSwatch, {
131
54
  key: index,
132
55
  color: color,
133
- onClick: (event) => {
134
- event.preventDefault();
56
+ onClick: () => {
135
57
  onChangeComplete?.(color);
136
58
  setActiveColor(color);
137
59
  },
@@ -16,5 +16,5 @@ type ColorSwatchProps = {
16
16
  * <ColorSwatch color='#23450b' onClick={onClick}/>
17
17
  * <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
18
18
  */
19
- export declare const ColorSwatch: PolymorphicForwardRefComponent<"div", ColorSwatchProps>;
19
+ export declare const ColorSwatch: PolymorphicForwardRefComponent<"button", ColorSwatchProps>;
20
20
  export default ColorSwatch;