attaform 0.29.0 → 0.30.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 -5
- package/dist/abstract.mjs +4 -4
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/dev-key-collision-warnings.mjs +47 -8
- package/dist/dev/chunks/devtools.mjs +1 -1
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +1 -2
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +3 -3
- package/dist/dev/shared/{attaform-dev.BO-71R54.mjs → attaform-dev.BK6Ge2qR.mjs} +34 -188
- package/dist/dev/shared/{attaform-dev.A-TpJW0B.mjs → attaform-dev.BQc5QV3Y.mjs} +1 -19
- package/dist/dev/shared/{attaform-dev.DrzObAZo.mjs → attaform-dev.BcNtyOmf.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.ButTkwHd.mjs → attaform-dev.BcYT6tFh.mjs} +7 -8
- package/dist/dev/shared/{attaform-dev.BgM6FdtA.mjs → attaform-dev.BisFstxh.mjs} +91 -59
- package/dist/dev/shared/{attaform-dev.DHuydLAC.mjs → attaform-dev.CQ2rJiAX.mjs} +560 -631
- package/dist/dev/shared/{attaform-dev.D8aoKb89.mjs → attaform-dev.D6CLvaQT.mjs} +8 -8
- package/dist/dev/shared/{attaform-dev.q6UutkCx.mjs → attaform-dev.DTrHonpc.mjs} +69 -120
- package/dist/dev/shared/{attaform-dev.DD5m2W51.mjs → attaform-dev.DUZckyV8.mjs} +1 -3
- 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 +2 -2
- package/dist/directive.mjs +1 -1
- package/dist/history.d.mts +1 -1
- package/dist/history.mjs +1 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.mts +2 -11
- package/dist/nuxt.mjs +0 -1
- package/dist/runtime/plugins/attaform.mjs +3 -3
- package/dist/shared/{attaform.DffRL5pP.mjs → attaform.B3resMQ1.mjs} +8 -8
- package/dist/shared/{attaform.Cvao8bW5.mjs → attaform.BRDDQeHV.mjs} +6 -6
- package/dist/shared/{attaform.C2MVyuxC.mjs → attaform.BXneBxEj.mjs} +34 -188
- package/dist/shared/{attaform.BndjUUYX.mjs → attaform.ByWP6kSx.mjs} +4 -4
- package/dist/shared/{attaform.D1fnTifF.mjs → attaform.CJ8DpRGj.mjs} +69 -120
- package/dist/shared/{attaform.B0dKL8ST.mjs → attaform.CUfrMK7t.mjs} +91 -59
- package/dist/shared/{attaform.CZYt_5N_.mjs → attaform.CdZIEf7_.mjs} +1 -19
- package/dist/shared/{attaform.axHXVQO7.d.mts → attaform.Clz0ArIi.d.mts} +1 -1
- package/dist/shared/{attaform.CZMAYwSK.mjs → attaform.DNJOWjQw.mjs} +559 -588
- package/dist/shared/{attaform.CIWLMY-R.d.mts → attaform.Rc9u4Vfw.d.mts} +1 -1
- package/dist/shared/{attaform.DDtqHYv1.d.mts → attaform.UGyOK83T.d.mts} +115 -214
- package/dist/shared/{attaform.D0x-qSXm.mjs → attaform.WiGdIqgx.mjs} +1 -3
- package/dist/shared/{attaform.CsoeRi3P.d.mts → attaform.bKLzMU0o.d.mts} +99 -493
- package/dist/vite.mjs +5 -0
- package/dist/zod-v3.d.mts +4 -4
- package/dist/zod-v3.mjs +6 -6
- package/dist/zod-v4.d.mts +9 -9
- package/dist/zod-v4.mjs +6 -6
- package/dist/zod.d.mts +4 -4
- package/dist/zod.mjs +5 -5
- package/package.json +3 -2
- package/skills/attaform/SKILL.md +1 -1
- package/skills/attaform/references/custom-components.md +1 -1
- package/dist/chunks/fingerprint.mjs +0 -183
- package/dist/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/chunks/fingerprint.mjs +0 -183
- package/dist/dev/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/shared/attaform-dev.BxfsuwBR.mjs +0 -44
- package/dist/shared/attaform.BxfsuwBR.mjs +0 -44
|
@@ -838,12 +838,12 @@ type AcceptableDefaultsOf<DVI, SchemaInput> = DVI | SchemaInput | (() => DVI | S
|
|
|
838
838
|
type FormKey = string;
|
|
839
839
|
/**
|
|
840
840
|
* Per-form options threaded from `useForm` into the adapter factory.
|
|
841
|
-
* Today carries
|
|
842
|
-
*
|
|
843
|
-
*
|
|
841
|
+
* Today carries `maxRecursionDepth` so adapter walks can cap their
|
|
842
|
+
* descent through recursive schemas; future per-form runtime knobs
|
|
843
|
+
* land here too.
|
|
844
844
|
*/
|
|
845
845
|
interface SchemaFactoryOptions {
|
|
846
|
-
/**
|
|
846
|
+
/** Recursion ceiling for walks through recursive schemas. */
|
|
847
847
|
maxRecursionDepth: number;
|
|
848
848
|
}
|
|
849
849
|
/**
|
|
@@ -948,27 +948,49 @@ type ErrorInput = Error | {
|
|
|
948
948
|
code?: string;
|
|
949
949
|
data?: Json | null;
|
|
950
950
|
};
|
|
951
|
-
/**
|
|
952
|
-
|
|
951
|
+
/**
|
|
952
|
+
* A parse verdict as an `AbstractSchema` produces it.
|
|
953
|
+
*
|
|
954
|
+
* A schema knows nothing about which form asked: it is a pure function
|
|
955
|
+
* of the schema it wraps, which is what lets one `AbstractSchema` serve
|
|
956
|
+
* every form built on the same schema. The owning store stamps its own
|
|
957
|
+
* `formKey` on the way out, producing the `ValidationResponse*` arms
|
|
958
|
+
* below. Adapter authors implement THESE.
|
|
959
|
+
*/
|
|
960
|
+
type SchemaParseSuccess<TData> = {
|
|
953
961
|
/** The parsed value at the validated subtree (whole form when `validate()` was called without a path). */
|
|
954
962
|
data: TData;
|
|
955
963
|
errors: undefined;
|
|
956
964
|
success: true;
|
|
957
|
-
formKey: FormKey;
|
|
958
965
|
};
|
|
959
|
-
/**
|
|
960
|
-
type
|
|
966
|
+
/** Schema-level verdict when no data could be produced (e.g. a top-level type mismatch). */
|
|
967
|
+
type SchemaParseErrorWithoutData = {
|
|
961
968
|
data: undefined;
|
|
962
969
|
/** Non-empty list of failures. */
|
|
963
970
|
errors: ValidationError[];
|
|
964
971
|
success: false;
|
|
965
|
-
formKey: FormKey;
|
|
966
972
|
};
|
|
967
|
-
/**
|
|
968
|
-
type
|
|
973
|
+
/** Schema-level verdict when the parser produced partial data alongside failures. */
|
|
974
|
+
type SchemaParseErrorWithData<TData> = {
|
|
969
975
|
data: TData;
|
|
970
976
|
errors: ValidationError[];
|
|
971
977
|
success: false;
|
|
978
|
+
};
|
|
979
|
+
/** Settled schema-level verdict. Discriminate on `success`. */
|
|
980
|
+
type SchemaParseResult<TData> = SchemaParseSuccess<TData> | SchemaParseErrorWithData<TData> | SchemaParseErrorWithoutData;
|
|
981
|
+
/** Schema-level `getDefaultValues` verdict: defaults always come back. */
|
|
982
|
+
type SchemaDefaultsResult<TData> = SchemaParseSuccess<TData> | SchemaParseErrorWithData<TData>;
|
|
983
|
+
/** Settled validation result when the form (or subtree) parsed successfully. */
|
|
984
|
+
type ValidationResponseSuccess<TData> = SchemaParseSuccess<TData> & {
|
|
985
|
+
/** The form this verdict belongs to. Stamped by the store, not the schema. */
|
|
986
|
+
formKey: FormKey;
|
|
987
|
+
};
|
|
988
|
+
/** Settled validation result when no data could be produced (e.g. a top-level type mismatch). */
|
|
989
|
+
type ValidationResponseErrorWithoutData = SchemaParseErrorWithoutData & {
|
|
990
|
+
formKey: FormKey;
|
|
991
|
+
};
|
|
992
|
+
/** Settled validation result when the parser produced partial data alongside failures. */
|
|
993
|
+
type ValidationResponseErrorWithData<TData> = SchemaParseErrorWithData<TData> & {
|
|
972
994
|
formKey: FormKey;
|
|
973
995
|
};
|
|
974
996
|
/**
|
|
@@ -983,12 +1005,6 @@ type ValidationResponseErrorWithData<TData> = {
|
|
|
983
1005
|
* ```
|
|
984
1006
|
*/
|
|
985
1007
|
type ValidationResponse<TData> = ValidationResponseSuccess<TData> | ValidationResponseErrorWithData<TData> | ValidationResponseErrorWithoutData;
|
|
986
|
-
/**
|
|
987
|
-
* Result of resolving the form's default values. Always returns at
|
|
988
|
-
* least the shape derived from the schema; `errors` carry any
|
|
989
|
-
* failures from validating those defaults against the schema.
|
|
990
|
-
*/
|
|
991
|
-
type DefaultValuesResponse<TData> = ValidationResponseSuccess<TData> | ValidationResponseErrorWithData<TData>;
|
|
992
1008
|
/**
|
|
993
1009
|
* Trimmed `ValidationResponse` that omits the `data` payload. Used by
|
|
994
1010
|
* the reactive `validate()` status, whose consumers only need the
|
|
@@ -1036,21 +1052,13 @@ type ValidateOptions = {
|
|
|
1036
1052
|
/**
|
|
1037
1053
|
* Configuration passed to `AbstractSchema.getDefaultValues`. Adapters
|
|
1038
1054
|
* receive `useDefaultSchemaValues` (honor `.default(x)` wrappers vs.
|
|
1039
|
-
* empty/falsy fallbacks)
|
|
1040
|
-
*
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
* service contract.
|
|
1055
|
+
* empty/falsy fallbacks) and an optional `constraints` overlay merged
|
|
1056
|
+
* into the derived defaults so the runtime can stamp user-supplied
|
|
1057
|
+
* defaults at construction. Exported so adapter authors can
|
|
1058
|
+
* co-implement the service contract.
|
|
1044
1059
|
*/
|
|
1045
1060
|
type GetDefaultValuesConfig<Form> = {
|
|
1046
1061
|
useDefaultSchemaValues: boolean;
|
|
1047
|
-
/**
|
|
1048
|
-
* Whether to keep schema refinements when deriving slim defaults.
|
|
1049
|
-
* `true` (default) — preserve refinements; `false` — strip them so
|
|
1050
|
-
* placeholder data lands without immediate construction-time
|
|
1051
|
-
* errors. Mirrors `useForm({ strict })`.
|
|
1052
|
-
*/
|
|
1053
|
-
strict?: boolean;
|
|
1054
1062
|
constraints?: DeepPartial<WriteShape<Form>> | undefined;
|
|
1055
1063
|
};
|
|
1056
1064
|
/**
|
|
@@ -1064,45 +1072,7 @@ type GetDefaultValuesConfig<Form> = {
|
|
|
1064
1072
|
* adding support for a new schema library (Valibot, ArkType, custom).
|
|
1065
1073
|
*/
|
|
1066
1074
|
type AbstractSchema<Form, GetValueFormType> = {
|
|
1067
|
-
|
|
1068
|
-
* Structural fingerprint of the schema. Same shape → same string;
|
|
1069
|
-
* different shape → (best-effort) different string.
|
|
1070
|
-
*
|
|
1071
|
-
* Resolves a `Promise` so adapters can defer the structural walk (and
|
|
1072
|
-
* its `canonicalStringify` helper) onto a dynamic import. The framework
|
|
1073
|
-
* only ever needs the fingerprint for the dev-only shared-key schema
|
|
1074
|
-
* mismatch warning, so none of those bytes belong on the eager
|
|
1075
|
-
* `useForm` path.
|
|
1076
|
-
*
|
|
1077
|
-
* The library uses this to detect schema mismatches at a shared
|
|
1078
|
-
* form key: two `useForm({ key: 'x', schema })` calls are allowed
|
|
1079
|
-
* to land on the same `FormStore` (the "shared store" semantic),
|
|
1080
|
-
* but only when their schemas agree. If the second call's
|
|
1081
|
-
* fingerprint differs from the first's, the library emits a
|
|
1082
|
-
* dev-mode warning — the first call's schema stays canonical and
|
|
1083
|
-
* the second call's schema is silently ignored.
|
|
1084
|
-
*
|
|
1085
|
-
* Guarantees adapter authors should provide:
|
|
1086
|
-
* - **Determinism:** equal shapes at different memory addresses
|
|
1087
|
-
* must produce the same fingerprint. Referential equality fails
|
|
1088
|
-
* 99% of the time across files, so reference-identity is not a
|
|
1089
|
-
* substitute.
|
|
1090
|
-
* - **Key-order-insensitivity** for record-like shapes (object,
|
|
1091
|
-
* struct) — two shapes with the same keys but different iteration
|
|
1092
|
-
* order must match.
|
|
1093
|
-
* - **Order-insensitivity for unbounded unions** — `a | b` and
|
|
1094
|
-
* `b | a` must match (the set of members is what matters, not
|
|
1095
|
-
* their source order).
|
|
1096
|
-
*
|
|
1097
|
-
* Compromises adapter authors may accept:
|
|
1098
|
-
* - Function-valued metadata (refinements, transforms, lazy
|
|
1099
|
-
* defaults) is not stably hashable. Represent it as an opaque
|
|
1100
|
-
* sentinel; two schemas differing only in refinement logic will
|
|
1101
|
-
* look identical. The warning is a footgun catcher, not a
|
|
1102
|
-
* soundness guarantee.
|
|
1103
|
-
*/
|
|
1104
|
-
fingerprint(): Promise<string>;
|
|
1105
|
-
getDefaultValues(config: GetDefaultValuesConfig<Form>): DefaultValuesResponse<Form>;
|
|
1075
|
+
getDefaultValues(config: GetDefaultValuesConfig<Form>): SchemaDefaultsResult<Form>;
|
|
1106
1076
|
/**
|
|
1107
1077
|
* Return the schema-prescribed default value at the given path. The
|
|
1108
1078
|
* runtime uses this to fill structural gaps so every `setValue` write
|
|
@@ -1302,7 +1272,7 @@ type AbstractSchema<Form, GetValueFormType> = {
|
|
|
1302
1272
|
* returned as a `success: false` response with a populated
|
|
1303
1273
|
* `errors` array.
|
|
1304
1274
|
*/
|
|
1305
|
-
validateAtPath(data: unknown, path: Path | undefined, options?: ValidateOptions): MaybePromise<
|
|
1275
|
+
validateAtPath(data: unknown, path: Path | undefined, options?: ValidateOptions): MaybePromise<SchemaParseResult<GetValueFormType>>;
|
|
1306
1276
|
/**
|
|
1307
1277
|
* Sync sister to `getSchemasAtPath` / `validateAtPath`. Returns the
|
|
1308
1278
|
* set of primitive `typeof`-style kinds the path's leaf schema
|
|
@@ -1333,7 +1303,7 @@ type AbstractSchema<Form, GetValueFormType> = {
|
|
|
1333
1303
|
* - For nullable / optional wrappers: adds `'null'` / `'undefined'`
|
|
1334
1304
|
* to the inner's set.
|
|
1335
1305
|
*/
|
|
1336
|
-
getSlimPrimitiveTypesAtPath(path: Path):
|
|
1306
|
+
getSlimPrimitiveTypesAtPath(path: Path): ReadonlySet<SlimPrimitiveKind>;
|
|
1337
1307
|
/**
|
|
1338
1308
|
* Return `true` iff `path` resolves to a **leaf** in the schema: a
|
|
1339
1309
|
* path the schema declares no sub-paths under. That is every path
|
|
@@ -1613,38 +1583,6 @@ type SettledValidationStatus<Form> = {
|
|
|
1613
1583
|
* `pending` to switch between in-flight and settled states.
|
|
1614
1584
|
*/
|
|
1615
1585
|
type ReactiveValidationStatus<Form> = PendingValidationStatus | SettledValidationStatus<Form>;
|
|
1616
|
-
/**
|
|
1617
|
-
* What to do when a submit attempt fails validation. The library can
|
|
1618
|
-
* focus and/or scroll the first errored field into view without you
|
|
1619
|
-
* wiring an `onError` callback yourself. Defaults to
|
|
1620
|
-
* `'focus-first-error'` because moving keyboard / screen-reader focus
|
|
1621
|
-
* to the broken field on submit is an accessibility baseline; opt out
|
|
1622
|
-
* with `'none'` if you're managing focus elsewhere.
|
|
1623
|
-
*
|
|
1624
|
-
* - `'focus-first-error'` (default): focus the first errored field's
|
|
1625
|
-
* first visible element. Modern browsers scroll the focused element
|
|
1626
|
-
* into view by default; pair with `'both'` if you want an explicit
|
|
1627
|
-
* scroll alongside.
|
|
1628
|
-
* - `'scroll-to-first-error'`: scroll that element into view without
|
|
1629
|
-
* moving focus.
|
|
1630
|
-
* - `'both'`: scroll first, then focus (with `preventScroll: true` so
|
|
1631
|
-
* the browser doesn't undo the explicit scroll).
|
|
1632
|
-
* - `'none'`: no automatic UI nudge; the dev handles focus / scroll
|
|
1633
|
-
* manually via `form.focusFirstError()` or `form.scrollToFirstError()`
|
|
1634
|
-
* from an `onError` callback.
|
|
1635
|
-
*
|
|
1636
|
-
* Both focusing policies request `focusVisible: true`, so the browser
|
|
1637
|
-
* paints a focus ring even though the move is programmatic. Where a UA
|
|
1638
|
-
* doesn't yet support that hint, non-text controls (radio, checkbox,
|
|
1639
|
-
* custom widgets) may end up focused without a visible ring after a
|
|
1640
|
-
* pointer-driven submit; if you target those browsers, pair the policy
|
|
1641
|
-
* with your own indicator (e.g. a `:focus-within` ring on the option
|
|
1642
|
-
* wrapper).
|
|
1643
|
-
*
|
|
1644
|
-
* If no errored field has a currently mounted, visible element, the
|
|
1645
|
-
* policy silently no-ops.
|
|
1646
|
-
*/
|
|
1647
|
-
type OnInvalidSubmitPolicy = 'none' | 'focus-first-error' | 'scroll-to-first-error' | 'both';
|
|
1648
1586
|
/**
|
|
1649
1587
|
* When per-field VALIDATION runs. Only validation timing varies per
|
|
1650
1588
|
* mode; storage commit timing is the directive's concern (the
|
|
@@ -1838,8 +1776,7 @@ type HistoryModule = {
|
|
|
1838
1776
|
* and `undo()` cannot reach the transient pre-hydration default.
|
|
1839
1777
|
*
|
|
1840
1778
|
* One plugin instance is a reusable configuration, not per-form state:
|
|
1841
|
-
* passing the same instance to several forms
|
|
1842
|
-
* `createAttaform({ defaults: { history } })`) gives each form its own
|
|
1779
|
+
* passing the same instance to several forms gives each form its own
|
|
1843
1780
|
* independent chain.
|
|
1844
1781
|
*/
|
|
1845
1782
|
type HistoryPlugin = {
|
|
@@ -1923,11 +1860,9 @@ type UseFormConfiguration<Form extends GenericForm, GetValueFormType, Schema ext
|
|
|
1923
1860
|
*
|
|
1924
1861
|
* For schemas that depend on the form's identity or per-form
|
|
1925
1862
|
* options, pass a factory `(key, options) => schema` instead — the
|
|
1926
|
-
* library calls it once per form
|
|
1927
|
-
*
|
|
1928
|
-
*
|
|
1929
|
-
* use it to thread the resolved recursion cap into the adapter
|
|
1930
|
-
* closure.
|
|
1863
|
+
* library calls it once per form. Most adapters ignore the options
|
|
1864
|
+
* argument; the typed Zod entry points use it to thread the
|
|
1865
|
+
* recursion cap into the adapter closure.
|
|
1931
1866
|
*/
|
|
1932
1867
|
schema: Schema | ((key: FormKey, options: SchemaFactoryOptions) => Schema);
|
|
1933
1868
|
/**
|
|
@@ -1985,40 +1920,29 @@ type UseFormConfiguration<Form extends GenericForm, GetValueFormType, Schema ext
|
|
|
1985
1920
|
*/
|
|
1986
1921
|
defaultValues?: DefaultValues | (() => DefaultValues) | (() => Promise<DefaultValues>);
|
|
1987
1922
|
/**
|
|
1988
|
-
*
|
|
1989
|
-
*
|
|
1923
|
+
* Move keyboard / screen-reader focus to the first errored field when
|
|
1924
|
+
* a submit attempt fails validation. Fires after errors are populated
|
|
1925
|
+
* and before your `onError` callback runs.
|
|
1990
1926
|
*
|
|
1991
|
-
*
|
|
1992
|
-
*
|
|
1993
|
-
*
|
|
1994
|
-
*
|
|
1995
|
-
*
|
|
1996
|
-
*
|
|
1997
|
-
* multi-step wizards, field arrays seeded with placeholder
|
|
1998
|
-
* rows, or any form intentionally mounting with incomplete data.
|
|
1927
|
+
* Default `true`: focusing the broken field on submit is an
|
|
1928
|
+
* accessibility baseline, and modern browsers scroll the focused
|
|
1929
|
+
* element into view as part of the move. Pass `false` when you drive
|
|
1930
|
+
* the nudge yourself from an `onError` callback with
|
|
1931
|
+
* `form.focusFirstError()` or `form.scrollToFirstError()`, both of
|
|
1932
|
+
* which stay available either way.
|
|
1999
1933
|
*
|
|
2000
|
-
*
|
|
2001
|
-
*
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
*
|
|
2006
|
-
*
|
|
2007
|
-
* Default `'focus-first-error'`, which moves keyboard / screen-reader
|
|
2008
|
-
* focus to the broken field as an accessibility baseline.
|
|
1934
|
+
* The focus requests `focusVisible: true`, so the browser paints a
|
|
1935
|
+
* focus ring even though the move is programmatic. Where a UA doesn't
|
|
1936
|
+
* yet support that hint, non-text controls (radio, checkbox, custom
|
|
1937
|
+
* widgets) may end up focused without a visible ring after a
|
|
1938
|
+
* pointer-driven submit; if you target those browsers, pair this with
|
|
1939
|
+
* your own indicator (e.g. a `:focus-within` ring on the option
|
|
1940
|
+
* wrapper).
|
|
2009
1941
|
*
|
|
2010
|
-
*
|
|
2011
|
-
*
|
|
2012
|
-
* - `'scroll-to-first-error'`: scroll it into view without focusing.
|
|
2013
|
-
* - `'both'`: scroll, then focus.
|
|
2014
|
-
* - `'none'`: opt out entirely; handle focus / scroll yourself in an
|
|
2015
|
-
* `onError` callback via `form.focusFirstError()` or
|
|
2016
|
-
* `form.scrollToFirstError()`.
|
|
2017
|
-
*
|
|
2018
|
-
* If no errored field has a currently-mounted, visible element,
|
|
2019
|
-
* the policy silently no-ops.
|
|
1942
|
+
* If no errored field has a currently-mounted, visible element, the
|
|
1943
|
+
* focus silently no-ops.
|
|
2020
1944
|
*/
|
|
2021
|
-
|
|
1945
|
+
focusOnInvalidSubmit?: boolean;
|
|
2022
1946
|
/**
|
|
2023
1947
|
* Freeze the form's data. When this resolves truthy every value write
|
|
2024
1948
|
* no-ops at the store's write chokepoint (programmatic `setValue`, the
|
|
@@ -2036,7 +1960,6 @@ type UseFormConfiguration<Form extends GenericForm, GetValueFormType, Schema ext
|
|
|
2036
1960
|
*
|
|
2037
1961
|
* Accepts a boolean, a ref, a computed, or a getter, read live so the
|
|
2038
1962
|
* freeze tracks a reactive source. `undefined` resolves to `false`.
|
|
2039
|
-
* Falls back to `AttaformDefaults.disabled`.
|
|
2040
1963
|
*
|
|
2041
1964
|
* A shared FormStore resolves `disabled` from its first `useForm({ key })`
|
|
2042
1965
|
* call; a later caller passing a different value is ignored.
|
|
@@ -2103,68 +2026,18 @@ type UseFormConfiguration<Form extends GenericForm, GetValueFormType, Schema ext
|
|
|
2103
2026
|
rememberVariants?: boolean;
|
|
2104
2027
|
/**
|
|
2105
2028
|
* Schema-driven coercion of user-typed DOM values at the v-register
|
|
2106
|
-
* directive layer.
|
|
2107
|
-
* `AttaformDefaults.coerce`.
|
|
2029
|
+
* directive layer.
|
|
2108
2030
|
*
|
|
2109
|
-
*
|
|
2110
|
-
*
|
|
2111
|
-
*
|
|
2112
|
-
*
|
|
2113
|
-
* extend.
|
|
2031
|
+
* Two rules ship: string→number and string→boolean, each firing
|
|
2032
|
+
* only when the schema declares that single type at the path.
|
|
2033
|
+
* Defaults to on; `false` disables coercion form-wide and the slim
|
|
2034
|
+
* gate rejects mismatches instead.
|
|
2114
2035
|
*
|
|
2115
2036
|
* Coercion applies ONLY to user-typed DOM values. Programmatic
|
|
2116
2037
|
* writes (`form.setValue`, `setValueWithInternalPath`) are NEVER
|
|
2117
2038
|
* coerced.
|
|
2118
2039
|
*/
|
|
2119
|
-
coerce?: boolean
|
|
2120
|
-
/**
|
|
2121
|
-
* Per-form override of the `getDisplayState` heuristic that drives
|
|
2122
|
-
* `field.displayState` and the `show*` booleans (and their `form.meta`
|
|
2123
|
-
* rollups). Falls back to `AttaformDefaults.getDisplayState`, then to
|
|
2124
|
-
* the library default (`defaultDisplayState`). See
|
|
2125
|
-
* `AttaformDefaults.getDisplayState` for the resolution rules and
|
|
2126
|
-
* predicate signature.
|
|
2127
|
-
*/
|
|
2128
|
-
getDisplayState?: GetDisplayState;
|
|
2129
|
-
/**
|
|
2130
|
-
* Recursion ceiling for schema walks that descend through recursive
|
|
2131
|
-
* schemas (Zod's `z.lazy(...)` today). Default `64`. Per-form value
|
|
2132
|
-
* overrides `AttaformDefaults.maxRecursionDepth`, which overrides
|
|
2133
|
-
* the library default.
|
|
2134
|
-
*
|
|
2135
|
-
* Schemas that don't include a recursive boundary ignore this knob
|
|
2136
|
-
* entirely — it's read only at the descent step through a recursive
|
|
2137
|
-
* wrapper. Set it on the specific form whose schema is recursive
|
|
2138
|
-
* (a comment tree, a category tree, a nested-rule editor):
|
|
2139
|
-
*
|
|
2140
|
-
* ```ts
|
|
2141
|
-
* useForm({ schema: commentTreeSchema, maxRecursionDepth: 128 })
|
|
2142
|
-
* ```
|
|
2143
|
-
*
|
|
2144
|
-
* Past the cap, the slim-primitive type gate falls back to permissive
|
|
2145
|
-
* (write-time type checks skip; full schema validation still runs).
|
|
2146
|
-
* Storage and reads work at any depth; only the per-write type gate
|
|
2147
|
-
* stops short of the cap. Raise the cap if you regularly edit nodes
|
|
2148
|
-
* beyond the default depth.
|
|
2149
|
-
*
|
|
2150
|
-
* See `AttaformDefaults.maxRecursionDepth` for the resolution rules
|
|
2151
|
-
* and the broader description of where the cap is read.
|
|
2152
|
-
*/
|
|
2153
|
-
maxRecursionDepth?: number;
|
|
2154
|
-
/**
|
|
2155
|
-
* Whether `v-register` automatically manages aria attributes
|
|
2156
|
-
* (`aria-invalid`, `aria-busy`, `aria-required`, `aria-describedby`)
|
|
2157
|
-
* from the field's display state. **Defaults to `true`.**
|
|
2158
|
-
*
|
|
2159
|
-
* **Resolution order (per-register override > per-form > global > library):**
|
|
2160
|
-
*
|
|
2161
|
-
* register(path, { autoAria }) > useForm({ autoAria }) > AttaformDefaults.autoAria > library default (`true`)
|
|
2162
|
-
*
|
|
2163
|
-
* Set `false` to leave all aria wiring to your own markup form-wide.
|
|
2164
|
-
* Any aria attribute you author yourself is always left untouched,
|
|
2165
|
-
* independent of this flag.
|
|
2166
|
-
*/
|
|
2167
|
-
autoAria?: boolean;
|
|
2040
|
+
coerce?: boolean;
|
|
2168
2041
|
/**
|
|
2169
2042
|
* @internal
|
|
2170
2043
|
* SSR prefetch mark — set by the `attaform/vite` compile-time
|
|
@@ -2181,176 +2054,6 @@ type UseFormConfiguration<Form extends GenericForm, GetValueFormType, Schema ext
|
|
|
2181
2054
|
*/
|
|
2182
2055
|
__ssrAccessed?: boolean;
|
|
2183
2056
|
};
|
|
2184
|
-
/**
|
|
2185
|
-
* App-level defaults applied to every `useForm` call. Set these once
|
|
2186
|
-
* per app via `createAttaform({ defaults })` (bare Vue) or
|
|
2187
|
-
* `attaform.defaults` (Nuxt module).
|
|
2188
|
-
*
|
|
2189
|
-
* Resolution order (per-form wins):
|
|
2190
|
-
*
|
|
2191
|
-
* useForm({ ... }) > createAttaform({ defaults }) > library default
|
|
2192
|
-
*
|
|
2193
|
-
* `validateOn` and `debounceMs` resolve per-field — set the debounce
|
|
2194
|
-
* globally while still overriding the trigger per form:
|
|
2195
|
-
*
|
|
2196
|
-
* ```ts
|
|
2197
|
-
* createAttaform({
|
|
2198
|
-
* defaults: { debounceMs: 100 },
|
|
2199
|
-
* })
|
|
2200
|
-
* // later
|
|
2201
|
-
* useForm({ schema, validateOn: 'blur' })
|
|
2202
|
-
* // → { validateOn: 'blur', debounceMs: <ignored under blur> }
|
|
2203
|
-
* ```
|
|
2204
|
-
*
|
|
2205
|
-
* Note: per the discriminated union, `debounceMs` only takes effect
|
|
2206
|
-
* when `validateOn` is `'change'` (or omitted). Setting it as an
|
|
2207
|
-
* app-level default is fine — forms that switch to `'blur'` /
|
|
2208
|
-
* `'submit'` simply ignore the inherited `debounceMs`.
|
|
2209
|
-
*
|
|
2210
|
-
* `schema`, `key`, and `defaultValues` are not configurable here —
|
|
2211
|
-
* they belong on the per-form call.
|
|
2212
|
-
*/
|
|
2213
|
-
type AttaformDefaults = {
|
|
2214
|
-
/** Default for `useForm({ strict })`. Default `true`. */
|
|
2215
|
-
strict?: boolean;
|
|
2216
|
-
/** Default for `useForm({ onInvalidSubmit })`. */
|
|
2217
|
-
onInvalidSubmit?: OnInvalidSubmitPolicy;
|
|
2218
|
-
/** Default for `useForm({ validateOn })` — when validation runs. */
|
|
2219
|
-
validateOn?: ValidateOn;
|
|
2220
|
-
/**
|
|
2221
|
-
* Default for `useForm({ debounceMs })` — ms to wait after the last
|
|
2222
|
-
* input event before re-running validation. Only meaningful when
|
|
2223
|
-
* `validateOn` resolves to `'change'`. Default `0` (synchronous).
|
|
2224
|
-
*/
|
|
2225
|
-
debounceMs?: number;
|
|
2226
|
-
/** Default for `useForm({ history })` — a `historyPlugin()` instance. */
|
|
2227
|
-
history?: HistoryPlugin;
|
|
2228
|
-
/** Default for `useForm({ rememberVariants })`. */
|
|
2229
|
-
rememberVariants?: boolean;
|
|
2230
|
-
/** Default for `useForm({ disabled })` — freeze the form's data. */
|
|
2231
|
-
disabled?: MaybeRefOrGetter<boolean | undefined>;
|
|
2232
|
-
/**
|
|
2233
|
-
* Default for `useForm({ coerce })`. Schema-driven coercion of
|
|
2234
|
-
* user-typed DOM values at the v-register directive layer.
|
|
2235
|
-
*
|
|
2236
|
-
* - `true` (default) — runs the built-in `defaultCoercionRules`
|
|
2237
|
-
* (`string→number`, `string→boolean`).
|
|
2238
|
-
* - `false` — disables coercion globally; the slim-primitive gate
|
|
2239
|
-
* rejects type mismatches with its existing dev-warn instead.
|
|
2240
|
-
* - `CoercionRegistry` — a custom array of `CoercionEntry` records.
|
|
2241
|
-
* Spread `defaultCoercionRules` to extend rather than replace:
|
|
2242
|
-
* `[...defaultCoercionRules, defineCoercion({ ... })]`.
|
|
2243
|
-
*
|
|
2244
|
-
* Coercion applies ONLY to user-typed DOM values flowing through
|
|
2245
|
-
* the directive's assigner. Programmatic writes (`form.setValue`,
|
|
2246
|
-
* `setValueWithInternalPath`) are NEVER coerced — they're
|
|
2247
|
-
* authoritative writes whose strict typing is on the caller.
|
|
2248
|
-
*/
|
|
2249
|
-
coerce?: boolean | CoercionRegistry;
|
|
2250
|
-
/**
|
|
2251
|
-
* Default for `useForm({ getDisplayState })`. The centralised
|
|
2252
|
-
* heuristic that resolves every path's `field.displayState` — and thus
|
|
2253
|
-
* the `show*` booleans and their `form.meta` rollups — to one of
|
|
2254
|
-
* `'idle' | 'pending' | 'error' | 'success'`.
|
|
2255
|
-
*
|
|
2256
|
-
* Resolution order (per-form wins):
|
|
2257
|
-
*
|
|
2258
|
-
* useForm({ getDisplayState }) > AttaformDefaults > library default
|
|
2259
|
-
*
|
|
2260
|
-
* The library default opens one timing gate, then resolves by
|
|
2261
|
-
* precedence: gate closed → `'idle'`; a run in flight → a delayed
|
|
2262
|
-
* `'pending'` (held briefly to smooth fast validations, then held a
|
|
2263
|
-
* minimum so it never flashes); an own-path error → `'error'`;
|
|
2264
|
-
* otherwise earned `valid` → `'success'`, else `'idle'`. The gate opens
|
|
2265
|
-
* after the first submit attempt OR once the field is edited and left:
|
|
2266
|
-
*
|
|
2267
|
-
* ```ts
|
|
2268
|
-
* (prev, ctx) => {
|
|
2269
|
-
* const gateOpen =
|
|
2270
|
-
* ctx.formMeta.submissionAttempts > 0 ||
|
|
2271
|
-
* ctx.field.blurredAfterInteraction === true
|
|
2272
|
-
* if (!gateOpen) return { display: 'idle' }
|
|
2273
|
-
* // ...timed 'pending' while validating; own-path error → 'error';
|
|
2274
|
-
* // earned valid → 'success'; else 'idle'
|
|
2275
|
-
* }
|
|
2276
|
-
* ```
|
|
2277
|
-
*
|
|
2278
|
-
* Compose with the library default via the public `defaultDisplayState`
|
|
2279
|
-
* export, or retune its timing via `makeDefaultDisplayState`. The
|
|
2280
|
-
* reducer runs on every field-state read, so it owns the
|
|
2281
|
-
* idle / pending / error / success decision outright.
|
|
2282
|
-
*
|
|
2283
|
-
* The reducer's `ctx.field` / `ctx.formMeta` are `Omit`'d of the
|
|
2284
|
-
* derived `displayState` / `show*` / `firstError` keys (see
|
|
2285
|
-
* `FieldStateDerivedKey`) to prevent a self-referential reducer.
|
|
2286
|
-
*/
|
|
2287
|
-
getDisplayState?: GetDisplayState;
|
|
2288
|
-
/**
|
|
2289
|
-
* Default for `useForm({ maxRecursionDepth })`. Recursion ceiling
|
|
2290
|
-
* for schema walks that descend through recursive schemas (Zod's
|
|
2291
|
-
* `z.lazy(...)` today, equivalent constructs in any future adapter).
|
|
2292
|
-
* Library default: `64`.
|
|
2293
|
-
*
|
|
2294
|
-
* Resolution order (per-form wins):
|
|
2295
|
-
*
|
|
2296
|
-
* useForm({ maxRecursionDepth }) > AttaformDefaults > library default (64)
|
|
2297
|
-
*
|
|
2298
|
-
* Read at every step of a schema walk that crosses a recursive
|
|
2299
|
-
* boundary — default-value derivation at construction, slim-primitive
|
|
2300
|
-
* type gates on each write, path-by-path schema resolution. Walks
|
|
2301
|
-
* track their descent depth and switch to a permissive fallback once
|
|
2302
|
-
* `depth > maxRecursionDepth`.
|
|
2303
|
-
*
|
|
2304
|
-
* "Permissive fallback" means storage and reads keep working at any
|
|
2305
|
-
* depth; only the per-write type gate stops checking past the cap.
|
|
2306
|
-
* Full schema validation (`parse`, `handleSubmit`) still runs
|
|
2307
|
-
* against the real schema, so refinement errors at any depth still
|
|
2308
|
-
* surface — the cap only affects the *write-time gate*.
|
|
2309
|
-
*
|
|
2310
|
-
* Forms with no recursive schemas ignore this entirely — the cap is
|
|
2311
|
-
* read only at the descent step through a recursive wrapper. Setting
|
|
2312
|
-
* it app-wide is the right move when you have multiple recursive
|
|
2313
|
-
* forms that should share one ceiling:
|
|
2314
|
-
*
|
|
2315
|
-
* ```ts
|
|
2316
|
-
* createAttaform({
|
|
2317
|
-
* defaults: { maxRecursionDepth: 128 },
|
|
2318
|
-
* })
|
|
2319
|
-
* ```
|
|
2320
|
-
*
|
|
2321
|
-
* Per-form override stays available for the one tree-shaped form
|
|
2322
|
-
* whose depth is unusual:
|
|
2323
|
-
*
|
|
2324
|
-
* ```ts
|
|
2325
|
-
* useForm({ schema: deepCategoryTreeSchema, maxRecursionDepth: 256 })
|
|
2326
|
-
* ```
|
|
2327
|
-
*
|
|
2328
|
-
* Setting this app-wide costs nothing for non-recursive forms — the
|
|
2329
|
-
* walks that read the cap never run for them.
|
|
2330
|
-
*
|
|
2331
|
-
* Pass `Infinity` to disable the cap entirely. Walks will then
|
|
2332
|
-
* descend through recursive boundaries until they terminate
|
|
2333
|
-
* structurally; a schema with no structural terminator will exhaust
|
|
2334
|
-
* the JS call stack. Reserve for schemas whose authors are
|
|
2335
|
-
* confident the recursion is bounded by the actual data shape.
|
|
2336
|
-
*/
|
|
2337
|
-
maxRecursionDepth?: number;
|
|
2338
|
-
/**
|
|
2339
|
-
* App-wide default for `useForm({ autoAria })`. Library default is
|
|
2340
|
-
* `true`: `v-register` keeps `aria-invalid` / `aria-busy` /
|
|
2341
|
-
* `aria-required` / `aria-describedby` in sync with each field's
|
|
2342
|
-
* display state out of the box.
|
|
2343
|
-
*
|
|
2344
|
-
* **Resolution order (per-form wins):**
|
|
2345
|
-
*
|
|
2346
|
-
* useForm({ autoAria }) > AttaformDefaults.autoAria > library default (`true`)
|
|
2347
|
-
*
|
|
2348
|
-
* Set `false` once at the plugin level to make every form manage its
|
|
2349
|
-
* own aria markup. Authored aria attributes are always preserved
|
|
2350
|
-
* regardless of this setting.
|
|
2351
|
-
*/
|
|
2352
|
-
autoAria?: boolean;
|
|
2353
|
-
};
|
|
2354
2057
|
/**
|
|
2355
2058
|
* Callback invoked by `handleSubmit` after the form parses successfully.
|
|
2356
2059
|
* Receives the strictly-typed parsed value — refinements have run, so
|
|
@@ -2363,7 +2066,7 @@ type OnSubmit<Form extends GenericForm> = (form: Form) => void | Promise<void>;
|
|
|
2363
2066
|
* the user-error layer (the `setErrors(...); return` server-rejection
|
|
2364
2067
|
* pattern). Receives the full list of errors. Bind this when you want to
|
|
2365
2068
|
* react to submit failures explicitly (alongside or instead of the
|
|
2366
|
-
* automatic `
|
|
2069
|
+
* automatic `focusOnInvalidSubmit` nudge).
|
|
2367
2070
|
*/
|
|
2368
2071
|
type OnError = (error: ValidationError[]) => void | Promise<void>;
|
|
2369
2072
|
/**
|
|
@@ -2417,11 +2120,11 @@ type DisplayMachine = {
|
|
|
2417
2120
|
readonly pendingShownAt?: number;
|
|
2418
2121
|
};
|
|
2419
2122
|
/**
|
|
2420
|
-
* Inputs to
|
|
2421
|
-
*
|
|
2422
|
-
*
|
|
2423
|
-
* `FieldStateDerivedKey` — so
|
|
2424
|
-
* form a cycle),
|
|
2123
|
+
* Inputs to the display reducer. `field` and `formMeta` are the
|
|
2124
|
+
* reactive snapshots it resolves against (minus the derived
|
|
2125
|
+
* `displayState` / `show*` / `firstError` keys — see
|
|
2126
|
+
* `FieldStateDerivedKey` — so the reducer can never read its own output
|
|
2127
|
+
* and form a cycle), joined by:
|
|
2425
2128
|
*
|
|
2426
2129
|
* - `validatingSince` — `Date.now()` at which the field's current
|
|
2427
2130
|
* validation streak opened, or `null` when nothing is in flight. This,
|
|
@@ -2449,26 +2152,9 @@ type DisplayCtx = {
|
|
|
2449
2152
|
* returns the next machine; the engine owns the clock and the timers, the
|
|
2450
2153
|
* reducer owns the timing policy. Runs on every field-state read (and
|
|
2451
2154
|
* again whenever a `reviewAt` deadline fires), so the whole app's
|
|
2452
|
-
* validation-display behavior flows from this one function
|
|
2453
|
-
*
|
|
2454
|
-
*
|
|
2455
|
-
* layered reducer can compose with it, and `makeDefaultDisplayState`
|
|
2456
|
-
* builds a default with custom anti-flash timings:
|
|
2457
|
-
*
|
|
2458
|
-
* ```ts
|
|
2459
|
-
* import { defaultDisplayState } from 'attaform'
|
|
2460
|
-
*
|
|
2461
|
-
* useForm({
|
|
2462
|
-
* schema,
|
|
2463
|
-
* // Defer to the default everywhere, but never show a success check on `username`.
|
|
2464
|
-
* getDisplayState: (prev, ctx) => {
|
|
2465
|
-
* const next = defaultDisplayState(prev, ctx)
|
|
2466
|
-
* return next.display === 'success' && ctx.field.path[0] === 'username'
|
|
2467
|
-
* ? { display: 'idle' }
|
|
2468
|
-
* : next
|
|
2469
|
-
* },
|
|
2470
|
-
* })
|
|
2471
|
-
* ```
|
|
2155
|
+
* validation-display behavior flows from this one function
|
|
2156
|
+
* (`core/display-state.ts`).
|
|
2157
|
+
* @internal
|
|
2472
2158
|
*/
|
|
2473
2159
|
type GetDisplayState = (prev: DisplayMachine, ctx: DisplayCtx) => DisplayMachine;
|
|
2474
2160
|
/**
|
|
@@ -2604,60 +2290,6 @@ type RegisterFlatPath<Form> = Form extends unknown ? FlatPathBuilder<Form, 'regi
|
|
|
2604
2290
|
* `transformError` channel above, not a throw into the host app.)
|
|
2605
2291
|
*/
|
|
2606
2292
|
type RegisterTransform = (value: unknown, ctx?: TransformContext) => unknown;
|
|
2607
|
-
/**
|
|
2608
|
-
* Runtime type for a slim primitive kind. Used to narrow the
|
|
2609
|
-
* `transform` parameter and return value on a `CoercionEntry` so
|
|
2610
|
-
* authors writing rules don't have to cast `unknown`.
|
|
2611
|
-
*
|
|
2612
|
-
* Exhaustive over `SlimPrimitiveKind` — adding a new kind to that
|
|
2613
|
-
* union must add a corresponding branch here.
|
|
2614
|
-
*/
|
|
2615
|
-
type SlimRuntimeOf<K extends SlimPrimitiveKind> = K extends 'string' ? string : K extends 'number' ? number : K extends 'boolean' ? boolean : K extends 'bigint' ? bigint : K extends 'date' ? Date : K extends 'null' ? null : K extends 'undefined' ? undefined : K extends 'array' ? readonly unknown[] : K extends 'set' ? ReadonlySet<unknown> : K extends 'map' ? ReadonlyMap<unknown, unknown> : K extends 'object' ? Record<string, unknown> : K extends 'symbol' ? symbol : K extends 'function' ? (...args: never[]) => unknown : never;
|
|
2616
|
-
/**
|
|
2617
|
-
* Outcome of a coercion attempt.
|
|
2618
|
-
*
|
|
2619
|
-
* - `coerced: true` — the rule produced `value`, which the directive
|
|
2620
|
-
* forwards to the slim gate (the gate may still reject if the
|
|
2621
|
-
* value doesn't satisfy the path's accept set).
|
|
2622
|
-
* - `coerced: false` — the rule decided it can't coerce this input.
|
|
2623
|
-
* The directive passes the original value through; the slim gate
|
|
2624
|
-
* decides downstream.
|
|
2625
|
-
*
|
|
2626
|
-
* Discriminated rather than `O | undefined` so rules with
|
|
2627
|
-
* `output: 'undefined'` or `output: 'null'` don't conflict with the
|
|
2628
|
-
* "skip" signal.
|
|
2629
|
-
*/
|
|
2630
|
-
type CoercionResult<O> = {
|
|
2631
|
-
coerced: true;
|
|
2632
|
-
value: O;
|
|
2633
|
-
} | {
|
|
2634
|
-
coerced: false;
|
|
2635
|
-
};
|
|
2636
|
-
/**
|
|
2637
|
-
* A single coercion rule. `input` and `output` are
|
|
2638
|
-
* `SlimPrimitiveKind` literals; `transform` receives a value already
|
|
2639
|
-
* narrowed to `SlimRuntimeOf<input>` and returns
|
|
2640
|
-
* `CoercionResult<SlimRuntimeOf<output>>`.
|
|
2641
|
-
*
|
|
2642
|
-
* Rules MUST be sync. They SHOULD NOT throw — wrap internal
|
|
2643
|
-
* try/catch when the conversion can fail (e.g. `BigInt(s)` throws
|
|
2644
|
-
* for non-numeric strings). The library wraps each invocation in
|
|
2645
|
-
* try/catch as defense in depth; throws are caught, logged once per
|
|
2646
|
-
* `(input, output)`, and the original value passes through.
|
|
2647
|
-
*/
|
|
2648
|
-
type CoercionEntry<I extends SlimPrimitiveKind = SlimPrimitiveKind, O extends SlimPrimitiveKind = SlimPrimitiveKind> = {
|
|
2649
|
-
readonly input: I;
|
|
2650
|
-
readonly output: O;
|
|
2651
|
-
readonly transform: (value: SlimRuntimeOf<I>) => CoercionResult<SlimRuntimeOf<O>>;
|
|
2652
|
-
};
|
|
2653
|
-
/**
|
|
2654
|
-
* A registry is an ordered array of `CoercionEntry` records.
|
|
2655
|
-
* Consumers compose by spreading `defaultCoercionRules` and
|
|
2656
|
-
* appending their own entries. Order is observable only when two
|
|
2657
|
-
* entries share the same `(input, output)` pair — the library emits
|
|
2658
|
-
* a one-shot dev-warn and the LATER entry wins.
|
|
2659
|
-
*/
|
|
2660
|
-
type CoercionRegistry = readonly CoercionEntry[];
|
|
2661
2293
|
/**
|
|
2662
2294
|
* Options for `register(path, options)`. Per-field configuration
|
|
2663
2295
|
* applied at the binding's own call site.
|
|
@@ -2695,22 +2327,6 @@ type RegisterOptions = {
|
|
|
2695
2327
|
* instead — see the "Custom assigners" section in the API docs.
|
|
2696
2328
|
*/
|
|
2697
2329
|
transforms?: ReadonlyArray<RegisterTransform>;
|
|
2698
|
-
/**
|
|
2699
|
-
* Per-binding override for automatic aria management, the narrowest
|
|
2700
|
-
* tier of the `autoAria` cascade. By default the directive keeps
|
|
2701
|
-
* `aria-invalid` / `aria-busy` / `aria-required` / `aria-describedby`
|
|
2702
|
-
* in sync with the field's display state. Pass `autoAria: false` to
|
|
2703
|
-
* leave every aria attribute on this element to you (the directive
|
|
2704
|
-
* still manages value binding and registration), or `autoAria: true`
|
|
2705
|
-
* to re-enable management on one binding even when the form set
|
|
2706
|
-
* `useForm({ autoAria: false })`.
|
|
2707
|
-
*
|
|
2708
|
-
* Overrides `useForm({ autoAria })` and
|
|
2709
|
-
* `createAttaform({ defaults: { autoAria } })`. Writing an aria
|
|
2710
|
-
* attribute yourself also locks the directive out of that one
|
|
2711
|
-
* attribute, regardless of this flag.
|
|
2712
|
-
*/
|
|
2713
|
-
autoAria?: boolean;
|
|
2714
2330
|
};
|
|
2715
2331
|
/**
|
|
2716
2332
|
* The narrow kernel surface the DOM binding drives. Structurally a
|
|
@@ -3048,14 +2664,6 @@ type RegisterValue<Value = unknown> = Readonly<{
|
|
|
3048
2664
|
* @internal
|
|
3049
2665
|
*/
|
|
3050
2666
|
isRequired?: boolean;
|
|
3051
|
-
/**
|
|
3052
|
-
* Whether the directive should auto-manage aria attributes for this
|
|
3053
|
-
* binding. Resolves the per-register `autoAria` override against the
|
|
3054
|
-
* form-level value: `options.autoAria ?? formAutoAria`. The directive
|
|
3055
|
-
* treats an absent value as off.
|
|
3056
|
-
* @internal
|
|
3057
|
-
*/
|
|
3058
|
-
ariaEnabled?: boolean;
|
|
3059
2667
|
/**
|
|
3060
2668
|
* The gated display-state verdict for this path, reusing the same
|
|
3061
2669
|
* field-state identity as `form.fields`. The directive watches it to
|
|
@@ -3604,11 +3212,11 @@ type FieldState<Value = unknown> = {
|
|
|
3604
3212
|
* <FieldStatusIcon :state="form.fields.email.displayState" />
|
|
3605
3213
|
* ```
|
|
3606
3214
|
*
|
|
3607
|
-
* Resolved by the
|
|
3608
|
-
*
|
|
3609
|
-
* `
|
|
3610
|
-
*
|
|
3611
|
-
*
|
|
3215
|
+
* Resolved by the display heuristic: gate closed → `'idle'`; a run
|
|
3216
|
+
* in flight → a delayed `'pending'`; an own-path error → `'error'`;
|
|
3217
|
+
* otherwise earned `valid` → `'success'`, else `'idle'`. The gate
|
|
3218
|
+
* opens after the first submit attempt OR once the field is edited
|
|
3219
|
+
* and left.
|
|
3612
3220
|
*
|
|
3613
3221
|
* Available on container paths too: `form.fields.users[0].displayState`
|
|
3614
3222
|
* rolls up over the row's descendants.
|
|
@@ -4200,9 +3808,8 @@ type FormMeta<F = unknown> = FieldState<F> & {
|
|
|
4200
3808
|
* the counter at its prior value.
|
|
4201
3809
|
*
|
|
4202
3810
|
* Pure introspection counter — useful for "this form has been
|
|
4203
|
-
* visited and left" UX (analytics, prior-step badges
|
|
4204
|
-
*
|
|
4205
|
-
* default `getDisplayState` heuristic. The reveal-on-submit story
|
|
3811
|
+
* visited and left" UX (analytics, prior-step badges) but does NOT
|
|
3812
|
+
* drive the display heuristic. The reveal-on-submit story
|
|
4206
3813
|
* runs entirely through `submissionAttempts`, which
|
|
4207
3814
|
* `wizard.handleSubmit` bumps on every form (it always validates the
|
|
4208
3815
|
* whole step list).
|
|
@@ -4968,20 +4575,19 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4968
4575
|
*/
|
|
4969
4576
|
scrollToFirstError: (options?: ScrollIntoViewOptions) => boolean;
|
|
4970
4577
|
/**
|
|
4971
|
-
*
|
|
4972
|
-
*
|
|
4973
|
-
*
|
|
4974
|
-
* `useForm({ onInvalidSubmit })` (or `'focus-first-error'` when
|
|
4975
|
-
* omitted). Pass an explicit policy to override for one call.
|
|
4578
|
+
* Run the form's own invalid-submit nudge imperatively: exactly what
|
|
4579
|
+
* `handleSubmit` does after a failed submit, but available standalone
|
|
4580
|
+
* and honoring this form's `useForm({ focusOnInvalidSubmit })` choice.
|
|
4976
4581
|
*
|
|
4977
4582
|
* Used by `useWizard` after navigating to the first failing form
|
|
4978
4583
|
* during `wizard.handleSubmit`, so the failing form's own configured
|
|
4979
|
-
*
|
|
4584
|
+
* behavior fires once its DOM is in view.
|
|
4980
4585
|
*
|
|
4981
|
-
* No-op when
|
|
4982
|
-
*
|
|
4586
|
+
* No-op when this form opted out, or when no errored field is
|
|
4587
|
+
* currently registered. Use `focusFirstError()` to focus regardless
|
|
4588
|
+
* of the configured choice.
|
|
4983
4589
|
*/
|
|
4984
|
-
applyInvalidSubmitPolicy: (
|
|
4590
|
+
applyInvalidSubmitPolicy: () => void;
|
|
4985
4591
|
/**
|
|
4986
4592
|
* Programmatically mark fields as `touched` — the descriptive
|
|
4987
4593
|
* "this field was visited" flag.
|
|
@@ -4997,9 +4603,9 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4997
4603
|
* heuristic.** `touched` also flips on a bare focus → blur with no
|
|
4998
4604
|
* edit, so the library-default gate deliberately ignores it and
|
|
4999
4605
|
* reads `blurredAfterInteraction` instead — the stricter bit that
|
|
5000
|
-
* only a blur *following* an edit sets. Reach for `touch()` when
|
|
5001
|
-
*
|
|
5002
|
-
*
|
|
4606
|
+
* only a blur *following* an edit sets. Reach for `touch()` when
|
|
4607
|
+
* your own analytics reads `touched`; reach for
|
|
4608
|
+
* {@link UseFormReturnType.interact} to make
|
|
5003
4609
|
* seeded or imported values surface their errors.
|
|
5004
4610
|
*
|
|
5005
4611
|
* Pure flag write — does not mutate value, focused, blurred, or
|
|
@@ -5151,5 +4757,5 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
5151
4757
|
blankPaths: ComputedRef<BlankPathsView>;
|
|
5152
4758
|
};
|
|
5153
4759
|
|
|
5154
|
-
export { ROOT_PATH as
|
|
5155
|
-
export type {
|
|
4760
|
+
export { ROOT_PATH as R, canonicalizePath as aj, isPathPrefix as ak, isUnset as al, parseDottedPath as am, unset as an, ROOT_PATH_KEY as z };
|
|
4761
|
+
export type { SchemaDefaultsResult as $, AbstractSchema as A, ReactiveValidationStatus as B, CustomDirectiveRegisterAssignerFn as C, DefaultValuesInput as D, ErrorInput as E, FormKey as F, GenericForm as G, HandleSubmit as H, IsTuple as I, JoinSegments as J, KeyofUnion as K, LiftedValueShape as L, MetaTrackerValue as M, NestedReadType as N, OnError as O, ParseOptions as P, RecordPath as Q, RecordValue as S, RegisterDirective as T, UseFormConfiguration as U, RegisterFlatPath as V, RegisterOptions as W, RegisterSelectModifier as X, RegisterTextModifier as Y, RegisterTransform as Z, RegisterValue as _, UseFormReturnType as a, SchemaParseErrorWithData as a0, SchemaParseErrorWithoutData as a1, SchemaParseResult as a2, SchemaParseSuccess as a3, Segment as a4, SetValueCallback as a5, SetValuePayload as a6, SettledValidationStatus as a7, SlimPrimitiveKind as a8, SubmitHandler as a9, Unset as aa, ValidateOn as ab, ValidateOnConfig as ac, ValidationError as ad, ValidationResponse as ae, ValidationResponseWithoutValue as af, ValueOfUnion as ag, WriteMeta as ah, WriteShape as ai, RegisterModelDynamicCustomDirective as ao, SchemaFactoryOptions as ap, AcceptableDefaults as aq, DisplayCtx as ar, GetDisplayState as as, DisplayMachine as at, FieldRecord as au, ErrorCell as av, OriginalsRecord as aw, AttaformDomBinding as ax, TransformAbortHolder as ay, ArrayItem as b, ArrayPath as c, DeepPartial as d, DefaultValuesShape as e, DisplayState as f, ErrorsProxyShape as g, FieldMetaPayload as h, FieldState as i, FieldStateMap as j, FieldStateMapEntry as k, FlatPath as l, FormErrorRecord as m, FormErrorsSurface as n, FormMeta as o, HistoryPlugin as p, IsUnion as q, Json as r, NestedType as s, OnSubmit as t, PartialFlatPath as u, Path as v, PathKey as w, PendingValidationStatus as x, Primitive as y };
|