@paragrav/rhf-utils 0.61.0 → 0.62.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 +49 -89
- package/dist/dts/_exports/relay.d.ts +7 -8
- package/dist/dts/errors/flat/getFlatFieldErrors.d.ts +5 -1
- package/dist/dts/form/RhfUtilsFormComponentPropsType.d.ts +2 -2
- package/dist/dts/form/UseRhfUtilsFormChildrenPropsType.d.ts +2 -2
- package/dist/dts/form/context/utils/LastSubmitStateType.d.ts +1 -0
- package/dist/dts/form/context/utils/{RhfUtilsContextPropsType.d.ts → RhfUtilsContextType.d.ts} +3 -2
- package/dist/dts/form/context/utils/useRhfUtilsContext.d.ts +4 -4
- package/dist/dts/form/defaults/form/useRhfUtilsFormResolvedFormProps.d.ts +10 -10
- package/dist/dts/form/providers/RhfUtilsFormProviders.d.ts +1 -1
- package/dist/dts/form/providers/RhfUtilsFormProvidersPropsType.d.ts +2 -0
- package/dist/dts/form/relay/FormRelayOptions.d.ts +16 -0
- package/dist/dts/form/{state/relay/FormStateRelayContextProvider.d.ts → relay/context/FormRelayContextProvider.d.ts} +1 -1
- package/dist/dts/form/relay/context/useFormRelayContext.d.ts +12 -0
- package/dist/dts/form/relay/context/utils.d.ts +4 -0
- package/dist/dts/form/relay/get/FormRelayGroupType.d.ts +16 -0
- package/dist/dts/form/relay/get/grouper/context/hooks.d.ts +8 -0
- package/dist/dts/form/relay/get/grouper/context/index.d.ts +5 -0
- package/dist/dts/form/relay/get/grouper/context/provider.d.ts +9 -0
- package/dist/dts/form/relay/get/grouper/useFirstFormStateGroup.d.ts +9 -0
- package/dist/dts/form/relay/get/useFormRelay.d.ts +13 -0
- package/dist/dts/form/relay/set/FormRelaySetter.d.ts +6 -0
- package/dist/dts/form/relay/set/useFormRelaySet.d.ts +2 -0
- package/dist/dts/form/relay/types.d.ts +12 -0
- package/dist/dts/form/with-handlers-and-children/RhfUtilsFormProps.d.ts +5 -1
- package/dist/dts/form/with-handlers-and-children/_useHandleSubmit.d.ts +1 -1
- package/dist/dts/form/with-providers/RhfUtilsFormWithProviders.d.ts +1 -1
- package/dist/dts/submit/UseRhfUtilsFormOnSubmitContextType.d.ts +3 -3
- package/dist/dts/submit/last-error/useLastSubmitErrorContextWith.d.ts +1 -1
- package/dist/esm/FormRelaySetter.mjs +140 -0
- package/dist/esm/index.mjs +226 -220
- package/dist/esm/relay.mjs +71 -209
- package/package.json +17 -17
- package/dist/dts/form/RhfUtilsFormStateWithUtilsType.d.ts +0 -7
- package/dist/dts/form/state/relay/FormStateRelayedAggregatedType.d.ts +0 -10
- package/dist/dts/form/state/relay/FormStateRelayedItemType.d.ts +0 -11
- package/dist/dts/form/state/relay/FormStateRelayedOptionsType.d.ts +0 -20
- package/dist/dts/form/state/relay/FormStateRelayedType.d.ts +0 -3
- package/dist/dts/form/state/relay/pull/hooks.d.ts +0 -31
- package/dist/dts/form/state/relay/push/FormStateRelayPusher.d.ts +0 -4
- package/dist/dts/form/state/relay/push/useFormStateRelayPusher.d.ts +0 -3
- package/dist/dts/form/state/relay/useFormStateRelayContext.d.ts +0 -20
- package/dist/dts/form/state/relay/utils.d.ts +0 -4
- package/dist/esm/getFlatFieldErrors.mjs +0 -55
package/dist/esm/relay.mjs
CHANGED
|
@@ -1,222 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import a from "
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
useRequired: y
|
|
8
|
-
} = V(), p = (s) => s.reduce(
|
|
9
|
-
(t, e) => ({
|
|
1
|
+
import { i as o, b as a, c as m, d as u } from "./FormRelaySetter.mjs";
|
|
2
|
+
import { F as x, a as M, e as D } from "./FormRelaySetter.mjs";
|
|
3
|
+
import { useFormState as y } from "react-hook-form";
|
|
4
|
+
import r from "react";
|
|
5
|
+
const l = (t) => t.reduce(
|
|
6
|
+
(i, s) => ({
|
|
10
7
|
// booleans
|
|
11
|
-
isDirty:
|
|
12
|
-
isSubmitting:
|
|
13
|
-
isLoading:
|
|
14
|
-
isSubmitted:
|
|
15
|
-
isSubmitSuccessful:
|
|
16
|
-
isValidating:
|
|
17
|
-
isValid:
|
|
18
|
-
isReady:
|
|
19
|
-
disabled:
|
|
8
|
+
isDirty: i.isDirty || s.isDirty,
|
|
9
|
+
isSubmitting: i.isSubmitting || s.isSubmitting,
|
|
10
|
+
isLoading: i.isLoading || s.isLoading,
|
|
11
|
+
isSubmitted: i.isSubmitted || s.isSubmitted,
|
|
12
|
+
isSubmitSuccessful: i.isSubmitSuccessful || s.isSubmitSuccessful,
|
|
13
|
+
isValidating: i.isValidating || s.isValidating,
|
|
14
|
+
isValid: i.isValid || s.isValid,
|
|
15
|
+
isReady: i.isReady || s.isReady,
|
|
16
|
+
disabled: i.disabled || s.disabled,
|
|
20
17
|
// objects
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
hasErrors: i.hasErrors || s.errors && !o(s.errors),
|
|
19
|
+
hasDirtyFields: i.hasDirtyFields || s.dirtyFields && !o(s.dirtyFields),
|
|
20
|
+
hasTouchedFields: i.hasTouchedFields || s.touchedFields && !o(s.touchedFields),
|
|
21
|
+
hasValidatingFields: i.hasValidatingFields || s.validatingFields && !o(s.validatingFields),
|
|
25
22
|
// counts
|
|
26
|
-
submitCount:
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
isMountedFlagged: t.isMountedFlagged || !!e.options?.flaggedState?.isMounted
|
|
23
|
+
submitCount: (i.submitCount ?? 0) + (s.submitCount ?? 0),
|
|
24
|
+
// supplemental
|
|
25
|
+
isMounted: i.isMounted || s.isMounted
|
|
30
26
|
}),
|
|
31
27
|
// initial values
|
|
32
28
|
{
|
|
33
|
-
isDirty:
|
|
34
|
-
isSubmitting:
|
|
35
|
-
isLoading:
|
|
36
|
-
isSubmitted:
|
|
37
|
-
isSubmitSuccessful:
|
|
38
|
-
isValidating:
|
|
39
|
-
isReady:
|
|
40
|
-
isValid:
|
|
41
|
-
disabled:
|
|
29
|
+
isDirty: void 0,
|
|
30
|
+
isSubmitting: void 0,
|
|
31
|
+
isLoading: void 0,
|
|
32
|
+
isSubmitted: void 0,
|
|
33
|
+
isSubmitSuccessful: void 0,
|
|
34
|
+
isValidating: void 0,
|
|
35
|
+
isReady: void 0,
|
|
36
|
+
isValid: void 0,
|
|
37
|
+
disabled: void 0,
|
|
42
38
|
// objects
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
hasErrors: void 0,
|
|
40
|
+
hasDirtyFields: void 0,
|
|
41
|
+
hasTouchedFields: void 0,
|
|
42
|
+
hasValidatingFields: void 0,
|
|
47
43
|
// counts
|
|
48
|
-
submitCount: 0,
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
isMountedFlagged: !1
|
|
44
|
+
submitCount: void 0,
|
|
45
|
+
// supplemental
|
|
46
|
+
isMounted: void 0
|
|
52
47
|
}
|
|
53
|
-
),
|
|
54
|
-
|
|
55
|
-
}) =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
e((m) => ({
|
|
60
|
-
...m,
|
|
61
|
-
[l.formId]: { state: i, utils: l, options: r }
|
|
62
|
-
}));
|
|
63
|
-
},
|
|
48
|
+
), R = (t) => a().state[t], b = (t) => {
|
|
49
|
+
const i = a().state, s = g(i, t), e = l(
|
|
50
|
+
s.map(({ state: n }) => n)
|
|
51
|
+
), d = JSON.stringify(e);
|
|
52
|
+
return r.useMemo(
|
|
53
|
+
() => e,
|
|
64
54
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
-
[]
|
|
66
|
-
), n = a.useCallback((i, l) => {
|
|
67
|
-
e((r) => {
|
|
68
|
-
const m = r[i];
|
|
69
|
-
if (!m) throw new Error("Form id doesn't exist");
|
|
70
|
-
return {
|
|
71
|
-
...r,
|
|
72
|
-
[i]: { ...m, state: l }
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
}, []), u = a.useCallback((i) => {
|
|
76
|
-
e(
|
|
77
|
-
(l) => Object.fromEntries(
|
|
78
|
-
Object.entries(l).filter(([r]) => r !== i)
|
|
79
|
-
)
|
|
80
|
-
);
|
|
81
|
-
}, []), d = a.useCallback((i) => t[i], [t]), b = a.useCallback(() => {
|
|
82
|
-
const i = Object.values(t);
|
|
83
|
-
if (i.length > 1) throw new Error("More than one form.");
|
|
84
|
-
return i[0];
|
|
85
|
-
}, [t]), S = P(t), F = a.useCallback(
|
|
86
|
-
(i) => S[i],
|
|
87
|
-
[S]
|
|
88
|
-
), c = E(t);
|
|
89
|
-
return /* @__PURE__ */ v(
|
|
90
|
-
j,
|
|
91
|
-
{
|
|
92
|
-
value: {
|
|
93
|
-
// push
|
|
94
|
-
add: o,
|
|
95
|
-
update: n,
|
|
96
|
-
remove: u,
|
|
97
|
-
// pull
|
|
98
|
-
get: d,
|
|
99
|
-
getOnly: b,
|
|
100
|
-
getGroup: F,
|
|
101
|
-
any: c
|
|
102
|
-
},
|
|
103
|
-
children: s
|
|
104
|
-
}
|
|
55
|
+
[d]
|
|
105
56
|
);
|
|
106
|
-
},
|
|
107
|
-
() =>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return Object.fromEntries(
|
|
127
|
-
Object.entries(t).map(([o, n]) => [
|
|
128
|
-
// preserve key
|
|
129
|
-
o,
|
|
130
|
-
// condense states to "any" for this group
|
|
131
|
-
p(n)
|
|
132
|
-
])
|
|
133
|
-
);
|
|
134
|
-
}, [s]), w = () => y().getOnly(), q = () => y().any, J = (s) => y().get(s), N = (s) => y().getGroup(s), T = () => {
|
|
135
|
-
const s = x();
|
|
136
|
-
if (s)
|
|
137
|
-
return {
|
|
138
|
-
state: h(),
|
|
139
|
-
utils: s
|
|
140
|
-
};
|
|
141
|
-
const t = w();
|
|
142
|
-
return t && // normalize for compatibility with rhf above
|
|
143
|
-
{
|
|
144
|
-
state: t.state,
|
|
145
|
-
utils: t.utils
|
|
146
|
-
};
|
|
147
|
-
}, G = (s) => {
|
|
148
|
-
const [t] = a.useState(s);
|
|
149
|
-
U(t), k();
|
|
150
|
-
}, U = (s) => {
|
|
151
|
-
const t = R(), e = y(), o = C();
|
|
152
|
-
a.useEffect(
|
|
153
|
-
() => (e.add(o, t, s), () => {
|
|
154
|
-
e.remove(t.formId);
|
|
155
|
-
}),
|
|
156
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
157
|
-
[]
|
|
158
|
-
);
|
|
159
|
-
}, k = () => {
|
|
160
|
-
const s = R(), t = y(), e = C();
|
|
161
|
-
a.useEffect(
|
|
162
|
-
// when form state changes, publish to relay context
|
|
163
|
-
() => {
|
|
164
|
-
t.update(s.formId, e);
|
|
165
|
-
},
|
|
166
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
167
|
-
[e]
|
|
168
|
-
);
|
|
169
|
-
}, C = () => {
|
|
170
|
-
const {
|
|
171
|
-
errors: s,
|
|
172
|
-
isDirty: t,
|
|
173
|
-
isSubmitting: e,
|
|
174
|
-
isValid: o,
|
|
175
|
-
isReady: n,
|
|
176
|
-
isSubmitted: u,
|
|
177
|
-
isSubmitSuccessful: d,
|
|
178
|
-
dirtyFields: b,
|
|
179
|
-
disabled: S,
|
|
180
|
-
isLoading: F,
|
|
181
|
-
isValidating: c,
|
|
182
|
-
submitCount: i,
|
|
183
|
-
touchedFields: l,
|
|
184
|
-
validatingFields: r,
|
|
185
|
-
defaultValues: m
|
|
186
|
-
} = h(), g = {
|
|
187
|
-
errors: s,
|
|
188
|
-
isDirty: t,
|
|
189
|
-
isSubmitting: e,
|
|
190
|
-
isValid: o,
|
|
191
|
-
isReady: n,
|
|
192
|
-
isSubmitted: u,
|
|
193
|
-
isSubmitSuccessful: d,
|
|
194
|
-
dirtyFields: b,
|
|
195
|
-
disabled: S,
|
|
196
|
-
isLoading: F,
|
|
197
|
-
isValidating: c,
|
|
198
|
-
submitCount: i,
|
|
199
|
-
touchedFields: l,
|
|
200
|
-
validatingFields: r,
|
|
201
|
-
defaultValues: m
|
|
202
|
-
}, O = JSON.stringify({
|
|
203
|
-
...g,
|
|
204
|
-
errors: M(s)
|
|
205
|
-
});
|
|
206
|
-
return a.useMemo(
|
|
207
|
-
// when watch JSON changes, update memo
|
|
208
|
-
() => g,
|
|
209
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
210
|
-
[O]
|
|
211
|
-
);
|
|
212
|
-
}, W = (s) => (G(s), null);
|
|
57
|
+
}, g = (t, i) => Object.values(t).filter(
|
|
58
|
+
({ options: s, utils: e }) => (
|
|
59
|
+
// no criteria specified
|
|
60
|
+
!i || // groups specified
|
|
61
|
+
"groups" in i && i.groups.filter((d) => s.groups?.includes(d)).length || // predicate specified
|
|
62
|
+
"predicate" in i && i.predicate({
|
|
63
|
+
groups: s.groups,
|
|
64
|
+
options: e.options
|
|
65
|
+
})
|
|
66
|
+
)
|
|
67
|
+
), {
|
|
68
|
+
useMaybe: F
|
|
69
|
+
} = m(), f = () => {
|
|
70
|
+
if (u()) {
|
|
71
|
+
const s = y();
|
|
72
|
+
return l([s]);
|
|
73
|
+
}
|
|
74
|
+
const i = F();
|
|
75
|
+
return i ? i.state : b();
|
|
76
|
+
};
|
|
213
77
|
export {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
G as useFormStateRelayPusher,
|
|
221
|
-
T as useFormStateWithUtilsViaRhfOrRelay
|
|
78
|
+
x as FormRelayContextProvider,
|
|
79
|
+
M as FormRelaySetter,
|
|
80
|
+
f as useFirstFormStateGroup,
|
|
81
|
+
b as useFormRelayGroup,
|
|
82
|
+
R as useFormRelayId,
|
|
83
|
+
D as useFormRelaySet
|
|
222
84
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paragrav/rhf-utils",
|
|
3
3
|
"author": "paragrav.dev",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.62.0",
|
|
5
5
|
"description": "Integration utilities for react-hook-form.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@eslint/compat": "^2.0.
|
|
63
|
+
"@eslint/compat": "^2.0.2",
|
|
64
64
|
"@eslint/eslintrc": "^3.3.3",
|
|
65
65
|
"@eslint/js": "^9.39.2",
|
|
66
|
-
"@playwright/experimental-ct-react": "^1.
|
|
67
|
-
"@playwright/test": "^1.
|
|
66
|
+
"@playwright/experimental-ct-react": "^1.58.2",
|
|
67
|
+
"@playwright/test": "^1.58.2",
|
|
68
68
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
69
|
-
"@types/node": "^24.10.
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
71
|
-
"@typescript-eslint/parser": "^8.
|
|
72
|
-
"@vitejs/plugin-react": "^5.1.
|
|
69
|
+
"@types/node": "^24.10.13",
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
71
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
72
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
73
73
|
"clean-publish": "^6.0.1",
|
|
74
74
|
"cross-env": "^10.1.0",
|
|
75
75
|
"eslint": "^9.39.2",
|
|
@@ -81,22 +81,22 @@
|
|
|
81
81
|
"eslint-plugin-prettier": "^5.5.5",
|
|
82
82
|
"eslint-plugin-react": "^7.37.5",
|
|
83
83
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
84
|
-
"eslint-plugin-react-refresh": "^0.
|
|
84
|
+
"eslint-plugin-react-refresh": "^0.5.0",
|
|
85
85
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
86
|
-
"globals": "^17.
|
|
87
|
-
"happy-dom": "^20.1
|
|
86
|
+
"globals": "^17.3.0",
|
|
87
|
+
"happy-dom": "^20.6.1",
|
|
88
88
|
"husky": "^9.1.7",
|
|
89
89
|
"lint-staged": "^16.2.7",
|
|
90
|
-
"prettier": "^3.
|
|
91
|
-
"rollup": "^4.
|
|
90
|
+
"prettier": "^3.8.1",
|
|
91
|
+
"rollup": "^4.57.1",
|
|
92
92
|
"safe-stable-stringify": "^2.5.0",
|
|
93
|
-
"terser": "^5.
|
|
93
|
+
"terser": "^5.46.0",
|
|
94
94
|
"typescript": "^5.9.3",
|
|
95
|
-
"typescript-eslint": "^8.
|
|
95
|
+
"typescript-eslint": "^8.55.0",
|
|
96
96
|
"vite": "^7.3.1",
|
|
97
97
|
"vite-plugin-dts": "^4.5.4",
|
|
98
|
-
"vite-tsconfig-paths": "^6.0
|
|
99
|
-
"vitest": "^4.0.
|
|
98
|
+
"vite-tsconfig-paths": "^6.1.0",
|
|
99
|
+
"vitest": "^4.0.18"
|
|
100
100
|
},
|
|
101
101
|
"resolutions": {
|
|
102
102
|
"esbuild": "^0.25.0",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FormState } from 'react-hook-form';
|
|
2
|
-
import { RhfUtilsContextProps } from './context/utils/RhfUtilsContextPropsType';
|
|
3
|
-
import { SafeFieldValues } from './rhf/SafeFieldValuesType';
|
|
4
|
-
export type RhfUtilsFormStateWithUtilsType<TFieldValues extends SafeFieldValues = SafeFieldValues> = {
|
|
5
|
-
state: FormState<TFieldValues>;
|
|
6
|
-
utils: RhfUtilsContextProps;
|
|
7
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Merge } from '../../../utils/types';
|
|
2
|
-
import { FormStateRelayed } from './FormStateRelayedType';
|
|
3
|
-
export type FormStateRelayedAggregated = Merge<Omit<FormStateRelayed, 'defaultValues'>, Record<Extract<keyof FormStateRelayed, 'dirtyFields' | 'touchedFields' | 'validatingFields' | 'errors'>, boolean> & {
|
|
4
|
-
/** Sum of all submit counts. */
|
|
5
|
-
submitCount: number;
|
|
6
|
-
/** Any submitted and not successful? */
|
|
7
|
-
isSubmitUnsuccessful: boolean;
|
|
8
|
-
/** Consider form flagged when mounted. (Corresponds to {@link FormStateRelayedOptions.flaggedState.isMounted}.) */
|
|
9
|
-
isMountedFlagged: boolean;
|
|
10
|
-
}>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SafeFieldValues } from '../../rhf/SafeFieldValuesType';
|
|
2
|
-
import { RhfUtilsFormStateWithUtilsType } from '../../RhfUtilsFormStateWithUtilsType';
|
|
3
|
-
import { FormStateRelayedOptions } from './FormStateRelayedOptionsType';
|
|
4
|
-
import { FormStateRelayed } from './FormStateRelayedType';
|
|
5
|
-
export type FormStateRelayedItem<TFieldValues extends SafeFieldValues = SafeFieldValues> = {
|
|
6
|
-
state: FormStateRelayed<TFieldValues>;
|
|
7
|
-
options?: FormStateRelayedOptions;
|
|
8
|
-
};
|
|
9
|
-
export type FormStateRelayedItemWithUtils<TFieldValues extends SafeFieldValues = SafeFieldValues> = RhfUtilsFormStateWithUtilsType<TFieldValues> & {
|
|
10
|
-
options?: FormStateRelayedOptions;
|
|
11
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type FormStateRelayedOptions = {
|
|
2
|
-
/**
|
|
3
|
-
* Arbitrary group name(s) for this form.
|
|
4
|
-
*
|
|
5
|
-
* Think of it like class or category names.
|
|
6
|
-
* (e.g., "parent" or "children")
|
|
7
|
-
*/
|
|
8
|
-
group?: string | string[];
|
|
9
|
-
/**
|
|
10
|
-
* Denote certain state(s) as flagged.
|
|
11
|
-
*/
|
|
12
|
-
flaggedState?: {
|
|
13
|
-
/**
|
|
14
|
-
* Flag when mounted.
|
|
15
|
-
*
|
|
16
|
-
* (e.g., forms that are unmounted by default)
|
|
17
|
-
*/
|
|
18
|
-
isMounted?: true;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { SafeFieldValues } from '../../../rhf/SafeFieldValuesType';
|
|
2
|
-
import { RhfUtilsFormStateWithUtilsType } from '../../../RhfUtilsFormStateWithUtilsType';
|
|
3
|
-
import { FormStateRelayedAggregated } from '../FormStateRelayedAggregatedType';
|
|
4
|
-
import { FormStateRelayedItemWithUtils } from '../FormStateRelayedItemType';
|
|
5
|
-
/**
|
|
6
|
-
* Watch only form -- without worrying about ID.
|
|
7
|
-
*
|
|
8
|
-
* @throws If more than one form is being tracked.
|
|
9
|
-
*/
|
|
10
|
-
export declare const useFormStateRelayPullOnlyOrThrow: () => FormStateRelayedItemWithUtils | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Watch all forms via {@link FormStateRelayedAggregated}.
|
|
13
|
-
*/
|
|
14
|
-
export declare const useFormStateRelayPullAny: () => FormStateRelayedAggregated;
|
|
15
|
-
/**
|
|
16
|
-
* Watch single form's state.
|
|
17
|
-
*
|
|
18
|
-
* @param formId Watched form identifier.
|
|
19
|
-
*/
|
|
20
|
-
export declare const useFormStateRelayPullById: (formId: string) => FormStateRelayedItemWithUtils | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Compute single boolean for group's form state to denote whether it's flagged via default algorithm.
|
|
23
|
-
* (i.e., is dirty or submitting or submit unsuccessful or mounted flagged)
|
|
24
|
-
*
|
|
25
|
-
* @param group Group name to watch.
|
|
26
|
-
*/
|
|
27
|
-
export declare const useFormStateRelayPullGroup: (group: string) => FormStateRelayedAggregated | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Use form state with utils either through RHF or relay.
|
|
30
|
-
*/
|
|
31
|
-
export declare const useFormStateWithUtilsViaRhfOrRelay: <TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues>() => RhfUtilsFormStateWithUtilsType<TFieldValues> | undefined;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { RhfUtilsContextProps } from '../../context/utils/RhfUtilsContextPropsType';
|
|
2
|
-
import { FormStateRelayedAggregated } from './FormStateRelayedAggregatedType';
|
|
3
|
-
import { FormStateRelayedItemWithUtils } from './FormStateRelayedItemType';
|
|
4
|
-
import { FormStateRelayedOptions } from './FormStateRelayedOptionsType';
|
|
5
|
-
import { FormStateRelayed } from './FormStateRelayedType';
|
|
6
|
-
export type FormStateRelayContext = {
|
|
7
|
-
add: (state: FormStateRelayed, utils: RhfUtilsContextProps, options?: FormStateRelayedOptions) => void;
|
|
8
|
-
update: (id: string, state: FormStateRelayed) => void;
|
|
9
|
-
remove: (id: string) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Get form state by ID.
|
|
12
|
-
*
|
|
13
|
-
* @throws Error if not found.
|
|
14
|
-
*/
|
|
15
|
-
get: (id: string) => FormStateRelayedItemWithUtils | undefined;
|
|
16
|
-
getOnly: () => FormStateRelayedItemWithUtils | undefined;
|
|
17
|
-
any: FormStateRelayedAggregated;
|
|
18
|
-
getGroup: (group: string) => FormStateRelayedAggregated | undefined;
|
|
19
|
-
};
|
|
20
|
-
export declare const _FormStateRelayContextProvider: import('react').Provider<FormStateRelayContext | undefined>, useFormStateRelayContext: () => FormStateRelayContext;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { FormStateRelayedAggregated } from './FormStateRelayedAggregatedType';
|
|
2
|
-
import { FormStateRelayedItem } from './FormStateRelayedItemType';
|
|
3
|
-
/** Condense list of form states to singular booleans. */
|
|
4
|
-
export declare const getFormContextRelayReducedFormState: (forms: FormStateRelayedItem[]) => FormStateRelayedAggregated;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import a from "react";
|
|
2
|
-
import { get as c } from "react-hook-form";
|
|
3
|
-
import { flatten as f } from "flat";
|
|
4
|
-
function d() {
|
|
5
|
-
const e = a.createContext(void 0), r = () => a.useContext(e), s = () => {
|
|
6
|
-
const t = r();
|
|
7
|
-
if (t === void 0) throw new Error();
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return {
|
|
11
|
-
Provider: e.Provider,
|
|
12
|
-
useMaybe: r,
|
|
13
|
-
useRequired: s
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const {
|
|
17
|
-
Provider: x,
|
|
18
|
-
useRequired: g,
|
|
19
|
-
useMaybe: E
|
|
20
|
-
} = d(), h = (e) => Object.keys(e).length === 0, u = (e) => f(e), b = (e) => {
|
|
21
|
-
const r = u(e), s = Object.keys(r);
|
|
22
|
-
return Object.fromEntries(
|
|
23
|
-
s.reduce(
|
|
24
|
-
(t, n) => {
|
|
25
|
-
const o = n.replace(
|
|
26
|
-
l,
|
|
27
|
-
""
|
|
28
|
-
);
|
|
29
|
-
if (o === n) return t;
|
|
30
|
-
const i = c(e, o, void 0);
|
|
31
|
-
return i && t.push([o, i]), t;
|
|
32
|
-
},
|
|
33
|
-
[]
|
|
34
|
-
// entries
|
|
35
|
-
)
|
|
36
|
-
);
|
|
37
|
-
}, l = /\.(?:type|message)\b$/, v = (e) => Object.fromEntries(
|
|
38
|
-
Object.entries(b(e)).map(([r, s]) => [
|
|
39
|
-
r,
|
|
40
|
-
{
|
|
41
|
-
type: s.type,
|
|
42
|
-
message: s.message
|
|
43
|
-
// strip out ref, etc. (avoid circular JSON error)
|
|
44
|
-
}
|
|
45
|
-
])
|
|
46
|
-
);
|
|
47
|
-
export {
|
|
48
|
-
x as _,
|
|
49
|
-
E as a,
|
|
50
|
-
v as b,
|
|
51
|
-
d as c,
|
|
52
|
-
b as g,
|
|
53
|
-
h as i,
|
|
54
|
-
g as u
|
|
55
|
-
};
|