@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
@@ -0,0 +1,146 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ import React from 'react';
28
+ import { Input } from '../Input';
29
+ import { useSafeContext, useMergedRefs } from '../utils';
30
+ import { ComboBoxStateContext, ComboBoxActionContext, ComboBoxRefsContext, } from './helpers';
31
+ export var ComboBoxInput = React.forwardRef(function (props, forwardedRef) {
32
+ var onKeyDownProp = props.onKeyDown, onFocusProp = props.onFocus, rest = __rest(props, ["onKeyDown", "onFocus"]);
33
+ var _a = useSafeContext(ComboBoxStateContext), isOpen = _a.isOpen, id = _a.id, focusedIndex = _a.focusedIndex, enableVirtualization = _a.enableVirtualization;
34
+ var dispatch = useSafeContext(ComboBoxActionContext);
35
+ var _b = useSafeContext(ComboBoxRefsContext), inputRef = _b.inputRef, menuRef = _b.menuRef, optionsExtraInfoRef = _b.optionsExtraInfoRef;
36
+ var refs = useMergedRefs(inputRef, forwardedRef);
37
+ var focusedIndexRef = React.useRef(focusedIndex !== null && focusedIndex !== void 0 ? focusedIndex : -1);
38
+ React.useEffect(function () {
39
+ focusedIndexRef.current = focusedIndex !== null && focusedIndex !== void 0 ? focusedIndex : -1;
40
+ }, [focusedIndex]);
41
+ var getIdFromIndex = function (index) {
42
+ var _a, _b, _c;
43
+ return ((_c = (_b = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-iui-index=\"".concat(index, "\"]"))) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '');
44
+ };
45
+ var handleKeyDown = React.useCallback(function (event) {
46
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
47
+ onKeyDownProp === null || onKeyDownProp === void 0 ? void 0 : onKeyDownProp(event);
48
+ var length = (_a = Object.keys(optionsExtraInfoRef.current).length) !== null && _a !== void 0 ? _a : 0;
49
+ switch (event.key) {
50
+ case 'ArrowDown': {
51
+ event.preventDefault();
52
+ if (!isOpen) {
53
+ return dispatch(['open']);
54
+ }
55
+ if (length === 0) {
56
+ return;
57
+ }
58
+ if (focusedIndexRef.current === -1) {
59
+ var currentElement = (_b = menuRef.current) === null || _b === void 0 ? void 0 : _b.querySelector('[data-iui-index]');
60
+ return dispatch([
61
+ 'focus',
62
+ Number((_c = currentElement === null || currentElement === void 0 ? void 0 : currentElement.getAttribute('data-iui-index')) !== null && _c !== void 0 ? _c : 0),
63
+ ]);
64
+ }
65
+ // If virtualization is enabled, dont let round scrolling
66
+ if (enableVirtualization &&
67
+ !((_e = (_d = menuRef.current) === null || _d === void 0 ? void 0 : _d.querySelector("[data-iui-index=\"".concat(focusedIndexRef.current, "\"]"))) === null || _e === void 0 ? void 0 : _e.nextElementSibling)) {
68
+ return;
69
+ }
70
+ var nextIndex = focusedIndexRef.current;
71
+ do {
72
+ var currentElement = (_f = menuRef.current) === null || _f === void 0 ? void 0 : _f.querySelector("[data-iui-index=\"".concat(nextIndex, "\"]"));
73
+ var nextElement = (_g = currentElement === null || currentElement === void 0 ? void 0 : currentElement.nextElementSibling) !== null && _g !== void 0 ? _g : (_h = menuRef.current) === null || _h === void 0 ? void 0 : _h.querySelector('[data-iui-index]');
74
+ nextIndex = Number(nextElement === null || nextElement === void 0 ? void 0 : nextElement.getAttribute('data-iui-index'));
75
+ if ((nextElement === null || nextElement === void 0 ? void 0 : nextElement.ariaDisabled) !== 'true') {
76
+ return dispatch(['focus', nextIndex]);
77
+ }
78
+ } while (nextIndex !== focusedIndexRef.current);
79
+ break;
80
+ }
81
+ case 'ArrowUp': {
82
+ event.preventDefault();
83
+ if (!isOpen) {
84
+ return dispatch(['open']);
85
+ }
86
+ if (length === 0) {
87
+ return;
88
+ }
89
+ // If virtualization is enabled, dont let round scrolling
90
+ if (enableVirtualization &&
91
+ !((_k = (_j = menuRef.current) === null || _j === void 0 ? void 0 : _j.querySelector("[data-iui-index=\"".concat(focusedIndexRef.current, "\"]"))) === null || _k === void 0 ? void 0 : _k.previousElementSibling)) {
92
+ return;
93
+ }
94
+ if (focusedIndexRef.current === -1) {
95
+ return dispatch([
96
+ 'focus',
97
+ (_m = (_l = Object.values(optionsExtraInfoRef.current)) === null || _l === void 0 ? void 0 : _l[length - 1].__originalIndex) !== null && _m !== void 0 ? _m : -1,
98
+ ]);
99
+ }
100
+ var prevIndex = focusedIndexRef.current;
101
+ do {
102
+ var currentElement = (_o = menuRef.current) === null || _o === void 0 ? void 0 : _o.querySelector("[data-iui-index=\"".concat(prevIndex, "\"]"));
103
+ var prevElement = (_p = currentElement === null || currentElement === void 0 ? void 0 : currentElement.previousElementSibling) !== null && _p !== void 0 ? _p : (_q = menuRef.current) === null || _q === void 0 ? void 0 : _q.querySelector('[data-iui-index]:last-of-type');
104
+ prevIndex = Number(prevElement === null || prevElement === void 0 ? void 0 : prevElement.getAttribute('data-iui-index'));
105
+ if ((prevElement === null || prevElement === void 0 ? void 0 : prevElement.ariaDisabled) !== 'true') {
106
+ return dispatch(['focus', prevIndex]);
107
+ }
108
+ } while (prevIndex !== focusedIndexRef.current);
109
+ break;
110
+ }
111
+ case 'Enter': {
112
+ event.preventDefault();
113
+ if (isOpen) {
114
+ dispatch(['select', focusedIndexRef.current]);
115
+ }
116
+ else {
117
+ dispatch(['open']);
118
+ }
119
+ break;
120
+ }
121
+ case 'Escape': {
122
+ event.preventDefault();
123
+ dispatch(['close']);
124
+ break;
125
+ }
126
+ case 'Tab':
127
+ dispatch(['close']);
128
+ break;
129
+ }
130
+ }, [
131
+ dispatch,
132
+ enableVirtualization,
133
+ isOpen,
134
+ menuRef,
135
+ onKeyDownProp,
136
+ optionsExtraInfoRef,
137
+ ]);
138
+ var handleFocus = React.useCallback(function (event) {
139
+ dispatch(['open']);
140
+ onFocusProp === null || onFocusProp === void 0 ? void 0 : onFocusProp(event);
141
+ }, [dispatch, onFocusProp]);
142
+ return (React.createElement(Input, __assign({ ref: refs, onKeyDown: handleKeyDown, onFocus: handleFocus, "aria-activedescendant": isOpen && focusedIndex != undefined && focusedIndex > -1
143
+ ? getIdFromIndex(focusedIndex)
144
+ : undefined, role: 'combobox', "aria-controls": isOpen ? "".concat(id, "-list") : undefined, "aria-autocomplete": 'list', spellCheck: false, autoCapitalize: 'none', autoCorrect: 'off' }, rest)));
145
+ });
146
+ ComboBoxInput.displayName = 'ComboBoxInput';
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { InputContainerProps } from '../utils';
3
+ declare type ComboBoxInputContainerProps = React.ComponentPropsWithoutRef<'div'> & Pick<InputContainerProps, 'status' | 'message' | 'disabled'>;
4
+ export declare const ComboBoxInputContainer: {
5
+ (props: ComboBoxInputContainerProps): JSX.Element;
6
+ displayName: string;
7
+ };
8
+ export {};
@@ -0,0 +1,38 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ import React from 'react';
28
+ import { StatusMessage } from '../StatusMessage';
29
+ import { InputContainer, useSafeContext } from '../utils';
30
+ import { ComboBoxStateContext } from './helpers';
31
+ export var ComboBoxInputContainer = function (props) {
32
+ var className = props.className, status = props.status, message = props.message, children = props.children, rest = __rest(props, ["className", "status", "message", "children"]);
33
+ var id = useSafeContext(ComboBoxStateContext).id;
34
+ return (React.createElement(InputContainer, __assign({ className: className, status: status, statusMessage: typeof message === 'string' ? (React.createElement(StatusMessage, { status: status }, message)) : (React.isValidElement(message) &&
35
+ React.cloneElement(message, { status: status })) }, rest, { id: id }),
36
+ React.createElement("div", { className: 'iui-input-with-icon' }, children)));
37
+ };
38
+ ComboBoxInputContainer.displayName = 'ComboBoxInputContainer';
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { MenuProps } from '../Menu';
3
+ export declare const ComboBoxMenu: React.ForwardRefExoticComponent<Omit<MenuProps, "onClick"> & Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "key" | keyof React.HTMLAttributes<HTMLUListElement>> & React.RefAttributes<HTMLUListElement>>;
@@ -0,0 +1,83 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ import cx from 'classnames';
28
+ import React from 'react';
29
+ import { Menu } from '../Menu';
30
+ import { Surface } from '../Surface';
31
+ import { useSafeContext, useMergedRefs, useVirtualization, mergeRefs, getWindow, } from '../utils';
32
+ import { ComboBoxStateContext, ComboBoxRefsContext } from './helpers';
33
+ var VirtualizedComboBoxMenu = React.forwardRef(function (_a, forwardedRef) {
34
+ var _b, _c, _d;
35
+ var children = _a.children, style = _a.style, rest = __rest(_a, ["children", "style"]);
36
+ var _e = useSafeContext(ComboBoxStateContext), minWidth = _e.minWidth, id = _e.id, filteredOptions = _e.filteredOptions, getMenuItem = _e.getMenuItem, focusedIndex = _e.focusedIndex;
37
+ var menuRef = useSafeContext(ComboBoxRefsContext).menuRef;
38
+ var virtualItemRenderer = React.useCallback(function (index) {
39
+ return filteredOptions.length > 0
40
+ ? getMenuItem(filteredOptions[index], index)
41
+ : children;
42
+ }, // Here is expected empty state content
43
+ [filteredOptions, getMenuItem, children]);
44
+ var focusedVisibleIndex = React.useMemo(function () {
45
+ var _a, _b;
46
+ var currentElement = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-iui-index=\"".concat(focusedIndex, "\"]"));
47
+ if (!currentElement) {
48
+ return focusedIndex;
49
+ }
50
+ return Number((_b = currentElement.getAttribute('data-iui-filtered-index')) !== null && _b !== void 0 ? _b : focusedIndex);
51
+ }, [focusedIndex, menuRef]);
52
+ var _f = useVirtualization({
53
+ // 'Fool' VirtualScroll by passing length 1
54
+ // whenever there is no elements, to show empty state message
55
+ itemsLength: filteredOptions.length || 1,
56
+ itemRenderer: virtualItemRenderer,
57
+ scrollToIndex: focusedVisibleIndex,
58
+ }), outerProps = _f.outerProps, innerProps = _f.innerProps, visibleChildren = _f.visibleChildren;
59
+ var overflowY = ((_d = (_c = (_b = getWindow()) === null || _b === void 0 ? void 0 : _b.CSS) === null || _c === void 0 ? void 0 : _c.supports) === null || _d === void 0 ? void 0 : _d.call(_c, 'overflow-x: overlay'))
60
+ ? { overflowY: 'overlay' }
61
+ : { overflowY: 'auto' };
62
+ var styles = React.useMemo(function () { return ({
63
+ minWidth: minWidth,
64
+ maxWidth: "min(".concat(minWidth * 2, "px, 90vw)"),
65
+ maxHeight: 315,
66
+ }); }, [minWidth]);
67
+ return (React.createElement(Surface, __assign({ elevation: 1, style: __assign(__assign(__assign({}, styles), overflowY), style) }, rest),
68
+ React.createElement("div", __assign({}, outerProps),
69
+ React.createElement(Menu, { id: "".concat(id, "-list"), setFocus: false, role: 'listbox', ref: mergeRefs(menuRef, innerProps.ref, forwardedRef), style: innerProps.style }, visibleChildren))));
70
+ });
71
+ export var ComboBoxMenu = React.forwardRef(function (props, forwardedRef) {
72
+ var className = props.className, style = props.style, rest = __rest(props, ["className", "style"]);
73
+ var _a = useSafeContext(ComboBoxStateContext), minWidth = _a.minWidth, id = _a.id, enableVirtualization = _a.enableVirtualization;
74
+ var menuRef = useSafeContext(ComboBoxRefsContext).menuRef;
75
+ var refs = useMergedRefs(menuRef, forwardedRef);
76
+ var styles = React.useMemo(function () { return ({
77
+ minWidth: minWidth,
78
+ maxWidth: "min(".concat(minWidth * 2, "px, 90vw)"),
79
+ maxHeight: 315,
80
+ }); }, [minWidth]);
81
+ return (React.createElement(React.Fragment, null, !enableVirtualization ? (React.createElement(Menu, __assign({ id: "".concat(id, "-list"), style: __assign(__assign({}, styles), style), setFocus: false, role: 'listbox', ref: refs, className: cx('iui-scroll', className) }, rest))) : (React.createElement(VirtualizedComboBoxMenu, __assign({ ref: forwardedRef }, props)))));
82
+ });
83
+ ComboBoxMenu.displayName = 'ComboBoxMenu';
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ export declare const ComboBoxMenuItem: React.MemoExoticComponent<React.ForwardRefExoticComponent<{
3
+ isSelected?: boolean | undefined;
4
+ disabled?: boolean | undefined;
5
+ value?: unknown;
6
+ onClick?: ((value?: unknown) => void) | undefined;
7
+ size?: "default" | "large" | undefined;
8
+ sublabel?: React.ReactNode;
9
+ icon?: JSX.Element | undefined;
10
+ badge?: JSX.Element | undefined;
11
+ role?: string | undefined;
12
+ subMenuItems?: JSX.Element[] | undefined;
13
+ children?: React.ReactNode;
14
+ } & {
15
+ title?: string | undefined;
16
+ id?: string | undefined;
17
+ } & {
18
+ style?: React.CSSProperties | undefined;
19
+ } & import("../utils").ClassNameProps & {
20
+ index: number;
21
+ } & React.RefAttributes<HTMLLIElement>>>;
@@ -0,0 +1,58 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ import cx from 'classnames';
28
+ import React from 'react';
29
+ import { useSafeContext, useMergedRefs } from '../utils';
30
+ import { ComboBoxStateContext } from './helpers';
31
+ export var ComboBoxMenuItem = React.memo(React.forwardRef(function (props, forwardedRef) {
32
+ var children = props.children, isSelected = props.isSelected, disabled = props.disabled, value = props.value, onClick = props.onClick, sublabel = props.sublabel, _a = props.size, size = _a === void 0 ? !!sublabel ? 'large' : 'default' : _a, icon = props.icon, badge = props.badge, className = props.className, _b = props.role, role = _b === void 0 ? 'menuitem' : _b, index = props.index, rest = __rest(props, ["children", "isSelected", "disabled", "value", "onClick", "sublabel", "size", "icon", "badge", "className", "role", "index"]);
33
+ var _c = useSafeContext(ComboBoxStateContext), focusedIndex = _c.focusedIndex, enableVirtualization = _c.enableVirtualization;
34
+ var focusRef = function (el) {
35
+ if (!enableVirtualization && focusedIndex === index) {
36
+ el === null || el === void 0 ? void 0 : el.scrollIntoView({ block: 'nearest' });
37
+ }
38
+ };
39
+ var refs = useMergedRefs(forwardedRef, focusRef);
40
+ return (React.createElement("li", __assign({ className: cx('iui-menu-item', {
41
+ 'iui-large': size === 'large',
42
+ 'iui-active': isSelected,
43
+ 'iui-disabled': disabled,
44
+ 'iui-focused': focusedIndex === index,
45
+ }, className), ref: refs, onClick: function () { return !disabled && (onClick === null || onClick === void 0 ? void 0 : onClick(value)); }, role: role, tabIndex: disabled || role === 'presentation' ? undefined : -1, "aria-selected": isSelected, "aria-disabled": disabled, "data-iui-index": index }, rest),
46
+ icon &&
47
+ React.cloneElement(icon, {
48
+ className: cx(icon.props.className, 'iui-icon'),
49
+ }),
50
+ React.createElement("span", { className: 'iui-content' },
51
+ React.createElement("div", { className: 'iui-menu-label' }, children),
52
+ sublabel && React.createElement("div", { className: 'iui-menu-description' }, sublabel)),
53
+ badge &&
54
+ React.cloneElement(badge, {
55
+ className: cx(badge.props.className, 'iui-icon'),
56
+ })));
57
+ }));
58
+ ComboBoxMenuItem.displayName = 'ComboBoxMenuItem';
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { SelectOption } from '../Select/Select';
3
+ declare type ComboBoxAction = 'open' | 'close' | 'select' | 'focus';
4
+ export declare const comboBoxReducer: (state: {
5
+ isOpen: boolean;
6
+ selectedIndex: number;
7
+ focusedIndex: number;
8
+ }, [type, value]: [ComboBoxAction] | [ComboBoxAction, number | undefined]) => {
9
+ isOpen: boolean;
10
+ selectedIndex: number;
11
+ focusedIndex: number;
12
+ };
13
+ export declare const ComboBoxRefsContext: React.Context<{
14
+ inputRef: React.RefObject<HTMLInputElement>;
15
+ menuRef: React.RefObject<HTMLUListElement>;
16
+ toggleButtonRef: React.RefObject<HTMLSpanElement>;
17
+ optionsExtraInfoRef: React.MutableRefObject<Record<string, {
18
+ __originalIndex: number;
19
+ }>>;
20
+ } | undefined>;
21
+ declare type ComboBoxStateContextProps<T = unknown> = {
22
+ isOpen: boolean;
23
+ id: string;
24
+ minWidth: number;
25
+ enableVirtualization: boolean;
26
+ filteredOptions: SelectOption<T>[];
27
+ getMenuItem: (option: SelectOption<T>, filteredIndex?: number) => JSX.Element;
28
+ focusedIndex?: number;
29
+ };
30
+ export declare const ComboBoxStateContext: React.Context<ComboBoxStateContextProps<unknown> | undefined>;
31
+ export declare const ComboBoxActionContext: React.Context<((x: [ComboBoxAction] | [ComboBoxAction, number]) => void) | undefined>;
32
+ export {};
@@ -0,0 +1,43 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ /*---------------------------------------------------------------------------------------------
13
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
14
+ * See LICENSE.md in the project root for license terms and full copyright notice.
15
+ *--------------------------------------------------------------------------------------------*/
16
+ import React from 'react';
17
+ export var comboBoxReducer = function (state, _a) {
18
+ var _b;
19
+ var type = _a[0], value = _a[1];
20
+ switch (type) {
21
+ case 'open': {
22
+ return __assign(__assign({}, state), { isOpen: true });
23
+ }
24
+ case 'close': {
25
+ return __assign(__assign({}, state), { isOpen: false });
26
+ }
27
+ case 'select': {
28
+ return __assign(__assign({}, state), { isOpen: false, selectedIndex: value !== null && value !== void 0 ? value : state.selectedIndex, focusedIndex: value !== null && value !== void 0 ? value : state.focusedIndex });
29
+ }
30
+ case 'focus': {
31
+ return __assign(__assign({}, state), { focusedIndex: (_b = value !== null && value !== void 0 ? value : state.selectedIndex) !== null && _b !== void 0 ? _b : -1 });
32
+ }
33
+ default: {
34
+ return state;
35
+ }
36
+ }
37
+ };
38
+ export var ComboBoxRefsContext = React.createContext(undefined);
39
+ ComboBoxRefsContext.displayName = 'ComboBoxRefsContext';
40
+ export var ComboBoxStateContext = React.createContext(undefined);
41
+ ComboBoxStateContext.displayName = 'ComboBoxStateContext';
42
+ export var ComboBoxActionContext = React.createContext(undefined);
43
+ ComboBoxActionContext.displayName = 'ComboBoxActionContext';
@@ -5,7 +5,7 @@ import { TimePickerProps } from '../TimePicker';
5
5
  * Generate localized months and days strings using `Intl.DateTimeFormat` for passed locale to use in DatePicker component.
6
6
  * If locale is not passed, browser locale will be used.
7
7
  */
8
- export declare const generateLocalizedStrings: (locale?: string | undefined) => {
8
+ export declare const generateLocalizedStrings: (locale?: string) => {
9
9
  months: string[];
10
10
  shortDays: string[];
11
11
  days: string[];
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { CommonProps } from '../utils';
3
- import '@itwin/itwinui-css/css/modal.css';
3
+ import '@itwin/itwinui-css/css/dialog.css';
4
4
  export declare type ModalProps = {
5
5
  /**
6
6
  * Flag whether modal should be shown.
@@ -29,7 +29,7 @@ import ReactDOM from 'react-dom';
29
29
  import cx from 'classnames';
30
30
  import SvgClose from '@itwin/itwinui-icons-react/cjs/icons/Close';
31
31
  import { useTheme, getContainer, getDocument, FocusTrap, } from '../utils';
32
- import '@itwin/itwinui-css/css/modal.css';
32
+ import '@itwin/itwinui-css/css/dialog.css';
33
33
  import { IconButton } from '../Buttons/IconButton';
34
34
  import { CSSTransition } from 'react-transition-group';
35
35
  /**
@@ -112,12 +112,12 @@ export var Modal = function (props) {
112
112
  onClose(event);
113
113
  }
114
114
  };
115
- return !!container ? (ReactDOM.createPortal(React.createElement(CSSTransition, { in: isOpen, classNames: 'iui-modal-animation', timeout: { exit: 600 }, unmountOnExit: true },
115
+ return !!container ? (ReactDOM.createPortal(React.createElement(CSSTransition, { in: isOpen, classNames: 'iui-dialog-animation', timeout: { exit: 600 }, unmountOnExit: true },
116
116
  React.createElement(FocusTrap, null,
117
- React.createElement("div", __assign({ className: cx('iui-modal', { 'iui-modal-full-page': styleType === 'fullPage' }, { 'iui-modal-visible': isOpen }, className), tabIndex: -1, onKeyDown: handleKeyDown, ref: overlayRef, onMouseDown: handleMouseDown }, rest),
118
- React.createElement("div", { className: 'iui-modal-dialog', id: id, style: style, role: 'dialog', "aria-modal": 'true' },
119
- React.createElement("div", { className: 'iui-title-bar' },
120
- React.createElement("div", { className: 'iui-title' }, title),
117
+ React.createElement("div", __assign({ className: cx('iui-dialog-backdrop', { 'iui-dialog-default': styleType === 'default' }, { 'iui-dialog-full-page': styleType === 'fullPage' }, { 'iui-dialog-visible': isOpen }, className), tabIndex: -1, onKeyDown: handleKeyDown, ref: overlayRef, onMouseDown: handleMouseDown }, rest),
118
+ React.createElement("div", { className: 'iui-dialog', id: id, style: style, role: 'dialog', "aria-modal": 'true' },
119
+ React.createElement("div", { className: 'iui-dialog-title-bar' },
120
+ React.createElement("div", { className: 'iui-dialog-title' }, title),
121
121
  isDismissible && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
122
122
  React.createElement(SvgClose, null)))),
123
123
  children)))), container)) : (React.createElement(React.Fragment, null));
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { CommonProps } from '../utils';
3
- import '@itwin/itwinui-css/css/modal.css';
3
+ import '@itwin/itwinui-css/css/dialog.css';
4
4
  export declare type ModalButtonBarProps = {
5
5
  /**
6
6
  * Buttons in the modal bar.
@@ -27,13 +27,13 @@ var __rest = (this && this.__rest) || function (s, e) {
27
27
  import React from 'react';
28
28
  import cx from 'classnames';
29
29
  import { useTheme } from '../utils';
30
- import '@itwin/itwinui-css/css/modal.css';
30
+ import '@itwin/itwinui-css/css/dialog.css';
31
31
  /**
32
32
  * Container for Buttons in modal.
33
33
  */
34
34
  export var ModalButtonBar = function (props) {
35
35
  var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
36
36
  useTheme();
37
- return (React.createElement("div", __assign({ className: cx('iui-button-bar', className) }, rest), children));
37
+ return (React.createElement("div", __assign({ className: cx('iui-dialog-button-bar', className) }, rest), children));
38
38
  };
39
39
  export default ModalButtonBar;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { CommonProps } from '../utils';
3
- import '@itwin/itwinui-css/css/modal.css';
3
+ import '@itwin/itwinui-css/css/dialog.css';
4
4
  export declare type ModalContentProps = {
5
5
  /**
6
6
  * Main content in the `Modal`.
@@ -27,13 +27,13 @@ var __rest = (this && this.__rest) || function (s, e) {
27
27
  import React from 'react';
28
28
  import cx from 'classnames';
29
29
  import { useTheme } from '../utils';
30
- import '@itwin/itwinui-css/css/modal.css';
30
+ import '@itwin/itwinui-css/css/dialog.css';
31
31
  /**
32
32
  * Container for content in `Modal`.
33
33
  */
34
34
  export var ModalContent = function (props) {
35
35
  var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
36
36
  useTheme();
37
- return (React.createElement("div", __assign({ className: cx('iui-modal-content', className) }, rest), children));
37
+ return (React.createElement("div", __assign({ className: cx('iui-dialog-content', className) }, rest), children));
38
38
  };
39
39
  export default ModalContent;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import '@itwin/itwinui-css/css/inputs.css';
2
+ import '@itwin/itwinui-css/css/radio-tile.css';
3
3
  export declare type RadioTileProps = {
4
4
  /**
5
5
  * Icon to be used.
@@ -24,11 +24,10 @@ var __rest = (this && this.__rest) || function (s, e) {
24
24
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
25
  * See LICENSE.md in the project root for license terms and full copyright notice.
26
26
  *--------------------------------------------------------------------------------------------*/
27
- import SvgCheckmark from '@itwin/itwinui-icons-react/cjs/icons/Checkmark';
28
27
  import cx from 'classnames';
29
28
  import React from 'react';
30
29
  import { useMergedRefs, useTheme } from '../utils';
31
- import '@itwin/itwinui-css/css/inputs.css';
30
+ import '@itwin/itwinui-css/css/radio-tile.css';
32
31
  /**
33
32
  * RadioTile component to be used in RadioTileGroup component
34
33
  * @example
@@ -44,15 +43,14 @@ export var RadioTile = React.forwardRef(function (props, ref) {
44
43
  inputElementRef.current.focus();
45
44
  }
46
45
  }, [setFocus]);
47
- return (React.createElement("label", { className: className, style: style },
48
- React.createElement("input", __assign({ type: 'radio', ref: refs }, rest)),
49
- React.createElement("div", { className: 'iui-radio-tile' },
50
- React.createElement(SvgCheckmark, { className: 'iui-checkmark', "aria-hidden": true }),
46
+ return (React.createElement("label", { className: cx('iui-radio-tile', className), style: style },
47
+ React.createElement("input", __assign({ className: 'iui-radio-tile-input', type: 'radio', ref: refs }, rest)),
48
+ React.createElement("div", { className: 'iui-radio-tile-content' },
51
49
  icon &&
52
50
  React.cloneElement(icon, {
53
- className: cx('iui-icon', icon.props.className),
51
+ className: cx('iui-radio-tile-icon', icon.props.className),
54
52
  }),
55
- label && React.createElement("div", { className: 'iui-label' }, label),
56
- description && React.createElement("div", { className: 'iui-description' }, description))));
53
+ label && React.createElement("div", { className: 'iui-radio-tile-label' }, label),
54
+ description && (React.createElement("div", { className: 'iui-radio-tile-sublabel' }, description)))));
57
55
  });
58
56
  export default RadioTile;
@@ -140,7 +140,7 @@ export var Select = function (props) {
140
140
  return options.find(function (option) { return option.value === value; });
141
141
  }, [options, value]);
142
142
  return (React.createElement("div", __assign({ className: cx('iui-input-with-icon', className), "aria-expanded": isOpen, "aria-haspopup": 'listbox', style: style }, rest),
143
- React.createElement(DropdownMenu, __assign({ menuItems: menuItems, placement: 'bottom-start', className: cx('iui-scroll', menuClassName), style: __assign({ minWidth: minWidth, maxWidth: "min(".concat(minWidth * 2, "px, 90vw)"), maxHeight: "300px" }, menuStyle), role: 'listbox', onShow: onShowHandler, onHide: onHideHandler, disabled: disabled }, popoverProps, { visible: isOpen, onClickOutside: function (_, _a) {
143
+ React.createElement(DropdownMenu, __assign({ menuItems: menuItems, placement: 'bottom-start', className: cx('iui-scroll', menuClassName), style: __assign({ minWidth: minWidth, maxWidth: "min(".concat(minWidth * 2, "px, 90vw)"), maxHeight: 315 }, menuStyle), role: 'listbox', onShow: onShowHandler, onHide: onHideHandler, disabled: disabled }, popoverProps, { visible: isOpen, onClickOutside: function (_, _a) {
144
144
  var _b;
145
145
  var target = _a.target;
146
146
  if (!((_b = toggleButtonRef.current) === null || _b === void 0 ? void 0 : _b.contains(target))) {