@formisch/solid 0.10.0 → 0.12.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
@@ -3,6 +3,177 @@ import { JSX } from "solid-js";
3
3
 
4
4
  //#region ../../packages/core/dist/index.solid.d.ts
5
5
 
6
+ //#region src/types/utils/utils.d.ts
7
+ /**
8
+ * Checks if a type is `any`.
9
+ */
10
+ type IsAny<T> = 0 extends 1 & T ? true : false;
11
+ /**
12
+ * Checks if a type is `never`.
13
+ */
14
+ type IsNever<T> = [T] extends [never] ? true : false;
15
+ /**
16
+ * Constructs a type that is maybe a promise.
17
+ */
18
+ type MaybePromise<T> = T | Promise<T>;
19
+ /**
20
+ * Makes all properties deeply optional.
21
+ */
22
+ type DeepPartial<TValue> = TValue extends Record<PropertyKey, unknown> | readonly unknown[] ? { [TKey in keyof TValue]?: DeepPartial<TValue[TKey]> | undefined } : TValue | undefined;
23
+ /**
24
+ * Makes all value properties optional.
25
+ *
26
+ * Hint: For dynamic arrays, only plain objects and nested arrays have their
27
+ * values made optional. Primitives and class instances are kept as-is to avoid
28
+ * types like `(string | undefined)[]`.
29
+ */
30
+ 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;
31
+ //#endregion
32
+ //#region src/types/path/path.d.ts
33
+ /**
34
+ * Path key type.
35
+ */
36
+ type PathKey = string | number;
37
+ /**
38
+ * Path type.
39
+ */
40
+ type Path = readonly PathKey[];
41
+ /**
42
+ * Required path type.
43
+ */
44
+ type RequiredPath = readonly [PathKey, ...Path];
45
+ /**
46
+ * Extracts the exact keys of a tuple, array or object. Tuples return their
47
+ * literal numeric indices, dynamic arrays return `number`, objects return
48
+ * their `keyof` keys, and any other input returns `never`.
49
+ */
50
+ 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;
51
+ /**
52
+ * Returns the flat object of all indexable properties of `TValue`. For object
53
+ * unions, properties from every member are merged so that any single property
54
+ * is accessible. For primitives and other non-indexable types, the result is
55
+ * `{}`.
56
+ *
57
+ * Hint: This is necessary to make properties accessible across union members.
58
+ * By default, properties that do not exist in all union options are not
59
+ * accessible and result in "any" when accessed.
60
+ */
61
+ type PropertiesOf<TValue> = { [TKey in ExactKeysOf<TValue>]: TValue extends Record<TKey, infer TItem> ? TItem : never };
62
+ /**
63
+ * Lazily evaluates only the first valid path segment based on the given value.
64
+ */
65
+ 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;
66
+ /**
67
+ * Returns the path if valid, otherwise the first possible valid path based on
68
+ * the given value.
69
+ */
70
+ type ValidPath<TValue, TPath extends RequiredPath> = TPath extends LazyPath<Required<TValue>, TPath> ? TPath : LazyPath<Required<TValue>, TPath>;
71
+ /**
72
+ * Detects whether the consuming project is configured with
73
+ * `exactOptionalPropertyTypes: true`.
74
+ *
75
+ * Hint: If `false` the built-in `Required<T>` strips `| undefined` from
76
+ * optional properties, so `Required<{ key?: undefined }>['key']` collapses
77
+ * to `never` — under strict mode the same expression yields `undefined`.
78
+ */
79
+ type IsExactOptionalProps = Required<{
80
+ key?: undefined;
81
+ }>["key"] extends never ? false : true;
82
+ /**
83
+ * Like the built-in `Required<T>`, but preserves `| undefined` in two
84
+ * places where `Required<T>` strips it:
85
+ *
86
+ * 1. Optional property values under `exactOptionalPropertyTypes: false`
87
+ * — without this, input typings for `v.optional`/`v.nullish` schemas
88
+ * narrow incorrectly (issue #15).
89
+ * 2. Array/tuple element types — e.g. `(string | undefined)[]` stays
90
+ * `(string | undefined)[]` instead of becoming `string[]`. Arrays
91
+ * fall through unchanged because they only have a numeric index
92
+ * signature and don't structurally extend `Record<PropertyKey,
93
+ * unknown>` (which requires string keys).
94
+ */
95
+ type ExactRequired<TValue> = TValue extends Record<PropertyKey, unknown> ? IsExactOptionalProps extends true ? Required<TValue> : { [TKey in keyof Required<TValue>]: TValue[TKey] } : TValue;
96
+ /**
97
+ * Extracts the value type at the given path.
98
+ */
99
+ 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;
100
+ /**
101
+ * Checks whether a value is a dynamic array or contains one anywhere in its
102
+ * shape. A fixed-length tuple is not itself a dynamic array, but it counts when
103
+ * it contains one, so paths can still navigate through tuples to reach nested
104
+ * arrays.
105
+ *
106
+ * Hint: The inner conditionals (`TValue extends readonly unknown[]` and
107
+ * `TValue extends Record<PropertyKey, unknown>`) distribute over union members,
108
+ * so the inner expression returns the union of each member's result (e.g.
109
+ * `true | false` when some members contain arrays and others don't).
110
+ * Downstream code uses `IsOrHasArray<T> extends true`, but
111
+ * `boolean extends true` is `false` — so we collapse the result via
112
+ * `true extends ...`, which is `true` whenever at least one union member
113
+ * contributed `true`.
114
+ */
115
+ 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;
116
+ /**
117
+ * Extracts the exact keys of a tuple, array or object that contain arrays.
118
+ */
119
+ 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;
120
+ /**
121
+ * Returns the flat object of indexable properties of `TValue` whose values
122
+ * are or contain arrays. Mirrors `PropertiesOf` but keyed by
123
+ * `ExactKeysOfArrayPath` so the lookup is provably valid for array-path
124
+ * navigation in `LazyArrayPath`.
125
+ */
126
+ type PropertiesOfArrayPath<TValue> = { [TKey in ExactKeysOfArrayPath<TValue>]: TValue extends Record<TKey, infer TItem> ? TItem : never };
127
+ /**
128
+ * Lazily evaluates only the first valid array path segment based on the given value.
129
+ */
130
+ 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;
131
+ /**
132
+ * Returns the path if valid, otherwise the first possible valid array path
133
+ * based on the given value.
134
+ */
135
+ type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<Required<TValue>, TPath> ? TPath : LazyArrayPath<Required<TValue>, TPath>;
136
+ /**
137
+ * Recursive helper for `DirtyPath` that prepends `TKey` to each deeper path,
138
+ * or falls through to `never` when the child is not an object.
139
+ */
140
+ type DeepDirtyPath<TChild, TKey$1 extends PathKey, TDepth extends 0[]> = TChild extends Record<PropertyKey, unknown> ? readonly [TKey$1, ...DirtyPath<TChild, [...TDepth, 0]>] : never;
141
+ /**
142
+ * Returns the union of all `RequiredPath`s that `getDirtyPaths` can emit
143
+ * for a given input type. Object fields contribute their own path and the
144
+ * paths of their descendants; arrays and tuples are atomic and contribute
145
+ * only their own path, because dirty arrays are returned as complete units.
146
+ *
147
+ * Narrowing is exact for the first 5 levels of nesting; deeper paths fall
148
+ * back to `RequiredPath` to keep the result a complete superset of any
149
+ * path the runtime can address.
150
+ *
151
+ * Hint: Arrays and tuples are atomic because they don't structurally
152
+ * extend `Record<PropertyKey, unknown>` and so fall through to `never`
153
+ * via `DeepDirtyPath` — no explicit array check is needed. `TDepth` is
154
+ * a tuple-length counter capped at 5 to bound TypeScript instantiation
155
+ * cost.
156
+ */
157
+ 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;
158
+ /**
159
+ * Recursive helper for `FieldPath` that prepends `TKey` to each deeper field
160
+ * path, or falls through to `never` when the child is a leaf value.
161
+ */
162
+ type DeepFieldPath<TChild, TKey$1 extends PathKey, TDepth extends 0[]> = TChild extends readonly unknown[] | Record<PropertyKey, unknown> ? readonly [TKey$1, ...FieldPath<TChild, [...TDepth, 0]>] : never;
163
+ /**
164
+ * Returns the union of all `RequiredPath`s that address a field within the
165
+ * given input type. Object and array fields contribute their own path and the
166
+ * paths of their descendants; unlike `DirtyPath`, arrays are recursed into so
167
+ * that fields at any depth, including array items, can be addressed. Leaf
168
+ * values contribute only their own path (emitted by their parent).
169
+ *
170
+ * Narrowing is exact for the first 5 levels of nesting; deeper paths fall
171
+ * back to `RequiredPath` to keep the result a complete superset of any path
172
+ * the runtime can address. `TDepth` is a tuple-length counter capped at 5 to
173
+ * bound TypeScript instantiation cost.
174
+ */
175
+ type FieldPath<TValue, TDepth extends 0[] = []> = TDepth["length"] extends 5 ? RequiredPath : TValue extends readonly unknown[] | Record<PropertyKey, unknown> ? { [TKey in ExactKeysOf<TValue>]: readonly [TKey] | DeepFieldPath<NonNullable<PropertiesOf<TValue>[TKey]>, TKey, TDepth> }[ExactKeysOf<TValue>] : never;
176
+ //#endregion
6
177
  //#region src/types/schema/schema.d.ts
7
178
  /**
8
179
  * Schema type.
@@ -67,11 +238,22 @@ interface InternalBaseStore {
67
238
  */
68
239
  name: string;
69
240
  /**
241
+ * The path to the field.
242
+ */
243
+ path: Path;
244
+ /**
70
245
  * The schema of the field.
71
246
  */
72
247
  schema: Schema;
73
248
  /**
74
249
  * The initial elements of the field.
250
+ *
251
+ * Hint: This may look unused, but do not remove it. `copyItemState` and
252
+ * `swapItemState` move the `elements` reference between field stores when
253
+ * array items are inserted, moved, removed or swapped, and `reset` restores
254
+ * each field's original element via `elements = initialElements`. Without it,
255
+ * focus and file reset target the wrong element after a reorder followed by a
256
+ * reset.
75
257
  */
76
258
  initialElements: FieldElement[];
77
259
  /**
@@ -87,6 +269,15 @@ interface InternalBaseStore {
87
269
  */
88
270
  isTouched: Signal<boolean>;
89
271
  /**
272
+ * The edited state of the field.
273
+ *
274
+ * Hint: Unlike `isTouched`, which is also set when a field is focused, this
275
+ * is only set when the field's value is changed. Unlike `isDirty`, it stays
276
+ * `true` even if the value is changed back to its initial value. It is only
277
+ * reset when the field is reset.
278
+ */
279
+ isEdited: Signal<boolean>;
280
+ /**
90
281
  * The dirty state of the field.
91
282
  */
92
283
  isDirty: Signal<boolean>;
@@ -100,6 +291,14 @@ interface InternalArrayStore extends InternalBaseStore {
100
291
  */
101
292
  kind: "array";
102
293
  /**
294
+ * Whether the array schema is wrapped in a nullish schema.
295
+ *
296
+ * Hint: This indicates whether a missing input should be represented as the
297
+ * nullish value (`null`/`undefined`) or as a present but empty array
298
+ * (`true`). It keeps resetting consistent with the initial state.
299
+ */
300
+ isNullish: boolean;
301
+ /**
103
302
  * The children of the array field.
104
303
  */
105
304
  children: InternalFieldStore[];
@@ -152,6 +351,14 @@ interface InternalObjectStore extends InternalBaseStore {
152
351
  */
153
352
  kind: "object";
154
353
  /**
354
+ * Whether the object schema is wrapped in a nullish schema.
355
+ *
356
+ * Hint: This indicates whether a missing input should be represented as the
357
+ * nullish value (`null`/`undefined`) or as a present but empty object
358
+ * (`true`). It keeps resetting consistent with the initial state.
359
+ */
360
+ isNullish: boolean;
361
+ /**
155
362
  * The children of the object field.
156
363
  */
157
364
  children: Record<string, InternalFieldStore>;
@@ -215,32 +422,6 @@ type InternalFieldStore = InternalArrayStore | InternalObjectStore | InternalVal
215
422
  */
216
423
  declare const INTERNAL: "~internal";
217
424
  //#endregion
218
- //#region src/types/utils/utils.d.ts
219
- /**
220
- * Checks if a type is `any`.
221
- */
222
- type IsAny<T> = 0 extends 1 & T ? true : false;
223
- /**
224
- * Checks if a type is `never`.
225
- */
226
- type IsNever<T> = [T] extends [never] ? true : false;
227
- /**
228
- * Constructs a type that is maybe a promise.
229
- */
230
- type MaybePromise<T> = T | Promise<T>;
231
- /**
232
- * Makes all properties deeply optional.
233
- */
234
- type DeepPartial<TValue> = TValue extends Record<PropertyKey, unknown> | readonly unknown[] ? { [TKey in keyof TValue]?: DeepPartial<TValue[TKey]> | undefined } : TValue | undefined;
235
- /**
236
- * Makes all value properties optional.
237
- *
238
- * Hint: For dynamic arrays, only plain objects and nested arrays have their
239
- * values made optional. Primitives and class instances are kept as-is to avoid
240
- * types like `(string | undefined)[]`.
241
- */
242
- 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;
243
- //#endregion
244
425
  //#region src/types/form/form.d.ts
245
426
  /**
246
427
  * Validation mode type.
@@ -324,174 +505,138 @@ type SubmitHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>
324
505
  */
325
506
  type SubmitEventHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
326
507
  //#endregion
327
- //#region src/types/path/path.d.ts
328
- /**
329
- * Path key type.
330
- */
331
- type PathKey = string | number;
332
- /**
333
- * Path type.
334
- */
335
- type Path = readonly PathKey[];
508
+ //#region src/array/copyItemState/copyItemState.d.ts
336
509
  /**
337
- * Required path type.
510
+ * Copies the deeply nested state (signal values) from one field store to
511
+ * another. This includes the `elements`, `errors`, `startInput`, `input`,
512
+ * `isTouched`, `isEdited`, `isDirty`, and for arrays `startItems` and `items`
513
+ * properties. Recursively walks through the field stores and copies all signal
514
+ * values.
515
+ *
516
+ * @param fromInternalFieldStore The source field store to copy from.
517
+ * @param toInternalFieldStore The destination field store to copy to.
338
518
  */
339
- type RequiredPath = readonly [PathKey, ...Path];
519
+ //#endregion
520
+ //#region ../../packages/methods/dist/index.solid.d.ts
521
+ //#region src/focus/focus.d.ts
522
+
340
523
  /**
341
- * Extracts the exact keys of a tuple, array or object. Tuples return their
342
- * literal numeric indices, dynamic arrays return `number`, objects return
343
- * their `keyof` keys, and any other input returns `never`.
524
+ * Focus field config interface.
344
525
  */
345
- 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;
526
+ interface FocusFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
527
+ /**
528
+ * The path to the field to focus.
529
+ */
530
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
531
+ }
346
532
  /**
347
- * Returns the flat object of all indexable properties of `TValue`. For object
348
- * unions, properties from every member are merged so that any single property
349
- * is accessible. For primitives and other non-indexable types, the result is
350
- * `{}`.
533
+ * Focuses the first focusable input element of a field. This is useful for
534
+ * programmatically setting focus to a specific field, such as after
535
+ * validation errors or user interactions.
351
536
  *
352
- * Hint: This is necessary to make properties accessible across union members.
353
- * By default, properties that do not exist in all union options are not
354
- * accessible and result in "any" when accessed.
537
+ * @param form The form store containing the field.
538
+ * @param config The focus field configuration.
355
539
  */
356
- type PropertiesOf<TValue> = { [TKey in ExactKeysOf<TValue>]: TValue extends Record<TKey, infer TItem> ? TItem : never };
540
+ declare function focus<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
541
+ //#endregion
542
+ //#region src/getDeepErrorEntries/getDeepErrorEntries.d.ts
357
543
  /**
358
- * Lazily evaluates only the first valid path segment based on the given value.
544
+ * Deep error entry interface.
359
545
  */
360
- 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;
546
+ interface DeepErrorEntry<TValue = unknown> {
547
+ /**
548
+ * The path to the field with errors, or an empty path for form-level errors.
549
+ */
550
+ readonly path: unknown extends TValue ? Path : readonly [] | FieldPath<TValue>;
551
+ /**
552
+ * The error messages of the field.
553
+ */
554
+ readonly errors: [string, ...string[]];
555
+ }
361
556
  /**
362
- * Returns the path if valid, otherwise the first possible valid path based on
363
- * the given value.
557
+ * Get form deep error entries config interface.
364
558
  */
365
- type ValidPath<TValue, TPath extends RequiredPath> = TPath extends LazyPath<Required<TValue>, TPath> ? TPath : LazyPath<Required<TValue>, TPath>;
559
+ interface GetFormDeepErrorEntriesConfig {
560
+ /**
561
+ * The path to a field. Leave undefined to get the entries of the entire form.
562
+ */
563
+ readonly path?: undefined;
564
+ }
366
565
  /**
367
- * Detects whether the consuming project is configured with
368
- * `exactOptionalPropertyTypes: true`.
369
- *
370
- * Hint: If `false` the built-in `Required<T>` strips `| undefined` from
371
- * optional properties, so `Required<{ key?: undefined }>['key']` collapses
372
- * to `never` — under strict mode the same expression yields `undefined`.
566
+ * Get field deep error entries config interface.
373
567
  */
374
- type IsExactOptionalProps = Required<{
375
- key?: undefined;
376
- }>["key"] extends never ? false : true;
568
+ interface GetFieldDeepErrorEntriesConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
569
+ /**
570
+ * The path to the field to retrieve the entries from.
571
+ */
572
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
573
+ }
377
574
  /**
378
- * Like the built-in `Required<T>`, but preserves `| undefined` in two
379
- * places where `Required<T>` strips it:
575
+ * Retrieves the errors of a specific field or the entire form as a list of
576
+ * entries, each pairing the path to a field with its error messages. This is
577
+ * useful for building custom error summaries that link each message back to
578
+ * its field. Form-level errors are included with an empty path.
380
579
  *
381
- * 1. Optional property values under `exactOptionalPropertyTypes: false`
382
- * — without this, input typings for `v.optional`/`v.nullish` schemas
383
- * narrow incorrectly (issue #15).
384
- * 2. Array/tuple element types — e.g. `(string | undefined)[]` stays
385
- * `(string | undefined)[]` instead of becoming `string[]`. Arrays
386
- * fall through unchanged because they only have a numeric index
387
- * signature and don't structurally extend `Record<PropertyKey,
388
- * unknown>` (which requires string keys).
389
- */
390
- type ExactRequired<TValue> = TValue extends Record<PropertyKey, unknown> ? IsExactOptionalProps extends true ? Required<TValue> : { [TKey in keyof Required<TValue>]: TValue[TKey] } : TValue;
391
- /**
392
- * Extracts the value type at the given path.
393
- */
394
- 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;
395
- /**
396
- * Checks whether a value is an array or contains one anywhere in its shape.
580
+ * @param form The form store to retrieve error entries from.
397
581
  *
398
- * Hint: The inner conditionals (`TValue extends readonly unknown[]` and
399
- * `TValue extends Record<PropertyKey, unknown>`) distribute over union members,
400
- * so the inner expression returns the union of each member's result (e.g.
401
- * `true | false` when some members contain arrays and others don't).
402
- * Downstream code uses `IsOrHasArray<T> extends true`, but
403
- * `boolean extends true` is `false` — so we collapse the result via
404
- * `true extends ...`, which is `true` whenever at least one union member
405
- * contributed `true`.
406
- */
407
- 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;
408
- /**
409
- * Extracts the exact keys of a tuple, array or object that contain arrays.
582
+ * @returns A list of path and error message entries.
410
583
  */
411
- 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;
412
- /**
413
- * Returns the flat object of indexable properties of `TValue` whose values
414
- * are or contain arrays. Mirrors `PropertiesOf` but keyed by
415
- * `ExactKeysOfArrayPath` so the lookup is provably valid for array-path
416
- * navigation in `LazyArrayPath`.
417
- */
418
- type PropertiesOfArrayPath<TValue> = { [TKey in ExactKeysOfArrayPath<TValue>]: TValue extends Record<TKey, infer TItem> ? TItem : never };
419
- /**
420
- * Lazily evaluates only the first valid array path segment based on the given value.
421
- */
422
- 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;
584
+ declare function getDeepErrorEntries<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): DeepErrorEntry<v.InferInput<TSchema>>[];
423
585
  /**
424
- * Returns the path if valid, otherwise the first possible valid array path
425
- * based on the given value.
426
- */
427
- type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<Required<TValue>, TPath> ? TPath : LazyArrayPath<Required<TValue>, TPath>;
428
- /**
429
- * Recursive helper for `DirtyPath` that prepends `TKey` to each deeper path,
430
- * or falls through to `never` when the child is not an object.
431
- */
432
- type DeepDirtyPath<TChild, TKey$1 extends PathKey, TDepth extends 0[]> = TChild extends Record<PropertyKey, unknown> ? readonly [TKey$1, ...DirtyPath<TChild, [...TDepth, 0]>] : never;
433
- /**
434
- * Returns the union of all `RequiredPath`s that `getDirtyPaths` can emit
435
- * for a given input type. Object fields contribute their own path and the
436
- * paths of their descendants; arrays and tuples are atomic and contribute
437
- * only their own path, because dirty arrays are returned as complete units.
586
+ * Retrieves the errors of a specific field or the entire form as a list of
587
+ * entries, each pairing the path to a field with its error messages. This is
588
+ * useful for building custom error summaries that link each message back to
589
+ * its field. Form-level errors are included with an empty path.
438
590
  *
439
- * Narrowing is exact for the first 5 levels of nesting; deeper paths fall
440
- * back to `RequiredPath` to keep the result a complete superset of any
441
- * path the runtime can address.
591
+ * @param form The form store to retrieve error entries from.
592
+ * @param config The get deep error entries configuration.
442
593
  *
443
- * Hint: Arrays and tuples are atomic because they don't structurally
444
- * extend `Record<PropertyKey, unknown>` and so fall through to `never`
445
- * via `DeepDirtyPath` — no explicit array check is needed. `TDepth` is
446
- * a tuple-length counter capped at 5 to bound TypeScript instantiation
447
- * cost.
594
+ * @returns A list of path and error message entries.
448
595
  */
449
- 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;
596
+ declare function getDeepErrorEntries<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldDeepErrorEntriesConfig<TSchema, TFieldPath> : GetFormDeepErrorEntriesConfig): DeepErrorEntry<v.InferInput<TSchema>>[];
450
597
  //#endregion
451
- //#region src/array/copyItemState/copyItemState.d.ts
598
+ //#region src/getDeepErrors/getDeepErrors.d.ts
452
599
  /**
453
- * Copies the deeply nested state (signal values) from one field store to
454
- * another. This includes the `elements`, `errors`, `startInput`, `input`,
455
- * `isTouched`, `isDirty`, and for arrays `startItems` and `items` properties.
456
- * Recursively walks through the field stores and copies all signal values.
457
- *
458
- * @param fromInternalFieldStore The source field store to copy from.
459
- * @param toInternalFieldStore The destination field store to copy to.
600
+ * Get form deep errors config interface.
460
601
  */
461
- //#endregion
462
- //#region ../../packages/methods/dist/index.solid.d.ts
463
- //#region src/focus/focus.d.ts
464
-
602
+ interface GetFormDeepErrorsConfig {
603
+ /**
604
+ * The path to a field. Leave undefined to get the errors of the entire form.
605
+ */
606
+ readonly path?: undefined;
607
+ }
465
608
  /**
466
- * Focus field config interface.
609
+ * Get field deep errors config interface.
467
610
  */
468
- interface FocusFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
611
+ interface GetFieldDeepErrorsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
469
612
  /**
470
- * The path to the field to focus.
613
+ * The path to the field to retrieve the errors from.
471
614
  */
472
615
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
473
616
  }
474
617
  /**
475
- * Focuses the first input element of a field. This is useful for
476
- * programmatically setting focus to a specific field, such as after
477
- * validation errors or user interactions.
618
+ * Retrieves all error messages of a specific field or the entire form by
619
+ * walking through the field store and all its descendants. This is useful for
620
+ * displaying a summary of all validation errors within a section or the whole
621
+ * form. Form-level errors are included.
478
622
  *
479
- * @param form The form store containing the field.
480
- * @param config The focus field configuration.
623
+ * @param form The form store to retrieve errors from.
624
+ *
625
+ * @returns A non-empty array of error messages, or null if no errors exist.
481
626
  */
482
- declare function focus<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
483
- //#endregion
484
- //#region src/getAllErrors/getAllErrors.d.ts
627
+ declare function getDeepErrors<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
485
628
  /**
486
- * Retrieves all error messages from all fields in the form by walking through
487
- * the entire field store tree. This is useful for displaying a summary of all
488
- * validation errors across the form.
629
+ * Retrieves all error messages of a specific field or the entire form by
630
+ * walking through the field store and all its descendants. This is useful for
631
+ * displaying a summary of all validation errors within a section or the whole
632
+ * form. Form-level errors are included.
489
633
  *
490
634
  * @param form The form store to retrieve errors from.
635
+ * @param config The get deep errors configuration.
491
636
  *
492
637
  * @returns A non-empty array of error messages, or null if no errors exist.
493
638
  */
494
- declare function getAllErrors(form: BaseFormStore): [string, ...string[]] | null;
639
+ declare function getDeepErrors<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldDeepErrorsConfig<TSchema, TFieldPath> : GetFormDeepErrorsConfig): [string, ...string[]] | null;
495
640
  //#endregion
496
641
  //#region src/getDirtyInput/getDirtyInput.d.ts
497
642
  /**
@@ -711,6 +856,172 @@ interface InsertConfig<TSchema extends FormSchema, TFieldArrayPath extends Requi
711
856
  */
712
857
  declare function insert<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
713
858
  //#endregion
859
+ //#region src/isDirty/isDirty.d.ts
860
+ /**
861
+ * Is form dirty config interface.
862
+ */
863
+ interface IsFormDirtyConfig {
864
+ /**
865
+ * The path to a field. Leave undefined to check the entire form.
866
+ */
867
+ readonly path?: undefined;
868
+ }
869
+ /**
870
+ * Is field dirty config interface.
871
+ */
872
+ interface IsFieldDirtyConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
873
+ /**
874
+ * The path to the field to check for dirtiness.
875
+ */
876
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
877
+ }
878
+ /**
879
+ * Checks whether a specific field or the entire form is dirty by walking
880
+ * through the field store and all its descendants. A field is dirty when its
881
+ * input differs from its initial value.
882
+ *
883
+ * @param form The form store to check for dirtiness.
884
+ *
885
+ * @returns Whether the field or form is dirty.
886
+ */
887
+ declare function isDirty<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): boolean;
888
+ /**
889
+ * Checks whether a specific field or the entire form is dirty by walking
890
+ * through the field store and all its descendants. A field is dirty when its
891
+ * input differs from its initial value.
892
+ *
893
+ * @param form The form store to check for dirtiness.
894
+ * @param config The is dirty configuration.
895
+ *
896
+ * @returns Whether the field or form is dirty.
897
+ */
898
+ declare function isDirty<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? IsFieldDirtyConfig<TSchema, TFieldPath> : IsFormDirtyConfig): boolean;
899
+ //#endregion
900
+ //#region src/isEdited/isEdited.d.ts
901
+ /**
902
+ * Is form edited config interface.
903
+ */
904
+ interface IsFormEditedConfig {
905
+ /**
906
+ * The path to a field. Leave undefined to check the entire form.
907
+ */
908
+ readonly path?: undefined;
909
+ }
910
+ /**
911
+ * Is field edited config interface.
912
+ */
913
+ interface IsFieldEditedConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
914
+ /**
915
+ * The path to the field to check for being edited.
916
+ */
917
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
918
+ }
919
+ /**
920
+ * Checks whether a specific field or the entire form is edited by walking
921
+ * through the field store and all its descendants. A field is edited once its
922
+ * value has been changed by the user.
923
+ *
924
+ * @param form The form store to check for being edited.
925
+ *
926
+ * @returns Whether the field or form is edited.
927
+ */
928
+ declare function isEdited<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): boolean;
929
+ /**
930
+ * Checks whether a specific field or the entire form is edited by walking
931
+ * through the field store and all its descendants. A field is edited once its
932
+ * value has been changed by the user.
933
+ *
934
+ * @param form The form store to check for being edited.
935
+ * @param config The is edited configuration.
936
+ *
937
+ * @returns Whether the field or form is edited.
938
+ */
939
+ declare function isEdited<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? IsFieldEditedConfig<TSchema, TFieldPath> : IsFormEditedConfig): boolean;
940
+ //#endregion
941
+ //#region src/isTouched/isTouched.d.ts
942
+ /**
943
+ * Is form touched config interface.
944
+ */
945
+ interface IsFormTouchedConfig {
946
+ /**
947
+ * The path to a field. Leave undefined to check the entire form.
948
+ */
949
+ readonly path?: undefined;
950
+ }
951
+ /**
952
+ * Is field touched config interface.
953
+ */
954
+ interface IsFieldTouchedConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
955
+ /**
956
+ * The path to the field to check for being touched.
957
+ */
958
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
959
+ }
960
+ /**
961
+ * Checks whether a specific field or the entire form is touched by walking
962
+ * through the field store and all its descendants. A field is touched once it
963
+ * has received and lost focus.
964
+ *
965
+ * @param form The form store to check for being touched.
966
+ *
967
+ * @returns Whether the field or form is touched.
968
+ */
969
+ declare function isTouched<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): boolean;
970
+ /**
971
+ * Checks whether a specific field or the entire form is touched by walking
972
+ * through the field store and all its descendants. A field is touched once it
973
+ * has received and lost focus.
974
+ *
975
+ * @param form The form store to check for being touched.
976
+ * @param config The is touched configuration.
977
+ *
978
+ * @returns Whether the field or form is touched.
979
+ */
980
+ declare function isTouched<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? IsFieldTouchedConfig<TSchema, TFieldPath> : IsFormTouchedConfig): boolean;
981
+ //#endregion
982
+ //#region src/isValid/isValid.d.ts
983
+ /**
984
+ * Is form valid config interface.
985
+ */
986
+ interface IsFormValidConfig {
987
+ /**
988
+ * The path to a field. Leave undefined to check the entire form.
989
+ */
990
+ readonly path?: undefined;
991
+ }
992
+ /**
993
+ * Is field valid config interface.
994
+ */
995
+ interface IsFieldValidConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
996
+ /**
997
+ * The path to the field to check for validity.
998
+ */
999
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
1000
+ }
1001
+ /**
1002
+ * Checks whether a specific field or the entire form is valid by walking
1003
+ * through the field store and all its descendants. A field is valid when
1004
+ * neither it nor any of its descendants contains an error. Form-level errors
1005
+ * are included.
1006
+ *
1007
+ * @param form The form store to check for validity.
1008
+ *
1009
+ * @returns Whether the field or form is valid.
1010
+ */
1011
+ declare function isValid<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): boolean;
1012
+ /**
1013
+ * Checks whether a specific field or the entire form is valid by walking
1014
+ * through the field store and all its descendants. A field is valid when
1015
+ * neither it nor any of its descendants contains an error. Form-level errors
1016
+ * are included.
1017
+ *
1018
+ * @param form The form store to check for validity.
1019
+ * @param config The is valid configuration.
1020
+ *
1021
+ * @returns Whether the field or form is valid.
1022
+ */
1023
+ declare function isValid<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? IsFieldValidConfig<TSchema, TFieldPath> : IsFormValidConfig): boolean;
1024
+ //#endregion
714
1025
  //#region src/move/move.d.ts
715
1026
  /**
716
1027
  * Move array field config interface.
@@ -826,6 +1137,10 @@ interface ResetBaseConfig {
826
1137
  */
827
1138
  readonly keepTouched?: boolean | undefined;
828
1139
  /**
1140
+ * Whether to keep the edited state during reset. Defaults to false.
1141
+ */
1142
+ readonly keepEdited?: boolean | undefined;
1143
+ /**
829
1144
  * Whether to keep the error messages during reset. Defaults to false.
830
1145
  */
831
1146
  readonly keepErrors?: boolean | undefined;
@@ -1076,6 +1391,10 @@ interface FieldStore<TSchema extends FormSchema = FormSchema, TFieldPath extends
1076
1391
  */
1077
1392
  readonly isTouched: boolean;
1078
1393
  /**
1394
+ * Whether the field value has been edited.
1395
+ */
1396
+ readonly isEdited: boolean;
1397
+ /**
1079
1398
  * Whether the field input differs from its initial value.
1080
1399
  */
1081
1400
  readonly isDirty: boolean;
@@ -1113,6 +1432,10 @@ interface FieldArrayStore<TSchema extends FormSchema = FormSchema, TFieldArrayPa
1113
1432
  */
1114
1433
  readonly isTouched: boolean;
1115
1434
  /**
1435
+ * Whether the field array value has been edited.
1436
+ */
1437
+ readonly isEdited: boolean;
1438
+ /**
1116
1439
  * Whether the field array input differs from its initial value.
1117
1440
  */
1118
1441
  readonly isDirty: boolean;
@@ -1144,6 +1467,10 @@ interface FormStore<TSchema extends FormSchema = FormSchema> extends BaseFormSto
1144
1467
  */
1145
1468
  readonly isTouched: boolean;
1146
1469
  /**
1470
+ * Whether any field in the form has been edited.
1471
+ */
1472
+ readonly isEdited: boolean;
1473
+ /**
1147
1474
  * Whether any field in the form differs from its initial value.
1148
1475
  */
1149
1476
  readonly isDirty: boolean;
@@ -1155,7 +1482,7 @@ interface FormStore<TSchema extends FormSchema = FormSchema> extends BaseFormSto
1155
1482
  * The current error messages of the form.
1156
1483
  *
1157
1484
  * Hint: This property only contains validation errors at the root level
1158
- * of the form. To get all errors from all fields, use `getAllErrors`.
1485
+ * of the form. To get all errors from all fields, use `getDeepErrors`.
1159
1486
  */
1160
1487
  readonly errors: [string, ...string[]] | null;
1161
1488
  }
@@ -1303,4 +1630,4 @@ interface UseFieldArrayConfig<TSchema extends FormSchema = FormSchema, TFieldArr
1303
1630
  */
1304
1631
  declare function useFieldArray<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
1305
1632
  //#endregion
1306
- 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 };
1633
+ export { DeepErrorEntry, type DeepPartial, Field, FieldArray, FieldArrayProps, FieldArrayStore, type FieldElement, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, type FormConfig, FormProps, type FormSchema, FormStore, GetFieldDeepErrorEntriesConfig, GetFieldDeepErrorsConfig, GetFieldDirtyInputConfig, GetFieldDirtyPathsConfig, GetFieldErrorsConfig, GetFieldInputConfig, GetFormDeepErrorEntriesConfig, GetFormDeepErrorsConfig, GetFormDirtyInputConfig, GetFormDirtyPathsConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, IsFieldDirtyConfig, IsFieldEditedConfig, IsFieldTouchedConfig, IsFieldValidConfig, IsFormDirtyConfig, IsFormEditedConfig, IsFormTouchedConfig, IsFormValidConfig, 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, getDeepErrorEntries, getDeepErrors, getDirtyInput, getDirtyPaths, getErrors, getInput, handleSubmit, insert, isDirty, isEdited, isTouched, isValid, move, pickDirty, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };