@formisch/solid 0.9.6 → 0.11.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/index.d.ts CHANGED
@@ -8,6 +8,31 @@ import { JSX } from "solid-js";
8
8
  * Schema type.
9
9
  */
10
10
  type Schema = v.GenericSchema | v.GenericSchemaAsync;
11
+ /**
12
+ * Object schema type.
13
+ */
14
+ 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>;
15
+ /**
16
+ * Object schema async type.
17
+ */
18
+ 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>;
19
+ /**
20
+ * Object root schema type.
21
+ */
22
+ type ObjectRootSchema = ObjectSchema | v.IntersectSchema<ObjectSchema[], v.ErrorMessage<v.IntersectIssue> | undefined> | v.UnionSchema<ObjectSchema[], v.ErrorMessage<v.UnionIssue<v.BaseIssue<unknown>>> | undefined>;
23
+ /**
24
+ * Object root schema async type.
25
+ */
26
+ type ObjectRootSchemaAsync = ObjectSchemaAsync | v.IntersectSchemaAsync<(ObjectSchema | ObjectSchemaAsync)[], v.ErrorMessage<v.IntersectIssue> | undefined> | v.UnionSchemaAsync<(ObjectSchema | ObjectSchemaAsync)[], v.ErrorMessage<v.UnionIssue<v.BaseIssue<unknown>>> | undefined>;
27
+ /**
28
+ * Form schema type.
29
+ *
30
+ * Hint: Forms must have an object root, so only object schemas (sync or async),
31
+ * combinators (intersect, union, variant) whose options resolve to objects, and
32
+ * `lazy` schemas wrapping any of these are allowed at the top level. Use
33
+ * {@link Schema} for nested field schemas.
34
+ */
35
+ type FormSchema = ObjectRootSchema | ObjectRootSchemaAsync | v.LazySchema<ObjectRootSchema> | v.LazySchemaAsync<ObjectRootSchema | ObjectRootSchemaAsync>;
11
36
  //#endregion
12
37
  //#region src/types/signal/signal.d.ts
13
38
  /**
@@ -47,6 +72,13 @@ interface InternalBaseStore {
47
72
  schema: Schema;
48
73
  /**
49
74
  * The initial elements of the field.
75
+ *
76
+ * Hint: This may look unused, but do not remove it. `copyItemState` and
77
+ * `swapItemState` move the `elements` reference between field stores when
78
+ * array items are inserted, moved, removed or swapped, and `reset` restores
79
+ * each field's original element via `elements = initialElements`. Without it,
80
+ * focus and file reset target the wrong element after a reorder followed by a
81
+ * reset.
50
82
  */
51
83
  initialElements: FieldElement[];
52
84
  /**
@@ -224,7 +256,7 @@ type ValidationMode = "initial" | "touch" | "input" | "change" | "blur" | "submi
224
256
  /**
225
257
  * Form config interface.
226
258
  */
227
- interface FormConfig<TSchema extends Schema = Schema> {
259
+ interface FormConfig<TSchema extends FormSchema = FormSchema> {
228
260
  /**
229
261
  * The schema of the form.
230
262
  */
@@ -245,7 +277,7 @@ interface FormConfig<TSchema extends Schema = Schema> {
245
277
  /**
246
278
  * Internal form store interface.
247
279
  */
248
- interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObjectStore {
280
+ interface InternalFormStore<TSchema extends FormSchema = FormSchema> extends InternalObjectStore {
249
281
  /**
250
282
  * The element of the form.
251
283
  */
@@ -282,7 +314,7 @@ interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObj
282
314
  /**
283
315
  * Base form store interface.
284
316
  */
285
- interface BaseFormStore<TSchema extends Schema = Schema> {
317
+ interface BaseFormStore<TSchema extends FormSchema = FormSchema> {
286
318
  /**
287
319
  * The internal form store.
288
320
  *
@@ -293,11 +325,11 @@ interface BaseFormStore<TSchema extends Schema = Schema> {
293
325
  /**
294
326
  * Submit handler type.
295
327
  */
296
- type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>) => MaybePromise<unknown>;
328
+ type SubmitHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>) => MaybePromise<unknown>;
297
329
  /**
298
330
  * Submit event handler type.
299
331
  */
300
- type SubmitEventHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
332
+ type SubmitEventHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
301
333
  //#endregion
302
334
  //#region src/types/path/path.d.ts
303
335
  /**
@@ -368,7 +400,10 @@ type ExactRequired<TValue> = TValue extends Record<PropertyKey, unknown> ? IsExa
368
400
  */
369
401
  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;
370
402
  /**
371
- * Checks whether a value is an array or contains one anywhere in its shape.
403
+ * Checks whether a value is a dynamic array or contains one anywhere in its
404
+ * shape. A fixed-length tuple is not itself a dynamic array, but it counts when
405
+ * it contains one, so paths can still navigate through tuples to reach nested
406
+ * arrays.
372
407
  *
373
408
  * Hint: The inner conditionals (`TValue extends readonly unknown[]` and
374
409
  * `TValue extends Record<PropertyKey, unknown>`) distribute over union members,
@@ -379,7 +414,7 @@ type PathValue<TValue, TPath extends Path> = TPath extends readonly [infer TKey,
379
414
  * `true extends ...`, which is `true` whenever at least one union member
380
415
  * contributed `true`.
381
416
  */
382
- 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;
417
+ type IsOrHasArray<TValue> = true extends (IsAny<TValue> extends true ? false : TValue extends readonly unknown[] ? number extends TValue["length"] ? true : IsOrHasArray<TValue[number]> : TValue extends Record<PropertyKey, unknown> ? { [TKey in keyof TValue]: IsOrHasArray<TValue[TKey]> }[keyof TValue] : false) ? true : false;
383
418
  /**
384
419
  * Extracts the exact keys of a tuple, array or object that contain arrays.
385
420
  */
@@ -394,12 +429,34 @@ type PropertiesOfArrayPath<TValue> = { [TKey in ExactKeysOfArrayPath<TValue>]: T
394
429
  /**
395
430
  * Lazily evaluates only the first valid array path segment based on the given value.
396
431
  */
397
- 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;
432
+ type LazyArrayPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValue extends readonly unknown[] ? number extends TValue["length"] ? TValidPath : IsNever<ExactKeysOfArrayPath<TValue>> extends false ? readonly [...TValidPath, ExactKeysOfArrayPath<TValue>] : never : 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;
398
433
  /**
399
434
  * Returns the path if valid, otherwise the first possible valid array path
400
435
  * based on the given value.
401
436
  */
402
437
  type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<Required<TValue>, TPath> ? TPath : LazyArrayPath<Required<TValue>, TPath>;
438
+ /**
439
+ * Recursive helper for `DirtyPath` that prepends `TKey` to each deeper path,
440
+ * or falls through to `never` when the child is not an object.
441
+ */
442
+ type DeepDirtyPath<TChild, TKey$1 extends PathKey, TDepth extends 0[]> = TChild extends Record<PropertyKey, unknown> ? readonly [TKey$1, ...DirtyPath<TChild, [...TDepth, 0]>] : never;
443
+ /**
444
+ * Returns the union of all `RequiredPath`s that `getDirtyPaths` can emit
445
+ * for a given input type. Object fields contribute their own path and the
446
+ * paths of their descendants; arrays and tuples are atomic and contribute
447
+ * only their own path, because dirty arrays are returned as complete units.
448
+ *
449
+ * Narrowing is exact for the first 5 levels of nesting; deeper paths fall
450
+ * back to `RequiredPath` to keep the result a complete superset of any
451
+ * path the runtime can address.
452
+ *
453
+ * Hint: Arrays and tuples are atomic because they don't structurally
454
+ * extend `Record<PropertyKey, unknown>` and so fall through to `never`
455
+ * via `DeepDirtyPath` — no explicit array check is needed. `TDepth` is
456
+ * a tuple-length counter capped at 5 to bound TypeScript instantiation
457
+ * cost.
458
+ */
459
+ 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;
403
460
  //#endregion
404
461
  //#region src/array/copyItemState/copyItemState.d.ts
405
462
  /**
@@ -418,21 +475,21 @@ type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArra
418
475
  /**
419
476
  * Focus field config interface.
420
477
  */
421
- interface FocusFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
478
+ interface FocusFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
422
479
  /**
423
480
  * The path to the field to focus.
424
481
  */
425
482
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
426
483
  }
427
484
  /**
428
- * Focuses the first input element of a field. This is useful for
485
+ * Focuses the first focusable input element of a field. This is useful for
429
486
  * programmatically setting focus to a specific field, such as after
430
487
  * validation errors or user interactions.
431
488
  *
432
489
  * @param form The form store containing the field.
433
490
  * @param config The focus field configuration.
434
491
  */
435
- declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
492
+ declare function focus<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
436
493
  //#endregion
437
494
  //#region src/getAllErrors/getAllErrors.d.ts
438
495
  /**
@@ -446,6 +503,93 @@ declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(
446
503
  */
447
504
  declare function getAllErrors(form: BaseFormStore): [string, ...string[]] | null;
448
505
  //#endregion
506
+ //#region src/getDirtyInput/getDirtyInput.d.ts
507
+ /**
508
+ * Get form dirty input config interface.
509
+ */
510
+ interface GetFormDirtyInputConfig {
511
+ /**
512
+ * The path to a field. Leave undefined to get the dirty input of the entire
513
+ * form.
514
+ */
515
+ readonly path?: undefined;
516
+ }
517
+ /**
518
+ * Get field dirty input config interface.
519
+ */
520
+ interface GetFieldDirtyInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
521
+ /**
522
+ * The path to the field to retrieve the dirty input from.
523
+ */
524
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
525
+ }
526
+ /**
527
+ * Retrieves only the dirty input values of a specific field or the entire
528
+ * form. Arrays are treated as atomic and returned in full if any item is
529
+ * dirty, while object keys without a dirty descendant are omitted. Returns
530
+ * `undefined` if no field in the inspected subtree is dirty.
531
+ *
532
+ * @param form The form store to retrieve dirty input from.
533
+ *
534
+ * @returns The dirty input of the form or specified field, or `undefined`.
535
+ */
536
+ declare function getDirtyInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): DeepPartial<v.InferInput<TSchema>> | undefined;
537
+ /**
538
+ * Retrieves only the dirty input values of a specific field or the entire
539
+ * form. Arrays are treated as atomic and returned in full if any item is
540
+ * dirty, while object keys without a dirty descendant are omitted. Returns
541
+ * `undefined` if no field in the inspected subtree is dirty.
542
+ *
543
+ * @param form The form store to retrieve dirty input from.
544
+ * @param config The get dirty input configuration.
545
+ *
546
+ * @returns The dirty input of the form or specified field, or `undefined`.
547
+ */
548
+ 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;
549
+ //#endregion
550
+ //#region src/getDirtyPaths/getDirtyPaths.d.ts
551
+ /**
552
+ * Get form dirty paths config interface.
553
+ */
554
+ interface GetFormDirtyPathsConfig {
555
+ /**
556
+ * The path to a field. Leave undefined to inspect the entire form.
557
+ */
558
+ readonly path?: undefined;
559
+ }
560
+ /**
561
+ * Get field dirty paths config interface.
562
+ */
563
+ interface GetFieldDirtyPathsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
564
+ /**
565
+ * The path to the field to inspect.
566
+ */
567
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
568
+ }
569
+ /**
570
+ * Returns a list of paths to the dirty fields of a specific field or the
571
+ * entire form. Arrays are treated as atomic and contribute only their own
572
+ * path if any item is dirty, while object branches are recursed into. Returns
573
+ * an empty list if no field in the inspected subtree is dirty.
574
+ *
575
+ * @param form The form store to inspect.
576
+ *
577
+ * @returns The list of paths to the dirty fields.
578
+ */
579
+ declare function getDirtyPaths<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): DirtyPath<v.InferInput<TSchema>>[];
580
+ /**
581
+ * Returns a list of paths to the dirty fields of a specific field or the
582
+ * entire form. Arrays are treated as atomic and contribute only their own
583
+ * path if any item is dirty, while object branches are recursed into. Returns
584
+ * an empty list if no field in the inspected subtree is dirty.
585
+ *
586
+ * @param form The form store to inspect.
587
+ * @param config The get dirty paths configuration.
588
+ *
589
+ * @returns The list of paths to the dirty fields.
590
+ */
591
+ 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>>[];
592
+ //#endregion
449
593
  //#region src/getErrors/getErrors.d.ts
450
594
  /**
451
595
  * Get form errors config interface.
@@ -459,7 +603,7 @@ interface GetFormErrorsConfig {
459
603
  /**
460
604
  * Get field errors config interface.
461
605
  */
462
- interface GetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
606
+ interface GetFieldErrorsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
463
607
  /**
464
608
  * The path to the field to retrieve errors from.
465
609
  */
@@ -474,7 +618,7 @@ interface GetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends Requir
474
618
  *
475
619
  * @returns A non-empty array of error messages, or null if no errors exist.
476
620
  */
477
- declare function getErrors<TSchema extends Schema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
621
+ declare function getErrors<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
478
622
  /**
479
623
  * Retrieves error messages from the form. When called without a config,
480
624
  * returns form-level errors. When called with a path, returns errors for
@@ -485,7 +629,7 @@ declare function getErrors<TSchema extends Schema>(form: BaseFormStore<TSchema>)
485
629
  *
486
630
  * @returns A non-empty array of error messages, or null if no errors exist.
487
631
  */
488
- 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;
632
+ 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;
489
633
  //#endregion
490
634
  //#region src/getInput/getInput.d.ts
491
635
  /**
@@ -500,7 +644,7 @@ interface GetFormInputConfig {
500
644
  /**
501
645
  * Get field input config interface.
502
646
  */
503
- interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
647
+ interface GetFieldInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
504
648
  /**
505
649
  * The path to the field to retrieve input from.
506
650
  */
@@ -514,7 +658,7 @@ interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends Require
514
658
  *
515
659
  * @returns The partial input values of the form or the specified field.
516
660
  */
517
- declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
661
+ declare function getInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
518
662
  /**
519
663
  * Retrieves the current input value of a specific field or the entire form.
520
664
  * Returns a partial object as not all fields may have been set.
@@ -524,7 +668,7 @@ declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>):
524
668
  *
525
669
  * @returns The partial input values of the form or the specified field.
526
670
  */
527
- 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>>;
671
+ 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>>;
528
672
  //#endregion
529
673
  //#region src/handleSubmit/handleSubmit.d.ts
530
674
  /**
@@ -537,7 +681,7 @@ declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPat
537
681
  *
538
682
  * @returns A submit event handler function to attach to the form element.
539
683
  */
540
- declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): () => Promise<void>;
684
+ declare function handleSubmit<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): () => Promise<void>;
541
685
  /**
542
686
  * Creates a submit event handler for the form that prevents default browser
543
687
  * submission, validates the form input, and calls the provided handler if
@@ -548,13 +692,13 @@ declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchem
548
692
  *
549
693
  * @returns A submit event handler function to attach to the form element.
550
694
  */
551
- declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitEventHandler<TSchema>): (event: SubmitEvent) => Promise<void>;
695
+ declare function handleSubmit<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, handler: SubmitEventHandler<TSchema>): (event: SubmitEvent) => Promise<void>;
552
696
  //#endregion
553
697
  //#region src/insert/insert.d.ts
554
698
  /**
555
699
  * Insert array field config interface.
556
700
  */
557
- interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
701
+ interface InsertConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
558
702
  /**
559
703
  * The path to the field array to insert into.
560
704
  */
@@ -575,13 +719,13 @@ interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredP
575
719
  * @param form The form store containing the field array.
576
720
  * @param config The insert configuration specifying the path, index, and initial value.
577
721
  */
578
- declare function insert<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
722
+ declare function insert<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
579
723
  //#endregion
580
724
  //#region src/move/move.d.ts
581
725
  /**
582
726
  * Move array field config interface.
583
727
  */
584
- interface MoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
728
+ interface MoveConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
585
729
  /**
586
730
  * The path to the field array to move an item within.
587
731
  */
@@ -602,13 +746,38 @@ interface MoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPat
602
746
  * @param form The form store containing the field array.
603
747
  * @param config The move configuration specifying the path and source/destination indices.
604
748
  */
605
- declare function move<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: MoveConfig<TSchema, TFieldArrayPath>): void;
749
+ declare function move<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: MoveConfig<TSchema, TFieldArrayPath>): void;
750
+ //#endregion
751
+ //#region src/pickDirty/pickDirty.d.ts
752
+ /**
753
+ * Pick dirty config interface.
754
+ */
755
+ interface PickDirtyConfig<TValue extends object> {
756
+ /**
757
+ * The value to filter down to its dirty parts. Must be structurally
758
+ * compatible with the form's schema.
759
+ */
760
+ readonly from: TValue;
761
+ }
762
+ /**
763
+ * Picks only the dirty parts of the given value, using the form's dirty fields
764
+ * as a structural mask. Arrays are treated as atomic and object keys without a
765
+ * dirty descendant are omitted. Returns `undefined` if no field is dirty.
766
+ * Useful for filtering a validated output down to its changed parts before
767
+ * submitting.
768
+ *
769
+ * @param form The form store providing the dirty mask.
770
+ * @param config The pick dirty configuration.
771
+ *
772
+ * @returns The dirty parts of the value, or `undefined`.
773
+ */
774
+ declare function pickDirty<TSchema extends FormSchema, TValue extends object>(form: BaseFormStore<TSchema>, config: PickDirtyConfig<TValue>): DeepPartial<TValue> | undefined;
606
775
  //#endregion
607
776
  //#region src/remove/remove.d.ts
608
777
  /**
609
778
  * Remove array field config interface.
610
779
  */
611
- interface RemoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
780
+ interface RemoveConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
612
781
  /**
613
782
  * The path to the field array to remove an item from.
614
783
  */
@@ -625,13 +794,13 @@ interface RemoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredP
625
794
  * @param form The form store containing the field array.
626
795
  * @param config The remove configuration specifying the path and index.
627
796
  */
628
- declare function remove<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: RemoveConfig<TSchema, TFieldArrayPath>): void;
797
+ declare function remove<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: RemoveConfig<TSchema, TFieldArrayPath>): void;
629
798
  //#endregion
630
799
  //#region src/replace/replace.d.ts
631
800
  /**
632
801
  * Replace array field config interface.
633
802
  */
634
- interface ReplaceConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
803
+ interface ReplaceConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
635
804
  /**
636
805
  * The path to the field array to replace an item within.
637
806
  */
@@ -651,7 +820,7 @@ interface ReplaceConfig<TSchema extends Schema, TFieldArrayPath extends Required
651
820
  * @param form The form store containing the field array.
652
821
  * @param config The replace configuration specifying the path, index, and initial input.
653
822
  */
654
- declare function replace<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: ReplaceConfig<TSchema, TFieldArrayPath>): void;
823
+ declare function replace<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: ReplaceConfig<TSchema, TFieldArrayPath>): void;
655
824
  //#endregion
656
825
  //#region src/reset/reset.d.ts
657
826
  /**
@@ -674,7 +843,7 @@ interface ResetBaseConfig {
674
843
  /**
675
844
  * Reset form config interface.
676
845
  */
677
- interface ResetFormConfig<TSchema extends Schema> extends ResetBaseConfig {
846
+ interface ResetFormConfig<TSchema extends FormSchema> extends ResetBaseConfig {
678
847
  /**
679
848
  * The path to a field. Leave undefined to reset the entire form.
680
849
  */
@@ -692,7 +861,7 @@ interface ResetFormConfig<TSchema extends Schema> extends ResetBaseConfig {
692
861
  /**
693
862
  * Reset field config interface.
694
863
  */
695
- interface ResetFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> extends ResetBaseConfig {
864
+ interface ResetFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> extends ResetBaseConfig {
696
865
  /**
697
866
  * The path to the field to reset.
698
867
  */
@@ -719,7 +888,7 @@ declare function reset(form: BaseFormStore): void;
719
888
  * @param form The form store to reset.
720
889
  * @param config The reset configuration specifying what to reset and what to keep.
721
890
  */
722
- declare function reset<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? ResetFieldConfig<TSchema, TFieldPath> : ResetFormConfig<TSchema>): void;
891
+ declare function reset<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? ResetFieldConfig<TSchema, TFieldPath> : ResetFormConfig<TSchema>): void;
723
892
  //#endregion
724
893
  //#region src/setErrors/setErrors.d.ts
725
894
  /**
@@ -738,7 +907,7 @@ interface SetFormErrorsConfig {
738
907
  /**
739
908
  * Set field errors config interface.
740
909
  */
741
- interface SetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
910
+ interface SetFieldErrorsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
742
911
  /**
743
912
  * The path to the field to set errors on.
744
913
  */
@@ -756,13 +925,13 @@ interface SetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends Requir
756
925
  * @param form The form store to set errors on.
757
926
  * @param config The set errors configuration specifying the path and error messages.
758
927
  */
759
- declare function setErrors<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldErrorsConfig<TSchema, TFieldPath> : SetFormErrorsConfig): void;
928
+ declare function setErrors<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldErrorsConfig<TSchema, TFieldPath> : SetFormErrorsConfig): void;
760
929
  //#endregion
761
930
  //#region src/setInput/setInput.d.ts
762
931
  /**
763
932
  * Set form input config interface.
764
933
  */
765
- interface SetFormInputConfig<TSchema extends Schema> {
934
+ interface SetFormInputConfig<TSchema extends FormSchema> {
766
935
  /**
767
936
  * The path to a field. Leave undefined to set the entire form input.
768
937
  */
@@ -775,7 +944,7 @@ interface SetFormInputConfig<TSchema extends Schema> {
775
944
  /**
776
945
  * Set field input config interface.
777
946
  */
778
- interface SetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
947
+ interface SetFieldInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
779
948
  /**
780
949
  * The path to the field to set input on.
781
950
  */
@@ -793,7 +962,7 @@ interface SetFieldInputConfig<TSchema extends Schema, TFieldPath extends Require
793
962
  * @param form The form store to set input on.
794
963
  * @param config The set form input configuration specifying the new input values.
795
964
  */
796
- declare function setInput<TSchema extends Schema>(form: BaseFormStore<TSchema>, config: SetFormInputConfig<TSchema>): void;
965
+ declare function setInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, config: SetFormInputConfig<TSchema>): void;
797
966
  /**
798
967
  * Sets the input value of a specific field or the entire form. This updates
799
968
  * the field value(s) and triggers validation if required by the form's
@@ -802,7 +971,7 @@ declare function setInput<TSchema extends Schema>(form: BaseFormStore<TSchema>,
802
971
  * @param form The form store to set input on.
803
972
  * @param config The set input configuration specifying the path and new value.
804
973
  */
805
- declare function setInput<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldInputConfig<TSchema, TFieldPath> : SetFormInputConfig<TSchema>): void;
974
+ declare function setInput<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldInputConfig<TSchema, TFieldPath> : SetFormInputConfig<TSchema>): void;
806
975
  //#endregion
807
976
  //#region src/submit/submit.d.ts
808
977
  /**
@@ -817,7 +986,7 @@ declare function submit(form: BaseFormStore): void;
817
986
  /**
818
987
  * Swap array field config interface.
819
988
  */
820
- interface SwapConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
989
+ interface SwapConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
821
990
  /**
822
991
  * The path to the field array to swap items within.
823
992
  */
@@ -837,7 +1006,7 @@ interface SwapConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPat
837
1006
  * @param form The form store containing the field array.
838
1007
  * @param config The swap configuration specifying the path and indices to swap.
839
1008
  */
840
- declare function swap<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: SwapConfig<TSchema, TFieldArrayPath>): void;
1009
+ declare function swap<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: SwapConfig<TSchema, TFieldArrayPath>): void;
841
1010
  //#endregion
842
1011
  //#region src/validate/validate.d.ts
843
1012
  /**
@@ -859,7 +1028,7 @@ interface ValidateFormConfig {
859
1028
  *
860
1029
  * @returns A promise resolving to the validation result.
861
1030
  */
862
- declare function validate<TSchema extends Schema>(form: BaseFormStore<TSchema>, config?: ValidateFormConfig): Promise<v.SafeParseResult<TSchema>>;
1031
+ declare function validate<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, config?: ValidateFormConfig): Promise<v.SafeParseResult<TSchema>>;
863
1032
  //#endregion
864
1033
  //#endregion
865
1034
  //#region src/types/field.d.ts
@@ -899,7 +1068,7 @@ interface FieldElementProps {
899
1068
  /**
900
1069
  * Field store interface.
901
1070
  */
902
- interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1071
+ interface FieldStore<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
903
1072
  /**
904
1073
  * The path to the field within the form.
905
1074
  */
@@ -936,7 +1105,7 @@ interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends Require
936
1105
  /**
937
1106
  * Field array store interface.
938
1107
  */
939
- interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1108
+ interface FieldArrayStore<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
940
1109
  /**
941
1110
  * The path to the array field within the form.
942
1111
  */
@@ -967,7 +1136,7 @@ interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath exten
967
1136
  /**
968
1137
  * Form store interface.
969
1138
  */
970
- interface FormStore<TSchema extends Schema = Schema> extends BaseFormStore<TSchema> {
1139
+ interface FormStore<TSchema extends FormSchema = FormSchema> extends BaseFormStore<TSchema> {
971
1140
  /**
972
1141
  * Whether the form is currently submitting.
973
1142
  */
@@ -1011,7 +1180,7 @@ type MaybeGetter<TValue> = TValue | (() => TValue);
1011
1180
  /**
1012
1181
  * Field component props interface.
1013
1182
  */
1014
- interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1183
+ interface FieldProps<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
1015
1184
  /**
1016
1185
  * The form store to which the field belongs.
1017
1186
  */
@@ -1034,13 +1203,13 @@ interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends Require
1034
1203
  *
1035
1204
  * @returns The UI of the field to be rendered.
1036
1205
  */
1037
- declare function Field<TSchema extends Schema, TFieldPath extends RequiredPath>(props: FieldProps<TSchema, TFieldPath>): JSX.Element;
1206
+ declare function Field<TSchema extends FormSchema, TFieldPath extends RequiredPath>(props: FieldProps<TSchema, TFieldPath>): JSX.Element;
1038
1207
  //#endregion
1039
1208
  //#region src/components/FieldArray/FieldArray.d.ts
1040
1209
  /**
1041
1210
  * FieldArray component props interface.
1042
1211
  */
1043
- interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1212
+ interface FieldArrayProps<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1044
1213
  /**
1045
1214
  * The form store to which the field array belongs.
1046
1215
  */
@@ -1063,13 +1232,13 @@ interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath exten
1063
1232
  *
1064
1233
  * @returns The UI of the field array to be rendered.
1065
1234
  */
1066
- declare function FieldArray<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(props: FieldArrayProps<TSchema, TFieldArrayPath>): JSX.Element;
1235
+ declare function FieldArray<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(props: FieldArrayProps<TSchema, TFieldArrayPath>): JSX.Element;
1067
1236
  //#endregion
1068
1237
  //#region src/components/Form/Form.d.ts
1069
1238
  /**
1070
1239
  * Form component props type.
1071
1240
  */
1072
- type FormProps<TSchema extends Schema = Schema> = Omit<JSX.FormHTMLAttributes<HTMLFormElement>, "onSubmit" | "novalidate" | "noValidate"> & {
1241
+ type FormProps<TSchema extends FormSchema = FormSchema> = Omit<JSX.FormHTMLAttributes<HTMLFormElement>, "onSubmit" | "novalidate" | "noValidate"> & {
1073
1242
  /**
1074
1243
  * The form store instance.
1075
1244
  */
@@ -1091,7 +1260,7 @@ type FormProps<TSchema extends Schema = Schema> = Omit<JSX.FormHTMLAttributes<HT
1091
1260
  *
1092
1261
  * @returns The a native form element.
1093
1262
  */
1094
- declare function Form<TSchema extends Schema>(props: FormProps<TSchema>): JSX.Element;
1263
+ declare function Form<TSchema extends FormSchema>(props: FormProps<TSchema>): JSX.Element;
1095
1264
  //#endregion
1096
1265
  //#region src/primitives/createForm/createForm.d.ts
1097
1266
  /**
@@ -1102,13 +1271,13 @@ declare function Form<TSchema extends Schema>(props: FormProps<TSchema>): JSX.El
1102
1271
  *
1103
1272
  * @returns The form store with reactive properties.
1104
1273
  */
1105
- declare function createForm<TSchema extends Schema>(config: FormConfig<TSchema>): FormStore<TSchema>;
1274
+ declare function createForm<TSchema extends FormSchema>(config: FormConfig<TSchema>): FormStore<TSchema>;
1106
1275
  //#endregion
1107
1276
  //#region src/primitives/useField/useField.d.ts
1108
1277
  /**
1109
1278
  * Use field config interface.
1110
1279
  */
1111
- interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1280
+ interface UseFieldConfig<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
1112
1281
  /**
1113
1282
  * The path to the field within the form schema.
1114
1283
  */
@@ -1122,13 +1291,13 @@ interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends Req
1122
1291
  *
1123
1292
  * @returns The field store with reactive properties and element props.
1124
1293
  */
1125
- declare function useField<TSchema extends Schema, TFieldPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldConfig<TSchema, TFieldPath>>): FieldStore<TSchema, TFieldPath>;
1294
+ declare function useField<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldConfig<TSchema, TFieldPath>>): FieldStore<TSchema, TFieldPath>;
1126
1295
  //#endregion
1127
1296
  //#region src/primitives/useFieldArray/useFieldArray.d.ts
1128
1297
  /**
1129
1298
  * Use field array config interface.
1130
1299
  */
1131
- interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1300
+ interface UseFieldArrayConfig<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1132
1301
  /**
1133
1302
  * The path to the field array within the form schema.
1134
1303
  */
@@ -1142,6 +1311,6 @@ interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath e
1142
1311
  *
1143
1312
  * @returns The field array store with reactive properties for array management.
1144
1313
  */
1145
- declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
1314
+ declare function useFieldArray<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
1146
1315
  //#endregion
1147
- export { type DeepPartial, Field, FieldArray, FieldArrayProps, FieldArrayStore, type FieldElement, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, type FormConfig, FormProps, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MaybeGetter, 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, createForm, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };
1316
+ export { type DeepPartial, Field, FieldArray, FieldArrayProps, FieldArrayStore, type FieldElement, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, type FormConfig, FormProps, type FormSchema, FormStore, GetFieldDirtyInputConfig, GetFieldDirtyPathsConfig, GetFieldErrorsConfig, GetFieldInputConfig, GetFormDirtyInputConfig, GetFormDirtyPathsConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MaybeGetter, 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, createForm, focus, getAllErrors, getDirtyInput, getDirtyPaths, getErrors, getInput, handleSubmit, insert, move, pickDirty, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };