attaform 0.17.1 → 0.17.2
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/shared/{attaform.B5qiXQwN.cjs → attaform.BPRHR3Zs.cjs} +11 -7
- package/dist/shared/{attaform.CVCmBKZX.mjs.map → attaform.BPRHR3Zs.cjs.map} +1 -1
- package/dist/shared/attaform.C5MH4lNh.d.mts +53 -0
- package/dist/shared/attaform.C6lbmMUe.d.ts +53 -0
- package/dist/shared/{attaform.CVCmBKZX.mjs → attaform.Drt6fivF.mjs} +11 -7
- package/dist/shared/{attaform.B5qiXQwN.cjs.map → attaform.Drt6fivF.mjs.map} +1 -1
- package/dist/shared/attaform.DtMN-MAm.d.cts +53 -0
- package/dist/zod-v3.cjs +1 -1
- package/dist/zod-v3.d.cts +33 -81
- package/dist/zod-v3.d.mts +33 -81
- package/dist/zod-v3.d.ts +33 -81
- package/dist/zod-v3.mjs +1 -1
- package/dist/zod.cjs +7 -3
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +32 -7
- package/dist/zod.d.mts +32 -7
- package/dist/zod.d.ts +32 -7
- package/dist/zod.mjs +7 -3
- package/dist/zod.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ag as ValidateOnConfig, F as FormKey, E as OnInvalidSubmitPolicy, X as PersistConfig, y as HistoryConfig, C as CoercionRegistry } from './attaform.C_5aB6EQ.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* v3 mirror of the Zod v4 `StorageShape`. Per top-level key, default
|
|
6
|
+
* to `z.output<Shape[K]>` (the post-init view — defaults have fired,
|
|
7
|
+
* Zod's own recursion peels nested defaults inside structural
|
|
8
|
+
* containers); fall back to `z.input<Shape[K]>` for transform / pipe
|
|
9
|
+
* carriers (`ZodEffects`, `ZodPipeline`) where storage holds the
|
|
10
|
+
* pre-transform input — transforms only run at submission /
|
|
11
|
+
* validation, not at the write boundary.
|
|
12
|
+
*
|
|
13
|
+
* v3 quirk: `ZodEffects` covers BOTH `.transform()` and
|
|
14
|
+
* `z.preprocess()` at the TS level — v3 doesn't carry a separate
|
|
15
|
+
* preprocess class the way v4 does. Deferring to `z.input` for
|
|
16
|
+
* `ZodEffects` means a top-level `z.preprocess(fn, T)` leaf reads as
|
|
17
|
+
* the preprocess input (commonly `unknown`); reach for the
|
|
18
|
+
* `AbstractSchema` escape hatch if a stronger type is needed.
|
|
19
|
+
* Transforms preserve their pre-transform input shape, which matches
|
|
20
|
+
* storage.
|
|
21
|
+
*/
|
|
22
|
+
type StorageShape<S extends z.ZodTypeAny> = S extends z.ZodObject<infer Shape> ? {
|
|
23
|
+
[K in keyof Shape]-?: Shape[K] extends z.ZodEffects<z.ZodTypeAny> | z.ZodPipeline<z.ZodTypeAny, z.ZodTypeAny> ? z.input<Shape[K]> : z.output<Shape[K]>;
|
|
24
|
+
} : z.input<S>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Configuration object for the Zod v3 `useForm` overload. Same
|
|
28
|
+
* shape as the schema-agnostic `UseFormConfiguration`, but with
|
|
29
|
+
* `schema` constrained to a `z.ZodObject` (or wrapped form).
|
|
30
|
+
*/
|
|
31
|
+
type UseFormConfigurationWithZod<Schema extends z.ZodType<unknown>, DefaultValues> = ValidateOnConfig & {
|
|
32
|
+
/** A Zod v3 `ZodObject` schema (or one wrapped in `.optional()` / `.nullable()` / `.default()` / `.refine()`). */
|
|
33
|
+
schema: Schema extends z.ZodType<unknown> ? UnwrapZodObject<Schema> extends z.ZodObject<z.ZodRawShape> ? Schema : never : never;
|
|
34
|
+
key?: FormKey;
|
|
35
|
+
defaultValues?: DefaultValues;
|
|
36
|
+
strict?: boolean;
|
|
37
|
+
onInvalidSubmit?: OnInvalidSubmitPolicy;
|
|
38
|
+
persist?: PersistConfig;
|
|
39
|
+
history?: HistoryConfig;
|
|
40
|
+
rememberVariants?: boolean;
|
|
41
|
+
coerce?: boolean | CoercionRegistry;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Peel `.optional()` / `.nullable()` / `.default()` / `.refine()` /
|
|
45
|
+
* `.transform()` wrappers off a Zod v3 schema to reach the inner
|
|
46
|
+
* `ZodObject`. Returns `never` if no `ZodObject` is found.
|
|
47
|
+
*
|
|
48
|
+
* Used internally by the v3 `useForm` overload to verify the
|
|
49
|
+
* supplied schema bottoms out at a `ZodObject`.
|
|
50
|
+
*/
|
|
51
|
+
type UnwrapZodObject<T> = T extends z.ZodEffects<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodOptional<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodNullable<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodDefault<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodObject<infer Shape> ? z.ZodObject<Shape> : never;
|
|
52
|
+
|
|
53
|
+
export type { StorageShape as S, UnwrapZodObject as U, UseFormConfigurationWithZod as a };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ag as ValidateOnConfig, F as FormKey, E as OnInvalidSubmitPolicy, X as PersistConfig, y as HistoryConfig, C as CoercionRegistry } from './attaform.C_5aB6EQ.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* v3 mirror of the Zod v4 `StorageShape`. Per top-level key, default
|
|
6
|
+
* to `z.output<Shape[K]>` (the post-init view — defaults have fired,
|
|
7
|
+
* Zod's own recursion peels nested defaults inside structural
|
|
8
|
+
* containers); fall back to `z.input<Shape[K]>` for transform / pipe
|
|
9
|
+
* carriers (`ZodEffects`, `ZodPipeline`) where storage holds the
|
|
10
|
+
* pre-transform input — transforms only run at submission /
|
|
11
|
+
* validation, not at the write boundary.
|
|
12
|
+
*
|
|
13
|
+
* v3 quirk: `ZodEffects` covers BOTH `.transform()` and
|
|
14
|
+
* `z.preprocess()` at the TS level — v3 doesn't carry a separate
|
|
15
|
+
* preprocess class the way v4 does. Deferring to `z.input` for
|
|
16
|
+
* `ZodEffects` means a top-level `z.preprocess(fn, T)` leaf reads as
|
|
17
|
+
* the preprocess input (commonly `unknown`); reach for the
|
|
18
|
+
* `AbstractSchema` escape hatch if a stronger type is needed.
|
|
19
|
+
* Transforms preserve their pre-transform input shape, which matches
|
|
20
|
+
* storage.
|
|
21
|
+
*/
|
|
22
|
+
type StorageShape<S extends z.ZodTypeAny> = S extends z.ZodObject<infer Shape> ? {
|
|
23
|
+
[K in keyof Shape]-?: Shape[K] extends z.ZodEffects<z.ZodTypeAny> | z.ZodPipeline<z.ZodTypeAny, z.ZodTypeAny> ? z.input<Shape[K]> : z.output<Shape[K]>;
|
|
24
|
+
} : z.input<S>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Configuration object for the Zod v3 `useForm` overload. Same
|
|
28
|
+
* shape as the schema-agnostic `UseFormConfiguration`, but with
|
|
29
|
+
* `schema` constrained to a `z.ZodObject` (or wrapped form).
|
|
30
|
+
*/
|
|
31
|
+
type UseFormConfigurationWithZod<Schema extends z.ZodType<unknown>, DefaultValues> = ValidateOnConfig & {
|
|
32
|
+
/** A Zod v3 `ZodObject` schema (or one wrapped in `.optional()` / `.nullable()` / `.default()` / `.refine()`). */
|
|
33
|
+
schema: Schema extends z.ZodType<unknown> ? UnwrapZodObject<Schema> extends z.ZodObject<z.ZodRawShape> ? Schema : never : never;
|
|
34
|
+
key?: FormKey;
|
|
35
|
+
defaultValues?: DefaultValues;
|
|
36
|
+
strict?: boolean;
|
|
37
|
+
onInvalidSubmit?: OnInvalidSubmitPolicy;
|
|
38
|
+
persist?: PersistConfig;
|
|
39
|
+
history?: HistoryConfig;
|
|
40
|
+
rememberVariants?: boolean;
|
|
41
|
+
coerce?: boolean | CoercionRegistry;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Peel `.optional()` / `.nullable()` / `.default()` / `.refine()` /
|
|
45
|
+
* `.transform()` wrappers off a Zod v3 schema to reach the inner
|
|
46
|
+
* `ZodObject`. Returns `never` if no `ZodObject` is found.
|
|
47
|
+
*
|
|
48
|
+
* Used internally by the v3 `useForm` overload to verify the
|
|
49
|
+
* supplied schema bottoms out at a `ZodObject`.
|
|
50
|
+
*/
|
|
51
|
+
type UnwrapZodObject<T> = T extends z.ZodEffects<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodOptional<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodNullable<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodDefault<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodObject<infer Shape> ? z.ZodObject<Shape> : never;
|
|
52
|
+
|
|
53
|
+
export type { StorageShape as S, UnwrapZodObject as U, UseFormConfigurationWithZod as a };
|
|
@@ -1577,16 +1577,20 @@ function useForm(configuration) {
|
|
|
1577
1577
|
const abstractSchema = isZodType(schema) ? zodAdapter(schema) : schema;
|
|
1578
1578
|
return useAbstractForm({
|
|
1579
1579
|
...configuration,
|
|
1580
|
-
//
|
|
1581
|
-
// `TypeWithNullableDynamicKeys<
|
|
1582
|
-
//
|
|
1583
|
-
//
|
|
1584
|
-
//
|
|
1585
|
-
//
|
|
1580
|
+
// `zodAdapter`'s constraint on its third generic is
|
|
1581
|
+
// `GetValueFormType extends TypeWithNullableDynamicKeys<FormSchema>`,
|
|
1582
|
+
// and `Schema` at this implementation overload is only constrained
|
|
1583
|
+
// by `extends z.ZodSchema<unknown>` — too loose for
|
|
1584
|
+
// `z.output<UnwrapZodObject<typeof schema>>` to resolve concretely.
|
|
1585
|
+
// Pass `TypeWithNullableDynamicKeys<typeof schema>` here purely to
|
|
1586
|
+
// satisfy the adapter's constraint at the structural-cast layer.
|
|
1587
|
+
// The PUBLIC signature's `GetValueFormType` default (line 67) is
|
|
1588
|
+
// what consumers see — that's `z.output<UnwrapZodObject<Schema>>`,
|
|
1589
|
+
// matching the docstring promise. Runtime is unaffected either way.
|
|
1586
1590
|
schema: abstractSchema,
|
|
1587
1591
|
defaultValues: configuration.defaultValues
|
|
1588
1592
|
});
|
|
1589
1593
|
}
|
|
1590
1594
|
|
|
1591
1595
|
export { fieldMeta as f, isZodSchemaType as i, useForm as u, withMeta as w, zodAdapter as z };
|
|
1592
|
-
//# sourceMappingURL=attaform.
|
|
1596
|
+
//# sourceMappingURL=attaform.Drt6fivF.mjs.map
|