@mapples/form 1.1.0 → 1.1.2
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 +2 -2
- package/dist/components/Form.d.ts +9 -0
- package/dist/components/Form.d.ts.map +1 -1
- package/dist/components/Form.js +16 -7
- package/dist/components/Form.js.map +1 -1
- package/dist/context/FormContext.d.ts.map +1 -1
- package/dist/context/FormContext.js +2 -2
- package/dist/context/FormContext.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useBindFormField.d.ts +3 -6
- package/dist/hooks/useBindFormField.d.ts.map +1 -1
- package/dist/hooks/useBindFormField.js +13 -46
- package/dist/hooks/useBindFormField.js.map +1 -1
- package/dist/hooks/{useFormContext.d.ts → useForm.d.ts} +4 -4
- package/dist/hooks/useForm.d.ts.map +1 -0
- package/dist/hooks/{useFormContext.js → useForm.js} +4 -4
- package/dist/hooks/useForm.js.map +1 -0
- package/dist/hooks/useFormArrayField.d.ts +7 -6
- package/dist/hooks/useFormArrayField.d.ts.map +1 -1
- package/dist/hooks/useFormArrayField.js +13 -17
- package/dist/hooks/useFormArrayField.js.map +1 -1
- package/dist/hooks/useFormField.d.ts +2 -4
- package/dist/hooks/useFormField.d.ts.map +1 -1
- package/dist/hooks/useFormField.js +7 -37
- package/dist/hooks/useFormField.js.map +1 -1
- package/dist/hooks/useFormFieldToggle.d.ts.map +1 -1
- package/dist/hooks/useFormFieldToggle.js +3 -7
- package/dist/hooks/useFormFieldToggle.js.map +1 -1
- package/dist/hooks/useFormHelper.d.ts +20 -0
- package/dist/hooks/useFormHelper.d.ts.map +1 -0
- package/dist/hooks/useFormHelper.js +33 -0
- package/dist/hooks/useFormHelper.js.map +1 -0
- package/dist/hooks/useFormHistory.js +3 -3
- package/dist/hooks/useFormHistory.js.map +1 -1
- package/dist/hooks/useFormState.d.ts.map +1 -1
- package/dist/hooks/useFormState.js +4 -7
- package/dist/hooks/useFormState.js.map +1 -1
- package/dist/hooks/useFormSubmit.d.ts +3 -2
- package/dist/hooks/useFormSubmit.d.ts.map +1 -1
- package/dist/hooks/useFormSubmit.js +5 -4
- package/dist/hooks/useFormSubmit.js.map +1 -1
- package/dist/hooks/useFormValue.d.ts.map +1 -1
- package/dist/hooks/useFormValue.js +3 -6
- package/dist/hooks/useFormValue.js.map +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/state/index.d.ts +2 -2
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +3 -2
- package/dist/state/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -3
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/hooks/useFormContext.d.ts.map +0 -1
- package/dist/hooks/useFormContext.js.map +0 -1
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ The main form component that provides form context to its children.
|
|
|
109
109
|
|
|
110
110
|
### Hooks
|
|
111
111
|
|
|
112
|
-
#### `
|
|
112
|
+
#### `useForm()`
|
|
113
113
|
|
|
114
114
|
Access the form context containing form state and methods.
|
|
115
115
|
|
|
@@ -122,7 +122,7 @@ const {
|
|
|
122
122
|
validate,
|
|
123
123
|
touch,
|
|
124
124
|
touched,
|
|
125
|
-
} =
|
|
125
|
+
} = useForm();
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
#### `useFormField<T>(fieldPath, fallbackValue?, subscribe?)`
|
|
@@ -6,6 +6,15 @@ import { FormProps } from '../types';
|
|
|
6
6
|
*
|
|
7
7
|
* @template T - The type of the form data object
|
|
8
8
|
* @param props - Form component props
|
|
9
|
+
* @param props.children - Child components that will have access to the form context
|
|
10
|
+
* @param props.initialValues - Initial values for the form fields
|
|
11
|
+
* @param props.validationSchema - Optional Yup validation schema
|
|
12
|
+
* @param props.onSubmit - Callback invoked with form values after successful validation
|
|
13
|
+
* @param props.ref - Optional ref to access the FormState instance directly
|
|
14
|
+
* @param props.historyItems - Number of history states to keep for undo/redo (0 to disable)
|
|
15
|
+
* @param props.historyItemThrottle - Save a history entry every Nth change
|
|
16
|
+
* @param props.filterHistoryKeys - Field paths to exclude from history tracking
|
|
17
|
+
* @param props.onChange - Callback invoked whenever any form value changes
|
|
9
18
|
* @returns JSX element that provides form context to children
|
|
10
19
|
*
|
|
11
20
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,QAAA,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,EAAE,+HAU7B,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,gCAoGjC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/dist/components/Form.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useImperativeHandle,
|
|
1
|
+
import { useCallback, useEffect, useImperativeHandle, useState, } from 'react';
|
|
2
2
|
import { mapValues } from 'lodash';
|
|
3
3
|
import { FormContextProvider } from '../context';
|
|
4
4
|
import FormState from '../state';
|
|
@@ -8,6 +8,15 @@ import FormState from '../state';
|
|
|
8
8
|
*
|
|
9
9
|
* @template T - The type of the form data object
|
|
10
10
|
* @param props - Form component props
|
|
11
|
+
* @param props.children - Child components that will have access to the form context
|
|
12
|
+
* @param props.initialValues - Initial values for the form fields
|
|
13
|
+
* @param props.validationSchema - Optional Yup validation schema
|
|
14
|
+
* @param props.onSubmit - Callback invoked with form values after successful validation
|
|
15
|
+
* @param props.ref - Optional ref to access the FormState instance directly
|
|
16
|
+
* @param props.historyItems - Number of history states to keep for undo/redo (0 to disable)
|
|
17
|
+
* @param props.historyItemThrottle - Save a history entry every Nth change
|
|
18
|
+
* @param props.filterHistoryKeys - Field paths to exclude from history tracking
|
|
19
|
+
* @param props.onChange - Callback invoked whenever any form value changes
|
|
11
20
|
* @returns JSX element that provides form context to children
|
|
12
21
|
*
|
|
13
22
|
* @example
|
|
@@ -35,11 +44,15 @@ import FormState from '../state';
|
|
|
35
44
|
* @public
|
|
36
45
|
*/
|
|
37
46
|
const Form = ({ children, initialValues, validationSchema, onSubmit, ref, historyItems, filterHistoryKeys, historyItemThrottle, onChange, }) => {
|
|
38
|
-
const [initialized, setInitialized] = useState(false);
|
|
39
47
|
const [touched, setTouched] = useState({});
|
|
40
48
|
const [submitting, setSubmitting] = useState(false);
|
|
41
49
|
const [validationErrors, setValidationErrors] = useState(null);
|
|
42
|
-
|
|
50
|
+
// Lazy state init creates the FormState exactly once and keeps the same
|
|
51
|
+
// instance for the component's lifetime. Unlike useMemo, it never re-creates
|
|
52
|
+
// when initialValues/schema change identity (e.g. inline object literals on
|
|
53
|
+
// every parent render), which would otherwise wipe edited values back to the
|
|
54
|
+
// initial state. We never call the setter, so this never triggers a re-render.
|
|
55
|
+
const [form] = useState(() => new FormState(initialValues, validationSchema, historyItems, historyItemThrottle, filterHistoryKeys));
|
|
43
56
|
useEffect(() => {
|
|
44
57
|
if (!onChange)
|
|
45
58
|
return;
|
|
@@ -53,9 +66,6 @@ const Form = ({ children, initialValues, validationSchema, onSubmit, ref, histor
|
|
|
53
66
|
useImperativeHandle(ref, () => {
|
|
54
67
|
return form;
|
|
55
68
|
});
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
form.setValues(initialValues, setInitialized);
|
|
58
|
-
}, [form, initialValues]);
|
|
59
69
|
const setFormTouched = useCallback(() => {
|
|
60
70
|
setTouched(mapValues(initialValues, () => true));
|
|
61
71
|
}, [initialValues]);
|
|
@@ -104,7 +114,6 @@ const Form = ({ children, initialValues, validationSchema, onSubmit, ref, histor
|
|
|
104
114
|
validationErrors,
|
|
105
115
|
validate,
|
|
106
116
|
touch,
|
|
107
|
-
initialized,
|
|
108
117
|
}}>
|
|
109
118
|
{children}
|
|
110
119
|
</FormContextProvider>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"Form.js","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,SAAS,MAAM,UAAU,CAAC;AAGjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,IAAI,GAAG,CAAmB,EAC9B,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,GAAG,EACH,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,GACwB,EAAE,EAAE;IACpC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CACpC,EAA8B,CAC/B,CAAC;IAEF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAC7D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAG9C,IAAI,CAAC,CAAC;IAEhB,wEAAwE;IACxE,6EAA6E;IAC7E,4E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S,EAAE,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;gBAAS,CAAC;YACT,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;IAErC,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,mBAAmB,CAAC,MAA2C,CAAC,CAAC;QACnE,CAAC;IACH,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,SAAiB,EAAE,EAAE;QAC9C,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACpB,GAAG,IAAI;YACP,CAAC,SAAS,CAAC,EAAE,IAAI;SAClB,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,CAAC,mBAAmB,CAClB,KAAK,CAAC,CAAC;YACL,OAAO;YACP,IAAI,EAAE,IAAyB;YAC/B,UAAU,EAAE,YAAY;YACxB,UAAU;YACV,gBAAgB;YAChB,QAAQ;YACR,KAAK;SACN,CAAC,CAEF;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,mBAAmB,CAAC,CACvB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormContext.d.ts","sourceRoot":"","sources":["../../src/context/FormContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormContext.d.ts","sourceRoot":"","sources":["../../src/context/FormContext.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;GAMG;AACH,QAAA,MAAM,WAAW,kDAQf,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,mDAAuB,CAAC;AAExD,eAAe,WAAW,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
import { noop } from 'lodash';
|
|
3
|
+
import FormState from '../state';
|
|
3
4
|
/**
|
|
4
5
|
* React Context for form state management.
|
|
5
6
|
* This context provides form state, validation errors, submission state,
|
|
@@ -8,14 +9,13 @@ import { noop } from 'lodash';
|
|
|
8
9
|
* @public
|
|
9
10
|
*/
|
|
10
11
|
const FormContext = createContext({
|
|
11
|
-
form:
|
|
12
|
+
form: new FormState({}),
|
|
12
13
|
validationErrors: null,
|
|
13
14
|
submitting: true,
|
|
14
15
|
submitForm: noop,
|
|
15
16
|
validate: noop,
|
|
16
17
|
touch: noop,
|
|
17
18
|
touched: {},
|
|
18
|
-
initialized: false,
|
|
19
19
|
});
|
|
20
20
|
/**
|
|
21
21
|
* Provider component for the FormContext.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormContext.js","sourceRoot":"","sources":["../../src/context/FormContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"FormContext.js","sourceRoot":"","sources":["../../src/context/FormContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,SAAS,MAAM,UAAU,CAAC;AAGjC;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,aAAa,CAA0B;IACzD,IAAI,EAAE,IAAI,SAAS,CAAS,EAAE,CAAC;IAC/B,gBAAgB,EAAE,IAAI;IACtB,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,EAAE;CACZ,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC,QAAQ,CAAC;AAExD,eAAe,WAAW,CAAC"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import useBindFormField from './useBindFormField';
|
|
2
|
+
import useForm from './useForm';
|
|
2
3
|
import useFormArrayField from './useFormArrayField';
|
|
3
|
-
import useFormContext from './useFormContext';
|
|
4
4
|
import useFormField from './useFormField';
|
|
5
5
|
import useFormFieldToggle from './useFormFieldToggle';
|
|
6
6
|
import useFormHistory from './useFormHistory';
|
|
7
7
|
import useFormState from './useFormState';
|
|
8
8
|
import useFormSubmit from './useFormSubmit';
|
|
9
9
|
import useFormValue from './useFormValue';
|
|
10
|
-
export { useFormField, useFormState, useFormValue,
|
|
10
|
+
export { useFormField, useFormState, useFormValue, useForm, useFormArrayField, useFormFieldToggle, useFormHistory, useFormSubmit, useBindFormField, };
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,GACjB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import useBindFormField from './useBindFormField';
|
|
2
|
+
import useForm from './useForm';
|
|
2
3
|
import useFormArrayField from './useFormArrayField';
|
|
3
|
-
import useFormContext from './useFormContext';
|
|
4
4
|
import useFormField from './useFormField';
|
|
5
5
|
import useFormFieldToggle from './useFormFieldToggle';
|
|
6
6
|
import useFormHistory from './useFormHistory';
|
|
7
7
|
import useFormState from './useFormState';
|
|
8
8
|
import useFormSubmit from './useFormSubmit';
|
|
9
9
|
import useFormValue from './useFormValue';
|
|
10
|
-
export { useFormField, useFormState, useFormValue,
|
|
10
|
+
export { useFormField, useFormState, useFormValue, useForm, useFormArrayField, useFormFieldToggle, useFormHistory, useFormSubmit, useBindFormField, };
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,GACjB,CAAC"}
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* @template T - The type of the field value
|
|
7
7
|
* @param fieldPath - Primary dot notation path to the field
|
|
8
8
|
* @param fallBackPath - Optional fallback path to synchronize with
|
|
9
|
-
* @param fallbackValue - Default value to use if field is undefined
|
|
10
|
-
* @param subscribe - Whether to subscribe to real-time value changes (default: true)
|
|
11
9
|
* @returns Object containing field value, error state, and control methods
|
|
12
10
|
*
|
|
13
11
|
* @example
|
|
@@ -15,13 +13,12 @@
|
|
|
15
13
|
* const NameField = () => {
|
|
16
14
|
* const { value, error, setValue } = useBindFormField<string>(
|
|
17
15
|
* 'user.name',
|
|
18
|
-
* 'displayName', // Also
|
|
19
|
-
* ''
|
|
16
|
+
* 'displayName', // Also writes to displayName whenever user.name changes
|
|
20
17
|
* );
|
|
21
18
|
*
|
|
22
19
|
* return (
|
|
23
20
|
* <input
|
|
24
|
-
* value={value}
|
|
21
|
+
* value={value ?? ''}
|
|
25
22
|
* onChange={(e) => setValue(e.target.value)}
|
|
26
23
|
* />
|
|
27
24
|
* );
|
|
@@ -30,7 +27,7 @@
|
|
|
30
27
|
*
|
|
31
28
|
* @public
|
|
32
29
|
*/
|
|
33
|
-
declare const useBindFormField: <T>(fieldPath: string, fallBackPath?: string
|
|
30
|
+
declare const useBindFormField: <T>(fieldPath: string, fallBackPath?: string) => {
|
|
34
31
|
value: T | undefined;
|
|
35
32
|
error: string | undefined;
|
|
36
33
|
errors: import("yup").ValidationError[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBindFormField.d.ts","sourceRoot":"","sources":["../../src/hooks/useBindFormField.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBindFormField.d.ts","sourceRoot":"","sources":["../../src/hooks/useBindFormField.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,QAAA,MAAM,gBAAgB,GAAI,CAAC,EAAE,WAAW,MAAM,EAAE,eAAe,MAAM;;;;;;;yBAoBtD,CAAC;CAef,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { useCallback,
|
|
2
|
-
import
|
|
3
|
-
import FormContext from '../context';
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import useFormHelper from './useFormHelper';
|
|
4
3
|
/**
|
|
5
4
|
* Hook to bind a form field with optional fallback path synchronization.
|
|
6
5
|
* This hook is similar to useFormField but allows binding a field to a fallback path,
|
|
@@ -9,8 +8,6 @@ import FormContext from '../context';
|
|
|
9
8
|
* @template T - The type of the field value
|
|
10
9
|
* @param fieldPath - Primary dot notation path to the field
|
|
11
10
|
* @param fallBackPath - Optional fallback path to synchronize with
|
|
12
|
-
* @param fallbackValue - Default value to use if field is undefined
|
|
13
|
-
* @param subscribe - Whether to subscribe to real-time value changes (default: true)
|
|
14
11
|
* @returns Object containing field value, error state, and control methods
|
|
15
12
|
*
|
|
16
13
|
* @example
|
|
@@ -18,13 +15,12 @@ import FormContext from '../context';
|
|
|
18
15
|
* const NameField = () => {
|
|
19
16
|
* const { value, error, setValue } = useBindFormField<string>(
|
|
20
17
|
* 'user.name',
|
|
21
|
-
* 'displayName', // Also
|
|
22
|
-
* ''
|
|
18
|
+
* 'displayName', // Also writes to displayName whenever user.name changes
|
|
23
19
|
* );
|
|
24
20
|
*
|
|
25
21
|
* return (
|
|
26
22
|
* <input
|
|
27
|
-
* value={value}
|
|
23
|
+
* value={value ?? ''}
|
|
28
24
|
* onChange={(e) => setValue(e.target.value)}
|
|
29
25
|
* />
|
|
30
26
|
* );
|
|
@@ -33,52 +29,23 @@ import FormContext from '../context';
|
|
|
33
29
|
*
|
|
34
30
|
* @public
|
|
35
31
|
*/
|
|
36
|
-
const useBindFormField = (fieldPath, fallBackPath
|
|
37
|
-
const {
|
|
38
|
-
const [value, setValue] = useState(
|
|
39
|
-
const errors = validationErrors?.[fieldPath];
|
|
40
|
-
const error = useMemo(() => {
|
|
41
|
-
return first(errors)?.message;
|
|
42
|
-
}, [errors]);
|
|
43
|
-
const isTouched = useMemo(() => {
|
|
44
|
-
return !!touched[fieldPath];
|
|
45
|
-
}, [fieldPath, touched]);
|
|
32
|
+
const useBindFormField = (fieldPath, fallBackPath) => {
|
|
33
|
+
const { error, form, isTouched, errors, touch, validate } = useFormHelper(fieldPath);
|
|
34
|
+
const [value, setValue] = useState();
|
|
46
35
|
useEffect(() => {
|
|
47
|
-
|
|
48
|
-
const value = form?.getValue(fieldPath) || fallbackValue;
|
|
36
|
+
const unsubscribe = form?.subscribeOnChange((v) => {
|
|
49
37
|
if (fallBackPath) {
|
|
50
|
-
form?.setValue(fallBackPath,
|
|
38
|
+
form?.setValue(fallBackPath, v);
|
|
51
39
|
}
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
}, [fallBackPath, fallbackValue, fieldPath, form]);
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (!subscribe) {
|
|
57
|
-
const unsubscribe = form?.subscribeOnHistoryChange(() => {
|
|
58
|
-
const newValue = form?.getValue(fieldPath) || fallbackValue;
|
|
59
|
-
if (fallBackPath) {
|
|
60
|
-
form?.setValue(fallBackPath, newValue);
|
|
61
|
-
}
|
|
62
|
-
setValue(newValue);
|
|
63
|
-
});
|
|
64
|
-
return () => {
|
|
65
|
-
unsubscribe?.();
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const unsubscribe = form?.subscribeOnChange(setValue, fieldPath);
|
|
40
|
+
setValue(v);
|
|
41
|
+
}, fieldPath);
|
|
69
42
|
return () => {
|
|
70
43
|
unsubscribe?.();
|
|
71
44
|
};
|
|
72
|
-
}, [fallBackPath,
|
|
45
|
+
}, [fallBackPath, fieldPath, form]);
|
|
73
46
|
const handleSetValue = useCallback((newValue) => {
|
|
74
47
|
form?.setValue(fieldPath, newValue);
|
|
75
|
-
|
|
76
|
-
setValue(newValue);
|
|
77
|
-
if (fallBackPath) {
|
|
78
|
-
form?.setValue(fallBackPath, newValue);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}, [fallBackPath, fieldPath, form, subscribe]);
|
|
48
|
+
}, [fieldPath, form]);
|
|
82
49
|
return {
|
|
83
50
|
value,
|
|
84
51
|
error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBindFormField.js","sourceRoot":"","sources":["../../src/hooks/useBindFormField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"useBindFormField.js","sourceRoot":"","sources":["../../src/hooks/useBindFormField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,gBAAgB,GAAG,CAAI,SAAiB,EAAE,YAAqB,EAAE,EAAE;IACvE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GACvD,aAAa,CAAC,SAAS,CAAC,CAAC;IAE3B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAiB,CAAC;IAEpD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAG,IAAI,EAAE,iBAAiB,CAAI,CAAC,CAAC,EAAE,EAAE;YACnD,IAAI,YAAY,EAAE,CAAC;gBACjB,IAAI,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;YAClC,CAAC;YACD,QAAQ,CAAC,CAAC,CAAC,CAAC;QACd,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,OAAO,GAAG,EAAE;YACV,WAAW,EAAE,EAAE,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpC,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,QAAW,EAAE,EAAE;QACd,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC,EACD,CAAC,SAAS,EAAE,IAAI,CAAC,CAClB,CAAC;IAEF,OAAO;QACL,KAAK;QACL,KAAK;QACL,MAAM;QACN,SAAS;QACT,QAAQ;QACR,KAAK;QACL,QAAQ,EAAE,cAAc;KACzB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @example
|
|
9
9
|
* ```tsx
|
|
10
10
|
* const MyComponent = () => {
|
|
11
|
-
* const { form, submitting, submitForm, validationErrors } =
|
|
11
|
+
* const { form, submitting, submitForm, validationErrors } = useForm();
|
|
12
12
|
*
|
|
13
13
|
* return (
|
|
14
14
|
* <div>
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
|
-
declare const
|
|
27
|
-
export default
|
|
28
|
-
//# sourceMappingURL=
|
|
26
|
+
declare const useForm: () => import("..").FormContextType<object>;
|
|
27
|
+
export default useForm;
|
|
28
|
+
//# sourceMappingURL=useForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,QAAA,MAAM,OAAO,4CAEZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -10,7 +10,7 @@ import FormContext from '../context';
|
|
|
10
10
|
* @example
|
|
11
11
|
* ```tsx
|
|
12
12
|
* const MyComponent = () => {
|
|
13
|
-
* const { form, submitting, submitForm, validationErrors } =
|
|
13
|
+
* const { form, submitting, submitForm, validationErrors } = useForm();
|
|
14
14
|
*
|
|
15
15
|
* return (
|
|
16
16
|
* <div>
|
|
@@ -25,8 +25,8 @@ import FormContext from '../context';
|
|
|
25
25
|
*
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
|
-
const
|
|
28
|
+
const useForm = () => {
|
|
29
29
|
return useContext(FormContext);
|
|
30
30
|
};
|
|
31
|
-
export default
|
|
32
|
-
//# sourceMappingURL=
|
|
31
|
+
export default useForm;
|
|
32
|
+
//# sourceMappingURL=useForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.js","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,WAAW,MAAM,YAAY,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,GAAG,GAAG,EAAE;IACnB,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook to manage array fields with specialized array manipulation methods.
|
|
3
3
|
* This hook provides methods to add, remove, and manipulate array items in a form field.
|
|
4
|
+
* Changes are reflected reactively via history-change subscriptions on the underlying FormState.
|
|
4
5
|
*
|
|
5
6
|
* @template T - The type of items in the array
|
|
6
|
-
* @param fieldPath - Dot notation path to the array field
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
7
|
+
* @param fieldPath - Dot notation path to the array field (e.g., `'tags'`)
|
|
8
|
+
* @returns Object containing the current array value and an `api` object with mutation helpers:
|
|
9
|
+
* `push`, `dropLeft`, `dropRight`, `remove`, `paste`, and `toggle`
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
* ```tsx
|
|
12
13
|
* const TagsField = () => {
|
|
13
|
-
* const { value, api } = useFormArrayField<string>('tags'
|
|
14
|
+
* const { value, api } = useFormArrayField<string>('tags');
|
|
14
15
|
*
|
|
15
16
|
* return (
|
|
16
17
|
* <div>
|
|
17
|
-
* {value
|
|
18
|
+
* {value?.map((tag, index) => (
|
|
18
19
|
* <div key={index}>
|
|
19
20
|
* {tag}
|
|
20
21
|
* <button onClick={() => api.remove(index)}>Remove</button>
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
*
|
|
29
30
|
* @public
|
|
30
31
|
*/
|
|
31
|
-
declare const useFormArrayField: <T>(fieldPath: string
|
|
32
|
+
declare const useFormArrayField: <T>(fieldPath: string) => {
|
|
32
33
|
value: T[] | undefined;
|
|
33
34
|
api: {
|
|
34
35
|
push: (item: T) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormArrayField.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormArrayField.ts"],"names":[],"mappings":"AAMA
|
|
1
|
+
{"version":3,"file":"useFormArrayField.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormArrayField.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,QAAA,MAAM,iBAAiB,GAAI,CAAC,EAAE,WAAW,MAAM;;;qBAgBpC,CAAC;2BAYC,MAAM;4BAWN,MAAM;wBAWP,MAAM;sBAYP,CAAC,SAAS,MAAM;uBAYhB,CAAC;;CAsBX,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { useCallback,
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { cloneDeep, drop, dropRight, indexOf } from 'lodash';
|
|
3
|
-
import
|
|
3
|
+
import useForm from './useForm';
|
|
4
4
|
/**
|
|
5
5
|
* Hook to manage array fields with specialized array manipulation methods.
|
|
6
6
|
* This hook provides methods to add, remove, and manipulate array items in a form field.
|
|
7
|
+
* Changes are reflected reactively via history-change subscriptions on the underlying FormState.
|
|
7
8
|
*
|
|
8
9
|
* @template T - The type of items in the array
|
|
9
|
-
* @param fieldPath - Dot notation path to the array field
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
10
|
+
* @param fieldPath - Dot notation path to the array field (e.g., `'tags'`)
|
|
11
|
+
* @returns Object containing the current array value and an `api` object with mutation helpers:
|
|
12
|
+
* `push`, `dropLeft`, `dropRight`, `remove`, `paste`, and `toggle`
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```tsx
|
|
15
16
|
* const TagsField = () => {
|
|
16
|
-
* const { value, api } = useFormArrayField<string>('tags'
|
|
17
|
+
* const { value, api } = useFormArrayField<string>('tags');
|
|
17
18
|
*
|
|
18
19
|
* return (
|
|
19
20
|
* <div>
|
|
20
|
-
* {value
|
|
21
|
+
* {value?.map((tag, index) => (
|
|
21
22
|
* <div key={index}>
|
|
22
23
|
* {tag}
|
|
23
24
|
* <button onClick={() => api.remove(index)}>Remove</button>
|
|
@@ -31,22 +32,17 @@ import FormContext from '../context';
|
|
|
31
32
|
*
|
|
32
33
|
* @public
|
|
33
34
|
*/
|
|
34
|
-
const useFormArrayField = (fieldPath
|
|
35
|
-
const { form
|
|
35
|
+
const useFormArrayField = (fieldPath) => {
|
|
36
|
+
const { form } = useForm();
|
|
36
37
|
const [value, setValue] = useState();
|
|
37
38
|
useEffect(() => {
|
|
38
39
|
const unsubscribe = form?.subscribeOnHistoryChange(() => {
|
|
39
|
-
setValue(form?.getValue(fieldPath)
|
|
40
|
+
setValue(form?.getValue(fieldPath));
|
|
40
41
|
});
|
|
41
42
|
return () => {
|
|
42
43
|
unsubscribe?.();
|
|
43
44
|
};
|
|
44
|
-
}, [
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (initialized) {
|
|
47
|
-
setValue(form?.getValue(fieldPath));
|
|
48
|
-
}
|
|
49
|
-
}, [fieldPath, form, initialized]);
|
|
45
|
+
}, [fieldPath, form]);
|
|
50
46
|
const fieldPush = useCallback((item) => {
|
|
51
47
|
setValue((prev) => {
|
|
52
48
|
const valueClone = cloneDeep(prev) || [];
|
|
@@ -95,7 +91,7 @@ const useFormArrayField = (fieldPath, fallbackValue) => {
|
|
|
95
91
|
}
|
|
96
92
|
}, [fieldPush, fieldRemove, value]);
|
|
97
93
|
return {
|
|
98
|
-
value: value
|
|
94
|
+
value: value,
|
|
99
95
|
api: {
|
|
100
96
|
push: fieldPush,
|
|
101
97
|
dropLeft: fieldDropLeft,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormArrayField.js","sourceRoot":"","sources":["../../src/hooks/useFormArrayField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"useFormArrayField.js","sourceRoot":"","sources":["../../src/hooks/useFormArrayField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE7D,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,iBAAiB,GAAG,CAAI,SAAiB,EAAE,EAAE;IACjD,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAmB,CAAC;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CAAC,CAAC;QACzB,CAAC;IACH,CAAC,EACD,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,CAChC,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,GAAG,EAAE;YACH,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,aAAa;YACvB,SAAS,EAAE,cAAc;YACzB,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,UAAU;YACjB,MAAM,EAAE,WAAW;SACpB;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -5,14 +5,12 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @template T - The type of the field value
|
|
7
7
|
* @param fieldPath - Dot notation path to the field (e.g., 'user.name')
|
|
8
|
-
* @param fallbackValue - Default value to use if field is undefined
|
|
9
|
-
* @param subscribe - Whether to subscribe to real-time value changes (default: true)
|
|
10
8
|
* @returns Object containing field value, error state, and control methods
|
|
11
9
|
*
|
|
12
10
|
* @example
|
|
13
11
|
* ```tsx
|
|
14
12
|
* const NameField = () => {
|
|
15
|
-
* const { value, error, isTouched, setValue, touch } = useFormField<string>('name'
|
|
13
|
+
* const { value, error, isTouched, setValue, touch } = useFormField<string>('name');
|
|
16
14
|
*
|
|
17
15
|
* return (
|
|
18
16
|
* <div>
|
|
@@ -29,7 +27,7 @@
|
|
|
29
27
|
*
|
|
30
28
|
* @public
|
|
31
29
|
*/
|
|
32
|
-
declare const useFormField: <T>(fieldPath: string
|
|
30
|
+
declare const useFormField: <T>(fieldPath: string) => {
|
|
33
31
|
value: T | undefined;
|
|
34
32
|
error: string | undefined;
|
|
35
33
|
errors: import("yup").ValidationError[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormField.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormField.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFormField.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormField.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,QAAA,MAAM,YAAY,GAAI,CAAC,EAAE,WAAW,MAAM;;;;;;;yBAe3B,CAAC;CAef,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { useCallback,
|
|
2
|
-
import
|
|
3
|
-
import FormContext from '../context';
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import useFormHelper from './useFormHelper';
|
|
4
3
|
/**
|
|
5
4
|
* Hook to manage a single form field with value, validation, and touch state.
|
|
6
5
|
* This hook provides reactive access to a form field's value, errors, and touch state,
|
|
@@ -8,14 +7,12 @@ import FormContext from '../context';
|
|
|
8
7
|
*
|
|
9
8
|
* @template T - The type of the field value
|
|
10
9
|
* @param fieldPath - Dot notation path to the field (e.g., 'user.name')
|
|
11
|
-
* @param fallbackValue - Default value to use if field is undefined
|
|
12
|
-
* @param subscribe - Whether to subscribe to real-time value changes (default: true)
|
|
13
10
|
* @returns Object containing field value, error state, and control methods
|
|
14
11
|
*
|
|
15
12
|
* @example
|
|
16
13
|
* ```tsx
|
|
17
14
|
* const NameField = () => {
|
|
18
|
-
* const { value, error, isTouched, setValue, touch } = useFormField<string>('name'
|
|
15
|
+
* const { value, error, isTouched, setValue, touch } = useFormField<string>('name');
|
|
19
16
|
*
|
|
20
17
|
* return (
|
|
21
18
|
* <div>
|
|
@@ -32,45 +29,18 @@ import FormContext from '../context';
|
|
|
32
29
|
*
|
|
33
30
|
* @public
|
|
34
31
|
*/
|
|
35
|
-
const useFormField = (fieldPath
|
|
36
|
-
const {
|
|
32
|
+
const useFormField = (fieldPath) => {
|
|
33
|
+
const { error, form, isTouched, errors, touch, validate } = useFormHelper(fieldPath);
|
|
37
34
|
const [value, setValue] = useState();
|
|
38
|
-
const fallBackValueRef = useRef(fallbackValue);
|
|
39
35
|
useEffect(() => {
|
|
40
|
-
fallBackValueRef.current = fallbackValue;
|
|
41
|
-
}, [fallbackValue]);
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (initialized && !subscribe) {
|
|
44
|
-
setValue(form?.getValue(fieldPath) || fallBackValueRef.current);
|
|
45
|
-
}
|
|
46
|
-
}, [fieldPath, form, initialized, subscribe]);
|
|
47
|
-
const errors = validationErrors?.[fieldPath];
|
|
48
|
-
const error = useMemo(() => {
|
|
49
|
-
return first(errors)?.message;
|
|
50
|
-
}, [errors]);
|
|
51
|
-
const isTouched = useMemo(() => {
|
|
52
|
-
return !!touched[fieldPath];
|
|
53
|
-
}, [fieldPath, touched]);
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (!subscribe) {
|
|
56
|
-
const unsubscribe = form?.subscribeOnHistoryChange(() => {
|
|
57
|
-
setValue(form?.getValue(fieldPath) || fallBackValueRef.current);
|
|
58
|
-
});
|
|
59
|
-
return () => {
|
|
60
|
-
unsubscribe?.();
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
36
|
const unsubscribe = form?.subscribeOnChange(setValue, fieldPath);
|
|
64
37
|
return () => {
|
|
65
38
|
unsubscribe?.();
|
|
66
39
|
};
|
|
67
|
-
}, [fieldPath, form
|
|
40
|
+
}, [fieldPath, form]);
|
|
68
41
|
const handleSetValue = useCallback((newValue) => {
|
|
69
42
|
form?.setValue(fieldPath, newValue);
|
|
70
|
-
|
|
71
|
-
setValue(newValue);
|
|
72
|
-
}
|
|
73
|
-
}, [fieldPath, form, subscribe]);
|
|
43
|
+
}, [fieldPath, form]);
|
|
74
44
|
return {
|
|
75
45
|
value,
|
|
76
46
|
error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormField.js","sourceRoot":"","sources":["../../src/hooks/useFormField.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useFormField.js","sourceRoot":"","sources":["../../src/hooks/useFormField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,YAAY,GAAG,CAAI,SAAiB,EAAE,EAAE;IAC5C,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GACvD,aAAa,CAAC,SAAS,CAAC,CAAC;IAE3B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAiB,CAAC;IAEpD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAG,IAAI,EAAE,iBAAiB,CAAI,QAAQ,EAAE,SAAS,CAAC,CAAC;QAEpE,OAAO,GAAG,EAAE;YACV,WAAW,EAAE,EAAE,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAEtB,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,QAAW,EAAE,EAAE;QACd,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC,EACD,CAAC,SAAS,EAAE,IAAI,CAAC,CAClB,CAAC;IAEF,OAAO;QACL,KAAK;QACL,KAAK;QACL,MAAM;QACN,SAAS;QACT,QAAQ;QACR,KAAK;QACL,QAAQ,EAAE,cAAc;KACzB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormFieldToggle.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormFieldToggle.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,kBAAkB,GAAI,WAAW,MAAM;;;
|
|
1
|
+
{"version":3,"file":"useFormFieldToggle.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormFieldToggle.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,kBAAkB,GAAI,WAAW,MAAM;;;CAiB5C,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import useForm from './useForm';
|
|
3
3
|
/**
|
|
4
4
|
* Hook to manage boolean toggle fields.
|
|
5
5
|
* This hook provides a simple way to handle boolean fields with toggle functionality.
|
|
@@ -28,12 +28,8 @@ import FormContext from '../context';
|
|
|
28
28
|
* @public
|
|
29
29
|
*/
|
|
30
30
|
const useFormFieldToggle = (fieldPath) => {
|
|
31
|
-
const { form
|
|
31
|
+
const { form } = useForm();
|
|
32
32
|
const [value, setValue] = useState(false);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (initialized)
|
|
35
|
-
setValue(form?.getValue(fieldPath) || false);
|
|
36
|
-
}, [initialized, fieldPath, form]);
|
|
37
33
|
const handleToggleValue = () => {
|
|
38
34
|
setValue((prev) => {
|
|
39
35
|
const nextValue = !prev;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormFieldToggle.js","sourceRoot":"","sources":["../../src/hooks/useFormFieldToggle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useFormFieldToggle.js","sourceRoot":"","sources":["../../src/hooks/useFormFieldToggle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,kBAAkB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC/C,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE1C,MAAM,iBAAiB,GAAG,GAAG,EAAE;QAC7B,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE;YAChB,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC;YACxB,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACrC,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,KAAK;QACL,WAAW,EAAE,iBAAiB;KAC/B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal helper hook that extracts per-field error and touch state from the form context.
|
|
3
|
+
* Used by `useFormField` and `useBindFormField` to avoid duplicating context-selection logic.
|
|
4
|
+
*
|
|
5
|
+
* @param fieldPath - Dot notation path to the field (e.g., `'user.name'`)
|
|
6
|
+
* @returns Object containing the form instance, the first error message, all errors,
|
|
7
|
+
* the touched state flag, and the `validate` / `touch` helpers from the form context
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
declare const useFormHelper: (fieldPath: string) => {
|
|
12
|
+
form: import("..").FormState<object>;
|
|
13
|
+
error: string | undefined;
|
|
14
|
+
errors: import("yup").ValidationError[] | undefined;
|
|
15
|
+
isTouched: boolean;
|
|
16
|
+
validate: () => void;
|
|
17
|
+
touch: (fieldName: string) => void;
|
|
18
|
+
};
|
|
19
|
+
export default useFormHelper;
|
|
20
|
+
//# sourceMappingURL=useFormHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormHelper.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormHelper.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,QAAA,MAAM,aAAa,GAAI,WAAW,MAAM;;;;;;;CAqBvC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { first } from 'lodash';
|
|
3
|
+
import useForm from './useForm';
|
|
4
|
+
/**
|
|
5
|
+
* Internal helper hook that extracts per-field error and touch state from the form context.
|
|
6
|
+
* Used by `useFormField` and `useBindFormField` to avoid duplicating context-selection logic.
|
|
7
|
+
*
|
|
8
|
+
* @param fieldPath - Dot notation path to the field (e.g., `'user.name'`)
|
|
9
|
+
* @returns Object containing the form instance, the first error message, all errors,
|
|
10
|
+
* the touched state flag, and the `validate` / `touch` helpers from the form context
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
const useFormHelper = (fieldPath) => {
|
|
15
|
+
const { form, touched, validationErrors, validate, touch } = useForm();
|
|
16
|
+
const errors = validationErrors?.[fieldPath];
|
|
17
|
+
const error = useMemo(() => {
|
|
18
|
+
return first(errors)?.message;
|
|
19
|
+
}, [errors]);
|
|
20
|
+
const isTouched = useMemo(() => {
|
|
21
|
+
return !!touched[fieldPath];
|
|
22
|
+
}, [fieldPath, touched]);
|
|
23
|
+
return {
|
|
24
|
+
form,
|
|
25
|
+
error,
|
|
26
|
+
errors,
|
|
27
|
+
isTouched,
|
|
28
|
+
validate,
|
|
29
|
+
touch,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export default useFormHelper;
|
|
33
|
+
//# sourceMappingURL=useFormHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormHelper.js","sourceRoot":"","sources":["../../src/hooks/useFormHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;;;;;GASG;AACH,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC1C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC;IAEvE,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC,SAAS,CAAC,CAAC;IAE7C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,OAAO,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAChC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE;QAC7B,OAAO,CAAC,CAAC,OAAO,CAAC,SAAiC,CAAC,CAAC;IACtD,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAEzB,OAAO;QACL,IAAI;QACJ,KAAK;QACL,MAAM;QACN,SAAS;QACT,QAAQ;QACR,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useCallback,
|
|
2
|
-
import
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import useForm from './useForm';
|
|
3
3
|
/**
|
|
4
4
|
* Hook to manage form history for undo/redo functionality.
|
|
5
5
|
* This hook provides methods to navigate through form history and check availability of undo/redo operations.
|
|
@@ -23,7 +23,7 @@ import FormContext from '../context';
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
const useFormHistory = () => {
|
|
26
|
-
const { form } =
|
|
26
|
+
const { form } = useForm();
|
|
27
27
|
const [state, setState] = useState({ canPrev: false, canNext: false });
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
const unsubscribe = form?.subscribeOnChange(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormHistory.js","sourceRoot":"","sources":["../../src/hooks/useFormHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
|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;QACJ,IAAI;QACJ,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormState.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormState.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM;;
|
|
1
|
+
{"version":3,"file":"useFormState.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormState.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM;;wBAgBzB,CAAC;qBAOkB,CAAC,GAAG,SAAS;CAQ5C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useCallback,
|
|
2
|
-
import
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import useForm from './useForm';
|
|
3
3
|
/**
|
|
4
4
|
* Hook to manage the entire form state with reactive values and control methods.
|
|
5
5
|
* This hook provides access to all form values and methods to update them.
|
|
@@ -29,18 +29,15 @@ import FormContext from '../context';
|
|
|
29
29
|
*/
|
|
30
30
|
const useFormState = () => {
|
|
31
31
|
const [values, setFormValues] = useState();
|
|
32
|
-
const { form
|
|
32
|
+
const { form } = useForm();
|
|
33
33
|
useEffect(() => {
|
|
34
|
-
if (initialized) {
|
|
35
|
-
setFormValues(form?.getValues());
|
|
36
|
-
}
|
|
37
34
|
const unsubscribe = form?.subscribeOnChange((values) => {
|
|
38
35
|
setFormValues(values);
|
|
39
36
|
});
|
|
40
37
|
return () => {
|
|
41
38
|
unsubscribe?.();
|
|
42
39
|
};
|
|
43
|
-
}, [form
|
|
40
|
+
}, [form]);
|
|
44
41
|
const setValues = useCallback((values) => {
|
|
45
42
|
form?.setValues(values);
|
|
46
43
|
}, [form]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormState.js","sourceRoot":"","sources":["../../src/hooks/useFormState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"useFormState.js","sourceRoot":"","sources":["../../src/hooks/useFormState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,YAAY,GAAG,GAAqB,EAAE;IAC1C,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,QAAQ,EAAK,CAAC;IAE9C,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAG,IAAI,EAAE,iBAAiB,CAAI,CAAC,MAAM,EAAE,EAAE;YACxD,aAAa,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,WAAW,EAAE,EAAE,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,MAAS,EAAE,EAAE;QACZ,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC,EACD,CAAC,IAAI,CAAC,CACP,CAAC;IAEF,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;QACjC,OAAO,IAAI,EAAE,SAAS,EAAmB,CAAC;IAC5C,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO;QACL,MAAM;QACN,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* @example
|
|
8
8
|
* ```tsx
|
|
9
9
|
* const SubmitButton = () => {
|
|
10
|
-
* const { submitting, submitForm } = useFormSubmit();
|
|
10
|
+
* const { submitting, submitForm, isValid } = useFormSubmit();
|
|
11
11
|
*
|
|
12
12
|
* return (
|
|
13
|
-
* <button onClick={submitForm} disabled={submitting}>
|
|
13
|
+
* <button onClick={submitForm} disabled={submitting || !isValid}>
|
|
14
14
|
* {submitting ? 'Submitting...' : 'Submit'}
|
|
15
15
|
* </button>
|
|
16
16
|
* );
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
declare const useFormSubmit: () => {
|
|
23
23
|
submitting: boolean;
|
|
24
24
|
submitForm: () => void;
|
|
25
|
+
isValid: boolean;
|
|
25
26
|
};
|
|
26
27
|
export default useFormSubmit;
|
|
27
28
|
//# sourceMappingURL=useFormSubmit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormSubmit.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormSubmit.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"useFormSubmit.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormSubmit.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,aAAa;;;;CAQlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import useForm from './useForm';
|
|
2
2
|
/**
|
|
3
3
|
* Hook to access form submission state and submit function.
|
|
4
4
|
* This hook provides the current submission state and the submit function.
|
|
@@ -8,10 +8,10 @@ import useFormContext from './useFormContext';
|
|
|
8
8
|
* @example
|
|
9
9
|
* ```tsx
|
|
10
10
|
* const SubmitButton = () => {
|
|
11
|
-
* const { submitting, submitForm } = useFormSubmit();
|
|
11
|
+
* const { submitting, submitForm, isValid } = useFormSubmit();
|
|
12
12
|
*
|
|
13
13
|
* return (
|
|
14
|
-
* <button onClick={submitForm} disabled={submitting}>
|
|
14
|
+
* <button onClick={submitForm} disabled={submitting || !isValid}>
|
|
15
15
|
* {submitting ? 'Submitting...' : 'Submit'}
|
|
16
16
|
* </button>
|
|
17
17
|
* );
|
|
@@ -21,10 +21,11 @@ import useFormContext from './useFormContext';
|
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
const useFormSubmit = () => {
|
|
24
|
-
const { submitting, submitForm } =
|
|
24
|
+
const { submitting, submitForm, validationErrors } = useForm();
|
|
25
25
|
return {
|
|
26
26
|
submitting,
|
|
27
27
|
submitForm,
|
|
28
|
+
isValid: !validationErrors,
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
export default useFormSubmit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormSubmit.js","sourceRoot":"","sources":["../../src/hooks/useFormSubmit.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useFormSubmit.js","sourceRoot":"","sources":["../../src/hooks/useFormSubmit.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,aAAa,GAAG,GAAG,EAAE;IACzB,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,OAAO,EAAE,CAAC;IAE/D,OAAO;QACL,UAAU;QACV,UAAU;QACV,OAAO,EAAE,CAAC,gBAAgB;KAC3B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormValue.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormValue.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,QAAA,MAAM,YAAY,GAAI,CAAC,EAAE,YAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"useFormValue.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormValue.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,QAAA,MAAM,YAAY,GAAI,CAAC,EAAE,YAAY,MAAM,kBAgB1C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import useForm from './useForm';
|
|
3
3
|
/**
|
|
4
4
|
* Hook to get a reactive value from the form state.
|
|
5
5
|
* This hook subscribes to value changes and returns the current value.
|
|
@@ -26,11 +26,8 @@ import FormContext from '../context';
|
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
28
|
const useFormValue = (fieldPath) => {
|
|
29
|
-
const { form } =
|
|
29
|
+
const { form } = useForm();
|
|
30
30
|
const [value, setValue] = useState();
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
setValue(form?.getValue(fieldPath));
|
|
33
|
-
}, [fieldPath, form]);
|
|
34
31
|
useEffect(() => {
|
|
35
32
|
const unsubscribe = form?.subscribeOnChange((formValue) => {
|
|
36
33
|
setValue(formValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormValue.js","sourceRoot":"","sources":["../../src/hooks/useFormValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useFormValue.js","sourceRoot":"","sources":["../../src/hooks/useFormValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,YAAY,GAAG,CAAI,SAAkB,EAAE,EAAE;IAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAK,CAAC;IAExC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAG,IAAI,EAAE,iBAAiB,CAAI,CAAC,SAAS,EAAE,EAAE;YAC3D,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,OAAO,GAAG,EAAE;YACV,WAAW,EAAE,EAAE,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAEtB,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import FormState from './state';
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
4
|
-
* @module @mapples/form
|
|
3
|
+
* @mapples/form - A comprehensive form management library for React and React Native
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* This package provides a powerful and flexible form state management solution with:
|
|
6
|
+
* - Type-safe form handling with TypeScript support
|
|
7
|
+
* - Yup validation integration
|
|
8
|
+
* - Form history management (undo/redo functionality)
|
|
9
|
+
* - Reactive form state with subscription-based updates
|
|
10
|
+
* - Comprehensive hook-based API for form field management
|
|
11
|
+
* - Support for nested objects and arrays
|
|
12
|
+
* - Touch state tracking for better UX
|
|
8
13
|
*
|
|
9
14
|
* @example
|
|
10
15
|
* ```tsx
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,SAAS,CAAC;AAEhC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,SAAS,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAGH,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import FormState from './state';
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
4
|
-
* @module @mapples/form
|
|
3
|
+
* @mapples/form - A comprehensive form management library for React and React Native
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* This package provides a powerful and flexible form state management solution with:
|
|
6
|
+
* - Type-safe form handling with TypeScript support
|
|
7
|
+
* - Yup validation integration
|
|
8
|
+
* - Form history management (undo/redo functionality)
|
|
9
|
+
* - Reactive form state with subscription-based updates
|
|
10
|
+
* - Comprehensive hook-based API for form field management
|
|
11
|
+
* - Support for nested objects and arrays
|
|
12
|
+
* - Touch state tracking for better UX
|
|
8
13
|
*
|
|
9
14
|
* @example
|
|
10
15
|
* ```tsx
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,SAAS,CAAC;AAEhC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,SAAS,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,mBAAmB;AACnB,cAAc,SAAS,CAAC;AAExB,wBAAwB;AACxB,cAAc,cAAc,CAAC;AAE7B,mBAAmB;AACnB,cAAc,SAAS,CAAC;AAExB,4CAA4C;AAC5C,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/state/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare class FormState<T extends object> {
|
|
|
52
52
|
* Sets all form values and triggers subscriptions.
|
|
53
53
|
*
|
|
54
54
|
* @param values - New values to set for the form
|
|
55
|
-
* @param cb -
|
|
55
|
+
* @param cb - Optional callback invoked with `true` after the values and subscriptions have been updated
|
|
56
56
|
*/
|
|
57
57
|
setValues(values: T, cb?: (success: boolean) => void): void;
|
|
58
58
|
/**
|
|
@@ -90,7 +90,7 @@ declare class FormState<T extends object> {
|
|
|
90
90
|
/**
|
|
91
91
|
* Validates the form using the provided validation schema.
|
|
92
92
|
*
|
|
93
|
-
* @throws
|
|
93
|
+
* @throws Throws validation errors if validation fails
|
|
94
94
|
*/
|
|
95
95
|
validate(): Promise<void>;
|
|
96
96
|
private saveToHistory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAEpD,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,UAAU,CAAC;AAElB;;;;;;;GAOG;AACH,cAAM,SAAS,CAAC,CAAC,SAAS,MAAM;IAC9B,OAAO,CAAC,MAAM,CAAI;IAElB,OAAO,CAAC,gBAAgB,CAAC,CAAkB;IAC3C,OAAO,CAAC,aAAa,CAA6C;IAClE,OAAO,CAAC,wBAAwB,CAAsC;IACtE,OAAO,CAAC,MAAM,CAAkD;IAEhE,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAW;IAE7C;;;;;;;;OAQG;gBAED,aA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;IAclC;;;;OAIG;IACH,SAAS;IAIT;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IAInD;;;;OAIG;IACH,SAAS;IAIT;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI;IAcpD;;;;;;OAMG;IACH,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC;IAwBnC;;;;;;;OAOG;IACH,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM;IAa/D;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,EAAE,MAAM,IAAI;IAQvC;;;;;;OAMG;IACH,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC;IAI7B;;;;OAIG;IACG,QAAQ;IAYd,OAAO,CAAC,aAAa;IA4BrB;;;;OAIG;IACH,IAAI;IASJ;;;;OAIG;IACH,IAAI;IASJ;;;;OAIG;IACH,OAAO;IAIP;;;;OAIG;IACH,OAAO;IAIP,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,0BAA0B;IAMlC,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,kBAAkB;CAM3B;AAED,eAAe,SAAS,CAAC"}
|
package/dist/state/index.js
CHANGED
|
@@ -67,7 +67,7 @@ class FormState {
|
|
|
67
67
|
* Sets all form values and triggers subscriptions.
|
|
68
68
|
*
|
|
69
69
|
* @param values - New values to set for the form
|
|
70
|
-
* @param cb -
|
|
70
|
+
* @param cb - Optional callback invoked with `true` after the values and subscriptions have been updated
|
|
71
71
|
*/
|
|
72
72
|
setValues(values, cb) {
|
|
73
73
|
this.values = cloneDeep(values);
|
|
@@ -116,6 +116,7 @@ class FormState {
|
|
|
116
116
|
cb: cb,
|
|
117
117
|
path,
|
|
118
118
|
});
|
|
119
|
+
cb(this.getValue(path));
|
|
119
120
|
return this.unsubscribeOnChange(id);
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
@@ -142,7 +143,7 @@ class FormState {
|
|
|
142
143
|
/**
|
|
143
144
|
* Validates the form using the provided validation schema.
|
|
144
145
|
*
|
|
145
|
-
* @throws
|
|
146
|
+
* @throws Throws validation errors if validation fails
|
|
146
147
|
*/
|
|
147
148
|
async validate() {
|
|
148
149
|
try {
|
package/dist/state/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AASrE;;;;;;;GAOG;AACH,MAAM,SAAS;IACL,MAAM,CAAI;IAEV,gBAAgB,CAAmB;IACnC,aAAa,GAAmC,IAAI,GAAG,EAAE,CAAC;IAC1D,wBAAwB,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC9D,MAAM,GAA6C,IAAI,CAAC;IAExD,OAAO,GAAQ,EAAE,CAAC;IAClB,YAAY,GAAW,CAAC,CAAC,CAAC;IACjB,YAAY,CAAS;IACrB,mBAAmB,CAAS;IACrC,WAAW,GAAW,CAAC,CAAC;IACf,iBAAiB,CAAW;IAE7C;;;;;;;;OAQG;IACH,YACE,aAAgB,EAChB,gBAAkC,EAClC,eAAuB,CAAC,EACxB,sBAA8B,CAAC,EAC/B,oBAA8B,EAAE;QAEhC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,aAAa,CAAC,CAAC;QACvC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACj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,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAE3D,OAAO,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC;IAC7B,CAAC;CACF;AAED,eAAe,SAAS,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface ValueSubscription<T = AnyValue> {
|
|
|
31
31
|
*/
|
|
32
32
|
export interface FormContextType<T extends object> {
|
|
33
33
|
/** The form state instance containing all form data and methods */
|
|
34
|
-
form: FormState<T
|
|
34
|
+
form: FormState<T>;
|
|
35
35
|
/** Object tracking which fields have been touched by the user */
|
|
36
36
|
touched: Record<keyof T, boolean>;
|
|
37
37
|
/** Function to submit the form, triggering validation and onSubmit callback */
|
|
@@ -44,8 +44,6 @@ export interface FormContextType<T extends object> {
|
|
|
44
44
|
validate: () => void;
|
|
45
45
|
/** Function to mark a specific field as touched */
|
|
46
46
|
touch: (fieldName: string) => void;
|
|
47
|
-
/** Set to true when initial values become available */
|
|
48
|
-
initialized: boolean;
|
|
49
47
|
}
|
|
50
48
|
/**
|
|
51
49
|
* Props for the Form component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAEpD,OAAO,SAAS,MAAM,UAAU,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;AAE1E;;;;;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0 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext.js","sourceRoot":"","sources":["../../src/hooks/useFormContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,WAAW,MAAM,YAAY,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|