@itwin/itwinui-react 1.37.3 → 1.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/cjs/core/Breadcrumbs/Breadcrumbs.js +3 -5
  3. package/cjs/core/Carousel/Carousel.js +21 -12
  4. package/cjs/core/Carousel/CarouselContext.d.ts +4 -2
  5. package/cjs/core/Carousel/CarouselDotsList.js +1 -0
  6. package/cjs/core/Carousel/CarouselNavigation.js +8 -10
  7. package/cjs/core/Carousel/CarouselSlide.js +3 -7
  8. package/cjs/core/Carousel/CarouselSlider.js +23 -28
  9. package/cjs/core/ColorPicker/ColorPickerContext.d.ts +2 -2
  10. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  11. package/cjs/core/ComboBox/ComboBox.d.ts +11 -2
  12. package/cjs/core/ComboBox/ComboBox.js +138 -246
  13. package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +7 -0
  14. package/cjs/core/ComboBox/ComboBoxDropdown.js +55 -0
  15. package/cjs/core/ComboBox/ComboBoxEndIcon.d.ts +5 -0
  16. package/cjs/core/ComboBox/ComboBoxEndIcon.js +54 -0
  17. package/cjs/core/ComboBox/ComboBoxInput.d.ts +5 -0
  18. package/cjs/core/ComboBox/ComboBoxInput.js +152 -0
  19. package/cjs/core/ComboBox/ComboBoxInputContainer.d.ts +8 -0
  20. package/cjs/core/ComboBox/ComboBoxInputContainer.js +45 -0
  21. package/cjs/core/ComboBox/ComboBoxMenu.d.ts +3 -0
  22. package/cjs/core/ComboBox/ComboBoxMenu.js +89 -0
  23. package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +21 -0
  24. package/cjs/core/ComboBox/ComboBoxMenuItem.js +64 -0
  25. package/cjs/core/ComboBox/helpers.d.ts +32 -0
  26. package/cjs/core/ComboBox/helpers.js +50 -0
  27. package/cjs/core/DatePicker/DatePicker.d.ts +1 -1
  28. package/cjs/core/Modal/Modal.d.ts +1 -1
  29. package/cjs/core/Modal/Modal.js +6 -6
  30. package/cjs/core/Modal/ModalButtonBar.d.ts +1 -1
  31. package/cjs/core/Modal/ModalButtonBar.js +2 -2
  32. package/cjs/core/Modal/ModalContent.d.ts +1 -1
  33. package/cjs/core/Modal/ModalContent.js +2 -2
  34. package/cjs/core/RadioTiles/RadioTile.d.ts +1 -1
  35. package/cjs/core/RadioTiles/RadioTile.js +7 -9
  36. package/cjs/core/Select/Select.js +1 -1
  37. package/cjs/core/Table/Table.js +33 -23
  38. package/cjs/core/Table/TablePaginator.js +1 -1
  39. package/cjs/core/Table/filters/FilterToggle.js +3 -2
  40. package/cjs/core/Table/filters/tableFilters.d.ts +3 -3
  41. package/cjs/core/Table/hooks/useExpanderCell.js +11 -1
  42. package/cjs/core/Toast/ToastWrapper.d.ts +7 -5
  43. package/cjs/core/Toast/ToastWrapper.js +8 -4
  44. package/cjs/core/Toast/Toaster.d.ts +3 -0
  45. package/cjs/core/Toast/Toaster.js +110 -6
  46. package/cjs/core/utils/components/Popover.d.ts +1 -18
  47. package/cjs/core/utils/components/VirtualScroll.d.ts +35 -1
  48. package/cjs/core/utils/components/VirtualScroll.js +159 -26
  49. package/cjs/core/utils/components/WithCSSTransition.d.ts +1 -2
  50. package/cjs/core/utils/components/icons.d.ts +4 -4
  51. package/cjs/core/utils/hooks/index.d.ts +1 -0
  52. package/cjs/core/utils/hooks/index.js +1 -0
  53. package/cjs/core/utils/hooks/useOverflow.js +4 -2
  54. package/cjs/core/utils/hooks/useSafeContext.d.ts +6 -0
  55. package/cjs/core/utils/hooks/useSafeContext.js +23 -0
  56. package/cjs/core/utils/hooks/useTheme.d.ts +1 -1
  57. package/esm/core/Breadcrumbs/Breadcrumbs.js +3 -5
  58. package/esm/core/Carousel/Carousel.js +21 -12
  59. package/esm/core/Carousel/CarouselContext.d.ts +4 -2
  60. package/esm/core/Carousel/CarouselDotsList.js +1 -0
  61. package/esm/core/Carousel/CarouselNavigation.js +8 -10
  62. package/esm/core/Carousel/CarouselSlide.js +3 -7
  63. package/esm/core/Carousel/CarouselSlider.js +24 -29
  64. package/esm/core/ColorPicker/ColorPickerContext.d.ts +2 -2
  65. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  66. package/esm/core/ComboBox/ComboBox.d.ts +11 -2
  67. package/esm/core/ComboBox/ComboBox.js +140 -248
  68. package/esm/core/ComboBox/ComboBoxDropdown.d.ts +7 -0
  69. package/esm/core/ComboBox/ComboBoxDropdown.js +49 -0
  70. package/esm/core/ComboBox/ComboBoxEndIcon.d.ts +5 -0
  71. package/esm/core/ComboBox/ComboBoxEndIcon.js +48 -0
  72. package/esm/core/ComboBox/ComboBoxInput.d.ts +5 -0
  73. package/esm/core/ComboBox/ComboBoxInput.js +146 -0
  74. package/esm/core/ComboBox/ComboBoxInputContainer.d.ts +8 -0
  75. package/esm/core/ComboBox/ComboBoxInputContainer.js +38 -0
  76. package/esm/core/ComboBox/ComboBoxMenu.d.ts +3 -0
  77. package/esm/core/ComboBox/ComboBoxMenu.js +83 -0
  78. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +21 -0
  79. package/esm/core/ComboBox/ComboBoxMenuItem.js +58 -0
  80. package/esm/core/ComboBox/helpers.d.ts +32 -0
  81. package/esm/core/ComboBox/helpers.js +43 -0
  82. package/esm/core/DatePicker/DatePicker.d.ts +1 -1
  83. package/esm/core/Modal/Modal.d.ts +1 -1
  84. package/esm/core/Modal/Modal.js +6 -6
  85. package/esm/core/Modal/ModalButtonBar.d.ts +1 -1
  86. package/esm/core/Modal/ModalButtonBar.js +2 -2
  87. package/esm/core/Modal/ModalContent.d.ts +1 -1
  88. package/esm/core/Modal/ModalContent.js +2 -2
  89. package/esm/core/RadioTiles/RadioTile.d.ts +1 -1
  90. package/esm/core/RadioTiles/RadioTile.js +7 -9
  91. package/esm/core/Select/Select.js +1 -1
  92. package/esm/core/Table/Table.js +33 -23
  93. package/esm/core/Table/TablePaginator.js +1 -1
  94. package/esm/core/Table/filters/FilterToggle.js +3 -2
  95. package/esm/core/Table/filters/tableFilters.d.ts +3 -3
  96. package/esm/core/Table/hooks/useExpanderCell.js +8 -1
  97. package/esm/core/Toast/ToastWrapper.d.ts +7 -5
  98. package/esm/core/Toast/ToastWrapper.js +8 -3
  99. package/esm/core/Toast/Toaster.d.ts +3 -0
  100. package/esm/core/Toast/Toaster.js +88 -7
  101. package/esm/core/utils/components/Popover.d.ts +1 -18
  102. package/esm/core/utils/components/VirtualScroll.d.ts +35 -1
  103. package/esm/core/utils/components/VirtualScroll.js +157 -25
  104. package/esm/core/utils/components/WithCSSTransition.d.ts +1 -2
  105. package/esm/core/utils/components/icons.d.ts +4 -4
  106. package/esm/core/utils/hooks/index.d.ts +1 -0
  107. package/esm/core/utils/hooks/index.js +1 -0
  108. package/esm/core/utils/hooks/useOverflow.js +4 -2
  109. package/esm/core/utils/hooks/useSafeContext.d.ts +6 -0
  110. package/esm/core/utils/hooks/useSafeContext.js +16 -0
  111. package/esm/core/utils/hooks/useTheme.d.ts +1 -1
  112. package/package.json +27 -70
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.39.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.38.0...v1.39.0) (2022-06-03)
4
+
5
+ ### What's new
6
+
7
+ * Add support of react 18 ([#656](https://www.github.com/iTwin/iTwinUI-react/issues/656)) ([b7a4c7b](https://www.github.com/iTwin/iTwinUI-react/commit/b7a4c7ba1e26445308dcb7f1fd5a374743de4e6f))
8
+ * **Combobox:** Virtualization ([#539](https://www.github.com/iTwin/iTwinUI-react/issues/539)) ([9e93871](https://www.github.com/iTwin/iTwinUI-react/commit/9e93871c59935a39f6ee1d633d96df04b78f33a1))
9
+
10
+ ### Fixes
11
+
12
+ * **Carousel:** Use event handler instead of useEffect for scroll ([#683](https://www.github.com/iTwin/iTwinUI-react/issues/683)) ([bcf125b](https://www.github.com/iTwin/iTwinUI-react/commit/bcf125be76495352a06c063bc7a0d5d2a884c860))
13
+ * **Toaster:** Fix inital position setting ([#687](https://www.github.com/iTwin/iTwinUI-react/issues/687)) ([c58b747](https://www.github.com/iTwin/iTwinUI-react/commit/c58b74786bf90a165993afb2eec926f74b37a1eb))
14
+
15
+ ### [1.38.1](https://www.github.com/iTwin/iTwinUI-react/compare/v1.38.0...v1.38.1) (2022-05-23)
16
+
17
+ ### Fixes
18
+
19
+ * **Toaster:** Fix initial position setting ([#687](https://www.github.com/iTwin/iTwinUI-react/issues/687)) ([c58b747](https://www.github.com/iTwin/iTwinUI-react/commit/c58b74786bf90a165993afb2eec926f74b37a1eb))
20
+
21
+ ## [1.38.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.37.3...v1.38.0) (2022-05-23)
22
+
23
+ ### What's new
24
+
25
+ * **ComboBox:** Full component refactor to improve performance by using components composition ([#618](https://www.github.com/iTwin/iTwinUI-react/issues/618)) ([5d56809](https://www.github.com/iTwin/iTwinUI-react/commit/5d56809c46ad312402669f9cb2dbf6c8d3c733ad))
26
+
27
+ ### Fixes
28
+
29
+ * **Table:** Allow 'false' as valid filter value ([#664](https://www.github.com/iTwin/iTwinUI-react/issues/664)) ([628cc26](https://www.github.com/iTwin/iTwinUI-react/commit/628cc26afc044e1b3f1c09b2489b31fe15b34de1))
30
+ * **Toaster:** Do not call `ReactDOM` render multiple times ([#667](https://www.github.com/iTwin/iTwinUI-react/issues/667)) ([195a857](https://www.github.com/iTwin/iTwinUI-react/commit/195a8573157ce6588e0edb40569770ffa4636584))
31
+ * Visuals changes after CSS update ([#678](https://www.github.com/iTwin/iTwinUI-react/issues/678)) ([16b9310](https://www.github.com/iTwin/iTwinUI-react/commit/16b93106c8d3787cc3f6bdee469604db6167ccf0))
32
+ - **Select:** Arrow color
33
+ - **Tabs:** Description color
34
+ - **Skeleton:** Background color
35
+ - **Checkbox:** Add border to disabled state
36
+
3
37
  ### [1.37.3](https://www.github.com/iTwin/iTwinUI-react/compare/v1.37.2...v1.37.3) (2022-05-06)
4
38
 
5
39
  ### Fixes
@@ -67,9 +67,7 @@ exports.Breadcrumbs = react_1.default.forwardRef(function (props, ref) {
67
67
  var _b;
68
68
  var index = _a.index;
69
69
  var item = items[index];
70
- return (react_1.default.createElement("li", { className: (0, classnames_1.default)('iui-breadcrumbs-item', {
71
- 'iui-current': currentIndex === index,
72
- }) }, react_1.default.isValidElement(item)
70
+ return (react_1.default.createElement("li", { className: 'iui-breadcrumbs-item iui-breadcrumbs-item-overrides' }, react_1.default.isValidElement(item)
73
71
  ? react_1.default.cloneElement(item, {
74
72
  'aria-current': ((_b = item.props['aria-current']) !== null && _b !== void 0 ? _b : currentIndex === index)
75
73
  ? 'location'
@@ -83,8 +81,8 @@ exports.Breadcrumbs = react_1.default.forwardRef(function (props, ref) {
83
81
  react_1.default.createElement(ListItem, { index: 0 }),
84
82
  react_1.default.createElement(Separator, null))),
85
83
  items.length - visibleCount > 0 && (react_1.default.createElement(react_1.default.Fragment, null,
86
- react_1.default.createElement("li", { className: 'iui-breadcrumbs-item' },
87
- react_1.default.createElement("span", null, "\u2026")),
84
+ react_1.default.createElement("li", { className: 'iui-breadcrumbs-item iui-breadcrumbs-item-overrides' },
85
+ react_1.default.createElement("span", { className: 'iui-breadcrumbs-text' }, "\u2026")),
88
86
  react_1.default.createElement(Separator, null))),
89
87
  items
90
88
  .slice(visibleCount > 1
@@ -64,19 +64,24 @@ exports.Carousel = Object.assign(react_1.default.forwardRef(function (props, ref
64
64
  var id = react_1.default.useState(function () { var _a; return (_a = props.id) !== null && _a !== void 0 ? _a : "iui-carousel-".concat((0, utils_1.getRandomValue)(10)); })[0];
65
65
  (0, utils_1.useTheme)();
66
66
  var isManuallyUpdating = react_1.default.useRef(false);
67
- var scrollInstantly = react_1.default.useRef(false);
68
67
  var carouselRef = react_1.default.useRef(null);
69
68
  var refs = (0, utils_1.useMergedRefs)(carouselRef, ref);
70
- var _b = react_1.default.useState(userActiveIndex), currentIndex = _b[0], _setCurrentIndex = _b[1];
69
+ var _b = react_1.default.useState(userActiveIndex), currentIndex = _b[0], setCurrentIndex = _b[1];
70
+ var scrollToSlide = react_1.default.useRef(function () { }); // stub function populated in CarouselSlider
71
+ var justMounted = react_1.default.useRef(true);
71
72
  react_1.default.useEffect(function () {
72
- _setCurrentIndex(userActiveIndex);
73
- }, [userActiveIndex]);
74
- var setCurrentIndex = react_1.default.useCallback(function (index) {
75
73
  var _a;
76
- _setCurrentIndex(index);
77
- isManuallyUpdating.current = true;
78
- (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.focus();
79
- }, []);
74
+ setCurrentIndex(userActiveIndex);
75
+ scrollToSlide.current(userActiveIndex, {
76
+ instant: justMounted.current,
77
+ });
78
+ // re-focus the carousel for keyboard nav, but not on first mount
79
+ // because it shows outline and might interfere with other components
80
+ if (!justMounted.current) {
81
+ (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
82
+ }
83
+ justMounted.current = false;
84
+ }, [userActiveIndex]);
80
85
  var _c = react_1.default.useState(0), slideCount = _c[0], setSlideCount = _c[1];
81
86
  var _d = react_1.default.useState({}), keysPressed = _d[0], setKeysPressed = _d[1];
82
87
  var handleKeyDown = function (event) {
@@ -94,12 +99,16 @@ exports.Carousel = Object.assign(react_1.default.forwardRef(function (props, ref
94
99
  switch (event.key) {
95
100
  case 'ArrowLeft': {
96
101
  setKeysPressed(function (old) { return (__assign(__assign({}, old), { ArrowLeft: false })); });
97
- setCurrentIndex(function (old) { return (slideCount + old - 1) % slideCount; });
102
+ var prevIndex = (slideCount + currentIndex - 1) % slideCount;
103
+ scrollToSlide.current(prevIndex);
104
+ setCurrentIndex(prevIndex);
98
105
  break;
99
106
  }
100
107
  case 'ArrowRight': {
101
108
  setKeysPressed(function (old) { return (__assign(__assign({}, old), { ArrowRight: false })); });
102
- setCurrentIndex(function (old) { return (slideCount + old + 1) % slideCount; });
109
+ var nextIndex = (slideCount + currentIndex + 1) % slideCount;
110
+ scrollToSlide.current(nextIndex);
111
+ setCurrentIndex(nextIndex);
103
112
  break;
104
113
  }
105
114
  }
@@ -118,7 +127,7 @@ exports.Carousel = Object.assign(react_1.default.forwardRef(function (props, ref
118
127
  keysPressed: keysPressed,
119
128
  idPrefix: id,
120
129
  isManuallyUpdating: isManuallyUpdating,
121
- scrollInstantly: scrollInstantly,
130
+ scrollToSlide: scrollToSlide,
122
131
  } }, children)));
123
132
  }), {
124
133
  Slider: CarouselSlider_1.CarouselSlider,
@@ -31,7 +31,9 @@ export declare const CarouselContext: React.Context<{
31
31
  */
32
32
  isManuallyUpdating: React.MutableRefObject<boolean>;
33
33
  /**
34
- * Ref object used to skip smooth scrolling when button is clicked too many times.
34
+ * Function that scrolls to the current slide. Should be called on all managed events (clicks and keydowns).
35
35
  */
36
- scrollInstantly: React.MutableRefObject<boolean>;
36
+ scrollToSlide: React.MutableRefObject<(slideIndex: number, options?: {
37
+ instant?: boolean;
38
+ }) => void>;
37
39
  } | undefined>;
@@ -69,6 +69,7 @@ exports.CarouselDotsList = react_1.default.forwardRef(function (props, ref) {
69
69
  var handleSlideChange = react_1.default.useCallback(function (index) {
70
70
  if (context) {
71
71
  context.setCurrentIndex(index);
72
+ context.scrollToSlide.current(index);
72
73
  }
73
74
  onSlideChange === null || onSlideChange === void 0 ? void 0 : onSlideChange(index);
74
75
  }, [context, onSlideChange]);
@@ -43,13 +43,12 @@ var PreviousButton = react_1.default.forwardRef(function (props, ref) {
43
43
  if (!context) {
44
44
  throw new Error('CarouselNavigation should be used inside Carousel');
45
45
  }
46
- var slideCount = context.slideCount, setCurrentIndex = context.setCurrentIndex, keysPressed = context.keysPressed, scrollInstantly = context.scrollInstantly;
46
+ var slideCount = context.slideCount, currentIndex = context.currentIndex, setCurrentIndex = context.setCurrentIndex, keysPressed = context.keysPressed, scrollToSlide = context.scrollToSlide;
47
47
  return (react_1.default.createElement(Buttons_1.IconButton, __assign({ styleType: 'borderless', size: 'small', tabIndex: -1, "data-pressed": keysPressed['ArrowLeft'] || undefined, ref: ref }, props, { onClick: function (e) {
48
48
  var _a;
49
- if (e.detail > 3) {
50
- scrollInstantly.current = true;
51
- }
52
- setCurrentIndex(function (old) { return (slideCount + old - 1) % slideCount; });
49
+ var prevIndex = (slideCount + currentIndex - 1) % slideCount;
50
+ setCurrentIndex(prevIndex);
51
+ scrollToSlide.current(prevIndex, { instant: e.detail > 3 });
53
52
  (_a = props === null || props === void 0 ? void 0 : props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
54
53
  } }),
55
54
  react_1.default.createElement(ChevronLeft_1.default, null)));
@@ -60,13 +59,12 @@ var NextButton = react_1.default.forwardRef(function (props, ref) {
60
59
  if (!context) {
61
60
  throw new Error('CarouselNavigation should be used inside Carousel');
62
61
  }
63
- var slideCount = context.slideCount, setCurrentIndex = context.setCurrentIndex, keysPressed = context.keysPressed, scrollInstantly = context.scrollInstantly;
62
+ var slideCount = context.slideCount, currentIndex = context.currentIndex, setCurrentIndex = context.setCurrentIndex, keysPressed = context.keysPressed, scrollToSlide = context.scrollToSlide;
64
63
  return (react_1.default.createElement(Buttons_1.IconButton, __assign({ styleType: 'borderless', size: 'small', tabIndex: -1, "data-pressed": keysPressed['ArrowRight'] || undefined, ref: ref }, props, { onClick: function (e) {
65
64
  var _a;
66
- if (e.detail > 3) {
67
- scrollInstantly.current = true;
68
- }
69
- setCurrentIndex(function (old) { return (slideCount + old + 1) % slideCount; });
65
+ var nextIndex = (slideCount + currentIndex + 1) % slideCount;
66
+ setCurrentIndex(nextIndex);
67
+ scrollToSlide.current(nextIndex, { instant: e.detail > 3 });
70
68
  (_a = props === null || props === void 0 ? void 0 : props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
71
69
  } }),
72
70
  react_1.default.createElement(ChevronRight_1.default, null)));
@@ -46,17 +46,13 @@ exports.CarouselSlide = react_1.default.forwardRef(function (props, ref) {
46
46
  if (!context || index == null) {
47
47
  throw new Error('CarouselSlide must be used within Carousel');
48
48
  }
49
- var currentIndex = context.currentIndex, isManuallyUpdating = context.isManuallyUpdating, setCurrentIndex = context.setCurrentIndex;
49
+ var isManuallyUpdating = context.isManuallyUpdating, setCurrentIndex = context.setCurrentIndex;
50
50
  var updateActiveIndexOnScroll = react_1.default.useCallback(function () {
51
51
  // only update index if scroll was triggered by browser
52
- if (!isManuallyUpdating.current && currentIndex !== index) {
52
+ if (!isManuallyUpdating.current) {
53
53
  setCurrentIndex(index);
54
54
  }
55
- // when manual scroll completes, reset the state of `isManuallyUpdating` so that it's ready for future actions
56
- if (currentIndex === index) {
57
- isManuallyUpdating.current = false;
58
- }
59
- }, [currentIndex, index, isManuallyUpdating, setCurrentIndex]);
55
+ }, [index, isManuallyUpdating, setCurrentIndex]);
60
56
  var intersectionRef = (0, utils_1.useIntersection)(updateActiveIndexOnScroll, { threshold: 0.5 }, false);
61
57
  var refs = (0, utils_1.useMergedRefs)(intersectionRef, ref);
62
58
  return (react_1.default.createElement("li", __assign({ className: (0, classnames_1.default)('iui-carousel-slider-item', className), role: 'tabpanel', "aria-roledescription": 'slide', ref: refs }, rest), children));
@@ -43,7 +43,7 @@ exports.CarouselSlider = react_1.default.forwardRef(function (props, ref) {
43
43
  if (!context) {
44
44
  throw new Error('CarouselSlider must be used within Carousel');
45
45
  }
46
- var currentIndex = context.currentIndex, setSlideCount = context.setSlideCount, idPrefix = context.idPrefix, isManuallyUpdating = context.isManuallyUpdating, scrollInstantly = context.scrollInstantly;
46
+ var setSlideCount = context.setSlideCount, idPrefix = context.idPrefix, scrollToSlide = context.scrollToSlide, isManuallyUpdating = context.isManuallyUpdating;
47
47
  var items = react_1.default.useMemo(function () {
48
48
  var _a;
49
49
  return (_a = react_1.default.Children.map(children, function (child, index) {
@@ -58,37 +58,32 @@ exports.CarouselSlider = react_1.default.forwardRef(function (props, ref) {
58
58
  react_1.default.useLayoutEffect(function () {
59
59
  setSlideCount(items.length);
60
60
  }, [items.length, setSlideCount]);
61
- var _a = react_1.default.useState(), width = _a[0], setWidth = _a[1];
62
- var resizeRef = (0, utils_1.useResizeObserver)(function (_a) {
63
- var width = _a.width;
64
- return setWidth(width);
65
- })[0];
66
61
  var sliderRef = react_1.default.useRef(null);
67
- var refs = (0, utils_1.useMergedRefs)(sliderRef, resizeRef, ref);
68
- var justMounted = react_1.default.useRef(true);
69
- var previousWidth = react_1.default.useRef();
70
- react_1.default.useLayoutEffect(function () {
71
- var _a, _b, _c;
72
- var slideToShow = (_a = sliderRef.current) === null || _a === void 0 ? void 0 : _a.children.item(currentIndex);
73
- if (!sliderRef.current ||
74
- !slideToShow ||
75
- (!isManuallyUpdating.current && previousWidth.current === width)) {
62
+ var refs = (0, utils_1.useMergedRefs)(sliderRef, ref);
63
+ scrollToSlide.current = function (slideIndex, _a) {
64
+ var _b, _c, _d;
65
+ var _e = _a === void 0 ? {} : _a, instant = _e.instant;
66
+ isManuallyUpdating.current = true; // start manual update
67
+ var slideToShow = (_b = sliderRef.current) === null || _b === void 0 ? void 0 : _b.children.item(slideIndex);
68
+ if (!sliderRef.current || !slideToShow) {
76
69
  return;
77
70
  }
78
- // instant scroll on first mount
79
- if (justMounted.current) {
80
- scrollInstantly.current = true;
81
- justMounted.current = false;
82
- }
83
- var motionOk = (_c = (_b = (0, utils_1.getWindow)()) === null || _b === void 0 ? void 0 : _b.matchMedia('(prefers-reduced-motion: no-preference)')) === null || _c === void 0 ? void 0 : _c.matches;
71
+ var motionOk = (_d = (_c = (0, utils_1.getWindow)()) === null || _c === void 0 ? void 0 : _c.matchMedia('(prefers-reduced-motion: no-preference)')) === null || _d === void 0 ? void 0 : _d.matches;
84
72
  sliderRef.current.scrollTo({
85
73
  left: slideToShow.offsetLeft - sliderRef.current.offsetLeft,
86
- behavior: (scrollInstantly.current || !motionOk
87
- ? 'instant'
88
- : 'smooth'), // scrollTo accepts 'instant' but ScrollBehavior type is wrong
74
+ behavior: (instant || !motionOk ? 'instant' : 'smooth'), // scrollTo accepts 'instant' but ScrollBehavior type is wrong
89
75
  });
90
- scrollInstantly.current = false;
91
- previousWidth.current = width;
92
- }, [currentIndex, isManuallyUpdating, scrollInstantly, width]);
93
- return (react_1.default.createElement("ol", __assign({ "aria-live": 'polite', className: (0, classnames_1.default)('iui-carousel-slider', className), ref: refs }, rest), items));
76
+ };
77
+ var scrollTimeout = react_1.default.useRef();
78
+ // reset isManuallyUpdating.current to false after the last scroll event
79
+ var handleOnScroll = react_1.default.useCallback(function () {
80
+ var _a, _b;
81
+ if (scrollTimeout.current) {
82
+ (_a = (0, utils_1.getWindow)()) === null || _a === void 0 ? void 0 : _a.clearTimeout(scrollTimeout.current);
83
+ }
84
+ scrollTimeout.current = (_b = (0, utils_1.getWindow)()) === null || _b === void 0 ? void 0 : _b.setTimeout(function () {
85
+ isManuallyUpdating.current = false;
86
+ }, 100);
87
+ }, [isManuallyUpdating]);
88
+ return (react_1.default.createElement("ol", __assign({ "aria-live": 'polite', className: (0, classnames_1.default)('iui-carousel-slider', className), ref: refs, onScroll: handleOnScroll }, rest), items));
94
89
  });
@@ -5,7 +5,7 @@ export declare const ColorPickerContext: React.Context<{
5
5
  setActiveColor: (color: ColorValue | ((prevColor: ColorValue) => ColorValue)) => void;
6
6
  hsvColor: HsvColor;
7
7
  onChangeComplete?: ((color: ColorValue) => void) | undefined;
8
- applyHsvColorChange: (newColor: HsvColor, selectionChanged: boolean, newColorValue?: ColorValue | undefined) => void;
8
+ applyHsvColorChange: (newColor: HsvColor, selectionChanged: boolean, newColorValue?: ColorValue) => void;
9
9
  showAlpha: boolean;
10
10
  } | undefined>;
11
11
  export declare const useColorPickerContext: () => {
@@ -13,6 +13,6 @@ export declare const useColorPickerContext: () => {
13
13
  setActiveColor: (color: ColorValue | ((prevColor: ColorValue) => ColorValue)) => void;
14
14
  hsvColor: HsvColor;
15
15
  onChangeComplete?: ((color: ColorValue) => void) | undefined;
16
- applyHsvColorChange: (newColor: HsvColor, selectionChanged: boolean, newColorValue?: ColorValue | undefined) => void;
16
+ applyHsvColorChange: (newColor: HsvColor, selectionChanged: boolean, newColorValue?: ColorValue) => void;
17
17
  showAlpha: boolean;
18
18
  };
@@ -17,5 +17,5 @@ export declare type ColorSwatchProps = {
17
17
  * <ColorSwatch color='#23450b' onClick={onClick}/>
18
18
  * <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
19
19
  */
20
- export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "role" | "children" | "className" | "onClick" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "isActive"> & React.RefAttributes<HTMLDivElement>>;
20
+ export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "children" | "role" | "className" | "onClick" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "isActive"> & React.RefAttributes<HTMLDivElement>>;
21
21
  export default ColorSwatch;
@@ -40,8 +40,10 @@ export declare type ComboBoxProps<T> = {
40
40
  emptyStateMessage?: string;
41
41
  /**
42
42
  * A custom item renderer can be specified to control the rendering.
43
- * This function should ideally return a customized version of `MenuItem`,
44
- * otherwise you will need to make sure to provide styling for the `isFocused` state.
43
+ *
44
+ * For keyboard navigation to work, the returned element should use the `id` provided by this function.
45
+ * The `isFocused` state is calculated using this `id` and can be used for specifying the focus styling.
46
+ * If a `MenuItem` is returned, then focus styling is automatically handled.
45
47
  */
46
48
  itemRenderer?: (option: SelectOption<T>, states: {
47
49
  isSelected: boolean;
@@ -49,6 +51,13 @@ export declare type ComboBoxProps<T> = {
49
51
  id: string;
50
52
  index: number;
51
53
  }) => JSX.Element;
54
+ /**
55
+ * If enabled, virtualization is used for the scrollable dropdown list.
56
+ * Use it if you expect a very long list of items.
57
+ * @default false
58
+ * @beta
59
+ */
60
+ enableVirtualization?: boolean;
52
61
  } & Pick<InputContainerProps, 'status'> & Omit<CommonProps, 'title'>;
53
62
  /**
54
63
  * ComboBox component that allows typing a value to filter the options in dropdown list.