attaform 0.19.0 → 0.20.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/chunks/devtools.cjs +1 -1
- package/dist/chunks/devtools.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/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +3 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -40
- package/dist/index.d.mts +14 -40
- package/dist/index.d.ts +14 -40
- package/dist/index.mjs +5 -5
- 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 +2 -2
- package/dist/runtime/components/DevtoolsValueTree.d.vue.ts +1 -3
- package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +1 -3
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.CrpjyXdO.mjs → attaform.BKozEdTr.mjs} +275 -266
- package/dist/shared/attaform.BKozEdTr.mjs.map +1 -0
- package/dist/shared/{attaform.Bubm_slq.cjs → attaform.BM6YD9kZ.cjs} +212 -269
- package/dist/shared/attaform.BM6YD9kZ.cjs.map +1 -0
- package/dist/shared/{attaform.CoxJ8Qm8.cjs → attaform.BPxsYtTe.cjs} +2 -26
- package/dist/shared/attaform.BPxsYtTe.cjs.map +1 -0
- package/dist/shared/{attaform.BqEfHpVB.cjs → attaform.BPy-4qRx.cjs} +275 -268
- package/dist/shared/attaform.BPy-4qRx.cjs.map +1 -0
- package/dist/shared/attaform.BWgAFnsj.mjs +770 -0
- package/dist/shared/attaform.BWgAFnsj.mjs.map +1 -0
- package/dist/shared/{attaform.BTpuvGec.d.ts → attaform.Bh3ACtts.d.ts} +109 -101
- package/dist/shared/{attaform.CXpzmj38.mjs → attaform.BupwXkj_.mjs} +213 -270
- package/dist/shared/attaform.BupwXkj_.mjs.map +1 -0
- package/dist/shared/{attaform.JBx8cfMA.cjs → attaform.CIn4bMsD.cjs} +263 -799
- package/dist/shared/attaform.CIn4bMsD.cjs.map +1 -0
- package/dist/shared/{attaform.BTi-PsHr.mjs → attaform.CKFbKFb6.mjs} +1818 -1472
- package/dist/shared/attaform.CKFbKFb6.mjs.map +1 -0
- package/dist/shared/{attaform.ePUcKxId.d.cts → attaform.D5-1XGQU.d.cts} +109 -101
- package/dist/shared/{attaform.a3uBo-gw.mjs → attaform.DEBvCjeH.mjs} +257 -793
- package/dist/shared/attaform.DEBvCjeH.mjs.map +1 -0
- package/dist/shared/{attaform.C1msmO2v.cjs → attaform.DL4CQ-oW.cjs} +1823 -1477
- package/dist/shared/attaform.DL4CQ-oW.cjs.map +1 -0
- package/dist/shared/{attaform.D4I63aBV.d.ts → attaform.DSD85fHb.d.cts} +1 -19
- package/dist/shared/{attaform.CBjmobqk.d.cts → attaform.DSD85fHb.d.mts} +1 -19
- package/dist/shared/{attaform.DXYHL99q.d.mts → attaform.DSD85fHb.d.ts} +1 -19
- package/dist/shared/{attaform.B7rzpK1U.d.cts → attaform.DkA5J8NW.d.cts} +1 -17
- package/dist/shared/{attaform.B7rzpK1U.d.mts → attaform.DkA5J8NW.d.mts} +1 -17
- package/dist/shared/{attaform.B7rzpK1U.d.ts → attaform.DkA5J8NW.d.ts} +1 -17
- package/dist/shared/{attaform.CJ-e9gYI.d.ts → attaform.Dl5kDY-A.d.ts} +1 -1
- package/dist/shared/attaform.Dmb6itxC.cjs +781 -0
- package/dist/shared/attaform.Dmb6itxC.cjs.map +1 -0
- package/dist/shared/{attaform.CRNA0vrd.d.mts → attaform.DoKXru-a.d.mts} +1 -1
- package/dist/shared/attaform.DvA-CJJW.mjs +1876 -0
- package/dist/shared/attaform.DvA-CJJW.mjs.map +1 -0
- package/dist/shared/{attaform.BtBmfLQN.d.mts → attaform.EMzJcQci.d.mts} +109 -101
- package/dist/shared/attaform.EZG6fOFb.mjs +35 -0
- package/dist/shared/attaform.EZG6fOFb.mjs.map +1 -0
- package/dist/shared/{attaform.QvygsFGh.d.cts → attaform.GbDo_lJi.d.cts} +1 -1
- package/dist/shared/{attaform.C0uGZQ4M.d.ts → attaform.SfhU0OEY.d.cts} +134 -30
- package/dist/shared/{attaform.C0uGZQ4M.d.cts → attaform.SfhU0OEY.d.mts} +134 -30
- package/dist/shared/{attaform.C0uGZQ4M.d.mts → attaform.SfhU0OEY.d.ts} +134 -30
- package/dist/shared/attaform.jgzuNZVC.cjs +1882 -0
- package/dist/shared/attaform.jgzuNZVC.cjs.map +1 -0
- package/dist/transforms.cjs +2 -2
- package/dist/transforms.d.cts +22 -13
- package/dist/transforms.d.mts +22 -13
- package/dist/transforms.d.ts +22 -13
- package/dist/transforms.mjs +1 -1
- package/dist/vite.cjs +8 -7
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +8 -7
- package/dist/vite.mjs.map +1 -1
- package/dist/zod-v3.cjs +3 -3
- package/dist/zod-v3.d.cts +32 -6
- package/dist/zod-v3.d.mts +32 -6
- package/dist/zod-v3.d.ts +32 -6
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +3 -3
- package/dist/zod-v4.d.cts +12 -8
- package/dist/zod-v4.d.mts +12 -8
- package/dist/zod-v4.d.ts +12 -8
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +8 -8
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +6 -6
- package/dist/zod.d.mts +6 -6
- package/dist/zod.d.ts +6 -6
- package/dist/zod.mjs +6 -6
- package/package.json +1 -1
- package/dist/shared/attaform.BTi-PsHr.mjs.map +0 -1
- package/dist/shared/attaform.BqEfHpVB.cjs.map +0 -1
- package/dist/shared/attaform.Bubm_slq.cjs.map +0 -1
- package/dist/shared/attaform.C1msmO2v.cjs.map +0 -1
- package/dist/shared/attaform.C8CyvYa_.cjs +0 -36
- package/dist/shared/attaform.C8CyvYa_.cjs.map +0 -1
- package/dist/shared/attaform.CXpzmj38.mjs.map +0 -1
- package/dist/shared/attaform.Cghpuav8.mjs +0 -57
- package/dist/shared/attaform.Cghpuav8.mjs.map +0 -1
- package/dist/shared/attaform.CiMqJHDm.mjs +0 -1594
- package/dist/shared/attaform.CiMqJHDm.mjs.map +0 -1
- package/dist/shared/attaform.CoxJ8Qm8.cjs.map +0 -1
- package/dist/shared/attaform.CrpjyXdO.mjs.map +0 -1
- package/dist/shared/attaform.D13GMFgK.mjs +0 -32
- package/dist/shared/attaform.D13GMFgK.mjs.map +0 -1
- package/dist/shared/attaform.JBx8cfMA.cjs.map +0 -1
- package/dist/shared/attaform.OznWyOPy.cjs +0 -1600
- package/dist/shared/attaform.OznWyOPy.cjs.map +0 -1
- package/dist/shared/attaform.a3uBo-gw.mjs.map +0 -1
|
@@ -136,6 +136,28 @@ declare function isUnset(value: unknown): value is Unset;
|
|
|
136
136
|
type GenericForm = Record<string, unknown>;
|
|
137
137
|
/** Internal helper — `true` when `T` is an object or array. */
|
|
138
138
|
type IsObjectOrArray<T> = T extends GenericForm ? true : T extends Array<unknown> ? true : false;
|
|
139
|
+
/**
|
|
140
|
+
* Shared recursion body backing `PartialFlatPath` and `RegisterFlatPath`.
|
|
141
|
+
* One walk over `Form`; `Mode` controls whether intermediate container
|
|
142
|
+
* paths are emitted alongside their reachable leaves.
|
|
143
|
+
*
|
|
144
|
+
* - `'partial'`: emit every container path (object containers, nested-
|
|
145
|
+
* object array roots, array-of-object element containers). Used by
|
|
146
|
+
* `setValue` / `form.values.<path>` / every read-side API that needs
|
|
147
|
+
* to address a container.
|
|
148
|
+
* - `'register'`: skip container paths. `v-register` binds onto a
|
|
149
|
+
* leaf-backing native element (`<input>`, `<select>`, `<textarea>`),
|
|
150
|
+
* so container paths aren't registrable. Primitive arrays still
|
|
151
|
+
* admit the array-root path under both modes (multi-select and
|
|
152
|
+
* grouped-checkbox bindings register onto the array itself).
|
|
153
|
+
*
|
|
154
|
+
* Both walkers were independent recursions before; threading `Mode`
|
|
155
|
+
* through one body keeps the surface guarded by a single source of
|
|
156
|
+
* truth, and `PartialFlatPath` / `RegisterFlatPath` stay byte-
|
|
157
|
+
* identical to the prior hand-written walks (see
|
|
158
|
+
* `test/types/flat-path-walker.test.ts`).
|
|
159
|
+
*/
|
|
160
|
+
type FlatPathBuilder<Form, Mode extends 'partial' | 'register', Key extends keyof Form = keyof Form> = IsObjectOrArray<Form> extends true ? Key extends string ? Form[Key] extends infer Value ? Value extends Array<infer ArrayItem> ? IsObjectOrArray<ArrayItem> extends true ? Mode extends 'partial' ? `${Key}` | `${Key}.${number}` | `${Key}.${number}.${FlatPathBuilder<ArrayItem, Mode>}` : `${Key}.${number}.${FlatPathBuilder<ArrayItem, Mode>}` : `${Key}` | `${Key}.${number}` : Value extends GenericForm ? Mode extends 'partial' ? `${Key}` | `${Key}.${FlatPathBuilder<Value, Mode>}` : `${Key}.${FlatPathBuilder<Value, Mode>}` : `${Key}` : never : Key extends number ? `${Key}` | (Form[Key] extends GenericForm ? `${Key}.${FlatPathBuilder<Form[Key], Mode>}` : Form[Key] extends Array<infer ArrayItem> ? IsObjectOrArray<ArrayItem> extends true ? Mode extends 'partial' ? `${Key}.${number}` | `${Key}.${number}.${FlatPathBuilder<ArrayItem, Mode>}` : `${Key}.${number}.${FlatPathBuilder<ArrayItem, Mode>}` : `${Key}.${number}` : never) : never : never;
|
|
139
161
|
/**
|
|
140
162
|
* Implementation detail backing `FlatPath` in its default
|
|
141
163
|
* (partial-path) mode. Exported so `rollup-plugin-dts` preserves it
|
|
@@ -146,8 +168,7 @@ type IsObjectOrArray<T> = T extends GenericForm ? true : T extends Array<unknown
|
|
|
146
168
|
* when multiple complex forms share a scope. Consumers should reach
|
|
147
169
|
* for `FlatPath` instead; this alias is not part of the stable surface.
|
|
148
170
|
*/
|
|
149
|
-
type PartialFlatPath<Form, Key extends keyof Form = keyof Form> =
|
|
150
|
-
type CompleteFlatPath<Form, Key extends keyof Form = keyof Form> = IsObjectOrArray<Form> extends true ? Key extends string ? Form[Key] extends infer Value ? Value extends Array<infer ArrayItem> ? `${Key}.${number}.${CompleteFlatPath<ArrayItem>}` : Value extends GenericForm ? `${Key}.${CompleteFlatPath<Value>}` : `${Key}` : never : Key extends number ? `${Key}` | (Form[Key] extends GenericForm ? `${Key}.${CompleteFlatPath<Form[Key]>}` : Form[Key] extends Array<infer ArrayItem> ? IsObjectOrArray<ArrayItem> extends true ? `${Key}.${number}.${CompleteFlatPath<ArrayItem>}` : `${Key}.${number}` : never) : never : never;
|
|
171
|
+
type PartialFlatPath<Form, Key extends keyof Form = keyof Form> = FlatPathBuilder<Form, 'partial', Key>;
|
|
151
172
|
/**
|
|
152
173
|
* Union of dotted-string paths reachable inside `Form`, e.g. for
|
|
153
174
|
* `{ user: { email: string }, items: string[] }`:
|
|
@@ -157,11 +178,8 @@ type CompleteFlatPath<Form, Key extends keyof Form = keyof Form> = IsObjectOrArr
|
|
|
157
178
|
* Used by every path-addressed API (`setValue(path, value)`,
|
|
158
179
|
* `register(path)`, `toRef(path)`, etc.) so paths autocomplete in
|
|
159
180
|
* the IDE and typos compile-error.
|
|
160
|
-
*
|
|
161
|
-
* Set `ForceFullPath` to `true` to restrict to leaf paths only
|
|
162
|
-
* (no intermediate container paths).
|
|
163
181
|
*/
|
|
164
|
-
type FlatPath<Form, Key extends keyof Form = keyof Form
|
|
182
|
+
type FlatPath<Form, Key extends keyof Form = keyof Form> = PartialFlatPath<Form, Key>;
|
|
165
183
|
/**
|
|
166
184
|
* Convert a tuple of path segments to its dotted-string equivalent.
|
|
167
185
|
*
|
|
@@ -251,6 +269,31 @@ type LiftedValueShape<T> = [T] extends [
|
|
|
251
269
|
type DeepPartial<T> = T extends Primitive ? T : T extends Array<infer ArrayItem> ? DeepPartial<ArrayItem>[] : T extends object ? {
|
|
252
270
|
[Key in keyof T]?: DeepPartial<T[Key]>;
|
|
253
271
|
} : T;
|
|
272
|
+
/**
|
|
273
|
+
* Shared descent body backing `NestedType` and `NestedReadType`. The
|
|
274
|
+
* recursion is identical — segment-by-segment, distributing over
|
|
275
|
+
* union members via `KeyofUnion` / `ValueOfUnion`. The two walkers
|
|
276
|
+
* diverge only at the leaf:
|
|
277
|
+
*
|
|
278
|
+
* - `TaintArrayCrossings extends false` (`NestedType` mode): leaves
|
|
279
|
+
* are returned untouched. Used by strict write-side APIs that need
|
|
280
|
+
* the exact resolved type (`setValue`'s value parameter,
|
|
281
|
+
* `form.fields.<path>`'s state map).
|
|
282
|
+
* - `TaintArrayCrossings extends true` (`NestedReadType` mode): leaves
|
|
283
|
+
* are widened with `| undefined` whenever any segment in the walk
|
|
284
|
+
* was numeric (array index). Reflects the runtime possibility of an
|
|
285
|
+
* out-of-bounds read.
|
|
286
|
+
*
|
|
287
|
+
* `_Tainted` propagates the array-crossing under taint mode; under
|
|
288
|
+
* strict mode it stays `false` through every recursion arm. Both
|
|
289
|
+
* arms strip nullishness at the root (`_RootValue = NonNullable<…>`)
|
|
290
|
+
* — the prior `NestedType.FilterOutNullishTypesDuringRecursion` flag
|
|
291
|
+
* was vestigial, never overridden from the outside.
|
|
292
|
+
*
|
|
293
|
+
* Not part of the stable consumer surface — reach for `NestedType` or
|
|
294
|
+
* `NestedReadType` directly.
|
|
295
|
+
*/
|
|
296
|
+
type NestedTypeBuilder<RootValue, FlattenedPath extends string, TaintArrayCrossings extends boolean, _Tainted extends boolean = false, _RootValue = NonNullable<RootValue>> = IsObjectOrArray<_RootValue> extends false ? never : FlattenedPath extends `${infer Key}.${infer Rest}` ? Key extends `${number}` ? Key extends KeyofUnion<_RootValue> ? NestedTypeBuilder<ValueOfUnion<_RootValue, Key>, Rest, TaintArrayCrossings, TaintArrayCrossings extends true ? true : _Tainted> : Key extends `${infer NumericKey extends number}` ? NumericKey extends KeyofUnion<_RootValue> ? NestedTypeBuilder<ValueOfUnion<_RootValue, NumericKey>, Rest, TaintArrayCrossings, TaintArrayCrossings extends true ? true : _Tainted> : never : never : Key extends KeyofUnion<_RootValue> ? NestedTypeBuilder<ValueOfUnion<_RootValue, Key>, Rest, TaintArrayCrossings, _Tainted> : never : FlattenedPath extends `${number}` ? FlattenedPath extends KeyofUnion<_RootValue> ? TaintArrayCrossings extends true ? ValueOfUnion<_RootValue, FlattenedPath> | undefined : ValueOfUnion<_RootValue, FlattenedPath> : FlattenedPath extends `${infer NumericKey extends number}` ? NumericKey extends KeyofUnion<_RootValue> ? TaintArrayCrossings extends true ? ValueOfUnion<_RootValue, NumericKey> | undefined : ValueOfUnion<_RootValue, NumericKey> : never : never : FlattenedPath extends KeyofUnion<_RootValue> ? _Tainted extends true ? ValueOfUnion<_RootValue, FlattenedPath> | undefined : ValueOfUnion<_RootValue, FlattenedPath> : never;
|
|
254
297
|
/**
|
|
255
298
|
* Resolve the type at a dotted-string path inside `RootValue`. Used
|
|
256
299
|
* by the strict (write-side) APIs to derive the type at a path:
|
|
@@ -264,11 +307,16 @@ type DeepPartial<T> = T extends Primitive ? T : T extends Array<infer ArrayItem>
|
|
|
264
307
|
* useful value type (vs. silently collapsing to `never` because
|
|
265
308
|
* `keyof (A|B|C)` would be the intersection of all variants' keys).
|
|
266
309
|
*
|
|
310
|
+
* Composed over `NestedTypeBuilder` with array-crossing tainting OFF,
|
|
311
|
+
* so leaves return their exact resolved type. The companion
|
|
312
|
+
* `NestedReadType` shares the same recursion body but enables
|
|
313
|
+
* tainting for read-side APIs.
|
|
314
|
+
*
|
|
267
315
|
* TypeScript caps conditional-type recursion at around 50 levels;
|
|
268
316
|
* paths deeper than that resolve to `never`. Real form schemas
|
|
269
317
|
* never reach this depth.
|
|
270
318
|
*/
|
|
271
|
-
type NestedType<RootValue, FlattenedPath extends string
|
|
319
|
+
type NestedType<RootValue, FlattenedPath extends string> = NestedTypeBuilder<RootValue, FlattenedPath, false>;
|
|
272
320
|
/**
|
|
273
321
|
* Implementation-detail primitive-leaf marker used by `DeepPartial`
|
|
274
322
|
* and sibling structural walkers. Exported so the bundled `.d.ts`
|
|
@@ -300,7 +348,7 @@ type IsTuple<T extends readonly unknown[]> = number extends T['length'] ? false
|
|
|
300
348
|
* `register(path).innerRef` so the compile-time type honours the
|
|
301
349
|
* runtime possibility of a missing array position.
|
|
302
350
|
*/
|
|
303
|
-
type NestedReadType<RootValue, FlattenedPath extends string
|
|
351
|
+
type NestedReadType<RootValue, FlattenedPath extends string> = NestedTypeBuilder<RootValue, FlattenedPath, true>;
|
|
304
352
|
/**
|
|
305
353
|
* Filter FlatPath<Form> down to the subset of paths whose resolved leaf
|
|
306
354
|
* is an array. Used by the typed field-array helpers (append / remove /
|
|
@@ -388,6 +436,28 @@ type WriteShape<T> = T extends string | number | boolean | bigint | symbol | nul
|
|
|
388
436
|
} : Array<WriteShape<U>> : T extends object ? {
|
|
389
437
|
[K in keyof T]: WriteShape<T[K]>;
|
|
390
438
|
} : T;
|
|
439
|
+
/**
|
|
440
|
+
* Walk `T` and add `| Unset` at every primitive leaf (except symbol /
|
|
441
|
+
* null / undefined), every opaque leaf (`Date`, `RegExp`, `Map`,
|
|
442
|
+
* `Set`, functions), and every container position (object, tuple,
|
|
443
|
+
* array). The recursion topology mirrors `WriteShape<T>` exactly —
|
|
444
|
+
* `DefaultValuesShape<T>` is then a 1-line composition.
|
|
445
|
+
*
|
|
446
|
+
* Symbol / null / undefined leaves pass through untouched so the
|
|
447
|
+
* runtime sentinel doesn't pollute leaf semantics it has no business
|
|
448
|
+
* carrying. Container positions widen so a single `unset` at any
|
|
449
|
+
* level recursively marks every descendant primitive blank.
|
|
450
|
+
*
|
|
451
|
+
* Not part of the stable consumer-facing surface — reach for
|
|
452
|
+
* `DefaultValuesShape` instead.
|
|
453
|
+
*/
|
|
454
|
+
type AugmentWithUnset<T> = T extends string | number | boolean | bigint ? T | Unset : T extends symbol | null | undefined ? T : T extends Date | RegExp | Map<unknown, unknown> | Set<unknown> | ((...args: never) => unknown) ? T | Unset : T extends readonly [unknown, ...unknown[]] ? {
|
|
455
|
+
-readonly [K in keyof T]: AugmentWithUnset<T[K]>;
|
|
456
|
+
} | Unset : T extends ReadonlyArray<infer U> ? IsTuple<T> extends true ? {
|
|
457
|
+
-readonly [K in keyof T]: AugmentWithUnset<T[K]>;
|
|
458
|
+
} | Unset : Array<AugmentWithUnset<U>> | Unset : T extends object ? {
|
|
459
|
+
[K in keyof T]: AugmentWithUnset<T[K]>;
|
|
460
|
+
} | Unset : T;
|
|
391
461
|
/**
|
|
392
462
|
* Like `WriteShape<T>`, but additionally widens every primitive leaf
|
|
393
463
|
* (`string`, `number`, `boolean`, `bigint`) to admit `Unset` — the
|
|
@@ -401,8 +471,10 @@ type WriteShape<T> = T extends string | number | boolean | bigint | symbol | nul
|
|
|
401
471
|
* descendant blank, so `defaultValues: { profile: unset }` and
|
|
402
472
|
* `setValue('cargo', unset)` typecheck cleanly.
|
|
403
473
|
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
474
|
+
* Composed as `AugmentWithUnset<WriteShape<T>>`: stage 1 widens
|
|
475
|
+
* primitive literals, stage 2 adds `| Unset` everywhere — the prior
|
|
476
|
+
* inline walker hand-synced this in a single body. The composition
|
|
477
|
+
* stays compatible at every nested position; tuple positions,
|
|
406
478
|
* unbounded arrays, and nested records all flow through unchanged.
|
|
407
479
|
*
|
|
408
480
|
* Example:
|
|
@@ -413,13 +485,7 @@ type WriteShape<T> = T extends string | number | boolean | bigint | symbol | nul
|
|
|
413
485
|
* Used by `UseFormConfiguration.defaultValues`, `setValue`'s value
|
|
414
486
|
* parameter, and `reset`'s parameter.
|
|
415
487
|
*/
|
|
416
|
-
type DefaultValuesShape<T> =
|
|
417
|
-
-readonly [K in keyof T]: DefaultValuesShape<T[K]>;
|
|
418
|
-
} | Unset : T extends ReadonlyArray<infer U> ? IsTuple<T> extends true ? {
|
|
419
|
-
-readonly [K in keyof T]: DefaultValuesShape<T[K]>;
|
|
420
|
-
} | Unset : Array<DefaultValuesShape<U>> | Unset : T extends object ? {
|
|
421
|
-
[K in keyof T]: DefaultValuesShape<T[K]>;
|
|
422
|
-
} | Unset : T;
|
|
488
|
+
type DefaultValuesShape<T> = AugmentWithUnset<WriteShape<T>>;
|
|
423
489
|
/**
|
|
424
490
|
* Single-walker fusion of `DeepPartial` and `DefaultValuesShape` — the
|
|
425
491
|
* type accepted at `defaultValues`, `reset()`'s parameter, and every
|
|
@@ -713,6 +779,15 @@ type MaybePromise<T> = T | Promise<T>;
|
|
|
713
779
|
type ValidateOptions = {
|
|
714
780
|
sync?: boolean;
|
|
715
781
|
};
|
|
782
|
+
/**
|
|
783
|
+
* Configuration passed to `AbstractSchema.getDefaultValues`. Adapters
|
|
784
|
+
* receive `useDefaultSchemaValues` (honor `.default(x)` wrappers vs.
|
|
785
|
+
* empty/falsy fallbacks), an optional `strict` mode (refinement
|
|
786
|
+
* preservation), and an optional `constraints` overlay merged into the
|
|
787
|
+
* derived defaults so the runtime can stamp user-supplied defaults at
|
|
788
|
+
* construction. Exported so adapter authors can co-implement the
|
|
789
|
+
* service contract.
|
|
790
|
+
*/
|
|
716
791
|
type GetDefaultValuesConfig<Form> = {
|
|
717
792
|
useDefaultSchemaValues: boolean;
|
|
718
793
|
/**
|
|
@@ -1092,6 +1167,32 @@ type AbstractSchema<Form, GetValueFormType> = {
|
|
|
1092
1167
|
* answers without a separate top-level overload.
|
|
1093
1168
|
*/
|
|
1094
1169
|
needsAsyncValidation?(): boolean;
|
|
1170
|
+
/**
|
|
1171
|
+
* Return `true` iff the schema carries a refine / check / transform
|
|
1172
|
+
* at any NON-LEAF position — a container node (object / array /
|
|
1173
|
+
* tuple / union / intersection / record / map / set) or the root
|
|
1174
|
+
* itself. False means every check this schema runs is leaf-local,
|
|
1175
|
+
* so a per-keystroke `validateAtPath(form, leafPath)` catches the
|
|
1176
|
+
* same verdicts as a whole-form pass — no ancestor refine reads
|
|
1177
|
+
* the form's wider state.
|
|
1178
|
+
*
|
|
1179
|
+
* The runtime uses this at the per-keystroke schedule to scope
|
|
1180
|
+
* field-level validation to the changed subtree when it can,
|
|
1181
|
+
* falling back to a whole-form pass when an ancestor refine
|
|
1182
|
+
* (cross-field equality, sum constraints, etc.) could be moved
|
|
1183
|
+
* by a leaf write. Optional. The runtime treats a missing
|
|
1184
|
+
* implementation as `() => true` — conservative whole-form,
|
|
1185
|
+
* preserving correctness for adapters that don't yet model
|
|
1186
|
+
* container-refine detection.
|
|
1187
|
+
*
|
|
1188
|
+
* Detection is best-effort: false negatives (returning `true`
|
|
1189
|
+
* when no container refine exists) only lose a perf win and
|
|
1190
|
+
* still validate correctly; false positives (returning `false`
|
|
1191
|
+
* when a container refine exists) would let an ancestor verdict
|
|
1192
|
+
* go stale and are the real risk — implementations should bias
|
|
1193
|
+
* toward returning `true` when in doubt.
|
|
1194
|
+
*/
|
|
1195
|
+
hasContainerOrRootRefine?(): boolean;
|
|
1095
1196
|
};
|
|
1096
1197
|
/**
|
|
1097
1198
|
* Adapter-returned info for a discriminated union — its discriminator
|
|
@@ -1795,8 +1896,9 @@ type UseFormConfiguration<Form extends GenericForm, GetValueFormType, Schema ext
|
|
|
1795
1896
|
maxRecursionDepth?: number;
|
|
1796
1897
|
/**
|
|
1797
1898
|
* Override the path-segment name stems treated as sensitive for this
|
|
1798
|
-
* form. Sensitive paths are excluded from persistence writes
|
|
1799
|
-
* multi-tab sync broadcasts
|
|
1899
|
+
* form. Sensitive paths are excluded from persistence writes and
|
|
1900
|
+
* multi-tab sync broadcasts. (DevTools renders raw values by design;
|
|
1901
|
+
* it does not redact.)
|
|
1800
1902
|
*
|
|
1801
1903
|
* Resolution: per-form value (this field) > global default
|
|
1802
1904
|
* (`createAttaform({ defaults: { sensitiveNames } })`) > library
|
|
@@ -2022,9 +2124,10 @@ type AttaformDefaults = {
|
|
|
2022
2124
|
maxRecursionDepth?: number;
|
|
2023
2125
|
/**
|
|
2024
2126
|
* Override the path-segment name stems treated as sensitive.
|
|
2025
|
-
* Sensitive paths are excluded from persistence writes
|
|
2026
|
-
* sync broadcasts
|
|
2027
|
-
*
|
|
2127
|
+
* Sensitive paths are excluded from persistence writes and multi-tab
|
|
2128
|
+
* sync broadcasts — one configurable source of truth across those
|
|
2129
|
+
* surfaces. (DevTools renders raw values by design; it does not
|
|
2130
|
+
* redact.)
|
|
2028
2131
|
*
|
|
2029
2132
|
* Library default is `DEFAULT_SENSITIVE_NAMES` (exported from
|
|
2030
2133
|
* `attaform`); compose to extend:
|
|
@@ -2235,7 +2338,7 @@ type MetaTrackerValue = {
|
|
|
2235
2338
|
*/
|
|
2236
2339
|
blank: boolean;
|
|
2237
2340
|
};
|
|
2238
|
-
type RegisterFlatPath<Form, Key extends keyof Form = keyof Form> =
|
|
2341
|
+
type RegisterFlatPath<Form, Key extends keyof Form = keyof Form> = FlatPathBuilder<Form, 'register', Key>;
|
|
2239
2342
|
/**
|
|
2240
2343
|
* Sync transformation applied to a field's value as user input flows
|
|
2241
2344
|
* from DOM through the directive's assigner. Composes left-to-right
|
|
@@ -2341,9 +2444,10 @@ type RegisterOptions = {
|
|
|
2341
2444
|
* If multiple inputs bind to the same path, the path keeps
|
|
2342
2445
|
* persisting as long as any opted-in input is mounted.
|
|
2343
2446
|
*
|
|
2344
|
-
*
|
|
2345
|
-
*
|
|
2346
|
-
* `acknowledgeSensitive: true` is also set
|
|
2447
|
+
* When the path looks sensitive (password / cvv / ssn / token /
|
|
2448
|
+
* etc.) the opt-in is skipped with a one-shot dev warning unless
|
|
2449
|
+
* `acknowledgeSensitive: true` is also set — the field simply isn't
|
|
2450
|
+
* persisted (the secure default). It never throws.
|
|
2347
2451
|
*/
|
|
2348
2452
|
persist?: boolean;
|
|
2349
2453
|
/**
|
|
@@ -2528,7 +2632,7 @@ type RegisterValue<Value = unknown> = Readonly<{
|
|
|
2528
2632
|
/**
|
|
2529
2633
|
* Resolved sensitive-path predicate honoring this form's
|
|
2530
2634
|
* `sensitiveNames` cascade. The directive calls this through
|
|
2531
|
-
* `
|
|
2635
|
+
* `allowSensitivePersist` when a `register('path', { persist: true })`
|
|
2532
2636
|
* binding mounts so a per-form custom list (e.g. extending with
|
|
2533
2637
|
* `'mrn'`) gates persistence enrolment correctly.
|
|
2534
2638
|
* @internal
|
|
@@ -4347,9 +4451,9 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4347
4451
|
* paths in the persisted draft are preserved (this is a merge,
|
|
4348
4452
|
* not a replace).
|
|
4349
4453
|
*
|
|
4350
|
-
*
|
|
4351
|
-
*
|
|
4352
|
-
* `useForm({ persist })` wasn't configured.
|
|
4454
|
+
* For sensitive-looking paths, warns once and no-ops unless you pass
|
|
4455
|
+
* `{ acknowledgeSensitive: true }` — it never throws. Also a no-op
|
|
4456
|
+
* when `useForm({ persist })` wasn't configured.
|
|
4353
4457
|
*/
|
|
4354
4458
|
persist: (path: FlatPath<Form>, options?: {
|
|
4355
4459
|
acknowledgeSensitive?: boolean;
|
|
@@ -136,6 +136,28 @@ declare function isUnset(value: unknown): value is Unset;
|
|
|
136
136
|
type GenericForm = Record<string, unknown>;
|
|
137
137
|
/** Internal helper — `true` when `T` is an object or array. */
|
|
138
138
|
type IsObjectOrArray<T> = T extends GenericForm ? true : T extends Array<unknown> ? true : false;
|
|
139
|
+
/**
|
|
140
|
+
* Shared recursion body backing `PartialFlatPath` and `RegisterFlatPath`.
|
|
141
|
+
* One walk over `Form`; `Mode` controls whether intermediate container
|
|
142
|
+
* paths are emitted alongside their reachable leaves.
|
|
143
|
+
*
|
|
144
|
+
* - `'partial'`: emit every container path (object containers, nested-
|
|
145
|
+
* object array roots, array-of-object element containers). Used by
|
|
146
|
+
* `setValue` / `form.values.<path>` / every read-side API that needs
|
|
147
|
+
* to address a container.
|
|
148
|
+
* - `'register'`: skip container paths. `v-register` binds onto a
|
|
149
|
+
* leaf-backing native element (`<input>`, `<select>`, `<textarea>`),
|
|
150
|
+
* so container paths aren't registrable. Primitive arrays still
|
|
151
|
+
* admit the array-root path under both modes (multi-select and
|
|
152
|
+
* grouped-checkbox bindings register onto the array itself).
|
|
153
|
+
*
|
|
154
|
+
* Both walkers were independent recursions before; threading `Mode`
|
|
155
|
+
* through one body keeps the surface guarded by a single source of
|
|
156
|
+
* truth, and `PartialFlatPath` / `RegisterFlatPath` stay byte-
|
|
157
|
+
* identical to the prior hand-written walks (see
|
|
158
|
+
* `test/types/flat-path-walker.test.ts`).
|
|
159
|
+
*/
|
|
160
|
+
type FlatPathBuilder<Form, Mode extends 'partial' | 'register', Key extends keyof Form = keyof Form> = IsObjectOrArray<Form> extends true ? Key extends string ? Form[Key] extends infer Value ? Value extends Array<infer ArrayItem> ? IsObjectOrArray<ArrayItem> extends true ? Mode extends 'partial' ? `${Key}` | `${Key}.${number}` | `${Key}.${number}.${FlatPathBuilder<ArrayItem, Mode>}` : `${Key}.${number}.${FlatPathBuilder<ArrayItem, Mode>}` : `${Key}` | `${Key}.${number}` : Value extends GenericForm ? Mode extends 'partial' ? `${Key}` | `${Key}.${FlatPathBuilder<Value, Mode>}` : `${Key}.${FlatPathBuilder<Value, Mode>}` : `${Key}` : never : Key extends number ? `${Key}` | (Form[Key] extends GenericForm ? `${Key}.${FlatPathBuilder<Form[Key], Mode>}` : Form[Key] extends Array<infer ArrayItem> ? IsObjectOrArray<ArrayItem> extends true ? Mode extends 'partial' ? `${Key}.${number}` | `${Key}.${number}.${FlatPathBuilder<ArrayItem, Mode>}` : `${Key}.${number}.${FlatPathBuilder<ArrayItem, Mode>}` : `${Key}.${number}` : never) : never : never;
|
|
139
161
|
/**
|
|
140
162
|
* Implementation detail backing `FlatPath` in its default
|
|
141
163
|
* (partial-path) mode. Exported so `rollup-plugin-dts` preserves it
|
|
@@ -146,8 +168,7 @@ type IsObjectOrArray<T> = T extends GenericForm ? true : T extends Array<unknown
|
|
|
146
168
|
* when multiple complex forms share a scope. Consumers should reach
|
|
147
169
|
* for `FlatPath` instead; this alias is not part of the stable surface.
|
|
148
170
|
*/
|
|
149
|
-
type PartialFlatPath<Form, Key extends keyof Form = keyof Form> =
|
|
150
|
-
type CompleteFlatPath<Form, Key extends keyof Form = keyof Form> = IsObjectOrArray<Form> extends true ? Key extends string ? Form[Key] extends infer Value ? Value extends Array<infer ArrayItem> ? `${Key}.${number}.${CompleteFlatPath<ArrayItem>}` : Value extends GenericForm ? `${Key}.${CompleteFlatPath<Value>}` : `${Key}` : never : Key extends number ? `${Key}` | (Form[Key] extends GenericForm ? `${Key}.${CompleteFlatPath<Form[Key]>}` : Form[Key] extends Array<infer ArrayItem> ? IsObjectOrArray<ArrayItem> extends true ? `${Key}.${number}.${CompleteFlatPath<ArrayItem>}` : `${Key}.${number}` : never) : never : never;
|
|
171
|
+
type PartialFlatPath<Form, Key extends keyof Form = keyof Form> = FlatPathBuilder<Form, 'partial', Key>;
|
|
151
172
|
/**
|
|
152
173
|
* Union of dotted-string paths reachable inside `Form`, e.g. for
|
|
153
174
|
* `{ user: { email: string }, items: string[] }`:
|
|
@@ -157,11 +178,8 @@ type CompleteFlatPath<Form, Key extends keyof Form = keyof Form> = IsObjectOrArr
|
|
|
157
178
|
* Used by every path-addressed API (`setValue(path, value)`,
|
|
158
179
|
* `register(path)`, `toRef(path)`, etc.) so paths autocomplete in
|
|
159
180
|
* the IDE and typos compile-error.
|
|
160
|
-
*
|
|
161
|
-
* Set `ForceFullPath` to `true` to restrict to leaf paths only
|
|
162
|
-
* (no intermediate container paths).
|
|
163
181
|
*/
|
|
164
|
-
type FlatPath<Form, Key extends keyof Form = keyof Form
|
|
182
|
+
type FlatPath<Form, Key extends keyof Form = keyof Form> = PartialFlatPath<Form, Key>;
|
|
165
183
|
/**
|
|
166
184
|
* Convert a tuple of path segments to its dotted-string equivalent.
|
|
167
185
|
*
|
|
@@ -251,6 +269,31 @@ type LiftedValueShape<T> = [T] extends [
|
|
|
251
269
|
type DeepPartial<T> = T extends Primitive ? T : T extends Array<infer ArrayItem> ? DeepPartial<ArrayItem>[] : T extends object ? {
|
|
252
270
|
[Key in keyof T]?: DeepPartial<T[Key]>;
|
|
253
271
|
} : T;
|
|
272
|
+
/**
|
|
273
|
+
* Shared descent body backing `NestedType` and `NestedReadType`. The
|
|
274
|
+
* recursion is identical — segment-by-segment, distributing over
|
|
275
|
+
* union members via `KeyofUnion` / `ValueOfUnion`. The two walkers
|
|
276
|
+
* diverge only at the leaf:
|
|
277
|
+
*
|
|
278
|
+
* - `TaintArrayCrossings extends false` (`NestedType` mode): leaves
|
|
279
|
+
* are returned untouched. Used by strict write-side APIs that need
|
|
280
|
+
* the exact resolved type (`setValue`'s value parameter,
|
|
281
|
+
* `form.fields.<path>`'s state map).
|
|
282
|
+
* - `TaintArrayCrossings extends true` (`NestedReadType` mode): leaves
|
|
283
|
+
* are widened with `| undefined` whenever any segment in the walk
|
|
284
|
+
* was numeric (array index). Reflects the runtime possibility of an
|
|
285
|
+
* out-of-bounds read.
|
|
286
|
+
*
|
|
287
|
+
* `_Tainted` propagates the array-crossing under taint mode; under
|
|
288
|
+
* strict mode it stays `false` through every recursion arm. Both
|
|
289
|
+
* arms strip nullishness at the root (`_RootValue = NonNullable<…>`)
|
|
290
|
+
* — the prior `NestedType.FilterOutNullishTypesDuringRecursion` flag
|
|
291
|
+
* was vestigial, never overridden from the outside.
|
|
292
|
+
*
|
|
293
|
+
* Not part of the stable consumer surface — reach for `NestedType` or
|
|
294
|
+
* `NestedReadType` directly.
|
|
295
|
+
*/
|
|
296
|
+
type NestedTypeBuilder<RootValue, FlattenedPath extends string, TaintArrayCrossings extends boolean, _Tainted extends boolean = false, _RootValue = NonNullable<RootValue>> = IsObjectOrArray<_RootValue> extends false ? never : FlattenedPath extends `${infer Key}.${infer Rest}` ? Key extends `${number}` ? Key extends KeyofUnion<_RootValue> ? NestedTypeBuilder<ValueOfUnion<_RootValue, Key>, Rest, TaintArrayCrossings, TaintArrayCrossings extends true ? true : _Tainted> : Key extends `${infer NumericKey extends number}` ? NumericKey extends KeyofUnion<_RootValue> ? NestedTypeBuilder<ValueOfUnion<_RootValue, NumericKey>, Rest, TaintArrayCrossings, TaintArrayCrossings extends true ? true : _Tainted> : never : never : Key extends KeyofUnion<_RootValue> ? NestedTypeBuilder<ValueOfUnion<_RootValue, Key>, Rest, TaintArrayCrossings, _Tainted> : never : FlattenedPath extends `${number}` ? FlattenedPath extends KeyofUnion<_RootValue> ? TaintArrayCrossings extends true ? ValueOfUnion<_RootValue, FlattenedPath> | undefined : ValueOfUnion<_RootValue, FlattenedPath> : FlattenedPath extends `${infer NumericKey extends number}` ? NumericKey extends KeyofUnion<_RootValue> ? TaintArrayCrossings extends true ? ValueOfUnion<_RootValue, NumericKey> | undefined : ValueOfUnion<_RootValue, NumericKey> : never : never : FlattenedPath extends KeyofUnion<_RootValue> ? _Tainted extends true ? ValueOfUnion<_RootValue, FlattenedPath> | undefined : ValueOfUnion<_RootValue, FlattenedPath> : never;
|
|
254
297
|
/**
|
|
255
298
|
* Resolve the type at a dotted-string path inside `RootValue`. Used
|
|
256
299
|
* by the strict (write-side) APIs to derive the type at a path:
|
|
@@ -264,11 +307,16 @@ type DeepPartial<T> = T extends Primitive ? T : T extends Array<infer ArrayItem>
|
|
|
264
307
|
* useful value type (vs. silently collapsing to `never` because
|
|
265
308
|
* `keyof (A|B|C)` would be the intersection of all variants' keys).
|
|
266
309
|
*
|
|
310
|
+
* Composed over `NestedTypeBuilder` with array-crossing tainting OFF,
|
|
311
|
+
* so leaves return their exact resolved type. The companion
|
|
312
|
+
* `NestedReadType` shares the same recursion body but enables
|
|
313
|
+
* tainting for read-side APIs.
|
|
314
|
+
*
|
|
267
315
|
* TypeScript caps conditional-type recursion at around 50 levels;
|
|
268
316
|
* paths deeper than that resolve to `never`. Real form schemas
|
|
269
317
|
* never reach this depth.
|
|
270
318
|
*/
|
|
271
|
-
type NestedType<RootValue, FlattenedPath extends string
|
|
319
|
+
type NestedType<RootValue, FlattenedPath extends string> = NestedTypeBuilder<RootValue, FlattenedPath, false>;
|
|
272
320
|
/**
|
|
273
321
|
* Implementation-detail primitive-leaf marker used by `DeepPartial`
|
|
274
322
|
* and sibling structural walkers. Exported so the bundled `.d.ts`
|
|
@@ -300,7 +348,7 @@ type IsTuple<T extends readonly unknown[]> = number extends T['length'] ? false
|
|
|
300
348
|
* `register(path).innerRef` so the compile-time type honours the
|
|
301
349
|
* runtime possibility of a missing array position.
|
|
302
350
|
*/
|
|
303
|
-
type NestedReadType<RootValue, FlattenedPath extends string
|
|
351
|
+
type NestedReadType<RootValue, FlattenedPath extends string> = NestedTypeBuilder<RootValue, FlattenedPath, true>;
|
|
304
352
|
/**
|
|
305
353
|
* Filter FlatPath<Form> down to the subset of paths whose resolved leaf
|
|
306
354
|
* is an array. Used by the typed field-array helpers (append / remove /
|
|
@@ -388,6 +436,28 @@ type WriteShape<T> = T extends string | number | boolean | bigint | symbol | nul
|
|
|
388
436
|
} : Array<WriteShape<U>> : T extends object ? {
|
|
389
437
|
[K in keyof T]: WriteShape<T[K]>;
|
|
390
438
|
} : T;
|
|
439
|
+
/**
|
|
440
|
+
* Walk `T` and add `| Unset` at every primitive leaf (except symbol /
|
|
441
|
+
* null / undefined), every opaque leaf (`Date`, `RegExp`, `Map`,
|
|
442
|
+
* `Set`, functions), and every container position (object, tuple,
|
|
443
|
+
* array). The recursion topology mirrors `WriteShape<T>` exactly —
|
|
444
|
+
* `DefaultValuesShape<T>` is then a 1-line composition.
|
|
445
|
+
*
|
|
446
|
+
* Symbol / null / undefined leaves pass through untouched so the
|
|
447
|
+
* runtime sentinel doesn't pollute leaf semantics it has no business
|
|
448
|
+
* carrying. Container positions widen so a single `unset` at any
|
|
449
|
+
* level recursively marks every descendant primitive blank.
|
|
450
|
+
*
|
|
451
|
+
* Not part of the stable consumer-facing surface — reach for
|
|
452
|
+
* `DefaultValuesShape` instead.
|
|
453
|
+
*/
|
|
454
|
+
type AugmentWithUnset<T> = T extends string | number | boolean | bigint ? T | Unset : T extends symbol | null | undefined ? T : T extends Date | RegExp | Map<unknown, unknown> | Set<unknown> | ((...args: never) => unknown) ? T | Unset : T extends readonly [unknown, ...unknown[]] ? {
|
|
455
|
+
-readonly [K in keyof T]: AugmentWithUnset<T[K]>;
|
|
456
|
+
} | Unset : T extends ReadonlyArray<infer U> ? IsTuple<T> extends true ? {
|
|
457
|
+
-readonly [K in keyof T]: AugmentWithUnset<T[K]>;
|
|
458
|
+
} | Unset : Array<AugmentWithUnset<U>> | Unset : T extends object ? {
|
|
459
|
+
[K in keyof T]: AugmentWithUnset<T[K]>;
|
|
460
|
+
} | Unset : T;
|
|
391
461
|
/**
|
|
392
462
|
* Like `WriteShape<T>`, but additionally widens every primitive leaf
|
|
393
463
|
* (`string`, `number`, `boolean`, `bigint`) to admit `Unset` — the
|
|
@@ -401,8 +471,10 @@ type WriteShape<T> = T extends string | number | boolean | bigint | symbol | nul
|
|
|
401
471
|
* descendant blank, so `defaultValues: { profile: unset }` and
|
|
402
472
|
* `setValue('cargo', unset)` typecheck cleanly.
|
|
403
473
|
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
474
|
+
* Composed as `AugmentWithUnset<WriteShape<T>>`: stage 1 widens
|
|
475
|
+
* primitive literals, stage 2 adds `| Unset` everywhere — the prior
|
|
476
|
+
* inline walker hand-synced this in a single body. The composition
|
|
477
|
+
* stays compatible at every nested position; tuple positions,
|
|
406
478
|
* unbounded arrays, and nested records all flow through unchanged.
|
|
407
479
|
*
|
|
408
480
|
* Example:
|
|
@@ -413,13 +485,7 @@ type WriteShape<T> = T extends string | number | boolean | bigint | symbol | nul
|
|
|
413
485
|
* Used by `UseFormConfiguration.defaultValues`, `setValue`'s value
|
|
414
486
|
* parameter, and `reset`'s parameter.
|
|
415
487
|
*/
|
|
416
|
-
type DefaultValuesShape<T> =
|
|
417
|
-
-readonly [K in keyof T]: DefaultValuesShape<T[K]>;
|
|
418
|
-
} | Unset : T extends ReadonlyArray<infer U> ? IsTuple<T> extends true ? {
|
|
419
|
-
-readonly [K in keyof T]: DefaultValuesShape<T[K]>;
|
|
420
|
-
} | Unset : Array<DefaultValuesShape<U>> | Unset : T extends object ? {
|
|
421
|
-
[K in keyof T]: DefaultValuesShape<T[K]>;
|
|
422
|
-
} | Unset : T;
|
|
488
|
+
type DefaultValuesShape<T> = AugmentWithUnset<WriteShape<T>>;
|
|
423
489
|
/**
|
|
424
490
|
* Single-walker fusion of `DeepPartial` and `DefaultValuesShape` — the
|
|
425
491
|
* type accepted at `defaultValues`, `reset()`'s parameter, and every
|
|
@@ -713,6 +779,15 @@ type MaybePromise<T> = T | Promise<T>;
|
|
|
713
779
|
type ValidateOptions = {
|
|
714
780
|
sync?: boolean;
|
|
715
781
|
};
|
|
782
|
+
/**
|
|
783
|
+
* Configuration passed to `AbstractSchema.getDefaultValues`. Adapters
|
|
784
|
+
* receive `useDefaultSchemaValues` (honor `.default(x)` wrappers vs.
|
|
785
|
+
* empty/falsy fallbacks), an optional `strict` mode (refinement
|
|
786
|
+
* preservation), and an optional `constraints` overlay merged into the
|
|
787
|
+
* derived defaults so the runtime can stamp user-supplied defaults at
|
|
788
|
+
* construction. Exported so adapter authors can co-implement the
|
|
789
|
+
* service contract.
|
|
790
|
+
*/
|
|
716
791
|
type GetDefaultValuesConfig<Form> = {
|
|
717
792
|
useDefaultSchemaValues: boolean;
|
|
718
793
|
/**
|
|
@@ -1092,6 +1167,32 @@ type AbstractSchema<Form, GetValueFormType> = {
|
|
|
1092
1167
|
* answers without a separate top-level overload.
|
|
1093
1168
|
*/
|
|
1094
1169
|
needsAsyncValidation?(): boolean;
|
|
1170
|
+
/**
|
|
1171
|
+
* Return `true` iff the schema carries a refine / check / transform
|
|
1172
|
+
* at any NON-LEAF position — a container node (object / array /
|
|
1173
|
+
* tuple / union / intersection / record / map / set) or the root
|
|
1174
|
+
* itself. False means every check this schema runs is leaf-local,
|
|
1175
|
+
* so a per-keystroke `validateAtPath(form, leafPath)` catches the
|
|
1176
|
+
* same verdicts as a whole-form pass — no ancestor refine reads
|
|
1177
|
+
* the form's wider state.
|
|
1178
|
+
*
|
|
1179
|
+
* The runtime uses this at the per-keystroke schedule to scope
|
|
1180
|
+
* field-level validation to the changed subtree when it can,
|
|
1181
|
+
* falling back to a whole-form pass when an ancestor refine
|
|
1182
|
+
* (cross-field equality, sum constraints, etc.) could be moved
|
|
1183
|
+
* by a leaf write. Optional. The runtime treats a missing
|
|
1184
|
+
* implementation as `() => true` — conservative whole-form,
|
|
1185
|
+
* preserving correctness for adapters that don't yet model
|
|
1186
|
+
* container-refine detection.
|
|
1187
|
+
*
|
|
1188
|
+
* Detection is best-effort: false negatives (returning `true`
|
|
1189
|
+
* when no container refine exists) only lose a perf win and
|
|
1190
|
+
* still validate correctly; false positives (returning `false`
|
|
1191
|
+
* when a container refine exists) would let an ancestor verdict
|
|
1192
|
+
* go stale and are the real risk — implementations should bias
|
|
1193
|
+
* toward returning `true` when in doubt.
|
|
1194
|
+
*/
|
|
1195
|
+
hasContainerOrRootRefine?(): boolean;
|
|
1095
1196
|
};
|
|
1096
1197
|
/**
|
|
1097
1198
|
* Adapter-returned info for a discriminated union — its discriminator
|
|
@@ -1795,8 +1896,9 @@ type UseFormConfiguration<Form extends GenericForm, GetValueFormType, Schema ext
|
|
|
1795
1896
|
maxRecursionDepth?: number;
|
|
1796
1897
|
/**
|
|
1797
1898
|
* Override the path-segment name stems treated as sensitive for this
|
|
1798
|
-
* form. Sensitive paths are excluded from persistence writes
|
|
1799
|
-
* multi-tab sync broadcasts
|
|
1899
|
+
* form. Sensitive paths are excluded from persistence writes and
|
|
1900
|
+
* multi-tab sync broadcasts. (DevTools renders raw values by design;
|
|
1901
|
+
* it does not redact.)
|
|
1800
1902
|
*
|
|
1801
1903
|
* Resolution: per-form value (this field) > global default
|
|
1802
1904
|
* (`createAttaform({ defaults: { sensitiveNames } })`) > library
|
|
@@ -2022,9 +2124,10 @@ type AttaformDefaults = {
|
|
|
2022
2124
|
maxRecursionDepth?: number;
|
|
2023
2125
|
/**
|
|
2024
2126
|
* Override the path-segment name stems treated as sensitive.
|
|
2025
|
-
* Sensitive paths are excluded from persistence writes
|
|
2026
|
-
* sync broadcasts
|
|
2027
|
-
*
|
|
2127
|
+
* Sensitive paths are excluded from persistence writes and multi-tab
|
|
2128
|
+
* sync broadcasts — one configurable source of truth across those
|
|
2129
|
+
* surfaces. (DevTools renders raw values by design; it does not
|
|
2130
|
+
* redact.)
|
|
2028
2131
|
*
|
|
2029
2132
|
* Library default is `DEFAULT_SENSITIVE_NAMES` (exported from
|
|
2030
2133
|
* `attaform`); compose to extend:
|
|
@@ -2235,7 +2338,7 @@ type MetaTrackerValue = {
|
|
|
2235
2338
|
*/
|
|
2236
2339
|
blank: boolean;
|
|
2237
2340
|
};
|
|
2238
|
-
type RegisterFlatPath<Form, Key extends keyof Form = keyof Form> =
|
|
2341
|
+
type RegisterFlatPath<Form, Key extends keyof Form = keyof Form> = FlatPathBuilder<Form, 'register', Key>;
|
|
2239
2342
|
/**
|
|
2240
2343
|
* Sync transformation applied to a field's value as user input flows
|
|
2241
2344
|
* from DOM through the directive's assigner. Composes left-to-right
|
|
@@ -2341,9 +2444,10 @@ type RegisterOptions = {
|
|
|
2341
2444
|
* If multiple inputs bind to the same path, the path keeps
|
|
2342
2445
|
* persisting as long as any opted-in input is mounted.
|
|
2343
2446
|
*
|
|
2344
|
-
*
|
|
2345
|
-
*
|
|
2346
|
-
* `acknowledgeSensitive: true` is also set
|
|
2447
|
+
* When the path looks sensitive (password / cvv / ssn / token /
|
|
2448
|
+
* etc.) the opt-in is skipped with a one-shot dev warning unless
|
|
2449
|
+
* `acknowledgeSensitive: true` is also set — the field simply isn't
|
|
2450
|
+
* persisted (the secure default). It never throws.
|
|
2347
2451
|
*/
|
|
2348
2452
|
persist?: boolean;
|
|
2349
2453
|
/**
|
|
@@ -2528,7 +2632,7 @@ type RegisterValue<Value = unknown> = Readonly<{
|
|
|
2528
2632
|
/**
|
|
2529
2633
|
* Resolved sensitive-path predicate honoring this form's
|
|
2530
2634
|
* `sensitiveNames` cascade. The directive calls this through
|
|
2531
|
-
* `
|
|
2635
|
+
* `allowSensitivePersist` when a `register('path', { persist: true })`
|
|
2532
2636
|
* binding mounts so a per-form custom list (e.g. extending with
|
|
2533
2637
|
* `'mrn'`) gates persistence enrolment correctly.
|
|
2534
2638
|
* @internal
|
|
@@ -4347,9 +4451,9 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4347
4451
|
* paths in the persisted draft are preserved (this is a merge,
|
|
4348
4452
|
* not a replace).
|
|
4349
4453
|
*
|
|
4350
|
-
*
|
|
4351
|
-
*
|
|
4352
|
-
* `useForm({ persist })` wasn't configured.
|
|
4454
|
+
* For sensitive-looking paths, warns once and no-ops unless you pass
|
|
4455
|
+
* `{ acknowledgeSensitive: true }` — it never throws. Also a no-op
|
|
4456
|
+
* when `useForm({ persist })` wasn't configured.
|
|
4353
4457
|
*/
|
|
4354
4458
|
persist: (path: FlatPath<Form>, options?: {
|
|
4355
4459
|
acknowledgeSensitive?: boolean;
|