@itwin/itwinui-react 1.37.3 → 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 (76) hide show
  1. package/CHANGELOG.md +16 -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/Table/Table.js +2 -2
  29. package/cjs/core/Table/filters/FilterToggle.js +3 -2
  30. package/cjs/core/Toast/ToastWrapper.d.ts +7 -5
  31. package/cjs/core/Toast/ToastWrapper.js +8 -4
  32. package/cjs/core/Toast/Toaster.d.ts +3 -0
  33. package/cjs/core/Toast/Toaster.js +66 -5
  34. package/cjs/core/utils/components/Popover.d.ts +1 -1
  35. package/cjs/core/utils/hooks/index.d.ts +1 -0
  36. package/cjs/core/utils/hooks/index.js +1 -0
  37. package/cjs/core/utils/hooks/useSafeContext.d.ts +6 -0
  38. package/cjs/core/utils/hooks/useSafeContext.js +23 -0
  39. package/esm/core/Breadcrumbs/Breadcrumbs.js +3 -5
  40. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  41. package/esm/core/ComboBox/ComboBox.d.ts +4 -2
  42. package/esm/core/ComboBox/ComboBox.js +131 -248
  43. package/esm/core/ComboBox/ComboBoxDropdown.d.ts +8 -0
  44. package/esm/core/ComboBox/ComboBoxDropdown.js +49 -0
  45. package/esm/core/ComboBox/ComboBoxEndIcon.d.ts +5 -0
  46. package/esm/core/ComboBox/ComboBoxEndIcon.js +48 -0
  47. package/esm/core/ComboBox/ComboBoxInput.d.ts +5 -0
  48. package/esm/core/ComboBox/ComboBoxInput.js +128 -0
  49. package/esm/core/ComboBox/ComboBoxInputContainer.d.ts +8 -0
  50. package/esm/core/ComboBox/ComboBoxInputContainer.js +38 -0
  51. package/esm/core/ComboBox/ComboBoxMenu.d.ts +3 -0
  52. package/esm/core/ComboBox/ComboBoxMenu.js +39 -0
  53. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +21 -0
  54. package/esm/core/ComboBox/ComboBoxMenuItem.js +59 -0
  55. package/esm/core/ComboBox/helpers.d.ts +27 -0
  56. package/esm/core/ComboBox/helpers.js +43 -0
  57. package/esm/core/Modal/Modal.d.ts +1 -1
  58. package/esm/core/Modal/Modal.js +6 -6
  59. package/esm/core/Modal/ModalButtonBar.d.ts +1 -1
  60. package/esm/core/Modal/ModalButtonBar.js +2 -2
  61. package/esm/core/Modal/ModalContent.d.ts +1 -1
  62. package/esm/core/Modal/ModalContent.js +2 -2
  63. package/esm/core/RadioTiles/RadioTile.d.ts +1 -1
  64. package/esm/core/RadioTiles/RadioTile.js +7 -9
  65. package/esm/core/Table/Table.js +2 -2
  66. package/esm/core/Table/filters/FilterToggle.js +3 -2
  67. package/esm/core/Toast/ToastWrapper.d.ts +7 -5
  68. package/esm/core/Toast/ToastWrapper.js +8 -3
  69. package/esm/core/Toast/Toaster.d.ts +3 -0
  70. package/esm/core/Toast/Toaster.js +66 -5
  71. package/esm/core/utils/components/Popover.d.ts +1 -1
  72. package/esm/core/utils/hooks/index.d.ts +1 -0
  73. package/esm/core/utils/hooks/index.js +1 -0
  74. package/esm/core/utils/hooks/useSafeContext.d.ts +6 -0
  75. package/esm/core/utils/hooks/useSafeContext.js +16 -0
  76. package/package.json +5 -33
@@ -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;
@@ -180,7 +180,7 @@ export var Table = function (props) {
180
180
  }
181
181
  return result;
182
182
  }, {});
183
- var areFiltersSet = allColumns.some(function (column) { return !!column.filterValue; });
183
+ var areFiltersSet = allColumns.some(function (column) { return column.filterValue != null && column.filterValue !== ''; });
184
184
  var onRowClickHandler = React.useCallback(function (event, row) {
185
185
  var isDisabled = isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original);
186
186
  if (!isDisabled) {
@@ -296,7 +296,7 @@ export var Table = function (props) {
296
296
  className: 'iui-row',
297
297
  });
298
298
  return (React.createElement("div", __assign({}, headerGroupProps, { key: headerGroupProps.key }), headerGroup.headers.map(function (column, index) {
299
- var columnProps = column.getHeaderProps(__assign(__assign({}, column.getSortByToggleProps()), { className: cx('iui-cell', { 'iui-actionable': column.canSort }, { 'iui-sorted': column.isSorted }, column.columnClassName), style: __assign({}, getCellStyle(column, !!state.isTableResizing)) }));
299
+ var columnProps = column.getHeaderProps(__assign(__assign({}, column.getSortByToggleProps()), { className: cx('iui-cell', { 'iui-actionable': column.canSort }, { 'iui-sorted': column.isSorted }, column.columnClassName), style: __assign(__assign({}, getCellStyle(column, !!state.isTableResizing)), { flexWrap: 'unset' }) }));
300
300
  return (React.createElement("div", __assign({}, columnProps, column.getDragAndDropProps(), { key: columnProps.key, title: undefined, ref: function (el) {
301
301
  if (el && isResizable) {
302
302
  columnRefs.current[column.id] = el;
@@ -47,10 +47,11 @@ export var FilterToggle = function (props) {
47
47
  column.setFilter(undefined);
48
48
  close();
49
49
  }, [close, column]);
50
+ var isColumnFiltered = column.filterValue != null && column.filterValue !== '';
50
51
  return (React.createElement(React.Fragment, null, column.canFilter && column.Filter && (React.createElement(Popover, { content: column.render('Filter', { close: close, setFilter: setFilter, clearFilter: clearFilter }), placement: 'bottom-start', visible: isVisible, onClickOutside: close, appendTo: ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body },
51
- React.createElement(IconButton, __assign({ styleType: 'borderless', isActive: isVisible || column.filterValue, className: cx('iui-filter-button', className), onClick: function (e) {
52
+ React.createElement(IconButton, __assign({ styleType: 'borderless', isActive: isVisible || isColumnFiltered, className: cx('iui-filter-button', className), onClick: function (e) {
52
53
  setIsVisible(function (v) { return !v; });
53
54
  // Prevents from triggering sort
54
55
  e.stopPropagation();
55
- } }, rest), column.filterValue ? React.createElement(SvgFilter, null) : React.createElement(SvgFilterHollow, null))))));
56
+ } }, rest), isColumnFiltered ? React.createElement(SvgFilter, null) : React.createElement(SvgFilterHollow, null))))));
56
57
  };
@@ -1,9 +1,11 @@
1
- /// <reference types="react" />
2
1
  import '@itwin/itwinui-css/css/toast-notification.css';
2
+ import React from 'react';
3
3
  import { ToastProps } from './Toast';
4
4
  import { ToasterSettings } from './Toaster';
5
- declare type ToastWrapperProps = {
6
- toasts: ToastProps[];
7
- } & Pick<ToasterSettings, 'placement'>;
8
- export declare const ToastWrapper: (props: ToastWrapperProps) => JSX.Element;
5
+ declare type ToastPlacement = NonNullable<ToasterSettings['placement']>;
6
+ export declare type ToastWrapperHandle = {
7
+ setToasts: (toasts: ToastProps[]) => void;
8
+ setPlacement: (placement: ToastPlacement) => void;
9
+ };
10
+ export declare const ToastWrapper: React.ForwardRefExoticComponent<React.RefAttributes<ToastWrapperHandle>>;
9
11
  export {};
@@ -17,10 +17,15 @@ import '@itwin/itwinui-css/css/toast-notification.css';
17
17
  import React from 'react';
18
18
  import cx from 'classnames';
19
19
  import Toast from './Toast';
20
- export var ToastWrapper = function (props) {
21
- var toasts = props.toasts, _a = props.placement, placement = _a === void 0 ? 'top' : _a;
20
+ export var ToastWrapper = React.forwardRef(function (_, ref) {
21
+ var _a = React.useState([]), toasts = _a[0], setToasts = _a[1];
22
+ var _b = React.useState('top'), placement = _b[0], setPlacement = _b[1];
22
23
  var placementPosition = placement.startsWith('top') ? 'top' : 'bottom';
24
+ React.useImperativeHandle(ref, function () { return ({
25
+ setToasts: setToasts,
26
+ setPlacement: setPlacement,
27
+ }); }, []);
23
28
  return (React.createElement("span", { className: cx("iui-toast-wrapper", "iui-placement-".concat(placement)) }, toasts.map(function (toastProps) {
24
29
  return (React.createElement(Toast, __assign({ key: toastProps.id, placementPosition: placementPosition }, toastProps)));
25
30
  })));
26
- };
31
+ });
@@ -20,6 +20,8 @@ export default class Toaster {
20
20
  private toasts;
21
21
  private lastId;
22
22
  private settings;
23
+ private toastsRef;
24
+ private isInitialized;
23
25
  /**
24
26
  * Set global Toaster settings for toasts order and placement.
25
27
  * Settings will be applied to new toasts on the page.
@@ -39,6 +41,7 @@ export default class Toaster {
39
41
  };
40
42
  private createToast;
41
43
  private removeToast;
44
+ private createContainer;
42
45
  private updateView;
43
46
  private closeToast;
44
47
  closeAll(): void;