@itwin/itwinui-react 3.2.4 → 3.3.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 (61) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/cjs/core/ComboBox/ComboBox.d.ts +3 -1
  3. package/cjs/core/ComboBox/ComboBox.js +3 -4
  4. package/cjs/core/ComboBox/ComboBoxInputContainer.js +1 -1
  5. package/cjs/core/Dialog/DialogContext.d.ts +1 -0
  6. package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +7 -4
  7. package/cjs/core/ExpandableBlock/ExpandableBlock.js +25 -12
  8. package/cjs/core/InputGrid/InputGrid.d.ts +7 -5
  9. package/cjs/core/InputGrid/InputGrid.js +175 -6
  10. package/cjs/core/InputGroup/InputGroup.d.ts +1 -1
  11. package/cjs/core/InputGroup/InputGroup.js +4 -13
  12. package/cjs/core/LabeledInput/LabeledInput.d.ts +1 -2
  13. package/cjs/core/LabeledInput/LabeledInput.js +11 -8
  14. package/cjs/core/LabeledSelect/LabeledSelect.d.ts +18 -0
  15. package/cjs/core/LabeledSelect/LabeledSelect.js +5 -20
  16. package/cjs/core/List/ListItem.d.ts +10 -0
  17. package/cjs/core/List/ListItem.js +14 -0
  18. package/cjs/core/Menu/MenuItem.d.ts +1 -1
  19. package/cjs/core/Modal/Modal.d.ts +3 -4
  20. package/cjs/core/Select/Select.js +2 -2
  21. package/cjs/core/StatusMessage/StatusMessage.d.ts +4 -2
  22. package/cjs/core/StatusMessage/StatusMessage.js +3 -1
  23. package/cjs/core/Table/columns/selectionColumn.d.ts +1 -1
  24. package/cjs/core/Table/columns/selectionColumn.js +3 -3
  25. package/cjs/core/utils/components/InputWithIcon.d.ts +2 -0
  26. package/cjs/core/utils/components/InputWithIcon.js +11 -0
  27. package/cjs/core/utils/components/Portal.d.ts +5 -1
  28. package/cjs/core/utils/components/Portal.js +6 -2
  29. package/cjs/core/utils/components/index.d.ts +1 -0
  30. package/cjs/core/utils/components/index.js +1 -0
  31. package/esm/core/ComboBox/ComboBox.d.ts +3 -1
  32. package/esm/core/ComboBox/ComboBox.js +3 -3
  33. package/esm/core/ComboBox/ComboBoxInputContainer.js +2 -2
  34. package/esm/core/Dialog/DialogContext.d.ts +1 -0
  35. package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +7 -4
  36. package/esm/core/ExpandableBlock/ExpandableBlock.js +26 -13
  37. package/esm/core/InputGrid/InputGrid.d.ts +7 -5
  38. package/esm/core/InputGrid/InputGrid.js +176 -7
  39. package/esm/core/InputGroup/InputGroup.d.ts +1 -1
  40. package/esm/core/InputGroup/InputGroup.js +5 -14
  41. package/esm/core/LabeledInput/LabeledInput.d.ts +1 -2
  42. package/esm/core/LabeledInput/LabeledInput.js +8 -9
  43. package/esm/core/LabeledSelect/LabeledSelect.d.ts +18 -0
  44. package/esm/core/LabeledSelect/LabeledSelect.js +5 -19
  45. package/esm/core/List/ListItem.d.ts +10 -0
  46. package/esm/core/List/ListItem.js +14 -0
  47. package/esm/core/Menu/MenuItem.d.ts +1 -1
  48. package/esm/core/Modal/Modal.d.ts +3 -4
  49. package/esm/core/Select/Select.js +3 -3
  50. package/esm/core/StatusMessage/StatusMessage.d.ts +4 -2
  51. package/esm/core/StatusMessage/StatusMessage.js +3 -1
  52. package/esm/core/Table/columns/selectionColumn.d.ts +1 -1
  53. package/esm/core/Table/columns/selectionColumn.js +3 -3
  54. package/esm/core/utils/components/InputWithIcon.d.ts +2 -0
  55. package/esm/core/utils/components/InputWithIcon.js +8 -0
  56. package/esm/core/utils/components/Portal.d.ts +5 -1
  57. package/esm/core/utils/components/Portal.js +6 -2
  58. package/esm/core/utils/components/index.d.ts +1 -0
  59. package/esm/core/utils/components/index.js +1 -0
  60. package/package.json +3 -3
  61. package/styles.css +7 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1753](https://github.com/iTwin/iTwinUI/pull/1753): `LabeledInput` and `LabeledTextarea` have been slightly reworked to fix alignment and consistency issues when used with `svgIcon`.
8
+ - [#1777](https://github.com/iTwin/iTwinUI/pull/1777): `InputGrid` will now attempt to automatically associate labels, inputs and status messages with each other, in the event that they haven't been explicitly associated.
9
+ - [#1777](https://github.com/iTwin/iTwinUI/pull/1777): The `message` passed to `LabeledInput`, `LabeledTextarea`, `LabeledSelect` and `ComboBox` will now be associated with the input using `aria-describedby` for better accessibility.
10
+ - [#1794](https://github.com/iTwin/iTwinUI/pull/1794): `ExpandableBlock` now internally uses `LinkAction` for the trigger element. This slightly improves the accessibility, and opens up the possibility of including secondary actions.
11
+ - [#1786](https://github.com/iTwin/iTwinUI/pull/1786): The `portal.to` prop in floating elements now also accepts `null | undefined` which acts identically to the default prop behavior (i.e. as if `portal` was not passed). Components affected: `Dialog`, `DropdownMenu`, `Modal`, `Popover`, `SplitButton`, and `Tooltip`.
12
+ - [#1791](https://github.com/iTwin/iTwinUI/pull/1791): Added new `ListItem.Action` component for rendering links inside `ListItem`s while ensuring that clicking anywhere on the list item triggers the link. This component is a wrapper over the existing `LinkAction` component.
13
+ - [#1780](https://github.com/iTwin/iTwinUI/pull/1780): `ComboBox` now forwards its `ref`.
14
+ - [#1753](https://github.com/iTwin/iTwinUI/pull/1753): `StatusMessage` now renders no status icon if `startIcon === null`.
15
+
16
+ ### Patch Changes
17
+
18
+ - [#1783](https://github.com/iTwin/iTwinUI/pull/1783): Fixed a Firefox-specific bug where focus outlines were not appearing correctly around menu items inside `ComboBox`.
19
+ - [#1792](https://github.com/iTwin/iTwinUI/pull/1792): Fixed an issue in `Table` where the "select all" checkbox was disabled if all top-level rows were disabled. The logic has been updated to also consider sub-rows.
20
+ - [#1788](https://github.com/iTwin/iTwinUI/pull/1788): `LinkAction` will no longer override styles from other components (such as `Anchor`).
21
+ - [#1753](https://github.com/iTwin/iTwinUI/pull/1753): Deprecated `svgIcon` in `LabeledSelect` in favor of passing `<StatusMessage startIcon={svgIcon} />` to the `message` prop.
22
+ - [#1787](https://github.com/iTwin/iTwinUI/pull/1787): Button, radial progress indicator, & select icons now use the correct icon variable color fill.
23
+
3
24
  ## 3.2.4
4
25
 
5
26
  ### Patch Changes
@@ -102,5 +102,7 @@ export type ComboBoxProps<T> = {
102
102
  * onChange={() => {}}
103
103
  * />
104
104
  */
105
- export declare const ComboBox: <T>(props: ComboBoxProps<T>) => React.JSX.Element;
105
+ export declare const ComboBox: <T>(props: ComboBoxProps<T> & {
106
+ ref?: React.ForwardedRef<HTMLElement> | undefined;
107
+ }) => JSX.Element;
106
108
  export default ComboBox;
@@ -65,7 +65,7 @@ const getOptionId = (option, idPrefix) => {
65
65
  * onChange={() => {}}
66
66
  * />
67
67
  */
68
- const ComboBox = (props) => {
68
+ exports.ComboBox = React.forwardRef((props, forwardedRef) => {
69
69
  const idPrefix = (0, index_js_1.useId)();
70
70
  const { options, value: valueProp, onChange, filterFunction, inputProps, endIconProps, dropdownMenuProps, emptyStateMessage = 'No options found', itemRenderer, enableVirtualization = false, multiple = false, onShow: onShowProp, onHide: onHideProp, id = inputProps?.id ? `iui-${inputProps.id}-cb` : idPrefix, ...rest } = props;
71
71
  // Refs get set in subcomponents
@@ -325,7 +325,7 @@ const ComboBox = (props) => {
325
325
  show,
326
326
  hide,
327
327
  } },
328
- React.createElement(ComboBoxInputContainer_js_1.ComboBoxInputContainer, { disabled: inputProps?.disabled, ...rest },
328
+ React.createElement(ComboBoxInputContainer_js_1.ComboBoxInputContainer, { ref: forwardedRef, disabled: inputProps?.disabled, ...rest },
329
329
  React.createElement(React.Fragment, null,
330
330
  React.createElement(ComboBoxInput_js_1.ComboBoxInput, { value: inputValue, disabled: inputProps?.disabled, ...inputProps, onChange: handleOnInput, selectTags: isMultipleEnabled(selected, multiple)
331
331
  ? selected.map((index) => {
@@ -338,6 +338,5 @@ const ComboBox = (props) => {
338
338
  React.createElement(ComboBoxMenu_js_1.ComboBoxMenu, { as: 'div', ...dropdownMenuProps }, filteredOptions.length > 0 && !enableVirtualization
339
339
  ? filteredOptions.map(getMenuItem)
340
340
  : emptyContent)))));
341
- };
342
- exports.ComboBox = ComboBox;
341
+ });
343
342
  exports.default = exports.ComboBox;
@@ -37,6 +37,6 @@ exports.ComboBoxInputContainer = React.forwardRef((props, forwardedRef) => {
37
37
  const { id } = (0, index_js_1.useSafeContext)(helpers_js_1.ComboBoxStateContext);
38
38
  return (React.createElement(index_js_1.InputContainer, { className: className, status: status, statusMessage: typeof message === 'string' ? (React.createElement(StatusMessage_js_1.StatusMessage, { status: status }, message)) : (React.isValidElement(message) &&
39
39
  React.cloneElement(message, { status })), ref: forwardedRef, ...rest, id: id },
40
- React.createElement(index_js_1.Box, { className: 'iui-input-with-icon' }, children)));
40
+ React.createElement(index_js_1.InputWithIcon, null, children)));
41
41
  });
42
42
  exports.ComboBoxInputContainer.displayName = 'ComboBoxInputContainer';
@@ -67,6 +67,7 @@ export type DialogContextProps = {
67
67
  * Recommended to set to true when for modal dialogs that use `relativeTo='viewport'`.
68
68
  *
69
69
  * Can be set to an object with a `to` property to portal into a specific element.
70
+ * If `to`/`to()` === `null`/`undefined`, the default behavior will be used (i.e. as if `portal` is not passed).
70
71
  *
71
72
  * Defaults to false if using `Dialog` and true if using `Modal`.
72
73
  */
@@ -73,7 +73,7 @@ export declare const ExpandableBlock: PolymorphicForwardRefComponent<"div", Expa
73
73
  * <ExpandableBlock.EndIcon/>
74
74
  * </ExpandableBlock.Trigger>
75
75
  */
76
- Trigger: PolymorphicForwardRefComponent<"button", ExpandableBlockTriggerOwnProps>;
76
+ Trigger: PolymorphicForwardRefComponent<"div", ExpandableBlockTriggerOwnProps>;
77
77
  /**
78
78
  * The expanding icon on the left of header
79
79
  */
@@ -90,11 +90,11 @@ export declare const ExpandableBlock: PolymorphicForwardRefComponent<"div", Expa
90
90
  /**
91
91
  * The main text displayed on the block header, regardless of state.
92
92
  */
93
- Title: PolymorphicForwardRefComponent<"div", {}>;
93
+ Title: PolymorphicForwardRefComponent<"button", {}>;
94
94
  /**
95
95
  * Small note displayed below title, regardless of state.
96
96
  */
97
- Caption: PolymorphicForwardRefComponent<NonNullable<keyof JSX.IntrinsicElements>, {}>;
97
+ Caption: PolymorphicForwardRefComponent<"div", {}>;
98
98
  /**
99
99
  * Svg icon displayed at the end of the main text.
100
100
  * Will override status icon if specified. Used inside `Header` subcomponent.
@@ -110,7 +110,10 @@ export declare const ExpandableBlock: PolymorphicForwardRefComponent<"div", Expa
110
110
  fill?: "default" | "informational" | "negative" | "positive" | "warning" | import("../utils/types.js").AnyString | undefined;
111
111
  padded?: boolean | undefined;
112
112
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
113
- as?: "span" | undefined;
113
+ as?: "span" | undefined; /**
114
+ * Status of the block.
115
+ * When set, a colored status icon is shown at the end of the main text.
116
+ */
114
117
  }, "ref">>;
115
118
  /**
116
119
  * Content shown in the block's body when fully expanded.
@@ -35,6 +35,7 @@ const classnames_1 = __importDefault(require("classnames"));
35
35
  const React = __importStar(require("react"));
36
36
  const index_js_1 = require("../utils/index.js");
37
37
  const Icon_js_1 = require("../Icon/Icon.js");
38
+ const LinkAction_js_1 = require("../LinkAction/LinkAction.js");
38
39
  const ExpandableBlockContext = React.createContext(undefined);
39
40
  ExpandableBlockContext.displayName = 'ExpandableBlockContext';
40
41
  const ExpandableBlockComponent = React.forwardRef((props, forwardedRef) => {
@@ -49,6 +50,7 @@ const ExpandableBlockWrapper = React.forwardRef((props, forwardedRef) => {
49
50
  const { children, className, onToggle, style, isExpanded, status, size = 'default', styleType = 'default', disabled = false, ...rest } = props;
50
51
  const [expandedState, setExpanded] = React.useState(isExpanded ?? false);
51
52
  const expanded = isExpanded ?? expandedState;
53
+ const [descriptionId, setDescriptionId] = React.useState(undefined);
52
54
  return (React.createElement(ExpandableBlockContext.Provider, { value: {
53
55
  status,
54
56
  isExpanded: expanded,
@@ -58,20 +60,16 @@ const ExpandableBlockWrapper = React.forwardRef((props, forwardedRef) => {
58
60
  disabled,
59
61
  setExpanded,
60
62
  children,
63
+ descriptionId,
64
+ setDescriptionId,
61
65
  } },
62
66
  React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-expandable-block', className), "data-iui-expanded": expanded, "data-iui-size": size, "data-iui-variant": styleType !== 'default' ? styleType : undefined, style: style, ref: forwardedRef, ...rest }, children)));
63
67
  });
64
68
  ExpandableBlockWrapper.displayName = 'ExpandableBlock.Wrapper';
65
69
  const ExpandableBlockTrigger = React.forwardRef((props, forwardedRef) => {
66
- const { className, children, label, caption, onClick: onClickProp, expandIcon, endIcon, ...rest } = props;
67
- const { isExpanded, setExpanded, disabled, onToggle, status } = (0, index_js_1.useSafeContext)(ExpandableBlockContext);
68
- return (React.createElement(index_js_1.ButtonBase, { className: (0, classnames_1.default)('iui-expandable-header', className), "aria-expanded": isExpanded, "aria-disabled": disabled, onClick: (0, index_js_1.mergeEventHandlers)(onClickProp, () => {
69
- if (disabled) {
70
- return;
71
- }
72
- setExpanded(!isExpanded);
73
- onToggle?.(!isExpanded);
74
- }), ref: forwardedRef, ...rest }, children ?? (React.createElement(React.Fragment, null,
70
+ const { className, children, label, caption, expandIcon, endIcon, ...rest } = props;
71
+ const { disabled, status } = (0, index_js_1.useSafeContext)(ExpandableBlockContext);
72
+ return (React.createElement(LinkAction_js_1.LinkBox, { className: (0, classnames_1.default)('iui-expandable-header', className), "data-iui-disabled": disabled ? 'true' : undefined, ref: forwardedRef, ...rest }, children ?? (React.createElement(React.Fragment, null,
75
73
  expandIcon ?? React.createElement(exports.ExpandableBlock.ExpandIcon, null),
76
74
  React.createElement(exports.ExpandableBlock.LabelArea, null,
77
75
  React.createElement(exports.ExpandableBlock.Title, null, label),
@@ -93,13 +91,28 @@ ExpandableBlockLabelArea.displayName = 'ExpandableBlock.LabelArea';
93
91
  // ----------------------------------------------------------------------------
94
92
  // ExpandableBlock.Title component
95
93
  const ExpandableBlockTitle = React.forwardRef((props, forwardedRef) => {
96
- const { className, children, ...rest } = props;
97
- return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-expandable-block-title', className), ref: forwardedRef, ...rest }, children));
94
+ const { className, children, onClick: onClickProp, ...rest } = props;
95
+ const { isExpanded, setExpanded, disabled, onToggle, descriptionId } = (0, index_js_1.useSafeContext)(ExpandableBlockContext);
96
+ return (React.createElement(index_js_1.ButtonBase, { className: (0, classnames_1.default)('iui-expandable-block-title', 'iui-link-action', className), "aria-expanded": isExpanded, "aria-disabled": disabled, onClick: (0, index_js_1.mergeEventHandlers)(onClickProp, () => {
97
+ if (disabled) {
98
+ return;
99
+ }
100
+ setExpanded(!isExpanded);
101
+ onToggle?.(!isExpanded);
102
+ }), ref: forwardedRef, "aria-describedby": descriptionId, ...rest }, children));
98
103
  });
99
104
  ExpandableBlockTitle.displayName = 'ExpandableBlock.Title';
100
105
  // ----------------------------------------------------------------------------
101
106
  // ExpandableBlock.Caption component
102
- const ExpandableBlockCaption = (0, index_js_1.polymorphic)('iui-expandable-block-caption');
107
+ const ExpandableBlockCaption = React.forwardRef((props, forwardedRef) => {
108
+ const fallbackId = (0, index_js_1.useId)();
109
+ const { setDescriptionId } = (0, index_js_1.useSafeContext)(ExpandableBlockContext);
110
+ React.useEffect(() => {
111
+ setDescriptionId(props.id || fallbackId);
112
+ return () => setDescriptionId(undefined);
113
+ }, [props.id, fallbackId, setDescriptionId]);
114
+ return (React.createElement(index_js_1.Box, { ref: forwardedRef, id: fallbackId, ...props, className: (0, classnames_1.default)('iui-expandable-block-caption', props?.className) }));
115
+ });
103
116
  ExpandableBlockCaption.displayName = 'ExpandableBlock.Caption';
104
117
  // ----------------------------------------------------------------------------
105
118
  // ExpandableBlock.EndIcon component
@@ -10,15 +10,17 @@ type InputGridOwnProps = {
10
10
  labelPlacement?: 'default' | 'inline';
11
11
  };
12
12
  /**
13
- * InputGrid component is used to display inputs (input, textarea, select)
13
+ * InputGrid component is used to display form fields (input, textarea, select)
14
14
  * with label and/or status message
15
15
  *
16
- * @usage
16
+ * Form fields are automatically associated with the label and status message for
17
+ * better accessibility.
17
18
  *
19
+ * @example
18
20
  * <InputGrid>
19
- * <Label htmlFor='input-1'>This is label</Label>
20
- * <Input id='input-1'/>
21
- * <StatusMessage>This is message</StatusMessage>
21
+ * <Label>This is a label</Label>
22
+ * <Input />
23
+ * <StatusMessage>This is a message</StatusMessage>
22
24
  * </InputGrid>
23
25
  */
24
26
  export declare const InputGrid: PolymorphicForwardRefComponent<"div", InputGridOwnProps>;
@@ -34,22 +34,191 @@ exports.InputGrid = void 0;
34
34
  const React = __importStar(require("react"));
35
35
  const index_js_1 = require("../utils/index.js");
36
36
  const classnames_1 = __importDefault(require("classnames"));
37
+ const Label_js_1 = require("../Label/Label.js");
38
+ const Input_js_1 = require("../Input/Input.js");
39
+ const Textarea_js_1 = require("../Textarea/Textarea.js");
40
+ const StatusMessage_js_1 = require("../StatusMessage/StatusMessage.js");
41
+ const InputWithDecorations_js_1 = require("../InputWithDecorations/InputWithDecorations.js");
42
+ const ComboBox_js_1 = require("../ComboBox/ComboBox.js");
43
+ const Select_js_1 = require("../Select/Select.js");
37
44
  //-------------------------------------------------------------------------------
38
45
  /**
39
- * InputGrid component is used to display inputs (input, textarea, select)
46
+ * InputGrid component is used to display form fields (input, textarea, select)
40
47
  * with label and/or status message
41
48
  *
42
- * @usage
49
+ * Form fields are automatically associated with the label and status message for
50
+ * better accessibility.
43
51
  *
52
+ * @example
44
53
  * <InputGrid>
45
- * <Label htmlFor='input-1'>This is label</Label>
46
- * <Input id='input-1'/>
47
- * <StatusMessage>This is message</StatusMessage>
54
+ * <Label>This is a label</Label>
55
+ * <Input />
56
+ * <StatusMessage>This is a message</StatusMessage>
48
57
  * </InputGrid>
49
58
  */
50
59
  exports.InputGrid = React.forwardRef((props, ref) => {
51
- const { children, className, labelPlacement = undefined, ...rest } = props;
60
+ const { children: childrenProp, className, labelPlacement = undefined, ...rest } = props;
61
+ const children = useChildrenWithIds(childrenProp);
52
62
  return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-input-grid', className), "data-iui-label-placement": labelPlacement, ref: ref, ...rest }, children));
53
63
  });
54
64
  //-------------------------------------------------------------------------------
65
+ /**
66
+ * Ensures that label, input and message are properly associated
67
+ * with each other, for accessibility purposes.
68
+ *
69
+ * - `Select` will be associated with label using `aria-labelledby`
70
+ * - Other inputs will be associated with label using `htmlFor`
71
+ * - Message will be associated with input/select using `aria-describedby`
72
+ */
73
+ const useChildrenWithIds = (children) => {
74
+ const { labelId, inputId, messageId } = useSetup(children);
75
+ return React.useMemo(() => React.Children.map(children, (child) => {
76
+ if (!React.isValidElement(child)) {
77
+ return child;
78
+ }
79
+ if (child.type === Label_js_1.Label || child.type === 'label') {
80
+ return (0, index_js_1.cloneElementWithRef)(child, (child) => ({
81
+ ...child.props,
82
+ htmlFor: child.props.htmlFor || inputId,
83
+ id: child.props.id || labelId,
84
+ }));
85
+ }
86
+ if (child.type === StatusMessage_js_1.StatusMessage) {
87
+ return (0, index_js_1.cloneElementWithRef)(child, (child) => ({
88
+ ...child.props,
89
+ id: child.props.id || messageId,
90
+ }));
91
+ }
92
+ if (isInput(child) ||
93
+ child.type === InputWithDecorations_js_1.InputWithDecorations ||
94
+ child.type === index_js_1.InputWithIcon) {
95
+ return handleCloningInputs(child, {
96
+ labelId,
97
+ inputId,
98
+ messageId,
99
+ });
100
+ }
101
+ return child;
102
+ }), [children, inputId, labelId, messageId]);
103
+ };
104
+ //-------------------------------------------------------------------------------
105
+ /**
106
+ * Setup/prerequisite for `useChildrenWithIds` to gather information from children.
107
+ *
108
+ * @returns the following ids (prefers id from props, otherwise generates one)
109
+ * - `labelId`
110
+ * - `inputId`
111
+ * - `messageId`
112
+ */
113
+ const useSetup = (children) => {
114
+ const idPrefix = (0, index_js_1.useId)();
115
+ let labelId;
116
+ let inputId;
117
+ let messageId;
118
+ let hasLabel = false;
119
+ let hasSelect = false;
120
+ const findInputId = (child) => {
121
+ if (!React.isValidElement(child)) {
122
+ return;
123
+ }
124
+ // ComboBox input id is passed through `inputProps`
125
+ if (child.type === ComboBox_js_1.ComboBox) {
126
+ return child.props.inputProps?.id || `${idPrefix}--input`;
127
+ }
128
+ // Select input id would be passed through `triggerProps`, but we don't even
129
+ // need it because, unlike other inputs, it gets labelled using `aria-labelledby`
130
+ else if (child.type !== Select_js_1.Select) {
131
+ return child.props.id || `${idPrefix}--input`;
132
+ }
133
+ };
134
+ React.Children.forEach(children, (child) => {
135
+ if (!React.isValidElement(child)) {
136
+ return;
137
+ }
138
+ if (child.type === Label_js_1.Label || child.type === 'label') {
139
+ hasLabel = true;
140
+ labelId || (labelId = child.props.id || `${idPrefix}--label`);
141
+ }
142
+ if (child.type === StatusMessage_js_1.StatusMessage) {
143
+ messageId || (messageId = child.props.id || `${idPrefix}--message`);
144
+ }
145
+ if (child.type === InputWithDecorations_js_1.InputWithDecorations || child.type === index_js_1.InputWithIcon) {
146
+ React.Children.forEach(child.props.children, (child) => {
147
+ if (isInput(child)) {
148
+ inputId || (inputId = findInputId(child));
149
+ }
150
+ });
151
+ }
152
+ else if (isInput(child)) {
153
+ inputId || (inputId = findInputId(child));
154
+ }
155
+ if (child.type === Select_js_1.Select) {
156
+ hasSelect = true;
157
+ }
158
+ });
159
+ return {
160
+ labelId: hasSelect ? labelId : undefined,
161
+ inputId: hasLabel && !hasSelect ? inputId : undefined,
162
+ messageId,
163
+ };
164
+ };
165
+ //-------------------------------------------------------------------------------
166
+ /**
167
+ * Handles regular inputs, plus `InputWithDecorations`, `InputWithIcon`, `ComboBox` and `Select`.
168
+ */
169
+ const handleCloningInputs = (child, { labelId, inputId, messageId, }) => {
170
+ const inputProps = (props = {}) => {
171
+ // Concatenate aria-describedby from props and from StatusMessage
172
+ const ariaDescribedBy = [props['aria-describedby'], messageId]
173
+ .filter(Boolean)
174
+ .join(' ');
175
+ return {
176
+ ...props,
177
+ ...(child.type !== Select_js_1.Select && { id: props.id || inputId }),
178
+ 'aria-describedby': ariaDescribedBy?.trim() || undefined,
179
+ };
180
+ };
181
+ const cloneInput = (child) => {
182
+ if (child.type === ComboBox_js_1.ComboBox) {
183
+ return (0, index_js_1.cloneElementWithRef)(child, (child) => ({
184
+ inputProps: inputProps(child.props.inputProps),
185
+ }));
186
+ }
187
+ if (child.type === Select_js_1.Select) {
188
+ return (0, index_js_1.cloneElementWithRef)(child, (child) => ({
189
+ triggerProps: {
190
+ ...{ 'aria-labelledby': labelId },
191
+ ...inputProps(child.props.triggerProps),
192
+ },
193
+ }));
194
+ }
195
+ return (0, index_js_1.cloneElementWithRef)(child, (child) => inputProps(child.props));
196
+ };
197
+ if (child.type === InputWithDecorations_js_1.InputWithDecorations || child.type === index_js_1.InputWithIcon) {
198
+ return (0, index_js_1.cloneElementWithRef)(child, (child) => ({
199
+ children: React.Children.map(child.props.children, (child) => {
200
+ if (React.isValidElement(child) && isInput(child)) {
201
+ return cloneInput(child);
202
+ }
203
+ return child;
204
+ }),
205
+ }));
206
+ }
207
+ return cloneInput(child);
208
+ };
209
+ //-------------------------------------------------------------------------------
210
+ /** @returns true if `child` is a form element that can be associated with a label using id */
211
+ const isInput = (child) => {
212
+ return (React.isValidElement(child) &&
213
+ (child.type === 'input' ||
214
+ child.type === 'textarea' ||
215
+ child.type === 'select' ||
216
+ child.type === Input_js_1.Input ||
217
+ child.type === Textarea_js_1.Textarea ||
218
+ child.type === InputWithDecorations_js_1.InputWithDecorations.Input ||
219
+ child.type === Select_js_1.Select || // contains Select.triggerProps
220
+ child.type === ComboBox_js_1.ComboBox) // contains ComboBox.inputProps
221
+ );
222
+ };
223
+ //-------------------------------------------------------------------------------
55
224
  exports.default = exports.InputGrid;
@@ -32,7 +32,7 @@ type InputGroupProps = {
32
32
  /**
33
33
  * Custom icon. If group has status, default status icon is used instead.
34
34
  */
35
- svgIcon?: JSX.Element;
35
+ svgIcon?: React.ComponentPropsWithoutRef<typeof StatusMessage>['startIcon'];
36
36
  /**
37
37
  * Child inputs inside group.
38
38
  */
@@ -54,20 +54,11 @@ const StatusMessage_js_1 = require("../StatusMessage/StatusMessage.js");
54
54
  */
55
55
  exports.InputGroup = React.forwardRef((props, forwardedRef) => {
56
56
  const { className, children, disabled = false, displayStyle = 'default', label, message, status, svgIcon, required = false, labelProps, messageProps, innerProps, ...rest } = props;
57
- const icon = () => {
58
- if (svgIcon) {
59
- return React.cloneElement(svgIcon, { 'aria-hidden': true });
60
- }
61
- if (status && message) {
62
- return React.cloneElement(index_js_1.StatusIconMap[status](), {
63
- 'aria-hidden': true,
64
- });
65
- }
66
- return undefined;
67
- };
68
- return (React.createElement(InputGrid_js_1.InputGrid, { ref: forwardedRef, as: 'div', labelPlacement: displayStyle, className: (0, classnames_1.default)('iui-input-group-wrapper', className), ...rest },
57
+ return (React.createElement(InputGrid_js_1.InputGrid, { ref: forwardedRef, as: 'div', labelPlacement: displayStyle, className: (0, classnames_1.default)('iui-input-group-wrapper', className), "data-iui-status": status, ...rest },
69
58
  label && (React.createElement(Label_js_1.Label, { as: 'label', required: required, disabled: disabled, ...labelProps }, label)),
70
59
  React.createElement(index_js_1.Box, { as: 'div', ...innerProps, className: (0, classnames_1.default)('iui-input-group', innerProps?.className) }, children),
71
- (message || status || svgIcon) && (React.createElement(StatusMessage_js_1.StatusMessage, { startIcon: icon(), status: status, ...messageProps }, displayStyle !== 'inline' && message))));
60
+ (message || status || svgIcon) && (React.createElement(StatusMessage_js_1.StatusMessage, { iconProps: {
61
+ 'aria-hidden': true,
62
+ }, startIcon: svgIcon, status: status, ...messageProps }, displayStyle !== 'inline' && message))));
72
63
  });
73
64
  exports.default = exports.InputGroup;
@@ -2,7 +2,6 @@ import * as React from 'react';
2
2
  import { Input } from '../Input/Input.js';
3
3
  import type { PolymorphicForwardRefComponent } from '../utils/index.js';
4
4
  import { InputGrid } from '../InputGrid/InputGrid.js';
5
- import { InputWithDecorations } from '../InputWithDecorations/InputWithDecorations.js';
6
5
  import { Icon } from '../Icon/Icon.js';
7
6
  export type LabeledInputProps = {
8
7
  /**
@@ -48,7 +47,7 @@ export type LabeledInputProps = {
48
47
  /**
49
48
  * Passes properties for input wrapper.
50
49
  */
51
- inputWrapperProps?: React.ComponentProps<typeof InputWithDecorations>;
50
+ inputWrapperProps?: React.ComponentPropsWithRef<'div'>;
52
51
  } & React.ComponentProps<typeof Input>;
53
52
  /**
54
53
  * Basic labeled input component
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.LabeledInput = void 0;
27
30
  /*---------------------------------------------------------------------------------------------
@@ -29,12 +32,13 @@ exports.LabeledInput = void 0;
29
32
  * See LICENSE.md in the project root for license terms and full copyright notice.
30
33
  *--------------------------------------------------------------------------------------------*/
31
34
  const React = __importStar(require("react"));
35
+ const Input_js_1 = require("../Input/Input.js");
32
36
  const index_js_1 = require("../utils/index.js");
33
37
  const InputGrid_js_1 = require("../InputGrid/InputGrid.js");
34
- const InputWithDecorations_js_1 = require("../InputWithDecorations/InputWithDecorations.js");
35
38
  const StatusMessage_js_1 = require("../StatusMessage/StatusMessage.js");
36
39
  const Label_js_1 = require("../Label/Label.js");
37
40
  const Icon_js_1 = require("../Icon/Icon.js");
41
+ const classnames_1 = __importDefault(require("classnames"));
38
42
  /**
39
43
  * Basic labeled input component
40
44
  * @example
@@ -44,15 +48,14 @@ const Icon_js_1 = require("../Icon/Icon.js");
44
48
  * <LabeledInput status='negative' label='Negative' />
45
49
  */
46
50
  exports.LabeledInput = React.forwardRef((props, ref) => {
47
- const uid = (0, index_js_1.useId)();
48
- const { disabled = false, label, message, status, svgIcon, wrapperProps, labelProps, messageContentProps, iconProps, inputWrapperProps, displayStyle = 'default', required = false, id = uid, ...rest } = props;
51
+ const { disabled = false, label, message, status, svgIcon, wrapperProps, labelProps, messageContentProps, iconProps, inputWrapperProps, displayStyle = 'default', required = false, ...rest } = props;
49
52
  const icon = svgIcon ?? (status && index_js_1.StatusIconMap[status]());
50
53
  const shouldShowIcon = svgIcon !== null && (svgIcon || (status && !message));
51
- return (React.createElement(InputGrid_js_1.InputGrid, { labelPlacement: displayStyle, ...wrapperProps },
52
- label && (React.createElement(Label_js_1.Label, { as: 'label', required: required, disabled: disabled, htmlFor: id, ...labelProps }, label)),
53
- React.createElement(InputWithDecorations_js_1.InputWithDecorations, { status: status, isDisabled: disabled, ...inputWrapperProps },
54
- React.createElement(InputWithDecorations_js_1.InputWithDecorations.Input, { disabled: disabled, required: required, id: id, ref: ref, ...rest }),
55
- shouldShowIcon && (React.createElement(Icon_js_1.Icon, { fill: !svgIcon ? status : undefined, padded: true, ...iconProps }, icon))),
54
+ return (React.createElement(InputGrid_js_1.InputGrid, { labelPlacement: displayStyle, "data-iui-status": status, ...wrapperProps },
55
+ label && (React.createElement(Label_js_1.Label, { as: 'label', required: required, disabled: disabled, ...labelProps }, label)),
56
+ React.createElement(index_js_1.InputWithIcon, { ...inputWrapperProps },
57
+ React.createElement(Input_js_1.Input, { disabled: disabled, required: required, ref: ref, ...rest }),
58
+ shouldShowIcon && (React.createElement(Icon_js_1.Icon, { fill: status, ...iconProps, className: (0, classnames_1.default)('iui-end-icon', iconProps?.className) }, icon))),
56
59
  typeof message === 'string' ? (React.createElement(StatusMessage_js_1.StatusMessage, { status: status, iconProps: iconProps, contentProps: messageContentProps }, message)) : (message)));
57
60
  });
58
61
  exports.default = exports.LabeledInput;
@@ -10,6 +10,22 @@ export type LabeledSelectProps<T> = {
10
10
  label?: React.ReactNode;
11
11
  /**
12
12
  * Message below the select. Does not apply to 'inline' select.
13
+ *
14
+ * @example
15
+ * <caption>strings</caption>
16
+ * <LabeledSelect message='Positive Message' … />
17
+ *
18
+ * @example
19
+ * <caption>Using StatusMessage for complete customization (e.g. icon)</caption>
20
+ * <LabeledSelect
21
+ * status="positive"
22
+ * message={
23
+ * <StatusMessage status="positive" startIcon={<SvgStar />}>
24
+ * Help message
25
+ * </StatusMessage>
26
+ * }
27
+ * …
28
+ * />
13
29
  */
14
30
  message?: React.ReactNode;
15
31
  /**
@@ -18,6 +34,8 @@ export type LabeledSelectProps<T> = {
18
34
  */
19
35
  status?: 'positive' | 'warning' | 'negative';
20
36
  /**
37
+ * @deprecated Pass a `<StatusMessage startIcon={svgIcon} />` to the `message` prop instead.
38
+ *
21
39
  * Custom svg icon. Will override status icon if specified.
22
40
  */
23
41
  svgIcon?: JSX.Element;
@@ -30,11 +30,9 @@ exports.LabeledSelect = void 0;
30
30
  *--------------------------------------------------------------------------------------------*/
31
31
  const React = __importStar(require("react"));
32
32
  const Select_js_1 = require("../Select/Select.js");
33
- const index_js_1 = require("../utils/index.js");
34
33
  const StatusMessage_js_1 = require("../StatusMessage/StatusMessage.js");
35
34
  const InputGrid_js_1 = require("../InputGrid/InputGrid.js");
36
35
  const Label_js_1 = require("../Label/Label.js");
37
- const Icon_js_1 = require("../Icon/Icon.js");
38
36
  /**
39
37
  * Labeled select component to select value from options.
40
38
  * @example
@@ -69,23 +67,10 @@ const Icon_js_1 = require("../Icon/Icon.js");
69
67
  * />
70
68
  */
71
69
  exports.LabeledSelect = React.forwardRef((props, forwardedRef) => {
72
- const { className, disabled = false, label, message, status, svgIcon, displayStyle = 'default', style, required = false, triggerProps, wrapperProps, labelProps, messageContentProps, messageIconProps, ...rest } = props;
73
- const labelId = `${(0, index_js_1.useId)()}-label`;
74
- const icon = () => {
75
- if (svgIcon) {
76
- return React.createElement(Icon_js_1.Icon, null, svgIcon);
77
- }
78
- if (status && message) {
79
- return index_js_1.StatusIconMap[status]();
80
- }
81
- return undefined;
82
- };
83
- return (React.createElement(InputGrid_js_1.InputGrid, { labelPlacement: displayStyle, ...wrapperProps },
84
- label && (React.createElement(Label_js_1.Label, { as: 'div', required: required, disabled: disabled, id: labelId, ...labelProps }, label)),
85
- React.createElement(Select_js_1.Select, { disabled: disabled, className: className, style: style, status: status, ...rest, ref: forwardedRef, triggerProps: {
86
- 'aria-labelledby': labelId,
87
- ...triggerProps,
88
- } }),
89
- typeof message === 'string' ? (React.createElement(StatusMessage_js_1.StatusMessage, { status: status, startIcon: displayStyle === 'default' ? icon() : undefined, iconProps: messageIconProps, contentProps: messageContentProps }, message)) : (message)));
70
+ const { className, disabled = false, label, message, status, svgIcon, displayStyle = 'default', style, required = false, wrapperProps, labelProps, messageContentProps, messageIconProps, ...rest } = props;
71
+ return (React.createElement(InputGrid_js_1.InputGrid, { labelPlacement: displayStyle, "data-iui-status": status, ...wrapperProps },
72
+ label && (React.createElement(Label_js_1.Label, { as: 'div', required: required, disabled: disabled, ...labelProps }, label)),
73
+ React.createElement(Select_js_1.Select, { disabled: disabled, className: className, style: style, ...rest, ref: forwardedRef }),
74
+ typeof message === 'string' ? (React.createElement(StatusMessage_js_1.StatusMessage, { status: status, startIcon: svgIcon, iconProps: messageIconProps, contentProps: messageContentProps }, message)) : (message)));
90
75
  });
91
76
  exports.default = exports.LabeledSelect;
@@ -68,4 +68,14 @@ export declare const ListItem: PolymorphicForwardRefComponent<"li", ListItemOwnP
68
68
  * </ListItem>
69
69
  */
70
70
  Description: PolymorphicForwardRefComponent<NonNullable<keyof JSX.IntrinsicElements>, {}>;
71
+ /**
72
+ * Wrapper over [LinkAction](https://itwinui.bentley.com/docs/linkaction) which allows rendering a link inside a ListItem.
73
+ * This ensures that clicking anywhere on the ListItem will trigger the link.
74
+ *
75
+ * @example
76
+ * <ListItem>
77
+ * <ListItem.Action href='https://example.com'>Example link</ListItem.Action>
78
+ * </ListItem>
79
+ */
80
+ Action: PolymorphicForwardRefComponent<"a", {}>;
71
81
  };
@@ -34,6 +34,7 @@ exports.ListItem = void 0;
34
34
  const React = __importStar(require("react"));
35
35
  const classnames_1 = __importDefault(require("classnames"));
36
36
  const index_js_1 = require("../utils/index.js");
37
+ const LinkAction_js_1 = require("../LinkAction/LinkAction.js");
37
38
  const ListItemComponent = React.forwardRef((props, ref) => {
38
39
  const { size = 'default', disabled = false, active = false, actionable = false, focused = false, className, ...rest } = props;
39
40
  return (React.createElement(index_js_1.Box, { as: 'li', className: (0, classnames_1.default)('iui-list-item', className), "data-iui-active": active ? 'true' : undefined, "data-iui-disabled": disabled ? 'true' : undefined, "data-iui-size": size === 'large' ? 'large' : undefined, "data-iui-actionable": actionable ? 'true' : undefined, "data-iui-focused": focused ? 'true' : undefined, ref: ref, ...rest }));
@@ -49,6 +50,9 @@ ListItemContent.displayName = 'ListItem.Content';
49
50
  const ListItemDescription = (0, index_js_1.polymorphic)('iui-list-item-description');
50
51
  ListItemDescription.displayName = 'ListItem.Description';
51
52
  // ----------------------------------------------------------------------------
53
+ const ListItemAction = LinkAction_js_1.LinkAction;
54
+ ListItemAction.displayName = 'ListItem.Action';
55
+ // ----------------------------------------------------------------------------
52
56
  // Exported compound component
53
57
  /**
54
58
  * A generic ListItem component that can be used simply for displaying data, or as a base
@@ -90,4 +94,14 @@ exports.ListItem = Object.assign(ListItemComponent, {
90
94
  * </ListItem>
91
95
  */
92
96
  Description: ListItemDescription,
97
+ /**
98
+ * Wrapper over [LinkAction](https://itwinui.bentley.com/docs/linkaction) which allows rendering a link inside a ListItem.
99
+ * This ensures that clicking anywhere on the ListItem will trigger the link.
100
+ *
101
+ * @example
102
+ * <ListItem>
103
+ * <ListItem.Action href='https://example.com'>Example link</ListItem.Action>
104
+ * </ListItem>
105
+ */
106
+ Action: ListItemAction,
93
107
  });