@react-stately/form 3.0.3-nightly.4624 → 3.0.3
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.
|
@@ -46,7 +46,7 @@ const $5d10129a174740d4$export$dad6ae84456c676a = {
|
|
|
46
46
|
validationErrors: []
|
|
47
47
|
};
|
|
48
48
|
const $5d10129a174740d4$export$571b5131b7e65c11 = (0, $kFCAu$react.createContext)({});
|
|
49
|
-
const $5d10129a174740d4$export$a763b9476acd3eb =
|
|
49
|
+
const $5d10129a174740d4$export$a763b9476acd3eb = '__formValidationState' + Date.now();
|
|
50
50
|
function $5d10129a174740d4$export$fc1a364ae1f3ff10(props) {
|
|
51
51
|
// Private prop for parent components to pass state to children.
|
|
52
52
|
if (props[$5d10129a174740d4$export$a763b9476acd3eb]) {
|
|
@@ -63,9 +63,9 @@ function $5d10129a174740d4$export$fc1a364ae1f3ff10(props) {
|
|
|
63
63
|
return $5d10129a174740d4$var$useFormValidationStateImpl(props);
|
|
64
64
|
}
|
|
65
65
|
function $5d10129a174740d4$var$useFormValidationStateImpl(props) {
|
|
66
|
-
let { isInvalid: isInvalid, validationState: validationState, name: name, value: value, builtinValidation: builtinValidation, validate: validate, validationBehavior: validationBehavior =
|
|
66
|
+
let { isInvalid: isInvalid, validationState: validationState, name: name, value: value, builtinValidation: builtinValidation, validate: validate, validationBehavior: validationBehavior = 'aria' } = props;
|
|
67
67
|
// backward compatibility.
|
|
68
|
-
if (validationState) isInvalid || (isInvalid = validationState ===
|
|
68
|
+
if (validationState) isInvalid || (isInvalid = validationState === 'invalid');
|
|
69
69
|
// If the isInvalid prop is controlled, update validation result in realtime.
|
|
70
70
|
let controlledError = isInvalid !== undefined ? {
|
|
71
71
|
isInvalid: isInvalid,
|
|
@@ -117,13 +117,13 @@ function $5d10129a174740d4$var$useFormValidationStateImpl(props) {
|
|
|
117
117
|
// displayValidation is the currently displayed validation state that the user sees (e.g. on input change/form submit).
|
|
118
118
|
// With validationBehavior="aria", all errors are displayed in realtime rather than on submit.
|
|
119
119
|
let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $5d10129a174740d4$export$dad6ae84456c676a;
|
|
120
|
-
let displayValidation = validationBehavior ===
|
|
120
|
+
let displayValidation = validationBehavior === 'native' ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
|
|
121
121
|
return {
|
|
122
122
|
realtimeValidation: realtimeValidation,
|
|
123
123
|
displayValidation: displayValidation,
|
|
124
124
|
updateValidation (value) {
|
|
125
125
|
// If validationBehavior is 'aria', update in realtime. Otherwise, store in a ref until commit.
|
|
126
|
-
if (validationBehavior ===
|
|
126
|
+
if (validationBehavior === 'aria' && !$5d10129a174740d4$var$isEqualValidation(currentValidity, value)) setCurrentValidity(value);
|
|
127
127
|
else nextValidation.current = value;
|
|
128
128
|
},
|
|
129
129
|
resetValidation () {
|
|
@@ -136,13 +136,13 @@ function $5d10129a174740d4$var$useFormValidationStateImpl(props) {
|
|
|
136
136
|
}
|
|
137
137
|
// Do not commit validation after the next render. This avoids a condition where
|
|
138
138
|
// useSelect calls commitValidation inside an onReset handler.
|
|
139
|
-
if (validationBehavior ===
|
|
139
|
+
if (validationBehavior === 'native') setCommitQueued(false);
|
|
140
140
|
setServerErrorCleared(true);
|
|
141
141
|
},
|
|
142
142
|
commitValidation () {
|
|
143
143
|
// Commit validation state so the user sees it on blur/change/submit. Also clear any server errors.
|
|
144
144
|
// Wait until after the next render to commit so that the latest value has been validated.
|
|
145
|
-
if (validationBehavior ===
|
|
145
|
+
if (validationBehavior === 'native') setCommitQueued(true);
|
|
146
146
|
setServerErrorCleared(true);
|
|
147
147
|
}
|
|
148
148
|
};
|
|
@@ -154,9 +154,9 @@ function $5d10129a174740d4$var$asArray(v) {
|
|
|
154
154
|
];
|
|
155
155
|
}
|
|
156
156
|
function $5d10129a174740d4$var$runValidate(validate, value) {
|
|
157
|
-
if (typeof validate ===
|
|
157
|
+
if (typeof validate === 'function') {
|
|
158
158
|
let e = validate(value);
|
|
159
|
-
if (e && typeof e !==
|
|
159
|
+
if (e && typeof e !== 'boolean') return $5d10129a174740d4$var$asArray(e);
|
|
160
160
|
}
|
|
161
161
|
return [];
|
|
162
162
|
}
|
|
@@ -35,7 +35,7 @@ const $e5be200c675c3b3a$export$dad6ae84456c676a = {
|
|
|
35
35
|
validationErrors: []
|
|
36
36
|
};
|
|
37
37
|
const $e5be200c675c3b3a$export$571b5131b7e65c11 = (0, $69F46$createContext)({});
|
|
38
|
-
const $e5be200c675c3b3a$export$a763b9476acd3eb =
|
|
38
|
+
const $e5be200c675c3b3a$export$a763b9476acd3eb = '__formValidationState' + Date.now();
|
|
39
39
|
function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
|
|
40
40
|
// Private prop for parent components to pass state to children.
|
|
41
41
|
if (props[$e5be200c675c3b3a$export$a763b9476acd3eb]) {
|
|
@@ -52,9 +52,9 @@ function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
|
|
|
52
52
|
return $e5be200c675c3b3a$var$useFormValidationStateImpl(props);
|
|
53
53
|
}
|
|
54
54
|
function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
55
|
-
let { isInvalid: isInvalid, validationState: validationState, name: name, value: value, builtinValidation: builtinValidation, validate: validate, validationBehavior: validationBehavior =
|
|
55
|
+
let { isInvalid: isInvalid, validationState: validationState, name: name, value: value, builtinValidation: builtinValidation, validate: validate, validationBehavior: validationBehavior = 'aria' } = props;
|
|
56
56
|
// backward compatibility.
|
|
57
|
-
if (validationState) isInvalid || (isInvalid = validationState ===
|
|
57
|
+
if (validationState) isInvalid || (isInvalid = validationState === 'invalid');
|
|
58
58
|
// If the isInvalid prop is controlled, update validation result in realtime.
|
|
59
59
|
let controlledError = isInvalid !== undefined ? {
|
|
60
60
|
isInvalid: isInvalid,
|
|
@@ -106,13 +106,13 @@ function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
|
106
106
|
// displayValidation is the currently displayed validation state that the user sees (e.g. on input change/form submit).
|
|
107
107
|
// With validationBehavior="aria", all errors are displayed in realtime rather than on submit.
|
|
108
108
|
let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
109
|
-
let displayValidation = validationBehavior ===
|
|
109
|
+
let displayValidation = validationBehavior === 'native' ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
|
|
110
110
|
return {
|
|
111
111
|
realtimeValidation: realtimeValidation,
|
|
112
112
|
displayValidation: displayValidation,
|
|
113
113
|
updateValidation (value) {
|
|
114
114
|
// If validationBehavior is 'aria', update in realtime. Otherwise, store in a ref until commit.
|
|
115
|
-
if (validationBehavior ===
|
|
115
|
+
if (validationBehavior === 'aria' && !$e5be200c675c3b3a$var$isEqualValidation(currentValidity, value)) setCurrentValidity(value);
|
|
116
116
|
else nextValidation.current = value;
|
|
117
117
|
},
|
|
118
118
|
resetValidation () {
|
|
@@ -125,13 +125,13 @@ function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
|
125
125
|
}
|
|
126
126
|
// Do not commit validation after the next render. This avoids a condition where
|
|
127
127
|
// useSelect calls commitValidation inside an onReset handler.
|
|
128
|
-
if (validationBehavior ===
|
|
128
|
+
if (validationBehavior === 'native') setCommitQueued(false);
|
|
129
129
|
setServerErrorCleared(true);
|
|
130
130
|
},
|
|
131
131
|
commitValidation () {
|
|
132
132
|
// Commit validation state so the user sees it on blur/change/submit. Also clear any server errors.
|
|
133
133
|
// Wait until after the next render to commit so that the latest value has been validated.
|
|
134
|
-
if (validationBehavior ===
|
|
134
|
+
if (validationBehavior === 'native') setCommitQueued(true);
|
|
135
135
|
setServerErrorCleared(true);
|
|
136
136
|
}
|
|
137
137
|
};
|
|
@@ -143,9 +143,9 @@ function $e5be200c675c3b3a$var$asArray(v) {
|
|
|
143
143
|
];
|
|
144
144
|
}
|
|
145
145
|
function $e5be200c675c3b3a$var$runValidate(validate, value) {
|
|
146
|
-
if (typeof validate ===
|
|
146
|
+
if (typeof validate === 'function') {
|
|
147
147
|
let e = validate(value);
|
|
148
|
-
if (e && typeof e !==
|
|
148
|
+
if (e && typeof e !== 'boolean') return $e5be200c675c3b3a$var$asArray(e);
|
|
149
149
|
}
|
|
150
150
|
return [];
|
|
151
151
|
}
|
|
@@ -35,7 +35,7 @@ const $e5be200c675c3b3a$export$dad6ae84456c676a = {
|
|
|
35
35
|
validationErrors: []
|
|
36
36
|
};
|
|
37
37
|
const $e5be200c675c3b3a$export$571b5131b7e65c11 = (0, $69F46$createContext)({});
|
|
38
|
-
const $e5be200c675c3b3a$export$a763b9476acd3eb =
|
|
38
|
+
const $e5be200c675c3b3a$export$a763b9476acd3eb = '__formValidationState' + Date.now();
|
|
39
39
|
function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
|
|
40
40
|
// Private prop for parent components to pass state to children.
|
|
41
41
|
if (props[$e5be200c675c3b3a$export$a763b9476acd3eb]) {
|
|
@@ -52,9 +52,9 @@ function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
|
|
|
52
52
|
return $e5be200c675c3b3a$var$useFormValidationStateImpl(props);
|
|
53
53
|
}
|
|
54
54
|
function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
55
|
-
let { isInvalid: isInvalid, validationState: validationState, name: name, value: value, builtinValidation: builtinValidation, validate: validate, validationBehavior: validationBehavior =
|
|
55
|
+
let { isInvalid: isInvalid, validationState: validationState, name: name, value: value, builtinValidation: builtinValidation, validate: validate, validationBehavior: validationBehavior = 'aria' } = props;
|
|
56
56
|
// backward compatibility.
|
|
57
|
-
if (validationState) isInvalid || (isInvalid = validationState ===
|
|
57
|
+
if (validationState) isInvalid || (isInvalid = validationState === 'invalid');
|
|
58
58
|
// If the isInvalid prop is controlled, update validation result in realtime.
|
|
59
59
|
let controlledError = isInvalid !== undefined ? {
|
|
60
60
|
isInvalid: isInvalid,
|
|
@@ -106,13 +106,13 @@ function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
|
106
106
|
// displayValidation is the currently displayed validation state that the user sees (e.g. on input change/form submit).
|
|
107
107
|
// With validationBehavior="aria", all errors are displayed in realtime rather than on submit.
|
|
108
108
|
let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
109
|
-
let displayValidation = validationBehavior ===
|
|
109
|
+
let displayValidation = validationBehavior === 'native' ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
|
|
110
110
|
return {
|
|
111
111
|
realtimeValidation: realtimeValidation,
|
|
112
112
|
displayValidation: displayValidation,
|
|
113
113
|
updateValidation (value) {
|
|
114
114
|
// If validationBehavior is 'aria', update in realtime. Otherwise, store in a ref until commit.
|
|
115
|
-
if (validationBehavior ===
|
|
115
|
+
if (validationBehavior === 'aria' && !$e5be200c675c3b3a$var$isEqualValidation(currentValidity, value)) setCurrentValidity(value);
|
|
116
116
|
else nextValidation.current = value;
|
|
117
117
|
},
|
|
118
118
|
resetValidation () {
|
|
@@ -125,13 +125,13 @@ function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
|
125
125
|
}
|
|
126
126
|
// Do not commit validation after the next render. This avoids a condition where
|
|
127
127
|
// useSelect calls commitValidation inside an onReset handler.
|
|
128
|
-
if (validationBehavior ===
|
|
128
|
+
if (validationBehavior === 'native') setCommitQueued(false);
|
|
129
129
|
setServerErrorCleared(true);
|
|
130
130
|
},
|
|
131
131
|
commitValidation () {
|
|
132
132
|
// Commit validation state so the user sees it on blur/change/submit. Also clear any server errors.
|
|
133
133
|
// Wait until after the next render to commit so that the latest value has been validated.
|
|
134
|
-
if (validationBehavior ===
|
|
134
|
+
if (validationBehavior === 'native') setCommitQueued(true);
|
|
135
135
|
setServerErrorCleared(true);
|
|
136
136
|
}
|
|
137
137
|
};
|
|
@@ -143,9 +143,9 @@ function $e5be200c675c3b3a$var$asArray(v) {
|
|
|
143
143
|
];
|
|
144
144
|
}
|
|
145
145
|
function $e5be200c675c3b3a$var$runValidate(validate, value) {
|
|
146
|
-
if (typeof validate ===
|
|
146
|
+
if (typeof validate === 'function') {
|
|
147
147
|
let e = validate(value);
|
|
148
|
-
if (e && typeof e !==
|
|
148
|
+
if (e && typeof e !== 'boolean') return $e5be200c675c3b3a$var$asArray(e);
|
|
149
149
|
}
|
|
150
150
|
return [];
|
|
151
151
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/form",
|
|
3
|
-
"version": "3.0.3
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-types/shared": "3.
|
|
25
|
+
"@react-types/shared": "^3.23.1",
|
|
26
26
|
"@swc/helpers": "^0.5.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "b77d7d594dff4dcfb5359bffbcfd18142b146433"
|
|
35
35
|
}
|