attaform 0.21.1 → 0.21.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/chunks/dev-key-collision-warnings.cjs +1 -1
- package/dist/chunks/dev-key-collision-warnings.mjs +1 -1
- package/dist/chunks/devtools.cjs +1 -1
- package/dist/chunks/devtools.mjs +1 -1
- package/dist/chunks/fingerprint2.cjs +1 -1
- package/dist/chunks/fingerprint2.mjs +1 -1
- package/dist/chunks/indexeddb.cjs +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/multi-tab-sync.cjs +2 -2
- package/dist/chunks/multi-tab-sync.mjs +2 -2
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/chunks/wire-persistence.cjs +2 -2
- package/dist/chunks/wire-persistence.mjs +2 -2
- package/dist/index.cjs +37 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -18
- package/dist/index.d.mts +20 -18
- package/dist/index.d.ts +20 -18
- package/dist/index.mjs +38 -25
- 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 +396 -216
- package/dist/runtime/components/DevtoolsValueTree.vue +176 -114
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.D32WwKk6.cjs → attaform.B5LNzqQh.cjs} +243 -352
- package/dist/shared/attaform.B5LNzqQh.cjs.map +1 -0
- package/dist/shared/{attaform.S-pYLSo4.cjs → attaform.BBDIKtKY.cjs} +13 -16
- package/dist/shared/attaform.BBDIKtKY.cjs.map +1 -0
- package/dist/shared/{attaform.Bv7dRDWK.d.ts → attaform.BCcrLApm.d.mts} +54 -63
- package/dist/shared/{attaform.BupwXkj_.mjs → attaform.BFWb6hDk.mjs} +29 -23
- package/dist/shared/attaform.BFWb6hDk.mjs.map +1 -0
- package/dist/shared/{attaform.BWfliRIK.d.cts → attaform.BGf_J22U.d.ts} +54 -63
- package/dist/shared/{attaform.DMEP_ENr.mjs → attaform.BVeLgfEh.mjs} +14 -17
- package/dist/shared/attaform.BVeLgfEh.mjs.map +1 -0
- package/dist/shared/{attaform.MtrpT6Ki.d.ts → attaform.BYgioWLF.d.ts} +1 -1
- package/dist/shared/{attaform.NQ8mybyW.d.mts → attaform.BkjJfMvJ.d.cts} +54 -63
- package/dist/shared/{attaform.Duecg2NO.d.mts → attaform.BoY6RZUl.d.cts} +1 -1
- package/dist/shared/{attaform.Bq5sX7TF.cjs → attaform.BwLp9KM7.cjs} +2 -2
- package/dist/shared/{attaform.Bq5sX7TF.cjs.map → attaform.BwLp9KM7.cjs.map} +1 -1
- package/dist/shared/{attaform.CICFZ1iS.cjs → attaform.BwrowMp2.cjs} +19 -45
- package/dist/shared/attaform.BwrowMp2.cjs.map +1 -0
- package/dist/shared/{attaform.Y1ZGhM4k.mjs → attaform.C41gjp-a.mjs} +2 -2
- package/dist/shared/{attaform.Y1ZGhM4k.mjs.map → attaform.C41gjp-a.mjs.map} +1 -1
- package/dist/shared/{attaform.BM6YD9kZ.cjs → attaform.CR6wGvNu.cjs} +29 -23
- package/dist/shared/attaform.CR6wGvNu.cjs.map +1 -0
- package/dist/shared/{attaform.DR6RmxWZ.mjs → attaform.CTheKoTc.mjs} +341 -221
- package/dist/shared/attaform.CTheKoTc.mjs.map +1 -0
- package/dist/shared/{attaform.BSkvn43g.cjs → attaform.CcnF1AKJ.cjs} +4 -4
- package/dist/shared/attaform.CcnF1AKJ.cjs.map +1 -0
- package/dist/shared/{attaform.FudOcHaa.d.cts → attaform.CnEl--PF.d.mts} +1 -1
- package/dist/shared/{attaform.DozgVlCE.mjs → attaform.CrD73S4m.mjs} +4 -4
- package/dist/shared/attaform.CrD73S4m.mjs.map +1 -0
- package/dist/shared/{attaform.ClXwitZj.cjs → attaform.D2ZuIOCf.cjs} +347 -226
- package/dist/shared/attaform.D2ZuIOCf.cjs.map +1 -0
- package/dist/shared/{attaform.Be8NZG9M.mjs → attaform.D6GYGshL.mjs} +19 -45
- package/dist/shared/attaform.D6GYGshL.mjs.map +1 -0
- package/dist/shared/{attaform.pmtahXKy.mjs → attaform.DP-u7_tk.mjs} +243 -352
- package/dist/shared/attaform.DP-u7_tk.mjs.map +1 -0
- package/dist/shared/{attaform.D0dWZsJt.d.mts → attaform.ory-3WhV.d.cts} +128 -129
- package/dist/shared/{attaform.D0dWZsJt.d.cts → attaform.ory-3WhV.d.mts} +128 -129
- package/dist/shared/{attaform.D0dWZsJt.d.ts → attaform.ory-3WhV.d.ts} +128 -129
- package/dist/transforms.cjs +1 -1
- package/dist/transforms.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/zod-v3.cjs +3 -4
- package/dist/zod-v3.cjs.map +1 -1
- package/dist/zod-v3.d.cts +4 -4
- package/dist/zod-v3.d.mts +4 -4
- package/dist/zod-v3.d.ts +4 -4
- package/dist/zod-v3.mjs +2 -3
- package/dist/zod-v3.mjs.map +1 -1
- package/dist/zod-v4.cjs +3 -4
- package/dist/zod-v4.cjs.map +1 -1
- package/dist/zod-v4.d.cts +4 -4
- package/dist/zod-v4.d.mts +4 -4
- package/dist/zod-v4.d.ts +4 -4
- package/dist/zod-v4.mjs +2 -3
- package/dist/zod-v4.mjs.map +1 -1
- package/dist/zod.cjs +6 -6
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +31 -22
- package/dist/zod.d.mts +31 -22
- package/dist/zod.d.ts +31 -22
- package/dist/zod.mjs +5 -6
- package/dist/zod.mjs.map +1 -1
- package/package.json +3 -11
- package/dist/shared/attaform.BM6YD9kZ.cjs.map +0 -1
- package/dist/shared/attaform.BSkvn43g.cjs.map +0 -1
- package/dist/shared/attaform.Be8NZG9M.mjs.map +0 -1
- package/dist/shared/attaform.BupwXkj_.mjs.map +0 -1
- package/dist/shared/attaform.CICFZ1iS.cjs.map +0 -1
- package/dist/shared/attaform.ClXwitZj.cjs.map +0 -1
- package/dist/shared/attaform.D32WwKk6.cjs.map +0 -1
- package/dist/shared/attaform.DMEP_ENr.mjs.map +0 -1
- package/dist/shared/attaform.DR6RmxWZ.mjs.map +0 -1
- package/dist/shared/attaform.DozgVlCE.mjs.map +0 -1
- package/dist/shared/attaform.S-pYLSo4.cjs.map +0 -1
- package/dist/shared/attaform.pmtahXKy.mjs.map +0 -1
- package/dist/shared/{attaform.DSD85fHb.d.cts → attaform.nf83TIR5.d.cts} +10 -10
- package/dist/shared/{attaform.DSD85fHb.d.mts → attaform.nf83TIR5.d.mts} +10 -10
- package/dist/shared/{attaform.DSD85fHb.d.ts → attaform.nf83TIR5.d.ts} +10 -10
|
@@ -73,6 +73,123 @@ type ResolvedFieldMeta = {
|
|
|
73
73
|
readonly meta: Readonly<FieldMetaPayload>;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Path primitives for advanced integrations. The form library accepts
|
|
78
|
+
* paths in dotted-string form (`'user.email'`) at every public API.
|
|
79
|
+
* These primitives are exposed for adapter authors who need to
|
|
80
|
+
* canonicalise user-provided paths.
|
|
81
|
+
*/
|
|
82
|
+
declare const pathKeyBrand: unique symbol;
|
|
83
|
+
/**
|
|
84
|
+
* Branded string identifier for a canonicalised path. Useful as a
|
|
85
|
+
* `Map` key — two paths that resolve to the same canonical form
|
|
86
|
+
* produce the same `PathKey`. Treat as opaque; don't try to parse.
|
|
87
|
+
*/
|
|
88
|
+
type PathKey = string & {
|
|
89
|
+
readonly [pathKeyBrand]: 'PathKey';
|
|
90
|
+
};
|
|
91
|
+
/** A single path segment — a property name or array index. */
|
|
92
|
+
type Segment = string | number;
|
|
93
|
+
/** A structured path as a read-only sequence of segments. */
|
|
94
|
+
type Path = readonly Segment[];
|
|
95
|
+
/**
|
|
96
|
+
* Parse a dotted-string path into structured segments.
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* parseDottedPath('user.address.line1') // ['user', 'address', 'line1']
|
|
100
|
+
* parseDottedPath('items.0.name') // ['items', 0, 'name']
|
|
101
|
+
* parseDottedPath('') // [''] (the empty-string key)
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* The empty-string input `''` is the **literal empty-key path**, not
|
|
105
|
+
* the root. Use the array form `[]` for root. Form-level errors
|
|
106
|
+
* (root `.refine()`) live at the empty-string path bucket so
|
|
107
|
+
* `errors('')` returns them without sweeping every field error too.
|
|
108
|
+
*
|
|
109
|
+
* Throws `InvalidPathError` for paths with empty INTERNAL segments
|
|
110
|
+
* (`'a..b'`, leading or trailing dots). For keys containing literal
|
|
111
|
+
* dots, pass an array form (`['user.name']`) instead.
|
|
112
|
+
*/
|
|
113
|
+
declare function parseDottedPath(path: string): Segment[];
|
|
114
|
+
/**
|
|
115
|
+
* Canonicalise a path into structured segments plus a stable string
|
|
116
|
+
* key. Accepts either dotted-string or array form; integer-looking
|
|
117
|
+
* segments normalise to numbers.
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* canonicalizePath('items.0.name')
|
|
121
|
+
* // { segments: ['items', 0, 'name'], key: '["items",0,"name"]' as PathKey }
|
|
122
|
+
*
|
|
123
|
+
* canonicalizePath(['items', 0, 'name'])
|
|
124
|
+
* // → same result
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* The returned `key` is suitable as a `Map`/`Set` key — equal paths
|
|
128
|
+
* produce equal keys regardless of input form.
|
|
129
|
+
*/
|
|
130
|
+
declare function canonicalizePath(input: string | Path): {
|
|
131
|
+
segments: readonly Segment[];
|
|
132
|
+
key: PathKey;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* The root path — an empty segment tuple. Pass to APIs that accept
|
|
136
|
+
* a `Path` to address the form value as a whole.
|
|
137
|
+
*/
|
|
138
|
+
declare const ROOT_PATH: Path;
|
|
139
|
+
/** Stable string key for the root path. */
|
|
140
|
+
declare const ROOT_PATH_KEY: PathKey;
|
|
141
|
+
/**
|
|
142
|
+
* `true` when `path` starts with every segment of `prefix` (in order).
|
|
143
|
+
* The empty `prefix` matches every path — ROOT prefix is universal.
|
|
144
|
+
*
|
|
145
|
+
* Walks segments rather than `PathKey` strings because the data this
|
|
146
|
+
* helper operates on (e.g. `meta.errors[].path`) carries segment
|
|
147
|
+
* arrays directly.
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* isPathPrefix(['cargo'], ['cargo', 'items', 0, 'sku']) // true
|
|
151
|
+
* isPathPrefix(['cargo', 'items'], ['cargo']) // false (path shorter)
|
|
152
|
+
* isPathPrefix([], ['anything']) // true (root prefix)
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare function isPathPrefix(prefix: readonly Segment[], path: readonly Segment[]): boolean;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Per-FormStore registry tracking which DOM elements have opted into
|
|
159
|
+
* persistence for which paths. Lives on the FormStore so that two SFCs
|
|
160
|
+
* sharing a key share the registry — opt-ins are per-element, not
|
|
161
|
+
* per-component.
|
|
162
|
+
*
|
|
163
|
+
* The directive's input handler computes `meta.persist` for each write
|
|
164
|
+
* by calling `hasOptIn(elementId, path)` — only THIS element's writes
|
|
165
|
+
* persist if THIS element opted in. Other call sites that aren't tied
|
|
166
|
+
* to a single element (history undo/redo, field-array helpers, devtools
|
|
167
|
+
* edits) use `hasAnyOptInForPath(path)` — persist if any element has
|
|
168
|
+
* opted into that path.
|
|
169
|
+
*
|
|
170
|
+
* Internal data structure: `Map<PathKey, Set<elementId>>`. Small forms
|
|
171
|
+
* have ~10-50 paths; iteration is cheap. All operations are O(1) given
|
|
172
|
+
* (id, path).
|
|
173
|
+
*/
|
|
174
|
+
type PersistOptInRegistry = {
|
|
175
|
+
/** Add an opt-in entry; idempotent. */
|
|
176
|
+
add(elementId: string, path: PathKey): void;
|
|
177
|
+
/** Remove a single (element, path) entry. */
|
|
178
|
+
remove(elementId: string, path: PathKey): void;
|
|
179
|
+
/** Remove every opt-in for `elementId`. Called from directive's beforeUnmount. */
|
|
180
|
+
removeAllFor(elementId: string): void;
|
|
181
|
+
/** Check whether THIS element has opted into THIS path. */
|
|
182
|
+
hasOptIn(elementId: string, path: PathKey): boolean;
|
|
183
|
+
/** Check whether ANY element has opted into this path. */
|
|
184
|
+
hasAnyOptInForPath(path: PathKey): boolean;
|
|
185
|
+
/** Iterate every path that currently has at least one opt-in. */
|
|
186
|
+
optedInPaths(): IterableIterator<PathKey>;
|
|
187
|
+
/** True iff no element has opted into any path. */
|
|
188
|
+
isEmpty(): boolean;
|
|
189
|
+
/** Drop every entry. Called from FormStore.dispose. */
|
|
190
|
+
clear(): void;
|
|
191
|
+
};
|
|
192
|
+
|
|
76
193
|
/** Internal brand for the `Unset` type. Never exposed at runtime. */
|
|
77
194
|
declare const _unsetBrand: unique symbol;
|
|
78
195
|
/**
|
|
@@ -545,6 +662,15 @@ type DefaultValuesInput<T> = T extends string ? string | Unset : T extends numbe
|
|
|
545
662
|
[K in keyof T]?: DefaultValuesInput<T[K]>;
|
|
546
663
|
} | Unset : T;
|
|
547
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Identifier for a form. A `FormKey` is the string passed via
|
|
667
|
+
* `useForm({ key })`, used to look up a form by name from a distant
|
|
668
|
+
* component, namespace persisted drafts, and label errors and
|
|
669
|
+
* DevTools entries. Anonymous `useForm` calls allocate one
|
|
670
|
+
* automatically; you only need to pick one when the form needs
|
|
671
|
+
* stable identity.
|
|
672
|
+
*/
|
|
673
|
+
type FormKey = string;
|
|
548
674
|
/**
|
|
549
675
|
* Per-form options threaded from `useForm` into the adapter factory.
|
|
550
676
|
* Today carries the resolved `maxRecursionDepth` so adapter walks can
|
|
@@ -555,133 +681,6 @@ interface SchemaFactoryOptions {
|
|
|
555
681
|
/** Resolved recursion ceiling (per-form > app-default > library default). */
|
|
556
682
|
maxRecursionDepth: number;
|
|
557
683
|
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Path primitives for advanced integrations. The form library accepts
|
|
561
|
-
* paths in dotted-string form (`'user.email'`) at every public API.
|
|
562
|
-
* These primitives are exposed for adapter authors who need to
|
|
563
|
-
* canonicalise user-provided paths.
|
|
564
|
-
*/
|
|
565
|
-
declare const pathKeyBrand: unique symbol;
|
|
566
|
-
/**
|
|
567
|
-
* Branded string identifier for a canonicalised path. Useful as a
|
|
568
|
-
* `Map` key — two paths that resolve to the same canonical form
|
|
569
|
-
* produce the same `PathKey`. Treat as opaque; don't try to parse.
|
|
570
|
-
*/
|
|
571
|
-
type PathKey = string & {
|
|
572
|
-
readonly [pathKeyBrand]: 'PathKey';
|
|
573
|
-
};
|
|
574
|
-
/** A single path segment — a property name or array index. */
|
|
575
|
-
type Segment = string | number;
|
|
576
|
-
/** A structured path as a read-only sequence of segments. */
|
|
577
|
-
type Path = readonly Segment[];
|
|
578
|
-
/**
|
|
579
|
-
* Parse a dotted-string path into structured segments.
|
|
580
|
-
*
|
|
581
|
-
* ```ts
|
|
582
|
-
* parseDottedPath('user.address.line1') // ['user', 'address', 'line1']
|
|
583
|
-
* parseDottedPath('items.0.name') // ['items', 0, 'name']
|
|
584
|
-
* parseDottedPath('') // [''] (the empty-string key)
|
|
585
|
-
* ```
|
|
586
|
-
*
|
|
587
|
-
* The empty-string input `''` is the **literal empty-key path**, not
|
|
588
|
-
* the root. Use the array form `[]` for root. Form-level errors
|
|
589
|
-
* (root `.refine()`) live at the empty-string path bucket so
|
|
590
|
-
* `errors('')` returns them without sweeping every field error too.
|
|
591
|
-
*
|
|
592
|
-
* Throws `InvalidPathError` for paths with empty INTERNAL segments
|
|
593
|
-
* (`'a..b'`, leading or trailing dots). For keys containing literal
|
|
594
|
-
* dots, pass an array form (`['user.name']`) instead.
|
|
595
|
-
*/
|
|
596
|
-
declare function parseDottedPath(path: string): Segment[];
|
|
597
|
-
/**
|
|
598
|
-
* Canonicalise a path into structured segments plus a stable string
|
|
599
|
-
* key. Accepts either dotted-string or array form; integer-looking
|
|
600
|
-
* segments normalise to numbers.
|
|
601
|
-
*
|
|
602
|
-
* ```ts
|
|
603
|
-
* canonicalizePath('items.0.name')
|
|
604
|
-
* // { segments: ['items', 0, 'name'], key: '["items",0,"name"]' as PathKey }
|
|
605
|
-
*
|
|
606
|
-
* canonicalizePath(['items', 0, 'name'])
|
|
607
|
-
* // → same result
|
|
608
|
-
* ```
|
|
609
|
-
*
|
|
610
|
-
* The returned `key` is suitable as a `Map`/`Set` key — equal paths
|
|
611
|
-
* produce equal keys regardless of input form.
|
|
612
|
-
*/
|
|
613
|
-
declare function canonicalizePath(input: string | Path): {
|
|
614
|
-
segments: readonly Segment[];
|
|
615
|
-
key: PathKey;
|
|
616
|
-
};
|
|
617
|
-
/**
|
|
618
|
-
* The root path — an empty segment tuple. Pass to APIs that accept
|
|
619
|
-
* a `Path` to address the form value as a whole.
|
|
620
|
-
*/
|
|
621
|
-
declare const ROOT_PATH: Path;
|
|
622
|
-
/** Stable string key for the root path. */
|
|
623
|
-
declare const ROOT_PATH_KEY: PathKey;
|
|
624
|
-
/**
|
|
625
|
-
* `true` when `path` starts with every segment of `prefix` (in order).
|
|
626
|
-
* The empty `prefix` matches every path — ROOT prefix is universal.
|
|
627
|
-
*
|
|
628
|
-
* Walks segments rather than `PathKey` strings because the data this
|
|
629
|
-
* helper operates on (e.g. `meta.errors[].path`) carries segment
|
|
630
|
-
* arrays directly.
|
|
631
|
-
*
|
|
632
|
-
* ```ts
|
|
633
|
-
* isPathPrefix(['cargo'], ['cargo', 'items', 0, 'sku']) // true
|
|
634
|
-
* isPathPrefix(['cargo', 'items'], ['cargo']) // false (path shorter)
|
|
635
|
-
* isPathPrefix([], ['anything']) // true (root prefix)
|
|
636
|
-
* ```
|
|
637
|
-
*/
|
|
638
|
-
declare function isPathPrefix(prefix: readonly Segment[], path: readonly Segment[]): boolean;
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Per-FormStore registry tracking which DOM elements have opted into
|
|
642
|
-
* persistence for which paths. Lives on the FormStore so that two SFCs
|
|
643
|
-
* sharing a key share the registry — opt-ins are per-element, not
|
|
644
|
-
* per-component.
|
|
645
|
-
*
|
|
646
|
-
* The directive's input handler computes `meta.persist` for each write
|
|
647
|
-
* by calling `hasOptIn(elementId, path)` — only THIS element's writes
|
|
648
|
-
* persist if THIS element opted in. Other call sites that aren't tied
|
|
649
|
-
* to a single element (history undo/redo, field-array helpers, devtools
|
|
650
|
-
* edits) use `hasAnyOptInForPath(path)` — persist if any element has
|
|
651
|
-
* opted into that path.
|
|
652
|
-
*
|
|
653
|
-
* Internal data structure: `Map<PathKey, Set<elementId>>`. Small forms
|
|
654
|
-
* have ~10-50 paths; iteration is cheap. All operations are O(1) given
|
|
655
|
-
* (id, path).
|
|
656
|
-
*/
|
|
657
|
-
type PersistOptInRegistry = {
|
|
658
|
-
/** Add an opt-in entry; idempotent. */
|
|
659
|
-
add(elementId: string, path: PathKey): void;
|
|
660
|
-
/** Remove a single (element, path) entry. */
|
|
661
|
-
remove(elementId: string, path: PathKey): void;
|
|
662
|
-
/** Remove every opt-in for `elementId`. Called from directive's beforeUnmount. */
|
|
663
|
-
removeAllFor(elementId: string): void;
|
|
664
|
-
/** Check whether THIS element has opted into THIS path. */
|
|
665
|
-
hasOptIn(elementId: string, path: PathKey): boolean;
|
|
666
|
-
/** Check whether ANY element has opted into this path. */
|
|
667
|
-
hasAnyOptInForPath(path: PathKey): boolean;
|
|
668
|
-
/** Iterate every path that currently has at least one opt-in. */
|
|
669
|
-
optedInPaths(): IterableIterator<PathKey>;
|
|
670
|
-
/** True iff no element has opted into any path. */
|
|
671
|
-
isEmpty(): boolean;
|
|
672
|
-
/** Drop every entry. Called from FormStore.dispose. */
|
|
673
|
-
clear(): void;
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* Identifier for a form. A `FormKey` is the string passed via
|
|
678
|
-
* `useForm({ key })`, used to look up a form by name from a distant
|
|
679
|
-
* component, namespace persisted drafts, and label errors and
|
|
680
|
-
* DevTools entries. Anonymous `useForm` calls allocate one
|
|
681
|
-
* automatically; you only need to pick one when the form needs
|
|
682
|
-
* stable identity.
|
|
683
|
-
*/
|
|
684
|
-
type FormKey = string;
|
|
685
684
|
/**
|
|
686
685
|
* One validation failure. `path` points at the offending field as a
|
|
687
686
|
* structured array — `['user', 'address', 0, 'line1']` for a nested
|
|
@@ -4916,5 +4915,5 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4916
4915
|
blankPaths: ComputedRef<BlankPathsView>;
|
|
4917
4916
|
};
|
|
4918
4917
|
|
|
4919
|
-
export { ROOT_PATH as
|
|
4920
|
-
export type {
|
|
4918
|
+
export { ROOT_PATH as a4, ROOT_PATH_KEY as a5, canonicalizePath as as, isPathPrefix as at, isUnset as au, parseDottedPath as av, unset as aw };
|
|
4919
|
+
export type { PendingValidationStatus as $, AttaformDefaults as A, FormStorage as B, CoercionEntry as C, DefaultValuesInput as D, ErrorsProxyShape as E, FormKey as F, GenericForm as G, FormStorageKind as H, HandleSubmit as I, HistoryConfig as J, IsTuple as K, IsUnion as L, JoinSegments as M, KeyofUnion as N, LiftedValueShape as O, MetaTrackerValue as P, NestedReadType as Q, RegisterModelDynamicCustomDirective as R, NestedType as S, OnError as T, UseFormConfiguration as U, ValidationError as V, OnInvalidSubmitPolicy as W, OnSubmit as X, PartialFlatPath as Y, Path as Z, PathKey as _, AbstractSchema as a, PersistConfig as a0, PersistConfigOptions as a1, PersistIncludeMode as a2, Primitive as a3, ReactiveValidationStatus as a6, RegisterDirective as a7, RegisterFlatPath as a8, RegisterOptions as a9, RegisterSelectModifier as aa, RegisterTextModifier as ab, RegisterTransform as ac, Segment as ad, SetValueCallback as ae, SetValuePayload as af, SettledValidationStatus as ag, SlimPrimitiveKind as ah, SlimRuntimeOf as ai, SubmitHandler as aj, Unset as ak, ValidateOn as al, ValidateOnConfig as am, ValidationResponse as an, ValidationResponseWithoutValue as ao, ValueOfUnion as ap, WriteMeta as aq, WriteShape as ar, SchemaFactoryOptions as ax, TransformAbortHolder as ay, PersistOptInRegistry as az, UseFormReturnType as b, RegisterValue as c, GetDisplayState as d, ApiErrorEnvelope as e, ApiErrorDetails as f, ApiErrorEntry as g, ArrayItem as h, ArrayPath as i, CoercionRegistry as j, CoercionResult as k, CustomDirectiveRegisterAssignerFn as l, DeepPartial as m, DefaultValuesResponse as n, DefaultValuesShape as o, DisplayCtx as p, DisplayMachine as q, DisplayState as r, FieldMetaPayload as s, FieldState as t, FieldStateMap as u, FieldStateMapEntry as v, FlatPath as w, FormErrorRecord as x, FormErrorsSurface as y, FormMeta as z };
|
|
@@ -73,6 +73,123 @@ type ResolvedFieldMeta = {
|
|
|
73
73
|
readonly meta: Readonly<FieldMetaPayload>;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Path primitives for advanced integrations. The form library accepts
|
|
78
|
+
* paths in dotted-string form (`'user.email'`) at every public API.
|
|
79
|
+
* These primitives are exposed for adapter authors who need to
|
|
80
|
+
* canonicalise user-provided paths.
|
|
81
|
+
*/
|
|
82
|
+
declare const pathKeyBrand: unique symbol;
|
|
83
|
+
/**
|
|
84
|
+
* Branded string identifier for a canonicalised path. Useful as a
|
|
85
|
+
* `Map` key — two paths that resolve to the same canonical form
|
|
86
|
+
* produce the same `PathKey`. Treat as opaque; don't try to parse.
|
|
87
|
+
*/
|
|
88
|
+
type PathKey = string & {
|
|
89
|
+
readonly [pathKeyBrand]: 'PathKey';
|
|
90
|
+
};
|
|
91
|
+
/** A single path segment — a property name or array index. */
|
|
92
|
+
type Segment = string | number;
|
|
93
|
+
/** A structured path as a read-only sequence of segments. */
|
|
94
|
+
type Path = readonly Segment[];
|
|
95
|
+
/**
|
|
96
|
+
* Parse a dotted-string path into structured segments.
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* parseDottedPath('user.address.line1') // ['user', 'address', 'line1']
|
|
100
|
+
* parseDottedPath('items.0.name') // ['items', 0, 'name']
|
|
101
|
+
* parseDottedPath('') // [''] (the empty-string key)
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* The empty-string input `''` is the **literal empty-key path**, not
|
|
105
|
+
* the root. Use the array form `[]` for root. Form-level errors
|
|
106
|
+
* (root `.refine()`) live at the empty-string path bucket so
|
|
107
|
+
* `errors('')` returns them without sweeping every field error too.
|
|
108
|
+
*
|
|
109
|
+
* Throws `InvalidPathError` for paths with empty INTERNAL segments
|
|
110
|
+
* (`'a..b'`, leading or trailing dots). For keys containing literal
|
|
111
|
+
* dots, pass an array form (`['user.name']`) instead.
|
|
112
|
+
*/
|
|
113
|
+
declare function parseDottedPath(path: string): Segment[];
|
|
114
|
+
/**
|
|
115
|
+
* Canonicalise a path into structured segments plus a stable string
|
|
116
|
+
* key. Accepts either dotted-string or array form; integer-looking
|
|
117
|
+
* segments normalise to numbers.
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* canonicalizePath('items.0.name')
|
|
121
|
+
* // { segments: ['items', 0, 'name'], key: '["items",0,"name"]' as PathKey }
|
|
122
|
+
*
|
|
123
|
+
* canonicalizePath(['items', 0, 'name'])
|
|
124
|
+
* // → same result
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* The returned `key` is suitable as a `Map`/`Set` key — equal paths
|
|
128
|
+
* produce equal keys regardless of input form.
|
|
129
|
+
*/
|
|
130
|
+
declare function canonicalizePath(input: string | Path): {
|
|
131
|
+
segments: readonly Segment[];
|
|
132
|
+
key: PathKey;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* The root path — an empty segment tuple. Pass to APIs that accept
|
|
136
|
+
* a `Path` to address the form value as a whole.
|
|
137
|
+
*/
|
|
138
|
+
declare const ROOT_PATH: Path;
|
|
139
|
+
/** Stable string key for the root path. */
|
|
140
|
+
declare const ROOT_PATH_KEY: PathKey;
|
|
141
|
+
/**
|
|
142
|
+
* `true` when `path` starts with every segment of `prefix` (in order).
|
|
143
|
+
* The empty `prefix` matches every path — ROOT prefix is universal.
|
|
144
|
+
*
|
|
145
|
+
* Walks segments rather than `PathKey` strings because the data this
|
|
146
|
+
* helper operates on (e.g. `meta.errors[].path`) carries segment
|
|
147
|
+
* arrays directly.
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* isPathPrefix(['cargo'], ['cargo', 'items', 0, 'sku']) // true
|
|
151
|
+
* isPathPrefix(['cargo', 'items'], ['cargo']) // false (path shorter)
|
|
152
|
+
* isPathPrefix([], ['anything']) // true (root prefix)
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare function isPathPrefix(prefix: readonly Segment[], path: readonly Segment[]): boolean;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Per-FormStore registry tracking which DOM elements have opted into
|
|
159
|
+
* persistence for which paths. Lives on the FormStore so that two SFCs
|
|
160
|
+
* sharing a key share the registry — opt-ins are per-element, not
|
|
161
|
+
* per-component.
|
|
162
|
+
*
|
|
163
|
+
* The directive's input handler computes `meta.persist` for each write
|
|
164
|
+
* by calling `hasOptIn(elementId, path)` — only THIS element's writes
|
|
165
|
+
* persist if THIS element opted in. Other call sites that aren't tied
|
|
166
|
+
* to a single element (history undo/redo, field-array helpers, devtools
|
|
167
|
+
* edits) use `hasAnyOptInForPath(path)` — persist if any element has
|
|
168
|
+
* opted into that path.
|
|
169
|
+
*
|
|
170
|
+
* Internal data structure: `Map<PathKey, Set<elementId>>`. Small forms
|
|
171
|
+
* have ~10-50 paths; iteration is cheap. All operations are O(1) given
|
|
172
|
+
* (id, path).
|
|
173
|
+
*/
|
|
174
|
+
type PersistOptInRegistry = {
|
|
175
|
+
/** Add an opt-in entry; idempotent. */
|
|
176
|
+
add(elementId: string, path: PathKey): void;
|
|
177
|
+
/** Remove a single (element, path) entry. */
|
|
178
|
+
remove(elementId: string, path: PathKey): void;
|
|
179
|
+
/** Remove every opt-in for `elementId`. Called from directive's beforeUnmount. */
|
|
180
|
+
removeAllFor(elementId: string): void;
|
|
181
|
+
/** Check whether THIS element has opted into THIS path. */
|
|
182
|
+
hasOptIn(elementId: string, path: PathKey): boolean;
|
|
183
|
+
/** Check whether ANY element has opted into this path. */
|
|
184
|
+
hasAnyOptInForPath(path: PathKey): boolean;
|
|
185
|
+
/** Iterate every path that currently has at least one opt-in. */
|
|
186
|
+
optedInPaths(): IterableIterator<PathKey>;
|
|
187
|
+
/** True iff no element has opted into any path. */
|
|
188
|
+
isEmpty(): boolean;
|
|
189
|
+
/** Drop every entry. Called from FormStore.dispose. */
|
|
190
|
+
clear(): void;
|
|
191
|
+
};
|
|
192
|
+
|
|
76
193
|
/** Internal brand for the `Unset` type. Never exposed at runtime. */
|
|
77
194
|
declare const _unsetBrand: unique symbol;
|
|
78
195
|
/**
|
|
@@ -545,6 +662,15 @@ type DefaultValuesInput<T> = T extends string ? string | Unset : T extends numbe
|
|
|
545
662
|
[K in keyof T]?: DefaultValuesInput<T[K]>;
|
|
546
663
|
} | Unset : T;
|
|
547
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Identifier for a form. A `FormKey` is the string passed via
|
|
667
|
+
* `useForm({ key })`, used to look up a form by name from a distant
|
|
668
|
+
* component, namespace persisted drafts, and label errors and
|
|
669
|
+
* DevTools entries. Anonymous `useForm` calls allocate one
|
|
670
|
+
* automatically; you only need to pick one when the form needs
|
|
671
|
+
* stable identity.
|
|
672
|
+
*/
|
|
673
|
+
type FormKey = string;
|
|
548
674
|
/**
|
|
549
675
|
* Per-form options threaded from `useForm` into the adapter factory.
|
|
550
676
|
* Today carries the resolved `maxRecursionDepth` so adapter walks can
|
|
@@ -555,133 +681,6 @@ interface SchemaFactoryOptions {
|
|
|
555
681
|
/** Resolved recursion ceiling (per-form > app-default > library default). */
|
|
556
682
|
maxRecursionDepth: number;
|
|
557
683
|
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Path primitives for advanced integrations. The form library accepts
|
|
561
|
-
* paths in dotted-string form (`'user.email'`) at every public API.
|
|
562
|
-
* These primitives are exposed for adapter authors who need to
|
|
563
|
-
* canonicalise user-provided paths.
|
|
564
|
-
*/
|
|
565
|
-
declare const pathKeyBrand: unique symbol;
|
|
566
|
-
/**
|
|
567
|
-
* Branded string identifier for a canonicalised path. Useful as a
|
|
568
|
-
* `Map` key — two paths that resolve to the same canonical form
|
|
569
|
-
* produce the same `PathKey`. Treat as opaque; don't try to parse.
|
|
570
|
-
*/
|
|
571
|
-
type PathKey = string & {
|
|
572
|
-
readonly [pathKeyBrand]: 'PathKey';
|
|
573
|
-
};
|
|
574
|
-
/** A single path segment — a property name or array index. */
|
|
575
|
-
type Segment = string | number;
|
|
576
|
-
/** A structured path as a read-only sequence of segments. */
|
|
577
|
-
type Path = readonly Segment[];
|
|
578
|
-
/**
|
|
579
|
-
* Parse a dotted-string path into structured segments.
|
|
580
|
-
*
|
|
581
|
-
* ```ts
|
|
582
|
-
* parseDottedPath('user.address.line1') // ['user', 'address', 'line1']
|
|
583
|
-
* parseDottedPath('items.0.name') // ['items', 0, 'name']
|
|
584
|
-
* parseDottedPath('') // [''] (the empty-string key)
|
|
585
|
-
* ```
|
|
586
|
-
*
|
|
587
|
-
* The empty-string input `''` is the **literal empty-key path**, not
|
|
588
|
-
* the root. Use the array form `[]` for root. Form-level errors
|
|
589
|
-
* (root `.refine()`) live at the empty-string path bucket so
|
|
590
|
-
* `errors('')` returns them without sweeping every field error too.
|
|
591
|
-
*
|
|
592
|
-
* Throws `InvalidPathError` for paths with empty INTERNAL segments
|
|
593
|
-
* (`'a..b'`, leading or trailing dots). For keys containing literal
|
|
594
|
-
* dots, pass an array form (`['user.name']`) instead.
|
|
595
|
-
*/
|
|
596
|
-
declare function parseDottedPath(path: string): Segment[];
|
|
597
|
-
/**
|
|
598
|
-
* Canonicalise a path into structured segments plus a stable string
|
|
599
|
-
* key. Accepts either dotted-string or array form; integer-looking
|
|
600
|
-
* segments normalise to numbers.
|
|
601
|
-
*
|
|
602
|
-
* ```ts
|
|
603
|
-
* canonicalizePath('items.0.name')
|
|
604
|
-
* // { segments: ['items', 0, 'name'], key: '["items",0,"name"]' as PathKey }
|
|
605
|
-
*
|
|
606
|
-
* canonicalizePath(['items', 0, 'name'])
|
|
607
|
-
* // → same result
|
|
608
|
-
* ```
|
|
609
|
-
*
|
|
610
|
-
* The returned `key` is suitable as a `Map`/`Set` key — equal paths
|
|
611
|
-
* produce equal keys regardless of input form.
|
|
612
|
-
*/
|
|
613
|
-
declare function canonicalizePath(input: string | Path): {
|
|
614
|
-
segments: readonly Segment[];
|
|
615
|
-
key: PathKey;
|
|
616
|
-
};
|
|
617
|
-
/**
|
|
618
|
-
* The root path — an empty segment tuple. Pass to APIs that accept
|
|
619
|
-
* a `Path` to address the form value as a whole.
|
|
620
|
-
*/
|
|
621
|
-
declare const ROOT_PATH: Path;
|
|
622
|
-
/** Stable string key for the root path. */
|
|
623
|
-
declare const ROOT_PATH_KEY: PathKey;
|
|
624
|
-
/**
|
|
625
|
-
* `true` when `path` starts with every segment of `prefix` (in order).
|
|
626
|
-
* The empty `prefix` matches every path — ROOT prefix is universal.
|
|
627
|
-
*
|
|
628
|
-
* Walks segments rather than `PathKey` strings because the data this
|
|
629
|
-
* helper operates on (e.g. `meta.errors[].path`) carries segment
|
|
630
|
-
* arrays directly.
|
|
631
|
-
*
|
|
632
|
-
* ```ts
|
|
633
|
-
* isPathPrefix(['cargo'], ['cargo', 'items', 0, 'sku']) // true
|
|
634
|
-
* isPathPrefix(['cargo', 'items'], ['cargo']) // false (path shorter)
|
|
635
|
-
* isPathPrefix([], ['anything']) // true (root prefix)
|
|
636
|
-
* ```
|
|
637
|
-
*/
|
|
638
|
-
declare function isPathPrefix(prefix: readonly Segment[], path: readonly Segment[]): boolean;
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Per-FormStore registry tracking which DOM elements have opted into
|
|
642
|
-
* persistence for which paths. Lives on the FormStore so that two SFCs
|
|
643
|
-
* sharing a key share the registry — opt-ins are per-element, not
|
|
644
|
-
* per-component.
|
|
645
|
-
*
|
|
646
|
-
* The directive's input handler computes `meta.persist` for each write
|
|
647
|
-
* by calling `hasOptIn(elementId, path)` — only THIS element's writes
|
|
648
|
-
* persist if THIS element opted in. Other call sites that aren't tied
|
|
649
|
-
* to a single element (history undo/redo, field-array helpers, devtools
|
|
650
|
-
* edits) use `hasAnyOptInForPath(path)` — persist if any element has
|
|
651
|
-
* opted into that path.
|
|
652
|
-
*
|
|
653
|
-
* Internal data structure: `Map<PathKey, Set<elementId>>`. Small forms
|
|
654
|
-
* have ~10-50 paths; iteration is cheap. All operations are O(1) given
|
|
655
|
-
* (id, path).
|
|
656
|
-
*/
|
|
657
|
-
type PersistOptInRegistry = {
|
|
658
|
-
/** Add an opt-in entry; idempotent. */
|
|
659
|
-
add(elementId: string, path: PathKey): void;
|
|
660
|
-
/** Remove a single (element, path) entry. */
|
|
661
|
-
remove(elementId: string, path: PathKey): void;
|
|
662
|
-
/** Remove every opt-in for `elementId`. Called from directive's beforeUnmount. */
|
|
663
|
-
removeAllFor(elementId: string): void;
|
|
664
|
-
/** Check whether THIS element has opted into THIS path. */
|
|
665
|
-
hasOptIn(elementId: string, path: PathKey): boolean;
|
|
666
|
-
/** Check whether ANY element has opted into this path. */
|
|
667
|
-
hasAnyOptInForPath(path: PathKey): boolean;
|
|
668
|
-
/** Iterate every path that currently has at least one opt-in. */
|
|
669
|
-
optedInPaths(): IterableIterator<PathKey>;
|
|
670
|
-
/** True iff no element has opted into any path. */
|
|
671
|
-
isEmpty(): boolean;
|
|
672
|
-
/** Drop every entry. Called from FormStore.dispose. */
|
|
673
|
-
clear(): void;
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* Identifier for a form. A `FormKey` is the string passed via
|
|
678
|
-
* `useForm({ key })`, used to look up a form by name from a distant
|
|
679
|
-
* component, namespace persisted drafts, and label errors and
|
|
680
|
-
* DevTools entries. Anonymous `useForm` calls allocate one
|
|
681
|
-
* automatically; you only need to pick one when the form needs
|
|
682
|
-
* stable identity.
|
|
683
|
-
*/
|
|
684
|
-
type FormKey = string;
|
|
685
684
|
/**
|
|
686
685
|
* One validation failure. `path` points at the offending field as a
|
|
687
686
|
* structured array — `['user', 'address', 0, 'line1']` for a nested
|
|
@@ -4916,5 +4915,5 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4916
4915
|
blankPaths: ComputedRef<BlankPathsView>;
|
|
4917
4916
|
};
|
|
4918
4917
|
|
|
4919
|
-
export { ROOT_PATH as
|
|
4920
|
-
export type {
|
|
4918
|
+
export { ROOT_PATH as a4, ROOT_PATH_KEY as a5, canonicalizePath as as, isPathPrefix as at, isUnset as au, parseDottedPath as av, unset as aw };
|
|
4919
|
+
export type { PendingValidationStatus as $, AttaformDefaults as A, FormStorage as B, CoercionEntry as C, DefaultValuesInput as D, ErrorsProxyShape as E, FormKey as F, GenericForm as G, FormStorageKind as H, HandleSubmit as I, HistoryConfig as J, IsTuple as K, IsUnion as L, JoinSegments as M, KeyofUnion as N, LiftedValueShape as O, MetaTrackerValue as P, NestedReadType as Q, RegisterModelDynamicCustomDirective as R, NestedType as S, OnError as T, UseFormConfiguration as U, ValidationError as V, OnInvalidSubmitPolicy as W, OnSubmit as X, PartialFlatPath as Y, Path as Z, PathKey as _, AbstractSchema as a, PersistConfig as a0, PersistConfigOptions as a1, PersistIncludeMode as a2, Primitive as a3, ReactiveValidationStatus as a6, RegisterDirective as a7, RegisterFlatPath as a8, RegisterOptions as a9, RegisterSelectModifier as aa, RegisterTextModifier as ab, RegisterTransform as ac, Segment as ad, SetValueCallback as ae, SetValuePayload as af, SettledValidationStatus as ag, SlimPrimitiveKind as ah, SlimRuntimeOf as ai, SubmitHandler as aj, Unset as ak, ValidateOn as al, ValidateOnConfig as am, ValidationResponse as an, ValidationResponseWithoutValue as ao, ValueOfUnion as ap, WriteMeta as aq, WriteShape as ar, SchemaFactoryOptions as ax, TransformAbortHolder as ay, PersistOptInRegistry as az, UseFormReturnType as b, RegisterValue as c, GetDisplayState as d, ApiErrorEnvelope as e, ApiErrorDetails as f, ApiErrorEntry as g, ArrayItem as h, ArrayPath as i, CoercionRegistry as j, CoercionResult as k, CustomDirectiveRegisterAssignerFn as l, DeepPartial as m, DefaultValuesResponse as n, DefaultValuesShape as o, DisplayCtx as p, DisplayMachine as q, DisplayState as r, FieldMetaPayload as s, FieldState as t, FieldStateMap as u, FieldStateMapEntry as v, FlatPath as w, FormErrorRecord as x, FormErrorsSurface as y, FormMeta as z };
|