attaform 0.30.0 → 0.30.1
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 +15 -21
- package/dist/abstract.mjs +2 -2
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/devtools.mjs +2 -2
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +1 -1
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +1 -1
- package/dist/dev/shared/{attaform-dev.BK6Ge2qR.mjs → attaform-dev.BJK1kqHY.mjs} +14 -14
- package/dist/dev/shared/{attaform-dev.D6CLvaQT.mjs → attaform-dev.BMQ3GcgD.mjs} +46 -59
- package/dist/dev/shared/{attaform-dev.BisFstxh.mjs → attaform-dev.BUIFcTYf.mjs} +6 -6
- package/dist/dev/shared/{attaform-dev.DTrHonpc.mjs → attaform-dev.CT7MDjPy.mjs} +27 -36
- package/dist/dev/shared/{attaform-dev.BcYT6tFh.mjs → attaform-dev.CZz4GYZ6.mjs} +21 -9
- package/dist/dev/shared/{attaform-dev.DUZckyV8.mjs → attaform-dev.Chm4D6SJ.mjs} +2 -2
- package/dist/dev/shared/{attaform-dev.BcNtyOmf.mjs → attaform-dev.DuEE4GU1.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.CQ2rJiAX.mjs → attaform-dev.DxHdkkPG.mjs} +126 -115
- package/dist/dev/shared/{attaform-dev.BQc5QV3Y.mjs → attaform-dev.zlvDr0WB.mjs} +2 -2
- package/dist/dev/zod-v3.mjs +6 -6
- package/dist/dev/zod-v4.mjs +6 -6
- package/dist/dev/zod.mjs +5 -5
- package/dist/directive.d.mts +4 -4
- package/dist/directive.mjs +1 -1
- package/dist/esbuild.d.mts +11 -0
- package/dist/esbuild.mjs +1 -1
- package/dist/history.d.mts +3 -32
- package/dist/history.mjs +1 -1
- package/dist/index.d.mts +67 -70
- package/dist/index.mjs +3 -3
- package/dist/nuxt.d.mts +4 -3
- package/dist/nuxt.mjs +3 -6
- package/dist/rollup.d.mts +11 -0
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.d.mts +19 -11
- package/dist/rspack.mjs +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +12 -12
- package/dist/runtime/components/DevtoolsValueTree.vue +2 -2
- package/dist/shared/{attaform.Rc9u4Vfw.d.mts → attaform.2FslhB9R.d.mts} +83 -95
- package/dist/shared/{attaform.BRDDQeHV.mjs → attaform.8mfKZCwH.mjs} +2 -2
- package/dist/shared/{attaform.DRUT703x.d.mts → attaform.B-Tb62qV.d.mts} +12 -12
- package/dist/shared/{attaform.v0fQtWyA.mjs → attaform.B1rH9ht6.mjs} +1 -1
- package/dist/shared/{attaform.ByWP6kSx.mjs → attaform.B2iebkPA.mjs} +3 -3
- package/dist/shared/{attaform.DhnPb6nK.mjs → attaform.BAf3UNn4.mjs} +1 -1
- package/dist/shared/{attaform.DNJOWjQw.mjs → attaform.BIWicztt.mjs} +102 -100
- package/dist/shared/attaform.BcQwgWaq.d.mts +2153 -0
- package/dist/shared/attaform.Br8EBn5B.d.mts +4553 -0
- package/dist/shared/{attaform.BXneBxEj.mjs → attaform.CO918TdU.mjs} +13 -13
- package/dist/shared/{attaform.CUfrMK7t.mjs → attaform.DRsANMok.mjs} +5 -5
- package/dist/shared/{attaform.B3resMQ1.mjs → attaform.D_f1WgYf.mjs} +40 -53
- package/dist/shared/{attaform.CJ8DpRGj.mjs → attaform.D_pt1gOj.mjs} +26 -33
- package/dist/shared/attaform.L0kUn3vL.d.mts +42 -0
- package/dist/shared/{attaform.BK0cgu2K.mjs → attaform.ZYn2ahzJ.mjs} +3 -3
- package/dist/transforms.d.mts +153 -26
- package/dist/transforms.mjs +1 -1
- package/dist/vite.d.mts +29 -52
- package/dist/vite.mjs +3 -3
- package/dist/webpack.d.mts +20 -12
- package/dist/webpack.mjs +1 -1
- package/dist/zod-v3.d.mts +90 -96
- package/dist/zod-v3.mjs +4 -4
- package/dist/zod-v4.d.mts +118 -118
- package/dist/zod-v4.mjs +4 -4
- package/dist/zod.d.mts +5 -5
- package/dist/zod.mjs +3 -3
- package/package.json +7 -6
- package/dist/shared/attaform.Clz0ArIi.d.mts +0 -44
- package/dist/shared/attaform.UGyOK83T.d.mts +0 -2366
- package/dist/shared/attaform.bKLzMU0o.d.mts +0 -4761
package/dist/vite.d.mts
CHANGED
|
@@ -28,9 +28,9 @@ import { Plugin } from 'vite';
|
|
|
28
28
|
* can be called at all.
|
|
29
29
|
*
|
|
30
30
|
* Deliberately absent (reach for these with an explicit import):
|
|
31
|
-
* - `useAbstractForm
|
|
32
|
-
* `attaform/abstract
|
|
33
|
-
* - `createAttaform
|
|
31
|
+
* - `useAbstractForm`, the schema-agnostic escape hatch on
|
|
32
|
+
* `attaform/abstract`: an advanced surface, not the default form.
|
|
33
|
+
* - `createAttaform`, the plugin install, a setup-level one-liner that
|
|
34
34
|
* belongs beside the app bootstrap, not in every component's scope.
|
|
35
35
|
* - `unset` / `isUnset` and the serialize helpers: plain values and
|
|
36
36
|
* functions with no component affinity, equally at home in a store, a
|
|
@@ -63,41 +63,14 @@ declare const attaformAutoImports: AttaformAutoImport[];
|
|
|
63
63
|
declare const attaformAutoImportsMap: Record<string, string[]>;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* `attaform/vite
|
|
67
|
-
*
|
|
68
|
-
* compiled template that uses it (so no app-level directive
|
|
69
|
-
* registration exists or is needed), AND rewrites `attaform` and
|
|
70
|
-
* `attaform/zod` imports to either `attaform/zod-v3` or `attaform/zod-v4`
|
|
71
|
-
* at build time, based on the consumer's installed Zod major. The result
|
|
72
|
-
* is one Zod adapter shipped per bundle, with no manual subpath choice.
|
|
66
|
+
* `attaform/vite`, the Vite plugin. See {@link attaform} for what it
|
|
67
|
+
* does and how to register it.
|
|
73
68
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* export default defineConfig({
|
|
81
|
-
* plugins: [vue(), attaform()],
|
|
82
|
-
* })
|
|
83
|
-
*
|
|
84
|
-
* The transforms inject `:value`, `:checked`, and `:selected` bindings
|
|
85
|
-
* into elements that use the `v-register` directive — load-bearing for
|
|
86
|
-
* SSR initial-render correctness. Omitting this plugin under CSR is
|
|
87
|
-
* tolerable (one-frame flash on mount); omitting it under SSR produces
|
|
88
|
-
* visibly wrong initial HTML.
|
|
89
|
-
*
|
|
90
|
-
* The `resolveZodAlias` option (default `true`) controls the build-time
|
|
91
|
-
* rewrite of `attaform` / `attaform/zod`. Set to `false` if your project
|
|
92
|
-
* intentionally mixes Zod versions or has a non-standard Zod resolution;
|
|
93
|
-
* the unified entry's runtime dispatch covers that case at the cost of
|
|
94
|
-
* bundling both adapters.
|
|
95
|
-
*
|
|
96
|
-
* Implementation note: this plugin mutates @vitejs/plugin-vue's options
|
|
97
|
-
* via the documented but somewhat informal `api.options` surface used
|
|
98
|
-
* by VueUse, Vite PWA, and other Vue ecosystem plugins. If you're
|
|
99
|
-
* using a custom Vue plugin wrapper, fall back to `attaform/transforms`
|
|
100
|
-
* and wire them yourself.
|
|
69
|
+
* It mutates @vitejs/plugin-vue's options through the documented but
|
|
70
|
+
* somewhat informal `api.options` surface that VueUse, Vite PWA and
|
|
71
|
+
* other Vue ecosystem plugins also use. Behind a custom Vue plugin
|
|
72
|
+
* wrapper, fall back to `attaform/transforms` and wire the transforms
|
|
73
|
+
* yourself.
|
|
101
74
|
*/
|
|
102
75
|
|
|
103
76
|
/** Options for `attaform()`. */
|
|
@@ -105,8 +78,8 @@ interface AttaformVitePluginOptions {
|
|
|
105
78
|
/**
|
|
106
79
|
* Rewrite `attaform` and `attaform/zod` imports at build time to
|
|
107
80
|
* either `attaform/zod-v3` or `attaform/zod-v4`, based on the
|
|
108
|
-
* consumer's installed Zod major. Default `true
|
|
109
|
-
* bundle for the common case of one Zod version per project.
|
|
81
|
+
* consumer's installed Zod major. Default `true`, which produces a
|
|
82
|
+
* leaner bundle for the common case of one Zod version per project.
|
|
110
83
|
*
|
|
111
84
|
* Set to `false` to fall through to the unified entry's runtime
|
|
112
85
|
* dispatch. Useful when:
|
|
@@ -120,12 +93,10 @@ interface AttaformVitePluginOptions {
|
|
|
120
93
|
resolveZodAlias?: boolean;
|
|
121
94
|
}
|
|
122
95
|
/**
|
|
123
|
-
* Vite plugin that wires
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* matching adapter subpath. Required for SSR and for hydration
|
|
128
|
-
* accuracy under bare Vue 3.
|
|
96
|
+
* Vite plugin that wires Attaform's compile-time template transforms
|
|
97
|
+
* into `@vitejs/plugin-vue`, binds `v-register` into each compiled
|
|
98
|
+
* template that uses it, and rewrites the bare `attaform` barrel and
|
|
99
|
+
* the unified `attaform/zod` import to the matching adapter subpath.
|
|
129
100
|
*
|
|
130
101
|
* ```ts
|
|
131
102
|
* // vite.config.ts
|
|
@@ -137,14 +108,20 @@ interface AttaformVitePluginOptions {
|
|
|
137
108
|
* })
|
|
138
109
|
* ```
|
|
139
110
|
*
|
|
140
|
-
* Place the call after `vue()
|
|
141
|
-
*
|
|
111
|
+
* Place the call after `vue()`. Nuxt projects do not need it;
|
|
112
|
+
* `attaform/nuxt` handles this.
|
|
113
|
+
*
|
|
114
|
+
* The transforms inject `:value`, `:checked` and `:selected` onto
|
|
115
|
+
* elements using `v-register`, which is load-bearing for SSR
|
|
116
|
+
* initial-render correctness. Omitting the plugin under CSR costs a
|
|
117
|
+
* one-frame flash on mount; omitting it under SSR produces visibly
|
|
118
|
+
* wrong initial HTML.
|
|
142
119
|
*
|
|
143
|
-
* Returns a two-plugin array
|
|
144
|
-
* main pre-plugin
|
|
145
|
-
*
|
|
146
|
-
* `attaform/directive`.
|
|
147
|
-
* registration
|
|
120
|
+
* Returns a two-plugin array, since Vite flattens nested plugin arrays:
|
|
121
|
+
* the main pre-plugin, plus a post-plugin rewriting each compiled SFC's
|
|
122
|
+
* `resolveDirective("register")` to a static import from
|
|
123
|
+
* `attaform/directive`. That rewrite is why no app-level directive
|
|
124
|
+
* registration is needed here; see
|
|
148
125
|
* `runtime/lib/core/transforms/directive-delivery-transform.ts` for the
|
|
149
126
|
* mechanism and its scope.
|
|
150
127
|
*/
|
package/dist/vite.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as resolveZodAliasTarget, i as isRewritableZodSpecifier } from './shared/attaform.
|
|
2
|
-
import { a as vRegisterPreambleTransform, r as redundantBindingWarnTransform, c as componentBridgeTransform, i as inputTextAreaNodeTransform, v as vRegisterHintTransform } from './shared/attaform.
|
|
1
|
+
import { r as resolveZodAliasTarget, i as isRewritableZodSpecifier } from './shared/attaform.BAf3UNn4.mjs';
|
|
2
|
+
import { a as vRegisterPreambleTransform, r as redundantBindingWarnTransform, c as componentBridgeTransform, i as inputTextAreaNodeTransform, v as vRegisterHintTransform } from './shared/attaform.ZYn2ahzJ.mjs';
|
|
3
3
|
import { parse, babelParse } from '@vue/compiler-sfc';
|
|
4
4
|
import { NodeTypes } from '@vue/compiler-core';
|
|
5
5
|
|
|
@@ -308,7 +308,7 @@ function attaform(options = {}) {
|
|
|
308
308
|
|
|
309
309
|
// The panel runs inside Nuxt DevTools' overlay iframe, which itself
|
|
310
310
|
// is nested in the consumer's main page. \`window.parent\` only
|
|
311
|
-
// crosses one frame boundary
|
|
311
|
+
// crosses one frame boundary (the overlay UI), which doesn't have
|
|
312
312
|
// the bridge attached. The bridge lives on the consumer's main
|
|
313
313
|
// page, which sits at the top of the frame hierarchy. Walk the
|
|
314
314
|
// chain checking each ancestor frame so the same code works whether
|
package/dist/webpack.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { W as WebpackFamilyPlugin, a as WebpackFamilyPluginOptions } from './shared/attaform.C9fPTxjB.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* `attaform/webpack
|
|
4
|
+
* `attaform/webpack`, the webpack plugin that rewrites `attaform/zod`
|
|
5
5
|
* imports to the single matching adapter subpath (`attaform/zod-v3` or
|
|
6
6
|
* `attaform/zod-v4`) at build time, based on the consumer's installed Zod
|
|
7
7
|
* major. Without it, webpack ships both adapters because the unified
|
|
8
8
|
* `attaform/zod` entry imports both for runtime dispatch.
|
|
9
9
|
*
|
|
10
|
-
* Usage
|
|
10
|
+
* Usage, in an ESM config, since the plugin is ESM-only like the rest of
|
|
11
|
+
* the package:
|
|
11
12
|
*
|
|
12
13
|
* // webpack.config.mjs
|
|
13
14
|
* import { attaform } from 'attaform/webpack'
|
|
@@ -16,16 +17,12 @@ import { W as WebpackFamilyPlugin, a as WebpackFamilyPluginOptions } from './sha
|
|
|
16
17
|
* plugins: [attaform()],
|
|
17
18
|
* }
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* that pipeline register it once per app:
|
|
26
|
-
*
|
|
27
|
-
* import { installVRegister } from 'attaform/directive'
|
|
28
|
-
* installVRegister(app)
|
|
20
|
+
* The adapter rewrite is all this plugin does. Two things
|
|
21
|
+
* `attaform/vite` also provides do NOT transfer, because both are
|
|
22
|
+
* `@vitejs/plugin-vue`-specific: wire `attaform/transforms` into your
|
|
23
|
+
* Vue compiler for the SSR-critical template transforms, and register
|
|
24
|
+
* the directive once per app with `installVRegister(app)` from
|
|
25
|
+
* `attaform/directive`.
|
|
29
26
|
*
|
|
30
27
|
* Zero-dep: the plugin imports nothing from `webpack` (it taps the resolve
|
|
31
28
|
* hook the compiler injects at the consumer's build). Shares its body with
|
|
@@ -36,6 +33,17 @@ import { W as WebpackFamilyPlugin, a as WebpackFamilyPluginOptions } from './sha
|
|
|
36
33
|
type AttaformWebpackPluginOptions = WebpackFamilyPluginOptions;
|
|
37
34
|
/** The structural shape webpack requires of the plugin. */
|
|
38
35
|
type AttaformWebpackPlugin = WebpackFamilyPlugin;
|
|
36
|
+
/**
|
|
37
|
+
* webpack plugin that resolves `attaform/zod` to the one adapter subpath
|
|
38
|
+
* matching the installed Zod major, so the build ships a single adapter
|
|
39
|
+
* instead of both.
|
|
40
|
+
*
|
|
41
|
+
* ```js
|
|
42
|
+
* const { attaform } = require('attaform/webpack')
|
|
43
|
+
*
|
|
44
|
+
* module.exports = { plugins: [attaform()] }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
39
47
|
declare function attaform(options?: AttaformWebpackPluginOptions): AttaformWebpackPlugin;
|
|
40
48
|
|
|
41
49
|
export { attaform };
|
package/dist/webpack.mjs
CHANGED
package/dist/zod-v3.d.mts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, aq as AcceptableDefaults, a as UseFormReturnType, ac as ValidateOnConfig, ap as SchemaFactoryOptions, h as FieldMetaPayload } from './shared/attaform.
|
|
2
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, aq as AcceptableDefaults, a as UseFormReturnType, ac as ValidateOnConfig, ap as SchemaFactoryOptions, h as FieldMetaPayload } from './shared/attaform.Br8EBn5B.mjs';
|
|
3
3
|
import { AbstractSchema } from './abstract.mjs';
|
|
4
|
-
export { b as ArrayItem, c as ArrayPath, C as CustomDirectiveRegisterAssignerFn, d as DeepPartial, D as DefaultValuesInput, e as DefaultValuesShape, f as DisplayState, E as ErrorInput, g as ErrorsProxyShape, i as FieldState, j as FieldStateMap, k as FieldStateMapEntry, l as FlatPath, m as FormErrorRecord, n as FormErrorsSurface, o as FormMeta, H as HandleSubmit, p as HistoryPlugin, I as IsTuple, q as IsUnion, J as JoinSegments, r as Json, K as KeyofUnion, L as LiftedValueShape, M as MetaTrackerValue, N as NestedReadType, s as NestedType, O as OnError, t as OnSubmit, P as ParseOptions, u as PartialFlatPath, v as Path, w as PathKey, x as PendingValidationStatus, y as Primitive, R as ROOT_PATH, z as ROOT_PATH_KEY, B as ReactiveValidationStatus, Q as RecordPath, S as RecordValue, T as RegisterDirective, V as RegisterFlatPath, W as RegisterOptions, X as RegisterSelectModifier, Y as RegisterTextModifier, Z as RegisterTransform, _ as RegisterValue, $ as SchemaDefaultsResult, a0 as SchemaParseErrorWithData, a1 as SchemaParseErrorWithoutData, a2 as SchemaParseResult, a3 as SchemaParseSuccess, a4 as Segment, a5 as SetValueCallback, a6 as SetValuePayload, a7 as SettledValidationStatus, a8 as SlimPrimitiveKind, a9 as SubmitHandler, aa as Unset, ab as ValidateOn, ad as ValidationError, ae as ValidationResponse, af as ValidationResponseWithoutValue, ag as ValueOfUnion, ah as WriteMeta, ai as WriteShape, aj as canonicalizePath, ak as isPathPrefix, al as isUnset, am as parseDottedPath, an as unset } from './shared/attaform.
|
|
5
|
-
import { S as SupportedRootSchema, U as UnwrapZodRoot, a as StorageShape } from './shared/attaform.
|
|
6
|
-
export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as DEVTOOLS_WINDOW_KEY, F as FormStatus, f as FormStatusSeed, G as GateMarker, I as InjectWizardInput, g as InvalidPathError, h as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, i as ReservedFormKeyError, S as SerializedAttaformState, j as SerializedFormData, k as StepSlot, l as SubmitErrorHandlerError, U as UseRegisterOptions, m as UseRegisterReturn, n as UseWizardReturnType, W as WizardAggregateError, o as WizardCtx, p as WizardCtxForm, q as WizardOnError, r as WizardOnSubmit, s as WizardOptions, t as WizardPersistFn, u as WizardRestoreFn, v as WizardRestoreState, w as WizardStatusesProxy, x as WizardSubmitContext, y as assignKey, z as createAttaform, B as createRegistry, E as escapeForInlineScript, H as gate, J as getRegistryFromApp, K as hydrateAttaformState, M as injectForm, N as injectWizard, P as isRegisterValue, Q as kAttaformRegistry, T as lazy, V as renderAttaformState, X as useRegister, Y as useRegistry, Z as useWizard } from './shared/attaform.
|
|
7
|
-
export { v as vRegister } from './shared/attaform.
|
|
4
|
+
export { b as ArrayItem, c as ArrayPath, C as CustomDirectiveRegisterAssignerFn, d as DeepPartial, D as DefaultValuesInput, e as DefaultValuesShape, f as DisplayState, E as ErrorInput, g as ErrorsProxyShape, i as FieldState, j as FieldStateMap, k as FieldStateMapEntry, l as FlatPath, m as FormErrorRecord, n as FormErrorsSurface, o as FormMeta, H as HandleSubmit, p as HistoryPlugin, I as IsTuple, q as IsUnion, J as JoinSegments, r as Json, K as KeyofUnion, L as LiftedValueShape, M as MetaTrackerValue, N as NestedReadType, s as NestedType, O as OnError, t as OnSubmit, P as ParseOptions, u as PartialFlatPath, v as Path, w as PathKey, x as PendingValidationStatus, y as Primitive, R as ROOT_PATH, z as ROOT_PATH_KEY, B as ReactiveValidationStatus, Q as RecordPath, S as RecordValue, T as RegisterDirective, V as RegisterFlatPath, W as RegisterOptions, X as RegisterSelectModifier, Y as RegisterTextModifier, Z as RegisterTransform, _ as RegisterValue, $ as SchemaDefaultsResult, a0 as SchemaParseErrorWithData, a1 as SchemaParseErrorWithoutData, a2 as SchemaParseResult, a3 as SchemaParseSuccess, a4 as Segment, a5 as SetValueCallback, a6 as SetValuePayload, a7 as SettledValidationStatus, a8 as SlimPrimitiveKind, a9 as SubmitHandler, aa as Unset, ab as ValidateOn, ad as ValidationError, ae as ValidationResponse, af as ValidationResponseWithoutValue, ag as ValueOfUnion, ah as WriteMeta, ai as WriteShape, aj as canonicalizePath, ak as isPathPrefix, al as isUnset, am as parseDottedPath, an as unset } from './shared/attaform.Br8EBn5B.mjs';
|
|
5
|
+
import { S as SupportedRootSchema, U as UnwrapZodRoot, a as StorageShape } from './shared/attaform.B-Tb62qV.mjs';
|
|
6
|
+
export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as DEVTOOLS_WINDOW_KEY, F as FormStatus, f as FormStatusSeed, G as GateMarker, I as InjectWizardInput, g as InvalidPathError, h as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, i as ReservedFormKeyError, S as SerializedAttaformState, j as SerializedFormData, k as StepSlot, l as SubmitErrorHandlerError, U as UseRegisterOptions, m as UseRegisterReturn, n as UseWizardReturnType, W as WizardAggregateError, o as WizardCtx, p as WizardCtxForm, q as WizardOnError, r as WizardOnSubmit, s as WizardOptions, t as WizardPersistFn, u as WizardRestoreFn, v as WizardRestoreState, w as WizardStatusesProxy, x as WizardSubmitContext, y as assignKey, z as createAttaform, B as createRegistry, E as escapeForInlineScript, H as gate, J as getRegistryFromApp, K as hydrateAttaformState, M as injectForm, N as injectWizard, P as isRegisterValue, Q as kAttaformRegistry, T as lazy, V as renderAttaformState, X as useRegister, Y as useRegistry, Z as useWizard } from './shared/attaform.BcQwgWaq.mjs';
|
|
7
|
+
export { v as vRegister } from './shared/attaform.L0kUn3vL.mjs';
|
|
8
8
|
import 'vue';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* the
|
|
19
|
-
* v3 and v4 carry the same per-call depth cost.
|
|
11
|
+
* Factor the three identical-shape conditionals out of the zod-typed
|
|
12
|
+
* `useForm` signature, so the bundled `.d.ts` carries one alias per
|
|
13
|
+
* shape instead of re-inlining `z.input<UnwrapZodRoot<Schema>> extends
|
|
14
|
+
* GenericForm ? ... : never` four times. That inlining is what produces
|
|
15
|
+
* TS2589 ("Type instantiation is excessively deep") at a consumer call
|
|
16
|
+
* site holding a discriminated union, a refine, or a deep `.register()`
|
|
17
|
+
* chain. The v4 adapter declares the same three aliases, so both lines
|
|
18
|
+
* carry the same per-call depth cost.
|
|
20
19
|
*/
|
|
21
20
|
type FormOf<Schema extends SupportedRootSchema> = z.input<UnwrapZodRoot<Schema>> extends GenericForm ? z.input<UnwrapZodRoot<Schema>> : never;
|
|
22
21
|
type OutOf<Schema extends SupportedRootSchema> = z.output<UnwrapZodRoot<Schema>> extends GenericForm ? z.output<UnwrapZodRoot<Schema>> : never;
|
|
@@ -27,39 +26,39 @@ type ReadOf<Schema extends SupportedRootSchema> = StorageShape<UnwrapZodRoot<Sch
|
|
|
27
26
|
* ```ts
|
|
28
27
|
* import { useForm } from 'attaform/zod-v3'
|
|
29
28
|
*
|
|
30
|
-
* const form = useForm({ schema: myAdapter, defaultValues: {
|
|
29
|
+
* const form = useForm({ schema: myAdapter, defaultValues: { name: '' } })
|
|
31
30
|
* ```
|
|
32
31
|
*
|
|
33
|
-
* For Zod
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* For a Zod schema, prefer the overload that takes the schema directly:
|
|
33
|
+
* it attaches the adapter for you. For Zod v4, import from
|
|
34
|
+
* `attaform/zod`.
|
|
36
35
|
*/
|
|
37
36
|
declare function useForm<Form extends GenericForm, GetValueFormType extends GenericForm = Form, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<Form, GetValueFormType, AbstractSchema<Form, GetValueFormType>, never, K>, 'defaultValues'> & {
|
|
38
37
|
defaultValues?: AcceptableDefaults<Form, Form>;
|
|
39
38
|
}): UseFormReturnType<Form, GetValueFormType, Form, K>;
|
|
40
39
|
/**
|
|
41
|
-
* Create a form bound to a Zod v3
|
|
40
|
+
* Create a form bound to a Zod v3 schema.
|
|
42
41
|
*
|
|
43
42
|
* ```ts
|
|
44
43
|
* import { useForm } from 'attaform/zod-v3'
|
|
45
44
|
* import { z } from 'zod'
|
|
46
45
|
*
|
|
46
|
+
* const schema = z.object({
|
|
47
|
+
* email: z.string().email(),
|
|
48
|
+
* password: z.string().min(8),
|
|
49
|
+
* })
|
|
50
|
+
*
|
|
47
51
|
* const form = useForm({
|
|
48
|
-
* schema
|
|
49
|
-
* email: z.string().email(),
|
|
50
|
-
* password: z.string().min(8),
|
|
51
|
-
* }),
|
|
52
|
+
* schema,
|
|
52
53
|
* defaultValues: { email: '' },
|
|
53
54
|
* validateOn: 'blur',
|
|
54
55
|
* })
|
|
55
56
|
* ```
|
|
56
57
|
*
|
|
57
|
-
*
|
|
58
|
-
* `
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* For Zod v4, import from `attaform/zod` instead.
|
|
58
|
+
* The returned form carries `register`, `values`, `errors`, `fields`,
|
|
59
|
+
* `setValue`, `handleSubmit`, `meta` and the field-array helpers; see
|
|
60
|
+
* `UseFormReturnType` for the whole surface. For Zod v4, import from
|
|
61
|
+
* `attaform/zod`.
|
|
63
62
|
*/
|
|
64
63
|
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'> & {
|
|
65
64
|
schema: Schema;
|
|
@@ -78,9 +77,9 @@ interface ZodTypeWithInnerType extends z.ZodTypeAny {
|
|
|
78
77
|
};
|
|
79
78
|
}
|
|
80
79
|
/**
|
|
81
|
-
* The
|
|
82
|
-
*
|
|
83
|
-
*
|
|
80
|
+
* The honest read shape of a Zod v3 schema: a field under a record, an
|
|
81
|
+
* array or a dynamic boundary is tagged optional or undefined, matching
|
|
82
|
+
* the runtime reality that the slot may be missing.
|
|
84
83
|
*
|
|
85
84
|
* Used internally by the v3 adapter as the read-side type for
|
|
86
85
|
* `getValue` / `getFieldState`. Not commonly needed in consumer code.
|
|
@@ -95,15 +94,12 @@ type TypeWithNullableDynamicKeys<Schema extends z.ZodSchema, CrossedBoundary ext
|
|
|
95
94
|
z.infer<Schema> | (CrossedBoundary extends true ? undefined : never);
|
|
96
95
|
|
|
97
96
|
/**
|
|
98
|
-
* Wrap a Zod v3 form-root schema
|
|
97
|
+
* Wrap a Zod v3 form-root schema, a `ZodObject` or `ZodRecord`, in an
|
|
99
98
|
* `AbstractSchema` factory.
|
|
100
99
|
*
|
|
101
|
-
*
|
|
102
|
-
* `
|
|
103
|
-
*
|
|
104
|
-
* the adapter outside of `useForm`.
|
|
105
|
-
*
|
|
106
|
-
* Throws if the underlying schema isn't a supported form root.
|
|
100
|
+
* `useForm` from `attaform/zod-v3` does this for you, so reach for it
|
|
101
|
+
* only to use the adapter outside `useForm`. Throws if the schema is not
|
|
102
|
+
* a supported form root.
|
|
107
103
|
*/
|
|
108
104
|
declare function zodAdapter<FormSchema extends z.ZodSchema, Form extends z.input<FormSchema>, GetValueFormType extends TypeWithNullableDynamicKeys<FormSchema>>(zodSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
109
105
|
|
|
@@ -163,44 +159,29 @@ type ZodTypeMap = {
|
|
|
163
159
|
declare function isZodSchemaType<K extends keyof ZodTypeMap>(schema: unknown, expectedType: K): schema is ZodTypeMap[K];
|
|
164
160
|
|
|
165
161
|
/**
|
|
166
|
-
* Field-metadata write
|
|
167
|
-
*
|
|
168
|
-
* Storage lives in the shared `field-meta-store
|
|
169
|
-
* (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`)
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* **Registration patterns:** both styles work — register on whatever
|
|
180
|
-
* schema reference you assign into the parent's shape, OR on the
|
|
181
|
-
* inner schema before wrapping. The adapter's resolver tries the
|
|
182
|
-
* walker-returned schema first, then falls back to the peeled
|
|
183
|
-
* inner so either ordering hits:
|
|
184
|
-
*
|
|
185
|
-
* // both equivalent — registry hits at lookup time
|
|
162
|
+
* Field-metadata write and read API for the Zod v3 adapter.
|
|
163
|
+
*
|
|
164
|
+
* Storage lives in the shared `core/field-meta-store`, where every entry
|
|
165
|
+
* (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) reads and
|
|
166
|
+
* writes the same `WeakMap`s, so a payload registered through any of
|
|
167
|
+
* them surfaces at lookup whichever adapter runs.
|
|
168
|
+
*
|
|
169
|
+
* **Registration order does not matter.** Register on the schema
|
|
170
|
+
* reference assigned into the parent's shape, or on the inner schema
|
|
171
|
+
* before wrapping:
|
|
172
|
+
*
|
|
173
|
+
* // equivalent; both hit at lookup time
|
|
186
174
|
* withMeta(z.string(), { label: 'Email' }).optional()
|
|
187
175
|
* withMeta(z.string().optional(), { label: 'Email' })
|
|
188
176
|
*
|
|
189
|
-
* The path walker returns the wrapper at terminal
|
|
190
|
-
*
|
|
191
|
-
*
|
|
177
|
+
* The path walker returns the wrapper at a terminal position and peels
|
|
178
|
+
* at intermediate descent, and the resolver tries the walker's schema
|
|
179
|
+
* before the peeled inner, so the two-stage lookup covers leaf and
|
|
180
|
+
* container registrations symmetrically.
|
|
192
181
|
*/
|
|
193
182
|
|
|
194
|
-
/**
|
|
195
|
-
*
|
|
196
|
-
* field metadata against. Backed by the cross-adapter store — a
|
|
197
|
-
* payload registered here is visible to the v4 adapter and the
|
|
198
|
-
* unified `attaform/zod` entry, and vice versa. Every `add` also
|
|
199
|
-
* installs the path-walking resolver into the shared store's builder
|
|
200
|
-
* slot, so the walk's bytes ride this module's import instead of the
|
|
201
|
-
* adapter — a consumer that never registers metadata never ships the
|
|
202
|
-
* walk.
|
|
203
|
-
*/
|
|
183
|
+
/** The `add` / `get` / `has` / `remove` shape of `fieldMeta`, matching
|
|
184
|
+
* Zod 4's `$ZodRegistry` closely enough to read the same either way. */
|
|
204
185
|
type FieldMetaRegistryV3 = {
|
|
205
186
|
/**
|
|
206
187
|
* Register `payload` against `schema`. Returns the registry to
|
|
@@ -220,32 +201,45 @@ type FieldMetaRegistryV3 = {
|
|
|
220
201
|
*/
|
|
221
202
|
remove(schema: z.ZodTypeAny): FieldMetaRegistryV3;
|
|
222
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* The shared registry an Attaform-aware Zod 3 schema registers field
|
|
206
|
+
* metadata against.
|
|
207
|
+
*
|
|
208
|
+
* ```ts
|
|
209
|
+
* import { fieldMeta } from 'attaform/zod-v3'
|
|
210
|
+
*
|
|
211
|
+
* const email = z.string().email()
|
|
212
|
+
* fieldMeta.add(email, { label: 'Email address' })
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* It is backed by the cross-adapter store, so a payload registered here
|
|
216
|
+
* is visible to the v4 adapter and to the unified `attaform/zod` entry,
|
|
217
|
+
* and the reverse. Every `add` also installs the path-walking resolver
|
|
218
|
+
* into the shared store's builder slot, which is what makes the walk's
|
|
219
|
+
* bytes ride this module's import rather than the adapter: a consumer
|
|
220
|
+
* who never registers metadata never ships the walk.
|
|
221
|
+
*/
|
|
223
222
|
declare const fieldMeta: FieldMetaRegistryV3;
|
|
224
223
|
/**
|
|
225
|
-
* Attach `payload` to `schema` in the shared `fieldMeta` registry
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
* and delivery
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* registers once and surfaces at every path.
|
|
245
|
-
*
|
|
246
|
-
* `schema.register()` does NOT exist on Zod 3 — `withMeta` is the
|
|
247
|
-
* only fluent write API. Register on the inner schema before
|
|
248
|
-
* wrapping; see the "Registration rule" note in this file's header.
|
|
224
|
+
* Attach `payload` to `schema` in the shared `fieldMeta` registry and
|
|
225
|
+
* return a chainable CLONE of `schema` carrying the new metadata. Zod 3
|
|
226
|
+
* has no `schema.register()`, so this is its only fluent write API, and
|
|
227
|
+
* it matches `attaform/zod`'s `withMeta()`.
|
|
228
|
+
*
|
|
229
|
+
* It clones rather than mutates because the store keys metadata on the
|
|
230
|
+
* schema reference: calling `withMeta` twice on one instance would
|
|
231
|
+
* overwrite last-write-wins, and a sub-schema reused at several paths,
|
|
232
|
+
* an address shared between pickup and delivery say, could then carry
|
|
233
|
+
* only one payload. Zod 3 exposes no `.clone()`, so the reconstruction
|
|
234
|
+
* goes through `new schema.constructor(schema._def)`. Each call gets a
|
|
235
|
+
* fresh identity and a fresh registry slot, and existing metadata merges
|
|
236
|
+
* through, so chaining accumulates payload fields rather than replacing
|
|
237
|
+
* them.
|
|
238
|
+
*
|
|
239
|
+
* An inner field schema, an object's `.shape.city` for instance, is
|
|
240
|
+
* shared across clones, the def being held by reference, so leaf
|
|
241
|
+
* metadata registers once and surfaces at every path. See this file's
|
|
242
|
+
* header for the two equivalent registration orderings.
|
|
249
243
|
*/
|
|
250
244
|
declare function withMeta<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): S;
|
|
251
245
|
|
package/dist/zod-v3.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { i as isZodSchemaType, u as useForm, z as zodAdapter } from './shared/attaform.
|
|
2
|
-
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform.
|
|
1
|
+
export { i as isZodSchemaType, u as useForm, z as zodAdapter } from './shared/attaform.D_pt1gOj.mjs';
|
|
2
|
+
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform.DRsANMok.mjs';
|
|
3
3
|
export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform.CdZIEf7_.mjs';
|
|
4
|
-
export { A as AttaformErrorCode, e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform.
|
|
4
|
+
export { A as AttaformErrorCode, e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform.BIWicztt.mjs';
|
|
5
5
|
export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform.WiGdIqgx.mjs';
|
|
6
|
-
export { a as assignKey, v as vRegister } from './shared/attaform.
|
|
6
|
+
export { a as assignKey, v as vRegister } from './shared/attaform.D_f1WgYf.mjs';
|
|
7
7
|
export { i as isRegisterValue } from './shared/attaform.KvlEedlF.mjs';
|
|
8
8
|
|
|
9
9
|
const fieldMeta = installingFieldMetaStore;
|