@itwin/itwinui-react 1.31.0 → 1.33.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 (78) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/cjs/core/ButtonGroup/ButtonGroup.d.ts +8 -1
  3. package/cjs/core/ButtonGroup/ButtonGroup.js +7 -3
  4. package/cjs/core/Checkbox/Checkbox.d.ts +13 -0
  5. package/cjs/core/Checkbox/Checkbox.js +15 -22
  6. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  7. package/cjs/core/ComboBox/ComboBox.d.ts +17 -1
  8. package/cjs/core/ComboBox/ComboBox.js +55 -20
  9. package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +6 -0
  10. package/cjs/core/ExpandableBlock/ExpandableBlock.js +3 -2
  11. package/cjs/core/Footer/Footer.d.ts +14 -2
  12. package/cjs/core/Footer/Footer.js +40 -17
  13. package/cjs/core/InputGroup/InputGroup.js +12 -2
  14. package/cjs/core/LabeledSelect/LabeledSelect.js +10 -4
  15. package/cjs/core/Menu/Menu.js +3 -3
  16. package/cjs/core/Menu/MenuItem.js +1 -1
  17. package/cjs/core/Radio/Radio.d.ts +13 -0
  18. package/cjs/core/Radio/Radio.js +7 -8
  19. package/cjs/core/StatusMessage/StatusMessage.d.ts +24 -0
  20. package/cjs/core/StatusMessage/StatusMessage.js +39 -0
  21. package/cjs/core/StatusMessage/index.d.ts +4 -0
  22. package/cjs/core/StatusMessage/index.js +10 -0
  23. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +1 -1
  24. package/cjs/core/Tree/Tree.d.ts +123 -0
  25. package/cjs/core/Tree/Tree.js +177 -0
  26. package/cjs/core/Tree/TreeContext.d.ts +25 -0
  27. package/cjs/core/Tree/TreeContext.js +20 -0
  28. package/cjs/core/Tree/TreeNode.d.ts +87 -0
  29. package/cjs/core/Tree/TreeNode.js +169 -0
  30. package/cjs/core/Tree/TreeNodeExpander.d.ts +8 -0
  31. package/cjs/core/Tree/TreeNodeExpander.js +46 -0
  32. package/cjs/core/Tree/index.d.ts +6 -0
  33. package/cjs/core/Tree/index.js +13 -0
  34. package/cjs/core/index.d.ts +4 -0
  35. package/cjs/core/index.js +7 -1
  36. package/cjs/core/utils/components/InputContainer.d.ts +1 -0
  37. package/cjs/core/utils/components/InputContainer.js +8 -7
  38. package/cjs/core/utils/components/Popover.js +1 -1
  39. package/cjs/core/utils/functions/focusable.js +6 -2
  40. package/esm/core/ButtonGroup/ButtonGroup.d.ts +8 -1
  41. package/esm/core/ButtonGroup/ButtonGroup.js +7 -3
  42. package/esm/core/Checkbox/Checkbox.d.ts +13 -0
  43. package/esm/core/Checkbox/Checkbox.js +15 -22
  44. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  45. package/esm/core/ComboBox/ComboBox.d.ts +17 -1
  46. package/esm/core/ComboBox/ComboBox.js +56 -21
  47. package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +6 -0
  48. package/esm/core/ExpandableBlock/ExpandableBlock.js +3 -2
  49. package/esm/core/Footer/Footer.d.ts +14 -2
  50. package/esm/core/Footer/Footer.js +40 -17
  51. package/esm/core/InputGroup/InputGroup.js +12 -2
  52. package/esm/core/LabeledSelect/LabeledSelect.js +10 -4
  53. package/esm/core/Menu/Menu.js +3 -3
  54. package/esm/core/Menu/MenuItem.js +1 -1
  55. package/esm/core/Radio/Radio.d.ts +13 -0
  56. package/esm/core/Radio/Radio.js +7 -8
  57. package/esm/core/StatusMessage/StatusMessage.d.ts +24 -0
  58. package/esm/core/StatusMessage/StatusMessage.js +32 -0
  59. package/esm/core/StatusMessage/index.d.ts +4 -0
  60. package/esm/core/StatusMessage/index.js +6 -0
  61. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +1 -1
  62. package/esm/core/Tree/Tree.d.ts +123 -0
  63. package/esm/core/Tree/Tree.js +170 -0
  64. package/esm/core/Tree/TreeContext.d.ts +25 -0
  65. package/esm/core/Tree/TreeContext.js +13 -0
  66. package/esm/core/Tree/TreeNode.d.ts +87 -0
  67. package/esm/core/Tree/TreeNode.js +162 -0
  68. package/esm/core/Tree/TreeNodeExpander.d.ts +8 -0
  69. package/esm/core/Tree/TreeNodeExpander.js +39 -0
  70. package/esm/core/Tree/index.d.ts +6 -0
  71. package/esm/core/Tree/index.js +7 -0
  72. package/esm/core/index.d.ts +4 -0
  73. package/esm/core/index.js +2 -0
  74. package/esm/core/utils/components/InputContainer.d.ts +1 -0
  75. package/esm/core/utils/components/InputContainer.js +8 -7
  76. package/esm/core/utils/components/Popover.js +1 -1
  77. package/esm/core/utils/functions/focusable.js +6 -2
  78. package/package.json +2 -2
@@ -29,9 +29,10 @@ import cx from 'classnames';
29
29
  import { Input } from '../Input';
30
30
  import { Menu, MenuExtraContent, MenuItem } from '../Menu';
31
31
  import { Text } from '../Typography';
32
- import { InputContainer, useTheme, Popover, getFocusableElements, getRandomValue, } from '../utils';
32
+ import { InputContainer, useTheme, Popover, getFocusableElements, getRandomValue, mergeRefs, } from '../utils';
33
33
  import SvgCaretDownSmall from '@itwin/itwinui-icons-react/cjs/icons/CaretDownSmall';
34
34
  import 'tippy.js/animations/shift-away.css';
35
+ import { StatusMessage } from '../StatusMessage';
35
36
  /**
36
37
  * ComboBox component that allows typing a value to filter the options in dropdown list.
37
38
  * Values can be selected either using mouse clicks or using the Enter key.
@@ -46,7 +47,7 @@ import 'tippy.js/animations/shift-away.css';
46
47
  * />
47
48
  */
48
49
  export var ComboBox = function (props) {
49
- var options = props.options, value = props.value, onChange = props.onChange, filterFunction = props.filterFunction, className = props.className, inputProps = props.inputProps, dropdownMenuProps = props.dropdownMenuProps, _a = props.emptyStateMessage, emptyStateMessage = _a === void 0 ? 'No options found' : _a, rest = __rest(props, ["options", "value", "onChange", "filterFunction", "className", "inputProps", "dropdownMenuProps", "emptyStateMessage"]);
50
+ var options = props.options, value = props.value, onChange = props.onChange, filterFunction = props.filterFunction, className = props.className, inputProps = props.inputProps, dropdownMenuProps = props.dropdownMenuProps, message = props.message, status = props.status, _a = props.emptyStateMessage, emptyStateMessage = _a === void 0 ? 'No options found' : _a, itemRenderer = props.itemRenderer, rest = __rest(props, ["options", "value", "onChange", "filterFunction", "className", "inputProps", "dropdownMenuProps", "message", "status", "emptyStateMessage", "itemRenderer"]);
50
51
  // Generate a stateful random id if not specified
51
52
  var id = React.useState(function () {
52
53
  var _a, _b;
@@ -61,16 +62,31 @@ export var ComboBox = function (props) {
61
62
  return value === options[index].value;
62
63
  });
63
64
  }, [options, id]);
65
+ var userOnChange = React.useRef(onChange);
64
66
  var memoizedItems = React.useMemo(function () {
65
- return options.map(function (_a, index) {
66
- var label = _a.label, value = _a.value, rest = __rest(_a, ["label", "value"]);
67
- return (React.createElement(MenuItem, __assign({ id: getOptionId(index), key: getOptionId(index), value: value, role: 'option', onClick: function (value) {
67
+ return options.map(function (option, index) {
68
+ var label = option.label, value = option.value, rest = __rest(option, ["label", "value"]);
69
+ var additionalProps = {
70
+ value: value,
71
+ role: 'option',
72
+ onClick: function () {
73
+ var _a;
68
74
  setSelectedValue(value);
69
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
75
+ (_a = userOnChange.current) === null || _a === void 0 ? void 0 : _a.call(userOnChange, value);
70
76
  setIsOpen(false);
71
- } }, rest), label));
77
+ },
78
+ };
79
+ if (itemRenderer) {
80
+ return React.cloneElement(itemRenderer(option, {
81
+ id: getOptionId(index),
82
+ index: index,
83
+ isSelected: false,
84
+ isFocused: false,
85
+ }), additionalProps);
86
+ }
87
+ return (React.createElement(MenuItem, __assign({ id: getOptionId(index), key: getOptionId(index) }, additionalProps, rest), label));
72
88
  });
73
- }, [options, getOptionId, onChange]);
89
+ }, [options, getOptionId, itemRenderer]);
74
90
  var inputRef = React.useRef(null);
75
91
  var menuRef = React.useRef(null);
76
92
  var toggleButtonRef = React.useRef(null);
@@ -149,6 +165,7 @@ export var ComboBox = function (props) {
149
165
  });
150
166
  }, [inputValue, options, selectedValue, isOpen, filterFunction]);
151
167
  var onKeyDown = React.useCallback(function (event) {
168
+ var _a;
152
169
  var focusableOptions = getFocusableElements(menuRef.current);
153
170
  var focusedIndexInFilteredList = focusableOptions.findIndex(function (_a) {
154
171
  var _b;
@@ -182,7 +199,7 @@ export var ComboBox = function (props) {
182
199
  case 'Enter':
183
200
  if (isOpen) {
184
201
  setSelectedValue(options[focusedIndex].value);
185
- onChange === null || onChange === void 0 ? void 0 : onChange(options[focusedIndex].value);
202
+ (_a = userOnChange.current) === null || _a === void 0 ? void 0 : _a.call(userOnChange, options[focusedIndex].value);
186
203
  }
187
204
  setIsOpen(function (open) { return !open; });
188
205
  event.preventDefault();
@@ -202,26 +219,41 @@ export var ComboBox = function (props) {
202
219
  }
203
220
  break;
204
221
  }
205
- }, [focusedIndex, isOpen, options, getOptionId, onChange]);
222
+ }, [focusedIndex, isOpen, options, getOptionId]);
206
223
  var menuItems = React.useMemo(function () {
207
224
  if (filteredOptions.length === 0) {
208
- return (React.createElement(MenuExtraContent, null,
209
- React.createElement(Text, { isMuted: true }, emptyStateMessage)));
225
+ return [
226
+ React.createElement(MenuExtraContent, { key: 0 },
227
+ React.createElement(Text, { isMuted: true }, emptyStateMessage)),
228
+ ];
210
229
  }
211
230
  return filteredOptions.map(function (option) {
231
+ var _a;
212
232
  var index = options.findIndex(function (_a) {
213
233
  var value = _a.value;
214
234
  return option.value === value;
215
235
  });
216
236
  if (index < 0) {
217
- return;
237
+ return React.createElement(React.Fragment, null);
218
238
  }
219
- if (selectedValue === option.value || focusedIndex === index) {
220
- return React.cloneElement(memoizedItems[index], {
221
- isSelected: selectedValue === option.value,
222
- className: cx({ 'iui-focused': focusedIndex === index }),
223
- ref: function (el) {
224
- return focusedIndex === index && (el === null || el === void 0 ? void 0 : el.scrollIntoView(false));
239
+ var id = getOptionId(index);
240
+ var isSelected = selectedValue === option.value;
241
+ var isFocused = focusedIndex === index;
242
+ var focusScrollRef = function (el) {
243
+ return isFocused && (el === null || el === void 0 ? void 0 : el.scrollIntoView({ block: 'nearest' }));
244
+ };
245
+ if (isSelected || isFocused) {
246
+ var item = (_a = itemRenderer === null || itemRenderer === void 0 ? void 0 : itemRenderer(option, { index: index, id: id, isSelected: isSelected, isFocused: isFocused })) !== null && _a !== void 0 ? _a : React.cloneElement(memoizedItems[index], { isSelected: isSelected });
247
+ return React.cloneElement(item, {
248
+ className: cx({ 'iui-focused': isFocused }, item.props.className),
249
+ ref: mergeRefs(focusScrollRef, item.props.ref),
250
+ value: option.value,
251
+ role: 'option',
252
+ onClick: function () {
253
+ var _a;
254
+ setSelectedValue(option.value);
255
+ (_a = userOnChange.current) === null || _a === void 0 ? void 0 : _a.call(userOnChange, option.value);
256
+ setIsOpen(false);
225
257
  },
226
258
  });
227
259
  }
@@ -231,11 +263,14 @@ export var ComboBox = function (props) {
231
263
  filteredOptions,
232
264
  emptyStateMessage,
233
265
  options,
234
- focusedIndex,
266
+ getOptionId,
235
267
  selectedValue,
268
+ focusedIndex,
269
+ itemRenderer,
236
270
  memoizedItems,
237
271
  ]);
238
- return (React.createElement(InputContainer, __assign({ className: className, isIconInline: true }, rest, { id: id }),
272
+ return (React.createElement(InputContainer, __assign({ className: className, status: status, statusMessage: typeof message === 'string' ? (React.createElement(StatusMessage, { status: status }, message)) : (React.isValidElement(message) &&
273
+ React.cloneElement(message, { status: status })) }, rest, { id: id }),
239
274
  React.createElement("div", { className: 'iui-input-with-icon' },
240
275
  React.createElement(Popover, __assign({ placement: 'bottom-start', visible: isOpen, onClickOutside: function (_, _a) {
241
276
  var _b;
@@ -38,6 +38,12 @@ export declare type ExpandableBlockProps = {
38
38
  * @default 'default'
39
39
  */
40
40
  size?: 'default' | 'small';
41
+ /**
42
+ * Style of the ExpandableBlock.
43
+ * Use 'borderless' to hide outline.
44
+ * @default 'default'
45
+ */
46
+ styleType?: 'default' | 'borderless';
41
47
  } & Omit<CommonProps, 'title'>;
42
48
  /**
43
49
  * Container that allows content to be hidden behind a brief title and a caption.
@@ -40,10 +40,10 @@ import '@itwin/itwinui-css/css/expandable-block.css';
40
40
  */
41
41
  export var ExpandableBlock = function (props) {
42
42
  var _a;
43
- var caption = props.caption, children = props.children, className = props.className, title = props.title, onToggle = props.onToggle, style = props.style, _b = props.isExpanded, isExpanded = _b === void 0 ? false : _b, endIcon = props.endIcon, status = props.status, _c = props.size, size = _c === void 0 ? 'default' : _c, rest = __rest(props, ["caption", "children", "className", "title", "onToggle", "style", "isExpanded", "endIcon", "status", "size"]);
43
+ var caption = props.caption, children = props.children, className = props.className, title = props.title, onToggle = props.onToggle, style = props.style, _b = props.isExpanded, isExpanded = _b === void 0 ? false : _b, endIcon = props.endIcon, status = props.status, _c = props.size, size = _c === void 0 ? 'default' : _c, _d = props.styleType, styleType = _d === void 0 ? 'default' : _d, rest = __rest(props, ["caption", "children", "className", "title", "onToggle", "style", "isExpanded", "endIcon", "status", "size", "styleType"]);
44
44
  useTheme();
45
45
  var icon = endIcon !== null && endIcon !== void 0 ? endIcon : (status && StatusIconMap[status]());
46
- var _d = React.useState(isExpanded), expanded = _d[0], setExpanded = _d[1];
46
+ var _e = React.useState(isExpanded), expanded = _e[0], setExpanded = _e[1];
47
47
  React.useEffect(function () {
48
48
  setExpanded(isExpanded);
49
49
  }, [isExpanded]);
@@ -62,6 +62,7 @@ export var ExpandableBlock = function (props) {
62
62
  'iui-with-caption': !!caption,
63
63
  'iui-expanded': expanded,
64
64
  'iui-small': size === 'small',
65
+ 'iui-borderless': styleType === 'borderless',
65
66
  }, className), style: style }, rest),
66
67
  React.createElement("div", { "aria-expanded": expanded, className: 'iui-header', tabIndex: 0, onClick: handleToggle, onKeyDown: onKeyDown },
67
68
  React.createElement(SvgChevronRight, { className: 'iui-icon', "aria-hidden": true }),
@@ -11,8 +11,10 @@ export declare type TitleTranslations = {
11
11
  export declare type FooterProps = {
12
12
  /**
13
13
  * Customize footer elements.
14
+ * Providing a `FooterElement[]` will append the custom elements to the end of the default elements.
15
+ * Providing a function that returns a `FooterElement[]` allows further customization - whatever is returned from the function is displayed in the footer with no amendments.
14
16
  */
15
- customElements?: FooterElement[];
17
+ customElements?: FooterElement[] | ((defaultElements: FooterElement[]) => FooterElement[]);
16
18
  /**
17
19
  * Provide localized strings.
18
20
  */
@@ -27,13 +29,23 @@ export declare type FooterElement = {
27
29
  * URL of the footer element.
28
30
  */
29
31
  url?: string;
32
+ /**
33
+ * Key of the footer element.
34
+ */
35
+ key?: keyof TitleTranslations | 'copyright' | (string & Record<never, never>);
30
36
  };
31
37
  /**
32
38
  * Footer element with all needed legal and info links.
33
39
  * Be sure to place it manually at the bottom of your page.
34
40
  * You can use position 'absolute' with relative body or set the height of the content and place footer at the end.
35
- * @example
41
+ * @example <caption>Appending custom element after default elements</caption>
36
42
  * <Footer customElements={[{title: 'Bentley', url: 'https://www.bentley.com/'}]} />
43
+ * @example <caption>Returning only custom elements</caption>
44
+ * <Footer customElements={() => newFooterElements)} />
45
+ * @example <caption>Filtering out a specific element</caption>
46
+ * <Footer customElements={(defaultElements) => defaultElements.filter(({ key }) => key !== 'privacy' )} />
47
+ * @example <caption>Changing a url</caption>
48
+ * <Footer customElements={(defaultElements) => defaultElements.map(element => ({ ...element, url: element.key === 'privacy' ? customPrivacyUrl : element.url }))} />
37
49
  */
38
50
  export declare const Footer: (props: FooterProps) => JSX.Element;
39
51
  export default Footer;
@@ -48,39 +48,62 @@ var footerTranslations = {
48
48
  * Footer element with all needed legal and info links.
49
49
  * Be sure to place it manually at the bottom of your page.
50
50
  * You can use position 'absolute' with relative body or set the height of the content and place footer at the end.
51
- * @example
51
+ * @example <caption>Appending custom element after default elements</caption>
52
52
  * <Footer customElements={[{title: 'Bentley', url: 'https://www.bentley.com/'}]} />
53
+ * @example <caption>Returning only custom elements</caption>
54
+ * <Footer customElements={() => newFooterElements)} />
55
+ * @example <caption>Filtering out a specific element</caption>
56
+ * <Footer customElements={(defaultElements) => defaultElements.filter(({ key }) => key !== 'privacy' )} />
57
+ * @example <caption>Changing a url</caption>
58
+ * <Footer customElements={(defaultElements) => defaultElements.map(element => ({ ...element, url: element.key === 'privacy' ? customPrivacyUrl : element.url }))} />
53
59
  */
54
60
  export var Footer = function (props) {
55
61
  var customElements = props.customElements, translatedTitles = props.translatedTitles, className = props.className, rest = __rest(props, ["customElements", "translatedTitles", "className"]);
56
62
  useTheme();
57
- var today = new Date();
58
63
  var titles = __assign(__assign({}, footerTranslations), translatedTitles);
59
64
  var defaultElements = [
60
65
  {
66
+ key: 'copyright',
67
+ title: "\u00A9 " + new Date().getFullYear() + " Bentley Systems, Incorporated",
68
+ },
69
+ {
70
+ key: 'termsOfService',
61
71
  title: titles.termsOfService,
62
72
  url: 'https://connect-agreementportal.bentley.com/AgreementApp/Home/Eula/view/readonly/BentleyConnect',
63
73
  },
64
- { title: titles.privacy, url: 'https://www.bentley.com/en/privacy-policy' },
65
74
  {
75
+ key: 'privacy',
76
+ title: titles.privacy,
77
+ url: 'https://www.bentley.com/en/privacy-policy',
78
+ },
79
+ {
80
+ key: 'termsOfUse',
66
81
  title: titles.termsOfUse,
67
82
  url: 'https://www.bentley.com/en/terms-of-use-and-select-online-agreement',
68
83
  },
69
- { title: titles.cookies, url: 'https://www.bentley.com/en/cookie-policy' },
70
- { title: titles.legalNotices, url: 'https://connect.bentley.com/Legal' },
84
+ {
85
+ key: 'cookies',
86
+ title: titles.cookies,
87
+ url: 'https://www.bentley.com/en/cookie-policy',
88
+ },
89
+ {
90
+ key: 'legalNotices',
91
+ title: titles.legalNotices,
92
+ url: 'https://connect.bentley.com/Legal',
93
+ },
71
94
  ];
72
- var elements = customElements
73
- ? __spreadArray(__spreadArray([], defaultElements, true), customElements, true) : defaultElements;
95
+ var elements = defaultElements;
96
+ if (customElements) {
97
+ elements =
98
+ typeof customElements === 'function'
99
+ ? customElements(defaultElements)
100
+ : __spreadArray(__spreadArray([], defaultElements, true), customElements, true);
101
+ }
74
102
  return (React.createElement("footer", __assign({ className: cx('iui-legal-footer', className) }, rest),
75
- React.createElement("ul", null,
76
- React.createElement("li", null,
77
- "\u00A9 ",
78
- today.getFullYear(),
79
- " Bentley Systems, Incorporated"),
80
- elements.map(function (element, index) {
81
- return (React.createElement("li", { key: element.title + "-" + index },
82
- React.createElement("span", { className: 'iui-separator' }),
83
- element.url ? (React.createElement("a", { href: element.url, target: '_blank', rel: 'noreferrer' }, element.title)) : (element.title)));
84
- }))));
103
+ React.createElement("ul", null, elements.map(function (element, index) {
104
+ return (React.createElement("li", { key: element.key || element.title + "-" + index },
105
+ index > 0 && React.createElement("span", { className: 'iui-separator' }),
106
+ element.url ? (React.createElement("a", { href: element.url, target: '_blank', rel: 'noreferrer' }, element.title)) : (element.title)));
107
+ }))));
85
108
  };
86
109
  export default Footer;
@@ -45,8 +45,18 @@ import '@itwin/itwinui-css/css/inputs.css';
45
45
  export var InputGroup = function (props) {
46
46
  var children = props.children, _a = props.disabled, disabled = _a === void 0 ? false : _a, _b = props.displayStyle, displayStyle = _b === void 0 ? 'default' : _b, label = props.label, message = props.message, status = props.status, svgIcon = props.svgIcon, className = props.className, style = props.style, _c = props.required, required = _c === void 0 ? false : _c, rest = __rest(props, ["children", "disabled", "displayStyle", "label", "message", "status", "svgIcon", "className", "style", "required"]);
47
47
  useTheme();
48
- var icon = svgIcon !== null && svgIcon !== void 0 ? svgIcon : (status && StatusIconMap[status]());
49
- return (React.createElement(InputContainer, __assign({ label: label, disabled: disabled, required: required, status: status, message: message, icon: icon ? React.cloneElement(icon, { 'aria-hidden': true }) : undefined, isLabelInline: displayStyle === 'inline', className: className, style: style }, rest),
48
+ var icon = function () {
49
+ if (svgIcon) {
50
+ return React.cloneElement(svgIcon, { 'aria-hidden': true });
51
+ }
52
+ if (status && message) {
53
+ return React.cloneElement(StatusIconMap[status](), {
54
+ 'aria-hidden': true,
55
+ });
56
+ }
57
+ return undefined;
58
+ };
59
+ return (React.createElement(InputContainer, __assign({ label: label, disabled: disabled, required: required, status: status, message: message, icon: icon(), isLabelInline: displayStyle === 'inline', className: className, style: style }, rest),
50
60
  React.createElement("div", { className: 'iui-input-group' }, children)));
51
61
  };
52
62
  export default InputGroup;
@@ -64,10 +64,16 @@ import '@itwin/itwinui-css/css/inputs.css';
64
64
  export var LabeledSelect = function (props) {
65
65
  var className = props.className, _a = props.disabled, disabled = _a === void 0 ? false : _a, label = props.label, message = props.message, status = props.status, svgIcon = props.svgIcon, _b = props.displayStyle, displayStyle = _b === void 0 ? 'default' : _b, style = props.style, selectClassName = props.selectClassName, selectStyle = props.selectStyle, _c = props.required, required = _c === void 0 ? false : _c, rest = __rest(props, ["className", "disabled", "label", "message", "status", "svgIcon", "displayStyle", "style", "selectClassName", "selectStyle", "required"]);
66
66
  useTheme();
67
- var icon = svgIcon !== null && svgIcon !== void 0 ? svgIcon : (status && StatusIconMap[status]());
68
- return (React.createElement(InputContainer, { label: label, disabled: disabled, required: required, status: status, message: message, icon: displayStyle === 'default' && icon
69
- ? React.cloneElement(icon, { 'aria-hidden': true })
70
- : undefined, isLabelInline: displayStyle === 'inline', className: className, style: style },
67
+ var icon = function () {
68
+ if (svgIcon) {
69
+ return React.cloneElement(svgIcon, { 'aria-hidden': true });
70
+ }
71
+ if (status && message) {
72
+ return StatusIconMap[status]();
73
+ }
74
+ return undefined;
75
+ };
76
+ return (React.createElement(InputContainer, { label: label, disabled: disabled, required: required, status: status, message: message, icon: displayStyle === 'default' ? icon() : undefined, isLabelInline: displayStyle === 'inline', className: className, style: style },
71
77
  React.createElement(Select, __assign({ disabled: disabled, className: selectClassName, style: selectStyle }, rest))));
72
78
  };
73
79
  export default LabeledSelect;
@@ -37,6 +37,9 @@ export var Menu = React.forwardRef(function (props, ref) {
37
37
  var _c = React.useState(), focusedIndex = _c[0], setFocusedIndex = _c[1];
38
38
  var menuRef = React.useRef(null);
39
39
  var refs = useMergedRefs(menuRef, ref);
40
+ React.useEffect(function () {
41
+ setFocusedIndex(null);
42
+ }, [children]);
40
43
  React.useEffect(function () {
41
44
  var _a;
42
45
  var items = getFocusableElements(menuRef.current);
@@ -49,9 +52,6 @@ export var Menu = React.forwardRef(function (props, ref) {
49
52
  setFocusedIndex(selectedIndex > -1 ? selectedIndex : 0);
50
53
  }
51
54
  }, [setFocus, focusedIndex]);
52
- React.useEffect(function () {
53
- setFocusedIndex(null);
54
- }, [children]);
55
55
  var onKeyDown = function (event) {
56
56
  var items = getFocusableElements(menuRef.current);
57
57
  if (!(items === null || items === void 0 ? void 0 : items.length)) {
@@ -100,7 +100,7 @@ export var MenuItem = React.forwardRef(function (props, ref) {
100
100
  className: cx(badge.props.className, 'iui-icon'),
101
101
  })));
102
102
  return subMenuItems.length === 0 ? (listItem) : (React.createElement(MenuItemContext.Provider, { value: { ref: menuItemRef } },
103
- React.createElement(Popover, { placement: 'right-start', visible: isSubmenuVisible, content: React.createElement("div", { onMouseLeave: function () { return setIsSubmenuVisible(false); }, onBlur: function (e) {
103
+ React.createElement(Popover, { placement: 'right-start', visible: isSubmenuVisible, appendTo: 'parent', content: React.createElement("div", { onMouseLeave: function () { return setIsSubmenuVisible(false); }, onBlur: function (e) {
104
104
  var _a, _b;
105
105
  !!(e.relatedTarget instanceof Node) &&
106
106
  !((_a = subMenuRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.relatedTarget)) &&
@@ -11,10 +11,16 @@ export declare type RadioProps = {
11
11
  status?: 'positive' | 'warning' | 'negative';
12
12
  /**
13
13
  * Custom CSS class name for the checkmark element.
14
+ *
15
+ * @deprecated As of 1.32.0, this is applied on the actual radio `<input>` element.
16
+ * The checkmark has been moved into a pseudo-element.
14
17
  */
15
18
  checkmarkClassName?: string;
16
19
  /**
17
20
  * Custom CSS Style for the checkmark element.
21
+ *
22
+ * @deprecated As of 1.32.0, this is applied on the actual radio `<input>` element.
23
+ * The checkmark has been moved into a pseudo-element.
18
24
  */
19
25
  checkmarkStyle?: React.CSSProperties;
20
26
  /**
@@ -26,6 +32,7 @@ export declare type RadioProps = {
26
32
  /**
27
33
  * Basic radio input component
28
34
  * @example
35
+ * <Radio />
29
36
  * <Radio label='Radio' />
30
37
  * <Radio disabled={true} label='Radio' />
31
38
  * <Radio status='positive' label='Positive' />
@@ -43,10 +50,16 @@ export declare const Radio: React.ForwardRefExoticComponent<{
43
50
  status?: "positive" | "warning" | "negative" | undefined;
44
51
  /**
45
52
  * Custom CSS class name for the checkmark element.
53
+ *
54
+ * @deprecated As of 1.32.0, this is applied on the actual radio `<input>` element.
55
+ * The checkmark has been moved into a pseudo-element.
46
56
  */
47
57
  checkmarkClassName?: string | undefined;
48
58
  /**
49
59
  * Custom CSS Style for the checkmark element.
60
+ *
61
+ * @deprecated As of 1.32.0, this is applied on the actual radio `<input>` element.
62
+ * The checkmark has been moved into a pseudo-element.
50
63
  */
51
64
  checkmarkStyle?: React.CSSProperties | undefined;
52
65
  /**
@@ -31,6 +31,7 @@ import '@itwin/itwinui-css/css/inputs.css';
31
31
  /**
32
32
  * Basic radio input component
33
33
  * @example
34
+ * <Radio />
34
35
  * <Radio label='Radio' />
35
36
  * <Radio disabled={true} label='Radio' />
36
37
  * <Radio status='positive' label='Positive' />
@@ -38,8 +39,8 @@ import '@itwin/itwinui-css/css/inputs.css';
38
39
  * <Radio status='negative' label='Negative' />
39
40
  */
40
41
  export var Radio = React.forwardRef(function (props, ref) {
41
- var _a;
42
- var className = props.className, _b = props.disabled, disabled = _b === void 0 ? false : _b, label = props.label, status = props.status, style = props.style, checkmarkClassName = props.checkmarkClassName, checkmarkStyle = props.checkmarkStyle, _c = props.setFocus, setFocus = _c === void 0 ? false : _c, rest = __rest(props, ["className", "disabled", "label", "status", "style", "checkmarkClassName", "checkmarkStyle", "setFocus"]);
42
+ var _a, _b;
43
+ var className = props.className, _c = props.disabled, disabled = _c === void 0 ? false : _c, label = props.label, status = props.status, style = props.style, checkmarkClassName = props.checkmarkClassName, checkmarkStyle = props.checkmarkStyle, _d = props.setFocus, setFocus = _d === void 0 ? false : _d, rest = __rest(props, ["className", "disabled", "label", "status", "style", "checkmarkClassName", "checkmarkStyle", "setFocus"]);
43
44
  useTheme();
44
45
  var inputElementRef = React.useRef(null);
45
46
  var refs = useMergedRefs(inputElementRef, ref);
@@ -48,11 +49,9 @@ export var Radio = React.forwardRef(function (props, ref) {
48
49
  inputElementRef.current.focus();
49
50
  }
50
51
  }, [setFocus]);
51
- return (React.createElement("label", { className: cx('iui-radio', (_a = { 'iui-disabled': disabled }, _a["iui-" + status] = !!status, _a), className), style: style },
52
- React.createElement("input", __assign({ disabled: disabled, type: 'radio', ref: refs }, rest)),
53
- React.createElement("span", { className: cx('iui-radio-dot', checkmarkClassName), style: checkmarkStyle },
54
- React.createElement("svg", { viewBox: '0 0 16 16', "aria-hidden": 'true', focusable: 'false' },
55
- React.createElement("circle", { cx: '8', cy: '8', r: '4' }))),
56
- label && React.createElement("span", { className: 'iui-label' }, label)));
52
+ var radio = (React.createElement("input", __assign({ className: cx('iui-radio', className && (_a = {}, _a[className] = !label, _a), checkmarkClassName), style: __assign(__assign({}, (!label && style)), checkmarkStyle), disabled: disabled, type: 'radio', ref: refs }, rest)));
53
+ return !label ? (radio) : (React.createElement("label", { className: cx('iui-radio-wrapper', (_b = { 'iui-disabled': disabled }, _b["iui-" + status] = !!status, _b), className), style: style },
54
+ radio,
55
+ label && React.createElement("span", { className: 'iui-radio-label' }, label)));
57
56
  });
58
57
  export default Radio;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ export declare type StatusMessageProps = {
3
+ /**
4
+ * Custom icon to be displayed at the beginning.
5
+ * It will default to the `status` icon, if it's set.
6
+ */
7
+ startIcon?: JSX.Element;
8
+ /**
9
+ * Message content.
10
+ */
11
+ children: React.ReactNode;
12
+ /**
13
+ * Status of the message.
14
+ */
15
+ status?: 'positive' | 'warning' | 'negative';
16
+ };
17
+ /**
18
+ * Component to display icon and text below the `Combobox` component.
19
+ * @example
20
+ * <StatusMessage>This is the text</StatusMessage>
21
+ * <StatusMessage startIcon={<SvgStar />}>This is the text</StatusMessage>
22
+ */
23
+ export declare const StatusMessage: ({ startIcon: userStartIcon, children, status, }: StatusMessageProps) => JSX.Element;
24
+ export default StatusMessage;
@@ -0,0 +1,32 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import React from 'react';
6
+ import { StatusIconMap, useTheme } from '../utils';
7
+ import cx from 'classnames';
8
+ /**
9
+ * Component to display icon and text below the `Combobox` component.
10
+ * @example
11
+ * <StatusMessage>This is the text</StatusMessage>
12
+ * <StatusMessage startIcon={<SvgStar />}>This is the text</StatusMessage>
13
+ */
14
+ export var StatusMessage = function (_a) {
15
+ var userStartIcon = _a.startIcon, children = _a.children, status = _a.status;
16
+ useTheme();
17
+ var StartIcon = function () {
18
+ var _a;
19
+ var icon = userStartIcon !== null && userStartIcon !== void 0 ? userStartIcon : (status && StatusIconMap[status]());
20
+ if (!icon) {
21
+ return null;
22
+ }
23
+ return React.cloneElement(icon, {
24
+ className: cx('iui-input-icon', (_a = icon.props) === null || _a === void 0 ? void 0 : _a.className),
25
+ 'aria-hidden': true,
26
+ });
27
+ };
28
+ return (React.createElement(React.Fragment, null,
29
+ React.createElement(StartIcon, null),
30
+ React.createElement("div", { className: 'iui-message' }, children)));
31
+ };
32
+ export default StatusMessage;
@@ -0,0 +1,4 @@
1
+ export { StatusMessage } from './StatusMessage';
2
+ export type { StatusMessageProps } from './StatusMessage';
3
+ declare const _default: "./StatusMessage";
4
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ export { StatusMessage } from './StatusMessage';
6
+ export default './StatusMessage';
@@ -63,7 +63,7 @@ var DatePickerInput = function (props) {
63
63
  if (!((_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
64
64
  close();
65
65
  }
66
- } },
66
+ }, appendTo: 'parent' },
67
67
  React.createElement(LabeledInput, __assign({ displayStyle: 'inline', value: inputValue, onChange: onInputChange, onClick: close, svgIcon: React.createElement(IconButton, { styleType: 'borderless', onClick: function () { return setIsVisible(function (v) { return !v; }); }, ref: buttonRef },
68
68
  React.createElement(SvgCalendar, null)) }, rest))));
69
69
  };