attaform 0.27.6 → 0.29.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/abstract.d.mts +5 -4
- package/dist/abstract.mjs +4 -3
- package/dist/chunks/fingerprint.mjs +1 -2
- package/dist/chunks/fingerprint2.mjs +2 -3
- package/dist/dev/abstract.mjs +4 -0
- package/dist/{chunks → dev/chunks}/dev-key-collision-warnings.mjs +0 -1
- package/dist/{chunks → dev/chunks}/devtools.mjs +5 -6
- package/dist/{chunks/fingerprint.cjs → dev/chunks/fingerprint.mjs} +7 -10
- package/dist/{chunks/fingerprint2.cjs → dev/chunks/fingerprint2.mjs} +32 -35
- package/dist/dev/directive.mjs +1 -0
- package/dist/dev/history.mjs +89 -0
- package/dist/dev/index.mjs +5 -0
- package/dist/dev/runtime/plugins/attaform.mjs +40 -0
- package/dist/dev/shared/attaform-dev.A-TpJW0B.mjs +207 -0
- package/dist/dev/shared/attaform-dev.BO-71R54.mjs +820 -0
- package/dist/{shared/attaform.D6tk90Rc.cjs → dev/shared/attaform-dev.BgM6FdtA.mjs} +324 -73
- package/dist/dev/shared/attaform-dev.ButTkwHd.mjs +375 -0
- package/dist/{shared/attaform.BJGA_UOS.mjs → dev/shared/attaform-dev.BxfsuwBR.mjs} +8 -1
- package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.D8aoKb89.mjs} +190 -400
- package/dist/dev/shared/attaform-dev.DD5m2W51.mjs +220 -0
- package/dist/{shared/attaform.CKH2lGdL.mjs → dev/shared/attaform-dev.DHuydLAC.mjs} +3867 -4731
- package/dist/{shared/attaform.DYEr28Pt.mjs → dev/shared/attaform-dev.DrzObAZo.mjs} +6 -7
- package/dist/{shared/attaform.B1ZYt2Li.mjs → dev/shared/attaform-dev.q6UutkCx.mjs} +274 -672
- package/dist/dev/zod-v3.mjs +17 -0
- package/dist/dev/zod-v4.mjs +16 -0
- package/dist/dev/zod.mjs +5 -0
- package/dist/directive.d.mts +20 -0
- package/dist/directive.mjs +1 -0
- package/dist/esbuild.mjs +0 -1
- package/dist/history.d.mts +59 -0
- package/dist/history.mjs +89 -0
- package/dist/index.d.mts +14 -6
- package/dist/index.mjs +5 -4
- package/dist/nuxt.d.mts +10 -10
- package/dist/nuxt.mjs +5 -2
- package/dist/rollup.mjs +0 -1
- package/dist/rspack.d.mts +6 -1
- package/dist/rspack.mjs +0 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +9 -8
- package/dist/runtime/plugins/attaform.mjs +1 -2
- package/dist/shared/{attaform.CoR4mWfv.mjs → attaform.B0dKL8ST.mjs} +309 -46
- package/dist/shared/{attaform.Cs2Rbdlo.mjs → attaform.BK0cgu2K.mjs} +123 -140
- package/dist/shared/{attaform.B9Wyhfro.cjs → attaform.BndjUUYX.mjs} +11 -16
- package/dist/shared/{attaform.CQN9R62B.cjs → attaform.BxfsuwBR.mjs} +9 -4
- package/dist/shared/attaform.C2MVyuxC.mjs +811 -0
- package/dist/shared/{attaform.Fp3sCrVs.d.ts → attaform.CIWLMY-R.d.mts} +2 -2
- package/dist/shared/attaform.CZMAYwSK.mjs +6383 -0
- package/dist/shared/attaform.CZYt_5N_.mjs +207 -0
- package/dist/shared/{attaform.DniawQLP.d.cts → attaform.CsoeRi3P.d.mts} +490 -98
- package/dist/shared/attaform.Cvao8bW5.mjs +358 -0
- package/dist/shared/attaform.D0x-qSXm.mjs +197 -0
- package/dist/shared/{attaform.D8kliaKw.cjs → attaform.D1fnTifF.mjs} +279 -692
- package/dist/shared/{attaform.CHlJLAiv.d.mts → attaform.DDtqHYv1.d.mts} +155 -184
- package/dist/shared/{attaform.Biytrv0-.cjs → attaform.DffRL5pP.mjs} +215 -547
- package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
- package/dist/shared/attaform.KvlEedlF.mjs +0 -1
- package/dist/shared/attaform.axHXVQO7.d.mts +44 -0
- package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
- package/dist/transforms.d.mts +0 -22
- package/dist/transforms.mjs +1 -2
- package/dist/vite.d.mts +30 -9
- package/dist/vite.mjs +27 -4
- package/dist/webpack.d.mts +6 -1
- package/dist/webpack.mjs +0 -1
- package/dist/zod-v3.d.mts +13 -6
- package/dist/zod-v3.mjs +17 -4
- package/dist/zod-v4.d.mts +19 -26
- package/dist/zod-v4.mjs +16 -4
- package/dist/zod.d.mts +4 -3
- package/dist/zod.mjs +5 -4
- package/package.json +38 -20
- package/skills/attaform/SKILL.md +6 -2
- package/skills/attaform/references/custom-components.md +7 -2
- package/skills/attaform/references/errors.md +8 -3
- package/skills/attaform/references/saving.md +77 -0
- package/skills/attaform/references/wizards.md +10 -8
- package/dist/abstract.cjs +0 -48
- package/dist/abstract.cjs.map +0 -1
- package/dist/abstract.d.cts +0 -42
- package/dist/abstract.d.ts +0 -42
- package/dist/abstract.mjs.map +0 -1
- package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
- package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
- package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
- package/dist/chunks/devtools.cjs +0 -157
- package/dist/chunks/devtools.cjs.map +0 -1
- package/dist/chunks/devtools.mjs.map +0 -1
- package/dist/chunks/fingerprint.cjs.map +0 -1
- package/dist/chunks/fingerprint.mjs.map +0 -1
- package/dist/chunks/fingerprint2.cjs.map +0 -1
- package/dist/chunks/fingerprint2.mjs.map +0 -1
- package/dist/esbuild.cjs +0 -28
- package/dist/esbuild.cjs.map +0 -1
- package/dist/esbuild.d.cts +0 -56
- package/dist/esbuild.d.ts +0 -56
- package/dist/esbuild.mjs.map +0 -1
- package/dist/index.cjs +0 -51
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -249
- package/dist/index.d.ts +0 -249
- package/dist/index.mjs.map +0 -1
- package/dist/nuxt.cjs +0 -84
- package/dist/nuxt.cjs.map +0 -1
- package/dist/nuxt.d.cts +0 -66
- package/dist/nuxt.d.ts +0 -66
- package/dist/nuxt.mjs.map +0 -1
- package/dist/rollup.cjs +0 -24
- package/dist/rollup.cjs.map +0 -1
- package/dist/rollup.d.cts +0 -35
- package/dist/rollup.d.ts +0 -35
- package/dist/rollup.mjs.map +0 -1
- package/dist/rspack.cjs +0 -10
- package/dist/rspack.cjs.map +0 -1
- package/dist/rspack.d.cts +0 -40
- package/dist/rspack.d.ts +0 -40
- package/dist/rspack.mjs.map +0 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
- package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
- package/dist/runtime/plugins/attaform.cjs +0 -43
- package/dist/runtime/plugins/attaform.cjs.map +0 -1
- package/dist/runtime/plugins/attaform.d.cts +0 -5
- package/dist/runtime/plugins/attaform.d.ts +0 -5
- package/dist/runtime/plugins/attaform.mjs.map +0 -1
- package/dist/shared/attaform.B1ZYt2Li.mjs.map +0 -1
- package/dist/shared/attaform.B9Wyhfro.cjs.map +0 -1
- package/dist/shared/attaform.BGDV42hI.d.cts +0 -232
- package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
- package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
- package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
- package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
- package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
- package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
- package/dist/shared/attaform.CKH2lGdL.mjs.map +0 -1
- package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
- package/dist/shared/attaform.CoR4mWfv.mjs.map +0 -1
- package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
- package/dist/shared/attaform.D6tk90Rc.cjs.map +0 -1
- package/dist/shared/attaform.D8kliaKw.cjs.map +0 -1
- package/dist/shared/attaform.DLknk9nF.d.mts +0 -232
- package/dist/shared/attaform.DMxM2kol.mjs +0 -1275
- package/dist/shared/attaform.DMxM2kol.mjs.map +0 -1
- package/dist/shared/attaform.DRUT703x.d.cts +0 -56
- package/dist/shared/attaform.DRUT703x.d.ts +0 -56
- package/dist/shared/attaform.DYEr28Pt.mjs.map +0 -1
- package/dist/shared/attaform.DdQN7sgN.cjs +0 -1302
- package/dist/shared/attaform.DdQN7sgN.cjs.map +0 -1
- package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
- package/dist/shared/attaform.DniawQLP.d.mts +0 -4763
- package/dist/shared/attaform.DniawQLP.d.ts +0 -4763
- package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
- package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
- package/dist/shared/attaform.DrvMscNX.cjs +0 -7697
- package/dist/shared/attaform.DrvMscNX.cjs.map +0 -1
- package/dist/shared/attaform.F2Q8iv38.d.ts +0 -2494
- package/dist/shared/attaform.FmqKO1Ex.d.cts +0 -2494
- package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
- package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
- package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
- package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
- package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
- package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
- package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
- package/dist/transforms.cjs +0 -12
- package/dist/transforms.cjs.map +0 -1
- package/dist/transforms.d.cts +0 -73
- package/dist/transforms.d.ts +0 -73
- package/dist/transforms.mjs.map +0 -1
- package/dist/vite.cjs +0 -363
- package/dist/vite.cjs.map +0 -1
- package/dist/vite.d.cts +0 -133
- package/dist/vite.d.ts +0 -133
- package/dist/vite.mjs.map +0 -1
- package/dist/webpack.cjs +0 -10
- package/dist/webpack.cjs.map +0 -1
- package/dist/webpack.d.cts +0 -37
- package/dist/webpack.d.ts +0 -37
- package/dist/webpack.mjs.map +0 -1
- package/dist/zod-v3.cjs +0 -53
- package/dist/zod-v3.cjs.map +0 -1
- package/dist/zod-v3.d.cts +0 -246
- package/dist/zod-v3.d.ts +0 -246
- package/dist/zod-v3.mjs.map +0 -1
- package/dist/zod-v4.cjs +0 -55
- package/dist/zod-v4.cjs.map +0 -1
- package/dist/zod-v4.d.cts +0 -172
- package/dist/zod-v4.d.ts +0 -172
- package/dist/zod-v4.mjs.map +0 -1
- package/dist/zod.cjs +0 -51
- package/dist/zod.cjs.map +0 -1
- package/dist/zod.d.cts +0 -7
- package/dist/zod.d.ts +0 -7
- package/dist/zod.mjs.map +0 -1
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm, s as FlatPath, B as NestedType, F as FormKey, U as UseFormConfiguration, A as AbstractSchema, aq as AcceptableDefaults, ae as ValidateOnConfig, a as UseFormReturnType } from './attaform.DniawQLP.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The Zod v4 schema roots `useForm` accepts. A fixed-shape
|
|
6
|
-
* `z.object({ … })` is the common case; `z.record(K, V)` admits a
|
|
7
|
-
* dictionary form (a homogeneous map with runtime-known keys);
|
|
8
|
-
* `z.discriminatedUnion(disc, [...])` admits a variant form (one of
|
|
9
|
-
* several object shapes, picked by a discriminator). Each projects to
|
|
10
|
-
* a `GenericForm`-shaped value the form engine drives: an object root
|
|
11
|
-
* descends into its fixed keys, a record root treats its entries as an
|
|
12
|
-
* open live-keyed container, a variant root lifts the active variant's
|
|
13
|
-
* keys into one addressable surface.
|
|
14
|
-
*
|
|
15
|
-
* Other roots (a bare `z.union`, a root `z.array`, primitives,
|
|
16
|
-
* `z.map` / `z.set`) are not form roots; wrap them under a key. The
|
|
17
|
-
* adapter's runtime construction rejects them with a legible error.
|
|
18
|
-
*
|
|
19
|
-
* `z.ZodObject` MUST keep its `z.ZodRawShape` argument, and the
|
|
20
|
-
* discriminated-union arm MUST stay fully applied. The unified entry's
|
|
21
|
-
* v4 overload constrains on `SupportedRootSchema & ZodV4Internals` to
|
|
22
|
-
* keep v3 schemas out (see `../unified/types-zod-major.ts`). In a
|
|
23
|
-
* single-major (v3-only) consumer install, the published `.d.mts`
|
|
24
|
-
* resolves this `z` to v3, where a bare or under-applied Zod class is
|
|
25
|
-
* missing its required arguments and degrades to an `any`-like error
|
|
26
|
-
* type; `any` then absorbs the union and `any & ZodV4Internals`
|
|
27
|
-
* collapses back to `any`, so the marker stops excluding v3 schemas and
|
|
28
|
-
* the read slot poisons to `never`. `z.ZodRecord` carries defaults for
|
|
29
|
-
* both arguments, so it stays concrete in either major.
|
|
30
|
-
* `z.ZodDiscriminatedUnion` does NOT (v3 requires both arguments, and
|
|
31
|
-
* its parameter order is the reverse of v4's), so the arm is written
|
|
32
|
-
* fully applied; the v3-only bundled-types fixture guards it.
|
|
33
|
-
*/
|
|
34
|
-
type SupportedRootSchema = z.ZodObject<z.ZodRawShape> | z.ZodRecord | z.ZodDiscriminatedUnion<readonly z.ZodObject<z.ZodRawShape>[], string>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The shape `form.values.<key>` returns at runtime.
|
|
38
|
-
*
|
|
39
|
-
* Per leaf:
|
|
40
|
-
*
|
|
41
|
-
* 1. Schema-side input normalizers — `z.preprocess(fn, inner)` AND
|
|
42
|
-
* `z.coerce.X()`. Zod v4 represents these differently
|
|
43
|
-
* (`ZodPipe<ZodTransform, inner>` for preprocess; a primitive
|
|
44
|
-
* with `def.coerce === true` for coerce), but they share the
|
|
45
|
-
* same type-level marker: `_zod.input` is `unknown`. The
|
|
46
|
-
* normalizer runs at parse time, NOT at the write boundary, so
|
|
47
|
-
* storage holds the consumer's raw input and the type collapses
|
|
48
|
-
* to `unknown` to match. Reach the typed value via
|
|
49
|
-
* `handleSubmit`, `validate`, or `validateAsync` — they re-parse
|
|
50
|
-
* storage through the wrapper.
|
|
51
|
-
*
|
|
52
|
-
* 2. `inner.transform(fn)` — compiles to `ZodPipe<inner, ZodTransform>`.
|
|
53
|
-
* Transforms fire at submit / validate, NOT at the write boundary,
|
|
54
|
-
* so storage holds whatever `inner` stores. Recurse `StorageShape`
|
|
55
|
-
* on `inner` so a defaulted leaf inside `inner` still reads `T`
|
|
56
|
-
* (not `T | undefined`).
|
|
57
|
-
*
|
|
58
|
-
* A bare top-level `ZodTransform` (no `in` schema) reads
|
|
59
|
-
* `_zod.input` directly — there's no inner to recurse into.
|
|
60
|
-
*
|
|
61
|
-
* 3. Codec / generic pipe — neither side is a transform. Read
|
|
62
|
-
* `_zod.output`. Codecs aren't write-boundary-synthesized, so the
|
|
63
|
-
* post-parse view is the only honest storage type.
|
|
64
|
-
*
|
|
65
|
-
* 4. Everything else (defaults, catch, readonly, optional, primitives,
|
|
66
|
-
* nested objects) — read `_zod.output`. Defaults and catches fire
|
|
67
|
-
* at parse time, so the post-init view is what storage holds.
|
|
68
|
-
* Nested objects delegate to Zod's own recursion on `_zod.output`,
|
|
69
|
-
* which peels nested defaults inside structural containers.
|
|
70
|
-
*
|
|
71
|
-
* Detection order: case 1 wins via the `_zod.input` IsUnknown check
|
|
72
|
-
* before the pipe/transform cascade fires, so wrapped variants like
|
|
73
|
-
* `z.coerce.number().optional()` (input = `unknown | undefined` →
|
|
74
|
-
* collapses to `unknown`) and `z.preprocess(fn, z.object(...))` (input
|
|
75
|
-
* = `unknown`) both land on `unknown` without descending. The IsAny
|
|
76
|
-
* filter keeps `z.any()` from being mistaken for coerce.
|
|
77
|
-
*
|
|
78
|
-
* Implementation note: direct `_zod` property access mirrors Zod's
|
|
79
|
-
* own `$InferObjectOutput` / `$InferObjectInput`, which read
|
|
80
|
-
* `T[k]['_zod']['output']` / `T[k]['_zod']['input']` directly rather
|
|
81
|
-
* than wrapping in the top-level `output<T>` / `input<T>` conditional.
|
|
82
|
-
* Wrapping per key spawns a fresh conditional instantiation for every
|
|
83
|
-
* key; Volar's web-worker checker collapses that per-key walk to
|
|
84
|
-
* `any` once the schema is non-trivial. Property access has no
|
|
85
|
-
* conditional and resolves cleanly under the same budget.
|
|
86
|
-
*
|
|
87
|
-
* Shape access also goes through `_zod.def.shape` rather than
|
|
88
|
-
* `infer Shape from z.ZodObject<Shape>` — the latter collapses to the
|
|
89
|
-
* `$ZodShape` upper bound in the same worker because of
|
|
90
|
-
* `z.ZodObject`'s `out Shape` covariance markers.
|
|
91
|
-
*/
|
|
92
|
-
type StorageShape<S> = S extends {
|
|
93
|
-
_zod: {
|
|
94
|
-
def: {
|
|
95
|
-
type: 'object';
|
|
96
|
-
shape: infer Shape;
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
} ? {
|
|
100
|
-
[K in keyof Shape]-?: StorageLeaf<Shape[K]>;
|
|
101
|
-
} : StorageLeaf<S>;
|
|
102
|
-
/**
|
|
103
|
-
* Detects a schema whose `_zod.input` is `unknown` — the marker both
|
|
104
|
-
* `z.preprocess(fn, _)` and `z.coerce.X()` share in Zod v4. Excludes
|
|
105
|
-
* `any` via the canonical `0 extends 1 & T` test so `z.any()` leaves
|
|
106
|
-
* fall through to the cascade below and keep their `any` typing.
|
|
107
|
-
*/
|
|
108
|
-
type InputIsUnknown<L> = L extends {
|
|
109
|
-
_zod: {
|
|
110
|
-
input: infer In;
|
|
111
|
-
};
|
|
112
|
-
} ? 0 extends 1 & In ? false : unknown extends In ? true : false : false;
|
|
113
|
-
/**
|
|
114
|
-
* Implementation-detail per-leaf branching for `StorageShape`.
|
|
115
|
-
* Exported so the bundled `.d.ts` carries a single alias body —
|
|
116
|
-
* every leaf of a Zod object schema otherwise re-emits the full
|
|
117
|
-
* pipe / transform / default conditional ladder, which compounds
|
|
118
|
-
* badly with multiple complex schemas in the same scope. Consumers
|
|
119
|
-
* should reach for `StorageShape` instead.
|
|
120
|
-
*/
|
|
121
|
-
type StorageLeaf<L> = InputIsUnknown<L> extends true ? unknown : L extends {
|
|
122
|
-
_zod: {
|
|
123
|
-
def: {
|
|
124
|
-
type: 'pipe';
|
|
125
|
-
in: infer A;
|
|
126
|
-
out: infer B;
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
} ? B extends {
|
|
130
|
-
_zod: {
|
|
131
|
-
def: {
|
|
132
|
-
type: 'transform';
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
} ? StorageShape<A> : L extends {
|
|
136
|
-
_zod: {
|
|
137
|
-
output: infer Out;
|
|
138
|
-
};
|
|
139
|
-
} ? Out : never : L extends {
|
|
140
|
-
_zod: {
|
|
141
|
-
def: {
|
|
142
|
-
type: 'transform';
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
} ? L extends {
|
|
146
|
-
_zod: {
|
|
147
|
-
input: infer In;
|
|
148
|
-
};
|
|
149
|
-
} ? In : never : L extends {
|
|
150
|
-
_zod: {
|
|
151
|
-
output: infer Out;
|
|
152
|
-
};
|
|
153
|
-
} ? Out : never;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Zod v4 adapter entry point. Re-exports the adapter + the useForm
|
|
157
|
-
* wrapper that threads zod-v4-specific schema types through
|
|
158
|
-
* useAbstractForm.
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Type of the value accepted at `Path` for `setValue` / `defaultValues`
|
|
163
|
-
* — the schema's `z.input<Schema>` shape at that path. Matches what
|
|
164
|
-
* `form.values.X` returns at runtime (the honest input view storage
|
|
165
|
-
* holds before transforms run).
|
|
166
|
-
*
|
|
167
|
-
* ```ts
|
|
168
|
-
* const schema = z.object({
|
|
169
|
-
* flag: z.string().transform((v) => v.length > 10),
|
|
170
|
-
* })
|
|
171
|
-
* type FlagWriteIn = PathInput<typeof schema, 'flag'> // string
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
type PathInput<Schema extends z.ZodType, Path extends string> = z.input<Schema> extends GenericForm ? Path extends FlatPath<z.input<Schema>> ? NestedType<z.input<Schema>, Path> : never : never;
|
|
175
|
-
/**
|
|
176
|
-
* Type produced at `Path` after the full parse pipeline — the schema's
|
|
177
|
-
* `z.output<Schema>` shape at that path. Matches the `data` payload of
|
|
178
|
-
* `form.parse()` and the value handed to `handleSubmit`'s callback.
|
|
179
|
-
*
|
|
180
|
-
* ```ts
|
|
181
|
-
* const schema = z.object({
|
|
182
|
-
* flag: z.string().transform((v) => v.length > 10),
|
|
183
|
-
* })
|
|
184
|
-
* type FlagParsedOut = PathOutput<typeof schema, 'flag'> // boolean
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
type PathOutput<Schema extends z.ZodType, Path extends string> = z.output<Schema> extends GenericForm ? Path extends FlatPath<z.output<Schema>> ? NestedType<z.output<Schema>, Path> : never : never;
|
|
188
|
-
/**
|
|
189
|
-
* Create a form bound to a Zod v4 schema.
|
|
190
|
-
*
|
|
191
|
-
* ```ts
|
|
192
|
-
* import { useForm } from 'attaform/zod'
|
|
193
|
-
* import { z } from 'zod'
|
|
194
|
-
*
|
|
195
|
-
* const form = useForm({
|
|
196
|
-
* schema: z.object({
|
|
197
|
-
* email: z.email(),
|
|
198
|
-
* password: z.string().min(8),
|
|
199
|
-
* }),
|
|
200
|
-
* defaultValues: { email: '' },
|
|
201
|
-
* })
|
|
202
|
-
* ```
|
|
203
|
-
*
|
|
204
|
-
* Returns a form API exposing `register`, `values`, `errors`,
|
|
205
|
-
* `fields`, `setValue`, `handleSubmit`, `meta`, field-array
|
|
206
|
-
* helpers, and more. See `UseFormReturnType` for the full
|
|
207
|
-
* surface.
|
|
208
|
-
*
|
|
209
|
-
* For Zod v3, import from `attaform/zod-v3` instead.
|
|
210
|
-
*/
|
|
211
|
-
/**
|
|
212
|
-
* `FormOf` / `OutOf` / `ReadOf` factor the three identical-shape
|
|
213
|
-
* conditionals out of `useForm`'s public signature. The bundled
|
|
214
|
-
* `.d.ts` then carries one alias per shape rather than re-inlining
|
|
215
|
-
* `z.input<Schema> extends GenericForm ? z.input<Schema> : never`
|
|
216
|
-
* four times — which is what produces TS2589 ("Type instantiation
|
|
217
|
-
* is excessively deep") on consumer call sites with complex schemas
|
|
218
|
-
* (discriminated unions, transform pipes, deep `.register()` chains).
|
|
219
|
-
* Each alias is computed once per `Schema` instantiation; downstream
|
|
220
|
-
* generics ride on the alias rather than re-evaluating the
|
|
221
|
-
* conditional from scratch.
|
|
222
|
-
*/
|
|
223
|
-
type FormOf<Schema extends SupportedRootSchema> = z.input<Schema> extends GenericForm ? z.input<Schema> : never;
|
|
224
|
-
type OutOf<Schema extends SupportedRootSchema> = z.output<Schema> extends GenericForm ? z.output<Schema> : never;
|
|
225
|
-
type ReadOf<Schema extends SupportedRootSchema> = StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never;
|
|
226
|
-
declare function useForm<Schema extends SupportedRootSchema, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<FormOf<Schema>, OutOf<Schema>, AbstractSchema<FormOf<Schema>, OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
|
|
227
|
-
schema: Schema;
|
|
228
|
-
defaultValues?: AcceptableDefaults<FormOf<Schema>, z.input<Schema>>;
|
|
229
|
-
} & ValidateOnConfig): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K>;
|
|
230
|
-
|
|
231
|
-
export { useForm as u };
|
|
232
|
-
export type { PathInput as P, SupportedRootSchema as S, PathOutput as a, StorageShape as b };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attaform.BJGA_UOS.mjs","sources":["../../src/runtime/core/canonical-stringify.ts"],"sourcesContent":["/**\n * Canonical stringify for arbitrary values, shared by the v3 and v4\n * schema fingerprint walkers. Produces a stable string surface for\n * structural equality testing: object keys are sorted, arrays walk in\n * index order, and functions / symbols / cycles collapse to opaque\n * sentinels.\n *\n * This is NOT JSON. The output is not meant to round-trip through\n * `JSON.parse`; it exists purely so two structurally-equal values\n * serialise to the same string and two structurally-different values\n * do not.\n *\n * Cycle detection uses an ancestor-stack add / delete pattern: a\n * reference is only treated as cyclic while it sits on the path from\n * the root being stringified. Without the `delete` on the way back up,\n * two sibling properties pointing at the same object would see the\n * second one falsely labelled `<cyclic>`.\n */\nexport function canonicalStringify(value: unknown, seen: WeakSet<object> = new WeakSet()): string {\n if (value === null) return 'null'\n if (value === undefined) return 'undefined'\n const t = typeof value\n if (t === 'string') return JSON.stringify(value)\n if (t === 'number' || t === 'boolean') return String(value)\n if (t === 'bigint') return `${String(value)}n`\n if (t === 'function') return 'fn:*'\n if (t === 'symbol') return 'symbol:*'\n if (Array.isArray(value)) {\n if (seen.has(value)) return '<cyclic>'\n seen.add(value)\n try {\n const parts = value.map((v) => canonicalStringify(v, seen))\n return `[${parts.join(',')}]`\n } finally {\n seen.delete(value)\n }\n }\n if (t === 'object') {\n // `null` already returned above, so the remaining `object` branch is\n // non-null; narrowing against null again is redundant (eslint's\n // no-unnecessary-condition rule flags it).\n const obj = value as Record<string, unknown>\n if (seen.has(obj)) return '<cyclic>'\n seen.add(obj)\n try {\n if (value instanceof Date) return `date:${value.getTime()}`\n if (value instanceof RegExp) return `regex:${String(value)}`\n const entries = Object.entries(obj)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([k, v]) => `${JSON.stringify(k)}:${canonicalStringify(v, seen)}`)\n return `{${entries.join(',')}}`\n } finally {\n seen.delete(obj)\n }\n }\n return 'unknown'\n}\n"],"names":[],"mappings":"AAkBO,SAAS,kBAAA,CAAmB,KAAA,EAAgB,IAAA,mBAAwB,IAAI,SAAQ,EAAW;AAChG,EAAA,IAAI,KAAA,KAAU,MAAM,OAAO,MAAA;AAC3B,EAAA,IAAI,KAAA,KAAU,QAAW,OAAO,WAAA;AAChC,EAAA,MAAM,IAAI,OAAO,KAAA;AACjB,EAAA,IAAI,CAAA,KAAM,QAAA,EAAU,OAAO,IAAA,CAAK,UAAU,KAAK,CAAA;AAC/C,EAAA,IAAI,MAAM,QAAA,IAAY,CAAA,KAAM,SAAA,EAAW,OAAO,OAAO,KAAK,CAAA;AAC1D,EAAA,IAAI,MAAM,QAAA,EAAU,OAAO,CAAA,EAAG,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA,CAAA;AAC3C,EAAA,IAAI,CAAA,KAAM,YAAY,OAAO,MAAA;AAC7B,EAAA,IAAI,CAAA,KAAM,UAAU,OAAO,UAAA;AAC3B,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,IAAI,IAAA,CAAK,GAAA,CAAI,KAAK,CAAA,EAAG,OAAO,UAAA;AAC5B,IAAA,IAAA,CAAK,IAAI,KAAK,CAAA;AACd,IAAA,IAAI;AACF,MAAA,MAAM,KAAA,GAAQ,MAAM,GAAA,CAAI,CAAC,MAAM,kBAAA,CAAmB,CAAA,EAAG,IAAI,CAAC,CAAA;AAC1D,MAAA,OAAO,CAAA,CAAA,EAAI,KAAA,CAAM,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAA,IAC5B,CAAA,SAAE;AACA,MAAA,IAAA,CAAK,OAAO,KAAK,CAAA;AAAA,IACnB;AAAA,EACF;AACA,EAAA,IAAI,MAAM,QAAA,EAAU;AAIlB,IAAA,MAAM,GAAA,GAAM,KAAA;AACZ,IAAA,IAAI,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA,EAAG,OAAO,UAAA;AAC1B,IAAA,IAAA,CAAK,IAAI,GAAG,CAAA;AACZ,IAAA,IAAI;AACF,MAAA,IAAI,iBAAiB,IAAA,EAAM,OAAO,CAAA,KAAA,EAAQ,KAAA,CAAM,SAAS,CAAA,CAAA;AACzD,MAAA,IAAI,iBAAiB,MAAA,EAAQ,OAAO,CAAA,MAAA,EAAS,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA;AAC1D,MAAA,MAAM,UAAU,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA,CAC/B,KAAK,CAAC,CAAC,CAAC,CAAA,EAAG,CAAC,CAAC,CAAA,KAAO,CAAA,GAAI,CAAA,GAAI,KAAK,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI,CAAE,EAC/C,GAAA,CAAI,CAAC,CAAC,CAAA,EAAG,CAAC,CAAA,KAAM,CAAA,EAAG,IAAA,CAAK,SAAA,CAAU,CAAC,CAAC,CAAA,CAAA,EAAI,mBAAmB,CAAA,EAAG,IAAI,CAAC,CAAA,CAAE,CAAA;AACxE,MAAA,OAAO,CAAA,CAAA,EAAI,OAAA,CAAQ,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAA,IAC9B,CAAA,SAAE;AACA,MAAA,IAAA,CAAK,OAAO,GAAG,CAAA;AAAA,IACjB;AAAA,EACF;AACA,EAAA,OAAO,SAAA;AACT;;;;"}
|