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 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
 
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,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, }: FormSetValueOptions<ValueType>): FormSetValueReturn<ValueType>;
@@ -156,7 +156,7 @@ function logicSetValue(params) {
156
156
  setValidate: setValidate
157
157
  };
158
158
  }
159
- export function useFormSetValue(_a) {
159
+ export function useFormField(_a) {
160
160
  var key = _a.key,
161
161
  initialValue = _a.initialValue,
162
162
  validate = _a.validate,
@@ -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");
@@ -348,7 +348,9 @@ var operationQueryErrorsForm = createOperationDescriptor(QueryErrors);
348
348
  var useFormState = function () {
349
349
  var environment = useStore();
350
350
  var snapshot = React__default["default"].useMemo(function () {
351
- return environment.lookup(operationQueryErrorsForm.fragment);
351
+ var s = environment.lookup(operationQueryErrorsForm.fragment);
352
+ s.seenRecords.add('local:form');
353
+ return s;
352
354
  }, [environment]);
353
355
  var _a = React__default["default"].useState(snapshot.data.form),
354
356
  data = _a[0],
@@ -522,7 +524,7 @@ function logicSetValue(params) {
522
524
  setValidate: setValidate
523
525
  };
524
526
  }
525
- function useFormSetValue(_a) {
527
+ function useFormField(_a) {
526
528
  var key = _a.key,
527
529
  initialValue = _a.initialValue,
528
530
  validate = _a.validate,
@@ -651,7 +653,7 @@ function logicSubmit(environment, onSubmit) {
651
653
  getData: getData
652
654
  };
653
655
  }
654
- var useFormSubmit = function (_a) {
656
+ var useForm = function (_a) {
655
657
  var onSubmit = _a.onSubmit;
656
658
  var environment = useStore();
657
659
  var resolver = React__default["default"].useMemo(function () {
@@ -1513,9 +1515,9 @@ exports.RecordSource = RelayRecordSource;
1513
1515
  exports.Store = RelayModernStore;
1514
1516
  exports.StoreProvider = StoreProvider;
1515
1517
  exports.createStore = createStore;
1516
- exports.useFormSetValue = useFormSetValue;
1518
+ exports.useForm = useForm;
1519
+ exports.useFormField = useFormField;
1517
1520
  exports.useFormState = useFormState;
1518
- exports.useFormSubmit = useFormSubmit;
1519
1521
  exports.useFormValue = useFormValue;
1520
1522
 
1521
1523
  Object.defineProperty(exports, '__esModule', { value: true });