@rpcbase/form 0.24.0 → 0.26.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/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "react-hook-form";
2
- export * from "./zodResolver";
1
+ export * from 'react-hook-form';
2
+ export * from './zodResolver';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../pkg/form/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,119 @@
1
+ import { get, set, appendErrors } from "react-hook-form";
1
2
  export * from "react-hook-form";
2
- export * from "./zodResolver";
3
+ import * as n$1 from "zod/v4/core";
4
+ const r = (t2, r2, o2) => {
5
+ if (t2 && "reportValidity" in t2) {
6
+ const s2 = get(o2, r2);
7
+ t2.setCustomValidity(s2 && s2.message || ""), t2.reportValidity();
8
+ }
9
+ }, o = (e, t2) => {
10
+ for (const o2 in t2.fields) {
11
+ const s2 = t2.fields[o2];
12
+ s2 && s2.ref && "reportValidity" in s2.ref ? r(s2.ref, o2, e) : s2 && s2.refs && s2.refs.forEach((t3) => r(t3, o2, e));
13
+ }
14
+ }, s$1 = (r2, s2) => {
15
+ s2.shouldUseNativeValidation && o(r2, s2);
16
+ const n2 = {};
17
+ for (const o2 in r2) {
18
+ const f = get(s2.fields, o2), c = Object.assign(r2[o2] || {}, { ref: f && f.ref });
19
+ if (i$1(s2.names || Object.keys(r2), o2)) {
20
+ const r3 = Object.assign({}, get(n2, o2));
21
+ set(r3, "root", c), set(n2, o2, r3);
22
+ } else set(n2, o2, c);
23
+ }
24
+ return n2;
25
+ }, i$1 = (e, t2) => {
26
+ const r2 = n(t2);
27
+ return e.some((e2) => n(e2).match(`^${r2}\\.\\d+`));
28
+ };
29
+ function n(e) {
30
+ return e.replace(/\]|\[/g, "");
31
+ }
32
+ function t(r2, e) {
33
+ try {
34
+ var o2 = r2();
35
+ } catch (r3) {
36
+ return e(r3);
37
+ }
38
+ return o2 && o2.then ? o2.then(void 0, e) : o2;
39
+ }
40
+ function s(r2, e) {
41
+ for (var n2 = {}; r2.length; ) {
42
+ var t2 = r2[0], s2 = t2.code, i2 = t2.message, a2 = t2.path.join(".");
43
+ if (!n2[a2]) if ("unionErrors" in t2) {
44
+ var u = t2.unionErrors[0].errors[0];
45
+ n2[a2] = { message: u.message, type: u.code };
46
+ } else n2[a2] = { message: i2, type: s2 };
47
+ if ("unionErrors" in t2 && t2.unionErrors.forEach(function(e2) {
48
+ return e2.errors.forEach(function(e3) {
49
+ return r2.push(e3);
50
+ });
51
+ }), e) {
52
+ var c = n2[a2].types, f = c && c[t2.code];
53
+ n2[a2] = appendErrors(a2, e, n2, s2, f ? [].concat(f, t2.message) : t2.message);
54
+ }
55
+ r2.shift();
56
+ }
57
+ return n2;
58
+ }
59
+ function i(r2, e) {
60
+ for (var n2 = {}; r2.length; ) {
61
+ var t2 = r2[0], s2 = t2.code, i2 = t2.message, a2 = t2.path.join(".");
62
+ if (!n2[a2]) if ("invalid_union" === t2.code && t2.errors.length > 0) {
63
+ var u = t2.errors[0][0];
64
+ n2[a2] = { message: u.message, type: u.code };
65
+ } else n2[a2] = { message: i2, type: s2 };
66
+ if ("invalid_union" === t2.code && t2.errors.forEach(function(e2) {
67
+ return e2.forEach(function(e3) {
68
+ return r2.push(e3);
69
+ });
70
+ }), e) {
71
+ var c = n2[a2].types, f = c && c[t2.code];
72
+ n2[a2] = appendErrors(a2, e, n2, s2, f ? [].concat(f, t2.message) : t2.message);
73
+ }
74
+ r2.shift();
75
+ }
76
+ return n2;
77
+ }
78
+ function a(o$1, a2, u) {
79
+ if (void 0 === u && (u = {}), (function(r2) {
80
+ return "_def" in r2 && "object" == typeof r2._def && "typeName" in r2._def;
81
+ })(o$1)) return function(n2, i2, c) {
82
+ try {
83
+ return Promise.resolve(t(function() {
84
+ return Promise.resolve(o$1["sync" === u.mode ? "parse" : "parseAsync"](n2, a2)).then(function(e) {
85
+ return c.shouldUseNativeValidation && o({}, c), { errors: {}, values: u.raw ? Object.assign({}, n2) : e };
86
+ });
87
+ }, function(r2) {
88
+ if ((function(r3) {
89
+ return Array.isArray(null == r3 ? void 0 : r3.issues);
90
+ })(r2)) return { values: {}, errors: s$1(s(r2.errors, !c.shouldUseNativeValidation && "all" === c.criteriaMode), c) };
91
+ throw r2;
92
+ }));
93
+ } catch (r2) {
94
+ return Promise.reject(r2);
95
+ }
96
+ };
97
+ if ((function(r2) {
98
+ return "_zod" in r2 && "object" == typeof r2._zod;
99
+ })(o$1)) return function(s2, c, f) {
100
+ try {
101
+ return Promise.resolve(t(function() {
102
+ return Promise.resolve(("sync" === u.mode ? n$1.parse : n$1.parseAsync)(o$1, s2, a2)).then(function(e) {
103
+ return f.shouldUseNativeValidation && o({}, f), { errors: {}, values: u.raw ? Object.assign({}, s2) : e };
104
+ });
105
+ }, function(r2) {
106
+ if ((function(r3) {
107
+ return r3 instanceof n$1.$ZodError;
108
+ })(r2)) return { values: {}, errors: s$1(i(r2.issues, !f.shouldUseNativeValidation && "all" === f.criteriaMode), f) };
109
+ throw r2;
110
+ }));
111
+ } catch (r2) {
112
+ return Promise.reject(r2);
113
+ }
114
+ };
115
+ throw new Error("Invalid input: not a Zod schema");
116
+ }
117
+ export {
118
+ a as zodResolver
119
+ };
@@ -1,3 +1,3 @@
1
- import { zodResolver } from "@hookform/resolvers/zod";
1
+ import { zodResolver } from '@hookform/resolvers/zod';
2
2
  export { zodResolver };
3
3
  //# sourceMappingURL=zodResolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zodResolver.d.ts","sourceRoot":"","sources":["../../../../pkg/form/src/zodResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGrD,OAAO,EAAC,WAAW,EAAC,CAAA"}
1
+ {"version":3,"file":"zodResolver.d.ts","sourceRoot":"","sources":["../src/zodResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGrD,OAAO,EAAC,WAAW,EAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/form",
3
- "version": "0.24.0",
3
+ "version": "0.26.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -14,12 +14,14 @@
14
14
  },
15
15
  "wireit": {
16
16
  "build": {
17
- "command": "node ../../scripts/build-package.js form",
17
+ "command": "../../node_modules/.bin/vite build",
18
18
  "files": [
19
19
  "src/**/*",
20
20
  "../../tsconfig.json",
21
- "../../tsconfig.base.json",
22
- "../../scripts/build-package.js"
21
+ "../../scripts/tsconfig.pkg.json",
22
+ "./tsconfig.json",
23
+ "./vite.config.ts",
24
+ "../../scripts/vite.config-pkg.js"
23
25
  ],
24
26
  "output": [
25
27
  "dist/"
@@ -1,2 +0,0 @@
1
- import { zodResolver } from "@hookform/resolvers/zod";
2
- export { zodResolver };