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