@paragrav/rhf-utils 0.62.0 → 0.63.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/dist/esm/FormRelaySetter.mjs +88 -139
- package/dist/esm/index.mjs +352 -602
- package/dist/esm/relay.mjs +48 -83
- package/dist/esm/trpc.mjs +24 -40
- package/package.json +25 -26
package/dist/esm/relay.mjs
CHANGED
|
@@ -1,84 +1,49 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import
|
|
3
|
-
import { useFormState as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
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,
|
|
54
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
-
[d]
|
|
56
|
-
);
|
|
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
|
-
};
|
|
77
|
-
export {
|
|
78
|
-
x as FormRelayContextProvider,
|
|
79
|
-
M as FormRelaySetter,
|
|
80
|
-
f as useFirstFormStateGroup,
|
|
81
|
-
b as useFormRelayGroup,
|
|
82
|
-
R as useFormRelayId,
|
|
83
|
-
D as useFormRelaySet
|
|
1
|
+
import { c as e, i as t, l as n, n as r, s as i, t as a, u as o } from "./FormRelaySetter.mjs";
|
|
2
|
+
import s from "react";
|
|
3
|
+
import { useFormState as c } from "react-hook-form";
|
|
4
|
+
//#region src/form/relay/context/utils.ts
|
|
5
|
+
var l = (e) => e.reduce((e, n) => ({
|
|
6
|
+
isDirty: e.isDirty || n.isDirty,
|
|
7
|
+
isSubmitting: e.isSubmitting || n.isSubmitting,
|
|
8
|
+
isLoading: e.isLoading || n.isLoading,
|
|
9
|
+
isSubmitted: e.isSubmitted || n.isSubmitted,
|
|
10
|
+
isSubmitSuccessful: e.isSubmitSuccessful || n.isSubmitSuccessful,
|
|
11
|
+
isValidating: e.isValidating || n.isValidating,
|
|
12
|
+
isValid: e.isValid || n.isValid,
|
|
13
|
+
isReady: e.isReady || n.isReady,
|
|
14
|
+
disabled: e.disabled || n.disabled,
|
|
15
|
+
hasErrors: e.hasErrors || n.errors && !t(n.errors),
|
|
16
|
+
hasDirtyFields: e.hasDirtyFields || n.dirtyFields && !t(n.dirtyFields),
|
|
17
|
+
hasTouchedFields: e.hasTouchedFields || n.touchedFields && !t(n.touchedFields),
|
|
18
|
+
hasValidatingFields: e.hasValidatingFields || n.validatingFields && !t(n.validatingFields),
|
|
19
|
+
submitCount: (e.submitCount ?? 0) + (n.submitCount ?? 0),
|
|
20
|
+
isMounted: e.isMounted || n.isMounted
|
|
21
|
+
}), {
|
|
22
|
+
isDirty: void 0,
|
|
23
|
+
isSubmitting: void 0,
|
|
24
|
+
isLoading: void 0,
|
|
25
|
+
isSubmitted: void 0,
|
|
26
|
+
isSubmitSuccessful: void 0,
|
|
27
|
+
isValidating: void 0,
|
|
28
|
+
isReady: void 0,
|
|
29
|
+
isValid: void 0,
|
|
30
|
+
disabled: void 0,
|
|
31
|
+
hasErrors: void 0,
|
|
32
|
+
hasDirtyFields: void 0,
|
|
33
|
+
hasTouchedFields: void 0,
|
|
34
|
+
hasValidatingFields: void 0,
|
|
35
|
+
submitCount: void 0,
|
|
36
|
+
isMounted: void 0
|
|
37
|
+
}), u = (e) => n().state[e], d = (e) => {
|
|
38
|
+
let t = n().state, r = l(f(t, e).map(({ state: e }) => e)), i = JSON.stringify(r);
|
|
39
|
+
return s.useMemo(() => r, [i]);
|
|
40
|
+
}, f = (e, t) => Object.values(e).filter(({ options: e, utils: n }) => !t || "groups" in t && t.groups.filter((t) => e.groups?.includes(t)).length || "predicate" in t && t.predicate({
|
|
41
|
+
groups: e.groups,
|
|
42
|
+
options: n.options
|
|
43
|
+
})), { Provider: p, useRequired: m, useMaybe: h } = o(), g = () => {
|
|
44
|
+
if (i()) return l([c()]);
|
|
45
|
+
let e = h();
|
|
46
|
+
return e ? e.state : d();
|
|
84
47
|
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { e as FormRelayContextProvider, a as FormRelaySetter, g as useFirstFormStateGroup, d as useFormRelayGroup, u as useFormRelayId, r as useFormRelaySet };
|
package/dist/esm/trpc.mjs
CHANGED
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
import { TRPCClientError as
|
|
2
|
-
import { z as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(t) => [
|
|
26
|
-
t.path.join("."),
|
|
27
|
-
// flatten path (e.g., "street.name")
|
|
28
|
-
{
|
|
29
|
-
type: t.code,
|
|
30
|
-
message: t.message
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
)
|
|
34
|
-
).transform((r) => Object.fromEntries(r)), i = (r) => (t) => t instanceof s ? o.parse(
|
|
35
|
-
t
|
|
36
|
-
) : r(t);
|
|
37
|
-
export {
|
|
38
|
-
i as makeOnSubmitTrpcClientErrorHandler,
|
|
39
|
-
o as trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer
|
|
40
|
-
};
|
|
1
|
+
import { TRPCClientError as e } from "@trpc/client";
|
|
2
|
+
import { z as t } from "zod";
|
|
3
|
+
//#region src/errors/trpc/trpcClientErrorMessageSchema.ts
|
|
4
|
+
var n = t.object({
|
|
5
|
+
code: t.string(),
|
|
6
|
+
message: t.string(),
|
|
7
|
+
path: t.array(t.string())
|
|
8
|
+
}).passthrough(), r = t.custom((t) => t instanceof e).transform((e) => e.message).transform((e) => {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(e);
|
|
11
|
+
} catch {
|
|
12
|
+
return [{
|
|
13
|
+
validation: "root",
|
|
14
|
+
code: "server",
|
|
15
|
+
message: e,
|
|
16
|
+
path: ["root"]
|
|
17
|
+
}];
|
|
18
|
+
}
|
|
19
|
+
}).pipe(t.array(n)).transform((e) => e.map((e) => [e.path.join("."), {
|
|
20
|
+
type: e.code,
|
|
21
|
+
message: e.message
|
|
22
|
+
}])).transform((e) => Object.fromEntries(e)), i = (t) => (n) => n instanceof e ? r.parse(n) : t(n);
|
|
23
|
+
//#endregion
|
|
24
|
+
export { i as makeOnSubmitTrpcClientErrorHandler, r as trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer };
|
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.63.0",
|
|
5
5
|
"description": "Integration utilities for react-hook-form.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -60,19 +60,19 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@eslint/compat": "^2.0.
|
|
64
|
-
"@eslint/eslintrc": "^3.3.
|
|
65
|
-
"@eslint/js": "^9.39.
|
|
63
|
+
"@eslint/compat": "^2.0.3",
|
|
64
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
65
|
+
"@eslint/js": "^9.39.4",
|
|
66
66
|
"@playwright/experimental-ct-react": "^1.58.2",
|
|
67
67
|
"@playwright/test": "^1.58.2",
|
|
68
68
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
69
|
-
"@types/node": "^24.
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
71
|
-
"@typescript-eslint/parser": "^8.
|
|
72
|
-
"@vitejs/plugin-react": "^
|
|
73
|
-
"clean-publish": "^6.0.
|
|
69
|
+
"@types/node": "^24.12.0",
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "^8.57.2",
|
|
71
|
+
"@typescript-eslint/parser": "^8.57.2",
|
|
72
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
73
|
+
"clean-publish": "^6.0.4",
|
|
74
74
|
"cross-env": "^10.1.0",
|
|
75
|
-
"eslint": "^9.39.
|
|
75
|
+
"eslint": "^9.39.4",
|
|
76
76
|
"eslint-config-prettier": "^10.1.8",
|
|
77
77
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
78
78
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
@@ -81,31 +81,30 @@
|
|
|
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.5.
|
|
84
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
85
85
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
86
|
-
"globals": "^17.
|
|
87
|
-
"happy-dom": "^20.
|
|
86
|
+
"globals": "^17.4.0",
|
|
87
|
+
"happy-dom": "^20.8.8",
|
|
88
88
|
"husky": "^9.1.7",
|
|
89
|
-
"lint-staged": "^16.
|
|
89
|
+
"lint-staged": "^16.4.0",
|
|
90
90
|
"prettier": "^3.8.1",
|
|
91
|
-
"rollup": "^4.
|
|
91
|
+
"rollup": "^4.60.0",
|
|
92
92
|
"safe-stable-stringify": "^2.5.0",
|
|
93
|
-
"terser": "^5.46.
|
|
94
|
-
"typescript": "^
|
|
95
|
-
"typescript-eslint": "^8.
|
|
96
|
-
"vite": "^
|
|
93
|
+
"terser": "^5.46.1",
|
|
94
|
+
"typescript": "^6.0.2",
|
|
95
|
+
"typescript-eslint": "^8.57.2",
|
|
96
|
+
"vite": "^8.0.2",
|
|
97
97
|
"vite-plugin-dts": "^4.5.4",
|
|
98
|
-
"
|
|
99
|
-
"vitest": "^4.0.18"
|
|
98
|
+
"vitest": "^4.1.1"
|
|
100
99
|
},
|
|
101
100
|
"resolutions": {
|
|
102
|
-
"
|
|
103
|
-
"eslint": "^9.22.0",
|
|
104
|
-
"react": "^19.0.0",
|
|
105
|
-
"react-dom": "^19.0.0",
|
|
101
|
+
"eslint": "^9.39.4",
|
|
106
102
|
"@types/react": "^19.0.4",
|
|
107
103
|
"@types/react-dom": "^19.0.2",
|
|
108
|
-
"
|
|
104
|
+
"react": "^19.0.0",
|
|
105
|
+
"react-dom": "^19.0.0",
|
|
106
|
+
"typescript": "^6.0.2",
|
|
107
|
+
"vite": "^8.0.2"
|
|
109
108
|
},
|
|
110
109
|
"repository": {
|
|
111
110
|
"type": "git",
|