@spark-web/field 1.1.0 → 2.0.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.
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare type
|
|
3
|
-
'aria-describedby'?: string;
|
|
4
|
-
id: string;
|
|
2
|
+
export declare type FieldState = {
|
|
5
3
|
disabled: boolean;
|
|
6
4
|
invalid: boolean;
|
|
7
5
|
};
|
|
6
|
+
export declare type InputPropsDerivedFromField = {
|
|
7
|
+
'aria-describedby'?: string;
|
|
8
|
+
'aria-invalid': true | undefined;
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type FieldContextType = [FieldState, InputPropsDerivedFromField];
|
|
8
12
|
export declare const FieldContext: import("react").Context<FieldContextType | null>;
|
|
9
13
|
export declare const FieldContextProvider: import("react").Provider<FieldContextType | null>;
|
|
10
14
|
export declare const FIELD_CONTEXT_ERROR_MESSAGE = "Input components must be inside a `Field`.";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { FieldContextProvider, useFieldContext } from './context';
|
|
2
2
|
export { Field, FieldMessage, useFieldIds } from './Field';
|
|
3
|
-
export type { FieldContextType } from './context';
|
|
3
|
+
export type { FieldContextType, FieldState, InputPropsDerivedFromField, } from './context';
|
|
4
4
|
export type { FieldProps, Tone } from './Field';
|
|
@@ -56,12 +56,15 @@ var Field = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
|
|
|
56
56
|
messageId = _useFieldIds.messageId; // field context
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
id: inputId,
|
|
59
|
+
var invalid = Boolean(message && tone === 'critical');
|
|
60
|
+
var fieldContext = [{
|
|
62
61
|
disabled: disabled,
|
|
63
|
-
invalid:
|
|
64
|
-
}
|
|
62
|
+
invalid: invalid
|
|
63
|
+
}, {
|
|
64
|
+
'aria-describedby': a11y.mergeIds(message && messageId, description && descriptionId),
|
|
65
|
+
'aria-invalid': invalid || undefined,
|
|
66
|
+
id: inputId
|
|
67
|
+
}]; // label prep
|
|
65
68
|
|
|
66
69
|
var hiddenLabel = /*#__PURE__*/jsxRuntime.jsxs(a11y.VisuallyHidden, {
|
|
67
70
|
as: "label",
|
|
@@ -56,12 +56,15 @@ var Field = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
|
|
|
56
56
|
messageId = _useFieldIds.messageId; // field context
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
id: inputId,
|
|
59
|
+
var invalid = Boolean(message && tone === 'critical');
|
|
60
|
+
var fieldContext = [{
|
|
62
61
|
disabled: disabled,
|
|
63
|
-
invalid:
|
|
64
|
-
}
|
|
62
|
+
invalid: invalid
|
|
63
|
+
}, {
|
|
64
|
+
'aria-describedby': a11y.mergeIds(message && messageId, description && descriptionId),
|
|
65
|
+
'aria-invalid': invalid || undefined,
|
|
66
|
+
id: inputId
|
|
67
|
+
}]; // label prep
|
|
65
68
|
|
|
66
69
|
var hiddenLabel = /*#__PURE__*/jsxRuntime.jsxs(a11y.VisuallyHidden, {
|
|
67
70
|
as: "label",
|
|
@@ -52,12 +52,15 @@ var Field = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
|
|
52
52
|
messageId = _useFieldIds.messageId; // field context
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
id: inputId,
|
|
55
|
+
var invalid = Boolean(message && tone === 'critical');
|
|
56
|
+
var fieldContext = [{
|
|
58
57
|
disabled: disabled,
|
|
59
|
-
invalid:
|
|
60
|
-
}
|
|
58
|
+
invalid: invalid
|
|
59
|
+
}, {
|
|
60
|
+
'aria-describedby': mergeIds(message && messageId, description && descriptionId),
|
|
61
|
+
'aria-invalid': invalid || undefined,
|
|
62
|
+
id: inputId
|
|
63
|
+
}]; // label prep
|
|
61
64
|
|
|
62
65
|
var hiddenLabel = /*#__PURE__*/jsxs(VisuallyHidden, {
|
|
63
66
|
as: "label",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-web/field",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/spark-web-field.cjs.js",
|
|
6
6
|
"module": "dist/spark-web-field.esm.js",
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@babel/runtime": "^7.
|
|
12
|
-
"@emotion/css": "^11.
|
|
13
|
-
"@spark-web/a11y": "^1.0.
|
|
14
|
-
"@spark-web/box": "^1.0.
|
|
15
|
-
"@spark-web/icon": "^1.1.
|
|
16
|
-
"@spark-web/stack": "^1.0.
|
|
17
|
-
"@spark-web/text": "^1.0.
|
|
18
|
-
"@spark-web/theme": "^3.0.
|
|
19
|
-
"@spark-web/utils": "^1.1.
|
|
11
|
+
"@babel/runtime": "^7.18.0",
|
|
12
|
+
"@emotion/css": "^11.9.0",
|
|
13
|
+
"@spark-web/a11y": "^1.0.5",
|
|
14
|
+
"@spark-web/box": "^1.0.5",
|
|
15
|
+
"@spark-web/icon": "^1.1.3",
|
|
16
|
+
"@spark-web/stack": "^1.0.5",
|
|
17
|
+
"@spark-web/text": "^1.0.5",
|
|
18
|
+
"@spark-web/theme": "^3.0.1",
|
|
19
|
+
"@spark-web/utils": "^1.1.3"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/react": "^17.0.12",
|