attaform 0.22.0 → 0.24.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 +8 -11
- package/dist/chunks/dev-key-collision-warnings.cjs +0 -33
- package/dist/chunks/dev-key-collision-warnings.cjs.map +1 -1
- package/dist/chunks/dev-key-collision-warnings.mjs +1 -33
- package/dist/chunks/dev-key-collision-warnings.mjs.map +1 -1
- package/dist/chunks/devtools.cjs +3 -5
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +3 -5
- package/dist/chunks/devtools.mjs.map +1 -1
- package/dist/chunks/fingerprint2.cjs +1 -1
- package/dist/chunks/fingerprint2.mjs +1 -1
- package/dist/index.cjs +3 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -168
- package/dist/index.d.mts +7 -168
- package/dist/index.d.ts +7 -168
- package/dist/index.mjs +4 -150
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +5 -13
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.DgCfLqay.mjs → attaform.BJ_W7q3U.mjs} +8 -6
- package/dist/shared/attaform.BJ_W7q3U.mjs.map +1 -0
- package/dist/shared/{attaform.aekT7mMx.d.cts → attaform.BNmkKz0q.d.mts} +38 -6
- package/dist/shared/{attaform.Q3eAD2wD.cjs → attaform.BV_HyaMO.cjs} +6 -4
- package/dist/shared/attaform.BV_HyaMO.cjs.map +1 -0
- package/dist/shared/{attaform.AyujQoHp.cjs → attaform.BnUXV01g.cjs} +4 -4
- package/dist/shared/attaform.BnUXV01g.cjs.map +1 -0
- package/dist/shared/{attaform.DNuiFCXG.mjs → attaform.C-dAB90u.mjs} +4 -4
- package/dist/shared/attaform.C-dAB90u.mjs.map +1 -0
- package/dist/shared/{attaform.CjMcwV7W.cjs → attaform.C42wL7EJ.cjs} +272 -776
- package/dist/shared/attaform.C42wL7EJ.cjs.map +1 -0
- package/dist/shared/{attaform.D4XYaasQ.d.ts → attaform.C6eE50re.d.ts} +27 -87
- package/dist/shared/{attaform.6xE0Lcfd.mjs → attaform.CAWKNCzc.mjs} +2 -2
- package/dist/shared/{attaform.6xE0Lcfd.mjs.map → attaform.CAWKNCzc.mjs.map} +1 -1
- package/dist/shared/{attaform.DkA5J8NW.d.cts → attaform.CO0e7YVY.d.cts} +1 -46
- package/dist/shared/{attaform.DkA5J8NW.d.ts → attaform.CO0e7YVY.d.mts} +1 -46
- package/dist/shared/{attaform.DkA5J8NW.d.mts → attaform.CO0e7YVY.d.ts} +1 -46
- package/dist/shared/{attaform.CsB-iKbU.mjs → attaform.CuBdtfbe.mjs} +274 -767
- package/dist/shared/attaform.CuBdtfbe.mjs.map +1 -0
- package/dist/shared/{attaform.FN0vaQAg.d.mts → attaform.CwFZGv5-.d.ts} +38 -6
- package/dist/shared/{attaform.BGwNZ9GV.d.cts → attaform.DdUYEhkV.d.cts} +27 -87
- package/dist/shared/attaform.DdjDqTah.d.cts +56 -0
- package/dist/shared/attaform.DdjDqTah.d.mts +56 -0
- package/dist/shared/attaform.DdjDqTah.d.ts +56 -0
- package/dist/shared/{attaform.BKFwekY2.mjs → attaform.Df-s8j1X.mjs} +3 -289
- package/dist/shared/attaform.Df-s8j1X.mjs.map +1 -0
- package/dist/shared/{attaform.CCCeEPwa.d.mts → attaform.DiWNbKWa.d.mts} +27 -87
- package/dist/shared/{attaform.01iKS_lz.cjs → attaform.DwkU0oY9.cjs} +2 -298
- package/dist/shared/attaform.DwkU0oY9.cjs.map +1 -0
- package/dist/shared/{attaform.DvUH4a3o.d.ts → attaform.GJbSmwLB.d.cts} +224 -824
- package/dist/shared/{attaform.DvUH4a3o.d.cts → attaform.GJbSmwLB.d.mts} +224 -824
- package/dist/shared/{attaform.DvUH4a3o.d.mts → attaform.GJbSmwLB.d.ts} +224 -824
- package/dist/shared/{attaform.DUMWQefY.d.ts → attaform.K-3glmiT.d.cts} +38 -6
- package/dist/shared/{attaform.C-RtnCJM.cjs → attaform.Z1qTwOYE.cjs} +8 -6
- package/dist/shared/attaform.Z1qTwOYE.cjs.map +1 -0
- package/dist/shared/{attaform.CRzpFCjV.cjs → attaform.nycEksJn.cjs} +2 -2
- package/dist/shared/{attaform.CRzpFCjV.cjs.map → attaform.nycEksJn.cjs.map} +1 -1
- package/dist/shared/{attaform.DCjgGir_.mjs → attaform.o95Kjd3U.mjs} +6 -4
- package/dist/shared/attaform.o95Kjd3U.mjs.map +1 -0
- package/dist/zod-v3.cjs +2 -2
- package/dist/zod-v3.d.cts +12 -11
- package/dist/zod-v3.d.mts +12 -11
- package/dist/zod-v3.d.ts +12 -11
- package/dist/zod-v3.mjs +2 -2
- package/dist/zod-v4.cjs +2 -2
- package/dist/zod-v4.d.cts +7 -6
- package/dist/zod-v4.d.mts +7 -6
- package/dist/zod-v4.d.ts +7 -6
- package/dist/zod-v4.mjs +2 -2
- package/dist/zod.cjs +5 -5
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +21 -52
- package/dist/zod.d.mts +21 -52
- package/dist/zod.d.ts +21 -52
- package/dist/zod.mjs +5 -5
- package/dist/zod.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/indexeddb.cjs +0 -119
- package/dist/chunks/indexeddb.cjs.map +0 -1
- package/dist/chunks/indexeddb.mjs +0 -117
- package/dist/chunks/indexeddb.mjs.map +0 -1
- package/dist/chunks/local-storage.cjs +0 -58
- package/dist/chunks/local-storage.cjs.map +0 -1
- package/dist/chunks/local-storage.mjs +0 -56
- package/dist/chunks/local-storage.mjs.map +0 -1
- package/dist/chunks/multi-tab-sync.cjs +0 -367
- package/dist/chunks/multi-tab-sync.cjs.map +0 -1
- package/dist/chunks/multi-tab-sync.mjs +0 -364
- package/dist/chunks/multi-tab-sync.mjs.map +0 -1
- package/dist/chunks/session-storage.cjs +0 -58
- package/dist/chunks/session-storage.cjs.map +0 -1
- package/dist/chunks/session-storage.mjs +0 -56
- package/dist/chunks/session-storage.mjs.map +0 -1
- package/dist/chunks/wire-persistence.cjs +0 -396
- package/dist/chunks/wire-persistence.cjs.map +0 -1
- package/dist/chunks/wire-persistence.mjs +0 -394
- package/dist/chunks/wire-persistence.mjs.map +0 -1
- package/dist/shared/attaform.01iKS_lz.cjs.map +0 -1
- package/dist/shared/attaform.AyujQoHp.cjs.map +0 -1
- package/dist/shared/attaform.BKFwekY2.mjs.map +0 -1
- package/dist/shared/attaform.C-RtnCJM.cjs.map +0 -1
- package/dist/shared/attaform.CjMcwV7W.cjs.map +0 -1
- package/dist/shared/attaform.CsB-iKbU.mjs.map +0 -1
- package/dist/shared/attaform.DCjgGir_.mjs.map +0 -1
- package/dist/shared/attaform.DNuiFCXG.mjs.map +0 -1
- package/dist/shared/attaform.DgCfLqay.mjs.map +0 -1
- package/dist/shared/attaform.Q3eAD2wD.cjs.map +0 -1
- package/dist/shared/attaform.nf83TIR5.d.cts +0 -35
- package/dist/shared/attaform.nf83TIR5.d.mts +0 -35
- package/dist/shared/attaform.nf83TIR5.d.ts +0 -35
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm,
|
|
2
|
+
import { G as GenericForm, u as FlatPath, O as NestedType, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, af as ValidateOnConfig, b as UseFormReturnType } from './attaform.GJbSmwLB.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The shape `form.values.<key>` returns at runtime.
|
|
@@ -120,6 +120,38 @@ type StorageLeaf<L> = InputIsUnknown<L> extends true ? unknown : L extends {
|
|
|
120
120
|
};
|
|
121
121
|
} ? Out : never;
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* The Zod v4 schema roots `useForm` accepts. A fixed-shape
|
|
125
|
+
* `z.object({ … })` is the common case; `z.record(K, V)` admits a
|
|
126
|
+
* dictionary form (a homogeneous map with runtime-known keys);
|
|
127
|
+
* `z.discriminatedUnion(disc, [...])` admits a variant form (one of
|
|
128
|
+
* several object shapes, picked by a discriminator). Each projects to
|
|
129
|
+
* a `GenericForm`-shaped value the form engine drives: an object root
|
|
130
|
+
* descends into its fixed keys, a record root treats its entries as an
|
|
131
|
+
* open live-keyed container, a variant root lifts the active variant's
|
|
132
|
+
* keys into one addressable surface.
|
|
133
|
+
*
|
|
134
|
+
* Other roots (a bare `z.union`, a root `z.array`, primitives,
|
|
135
|
+
* `z.map` / `z.set`) are not form roots; wrap them under a key. The
|
|
136
|
+
* adapter's runtime construction rejects them with a legible error.
|
|
137
|
+
*
|
|
138
|
+
* `z.ZodObject` MUST keep its `z.ZodRawShape` argument, and the
|
|
139
|
+
* discriminated-union arm MUST stay fully applied. The unified entry's
|
|
140
|
+
* v4 overload constrains on `SupportedRootSchema & ZodV4Internals` to
|
|
141
|
+
* keep v3 schemas out (see `../unified/types-zod-major.ts`). In a
|
|
142
|
+
* single-major (v3-only) consumer install, the published `.d.mts`
|
|
143
|
+
* resolves this `z` to v3, where a bare or under-applied Zod class is
|
|
144
|
+
* missing its required arguments and degrades to an `any`-like error
|
|
145
|
+
* type; `any` then absorbs the union and `any & ZodV4Internals`
|
|
146
|
+
* collapses back to `any`, so the marker stops excluding v3 schemas and
|
|
147
|
+
* the read slot poisons to `never`. `z.ZodRecord` carries defaults for
|
|
148
|
+
* both arguments, so it stays concrete in either major.
|
|
149
|
+
* `z.ZodDiscriminatedUnion` does NOT (v3 requires both arguments, and
|
|
150
|
+
* its parameter order is the reverse of v4's), so the arm is written
|
|
151
|
+
* fully applied; the v3-only bundled-types fixture guards it.
|
|
152
|
+
*/
|
|
153
|
+
type SupportedRootSchema = z.ZodObject<z.ZodRawShape> | z.ZodRecord | z.ZodDiscriminatedUnion<readonly z.ZodObject<z.ZodRawShape>[], string>;
|
|
154
|
+
|
|
123
155
|
/**
|
|
124
156
|
* Zod v4 adapter entry point. Re-exports the adapter + the useForm
|
|
125
157
|
* wrapper that threads zod-v4-specific schema types through
|
|
@@ -188,12 +220,12 @@ type PathOutput<Schema extends z.ZodType, Path extends string> = z.output<Schema
|
|
|
188
220
|
* generics ride on the alias rather than re-evaluating the
|
|
189
221
|
* conditional from scratch.
|
|
190
222
|
*/
|
|
191
|
-
type FormOf<Schema extends
|
|
192
|
-
type OutOf<Schema extends
|
|
193
|
-
type ReadOf<Schema extends
|
|
194
|
-
declare function useForm<Schema extends
|
|
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>>, DefaultValuesInput<FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
195
227
|
schema: Schema;
|
|
196
228
|
} & ValidateOnConfig): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K>;
|
|
197
229
|
|
|
198
230
|
export { useForm as u };
|
|
199
|
-
export type { PathInput as P,
|
|
231
|
+
export type { PathInput as P, SupportedRootSchema as S, PathOutput as a, StorageShape as b };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const walkFieldMeta = require('./attaform.
|
|
4
|
-
const injectWizard = require('./attaform.
|
|
5
|
-
const paths = require('./attaform.
|
|
3
|
+
const walkFieldMeta = require('./attaform.BV_HyaMO.cjs');
|
|
4
|
+
const injectWizard = require('./attaform.C42wL7EJ.cjs');
|
|
5
|
+
const paths = require('./attaform.DwkU0oY9.cjs');
|
|
6
6
|
|
|
7
7
|
const fieldMeta = walkFieldMeta.fieldMetaStore;
|
|
8
8
|
function withMeta(schema, payload) {
|
|
@@ -848,9 +848,11 @@ function zodAdapter(zodSchema) {
|
|
|
848
848
|
stripZodEffects: true,
|
|
849
849
|
stripZodRefinements: true
|
|
850
850
|
});
|
|
851
|
-
if (!isZodSchemaType(_strippedRoot, "ZodObject")) {
|
|
851
|
+
if (!isZodSchemaType(_strippedRoot, "ZodObject") && !isZodSchemaType(_strippedRoot, "ZodRecord") && !isZodSchemaType(_strippedRoot, "ZodDiscriminatedUnion")) {
|
|
852
852
|
const name = getTypeName(_strippedRoot);
|
|
853
|
-
throw new Error(
|
|
853
|
+
throw new Error(
|
|
854
|
+
`Attaform: useForm schema root must be a ZodObject, ZodRecord, or ZodDiscriminatedUnion (got ${name}). Wrap other shapes under a key.`
|
|
855
|
+
);
|
|
854
856
|
}
|
|
855
857
|
return (formKey, options) => walkFieldMeta.createAbstractSchema(
|
|
856
858
|
zodSchema,
|
|
@@ -1632,4 +1634,4 @@ exports.isZodSchemaType = isZodSchemaType;
|
|
|
1632
1634
|
exports.useForm = useForm;
|
|
1633
1635
|
exports.withMeta = withMeta;
|
|
1634
1636
|
exports.zodAdapter = zodAdapter;
|
|
1635
|
-
//# sourceMappingURL=attaform.
|
|
1637
|
+
//# sourceMappingURL=attaform.Z1qTwOYE.cjs.map
|