@box/blueprint-web 7.0.2 → 7.2.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.
|
@@ -11,6 +11,7 @@ export declare const TextInput: import("react").ForwardRefExoticComponent<(Omit<
|
|
|
11
11
|
label: string;
|
|
12
12
|
type?: "text" | undefined;
|
|
13
13
|
hideLabel?: boolean | undefined;
|
|
14
|
+
invalid?: boolean | undefined;
|
|
14
15
|
disabled?: boolean | undefined;
|
|
15
16
|
required?: boolean | undefined;
|
|
16
17
|
error?: import("react").ReactNode;
|
|
@@ -20,6 +21,7 @@ export declare const TextInput: import("react").ForwardRefExoticComponent<(Omit<
|
|
|
20
21
|
label: string;
|
|
21
22
|
type?: "text" | undefined;
|
|
22
23
|
hideLabel?: boolean | undefined;
|
|
24
|
+
invalid?: boolean | undefined;
|
|
23
25
|
disabled?: boolean | undefined;
|
|
24
26
|
required?: boolean | undefined;
|
|
25
27
|
error?: import("react").ReactNode;
|
|
@@ -20,6 +20,7 @@ const TextInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
20
20
|
label,
|
|
21
21
|
type = 'text',
|
|
22
22
|
disabled,
|
|
23
|
+
invalid = false,
|
|
23
24
|
hideLabel,
|
|
24
25
|
error,
|
|
25
26
|
loading = false,
|
|
@@ -29,16 +30,18 @@ const TextInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
29
30
|
} = props;
|
|
30
31
|
const inputRef = useRef(null);
|
|
31
32
|
const inputId = useUniqueId('input-');
|
|
33
|
+
const inlineErrorId = useUniqueId('inline-error-');
|
|
32
34
|
const focusInput = useCallback(() => {
|
|
33
35
|
inputRef.current?.focus();
|
|
34
36
|
}, []);
|
|
35
37
|
const hasError = !!error && !disabled;
|
|
38
|
+
const shouldMarkError = (!!error || invalid) && !disabled;
|
|
36
39
|
const isLoading = !disabled && loading && loadingAriaLabel;
|
|
37
40
|
return jsxs(Fragment, {
|
|
38
41
|
children: [jsxs("div", {
|
|
39
42
|
className: clsx([styles.textInputContainer], {
|
|
40
43
|
[styles.disabled]: disabled,
|
|
41
|
-
[styles.error]:
|
|
44
|
+
[styles.error]: shouldMarkError
|
|
42
45
|
}, className),
|
|
43
46
|
children: [jsx("label", {
|
|
44
47
|
className: clsx([styles.label], {
|
|
@@ -50,11 +53,14 @@ const TextInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
50
53
|
}) : label
|
|
51
54
|
}), jsx("input", {
|
|
52
55
|
...rest,
|
|
56
|
+
...(hasError && {
|
|
57
|
+
'aria-describedby': inlineErrorId
|
|
58
|
+
}),
|
|
53
59
|
ref: useForkRef(inputRef, forwardedRef),
|
|
54
|
-
"aria-invalid":
|
|
60
|
+
"aria-invalid": shouldMarkError,
|
|
55
61
|
"aria-required": required,
|
|
56
62
|
className: clsx([styles.textInput], {
|
|
57
|
-
[styles.error]:
|
|
63
|
+
[styles.error]: shouldMarkError,
|
|
58
64
|
[styles.loading]: isLoading
|
|
59
65
|
}),
|
|
60
66
|
disabled: disabled,
|
|
@@ -68,6 +74,7 @@ const TextInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
68
74
|
})]
|
|
69
75
|
}), jsx(InlineError, {
|
|
70
76
|
className: styles.inlineError,
|
|
77
|
+
id: inlineErrorId,
|
|
71
78
|
children: error
|
|
72
79
|
})]
|
|
73
80
|
});
|
|
@@ -13,6 +13,12 @@ export type TextInputProps = React.ComponentPropsWithRef<'input'> & {
|
|
|
13
13
|
type?: 'text';
|
|
14
14
|
/** When true label text is hidden */
|
|
15
15
|
hideLabel?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* When true it enforces the error state, without error message.
|
|
18
|
+
* Developer is responsible for connecting the error message with TextInput using aria-describedby.
|
|
19
|
+
* This prop should not be used in conjunction with error prop.
|
|
20
|
+
* */
|
|
21
|
+
invalid?: boolean;
|
|
16
22
|
/** When true prevents user interaction with input */
|
|
17
23
|
disabled?: boolean;
|
|
18
24
|
/** When true it indicates input field must be filled out */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@box/storybook-utils": "^0.1.0",
|
|
59
59
|
"react-stately": "^3.31.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "0958a7b410ffc0894fb5e04ccb513fdb571a544b",
|
|
62
62
|
"module": "lib-esm/index.js",
|
|
63
63
|
"main": "lib-esm/index.js",
|
|
64
64
|
"exports": {
|