relay-forms-nodeps 1.0.0 → 1.1.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 (39) hide show
  1. package/README.md +23 -108
  2. package/lib/RelayFormsTypes.d.ts +1 -0
  3. package/lib/Utils.d.ts +5 -8
  4. package/lib/Utils.js +10 -65
  5. package/lib/es/RelayFormsTypes.d.ts +1 -0
  6. package/lib/es/Utils.d.ts +5 -8
  7. package/lib/es/Utils.js +10 -67
  8. package/lib/es/relay/RelayRecordProxy.d.ts +1 -0
  9. package/lib/es/relay/RelayRecordProxy.js +3 -0
  10. package/lib/es/relay/RelayRecordSourceMutator.d.ts +1 -0
  11. package/lib/es/relay/RelayRecordSourceMutator.js +13 -0
  12. package/lib/es/relay/RelayTypes.d.ts +1 -0
  13. package/lib/es/relay/queries.d.ts +6 -4
  14. package/lib/es/relay/queries.js +6 -3
  15. package/lib/es/useFormSetValue.d.ts +5 -1
  16. package/lib/es/useFormSetValue.js +162 -64
  17. package/lib/es/useFormState.d.ts +12 -2
  18. package/lib/es/useFormState.js +10 -40
  19. package/lib/es/useFormSubmit.js +104 -89
  20. package/lib/es/useFormValue.js +1 -1
  21. package/lib/relay/RelayRecordProxy.d.ts +1 -0
  22. package/lib/relay/RelayRecordProxy.js +3 -0
  23. package/lib/relay/RelayRecordSourceMutator.d.ts +1 -0
  24. package/lib/relay/RelayRecordSourceMutator.js +13 -0
  25. package/lib/relay/RelayTypes.d.ts +1 -0
  26. package/lib/relay/queries.d.ts +6 -4
  27. package/lib/relay/queries.js +6 -3
  28. package/lib/umd/relay-forms-nodeps.js +319 -273
  29. package/lib/umd/relay-forms-nodeps.js.map +1 -1
  30. package/lib/umd/relay-forms-nodeps.min.js +1 -1
  31. package/lib/umd/relay-forms-nodeps.min.js.map +1 -1
  32. package/lib/useFormSetValue.d.ts +5 -1
  33. package/lib/useFormSetValue.js +162 -63
  34. package/lib/useFormState.d.ts +12 -2
  35. package/lib/useFormState.js +10 -40
  36. package/lib/useFormSubmit.js +103 -88
  37. package/lib/useFormValue.js +1 -1
  38. package/package.json +15 -2
  39. package/yarn-error.log +31 -31
@@ -3,82 +3,180 @@ import { FragmentSet } from './relay/queries';
3
3
  import { useStore } from './relay/RelayStoreProvider';
4
4
  import { isPromise } from './relay/RelayStoreUtils';
5
5
  import { useForceUpdate } from './useForceUpdate';
6
- import { commitValue, commitErrorIntoRelay, commitResetField, getSnapshot } from './Utils';
7
- export function useFormSetValue(_a) {
8
- var key = _a.key,
9
- initialValue = _a.initialValue,
10
- validate = _a.validate,
11
- validateOnChange = _a.validateOnChange;
12
- var forceUpdate = useForceUpdate();
13
- var environment = useStore();
14
- var ref = React.useRef({
15
- value: initialValue,
16
- error: undefined,
17
- check: validate ? 'INIT' : 'DONE',
6
+ import { getSnapshot, getFieldId, commit } from './Utils';
7
+ var INIT = 0;
8
+ export var TOBEVALIDATE = 1;
9
+ export var VALIDATING = 2;
10
+ var DONE = 3;
11
+ var DONEVALIDATED = 4;
12
+ export var RESET = 5;
13
+ function getInitCheck(validate) {
14
+ return validate ? TOBEVALIDATE : DONE;
15
+ }
16
+ export function isDone(check) {
17
+ return check === DONE || check === DONEVALIDATED;
18
+ }
19
+ function logicSetValue(params) {
20
+ var environment = params.environment,
21
+ key = params.key,
22
+ initialValue = params.initialValue,
23
+ forceUpdate = params.forceUpdate,
24
+ validateOnChange = params.validateOnChange,
25
+ label = params.label;
26
+ var validate = undefined;
27
+ var firstSet = true;
28
+ var localId = getFieldId(key);
29
+ function getValidate() {
30
+ return validate;
31
+ }
32
+ var ref = {
33
+ check: INIT,
18
34
  isChecking: false
19
- });
20
- var setValue = React.useCallback(function (newValue) {
21
- ref.current.value = newValue;
22
- if (ref.current.check === 'DONE' && validate) {
23
- ref.current.check = 'START';
35
+ };
36
+ var dataResult = {
37
+ value: initialValue,
38
+ error: undefined
39
+ };
40
+ function commitField(commitValue) {
41
+ if (commitValue === void 0) {
42
+ commitValue = true;
24
43
  }
25
- commitValue(key, newValue, ref.current.check, environment);
44
+ commit(environment, function (store, form) {
45
+ var field = store.get(localId);
46
+ if (!field) {
47
+ field = store.create(localId).setValue(localId, 'id').setValue(label, 'label').setValue(key, 'key');
48
+ var entriesArray = form.getLinkedRecords('entries');
49
+ entriesArray.push(field);
50
+ form.setLinkedRecords(entriesArray, 'entries');
51
+ }
52
+ if (ref.check === VALIDATING) {
53
+ form.setValue(true, 'isValidating');
54
+ }
55
+ field.setValue(ref.check, 'check').setValue(dataResult.error, 'error');
56
+ if (commitValue) field.setValue(dataResult.value, 'value');
57
+ });
58
+ }
59
+ function setValidate(newValidate) {
60
+ if (validate === newValidate && !firstSet) {
61
+ // first set only needs this
62
+ return;
63
+ }
64
+ firstSet = false;
65
+ validate = newValidate;
66
+ // validation was called
67
+ if (ref.check === DONEVALIDATED && validate) {
68
+ ref.check = VALIDATING;
69
+ } else {
70
+ // reinit
71
+ ref.check = getInitCheck(validate);
72
+ }
73
+ commitField();
74
+ }
75
+ function getData() {
76
+ return dataResult;
77
+ }
78
+ function changeData(value, error) {
79
+ dataResult = {
80
+ value: value,
81
+ error: error
82
+ };
26
83
  forceUpdate();
27
- }, [environment, key, validate, forceUpdate]);
28
- React.useEffect(function () {
29
- //commitResetField(environment, key);
30
- commitValue(key, initialValue, ref.current.check, environment);
84
+ }
85
+ function setValue(newValue) {
86
+ setValueInternal(newValue);
87
+ }
88
+ function setValueInternal(newValue, error) {
89
+ if (ref.check === DONEVALIDATED) {
90
+ ref.check = VALIDATING;
91
+ }
92
+ changeData(newValue, error);
93
+ commitField();
94
+ }
95
+ function finalizeCheck(error) {
96
+ ref.isChecking = false;
97
+ ref.check = DONEVALIDATED;
98
+ if (dataResult.error !== error) {
99
+ changeData(dataResult.value, error);
100
+ }
101
+ commitField(false);
102
+ }
103
+ function internalValidate(value, validateFunction) {
104
+ ref.isChecking = true;
105
+ var result = validateFunction(value);
106
+ function internalFinalize(error) {
107
+ var validate = getValidate();
108
+ if (value !== dataResult.value || validate !== validateFunction) {
109
+ internalValidate(dataResult.value, validate);
110
+ return;
111
+ }
112
+ finalizeCheck(error);
113
+ }
114
+ if (isPromise(result)) {
115
+ result.then(internalFinalize).catch(internalFinalize);
116
+ } else {
117
+ internalFinalize(result);
118
+ }
119
+ }
120
+ function subscribe() {
31
121
  var snapshot = getSnapshot(environment, FragmentSet, key);
32
122
  var disposeSubscrition = environment.subscribe(snapshot, function (s) {
33
- var check = s.data.check;
34
- var isStart = check === 'START';
35
- var isReset = check === 'RESET';
36
- ref.current.check = check;
123
+ var data = s.data;
124
+ var dataCheck = data.check;
125
+ var isValidating = dataCheck === VALIDATING;
126
+ var isReset = dataCheck === RESET;
127
+ ref.check = dataCheck;
128
+ var validate = getValidate();
37
129
  if (isReset) {
38
- ref.current.check = validate ? 'INIT' : 'DONE';
39
- setValue(initialValue);
40
- } else {
41
- if (!validate) {
42
- commitErrorIntoRelay(key, undefined, environment);
43
- return;
44
- }
45
- if (isStart && !ref.current.isChecking) {
46
- internalValidate(ref.current.value);
47
- }
130
+ ref.check = getInitCheck(validate);
131
+ setValueInternal(initialValue);
132
+ } else if (isValidating && !ref.isChecking) {
133
+ internalValidate(dataResult.value, validate);
48
134
  }
49
135
  }).dispose;
50
136
  var dispose = function () {
51
137
  disposeSubscrition();
52
- commitResetField(environment, key);
138
+ commit(environment, function (store, form) {
139
+ var entriesArray = form.getLinkedRecords('entries');
140
+ var newEntries = entriesArray.filter(function (value) {
141
+ return value.getDataID() != localId;
142
+ });
143
+ form.setLinkedRecords(newEntries, 'entries');
144
+ store.delete(localId);
145
+ });
53
146
  };
54
- function finalizeCheck(error) {
55
- ref.current.isChecking = false;
56
- if (ref.current.error !== error) {
57
- ref.current.error = error;
58
- forceUpdate();
59
- }
60
- commitErrorIntoRelay(key, error, environment);
61
- }
62
- function internalValidate(value) {
63
- ref.current.isChecking = true;
64
- var result = validate(value);
65
- function internalFinalize(error) {
66
- if (value !== ref.current.value) {
67
- internalValidate(ref.current.value);
68
- return;
69
- }
70
- finalizeCheck(error);
71
- }
72
- if (isPromise(result)) {
73
- result.then(internalFinalize).catch(internalFinalize);
74
- } else {
75
- internalFinalize(result);
76
- }
77
- }
78
147
  if (validateOnChange) {
79
- internalValidate(initialValue);
148
+ internalValidate(initialValue, getValidate());
80
149
  }
81
150
  return dispose;
82
- }, [environment, initialValue, key, setValue, validate, validateOnChange, forceUpdate]);
83
- return [ref.current, setValue];
151
+ }
152
+ return {
153
+ subscribe: subscribe,
154
+ getData: getData,
155
+ setValue: setValue,
156
+ setValidate: setValidate
157
+ };
158
+ }
159
+ export function useFormSetValue(_a) {
160
+ var key = _a.key,
161
+ initialValue = _a.initialValue,
162
+ validate = _a.validate,
163
+ validateOnChange = _a.validateOnChange,
164
+ label = _a.label;
165
+ var forceUpdate = useForceUpdate();
166
+ var environment = useStore();
167
+ var resolver = React.useMemo(function () {
168
+ return logicSetValue({
169
+ environment: environment,
170
+ key: key,
171
+ label: label,
172
+ initialValue: initialValue,
173
+ forceUpdate: forceUpdate,
174
+ validateOnChange: validateOnChange
175
+ });
176
+ }, [environment, key, initialValue, forceUpdate, validateOnChange, label]);
177
+ resolver.setValidate(validate);
178
+ React.useEffect(function () {
179
+ return resolver.subscribe();
180
+ }, [resolver]);
181
+ return [resolver.getData(), resolver.setValue];
84
182
  }
@@ -1,2 +1,12 @@
1
- import { FormStateReturn } from './RelayFormsTypes';
2
- export declare const useFormState: () => FormStateReturn;
1
+ export declare const useFormState: () => {
2
+ readonly errors: readonly {
3
+ readonly check: number;
4
+ readonly error: string;
5
+ readonly id: string;
6
+ readonly key: string;
7
+ readonly label: string;
8
+ }[];
9
+ readonly isSubmitting: boolean;
10
+ readonly isValid: boolean;
11
+ readonly isValidating: boolean;
12
+ };
@@ -1,49 +1,19 @@
1
1
  import React from 'react';
2
2
  import { useStore } from './relay/RelayStoreProvider';
3
- import { areEqual } from './relay/RelayStoreUtils';
4
- import { useForceUpdate } from './useForceUpdate';
5
3
  import { operationQueryErrorsForm } from './Utils';
6
4
  export var useFormState = function () {
7
- var ref = React.useRef({
8
- errors: undefined,
9
- isValidating: false,
10
- isSubmitting: false,
11
- isValid: false
12
- });
13
- var forceUpdate = useForceUpdate();
14
5
  var environment = useStore();
6
+ var snapshot = React.useMemo(function () {
7
+ return environment.lookup(operationQueryErrorsForm.fragment);
8
+ }, [environment]);
9
+ var _a = React.useState(snapshot.data.form),
10
+ data = _a[0],
11
+ setData = _a[1];
15
12
  React.useEffect(function () {
16
- function checkError(s) {
17
- var data = s.data;
18
- var form = data.form;
19
- var entries = form.entries;
20
- var current = ref.current;
21
- var entryErrors = entries.filter(function (value) {
22
- return !!value.error;
23
- });
24
- var entryValidated = entries.filter(function (value) {
25
- return value.check === 'DONE';
26
- });
27
- var errors = entryErrors.length > 0 ? entryErrors : undefined;
28
- var isValidating = form.isValidating;
29
- var isSubmitting = form.isSubmitting;
30
- var isValid = entries.length === entryValidated.length && (!errors || Object.keys(errors).length === 0);
31
- var newState = {
32
- errors: errors,
33
- isValid: isValid,
34
- isValidating: isValidating,
35
- isSubmitting: isSubmitting
36
- };
37
- if (!areEqual(current, newState)) {
38
- ref.current = newState;
39
- forceUpdate();
40
- }
41
- }
42
- var snapshot = environment.lookup(operationQueryErrorsForm.fragment);
43
- checkError(snapshot);
44
13
  return environment.subscribe(snapshot, function (s) {
45
- checkError(s);
14
+ setData(s.data.form);
46
15
  }).dispose;
47
- }, [environment, forceUpdate]);
48
- return ref.current;
16
+ // eslint-disable-next-line react-hooks/exhaustive-deps
17
+ }, [snapshot]);
18
+ return data;
49
19
  };
@@ -1,105 +1,120 @@
1
1
  import React from 'react';
2
2
  import { useStore } from './relay/RelayStoreProvider';
3
3
  import { isPromise } from './relay/RelayStoreUtils';
4
- import { commitValidateEndRelay, commitValidateIntoRelay, commitSubmitEndRelay, operationQueryForm, commitResetIntoRelay } from './Utils';
5
- export var useFormSubmit = function (_a) {
6
- var onSubmit = _a.onSubmit;
7
- var environment = useStore();
8
- React.useEffect(function () {
9
- return environment.retain(operationQueryForm).dispose;
10
- }, [environment]);
11
- var ref = React.useRef({
12
- isSubmitting: false,
13
- isValidating: false,
14
- error: undefined,
15
- subscription: undefined
16
- });
17
- var internalValidate = React.useCallback(function (snapshot, isSubmitting) {
18
- ref.current.isValidating = true;
19
- var data = snapshot.data;
20
- var filtered = data.form.entries.filter(function (value) {
21
- return value.check === 'INIT';
22
- });
23
- commitValidateIntoRelay(filtered, isSubmitting, environment);
24
- }, [environment]);
25
- var execute = React.useCallback(function (environment, snapshot, dispose, onSubmit) {
4
+ import { isDone, RESET, TOBEVALIDATE, VALIDATING } from './useFormSetValue';
5
+ import { operationQueryForm, commit } from './Utils';
6
+ function logicSubmit(environment, onSubmit) {
7
+ function dispose() {
8
+ subscription && subscription.dispose();
9
+ subscription = undefined;
10
+ }
11
+ var isSubmitting = false;
12
+ var subscription;
13
+ function execute(snapshot) {
14
+ var disposeSubmit = function () {
15
+ isSubmitting = false;
16
+ commit(environment, function (_, form) {
17
+ form.setValue(false, 'isSubmitting');
18
+ });
19
+ };
26
20
  var data = snapshot.data;
27
21
  var entries = data.form.entries;
28
22
  var filtered = entries.filter(function (value) {
29
- return value.check === 'DONE';
23
+ return isDone(value.check);
24
+ });
25
+ var isValidating = filtered.length !== entries.length;
26
+ var errors = entries.filter(function (value) {
27
+ return !!value.error;
28
+ }).map(function (value) {
29
+ return value.id;
30
30
  });
31
- if (filtered.length === entries.length) {
32
- var errors = entries.filter(function (value) {
33
- return !!value.error;
31
+ var isValid = !isValidating && errors.length === 0;
32
+ commit(environment, function (store, form) {
33
+ form.setValue(isValidating, 'isValidating').setValue(isValid, 'isValid');
34
+ var errorFields = [];
35
+ errors.forEach(function (id) {
36
+ errorFields.push(store.get(id));
34
37
  });
35
- commitValidateEndRelay(environment);
36
- ref.current.isValidating = false;
37
- var internalDispose = function () {
38
- dispose();
39
- if (ref.current.isSubmitting) {
40
- ref.current.isSubmitting = false;
41
- commitSubmitEndRelay(environment);
42
- }
43
- };
44
- if (ref.current.isSubmitting && onSubmit && errors.length === 0) {
45
- var result_1 = {};
46
- entries.forEach(function (entry) {
47
- result_1[entry.key] = entry.value;
48
- });
49
- var submit_1 = onSubmit(result_1);
50
- if (isPromise(submit_1)) {
51
- submit_1.then(internalDispose).catch(internalDispose);
52
- return;
53
- }
38
+ form.setLinkedRecords(errorFields, 'errors');
39
+ });
40
+ if (isValid && isSubmitting) {
41
+ dispose();
42
+ var result_1 = {};
43
+ entries.forEach(function (entry) {
44
+ result_1[entry.key] = entry.value;
45
+ });
46
+ var submit_1 = onSubmit(result_1);
47
+ if (isPromise(submit_1)) {
48
+ submit_1.then(disposeSubmit).catch(disposeSubmit);
49
+ return;
54
50
  }
55
- internalDispose();
56
- }
57
- }, []);
58
- var reset = React.useCallback(function () {
59
- var snapshot = environment.lookup(operationQueryForm.fragment);
60
- if (ref.current.isValidating && ref.current.isSubmitting) {
61
- return;
51
+ } else if (!isValidating) {
52
+ disposeSubmit();
62
53
  }
63
- var data = snapshot.data;
64
- commitResetIntoRelay(data.form.entries, environment);
65
- }, [environment]);
66
- var subscribe = React.useCallback(function (submit) {
67
- if (submit === void 0) {
68
- submit = false;
69
- }
70
- var snapshot = environment.lookup(operationQueryForm.fragment);
71
- var subscription = ref.current.subscription;
72
- subscription && subscription.dispose();
73
- function dispose() {
74
- subscription && subscription.dispose();
75
- ref.current.subscription = null;
54
+ }
55
+ function reset() {
56
+ if (!isSubmitting) {
57
+ dispose();
58
+ commit(environment, function (_, form) {
59
+ form.setValue(false, 'isSubmitting').setValue(false, 'isValidating').setLinkedRecords([], 'errors').getLinkedRecords('entries').forEach(function (entry) {
60
+ return entry.setValue(RESET, 'check').setValue(undefined, 'error');
61
+ });
62
+ });
76
63
  }
77
- ref.current.subscription = environment.subscribe(snapshot, function (s) {
78
- return execute(environment, s, dispose, onSubmit);
64
+ }
65
+ function validate() {
66
+ commit(environment, function (_, form) {
67
+ var tobeValitating = form.setValue(isSubmitting, 'isSubmitting').getLinkedRecords('entries').filter(function (value) {
68
+ return value.getValue('check') === TOBEVALIDATE;
69
+ });
70
+ form.setValue(tobeValitating.length === 0, 'isValidating');
71
+ tobeValitating.forEach(function (entry) {
72
+ return entry.setValue(VALIDATING, 'check');
73
+ });
79
74
  });
80
- internalValidate(snapshot, submit);
81
- execute(environment, snapshot, dispose, onSubmit);
82
- }, [environment, internalValidate, execute, onSubmit]);
83
- var validate = React.useCallback(function () {
84
- if (!ref.current.isValidating) {
85
- subscribe(false);
86
- }
87
- }, [subscribe]);
88
- var submit = React.useCallback(function (event) {
89
- if (event) {
90
- event.preventDefault();
75
+ var snapshot = environment.lookup(operationQueryForm.fragment);
76
+ if (!subscription) {
77
+ subscription = environment.subscribe(snapshot, function (s) {
78
+ return execute(s);
79
+ });
91
80
  }
92
- if (!ref.current.isSubmitting) {
93
- ref.current.isSubmitting = true;
94
- subscribe(true);
81
+ execute(snapshot);
82
+ }
83
+ function submit(event) {
84
+ event && event.preventDefault();
85
+ if (!isSubmitting) {
86
+ isSubmitting = true;
87
+ validate();
95
88
  }
96
- }, [subscribe]);
97
- var result = React.useMemo(function () {
98
- return {
99
- submit: submit,
100
- validate: validate,
101
- reset: reset
89
+ }
90
+ function subscribe() {
91
+ var disposeRetain = environment.retain(operationQueryForm).dispose;
92
+ return function () {
93
+ dispose();
94
+ disposeRetain();
102
95
  };
103
- }, [submit, validate, reset]);
104
- return result;
96
+ }
97
+ var result = {
98
+ submit: submit,
99
+ validate: validate,
100
+ reset: reset
101
+ };
102
+ function getData() {
103
+ return result;
104
+ }
105
+ return {
106
+ subscribe: subscribe,
107
+ getData: getData
108
+ };
109
+ }
110
+ export var useFormSubmit = function (_a) {
111
+ var onSubmit = _a.onSubmit;
112
+ var environment = useStore();
113
+ var resolver = React.useMemo(function () {
114
+ return logicSubmit(environment, onSubmit);
115
+ }, [environment, onSubmit]);
116
+ React.useEffect(function () {
117
+ return resolver.subscribe();
118
+ }, [resolver]);
119
+ return resolver.getData();
105
120
  };
@@ -14,6 +14,6 @@ export function useFormValue(key) {
14
14
  return environment.subscribe(snapshot, function (s) {
15
15
  setData(s.data);
16
16
  }).dispose;
17
- }, [environment, snapshot, setData]);
17
+ }, [environment, snapshot]);
18
18
  return data;
19
19
  }
@@ -22,6 +22,7 @@ export declare class RelayRecordProxy implements RecordProxy {
22
22
  constructor(source: any, mutator: any, dataID: any);
23
23
  getDataID(): string;
24
24
  setValue(value: any, name: string): this;
25
+ getValue(name: any): any;
25
26
  setLinkedRecord(record: RecordProxy, name: string): this;
26
27
  getLinkedRecords(name: string): Array<RecordProxy | null | undefined> | null | undefined;
27
28
  setLinkedRecords(records: any, name: string): RecordProxy;
@@ -33,6 +33,9 @@ var RelayRecordProxy = /** @class */function () {
33
33
  this._mutator.setValue(this._dataID, name, value);
34
34
  return this;
35
35
  };
36
+ RelayRecordProxy.prototype.getValue = function (name) {
37
+ return this._mutator.getValue(this._dataID, name);
38
+ };
36
39
  RelayRecordProxy.prototype.setLinkedRecord = function (record, name) {
37
40
  var linkedID = record.getDataID();
38
41
  this._mutator.setLinkedRecordID(this._dataID, name, linkedID);
@@ -29,6 +29,7 @@ export declare class RelayRecordSourceMutator {
29
29
  create(dataID: any): void;
30
30
  delete(dataID: any): void;
31
31
  getStatus(dataID: any): "EXISTENT" | "NONEXISTENT" | "UNKNOWN";
32
+ getValue(dataID: any, storageKey: string): any;
32
33
  setValue(dataID: any, storageKey: string, value: any): void;
33
34
  setLinkedRecordID(dataID: any, storageKey: any, linkedID: any): void;
34
35
  getLinkedRecordIDs(dataID: any, storageKey: string): any;
@@ -50,6 +50,19 @@ var RelayRecordSourceMutator = /** @class */function () {
50
50
  RelayRecordSourceMutator.prototype.getStatus = function (dataID) {
51
51
  return this._sink.has(dataID) ? this._sink.getStatus(dataID) : this._base.getStatus(dataID);
52
52
  };
53
+ RelayRecordSourceMutator.prototype.getValue = function (dataID, storageKey) {
54
+ for (var ii = 0; ii < this.__sources.length; ii++) {
55
+ var record = this.__sources[ii].get(dataID);
56
+ if (record) {
57
+ var value = RelayModernRecord_1.RelayModernRecord.getValue(record, storageKey);
58
+ if (value !== undefined) {
59
+ return value;
60
+ }
61
+ } else if (record === null) {
62
+ return null;
63
+ }
64
+ }
65
+ };
53
66
  RelayRecordSourceMutator.prototype.setValue = function (dataID, storageKey, value) {
54
67
  var sinkRecord = this._getSinkRecord(dataID);
55
68
  RelayModernRecord_1.RelayModernRecord.setValue(sinkRecord, storageKey, value);
@@ -4,6 +4,7 @@ export declare type Disposable = {
4
4
  };
5
5
  export interface RecordProxy {
6
6
  getDataID(): string;
7
+ getValue(name: string): any;
7
8
  getLinkedRecords(name: string): Array<RecordProxy | null | undefined> | null | undefined;
8
9
  setLinkedRecord(record: RecordProxy, name: string): RecordProxy;
9
10
  setLinkedRecords(records: Array<RecordProxy>, name: string): RecordProxy;
@@ -1,12 +1,14 @@
1
1
  export declare type QueryErrorsData = {
2
2
  readonly form: {
3
- readonly entries: ReadonlyArray<{
4
- readonly check: string | null;
3
+ readonly errors: ReadonlyArray<{
4
+ readonly check: number | null;
5
5
  readonly error: string | null;
6
6
  readonly id: string;
7
7
  readonly key: string;
8
+ readonly label: string | null;
8
9
  } | null> | null;
9
10
  readonly isSubmitting: boolean | null;
11
+ readonly isValid: boolean | null;
10
12
  readonly isValidating: boolean | null;
11
13
  } | null;
12
14
  };
@@ -38,7 +40,7 @@ export declare const QueryErrors: {
38
40
  export declare type QueryFieldsData = {
39
41
  readonly form: {
40
42
  readonly entries: ReadonlyArray<{
41
- readonly check: string | null;
43
+ readonly check: number | null;
42
44
  readonly error: string | null;
43
45
  readonly id: string;
44
46
  readonly key: string;
@@ -67,7 +69,7 @@ export declare const QueryFields: {
67
69
  };
68
70
  };
69
71
  export declare type FragmentSetData = {
70
- readonly check: string | null;
72
+ readonly check: number | null;
71
73
  readonly id: string;
72
74
  };
73
75
  export declare const FragmentSet: {
@@ -19,6 +19,9 @@ var error = {
19
19
  var value = {
20
20
  name: 'value'
21
21
  };
22
+ var label = {
23
+ name: 'label'
24
+ };
22
25
  var kindFragment = 'Fragment';
23
26
  exports.QueryErrors = {
24
27
  id: '1',
@@ -35,9 +38,9 @@ exports.QueryErrors = {
35
38
  name: 'isValidating'
36
39
  }, {
37
40
  kind: RelayStoreUtils_1.LINKED_FIELD,
38
- name: 'entries',
41
+ name: 'errors',
39
42
  plural: true,
40
- selections: [id, key, error, check]
43
+ selections: [id, key, error, check, label]
41
44
  }]
42
45
  }] /*: any*/
43
46
  }
@@ -69,5 +72,5 @@ exports.FragmentSet = {
69
72
  exports.FragmentValue = {
70
73
  kind: kindFragment,
71
74
  name: 'fragmentValue',
72
- selections: [id, value, error]
75
+ selections: [id, value, error, label]
73
76
  };