@itwin/itwinui-react 3.2.4 → 3.3.1
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.
- package/CHANGELOG.md +28 -0
- package/cjs/core/ComboBox/ComboBox.d.ts +3 -1
- package/cjs/core/ComboBox/ComboBox.js +3 -4
- package/cjs/core/ComboBox/ComboBoxInputContainer.js +1 -1
- package/cjs/core/Dialog/DialogContent.d.ts +1 -2
- package/cjs/core/Dialog/DialogContent.js +1 -42
- package/cjs/core/Dialog/DialogContext.d.ts +1 -0
- package/cjs/core/Dialog/DialogMain.js +2 -24
- package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +7 -4
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +25 -12
- package/cjs/core/InputGrid/InputGrid.d.ts +7 -5
- package/cjs/core/InputGrid/InputGrid.js +175 -6
- package/cjs/core/InputGroup/InputGroup.d.ts +1 -1
- package/cjs/core/InputGroup/InputGroup.js +4 -13
- package/cjs/core/LabeledInput/LabeledInput.d.ts +1 -2
- package/cjs/core/LabeledInput/LabeledInput.js +11 -8
- package/cjs/core/LabeledSelect/LabeledSelect.d.ts +18 -0
- package/cjs/core/LabeledSelect/LabeledSelect.js +5 -20
- package/cjs/core/List/ListItem.d.ts +10 -0
- package/cjs/core/List/ListItem.js +14 -0
- package/cjs/core/Menu/MenuItem.d.ts +1 -1
- package/cjs/core/Modal/Modal.d.ts +3 -4
- package/cjs/core/Select/Select.js +2 -2
- package/cjs/core/StatusMessage/StatusMessage.d.ts +4 -2
- package/cjs/core/StatusMessage/StatusMessage.js +3 -1
- package/cjs/core/Table/Table.js +4 -0
- package/cjs/core/Table/TableCell.js +7 -22
- package/cjs/core/Table/columns/selectionColumn.d.ts +1 -1
- package/cjs/core/Table/columns/selectionColumn.js +3 -3
- package/cjs/core/Table/utils.d.ts +6 -0
- package/cjs/core/Table/utils.js +18 -1
- package/cjs/core/utils/components/InputWithIcon.d.ts +2 -0
- package/cjs/core/utils/components/InputWithIcon.js +11 -0
- package/cjs/core/utils/components/Portal.d.ts +5 -1
- package/cjs/core/utils/components/Portal.js +6 -2
- package/cjs/core/utils/components/index.d.ts +1 -0
- package/cjs/core/utils/components/index.js +1 -0
- package/esm/core/ComboBox/ComboBox.d.ts +3 -1
- package/esm/core/ComboBox/ComboBox.js +3 -3
- package/esm/core/ComboBox/ComboBoxInputContainer.js +2 -2
- package/esm/core/Dialog/DialogContent.d.ts +1 -2
- package/esm/core/Dialog/DialogContent.js +2 -17
- package/esm/core/Dialog/DialogContext.d.ts +1 -0
- package/esm/core/Dialog/DialogMain.js +3 -25
- package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +7 -4
- package/esm/core/ExpandableBlock/ExpandableBlock.js +26 -13
- package/esm/core/InputGrid/InputGrid.d.ts +7 -5
- package/esm/core/InputGrid/InputGrid.js +176 -7
- package/esm/core/InputGroup/InputGroup.d.ts +1 -1
- package/esm/core/InputGroup/InputGroup.js +5 -14
- package/esm/core/LabeledInput/LabeledInput.d.ts +1 -2
- package/esm/core/LabeledInput/LabeledInput.js +8 -9
- package/esm/core/LabeledSelect/LabeledSelect.d.ts +18 -0
- package/esm/core/LabeledSelect/LabeledSelect.js +5 -19
- package/esm/core/List/ListItem.d.ts +10 -0
- package/esm/core/List/ListItem.js +14 -0
- package/esm/core/Menu/MenuItem.d.ts +1 -1
- package/esm/core/Modal/Modal.d.ts +3 -4
- package/esm/core/Select/Select.js +3 -3
- package/esm/core/StatusMessage/StatusMessage.d.ts +4 -2
- package/esm/core/StatusMessage/StatusMessage.js +3 -1
- package/esm/core/Table/Table.js +5 -1
- package/esm/core/Table/TableCell.js +8 -23
- package/esm/core/Table/columns/selectionColumn.d.ts +1 -1
- package/esm/core/Table/columns/selectionColumn.js +3 -3
- package/esm/core/Table/utils.d.ts +6 -0
- package/esm/core/Table/utils.js +16 -0
- package/esm/core/utils/components/InputWithIcon.d.ts +2 -0
- package/esm/core/utils/components/InputWithIcon.js +8 -0
- package/esm/core/utils/components/Portal.d.ts +5 -1
- package/esm/core/utils/components/Portal.js +6 -2
- package/esm/core/utils/components/index.d.ts +1 -0
- package/esm/core/utils/components/index.js +1 -0
- package/package.json +3 -3
- package/styles.css +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1796](https://github.com/iTwin/iTwinUI/pull/1796): Fixed a visual issue in `Table` where column headers were not aligned with rows when using expandable `subRows`.
|
|
8
|
+
- [#1795](https://github.com/iTwin/iTwinUI/pull/1795): Fixed blurring and resizing issues in Dialog/Modal by removing `overflow: hidden` and inline `transform` styles.
|
|
9
|
+
|
|
10
|
+
## 3.3.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#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`.
|
|
15
|
+
- [#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.
|
|
16
|
+
- [#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.
|
|
17
|
+
- [#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.
|
|
18
|
+
- [#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`.
|
|
19
|
+
- [#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.
|
|
20
|
+
- [#1780](https://github.com/iTwin/iTwinUI/pull/1780): `ComboBox` now forwards its `ref`.
|
|
21
|
+
- [#1753](https://github.com/iTwin/iTwinUI/pull/1753): `StatusMessage` now renders no status icon if `startIcon === null`.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#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`.
|
|
26
|
+
- [#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.
|
|
27
|
+
- [#1788](https://github.com/iTwin/iTwinUI/pull/1788): `LinkAction` will no longer override styles from other components (such as `Anchor`).
|
|
28
|
+
- [#1753](https://github.com/iTwin/iTwinUI/pull/1753): Deprecated `svgIcon` in `LabeledSelect` in favor of passing `<StatusMessage startIcon={svgIcon} />` to the `message` prop.
|
|
29
|
+
- [#1787](https://github.com/iTwin/iTwinUI/pull/1787): Button, radial progress indicator, & select icons now use the correct icon variable color fill.
|
|
30
|
+
|
|
3
31
|
## 3.2.4
|
|
4
32
|
|
|
5
33
|
### 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>
|
|
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
|
-
|
|
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.
|
|
40
|
+
React.createElement(index_js_1.InputWithIcon, null, children)));
|
|
41
41
|
});
|
|
42
42
|
exports.ComboBoxInputContainer.displayName = 'ComboBoxInputContainer';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
2
1
|
/**
|
|
3
2
|
* Container for content in `Dialog`. Recommended to be used as a child of `Dialog`.
|
|
4
3
|
* @example
|
|
@@ -6,5 +5,5 @@ import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
|
6
5
|
* My dialog content
|
|
7
6
|
* </Dialog.Content>
|
|
8
7
|
*/
|
|
9
|
-
export declare const DialogContent: PolymorphicForwardRefComponent<"div", {}>;
|
|
8
|
+
export declare const DialogContent: import("../utils/props.js").PolymorphicForwardRefComponent<"div", {}>;
|
|
10
9
|
export default DialogContent;
|
|
@@ -1,38 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
3
|
exports.DialogContent = void 0;
|
|
30
4
|
/*---------------------------------------------------------------------------------------------
|
|
31
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
32
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
33
7
|
*--------------------------------------------------------------------------------------------*/
|
|
34
|
-
const React = __importStar(require("react"));
|
|
35
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
36
8
|
const index_js_1 = require("../utils/index.js");
|
|
37
9
|
/**
|
|
38
10
|
* Container for content in `Dialog`. Recommended to be used as a child of `Dialog`.
|
|
@@ -41,18 +13,5 @@ const index_js_1 = require("../utils/index.js");
|
|
|
41
13
|
* My dialog content
|
|
42
14
|
* </Dialog.Content>
|
|
43
15
|
*/
|
|
44
|
-
exports.DialogContent =
|
|
45
|
-
const { children, className, ...rest } = props;
|
|
46
|
-
const contentRef = React.useRef(null);
|
|
47
|
-
React.useEffect(() => {
|
|
48
|
-
// firefox hack for adding data-iui-flex in absence of :has
|
|
49
|
-
if (!(0, index_js_1.supportsHas)()) {
|
|
50
|
-
const dialog = contentRef.current?.closest('[role=dialog]');
|
|
51
|
-
if (dialog instanceof HTMLElement) {
|
|
52
|
-
dialog.dataset.iuiFlex = 'true';
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}, []);
|
|
56
|
-
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-dialog-content', className), ref: (0, index_js_1.useMergedRefs)(contentRef, ref), ...rest }, children));
|
|
57
|
-
});
|
|
16
|
+
exports.DialogContent = index_js_1.polymorphic.div('iui-dialog-content');
|
|
58
17
|
exports.default = exports.DialogContent;
|
|
@@ -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
|
*/
|
|
@@ -63,7 +63,6 @@ exports.DialogMain = React.forwardRef((props, ref) => {
|
|
|
63
63
|
const { className, children, styleType = 'default', isOpen = dialogContext.isOpen, isDismissible = dialogContext.isDismissible, onClose = dialogContext.onClose, closeOnEsc = dialogContext.closeOnEsc, trapFocus = dialogContext.trapFocus, setFocus = dialogContext.setFocus, preventDocumentScroll = dialogContext.preventDocumentScroll, onKeyDown, isDraggable = dialogContext.isDraggable, isResizable = dialogContext.isResizable, style: propStyle, placement = dialogContext.placement, ...rest } = props;
|
|
64
64
|
const [style, setStyle] = React.useState();
|
|
65
65
|
const dialogRef = React.useRef(null);
|
|
66
|
-
const [dialogElement, setDialogElement] = React.useState();
|
|
67
66
|
const hasBeenResized = React.useRef(false);
|
|
68
67
|
const previousFocusedElement = React.useRef();
|
|
69
68
|
const originalBodyOverflow = React.useRef('');
|
|
@@ -131,17 +130,13 @@ exports.DialogMain = React.forwardRef((props, ref) => {
|
|
|
131
130
|
...newStyle,
|
|
132
131
|
}));
|
|
133
132
|
}, []);
|
|
134
|
-
const roundedTransform = useRoundedTransform({
|
|
135
|
-
element: dialogElement,
|
|
136
|
-
transform,
|
|
137
|
-
});
|
|
138
133
|
const content = (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-dialog', {
|
|
139
134
|
'iui-dialog-default': styleType === 'default',
|
|
140
135
|
'iui-dialog-full-page': styleType === 'fullPage',
|
|
141
136
|
'iui-dialog-visible': isOpen,
|
|
142
137
|
'iui-dialog-draggable': isDraggable,
|
|
143
|
-
}, className), role: 'dialog', ref: (0, index_js_1.useMergedRefs)(dialogRef, ref
|
|
144
|
-
transform
|
|
138
|
+
}, className), role: 'dialog', ref: (0, index_js_1.useMergedRefs)(dialogRef, ref), onKeyDown: handleKeyDown, tabIndex: -1, "data-iui-placement": placement, style: {
|
|
139
|
+
transform,
|
|
145
140
|
...style,
|
|
146
141
|
...propStyle,
|
|
147
142
|
}, ...rest },
|
|
@@ -173,20 +168,3 @@ exports.DialogMain = React.forwardRef((props, ref) => {
|
|
|
173
168
|
!trapFocus && content)));
|
|
174
169
|
});
|
|
175
170
|
exports.default = exports.DialogMain;
|
|
176
|
-
// ----------------------------------------------------------------------------
|
|
177
|
-
/**
|
|
178
|
-
* Rounds off an element's transform value based on the device's pixel grid, to avoid blurring.
|
|
179
|
-
*/
|
|
180
|
-
const useRoundedTransform = ({ element, transform, }) => {
|
|
181
|
-
const [roundedStyles, setRoundedStyles] = React.useState(transform);
|
|
182
|
-
(0, index_js_1.useIsomorphicLayoutEffect)(() => {
|
|
183
|
-
if (!element || typeof DOMMatrix === 'undefined') {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const [x, y] = transform
|
|
187
|
-
? (0, index_js_1.getTranslateValues)(transform)
|
|
188
|
-
: (0, index_js_1.getTranslateValuesFromElement)(element);
|
|
189
|
-
setRoundedStyles(`translate(${(0, index_js_1.roundByDPR)(x)}px, ${(0, index_js_1.roundByDPR)(y)}px)`);
|
|
190
|
-
}, [element, transform]);
|
|
191
|
-
return roundedStyles;
|
|
192
|
-
};
|
|
@@ -73,7 +73,7 @@ export declare const ExpandableBlock: PolymorphicForwardRefComponent<"div", Expa
|
|
|
73
73
|
* <ExpandableBlock.EndIcon/>
|
|
74
74
|
* </ExpandableBlock.Trigger>
|
|
75
75
|
*/
|
|
76
|
-
Trigger: PolymorphicForwardRefComponent<"
|
|
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<"
|
|
93
|
+
Title: PolymorphicForwardRefComponent<"button", {}>;
|
|
94
94
|
/**
|
|
95
95
|
* Small note displayed below title, regardless of state.
|
|
96
96
|
*/
|
|
97
|
-
Caption: PolymorphicForwardRefComponent<
|
|
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,
|
|
67
|
-
const {
|
|
68
|
-
return (React.createElement(
|
|
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
|
-
|
|
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 = (
|
|
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
|
|
13
|
+
* InputGrid component is used to display form fields (input, textarea, select)
|
|
14
14
|
* with label and/or status message
|
|
15
15
|
*
|
|
16
|
-
*
|
|
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
|
|
20
|
-
* <Input
|
|
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
|
|
46
|
+
* InputGrid component is used to display form fields (input, textarea, select)
|
|
40
47
|
* with label and/or status message
|
|
41
48
|
*
|
|
42
|
-
*
|
|
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
|
|
46
|
-
* <Input
|
|
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?:
|
|
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
|
-
|
|
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, {
|
|
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.
|
|
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
|
|
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,
|
|
53
|
-
React.createElement(
|
|
54
|
-
React.createElement(
|
|
55
|
-
shouldShowIcon && (React.createElement(Icon_js_1.Icon, { fill:
|
|
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;
|