@formisch/vue 0.7.5 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -53,7 +53,13 @@ In addition, Formisch offers several functions (we call them "methods") that can
53
53
 
54
54
  ## Comparison
55
55
 
56
- What makes Formisch unique is its framework-agnostic core, which is fully native to the framework you are using. It works by inserting framework-specific reactivity blocks when the core package is built. The result is a small bundle size and native performance for any UI update. This feature, along with a few others, distinguishes Formisch from other form libraries. My vision for Formisch is to create a framework-agnostic platform similar to [Vite](https://vite.dev/), but for forms.
56
+ What makes Formisch unique is its framework-agnostic core, which is fully native to the framework you are using. It works by inserting framework-specific reactivity blocks when the core package is built, giving you native performance for any UI update. A modular methods API keeps bundles starting at just ~2.5 kB by only including the methods you import, and end-to-end type safety covers deeply nested paths and field arrays with TypeScript inference that stays fast even as forms grow.
57
+
58
+ For a side-by-side look at how Formisch compares to VeeValidate, FormKit, and TanStack Form, see the [comparison guide](https://formisch.dev/vue/guides/comparison/).
59
+
60
+ ## Vision
61
+
62
+ My vision for Formisch is to create a framework-agnostic platform similar to [Vite](https://vite.dev/), but for forms — a shared core that lets the same mental model and codebase work natively across every modern UI framework.
57
63
 
58
64
  ## Partners
59
65
 
package/dist/index.d.ts CHANGED
@@ -4,20 +4,44 @@ import { ComponentPublicInstance, MaybeRefOrGetter, ShallowRef as Signal } from
4
4
 
5
5
  //#region ../../packages/core/dist/index.vue.d.ts
6
6
 
7
- //#region src/types/schema.d.ts
7
+ //#region src/types/schema/schema.d.ts
8
8
  /**
9
9
  * Schema type.
10
10
  */
11
11
  type Schema = v.GenericSchema | v.GenericSchemaAsync;
12
+ /**
13
+ * Object schema type.
14
+ */
15
+ type ObjectSchema = v.LooseObjectSchema<v.ObjectEntries, v.ErrorMessage<v.LooseObjectIssue> | undefined> | v.ObjectSchema<v.ObjectEntries, v.ErrorMessage<v.ObjectIssue> | undefined> | v.StrictObjectSchema<v.ObjectEntries, v.ErrorMessage<v.StrictObjectIssue> | undefined> | v.VariantSchema<string, v.VariantOptions<string>, v.ErrorMessage<v.VariantIssue> | undefined>;
16
+ /**
17
+ * Object schema async type.
18
+ */
19
+ type ObjectSchemaAsync = v.LooseObjectSchemaAsync<v.ObjectEntriesAsync, v.ErrorMessage<v.LooseObjectIssue> | undefined> | v.ObjectSchemaAsync<v.ObjectEntriesAsync, v.ErrorMessage<v.ObjectIssue> | undefined> | v.StrictObjectSchemaAsync<v.ObjectEntriesAsync, v.ErrorMessage<v.StrictObjectIssue> | undefined> | v.VariantSchemaAsync<string, v.VariantOptionsAsync<string>, v.ErrorMessage<v.VariantIssue> | undefined>;
20
+ /**
21
+ * Object root schema type.
22
+ */
23
+ type ObjectRootSchema = ObjectSchema | v.IntersectSchema<ObjectSchema[], v.ErrorMessage<v.IntersectIssue> | undefined> | v.UnionSchema<ObjectSchema[], v.ErrorMessage<v.UnionIssue<v.BaseIssue<unknown>>> | undefined>;
24
+ /**
25
+ * Object root schema async type.
26
+ */
27
+ type ObjectRootSchemaAsync = ObjectSchemaAsync | v.IntersectSchemaAsync<(ObjectSchema | ObjectSchemaAsync)[], v.ErrorMessage<v.IntersectIssue> | undefined> | v.UnionSchemaAsync<(ObjectSchema | ObjectSchemaAsync)[], v.ErrorMessage<v.UnionIssue<v.BaseIssue<unknown>>> | undefined>;
28
+ /**
29
+ * Form schema type.
30
+ *
31
+ * Hint: Forms must have an object root, so only object schemas (sync or async),
32
+ * combinators (intersect, union, variant) whose options resolve to objects, and
33
+ * `lazy` schemas wrapping any of these are allowed at the top level. Use
34
+ * {@link Schema} for nested field schemas.
35
+ */
36
+ type FormSchema = ObjectRootSchema | ObjectRootSchemaAsync | v.LazySchema<ObjectRootSchema> | v.LazySchemaAsync<ObjectRootSchema | ObjectRootSchemaAsync>;
12
37
  //#endregion
13
- //#region src/types/signal.d.ts
14
-
38
+ //#region src/types/signal/signal.d.ts
15
39
  /**
16
40
  * Batch interface.
17
41
  */
18
42
 
19
43
  //#endregion
20
- //#region src/types/field.d.ts
44
+ //#region src/types/field/field.d.ts
21
45
  /**
22
46
  * Field element type.
23
47
  */
@@ -183,7 +207,7 @@ type InternalFieldStore = InternalArrayStore | InternalObjectStore | InternalVal
183
207
  */
184
208
  declare const INTERNAL: "~internal";
185
209
  //#endregion
186
- //#region src/types/utils.d.ts
210
+ //#region src/types/utils/utils.d.ts
187
211
  /**
188
212
  * Checks if a type is `any`.
189
213
  */
@@ -209,7 +233,7 @@ type DeepPartial<TValue> = TValue extends Record<PropertyKey, unknown> | readonl
209
233
  */
210
234
  type PartialValues<TValue> = TValue extends readonly (infer TItem)[] ? number extends TValue["length"] ? (TItem extends Record<PropertyKey, unknown> | readonly unknown[] ? { [TKey in keyof TItem]: PartialValues<TItem[TKey]> } : TItem)[] : { [TKey in keyof TValue]: PartialValues<TValue[TKey]> } : TValue extends Record<PropertyKey, unknown> ? { [TKey in keyof TValue]: PartialValues<TValue[TKey]> } : TValue | undefined;
211
235
  //#endregion
212
- //#region src/types/form.d.ts
236
+ //#region src/types/form/form.d.ts
213
237
  /**
214
238
  * Validation mode type.
215
239
  */
@@ -217,7 +241,7 @@ type ValidationMode = "initial" | "touch" | "input" | "change" | "blur" | "submi
217
241
  /**
218
242
  * Form config interface.
219
243
  */
220
- interface FormConfig<TSchema extends Schema = Schema> {
244
+ interface FormConfig<TSchema extends FormSchema = FormSchema> {
221
245
  /**
222
246
  * The schema of the form.
223
247
  */
@@ -238,7 +262,7 @@ interface FormConfig<TSchema extends Schema = Schema> {
238
262
  /**
239
263
  * Internal form store interface.
240
264
  */
241
- interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObjectStore {
265
+ interface InternalFormStore<TSchema extends FormSchema = FormSchema> extends InternalObjectStore {
242
266
  /**
243
267
  * The element of the form.
244
268
  */
@@ -275,7 +299,7 @@ interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObj
275
299
  /**
276
300
  * Base form store interface.
277
301
  */
278
- interface BaseFormStore<TSchema extends Schema = Schema> {
302
+ interface BaseFormStore<TSchema extends FormSchema = FormSchema> {
279
303
  /**
280
304
  * The internal form store.
281
305
  *
@@ -286,13 +310,13 @@ interface BaseFormStore<TSchema extends Schema = Schema> {
286
310
  /**
287
311
  * Submit handler type.
288
312
  */
289
- type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>) => MaybePromise<unknown>;
313
+ type SubmitHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>) => MaybePromise<unknown>;
290
314
  /**
291
315
  * Submit event handler type.
292
316
  */
293
- type SubmitEventHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
317
+ type SubmitEventHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
294
318
  //#endregion
295
- //#region src/types/path.d.ts
319
+ //#region src/types/path/path.d.ts
296
320
  /**
297
321
  * Path key type.
298
322
  */
@@ -306,47 +330,115 @@ type Path = readonly PathKey[];
306
330
  */
307
331
  type RequiredPath = readonly [PathKey, ...Path];
308
332
  /**
309
- * Extracts the exact keys of a tuple, array or object.
333
+ * Extracts the exact keys of a tuple, array or object. Tuples return their
334
+ * literal numeric indices, dynamic arrays return `number`, objects return
335
+ * their `keyof` keys, and any other input returns `never`.
310
336
  */
311
- type KeyOf<TValue> = IsAny<TValue> extends true ? never : TValue extends readonly unknown[] ? number extends TValue["length"] ? number : { [TKey in keyof TValue]: TKey extends `${infer TIndex extends number}` ? TIndex : never }[number] : TValue extends Record<string, unknown> ? keyof TValue & PathKey : never;
337
+ type ExactKeysOf<TValue> = IsAny<TValue> extends true ? never : TValue extends readonly unknown[] ? number extends TValue["length"] ? number : { [TKey in keyof TValue]: TKey extends `${infer TIndex extends number}` ? TIndex : never }[number] : TValue extends Record<PropertyKey, unknown> ? keyof TValue & PathKey : never;
312
338
  /**
313
- * Merges array and object unions into a single object.
339
+ * Returns the flat object of all indexable properties of `TValue`. For object
340
+ * unions, properties from every member are merged so that any single property
341
+ * is accessible. For primitives and other non-indexable types, the result is
342
+ * `{}`.
314
343
  *
315
- * Hint: This is necessary to make any property accessible. By default,
316
- * properties that do not exist in all union options are not accessible
317
- * and result in "any" when accessed.
344
+ * Hint: This is necessary to make properties accessible across union members.
345
+ * By default, properties that do not exist in all union options are not
346
+ * accessible and result in "any" when accessed.
318
347
  */
319
- type MergeUnion<TValue> = { [TKey in KeyOf<TValue>]: TValue extends Record<TKey, infer TItem> ? TItem : never };
348
+ type PropertiesOf<TValue> = { [TKey in ExactKeysOf<TValue>]: TValue extends Record<TKey, infer TItem> ? TItem : never };
320
349
  /**
321
350
  * Lazily evaluates only the first valid path segment based on the given value.
322
351
  */
323
- type LazyPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValidPath : TPathToCheck extends readonly [infer TFirstKey extends KeyOf<TValue>, ...infer TPathRest extends Path] ? LazyPath<Required<MergeUnion<TValue>[TFirstKey]>, TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOf<TValue>> extends false ? readonly [...TValidPath, KeyOf<TValue>] : TValidPath;
352
+ type LazyPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValidPath : TPathToCheck extends readonly [infer TFirstKey extends ExactKeysOf<TValue>, ...infer TPathRest extends Path] ? LazyPath<Required<PropertiesOf<TValue>[TFirstKey]>, TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<ExactKeysOf<TValue>> extends false ? readonly [...TValidPath, ExactKeysOf<TValue>] : TValidPath;
324
353
  /**
325
354
  * Returns the path if valid, otherwise the first possible valid path based on
326
355
  * the given value.
327
356
  */
328
357
  type ValidPath<TValue, TPath extends RequiredPath> = TPath extends LazyPath<Required<TValue>, TPath> ? TPath : LazyPath<Required<TValue>, TPath>;
329
358
  /**
359
+ * Detects whether the consuming project is configured with
360
+ * `exactOptionalPropertyTypes: true`.
361
+ *
362
+ * Hint: If `false` the built-in `Required<T>` strips `| undefined` from
363
+ * optional properties, so `Required<{ key?: undefined }>['key']` collapses
364
+ * to `never` — under strict mode the same expression yields `undefined`.
365
+ */
366
+ type IsExactOptionalProps = Required<{
367
+ key?: undefined;
368
+ }>["key"] extends never ? false : true;
369
+ /**
370
+ * Like the built-in `Required<T>`, but preserves `| undefined` in two
371
+ * places where `Required<T>` strips it:
372
+ *
373
+ * 1. Optional property values under `exactOptionalPropertyTypes: false`
374
+ * — without this, input typings for `v.optional`/`v.nullish` schemas
375
+ * narrow incorrectly (issue #15).
376
+ * 2. Array/tuple element types — e.g. `(string | undefined)[]` stays
377
+ * `(string | undefined)[]` instead of becoming `string[]`. Arrays
378
+ * fall through unchanged because they only have a numeric index
379
+ * signature and don't structurally extend `Record<PropertyKey,
380
+ * unknown>` (which requires string keys).
381
+ */
382
+ type ExactRequired<TValue> = TValue extends Record<PropertyKey, unknown> ? IsExactOptionalProps extends true ? Required<TValue> : { [TKey in keyof Required<TValue>]: TValue[TKey] } : TValue;
383
+ /**
330
384
  * Extracts the value type at the given path.
331
385
  */
332
- type PathValue<TValue, TPath extends Path> = TPath extends readonly [infer TKey, ...infer TRest extends Path] ? TKey extends KeyOf<Required<TValue>> ? PathValue<MergeUnion<Required<TValue>>[TKey], TRest> : unknown : TValue;
386
+ type PathValue<TValue, TPath extends Path> = TPath extends readonly [infer TKey, ...infer TRest extends Path] ? TKey extends ExactKeysOf<ExactRequired<TValue>> ? PathValue<PropertiesOf<ExactRequired<TValue>>[TKey], TRest> : unknown : TValue;
333
387
  /**
334
- * Checks if a value is an array or contains one.
388
+ * Checks whether a value is an array or contains one anywhere in its shape.
389
+ *
390
+ * Hint: The inner conditionals (`TValue extends readonly unknown[]` and
391
+ * `TValue extends Record<PropertyKey, unknown>`) distribute over union members,
392
+ * so the inner expression returns the union of each member's result (e.g.
393
+ * `true | false` when some members contain arrays and others don't).
394
+ * Downstream code uses `IsOrHasArray<T> extends true`, but
395
+ * `boolean extends true` is `false` — so we collapse the result via
396
+ * `true extends ...`, which is `true` whenever at least one union member
397
+ * contributed `true`.
335
398
  */
336
- type IsOrHasArray<TValue> = IsAny<TValue> extends true ? false : TValue extends readonly unknown[] ? true : TValue extends Record<string, unknown> ? true extends { [TKey in keyof TValue]: IsOrHasArray<TValue[TKey]> }[keyof TValue] ? true : false : false;
399
+ type IsOrHasArray<TValue> = true extends (IsAny<TValue> extends true ? false : TValue extends readonly unknown[] ? true : TValue extends Record<PropertyKey, unknown> ? { [TKey in keyof TValue]: IsOrHasArray<TValue[TKey]> }[keyof TValue] : false) ? true : false;
337
400
  /**
338
401
  * Extracts the exact keys of a tuple, array or object that contain arrays.
339
402
  */
340
- type KeyOfArrayPath<TValue> = IsAny<TValue> extends true ? never : TValue extends readonly (infer TItem)[] ? number extends TValue["length"] ? IsOrHasArray<TItem> extends true ? number : never : { [TKey in keyof TValue]: TKey extends `${infer TIndex extends number}` ? IsOrHasArray<NonNullable<TValue[TKey]>> extends true ? TIndex : never : never }[number] : TValue extends Record<string, unknown> ? { [TKey in keyof TValue]: IsOrHasArray<NonNullable<TValue[TKey]>> extends true ? TKey : never }[keyof TValue] & PathKey : never;
403
+ type ExactKeysOfArrayPath<TValue> = IsAny<TValue> extends true ? never : TValue extends readonly (infer TItem)[] ? number extends TValue["length"] ? IsOrHasArray<TItem> extends true ? number : never : { [TKey in keyof TValue]: TKey extends `${infer TIndex extends number}` ? IsOrHasArray<NonNullable<TValue[TKey]>> extends true ? TIndex : never : never }[number] : TValue extends Record<PropertyKey, unknown> ? { [TKey in keyof TValue]: IsOrHasArray<NonNullable<TValue[TKey]>> extends true ? TKey : never }[keyof TValue] & PathKey : never;
404
+ /**
405
+ * Returns the flat object of indexable properties of `TValue` whose values
406
+ * are or contain arrays. Mirrors `PropertiesOf` but keyed by
407
+ * `ExactKeysOfArrayPath` so the lookup is provably valid for array-path
408
+ * navigation in `LazyArrayPath`.
409
+ */
410
+ type PropertiesOfArrayPath<TValue> = { [TKey in ExactKeysOfArrayPath<TValue>]: TValue extends Record<TKey, infer TItem> ? TItem : never };
341
411
  /**
342
412
  * Lazily evaluates only the first valid array path segment based on the given value.
343
413
  */
344
- type LazyArrayPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValue extends readonly unknown[] ? TValidPath : readonly [...TValidPath, KeyOfArrayPath<TValue>] : TPathToCheck extends readonly [infer TFirstKey extends KeyOfArrayPath<TValue>, ...infer TPathRest extends Path] ? LazyArrayPath<Required<MergeUnion<TValue>[TFirstKey]>, TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOfArrayPath<TValue>> extends false ? readonly [...TValidPath, KeyOfArrayPath<TValue>] : never;
414
+ type LazyArrayPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValue extends readonly unknown[] ? TValidPath : readonly [...TValidPath, ExactKeysOfArrayPath<TValue>] : TPathToCheck extends readonly [infer TFirstKey extends ExactKeysOfArrayPath<TValue>, ...infer TPathRest extends Path] ? LazyArrayPath<Required<PropertiesOfArrayPath<TValue>[TFirstKey]>, TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<ExactKeysOfArrayPath<TValue>> extends false ? readonly [...TValidPath, ExactKeysOfArrayPath<TValue>] : never;
345
415
  /**
346
416
  * Returns the path if valid, otherwise the first possible valid array path
347
417
  * based on the given value.
348
418
  */
349
419
  type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<Required<TValue>, TPath> ? TPath : LazyArrayPath<Required<TValue>, TPath>;
420
+ /**
421
+ * Recursive helper for `DirtyPath` that prepends `TKey` to each deeper path,
422
+ * or falls through to `never` when the child is not an object.
423
+ */
424
+ type DeepDirtyPath<TChild, TKey$1 extends PathKey, TDepth extends 0[]> = TChild extends Record<PropertyKey, unknown> ? readonly [TKey$1, ...DirtyPath<TChild, [...TDepth, 0]>] : never;
425
+ /**
426
+ * Returns the union of all `RequiredPath`s that `getDirtyPaths` can emit
427
+ * for a given input type. Object fields contribute their own path and the
428
+ * paths of their descendants; arrays and tuples are atomic and contribute
429
+ * only their own path, because dirty arrays are returned as complete units.
430
+ *
431
+ * Narrowing is exact for the first 5 levels of nesting; deeper paths fall
432
+ * back to `RequiredPath` to keep the result a complete superset of any
433
+ * path the runtime can address.
434
+ *
435
+ * Hint: Arrays and tuples are atomic because they don't structurally
436
+ * extend `Record<PropertyKey, unknown>` and so fall through to `never`
437
+ * via `DeepDirtyPath` — no explicit array check is needed. `TDepth` is
438
+ * a tuple-length counter capped at 5 to bound TypeScript instantiation
439
+ * cost.
440
+ */
441
+ type DirtyPath<TValue, TDepth extends 0[] = []> = TDepth["length"] extends 5 ? RequiredPath : TValue extends Record<PropertyKey, unknown> ? { [TKey in ExactKeysOf<TValue>]: readonly [TKey] | DeepDirtyPath<NonNullable<PropertiesOf<TValue>[TKey]>, TKey, TDepth> }[ExactKeysOf<TValue>] : never;
350
442
  //#endregion
351
443
  //#region src/array/copyItemState/copyItemState.d.ts
352
444
  /**
@@ -365,7 +457,7 @@ type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArra
365
457
  /**
366
458
  * Focus field config interface.
367
459
  */
368
- interface FocusFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
460
+ interface FocusFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
369
461
  /**
370
462
  * The path to the field to focus.
371
463
  */
@@ -379,7 +471,7 @@ interface FocusFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPa
379
471
  * @param form The form store containing the field.
380
472
  * @param config The focus field configuration.
381
473
  */
382
- declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
474
+ declare function focus<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
383
475
  //#endregion
384
476
  //#region src/getAllErrors/getAllErrors.d.ts
385
477
  /**
@@ -393,6 +485,93 @@ declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(
393
485
  */
394
486
  declare function getAllErrors(form: BaseFormStore): [string, ...string[]] | null;
395
487
  //#endregion
488
+ //#region src/getDirtyInput/getDirtyInput.d.ts
489
+ /**
490
+ * Get form dirty input config interface.
491
+ */
492
+ interface GetFormDirtyInputConfig {
493
+ /**
494
+ * The path to a field. Leave undefined to get the dirty input of the entire
495
+ * form.
496
+ */
497
+ readonly path?: undefined;
498
+ }
499
+ /**
500
+ * Get field dirty input config interface.
501
+ */
502
+ interface GetFieldDirtyInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
503
+ /**
504
+ * The path to the field to retrieve the dirty input from.
505
+ */
506
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
507
+ }
508
+ /**
509
+ * Retrieves only the dirty input values of a specific field or the entire
510
+ * form. Arrays are treated as atomic and returned in full if any item is
511
+ * dirty, while object keys without a dirty descendant are omitted. Returns
512
+ * `undefined` if no field in the inspected subtree is dirty.
513
+ *
514
+ * @param form The form store to retrieve dirty input from.
515
+ *
516
+ * @returns The dirty input of the form or specified field, or `undefined`.
517
+ */
518
+ declare function getDirtyInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): DeepPartial<v.InferInput<TSchema>> | undefined;
519
+ /**
520
+ * Retrieves only the dirty input values of a specific field or the entire
521
+ * form. Arrays are treated as atomic and returned in full if any item is
522
+ * dirty, while object keys without a dirty descendant are omitted. Returns
523
+ * `undefined` if no field in the inspected subtree is dirty.
524
+ *
525
+ * @param form The form store to retrieve dirty input from.
526
+ * @param config The get dirty input configuration.
527
+ *
528
+ * @returns The dirty input of the form or specified field, or `undefined`.
529
+ */
530
+ declare function getDirtyInput<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldDirtyInputConfig<TSchema, TFieldPath> : GetFormDirtyInputConfig): DeepPartial<TFieldPath extends RequiredPath ? PathValue<v.InferInput<TSchema>, TFieldPath> : v.InferInput<TSchema>> | undefined;
531
+ //#endregion
532
+ //#region src/getDirtyPaths/getDirtyPaths.d.ts
533
+ /**
534
+ * Get form dirty paths config interface.
535
+ */
536
+ interface GetFormDirtyPathsConfig {
537
+ /**
538
+ * The path to a field. Leave undefined to inspect the entire form.
539
+ */
540
+ readonly path?: undefined;
541
+ }
542
+ /**
543
+ * Get field dirty paths config interface.
544
+ */
545
+ interface GetFieldDirtyPathsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
546
+ /**
547
+ * The path to the field to inspect.
548
+ */
549
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
550
+ }
551
+ /**
552
+ * Returns a list of paths to the dirty fields of a specific field or the
553
+ * entire form. Arrays are treated as atomic and contribute only their own
554
+ * path if any item is dirty, while object branches are recursed into. Returns
555
+ * an empty list if no field in the inspected subtree is dirty.
556
+ *
557
+ * @param form The form store to inspect.
558
+ *
559
+ * @returns The list of paths to the dirty fields.
560
+ */
561
+ declare function getDirtyPaths<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): DirtyPath<v.InferInput<TSchema>>[];
562
+ /**
563
+ * Returns a list of paths to the dirty fields of a specific field or the
564
+ * entire form. Arrays are treated as atomic and contribute only their own
565
+ * path if any item is dirty, while object branches are recursed into. Returns
566
+ * an empty list if no field in the inspected subtree is dirty.
567
+ *
568
+ * @param form The form store to inspect.
569
+ * @param config The get dirty paths configuration.
570
+ *
571
+ * @returns The list of paths to the dirty fields.
572
+ */
573
+ declare function getDirtyPaths<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldDirtyPathsConfig<TSchema, TFieldPath> : GetFormDirtyPathsConfig): DirtyPath<v.InferInput<TSchema>>[];
574
+ //#endregion
396
575
  //#region src/getErrors/getErrors.d.ts
397
576
  /**
398
577
  * Get form errors config interface.
@@ -406,7 +585,7 @@ interface GetFormErrorsConfig {
406
585
  /**
407
586
  * Get field errors config interface.
408
587
  */
409
- interface GetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
588
+ interface GetFieldErrorsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
410
589
  /**
411
590
  * The path to the field to retrieve errors from.
412
591
  */
@@ -421,7 +600,7 @@ interface GetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends Requir
421
600
  *
422
601
  * @returns A non-empty array of error messages, or null if no errors exist.
423
602
  */
424
- declare function getErrors<TSchema extends Schema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
603
+ declare function getErrors<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
425
604
  /**
426
605
  * Retrieves error messages from the form. When called without a config,
427
606
  * returns form-level errors. When called with a path, returns errors for
@@ -432,7 +611,7 @@ declare function getErrors<TSchema extends Schema>(form: BaseFormStore<TSchema>)
432
611
  *
433
612
  * @returns A non-empty array of error messages, or null if no errors exist.
434
613
  */
435
- declare function getErrors<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldErrorsConfig<TSchema, TFieldPath> : GetFormErrorsConfig): [string, ...string[]] | null;
614
+ declare function getErrors<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldErrorsConfig<TSchema, TFieldPath> : GetFormErrorsConfig): [string, ...string[]] | null;
436
615
  //#endregion
437
616
  //#region src/getInput/getInput.d.ts
438
617
  /**
@@ -447,7 +626,7 @@ interface GetFormInputConfig {
447
626
  /**
448
627
  * Get field input config interface.
449
628
  */
450
- interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
629
+ interface GetFieldInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
451
630
  /**
452
631
  * The path to the field to retrieve input from.
453
632
  */
@@ -461,7 +640,7 @@ interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends Require
461
640
  *
462
641
  * @returns The partial input values of the form or the specified field.
463
642
  */
464
- declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
643
+ declare function getInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
465
644
  /**
466
645
  * Retrieves the current input value of a specific field or the entire form.
467
646
  * Returns a partial object as not all fields may have been set.
@@ -471,7 +650,7 @@ declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>):
471
650
  *
472
651
  * @returns The partial input values of the form or the specified field.
473
652
  */
474
- declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldInputConfig<TSchema, TFieldPath> : GetFormInputConfig): PartialValues<TFieldPath extends RequiredPath ? PathValue<v.InferInput<TSchema>, TFieldPath> : v.InferInput<TSchema>>;
653
+ declare function getInput<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldInputConfig<TSchema, TFieldPath> : GetFormInputConfig): PartialValues<TFieldPath extends RequiredPath ? PathValue<v.InferInput<TSchema>, TFieldPath> : v.InferInput<TSchema>>;
475
654
  //#endregion
476
655
  //#region src/handleSubmit/handleSubmit.d.ts
477
656
  /**
@@ -484,7 +663,7 @@ declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPat
484
663
  *
485
664
  * @returns A submit event handler function to attach to the form element.
486
665
  */
487
- declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): () => Promise<void>;
666
+ declare function handleSubmit<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): () => Promise<void>;
488
667
  /**
489
668
  * Creates a submit event handler for the form that prevents default browser
490
669
  * submission, validates the form input, and calls the provided handler if
@@ -495,13 +674,13 @@ declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchem
495
674
  *
496
675
  * @returns A submit event handler function to attach to the form element.
497
676
  */
498
- declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitEventHandler<TSchema>): (event: SubmitEvent) => Promise<void>;
677
+ declare function handleSubmit<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, handler: SubmitEventHandler<TSchema>): (event: SubmitEvent) => Promise<void>;
499
678
  //#endregion
500
679
  //#region src/insert/insert.d.ts
501
680
  /**
502
681
  * Insert array field config interface.
503
682
  */
504
- interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
683
+ interface InsertConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
505
684
  /**
506
685
  * The path to the field array to insert into.
507
686
  */
@@ -522,13 +701,13 @@ interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredP
522
701
  * @param form The form store containing the field array.
523
702
  * @param config The insert configuration specifying the path, index, and initial value.
524
703
  */
525
- declare function insert<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
704
+ declare function insert<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
526
705
  //#endregion
527
706
  //#region src/move/move.d.ts
528
707
  /**
529
708
  * Move array field config interface.
530
709
  */
531
- interface MoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
710
+ interface MoveConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
532
711
  /**
533
712
  * The path to the field array to move an item within.
534
713
  */
@@ -549,13 +728,38 @@ interface MoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPat
549
728
  * @param form The form store containing the field array.
550
729
  * @param config The move configuration specifying the path and source/destination indices.
551
730
  */
552
- declare function move<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: MoveConfig<TSchema, TFieldArrayPath>): void;
731
+ declare function move<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: MoveConfig<TSchema, TFieldArrayPath>): void;
732
+ //#endregion
733
+ //#region src/pickDirty/pickDirty.d.ts
734
+ /**
735
+ * Pick dirty config interface.
736
+ */
737
+ interface PickDirtyConfig<TValue extends object> {
738
+ /**
739
+ * The value to filter down to its dirty parts. Must be structurally
740
+ * compatible with the form's schema.
741
+ */
742
+ readonly from: TValue;
743
+ }
744
+ /**
745
+ * Picks only the dirty parts of the given value, using the form's dirty fields
746
+ * as a structural mask. Arrays are treated as atomic and object keys without a
747
+ * dirty descendant are omitted. Returns `undefined` if no field is dirty.
748
+ * Useful for filtering a validated output down to its changed parts before
749
+ * submitting.
750
+ *
751
+ * @param form The form store providing the dirty mask.
752
+ * @param config The pick dirty configuration.
753
+ *
754
+ * @returns The dirty parts of the value, or `undefined`.
755
+ */
756
+ declare function pickDirty<TSchema extends FormSchema, TValue extends object>(form: BaseFormStore<TSchema>, config: PickDirtyConfig<TValue>): DeepPartial<TValue> | undefined;
553
757
  //#endregion
554
758
  //#region src/remove/remove.d.ts
555
759
  /**
556
760
  * Remove array field config interface.
557
761
  */
558
- interface RemoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
762
+ interface RemoveConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
559
763
  /**
560
764
  * The path to the field array to remove an item from.
561
765
  */
@@ -572,13 +776,13 @@ interface RemoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredP
572
776
  * @param form The form store containing the field array.
573
777
  * @param config The remove configuration specifying the path and index.
574
778
  */
575
- declare function remove<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: RemoveConfig<TSchema, TFieldArrayPath>): void;
779
+ declare function remove<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: RemoveConfig<TSchema, TFieldArrayPath>): void;
576
780
  //#endregion
577
781
  //#region src/replace/replace.d.ts
578
782
  /**
579
783
  * Replace array field config interface.
580
784
  */
581
- interface ReplaceConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
785
+ interface ReplaceConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
582
786
  /**
583
787
  * The path to the field array to replace an item within.
584
788
  */
@@ -598,7 +802,7 @@ interface ReplaceConfig<TSchema extends Schema, TFieldArrayPath extends Required
598
802
  * @param form The form store containing the field array.
599
803
  * @param config The replace configuration specifying the path, index, and initial input.
600
804
  */
601
- declare function replace<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: ReplaceConfig<TSchema, TFieldArrayPath>): void;
805
+ declare function replace<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: ReplaceConfig<TSchema, TFieldArrayPath>): void;
602
806
  //#endregion
603
807
  //#region src/reset/reset.d.ts
604
808
  /**
@@ -621,7 +825,7 @@ interface ResetBaseConfig {
621
825
  /**
622
826
  * Reset form config interface.
623
827
  */
624
- interface ResetFormConfig<TSchema extends Schema> extends ResetBaseConfig {
828
+ interface ResetFormConfig<TSchema extends FormSchema> extends ResetBaseConfig {
625
829
  /**
626
830
  * The path to a field. Leave undefined to reset the entire form.
627
831
  */
@@ -639,7 +843,7 @@ interface ResetFormConfig<TSchema extends Schema> extends ResetBaseConfig {
639
843
  /**
640
844
  * Reset field config interface.
641
845
  */
642
- interface ResetFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> extends ResetBaseConfig {
846
+ interface ResetFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> extends ResetBaseConfig {
643
847
  /**
644
848
  * The path to the field to reset.
645
849
  */
@@ -666,7 +870,7 @@ declare function reset(form: BaseFormStore): void;
666
870
  * @param form The form store to reset.
667
871
  * @param config The reset configuration specifying what to reset and what to keep.
668
872
  */
669
- declare function reset<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? ResetFieldConfig<TSchema, TFieldPath> : ResetFormConfig<TSchema>): void;
873
+ declare function reset<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? ResetFieldConfig<TSchema, TFieldPath> : ResetFormConfig<TSchema>): void;
670
874
  //#endregion
671
875
  //#region src/setErrors/setErrors.d.ts
672
876
  /**
@@ -685,7 +889,7 @@ interface SetFormErrorsConfig {
685
889
  /**
686
890
  * Set field errors config interface.
687
891
  */
688
- interface SetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
892
+ interface SetFieldErrorsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
689
893
  /**
690
894
  * The path to the field to set errors on.
691
895
  */
@@ -703,13 +907,13 @@ interface SetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends Requir
703
907
  * @param form The form store to set errors on.
704
908
  * @param config The set errors configuration specifying the path and error messages.
705
909
  */
706
- declare function setErrors<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldErrorsConfig<TSchema, TFieldPath> : SetFormErrorsConfig): void;
910
+ declare function setErrors<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldErrorsConfig<TSchema, TFieldPath> : SetFormErrorsConfig): void;
707
911
  //#endregion
708
912
  //#region src/setInput/setInput.d.ts
709
913
  /**
710
914
  * Set form input config interface.
711
915
  */
712
- interface SetFormInputConfig<TSchema extends Schema> {
916
+ interface SetFormInputConfig<TSchema extends FormSchema> {
713
917
  /**
714
918
  * The path to a field. Leave undefined to set the entire form input.
715
919
  */
@@ -722,7 +926,7 @@ interface SetFormInputConfig<TSchema extends Schema> {
722
926
  /**
723
927
  * Set field input config interface.
724
928
  */
725
- interface SetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
929
+ interface SetFieldInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
726
930
  /**
727
931
  * The path to the field to set input on.
728
932
  */
@@ -740,7 +944,7 @@ interface SetFieldInputConfig<TSchema extends Schema, TFieldPath extends Require
740
944
  * @param form The form store to set input on.
741
945
  * @param config The set form input configuration specifying the new input values.
742
946
  */
743
- declare function setInput<TSchema extends Schema>(form: BaseFormStore<TSchema>, config: SetFormInputConfig<TSchema>): void;
947
+ declare function setInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, config: SetFormInputConfig<TSchema>): void;
744
948
  /**
745
949
  * Sets the input value of a specific field or the entire form. This updates
746
950
  * the field value(s) and triggers validation if required by the form's
@@ -749,7 +953,7 @@ declare function setInput<TSchema extends Schema>(form: BaseFormStore<TSchema>,
749
953
  * @param form The form store to set input on.
750
954
  * @param config The set input configuration specifying the path and new value.
751
955
  */
752
- declare function setInput<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldInputConfig<TSchema, TFieldPath> : SetFormInputConfig<TSchema>): void;
956
+ declare function setInput<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldInputConfig<TSchema, TFieldPath> : SetFormInputConfig<TSchema>): void;
753
957
  //#endregion
754
958
  //#region src/submit/submit.d.ts
755
959
  /**
@@ -764,7 +968,7 @@ declare function submit(form: BaseFormStore): void;
764
968
  /**
765
969
  * Swap array field config interface.
766
970
  */
767
- interface SwapConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
971
+ interface SwapConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
768
972
  /**
769
973
  * The path to the field array to swap items within.
770
974
  */
@@ -784,7 +988,7 @@ interface SwapConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPat
784
988
  * @param form The form store containing the field array.
785
989
  * @param config The swap configuration specifying the path and indices to swap.
786
990
  */
787
- declare function swap<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: SwapConfig<TSchema, TFieldArrayPath>): void;
991
+ declare function swap<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: SwapConfig<TSchema, TFieldArrayPath>): void;
788
992
  //#endregion
789
993
  //#region src/validate/validate.d.ts
790
994
  /**
@@ -806,7 +1010,7 @@ interface ValidateFormConfig {
806
1010
  *
807
1011
  * @returns A promise resolving to the validation result.
808
1012
  */
809
- declare function validate<TSchema extends Schema>(form: BaseFormStore<TSchema>, config?: ValidateFormConfig): Promise<v.SafeParseResult<TSchema>>;
1013
+ declare function validate<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, config?: ValidateFormConfig): Promise<v.SafeParseResult<TSchema>>;
810
1014
  //#endregion
811
1015
  //#endregion
812
1016
  //#region src/types/field.d.ts
@@ -842,7 +1046,7 @@ interface FieldElementProps {
842
1046
  /**
843
1047
  * Field store interface.
844
1048
  */
845
- interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1049
+ interface FieldStore<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
846
1050
  /**
847
1051
  * The path to the field within the form.
848
1052
  */
@@ -879,7 +1083,7 @@ interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends Require
879
1083
  /**
880
1084
  * Field array store interface.
881
1085
  */
882
- interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1086
+ interface FieldArrayStore<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
883
1087
  /**
884
1088
  * The path to the array field within the form.
885
1089
  */
@@ -910,7 +1114,7 @@ interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath exten
910
1114
  /**
911
1115
  * Form store interface.
912
1116
  */
913
- interface FormStore<TSchema extends Schema = Schema> extends BaseFormStore<TSchema> {
1117
+ interface FormStore<TSchema extends FormSchema = FormSchema> extends BaseFormStore<TSchema> {
914
1118
  /**
915
1119
  * Whether the form is currently submitting.
916
1120
  */
@@ -948,7 +1152,7 @@ interface FormStore<TSchema extends Schema = Schema> extends BaseFormStore<TSche
948
1152
  /**
949
1153
  * Field component props interface.
950
1154
  */
951
- interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1155
+ interface FieldProps<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
952
1156
  /**
953
1157
  * The form store to which the field belongs.
954
1158
  */
@@ -958,7 +1162,7 @@ interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends Require
958
1162
  */
959
1163
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
960
1164
  }
961
- declare const __VLS_export$2: <TSchema extends Schema, TFieldPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$2<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1165
+ declare const __VLS_export$2: <TSchema extends FormSchema, TFieldPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$2<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
962
1166
  props: __VLS_PrettifyLocal$2<FieldProps<TSchema, TFieldPath>> & vue1.PublicProps;
963
1167
  expose: (exposed: {}) => void;
964
1168
  attrs: any;
@@ -976,7 +1180,7 @@ type __VLS_PrettifyLocal$2<T> = { [K in keyof T as K]: T[K] } & {};
976
1180
  /**
977
1181
  * Field array component props interface.
978
1182
  */
979
- interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1183
+ interface FieldArrayProps<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
980
1184
  /**
981
1185
  * The form store to which the field array belongs.
982
1186
  */
@@ -986,7 +1190,7 @@ interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath exten
986
1190
  */
987
1191
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
988
1192
  }
989
- declare const __VLS_export$1: <TSchema extends Schema, TFieldArrayPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$1<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1193
+ declare const __VLS_export$1: <TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$1<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
990
1194
  props: __VLS_PrettifyLocal$1<FieldArrayProps<TSchema, TFieldArrayPath>> & vue1.PublicProps;
991
1195
  expose: (exposed: {}) => void;
992
1196
  attrs: any;
@@ -1004,7 +1208,7 @@ type __VLS_PrettifyLocal$1<T> = { [K in keyof T as K]: T[K] } & {};
1004
1208
  /**
1005
1209
  * Form component props interface.
1006
1210
  */
1007
- interface FormProps<TSchema extends Schema = Schema> {
1211
+ interface FormProps<TSchema extends FormSchema = FormSchema> {
1008
1212
  /**
1009
1213
  * The form store instance.
1010
1214
  */
@@ -1014,7 +1218,7 @@ interface FormProps<TSchema extends Schema = Schema> {
1014
1218
  */
1015
1219
  onSubmit: SubmitEventHandler<TSchema>;
1016
1220
  }
1017
- declare const __VLS_export: <TSchema extends Schema = Schema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1221
+ declare const __VLS_export: <TSchema extends FormSchema = FormSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1018
1222
  props: __VLS_PrettifyLocal<FormProps<TSchema>> & vue1.PublicProps;
1019
1223
  expose: (exposed: {}) => void;
1020
1224
  attrs: any;
@@ -1032,7 +1236,7 @@ type __VLS_PrettifyLocal<T> = { [K in keyof T as K]: T[K] } & {};
1032
1236
  /**
1033
1237
  * Use field config interface.
1034
1238
  */
1035
- interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1239
+ interface UseFieldConfig<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
1036
1240
  /**
1037
1241
  * The path to the field within the form schema.
1038
1242
  */
@@ -1046,13 +1250,13 @@ interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends Req
1046
1250
  *
1047
1251
  * @returns The field store with reactive properties and element props.
1048
1252
  */
1049
- declare function useField<TSchema extends Schema, TFieldPath extends RequiredPath>(form: MaybeRefOrGetter<FormStore<TSchema>>, config: MaybeRefOrGetter<UseFieldConfig<TSchema, TFieldPath>>): FieldStore<TSchema, TFieldPath>;
1253
+ declare function useField<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: MaybeRefOrGetter<FormStore<TSchema>>, config: MaybeRefOrGetter<UseFieldConfig<TSchema, TFieldPath>>): FieldStore<TSchema, TFieldPath>;
1050
1254
  //#endregion
1051
1255
  //#region src/composables/useFieldArray/useFieldArray.d.ts
1052
1256
  /**
1053
1257
  * Use field array config interface.
1054
1258
  */
1055
- interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1259
+ interface UseFieldArrayConfig<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1056
1260
  /**
1057
1261
  * The path to the field array within the form schema.
1058
1262
  */
@@ -1066,7 +1270,7 @@ interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath e
1066
1270
  *
1067
1271
  * @returns The field array store with reactive properties for array management.
1068
1272
  */
1069
- declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: MaybeRefOrGetter<FormStore<TSchema>>, config: MaybeRefOrGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
1273
+ declare function useFieldArray<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: MaybeRefOrGetter<FormStore<TSchema>>, config: MaybeRefOrGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
1070
1274
  //#endregion
1071
1275
  //#region src/composables/useForm/useForm.d.ts
1072
1276
  /**
@@ -1077,6 +1281,6 @@ declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends R
1077
1281
  *
1078
1282
  * @returns The form store with reactive properties.
1079
1283
  */
1080
- declare function useForm<TSchema extends Schema>(config: FormConfig<TSchema>): FormStore<TSchema>;
1284
+ declare function useForm<TSchema extends FormSchema>(config: FormConfig<TSchema>): FormStore<TSchema>;
1081
1285
  //#endregion
1082
- export { type DeepPartial, _default as Field, _default$1 as FieldArray, FieldArrayStore, type FieldElement, FieldElementProps, FieldStore, FocusFieldConfig, _default$2 as Form, type FormConfig, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MoveConfig, type PartialValues, type PathValue, RemoveConfig, ReplaceConfig, type RequiredPath, ResetFieldConfig, ResetFormConfig, type Schema, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, type SubmitEventHandler, type SubmitHandler, SwapConfig, UseFieldArrayConfig, UseFieldConfig, type ValidArrayPath, type ValidPath, ValidateFormConfig, type ValidationMode, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
1286
+ export { type DeepPartial, _default as Field, _default$1 as FieldArray, FieldArrayStore, type FieldElement, FieldElementProps, FieldStore, FocusFieldConfig, _default$2 as Form, type FormConfig, type FormSchema, FormStore, GetFieldDirtyInputConfig, GetFieldDirtyPathsConfig, GetFieldErrorsConfig, GetFieldInputConfig, GetFormDirtyInputConfig, GetFormDirtyPathsConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MoveConfig, type PartialValues, type PathValue, PickDirtyConfig, RemoveConfig, ReplaceConfig, type RequiredPath, ResetFieldConfig, ResetFormConfig, type Schema, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, type SubmitEventHandler, type SubmitHandler, SwapConfig, UseFieldArrayConfig, UseFieldConfig, type ValidArrayPath, type ValidPath, ValidateFormConfig, type ValidationMode, focus, getAllErrors, getDirtyInput, getDirtyPaths, getErrors, getInput, handleSubmit, insert, move, pickDirty, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
package/dist/index.js CHANGED
@@ -96,7 +96,7 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
96
96
  if (internalFieldStore.kind === "object") {
97
97
  internalFieldStore.children ??= {};
98
98
  for (const key in schema.entries) {
99
- internalFieldStore.children[key] = {};
99
+ internalFieldStore.children[key] ??= {};
100
100
  path.push(key);
101
101
  initializeFieldStore(internalFieldStore.children[key], schema.entries[key], initialInput?.[key], path);
102
102
  path.pop();
@@ -107,6 +107,7 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
107
107
  internalFieldStore.input = createSignal(objectInput);
108
108
  }
109
109
  } else {
110
+ if (internalFieldStore.kind && internalFieldStore.kind !== "value") throw new Error(`Store initialized as "${internalFieldStore.kind}" cannot be reinitialized as "value"`);
110
111
  internalFieldStore.kind = "value";
111
112
  if (internalFieldStore.kind === "value") {
112
113
  internalFieldStore.initialInput = createSignal(initialInput);
@@ -252,20 +253,45 @@ function swapItemState(firstInternalFieldStore, secondInternalFieldStore) {
252
253
  });
253
254
  }
254
255
  /**
255
- * Returns the current input of the field store. For arrays and objects,
256
- * recursively collects input from all children. Returns `null` or `undefined`
257
- * for nullish array/object inputs, or the primitive value for value fields.
256
+ * Returns whether the specified boolean property is true for the field store
257
+ * or any of its nested children. Recursively checks arrays and objects.
258
258
  *
259
- * @param internalFieldStore The field store to get input from.
259
+ * @param internalFieldStore The field store to check.
260
+ * @param type The boolean property type to check.
260
261
  *
261
- * @returns The field input.
262
+ * @returns Whether the property is true.
262
263
  */
263
264
  /* @__NO_SIDE_EFFECTS__ */
264
- function getFieldInput(internalFieldStore) {
265
+ function getFieldBool(internalFieldStore, type) {
266
+ if (internalFieldStore[type].value) return true;
267
+ if (internalFieldStore.kind === "array") {
268
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[index], type)) return true;
269
+ return false;
270
+ }
271
+ if (internalFieldStore.kind == "object") {
272
+ for (const key in internalFieldStore.children) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[key], type)) return true;
273
+ return false;
274
+ }
275
+ return false;
276
+ }
277
+ /**
278
+ * Returns only the dirty input of the field store. Arrays are treated as
279
+ * atomic and returned in full if any item is dirty, while object keys without
280
+ * a dirty descendant are omitted. Returns `undefined` if no descendant is
281
+ * dirty.
282
+ *
283
+ * @param internalFieldStore The field store to get dirty input from.
284
+ * @param dirtyOnly Whether to only include dirty fields. Defaults to `true`.
285
+ *
286
+ * @returns The dirty input, or `undefined` if no descendant is dirty.
287
+ */
288
+ /* @__NO_SIDE_EFFECTS__ */
289
+ function getDirtyFieldInput(internalFieldStore, dirtyOnly = true) {
290
+ if (dirtyOnly && !/* @__PURE__ */ getFieldBool(internalFieldStore, "isDirty")) return;
265
291
  if (internalFieldStore.kind === "array") {
266
292
  if (internalFieldStore.input.value) {
267
293
  const value = [];
268
- for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[index]);
294
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = /* @__PURE__ */ getDirtyFieldInput(internalFieldStore.children[index], false);
269
295
  return value;
270
296
  }
271
297
  return internalFieldStore.input.value;
@@ -273,7 +299,10 @@ function getFieldInput(internalFieldStore) {
273
299
  if (internalFieldStore.kind === "object") {
274
300
  if (internalFieldStore.input.value) {
275
301
  const value = {};
276
- for (const key in internalFieldStore.children) value[key] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[key]);
302
+ for (const key in internalFieldStore.children) {
303
+ const child = internalFieldStore.children[key];
304
+ if (!dirtyOnly || /* @__PURE__ */ getFieldBool(child, "isDirty")) value[key] = /* @__PURE__ */ getDirtyFieldInput(child, dirtyOnly);
305
+ }
277
306
  return value;
278
307
  }
279
308
  return internalFieldStore.input.value;
@@ -281,26 +310,33 @@ function getFieldInput(internalFieldStore) {
281
310
  return internalFieldStore.input.value;
282
311
  }
283
312
  /**
284
- * Returns whether the specified boolean property is true for the field store
285
- * or any of its nested children. Recursively checks arrays and objects.
313
+ * Returns the current input of the field store. For arrays and objects,
314
+ * recursively collects input from all children. Returns `null` or `undefined`
315
+ * for nullish array/object inputs, or the primitive value for value fields.
286
316
  *
287
- * @param internalFieldStore The field store to check.
288
- * @param type The boolean property type to check.
317
+ * @param internalFieldStore The field store to get input from.
289
318
  *
290
- * @returns Whether the property is true.
319
+ * @returns The field input.
291
320
  */
292
321
  /* @__NO_SIDE_EFFECTS__ */
293
- function getFieldBool(internalFieldStore, type) {
294
- if (internalFieldStore[type].value) return true;
322
+ function getFieldInput(internalFieldStore) {
295
323
  if (internalFieldStore.kind === "array") {
296
- for (let index = 0; index < internalFieldStore.items.value.length; index++) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[index], type)) return true;
297
- return false;
324
+ if (internalFieldStore.input.value) {
325
+ const value = [];
326
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[index]);
327
+ return value;
328
+ }
329
+ return internalFieldStore.input.value;
298
330
  }
299
- if (internalFieldStore.kind == "object") {
300
- for (const key in internalFieldStore.children) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[key], type)) return true;
301
- return false;
331
+ if (internalFieldStore.kind === "object") {
332
+ if (internalFieldStore.input.value) {
333
+ const value = {};
334
+ for (const key in internalFieldStore.children) value[key] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[key]);
335
+ return value;
336
+ }
337
+ return internalFieldStore.input.value;
302
338
  }
303
- return false;
339
+ return internalFieldStore.input.value;
304
340
  }
305
341
  /**
306
342
  * Returns the field store at the specified path by traversing the form store's
@@ -559,6 +595,17 @@ function getAllErrors(form) {
559
595
  return allErrors;
560
596
  }
561
597
  /* @__NO_SIDE_EFFECTS__ */
598
+ function getDirtyInput(form, config) {
599
+ return getDirtyFieldInput(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL]);
600
+ }
601
+ /* @__NO_SIDE_EFFECTS__ */
602
+ function getDirtyPaths(form, config) {
603
+ config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL];
604
+ const paths = [];
605
+ config?.path && [...config.path];
606
+ return paths;
607
+ }
608
+ /* @__NO_SIDE_EFFECTS__ */
562
609
  function getErrors(form, config) {
563
610
  return (config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL]).errors.value;
564
611
  }
@@ -652,6 +699,48 @@ function move(form, config) {
652
699
  });
653
700
  }
654
701
  /**
702
+ * Picks only the dirty parts of the given value, using the form's dirty fields
703
+ * as a structural mask. Arrays are treated as atomic and object keys without a
704
+ * dirty descendant are omitted. Returns `undefined` if no field is dirty.
705
+ * Useful for filtering a validated output down to its changed parts before
706
+ * submitting.
707
+ *
708
+ * @param form The form store providing the dirty mask.
709
+ * @param config The pick dirty configuration.
710
+ *
711
+ * @returns The dirty parts of the value, or `undefined`.
712
+ */
713
+ /* @__NO_SIDE_EFFECTS__ */
714
+ function pickDirty(form, config) {
715
+ if (!getFieldBool(form[INTERNAL], "isDirty")) return;
716
+ const result = /* @__PURE__ */ pickFieldValue(form[INTERNAL], config.from);
717
+ return Object.keys(result).length ? result : void 0;
718
+ }
719
+ /**
720
+ * Recursively picks the dirty parts of a value using the field store as a
721
+ * structural mask, reading from the supplied value rather than the form's own
722
+ * input. Objects with non-nullish input recurse into their dirty children that
723
+ * are present in the value, while arrays, primitives, nullish-cleared fields
724
+ * and shape-diverging values are returned as-is.
725
+ *
726
+ * @param internalFieldStore The field store used as the dirty mask.
727
+ * @param value The value to pick the dirty parts from.
728
+ *
729
+ * @returns The dirty parts of the value.
730
+ */
731
+ /* @__NO_SIDE_EFFECTS__ */
732
+ function pickFieldValue(internalFieldStore, value) {
733
+ if (internalFieldStore.kind === "object" && internalFieldStore.input.value && value && typeof value === "object" && !Array.isArray(value)) {
734
+ const result = {};
735
+ for (const key in internalFieldStore.children) {
736
+ const child = internalFieldStore.children[key];
737
+ if (getFieldBool(child, "isDirty") && key in value) result[key] = /* @__PURE__ */ pickFieldValue(child, value[key]);
738
+ }
739
+ return result;
740
+ }
741
+ return value;
742
+ }
743
+ /**
655
744
  * Removes an item from a field array at the specified index. All items after
656
745
  * the removed item are shifted down by one index.
657
746
  *
@@ -697,7 +786,7 @@ function reset(form, config) {
697
786
  untrack(() => {
698
787
  const internalFormStore = form[INTERNAL];
699
788
  const internalFieldStore = config?.path ? getFieldStore(internalFormStore, config.path) : internalFormStore;
700
- if (config?.initialInput) setInitialFieldInput(internalFieldStore, config.initialInput);
789
+ if (config && "initialInput" in config) setInitialFieldInput(internalFieldStore, config.initialInput);
701
790
  walkFieldStore(internalFieldStore, (internalFieldStore$1) => {
702
791
  internalFieldStore$1.elements = internalFieldStore$1.initialElements;
703
792
  if (!config?.keepErrors) internalFieldStore$1.errors.value = null;
@@ -976,4 +1065,4 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
976
1065
  var Form_default = Form_vue_vue_type_script_setup_true_lang_default;
977
1066
 
978
1067
  //#endregion
979
- export { Field_default as Field, FieldArray_default as FieldArray, Form_default as Form, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
1068
+ export { Field_default as Field, FieldArray_default as FieldArray, Form_default as Form, focus, getAllErrors, getDirtyInput, getDirtyPaths, getErrors, getInput, handleSubmit, insert, move, pickDirty, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formisch/vue",
3
- "description": "The modular and type-safe form library for Vue",
4
- "version": "0.7.5",
3
+ "description": "The lightweight, schema-first, and fully type-safe form library for Vue",
4
+ "version": "0.8.0",
5
5
  "license": "MIT",
6
6
  "author": "Fabian Hiller",
7
7
  "homepage": "https://formisch.dev",
@@ -34,6 +34,7 @@
34
34
  },
35
35
  "scripts": {
36
36
  "build": "tsdown",
37
+ "test": "vitest run --typecheck",
37
38
  "lint": "eslint \"src/**/*.ts*\" && tsc --noEmit",
38
39
  "lint.fix": "eslint \"src/**/*.ts*\" --fix",
39
40
  "format": "prettier --write ./src",
@@ -44,20 +45,25 @@
44
45
  "@formisch/core": "workspace:*",
45
46
  "@formisch/eslint-config": "workspace:*",
46
47
  "@formisch/methods": "workspace:*",
48
+ "@testing-library/jest-dom": "^6.6.0",
47
49
  "@types/node": "^24.1.0",
50
+ "@vitest/coverage-v8": "^3.2.4",
48
51
  "@vue/eslint-config-typescript": "^14.6.0",
52
+ "@vue/test-utils": "^2.4.6",
49
53
  "eslint": "^9.32.0",
50
54
  "eslint-plugin-vue": "~10.3.0",
55
+ "jsdom": "^26.1.0",
51
56
  "tsdown": "^0.16.8",
52
57
  "typescript": "~5.8.3",
53
58
  "unplugin-vue": "^7.0.0",
54
- "valibot": "^1.2.0",
59
+ "valibot": "^1.4.1",
60
+ "vitest": "^3.2.4",
55
61
  "vue": "^3.5.18",
56
62
  "vue-tsc": "^3.0.4"
57
63
  },
58
64
  "peerDependencies": {
59
65
  "typescript": ">=5",
60
- "valibot": "^1.0.0",
66
+ "valibot": "^1.4.1",
61
67
  "vue": "^3.3.0"
62
68
  },
63
69
  "peerDependenciesMeta": {