relay-forms-nodeps 1.1.1 → 2.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.
Files changed (40) hide show
  1. package/README.md +4 -4
  2. package/lib/RelayFormsTypes.d.ts +5 -1
  3. package/lib/es/RelayFormsTypes.d.ts +5 -1
  4. package/lib/es/index.d.ts +2 -2
  5. package/lib/es/index.js +2 -2
  6. package/lib/es/relay/queryErrorsFieldQuery.graphql.d.ts +28 -0
  7. package/lib/es/relay/queryErrorsFieldQuery.graphql.js +103 -0
  8. package/lib/es/relay/queryFieldFragment.graphql.d.ts +18 -0
  9. package/lib/es/relay/queryFieldFragment.graphql.js +28 -0
  10. package/lib/es/relay/queryFieldQuery.graphql.d.ts +25 -0
  11. package/lib/es/relay/queryFieldQuery.graphql.js +85 -0
  12. package/lib/es/relay/queryValueFieldFragment.graphql.d.ts +20 -0
  13. package/lib/es/relay/queryValueFieldFragment.graphql.js +40 -0
  14. package/lib/es/useForm.d.ts +2 -0
  15. package/lib/es/{useFormSubmit.js → useForm.js} +2 -2
  16. package/lib/es/{useFormSetValue.d.ts → useFormField.d.ts} +1 -1
  17. package/lib/es/{useFormSetValue.js → useFormField.js} +49 -11
  18. package/lib/es/useFormState.js +3 -1
  19. package/lib/index.d.ts +2 -2
  20. package/lib/index.js +4 -4
  21. package/lib/relay/queryErrorsFieldQuery.graphql.d.ts +28 -0
  22. package/lib/relay/queryErrorsFieldQuery.graphql.js +108 -0
  23. package/lib/relay/queryFieldFragment.graphql.d.ts +18 -0
  24. package/lib/relay/queryFieldFragment.graphql.js +33 -0
  25. package/lib/relay/queryFieldQuery.graphql.d.ts +25 -0
  26. package/lib/relay/queryFieldQuery.graphql.js +90 -0
  27. package/lib/relay/queryValueFieldFragment.graphql.d.ts +20 -0
  28. package/lib/relay/queryValueFieldFragment.graphql.js +45 -0
  29. package/lib/umd/relay-forms-nodeps.js +133 -69
  30. package/lib/umd/relay-forms-nodeps.js.map +1 -1
  31. package/lib/umd/relay-forms-nodeps.min.js +1 -1
  32. package/lib/umd/relay-forms-nodeps.min.js.map +1 -1
  33. package/lib/useForm.d.ts +2 -0
  34. package/lib/{useFormSubmit.js → useForm.js} +6 -6
  35. package/lib/{useFormSetValue.d.ts → useFormField.d.ts} +1 -1
  36. package/lib/{useFormSetValue.js → useFormField.js} +50 -12
  37. package/lib/useFormState.js +3 -1
  38. package/package.json +4 -4
  39. package/lib/es/useFormSubmit.d.ts +0 -2
  40. package/lib/useFormSubmit.d.ts +0 -2
package/README.md CHANGED
@@ -22,13 +22,13 @@ This repository manages the three libraries to manage forms by exploiting the po
22
22
 
23
23
  [See SimpleExample.md](./docs/RelaySimpleExample.md)
24
24
 
25
- ## useFormSetValue
25
+ ## useFormField
26
26
 
27
- [See useFormSetValue.md](./docs/useFormSetValue.md)
27
+ [See useFormField.md](./docs/useFormSetValue.md)
28
28
 
29
- ## useFormSubmit
29
+ ## useForm
30
30
 
31
- [See useFormSubmit.md](./docs/useFormSubmit.md)
31
+ [See useForm.md](./docs/useFormSubmit.md)
32
32
 
33
33
  ## useFormState
34
34
 
@@ -8,12 +8,16 @@ export declare type FormSubmitReturn = {
8
8
  validate: () => void;
9
9
  reset: () => void;
10
10
  };
11
+ export declare type ValidateFunction<ValueType> = (value: ValueType, deps?: {
12
+ [key: string]: FormValueStateReturn<any>;
13
+ }) => Promise<string | undefined> | string | undefined;
11
14
  export declare type FormSetValueOptions<ValueType> = {
12
15
  key: string;
13
16
  initialValue?: ValueType;
14
- validate?: (value: ValueType) => Promise<string | undefined> | string | undefined;
17
+ validate?: ValidateFunction<ValueType>;
15
18
  validateOnChange?: boolean;
16
19
  label?: string;
20
+ dependsOn?: ReadonlyArray<string> | null | undefined;
17
21
  };
18
22
  export declare type FormSetValueStateReturn<ValueType> = {
19
23
  error: undefined | null | Error;
@@ -8,12 +8,16 @@ export declare type FormSubmitReturn = {
8
8
  validate: () => void;
9
9
  reset: () => void;
10
10
  };
11
+ export declare type ValidateFunction<ValueType> = (value: ValueType, deps?: {
12
+ [key: string]: FormValueStateReturn<any>;
13
+ }) => Promise<string | undefined> | string | undefined;
11
14
  export declare type FormSetValueOptions<ValueType> = {
12
15
  key: string;
13
16
  initialValue?: ValueType;
14
- validate?: (value: ValueType) => Promise<string | undefined> | string | undefined;
17
+ validate?: ValidateFunction<ValueType>;
15
18
  validateOnChange?: boolean;
16
19
  label?: string;
20
+ dependsOn?: ReadonlyArray<string> | null | undefined;
17
21
  };
18
22
  export declare type FormSetValueStateReturn<ValueType> = {
19
23
  error: undefined | null | Error;
package/lib/es/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { useFormState } from './useFormState';
2
- export { useFormSubmit } from './useFormSubmit';
3
- export { useFormSetValue } from './useFormSetValue';
2
+ export { useForm } from './useForm';
3
+ export { useFormField } from './useFormField';
4
4
  export { useFormValue } from './useFormValue';
5
5
  export { StoreProvider } from './relay/RelayStoreProvider';
6
6
  export { RelayModernStore as Store, createStore } from './relay/RelayModernStore';
package/lib/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { useFormState } from './useFormState';
2
- export { useFormSubmit } from './useFormSubmit';
3
- export { useFormSetValue } from './useFormSetValue';
2
+ export { useForm } from './useForm';
3
+ export { useFormField } from './useFormField';
4
4
  export { useFormValue } from './useFormValue';
5
5
  export { StoreProvider } from './relay/RelayStoreProvider';
6
6
  export { RelayModernStore as Store, createStore } from './relay/RelayModernStore';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @generated SignedSource<<cdb0ac3f0c6e25530bc6aa8ece819e03>>
3
+ * @relayHash 1e729a4dd469bbcedf1c07919286ff70
4
+ * @lightSyntaxTransform
5
+ * @nogrep
6
+ */
7
+ import { ConcreteRequest } from 'relay-runtime';
8
+ export declare type queryErrorsFieldQuery$variables = Record<PropertyKey, never>;
9
+ export declare type queryErrorsFieldQuery$data = {
10
+ readonly form: {
11
+ readonly errors: ReadonlyArray<{
12
+ readonly check: number | null | undefined;
13
+ readonly error: string | null | undefined;
14
+ readonly id: string;
15
+ readonly key: string;
16
+ readonly label: string | null | undefined;
17
+ } | null | undefined> | null | undefined;
18
+ readonly isSubmitting: boolean | null | undefined;
19
+ readonly isValid: boolean | null | undefined;
20
+ readonly isValidating: boolean | null | undefined;
21
+ } | null | undefined;
22
+ };
23
+ export declare type queryErrorsFieldQuery = {
24
+ response: queryErrorsFieldQuery$data;
25
+ variables: queryErrorsFieldQuery$variables;
26
+ };
27
+ declare const node: ConcreteRequest;
28
+ export default node;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @generated SignedSource<<cdb0ac3f0c6e25530bc6aa8ece819e03>>
3
+ * @relayHash 1e729a4dd469bbcedf1c07919286ff70
4
+ * @lightSyntaxTransform
5
+ * @nogrep
6
+ */
7
+ var node = function () {
8
+ var v0 = [{
9
+ "alias": null,
10
+ "args": null,
11
+ "concreteType": "EntryForm",
12
+ "kind": "LinkedField",
13
+ "name": "form",
14
+ "plural": false,
15
+ "selections": [{
16
+ "alias": null,
17
+ "args": null,
18
+ "kind": "ScalarField",
19
+ "name": "isSubmitting",
20
+ "storageKey": null
21
+ }, {
22
+ "alias": null,
23
+ "args": null,
24
+ "kind": "ScalarField",
25
+ "name": "isValidating",
26
+ "storageKey": null
27
+ }, {
28
+ "alias": null,
29
+ "args": null,
30
+ "kind": "ScalarField",
31
+ "name": "isValid",
32
+ "storageKey": null
33
+ }, {
34
+ "alias": null,
35
+ "args": null,
36
+ "concreteType": "Entry",
37
+ "kind": "LinkedField",
38
+ "name": "errors",
39
+ "plural": true,
40
+ "selections": [{
41
+ "alias": null,
42
+ "args": null,
43
+ "kind": "ScalarField",
44
+ "name": "id",
45
+ "storageKey": null
46
+ }, {
47
+ "alias": null,
48
+ "args": null,
49
+ "kind": "ScalarField",
50
+ "name": "key",
51
+ "storageKey": null
52
+ }, {
53
+ "alias": null,
54
+ "args": null,
55
+ "kind": "ScalarField",
56
+ "name": "error",
57
+ "storageKey": null
58
+ }, {
59
+ "alias": null,
60
+ "args": null,
61
+ "kind": "ScalarField",
62
+ "name": "check",
63
+ "storageKey": null
64
+ }, {
65
+ "alias": null,
66
+ "args": null,
67
+ "kind": "ScalarField",
68
+ "name": "label",
69
+ "storageKey": null
70
+ }],
71
+ "storageKey": null
72
+ }],
73
+ "storageKey": null
74
+ }];
75
+ return {
76
+ "fragment": {
77
+ "argumentDefinitions": [],
78
+ "kind": "Fragment",
79
+ "metadata": null,
80
+ "name": "queryErrorsFieldQuery",
81
+ "selections": v0 /*: any*/,
82
+ "type": "Query",
83
+ "abstractKey": null
84
+ },
85
+ "kind": "Request",
86
+ "operation": {
87
+ "argumentDefinitions": [],
88
+ "kind": "Operation",
89
+ "name": "queryErrorsFieldQuery",
90
+ "selections": v0 /*: any*/
91
+ },
92
+
93
+ "params": {
94
+ "id": "1e729a4dd469bbcedf1c07919286ff70\r",
95
+ "metadata": {},
96
+ "name": "queryErrorsFieldQuery",
97
+ "operationKind": "query",
98
+ "text": null
99
+ }
100
+ };
101
+ }();
102
+ node.hash = "10e337eb009f23b0bbee954d56b68b89";
103
+ export default node;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @generated SignedSource<<d21170d0feb748c6558c5e5dbb4425c4>>
3
+ * @lightSyntaxTransform
4
+ * @nogrep
5
+ */
6
+ import { ReaderFragment } from 'relay-runtime';
7
+ import { FragmentRefs } from "relay-runtime";
8
+ export declare type queryFieldFragment$data = {
9
+ readonly check: number | null | undefined;
10
+ readonly id: string;
11
+ readonly " $fragmentType": "queryFieldFragment";
12
+ };
13
+ export declare type queryFieldFragment$key = {
14
+ readonly " $data"?: queryFieldFragment$data;
15
+ readonly " $fragmentSpreads": FragmentRefs<"queryFieldFragment">;
16
+ };
17
+ declare const node: ReaderFragment;
18
+ export default node;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @generated SignedSource<<d21170d0feb748c6558c5e5dbb4425c4>>
3
+ * @lightSyntaxTransform
4
+ * @nogrep
5
+ */
6
+ var node = {
7
+ "argumentDefinitions": [],
8
+ "kind": "Fragment",
9
+ "metadata": null,
10
+ "name": "queryFieldFragment",
11
+ "selections": [{
12
+ "alias": null,
13
+ "args": null,
14
+ "kind": "ScalarField",
15
+ "name": "id",
16
+ "storageKey": null
17
+ }, {
18
+ "alias": null,
19
+ "args": null,
20
+ "kind": "ScalarField",
21
+ "name": "check",
22
+ "storageKey": null
23
+ }],
24
+ "type": "Entry",
25
+ "abstractKey": null
26
+ };
27
+ node.hash = "d5b0953bdeb412925ee13444a6be6082";
28
+ export default node;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @generated SignedSource<<6f460eca2a43fd75eab202937349c693>>
3
+ * @relayHash 0b493a6f66e132f2693f91a5da941414
4
+ * @lightSyntaxTransform
5
+ * @nogrep
6
+ */
7
+ import { ConcreteRequest } from 'relay-runtime';
8
+ export declare type queryFieldQuery$variables = Record<PropertyKey, never>;
9
+ export declare type queryFieldQuery$data = {
10
+ readonly form: {
11
+ readonly entries: ReadonlyArray<{
12
+ readonly check: number | null | undefined;
13
+ readonly error: string | null | undefined;
14
+ readonly id: string;
15
+ readonly key: string;
16
+ readonly value: string | null | undefined;
17
+ } | null | undefined> | null | undefined;
18
+ } | null | undefined;
19
+ };
20
+ export declare type queryFieldQuery = {
21
+ response: queryFieldQuery$data;
22
+ variables: queryFieldQuery$variables;
23
+ };
24
+ declare const node: ConcreteRequest;
25
+ export default node;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @generated SignedSource<<6f460eca2a43fd75eab202937349c693>>
3
+ * @relayHash 0b493a6f66e132f2693f91a5da941414
4
+ * @lightSyntaxTransform
5
+ * @nogrep
6
+ */
7
+ var node = function () {
8
+ var v0 = [{
9
+ "alias": null,
10
+ "args": null,
11
+ "concreteType": "EntryForm",
12
+ "kind": "LinkedField",
13
+ "name": "form",
14
+ "plural": false,
15
+ "selections": [{
16
+ "alias": null,
17
+ "args": null,
18
+ "concreteType": "Entry",
19
+ "kind": "LinkedField",
20
+ "name": "entries",
21
+ "plural": true,
22
+ "selections": [{
23
+ "alias": null,
24
+ "args": null,
25
+ "kind": "ScalarField",
26
+ "name": "id",
27
+ "storageKey": null
28
+ }, {
29
+ "alias": null,
30
+ "args": null,
31
+ "kind": "ScalarField",
32
+ "name": "key",
33
+ "storageKey": null
34
+ }, {
35
+ "alias": null,
36
+ "args": null,
37
+ "kind": "ScalarField",
38
+ "name": "value",
39
+ "storageKey": null
40
+ }, {
41
+ "alias": null,
42
+ "args": null,
43
+ "kind": "ScalarField",
44
+ "name": "check",
45
+ "storageKey": null
46
+ }, {
47
+ "alias": null,
48
+ "args": null,
49
+ "kind": "ScalarField",
50
+ "name": "error",
51
+ "storageKey": null
52
+ }],
53
+ "storageKey": null
54
+ }],
55
+ "storageKey": null
56
+ }];
57
+ return {
58
+ "fragment": {
59
+ "argumentDefinitions": [],
60
+ "kind": "Fragment",
61
+ "metadata": null,
62
+ "name": "queryFieldQuery",
63
+ "selections": v0 /*: any*/,
64
+ "type": "Query",
65
+ "abstractKey": null
66
+ },
67
+ "kind": "Request",
68
+ "operation": {
69
+ "argumentDefinitions": [],
70
+ "kind": "Operation",
71
+ "name": "queryFieldQuery",
72
+ "selections": v0 /*: any*/
73
+ },
74
+
75
+ "params": {
76
+ "id": "0b493a6f66e132f2693f91a5da941414\r",
77
+ "metadata": {},
78
+ "name": "queryFieldQuery",
79
+ "operationKind": "query",
80
+ "text": null
81
+ }
82
+ };
83
+ }();
84
+ node.hash = "f9fd20a80a839dfb51206c305cbb1657";
85
+ export default node;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @generated SignedSource<<432c971608826457e61804e44aeb7a64>>
3
+ * @lightSyntaxTransform
4
+ * @nogrep
5
+ */
6
+ import { ReaderFragment } from 'relay-runtime';
7
+ import { FragmentRefs } from "relay-runtime";
8
+ export declare type queryValueFieldFragment$data = {
9
+ readonly error: string | null | undefined;
10
+ readonly id: string;
11
+ readonly label: string | null | undefined;
12
+ readonly value: string | null | undefined;
13
+ readonly " $fragmentType": "queryValueFieldFragment";
14
+ };
15
+ export declare type queryValueFieldFragment$key = {
16
+ readonly " $data"?: queryValueFieldFragment$data;
17
+ readonly " $fragmentSpreads": FragmentRefs<"queryValueFieldFragment">;
18
+ };
19
+ declare const node: ReaderFragment;
20
+ export default node;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @generated SignedSource<<432c971608826457e61804e44aeb7a64>>
3
+ * @lightSyntaxTransform
4
+ * @nogrep
5
+ */
6
+ var node = {
7
+ "argumentDefinitions": [],
8
+ "kind": "Fragment",
9
+ "metadata": null,
10
+ "name": "queryValueFieldFragment",
11
+ "selections": [{
12
+ "alias": null,
13
+ "args": null,
14
+ "kind": "ScalarField",
15
+ "name": "id",
16
+ "storageKey": null
17
+ }, {
18
+ "alias": null,
19
+ "args": null,
20
+ "kind": "ScalarField",
21
+ "name": "value",
22
+ "storageKey": null
23
+ }, {
24
+ "alias": null,
25
+ "args": null,
26
+ "kind": "ScalarField",
27
+ "name": "label",
28
+ "storageKey": null
29
+ }, {
30
+ "alias": null,
31
+ "args": null,
32
+ "kind": "ScalarField",
33
+ "name": "error",
34
+ "storageKey": null
35
+ }],
36
+ "type": "Entry",
37
+ "abstractKey": null
38
+ };
39
+ node.hash = "364beea31c4e318a5241f2bd7d96fbd8";
40
+ export default node;
@@ -0,0 +1,2 @@
1
+ import { FormSubmitOptions, FormSubmitReturn } from './RelayFormsTypes';
2
+ export declare const useForm: <ValueType extends object = object>({ onSubmit, }: FormSubmitOptions<ValueType>) => FormSubmitReturn;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useStore } from './relay/RelayStoreProvider';
3
3
  import { isPromise } from './relay/RelayStoreUtils';
4
- import { isDone, RESET, TOBEVALIDATE, VALIDATING } from './useFormSetValue';
4
+ import { isDone, RESET, TOBEVALIDATE, VALIDATING } from './useFormField';
5
5
  import { operationQueryForm, commit } from './Utils';
6
6
  function logicSubmit(environment, onSubmit) {
7
7
  function dispose() {
@@ -107,7 +107,7 @@ function logicSubmit(environment, onSubmit) {
107
107
  getData: getData
108
108
  };
109
109
  }
110
- export var useFormSubmit = function (_a) {
110
+ export var useForm = function (_a) {
111
111
  var onSubmit = _a.onSubmit;
112
112
  var environment = useStore();
113
113
  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 useFormSetValue<ValueType>({ key, initialValue, validate, validateOnChange, label, }: FormSetValueOptions<ValueType>): FormSetValueReturn<ValueType>;
6
+ export declare function useFormField<ValueType>({ key, initialValue, validate, validateOnChange, label, dependsOn, }: FormSetValueOptions<ValueType>): FormSetValueReturn<ValueType>;
@@ -1,5 +1,16 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
+ }
7
+ return t;
8
+ };
9
+ return __assign.apply(this, arguments);
10
+ };
1
11
  import React from 'react';
2
12
  import { FragmentSet } from './relay/queries';
13
+ import FragmentValueField from './relay/queryValueFieldFragment.graphql';
3
14
  import { useStore } from './relay/RelayStoreProvider';
4
15
  import { isPromise } from './relay/RelayStoreUtils';
5
16
  import { useForceUpdate } from './useForceUpdate';
@@ -22,10 +33,15 @@ function logicSetValue(params) {
22
33
  initialValue = params.initialValue,
23
34
  forceUpdate = params.forceUpdate,
24
35
  validateOnChange = params.validateOnChange,
25
- label = params.label;
36
+ label = params.label,
37
+ dependsOn = params.dependsOn;
26
38
  var validate = undefined;
27
39
  var firstSet = true;
40
+ var deps = {};
28
41
  var localId = getFieldId(key);
42
+ function getDeps() {
43
+ return deps;
44
+ }
29
45
  function getValidate() {
30
46
  return validate;
31
47
  }
@@ -100,13 +116,14 @@ function logicSetValue(params) {
100
116
  }
101
117
  commitField(false);
102
118
  }
103
- function internalValidate(value, validateFunction) {
119
+ function internalValidate(value, validateFunction, depsValidation) {
104
120
  ref.isChecking = true;
105
- var result = validateFunction(value);
121
+ var result = validateFunction(value, deps);
106
122
  function internalFinalize(error) {
107
123
  var validate = getValidate();
108
- if (value !== dataResult.value || validate !== validateFunction) {
109
- internalValidate(dataResult.value, validate);
124
+ var deps = getDeps();
125
+ if (value !== dataResult.value || validate !== validateFunction || deps !== depsValidation) {
126
+ internalValidate(dataResult.value, validate, deps);
110
127
  return;
111
128
  }
112
129
  finalizeCheck(error);
@@ -130,9 +147,25 @@ function logicSetValue(params) {
130
147
  ref.check = getInitCheck(validate);
131
148
  setValueInternal(initialValue);
132
149
  } else if (isValidating && !ref.isChecking) {
133
- internalValidate(dataResult.value, validate);
150
+ internalValidate(dataResult.value, validate, deps);
134
151
  }
135
152
  }).dispose;
153
+ var disposeDeps = [];
154
+ if (dependsOn != null) {
155
+ dependsOn.forEach(function (depKey) {
156
+ var snapshot = getSnapshot(environment, FragmentValueField, depKey);
157
+ var disposeDep = environment.subscribe(snapshot, function (s) {
158
+ var _a;
159
+ var data = s.data;
160
+ deps = __assign(__assign({}, deps), (_a = {}, _a[depKey] = data, _a));
161
+ if (ref.check == DONEVALIDATED && !ref.isChecking) {
162
+ ref.check = VALIDATING;
163
+ commitField(false);
164
+ }
165
+ }).dispose;
166
+ disposeDeps.push(disposeDep);
167
+ });
168
+ }
136
169
  var dispose = function () {
137
170
  disposeSubscrition();
138
171
  commit(environment, function (store, form) {
@@ -143,9 +176,12 @@ function logicSetValue(params) {
143
176
  form.setLinkedRecords(newEntries, 'entries');
144
177
  store.delete(localId);
145
178
  });
179
+ disposeDeps.forEach(function (dispose) {
180
+ return dispose;
181
+ });
146
182
  };
147
183
  if (validateOnChange) {
148
- internalValidate(initialValue, getValidate());
184
+ internalValidate(initialValue, getValidate(), deps);
149
185
  }
150
186
  return dispose;
151
187
  }
@@ -156,12 +192,13 @@ function logicSetValue(params) {
156
192
  setValidate: setValidate
157
193
  };
158
194
  }
159
- export function useFormSetValue(_a) {
195
+ export function useFormField(_a) {
160
196
  var key = _a.key,
161
197
  initialValue = _a.initialValue,
162
198
  validate = _a.validate,
163
199
  validateOnChange = _a.validateOnChange,
164
- label = _a.label;
200
+ label = _a.label,
201
+ dependsOn = _a.dependsOn;
165
202
  var forceUpdate = useForceUpdate();
166
203
  var environment = useStore();
167
204
  var resolver = React.useMemo(function () {
@@ -171,9 +208,10 @@ export function useFormSetValue(_a) {
171
208
  label: label,
172
209
  initialValue: initialValue,
173
210
  forceUpdate: forceUpdate,
174
- validateOnChange: validateOnChange
211
+ validateOnChange: validateOnChange,
212
+ dependsOn: dependsOn
175
213
  });
176
- }, [environment, key, initialValue, forceUpdate, validateOnChange, label]);
214
+ }, [environment, key, initialValue, forceUpdate, validateOnChange, label, dependsOn]);
177
215
  resolver.setValidate(validate);
178
216
  React.useEffect(function () {
179
217
  return resolver.subscribe();
@@ -4,7 +4,9 @@ import { operationQueryErrorsForm } from './Utils';
4
4
  export var useFormState = function () {
5
5
  var environment = useStore();
6
6
  var snapshot = React.useMemo(function () {
7
- return environment.lookup(operationQueryErrorsForm.fragment);
7
+ var s = environment.lookup(operationQueryErrorsForm.fragment);
8
+ s.seenRecords.add('local:form');
9
+ return s;
8
10
  }, [environment]);
9
11
  var _a = React.useState(snapshot.data.form),
10
12
  data = _a[0],
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { useFormState } from './useFormState';
2
- export { useFormSubmit } from './useFormSubmit';
3
- export { useFormSetValue } from './useFormSetValue';
2
+ export { useForm } from './useForm';
3
+ export { useFormField } from './useFormField';
4
4
  export { useFormValue } from './useFormValue';
5
5
  export { StoreProvider } from './relay/RelayStoreProvider';
6
6
  export { RelayModernStore as Store, createStore } from './relay/RelayModernStore';
package/lib/index.js CHANGED
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  var useFormState_1 = require("./useFormState");
7
7
  exports.useFormState = useFormState_1.useFormState;
8
- var useFormSubmit_1 = require("./useFormSubmit");
9
- exports.useFormSubmit = useFormSubmit_1.useFormSubmit;
10
- var useFormSetValue_1 = require("./useFormSetValue");
11
- exports.useFormSetValue = useFormSetValue_1.useFormSetValue;
8
+ var useForm_1 = require("./useForm");
9
+ exports.useForm = useForm_1.useForm;
10
+ var useFormField_1 = require("./useFormField");
11
+ exports.useFormField = useFormField_1.useFormField;
12
12
  var useFormValue_1 = require("./useFormValue");
13
13
  exports.useFormValue = useFormValue_1.useFormValue;
14
14
  var RelayStoreProvider_1 = require("./relay/RelayStoreProvider");
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @generated SignedSource<<cdb0ac3f0c6e25530bc6aa8ece819e03>>
3
+ * @relayHash 1e729a4dd469bbcedf1c07919286ff70
4
+ * @lightSyntaxTransform
5
+ * @nogrep
6
+ */
7
+ import { ConcreteRequest } from 'relay-runtime';
8
+ export declare type queryErrorsFieldQuery$variables = Record<PropertyKey, never>;
9
+ export declare type queryErrorsFieldQuery$data = {
10
+ readonly form: {
11
+ readonly errors: ReadonlyArray<{
12
+ readonly check: number | null | undefined;
13
+ readonly error: string | null | undefined;
14
+ readonly id: string;
15
+ readonly key: string;
16
+ readonly label: string | null | undefined;
17
+ } | null | undefined> | null | undefined;
18
+ readonly isSubmitting: boolean | null | undefined;
19
+ readonly isValid: boolean | null | undefined;
20
+ readonly isValidating: boolean | null | undefined;
21
+ } | null | undefined;
22
+ };
23
+ export declare type queryErrorsFieldQuery = {
24
+ response: queryErrorsFieldQuery$data;
25
+ variables: queryErrorsFieldQuery$variables;
26
+ };
27
+ declare const node: ConcreteRequest;
28
+ export default node;