relay-forms-nodeps 1.1.1 → 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.
- package/README.md +4 -4
- package/lib/es/index.d.ts +2 -2
- package/lib/es/index.js +2 -2
- package/lib/es/useForm.d.ts +2 -0
- package/lib/es/{useFormSubmit.js → useForm.js} +2 -2
- package/lib/es/{useFormSetValue.d.ts → useFormField.d.ts} +1 -1
- package/lib/es/{useFormSetValue.js → useFormField.js} +1 -1
- package/lib/es/useFormState.js +3 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -4
- package/lib/umd/relay-forms-nodeps.js +7 -5
- package/lib/umd/relay-forms-nodeps.js.map +1 -1
- package/lib/umd/relay-forms-nodeps.min.js +1 -1
- package/lib/umd/relay-forms-nodeps.min.js.map +1 -1
- package/lib/useForm.d.ts +2 -0
- package/lib/{useFormSubmit.js → useForm.js} +6 -6
- package/lib/{useFormSetValue.d.ts → useFormField.d.ts} +1 -1
- package/lib/{useFormSetValue.js → useFormField.js} +2 -2
- package/lib/useFormState.js +3 -1
- package/package.json +1 -1
- package/lib/es/useFormSubmit.d.ts +0 -2
- package/lib/useFormSubmit.d.ts +0 -2
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var React = require("react");
|
|
7
7
|
var RelayStoreProvider_1 = require("./relay/RelayStoreProvider");
|
|
8
8
|
var RelayStoreUtils_1 = require("./relay/RelayStoreUtils");
|
|
9
|
-
var
|
|
9
|
+
var useFormField_1 = require("./useFormField");
|
|
10
10
|
var Utils_1 = require("./Utils");
|
|
11
11
|
function logicSubmit(environment, onSubmit) {
|
|
12
12
|
function dispose() {
|
|
@@ -25,7 +25,7 @@ function logicSubmit(environment, onSubmit) {
|
|
|
25
25
|
var data = snapshot.data;
|
|
26
26
|
var entries = data.form.entries;
|
|
27
27
|
var filtered = entries.filter(function (value) {
|
|
28
|
-
return
|
|
28
|
+
return useFormField_1.isDone(value.check);
|
|
29
29
|
});
|
|
30
30
|
var isValidating = filtered.length !== entries.length;
|
|
31
31
|
var errors = entries.filter(function (value) {
|
|
@@ -62,7 +62,7 @@ function logicSubmit(environment, onSubmit) {
|
|
|
62
62
|
dispose();
|
|
63
63
|
Utils_1.commit(environment, function (_, form) {
|
|
64
64
|
form.setValue(false, 'isSubmitting').setValue(false, 'isValidating').setLinkedRecords([], 'errors').getLinkedRecords('entries').forEach(function (entry) {
|
|
65
|
-
return entry.setValue(
|
|
65
|
+
return entry.setValue(useFormField_1.RESET, 'check').setValue(undefined, 'error');
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -70,11 +70,11 @@ function logicSubmit(environment, onSubmit) {
|
|
|
70
70
|
function validate() {
|
|
71
71
|
Utils_1.commit(environment, function (_, form) {
|
|
72
72
|
var tobeValitating = form.setValue(isSubmitting, 'isSubmitting').getLinkedRecords('entries').filter(function (value) {
|
|
73
|
-
return value.getValue('check') ===
|
|
73
|
+
return value.getValue('check') === useFormField_1.TOBEVALIDATE;
|
|
74
74
|
});
|
|
75
75
|
form.setValue(tobeValitating.length === 0, 'isValidating');
|
|
76
76
|
tobeValitating.forEach(function (entry) {
|
|
77
|
-
return entry.setValue(
|
|
77
|
+
return entry.setValue(useFormField_1.VALIDATING, 'check');
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
var snapshot = environment.lookup(Utils_1.operationQueryForm.fragment);
|
|
@@ -112,7 +112,7 @@ function logicSubmit(environment, onSubmit) {
|
|
|
112
112
|
getData: getData
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
exports.
|
|
115
|
+
exports.useForm = function (_a) {
|
|
116
116
|
var onSubmit = _a.onSubmit;
|
|
117
117
|
var environment = RelayStoreProvider_1.useStore();
|
|
118
118
|
var resolver = React.useMemo(function () {
|
|
@@ -3,4 +3,4 @@ export declare const TOBEVALIDATE = 1;
|
|
|
3
3
|
export declare const VALIDATING = 2;
|
|
4
4
|
export declare const RESET = 5;
|
|
5
5
|
export declare function isDone(check: any): boolean;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function useFormField<ValueType>({ key, initialValue, validate, validateOnChange, label, }: FormSetValueOptions<ValueType>): FormSetValueReturn<ValueType>;
|
|
@@ -162,7 +162,7 @@ function logicSetValue(params) {
|
|
|
162
162
|
setValidate: setValidate
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function useFormField(_a) {
|
|
166
166
|
var key = _a.key,
|
|
167
167
|
initialValue = _a.initialValue,
|
|
168
168
|
validate = _a.validate,
|
|
@@ -186,4 +186,4 @@ function useFormSetValue(_a) {
|
|
|
186
186
|
}, [resolver]);
|
|
187
187
|
return [resolver.getData(), resolver.setValue];
|
|
188
188
|
}
|
|
189
|
-
exports.
|
|
189
|
+
exports.useFormField = useFormField;
|
package/lib/useFormState.js
CHANGED
|
@@ -9,7 +9,9 @@ var Utils_1 = require("./Utils");
|
|
|
9
9
|
exports.useFormState = function () {
|
|
10
10
|
var environment = RelayStoreProvider_1.useStore();
|
|
11
11
|
var snapshot = React.useMemo(function () {
|
|
12
|
-
|
|
12
|
+
var s = environment.lookup(Utils_1.operationQueryErrorsForm.fragment);
|
|
13
|
+
s.seenRecords.add('local:form');
|
|
14
|
+
return s;
|
|
13
15
|
}, [environment]);
|
|
14
16
|
var _a = React.useState(snapshot.data.form),
|
|
15
17
|
data = _a[0],
|
package/package.json
CHANGED
package/lib/useFormSubmit.d.ts
DELETED