@itwin/itwinui-react 1.37.1 → 1.38.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 (82) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/cjs/core/Breadcrumbs/Breadcrumbs.js +3 -5
  3. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  4. package/cjs/core/ComboBox/ComboBox.d.ts +4 -2
  5. package/cjs/core/ComboBox/ComboBox.js +129 -246
  6. package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +8 -0
  7. package/cjs/core/ComboBox/ComboBoxDropdown.js +55 -0
  8. package/cjs/core/ComboBox/ComboBoxEndIcon.d.ts +5 -0
  9. package/cjs/core/ComboBox/ComboBoxEndIcon.js +54 -0
  10. package/cjs/core/ComboBox/ComboBoxInput.d.ts +5 -0
  11. package/cjs/core/ComboBox/ComboBoxInput.js +134 -0
  12. package/cjs/core/ComboBox/ComboBoxInputContainer.d.ts +8 -0
  13. package/cjs/core/ComboBox/ComboBoxInputContainer.js +45 -0
  14. package/cjs/core/ComboBox/ComboBoxMenu.d.ts +3 -0
  15. package/cjs/core/ComboBox/ComboBoxMenu.js +45 -0
  16. package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +21 -0
  17. package/cjs/core/ComboBox/ComboBoxMenuItem.js +65 -0
  18. package/cjs/core/ComboBox/helpers.d.ts +27 -0
  19. package/cjs/core/ComboBox/helpers.js +50 -0
  20. package/cjs/core/Modal/Modal.d.ts +1 -1
  21. package/cjs/core/Modal/Modal.js +6 -6
  22. package/cjs/core/Modal/ModalButtonBar.d.ts +1 -1
  23. package/cjs/core/Modal/ModalButtonBar.js +2 -2
  24. package/cjs/core/Modal/ModalContent.d.ts +1 -1
  25. package/cjs/core/Modal/ModalContent.js +2 -2
  26. package/cjs/core/RadioTiles/RadioTile.d.ts +1 -1
  27. package/cjs/core/RadioTiles/RadioTile.js +7 -9
  28. package/cjs/core/Slider/Thumb.js +15 -1
  29. package/cjs/core/Slider/Track.js +23 -12
  30. package/cjs/core/Table/Table.js +19 -7
  31. package/cjs/core/Table/cells/EditableCell.js +2 -1
  32. package/cjs/core/Table/filters/FilterToggle.js +3 -2
  33. package/cjs/core/Toast/ToastWrapper.d.ts +7 -5
  34. package/cjs/core/Toast/ToastWrapper.js +8 -4
  35. package/cjs/core/Toast/Toaster.d.ts +3 -0
  36. package/cjs/core/Toast/Toaster.js +66 -5
  37. package/cjs/core/utils/components/Popover.d.ts +1 -1
  38. package/cjs/core/utils/hooks/index.d.ts +1 -0
  39. package/cjs/core/utils/hooks/index.js +1 -0
  40. package/cjs/core/utils/hooks/useSafeContext.d.ts +6 -0
  41. package/cjs/core/utils/hooks/useSafeContext.js +23 -0
  42. package/esm/core/Breadcrumbs/Breadcrumbs.js +3 -5
  43. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  44. package/esm/core/ComboBox/ComboBox.d.ts +4 -2
  45. package/esm/core/ComboBox/ComboBox.js +131 -248
  46. package/esm/core/ComboBox/ComboBoxDropdown.d.ts +8 -0
  47. package/esm/core/ComboBox/ComboBoxDropdown.js +49 -0
  48. package/esm/core/ComboBox/ComboBoxEndIcon.d.ts +5 -0
  49. package/esm/core/ComboBox/ComboBoxEndIcon.js +48 -0
  50. package/esm/core/ComboBox/ComboBoxInput.d.ts +5 -0
  51. package/esm/core/ComboBox/ComboBoxInput.js +128 -0
  52. package/esm/core/ComboBox/ComboBoxInputContainer.d.ts +8 -0
  53. package/esm/core/ComboBox/ComboBoxInputContainer.js +38 -0
  54. package/esm/core/ComboBox/ComboBoxMenu.d.ts +3 -0
  55. package/esm/core/ComboBox/ComboBoxMenu.js +39 -0
  56. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +21 -0
  57. package/esm/core/ComboBox/ComboBoxMenuItem.js +59 -0
  58. package/esm/core/ComboBox/helpers.d.ts +27 -0
  59. package/esm/core/ComboBox/helpers.js +43 -0
  60. package/esm/core/Modal/Modal.d.ts +1 -1
  61. package/esm/core/Modal/Modal.js +6 -6
  62. package/esm/core/Modal/ModalButtonBar.d.ts +1 -1
  63. package/esm/core/Modal/ModalButtonBar.js +2 -2
  64. package/esm/core/Modal/ModalContent.d.ts +1 -1
  65. package/esm/core/Modal/ModalContent.js +2 -2
  66. package/esm/core/RadioTiles/RadioTile.d.ts +1 -1
  67. package/esm/core/RadioTiles/RadioTile.js +7 -9
  68. package/esm/core/Slider/Thumb.js +15 -1
  69. package/esm/core/Slider/Track.js +23 -12
  70. package/esm/core/Table/Table.js +19 -7
  71. package/esm/core/Table/cells/EditableCell.js +2 -1
  72. package/esm/core/Table/filters/FilterToggle.js +3 -2
  73. package/esm/core/Toast/ToastWrapper.d.ts +7 -5
  74. package/esm/core/Toast/ToastWrapper.js +8 -3
  75. package/esm/core/Toast/Toaster.d.ts +3 -0
  76. package/esm/core/Toast/Toaster.js +66 -5
  77. package/esm/core/utils/components/Popover.d.ts +1 -1
  78. package/esm/core/utils/hooks/index.d.ts +1 -0
  79. package/esm/core/utils/hooks/index.js +1 -0
  80. package/esm/core/utils/hooks/useSafeContext.d.ts +6 -0
  81. package/esm/core/utils/hooks/useSafeContext.js +16 -0
  82. package/package.json +6 -34
@@ -0,0 +1,128 @@
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;
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;
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
+ return dispatch([
60
+ 'focus',
61
+ (_c = (_b = Object.values(optionsExtraInfoRef.current)) === null || _b === void 0 ? void 0 : _b[0].__originalIndex) !== null && _c !== void 0 ? _c : -1,
62
+ ]);
63
+ }
64
+ var nextIndex = focusedIndexRef.current;
65
+ do {
66
+ var currentElement = (_d = menuRef.current) === null || _d === void 0 ? void 0 : _d.querySelector("[data-iui-index=\"".concat(nextIndex, "\"]"));
67
+ var nextElement = (_e = currentElement === null || currentElement === void 0 ? void 0 : currentElement.nextElementSibling) !== null && _e !== void 0 ? _e : (_f = menuRef.current) === null || _f === void 0 ? void 0 : _f.querySelector('[data-iui-index]');
68
+ nextIndex = Number(nextElement === null || nextElement === void 0 ? void 0 : nextElement.getAttribute('data-iui-index'));
69
+ if ((nextElement === null || nextElement === void 0 ? void 0 : nextElement.ariaDisabled) !== 'true') {
70
+ return dispatch(['focus', nextIndex]);
71
+ }
72
+ } while (nextIndex !== focusedIndexRef.current);
73
+ break;
74
+ }
75
+ case 'ArrowUp': {
76
+ event.preventDefault();
77
+ if (!isOpen) {
78
+ return dispatch(['open']);
79
+ }
80
+ if (length === 0) {
81
+ return;
82
+ }
83
+ if (focusedIndexRef.current === -1) {
84
+ return dispatch([
85
+ 'focus',
86
+ (_h = (_g = Object.values(optionsExtraInfoRef.current)) === null || _g === void 0 ? void 0 : _g[length - 1].__originalIndex) !== null && _h !== void 0 ? _h : -1,
87
+ ]);
88
+ }
89
+ var prevIndex = focusedIndexRef.current;
90
+ do {
91
+ var currentElement = (_j = menuRef.current) === null || _j === void 0 ? void 0 : _j.querySelector("[data-iui-index=\"".concat(prevIndex, "\"]"));
92
+ var prevElement = (_k = currentElement === null || currentElement === void 0 ? void 0 : currentElement.previousElementSibling) !== null && _k !== void 0 ? _k : (_l = menuRef.current) === null || _l === void 0 ? void 0 : _l.querySelector('[data-iui-index]:last-of-type');
93
+ prevIndex = Number(prevElement === null || prevElement === void 0 ? void 0 : prevElement.getAttribute('data-iui-index'));
94
+ if ((prevElement === null || prevElement === void 0 ? void 0 : prevElement.ariaDisabled) !== 'true') {
95
+ return dispatch(['focus', prevIndex]);
96
+ }
97
+ } while (prevIndex !== focusedIndexRef.current);
98
+ break;
99
+ }
100
+ case 'Enter': {
101
+ event.preventDefault();
102
+ if (isOpen) {
103
+ dispatch(['select', focusedIndexRef.current]);
104
+ }
105
+ else {
106
+ dispatch(['open']);
107
+ }
108
+ break;
109
+ }
110
+ case 'Escape': {
111
+ event.preventDefault();
112
+ dispatch(['close']);
113
+ break;
114
+ }
115
+ case 'Tab':
116
+ dispatch(['close']);
117
+ break;
118
+ }
119
+ }, [dispatch, isOpen, menuRef, onKeyDownProp, optionsExtraInfoRef]);
120
+ var handleFocus = React.useCallback(function (event) {
121
+ dispatch(['open']);
122
+ onFocusProp === null || onFocusProp === void 0 ? void 0 : onFocusProp(event);
123
+ }, [dispatch, onFocusProp]);
124
+ return (React.createElement(Input, __assign({ ref: refs, onKeyDown: handleKeyDown, onFocus: handleFocus, "aria-activedescendant": isOpen && focusedIndex != undefined && focusedIndex > -1
125
+ ? getIdFromIndex(focusedIndex)
126
+ : undefined, role: 'combobox', "aria-controls": isOpen ? "".concat(id, "-list") : undefined, "aria-autocomplete": 'list', spellCheck: false, autoCapitalize: 'none', autoCorrect: 'off' }, rest)));
127
+ });
128
+ 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,39 @@
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 { useSafeContext, useMergedRefs } from '../utils';
31
+ import { ComboBoxStateContext, ComboBoxRefsContext } from './helpers';
32
+ export var ComboBoxMenu = React.forwardRef(function (props, forwardedRef) {
33
+ var className = props.className, style = props.style, rest = __rest(props, ["className", "style"]);
34
+ var _a = useSafeContext(ComboBoxStateContext), minWidth = _a.minWidth, id = _a.id;
35
+ var menuRef = useSafeContext(ComboBoxRefsContext).menuRef;
36
+ var refs = useMergedRefs(menuRef, forwardedRef);
37
+ return (React.createElement(Menu, __assign({ id: "".concat(id, "-list"), style: React.useMemo(function () { return (__assign({ minWidth: minWidth, maxWidth: "min(".concat(minWidth * 2, "px, 90vw)"), maxHeight: 300 }, style)); }, [minWidth, style]), setFocus: false, role: 'listbox', ref: refs, className: cx('iui-scroll', className) }, rest)));
38
+ });
39
+ 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,59 @@
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 focusedIndex = useSafeContext(ComboBoxStateContext).focusedIndex;
34
+ var focusRef = function (el) {
35
+ // will need to check for virtualization here too
36
+ if (focusedIndex === index) {
37
+ el === null || el === void 0 ? void 0 : el.scrollIntoView({ block: 'nearest' });
38
+ }
39
+ };
40
+ var refs = useMergedRefs(forwardedRef, focusRef);
41
+ return (React.createElement("li", __assign({ className: cx('iui-menu-item', {
42
+ 'iui-large': size === 'large',
43
+ 'iui-active': isSelected,
44
+ 'iui-disabled': disabled,
45
+ 'iui-focused': focusedIndex === index,
46
+ }, 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),
47
+ icon &&
48
+ React.cloneElement(icon, {
49
+ className: cx(icon.props.className, 'iui-icon'),
50
+ }),
51
+ React.createElement("span", { className: 'iui-content' },
52
+ React.createElement("div", { className: 'iui-menu-label' }, children),
53
+ sublabel && React.createElement("div", { className: 'iui-menu-description' }, sublabel)),
54
+ badge &&
55
+ React.cloneElement(badge, {
56
+ className: cx(badge.props.className, 'iui-icon'),
57
+ })));
58
+ }));
59
+ ComboBoxMenuItem.displayName = 'ComboBoxMenuItem';
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ declare type ComboBoxAction = 'open' | 'close' | 'select' | 'focus';
3
+ export declare const comboBoxReducer: (state: {
4
+ isOpen: boolean;
5
+ selectedIndex: number;
6
+ focusedIndex: number;
7
+ }, [type, value]: [ComboBoxAction] | [ComboBoxAction, number | undefined]) => {
8
+ isOpen: boolean;
9
+ selectedIndex: number;
10
+ focusedIndex: number;
11
+ };
12
+ export declare const ComboBoxRefsContext: React.Context<{
13
+ inputRef: React.RefObject<HTMLInputElement>;
14
+ menuRef: React.RefObject<HTMLUListElement>;
15
+ toggleButtonRef: React.RefObject<HTMLSpanElement>;
16
+ optionsExtraInfoRef: React.MutableRefObject<Record<string, {
17
+ __originalIndex: number;
18
+ }>>;
19
+ } | undefined>;
20
+ export declare const ComboBoxStateContext: React.Context<{
21
+ isOpen: boolean;
22
+ id: string;
23
+ minWidth: number;
24
+ focusedIndex?: number | undefined;
25
+ } | undefined>;
26
+ export declare const ComboBoxActionContext: React.Context<((x: [ComboBoxAction] | [ComboBoxAction, number]) => void) | undefined>;
27
+ 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';
@@ -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;
@@ -64,7 +64,21 @@ export var Thumb = function (props) {
64
64
  }, [disabled, index, onThumbActivated]);
65
65
  var _a = React.useState(false), hasFocus = _a[0], setHasFocus = _a[1];
66
66
  var _b = React.useState(false), isHovered = _b[0], setIsHovered = _b[1];
67
- var leftPercent = (100.0 * (value - sliderMin)) / (sliderMax - sliderMin);
67
+ var adjustedValue = React.useMemo(function () {
68
+ if (value < sliderMin) {
69
+ return sliderMin;
70
+ }
71
+ if (value > sliderMax) {
72
+ return sliderMax;
73
+ }
74
+ return value;
75
+ }, [sliderMax, sliderMin, value]);
76
+ var leftPercent = React.useMemo(function () {
77
+ if (sliderMax === sliderMin) {
78
+ return 0;
79
+ }
80
+ return (100.0 * (adjustedValue - sliderMin)) / (sliderMax - sliderMin);
81
+ }, [adjustedValue, sliderMax, sliderMin]);
68
82
  var _c = thumbProps || {}, style = _c.style, className = _c.className, rest = __rest(_c, ["style", "className"]);
69
83
  return (React.createElement(Tooltip, __assign({ visible: isActive || hasFocus || isHovered, placement: 'top' }, tooltipProps),
70
84
  React.createElement("div", __assign({}, rest, { "data-index": index, ref: thumbRef, style: __assign(__assign({}, style), { left: "".concat(leftPercent, "%") }), className: cx('iui-slider-thumb', { 'iui-active': isActive }, className), role: 'slider', tabIndex: disabled ? undefined : 0, "aria-valuemin": minVal, "aria-valuenow": value, "aria-valuemax": maxVal, "aria-disabled": disabled, onPointerDown: handlePointerDownOnThumb, onKeyDown: handleOnKeyDown, onFocus: function () { return setHasFocus(true); }, onBlur: function () { return setHasFocus(false); }, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }))));
@@ -23,10 +23,18 @@ function shouldDisplaySegment(segmentIndex, mode) {
23
23
  }
24
24
  function generateSegments(values, min, max) {
25
25
  var segments = [];
26
+ var newValues = __spreadArray([], values, true);
27
+ newValues.sort(function (a, b) { return a - b; });
28
+ if (0 === newValues.length ||
29
+ newValues[0] < min ||
30
+ newValues[newValues.length - 1] > max ||
31
+ min === max) {
32
+ return [];
33
+ }
26
34
  var lastValue = min;
27
- for (var i = 0; i < values.length; i++) {
28
- segments.push({ left: lastValue, right: values[i] });
29
- lastValue = values[i];
35
+ for (var i = 0; i < newValues.length; i++) {
36
+ segments.push({ left: lastValue, right: newValues[i] });
37
+ lastValue = newValues[i];
30
38
  }
31
39
  segments.push({ left: lastValue, right: max });
32
40
  return segments;
@@ -37,18 +45,21 @@ function generateSegments(values, min, max) {
37
45
  */
38
46
  export var Track = function (props) {
39
47
  var trackDisplayMode = props.trackDisplayMode, sliderMin = props.sliderMin, sliderMax = props.sliderMax, values = props.values;
40
- var _a = React.useState(__spreadArray([], values, true).sort(function (a, b) { return a - b; })), currentValues = _a[0], setCurrentValues = _a[1];
48
+ var _a = React.useState(function () {
49
+ return generateSegments(values, sliderMin, sliderMax);
50
+ }), segments = _a[0], setSegments = _a[1];
41
51
  React.useEffect(function () {
42
- var newValues = __spreadArray([], values, true);
43
- newValues.sort(function (a, b) { return a - b; });
44
- setCurrentValues(newValues);
45
- }, [values]);
46
- var segments = React.useMemo(function () { return generateSegments(currentValues, sliderMin, sliderMax); }, [currentValues, sliderMin, sliderMax]);
52
+ setSegments(generateSegments(values, sliderMin, sliderMax));
53
+ }, [values, sliderMin, sliderMax]);
47
54
  return (React.createElement(React.Fragment, null, 'none' !== trackDisplayMode &&
48
55
  segments.map(function (segment, index) {
49
- var leftPercent = (100.0 * (segment.left - sliderMin)) / (sliderMax - sliderMin);
50
- var rightPercent = (100.0 * (segment.right - sliderMin)) / (sliderMax - sliderMin);
51
- rightPercent = 100.0 - rightPercent;
56
+ var leftPercent = segment.left >= sliderMin && sliderMax !== sliderMin
57
+ ? (100.0 * (segment.left - sliderMin)) / (sliderMax - sliderMin)
58
+ : 0;
59
+ var rightPercent = segment.right >= sliderMin && sliderMax !== sliderMin
60
+ ? 100.0 -
61
+ (100.0 * (segment.right - sliderMin)) / (sliderMax - sliderMin)
62
+ : 100;
52
63
  return (React.createElement(React.Fragment, { key: index }, shouldDisplaySegment(index, trackDisplayMode) ? (React.createElement("div", { className: 'iui-slider-track', style: { left: "".concat(leftPercent, "%"), right: "".concat(rightPercent, "%") } })) : null));
53
64
  })));
54
65
  };