@formisch/qwik 0.5.0 → 0.6.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,58 +3,201 @@ import { JSXOutput, NoSerialize, PropsOf, QRL, ReadonlySignal } from "@qwik.dev/
3
3
  import * as _qwik_dev_core_internal1 from "@qwik.dev/core/internal";
4
4
 
5
5
  //#region ../../packages/core/dist/index.qwik.d.ts
6
+
6
7
  //#region src/types/schema.d.ts
8
+ /**
9
+ * Schema type.
10
+ */
7
11
  type Schema = v.GenericSchema | v.GenericSchemaAsync;
8
12
  //#endregion
9
13
  //#region src/types/signal.d.ts
14
+ /**
15
+ * Signal interface.
16
+ */
10
17
  interface Signal<T> {
18
+ /**
19
+ * The value of the signal.
20
+ */
11
21
  value: T;
12
22
  }
23
+ /**
24
+ * Batch interface.
25
+ */
26
+
13
27
  //#endregion
14
28
  //#region src/types/field.d.ts
15
29
  /**
16
- * Value type of the field element.
30
+ * Field element type.
17
31
  */
18
32
  type FieldElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
33
+ /**
34
+ * Internal base store interface.
35
+ */
19
36
  //#endregion
20
37
  //#region src/types/field.qwik.d.ts
38
+ /**
39
+ * Internal base store interface.
40
+ */
21
41
  interface InternalBaseStore {
42
+ /**
43
+ * The kind of field store.
44
+ */
22
45
  kind: "array" | "object" | "value";
46
+ /**
47
+ * The name of the field.
48
+ */
23
49
  name: string;
50
+ /**
51
+ * The schema of the field.
52
+ */
24
53
  schema: NoSerialize<Schema>;
54
+ /**
55
+ * The elements of the field.
56
+ */
25
57
  elements: FieldElement[];
58
+ /**
59
+ * The errors of the field.
60
+ */
26
61
  errors: Signal<[string, ...string[]] | null>;
62
+ /**
63
+ * The touched state of the field.
64
+ */
27
65
  isTouched: Signal<boolean>;
66
+ /**
67
+ * The dirty state of the field.
68
+ */
28
69
  isDirty: Signal<boolean>;
29
70
  }
71
+ /**
72
+ * Internal array store interface.
73
+ */
30
74
  interface InternalArrayStore extends InternalBaseStore {
75
+ /**
76
+ * The kind of field store.
77
+ */
31
78
  kind: "array";
79
+ /**
80
+ * The children of the array field.
81
+ */
32
82
  children: InternalFieldStore[];
83
+ /**
84
+ * The initial input of the array field.
85
+ *
86
+ * Hint: The initial input is used for resetting and may only be changed
87
+ * during this process. It does not move when a field is moved.
88
+ */
33
89
  initialInput: Signal<true | null | undefined>;
90
+ /**
91
+ * The start input of the array field.
92
+ *
93
+ * Hint: The start input is used to determine whether the field is dirty
94
+ * and moves with it.
95
+ */
34
96
  startInput: Signal<true | null | undefined>;
97
+ /**
98
+ * The input of the array field.
99
+ *
100
+ * Hint: The input indicates whether it is `null`, `undefined`, or found in
101
+ * the children.
102
+ */
35
103
  input: Signal<true | null | undefined>;
104
+ /**
105
+ * The initial items of the array field.
106
+ *
107
+ * Hint: The initial items are used for resetting and may only be changed
108
+ * during this process. It does not move when a field is moved.
109
+ */
36
110
  initialItems: Signal<string[]>;
111
+ /**
112
+ * The start items of the array field.
113
+ *
114
+ * Hint: The start items are used to determine whether the field is dirty
115
+ * and moves with it.
116
+ */
37
117
  startItems: Signal<string[]>;
118
+ /**
119
+ * The items of the array field.
120
+ */
38
121
  items: Signal<string[]>;
39
122
  }
123
+ /**
124
+ * Internal object store interface.
125
+ */
40
126
  interface InternalObjectStore extends InternalBaseStore {
127
+ /**
128
+ * The kind of field store.
129
+ */
41
130
  kind: "object";
131
+ /**
132
+ * The children of the object field.
133
+ */
42
134
  children: Record<string, InternalFieldStore>;
135
+ /**
136
+ * The initial input of the object field.
137
+ *
138
+ * Hint: The initial input is used for resetting and may only be changed
139
+ * during this process. It does not move when a field is moved.
140
+ */
43
141
  initialInput: Signal<true | null | undefined>;
142
+ /**
143
+ * The start input of the object field.
144
+ *
145
+ * Hint: The start input is used to determine whether the field is dirty
146
+ * and moves with it.
147
+ */
44
148
  startInput: Signal<true | null | undefined>;
149
+ /**
150
+ * The input of the object field.
151
+ *
152
+ * Hint: The input indicates whether it is `null`, `undefined`, or found in
153
+ * the children.
154
+ */
45
155
  input: Signal<true | null | undefined>;
46
156
  }
157
+ /**
158
+ * Internal value store interface.
159
+ */
47
160
  interface InternalValueStore extends InternalBaseStore {
161
+ /**
162
+ * The kind of field store.
163
+ */
48
164
  kind: "value";
165
+ /**
166
+ * The initial input of the value field.
167
+ *
168
+ * Hint: The initial input is used for resetting and may only be changed
169
+ * during this process. It does not move when a field is moved.
170
+ */
49
171
  initialInput: Signal<unknown>;
172
+ /**
173
+ * The start input of the value field.
174
+ *
175
+ * Hint: The start input is used to determine whether the field is dirty
176
+ * and moves with it.
177
+ */
50
178
  startInput: Signal<unknown>;
179
+ /**
180
+ * The input of the value field.
181
+ */
51
182
  input: Signal<unknown>;
183
+ /**
184
+ * The touched state of the field.
185
+ */
52
186
  isTouched: Signal<boolean>;
187
+ /**
188
+ * The dirty state of the field.
189
+ */
53
190
  isDirty: Signal<boolean>;
54
191
  }
192
+ /**
193
+ * Internal field store type.
194
+ */
55
195
  type InternalFieldStore = InternalArrayStore | InternalObjectStore | InternalValueStore;
56
196
  //#endregion
57
197
  //#region src/values.d.ts
198
+ /**
199
+ * Internal symbol constant.
200
+ */
58
201
  declare const INTERNAL: "~internal";
59
202
  //#endregion
60
203
  //#region src/types/utils.d.ts
@@ -81,30 +224,87 @@ type PartialValues<TValue> = TValue extends readonly unknown[] ? number extends
81
224
  //#endregion
82
225
  //#region src/types/form.d.ts
83
226
  /**
84
- * Value type of the validation mode.
227
+ * Validation mode type.
85
228
  */
86
229
  type ValidationMode = "initial" | "touch" | "input" | "change" | "blur" | "submit";
230
+ /**
231
+ * Form config interface.
232
+ */
233
+
234
+ /**
235
+ * Submit handler type.
236
+ */
87
237
  type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
88
238
  //#endregion
89
239
  //#region src/types/form.qwik.d.ts
240
+ /**
241
+ * Form config interface.
242
+ */
90
243
  interface FormConfig<TSchema extends Schema = Schema> {
244
+ /**
245
+ * The schema of the form.
246
+ */
91
247
  readonly schema: TSchema;
248
+ /**
249
+ * The initial input of the form.
250
+ */
92
251
  readonly initialInput?: DeepPartial<v.InferInput<TSchema>> | undefined;
252
+ /**
253
+ * The validation mode of the form.
254
+ */
93
255
  readonly validate?: ValidationMode | undefined;
256
+ /**
257
+ * The revalidation mode of the form.
258
+ */
94
259
  readonly revalidate?: Exclude<ValidationMode, "initial"> | undefined;
95
260
  }
261
+ /**
262
+ * Internal form store interface.
263
+ */
96
264
  interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObjectStore {
265
+ /**
266
+ * The element of the form.
267
+ */
97
268
  element?: HTMLFormElement;
269
+ /**
270
+ * The number of active validators.
271
+ */
98
272
  validators: number;
273
+ /**
274
+ * The validation mode of the form.
275
+ */
99
276
  validate: ValidationMode;
277
+ /**
278
+ * The revalidation mode of the form.
279
+ */
100
280
  revalidate: Exclude<ValidationMode, "initial">;
281
+ /**
282
+ * The parse function of the form.
283
+ */
101
284
  parse: QRL<(input: unknown) => Promise<v.SafeParseResult<TSchema>>>;
285
+ /**
286
+ * The submitting state of the form.
287
+ */
102
288
  isSubmitting: Signal<boolean>;
289
+ /**
290
+ * The submitted state of the form.
291
+ */
103
292
  isSubmitted: Signal<boolean>;
293
+ /**
294
+ * The validating state of the form.
295
+ */
104
296
  isValidating: Signal<boolean>;
105
297
  }
298
+ /**
299
+ * Base form store interface.
300
+ */
106
301
  interface BaseFormStore<TSchema extends Schema = Schema> {
107
- [INTERNAL]: InternalFormStore<TSchema>;
302
+ /**
303
+ * The internal form store.
304
+ *
305
+ * @internal
306
+ */
307
+ readonly [INTERNAL]: InternalFormStore<TSchema>;
108
308
  }
109
309
  //#endregion
110
310
  //#region src/types/path.d.ts
@@ -133,7 +333,7 @@ type KeyOf<TValue> = IsAny<TValue> extends true ? never : TValue extends readonl
133
333
  */
134
334
  type MergeUnion<T> = { [K in KeyOf<T>]: T extends Record<K, infer V> ? V : never };
135
335
  /**
136
- * Lazily evaluate only the first valid path segment based on the given value.
336
+ * Lazily evaluates only the first valid path segment based on the given value.
137
337
  */
138
338
  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;
139
339
  /**
@@ -154,248 +354,725 @@ type IsOrHasArray<TValue> = IsAny<TValue> extends true ? false : TValue extends
154
354
  */
155
355
  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;
156
356
  /**
157
- * Lazily evaluate only the first valid array path segment based on the given value.
357
+ * Lazily evaluates only the first valid array path segment based on the given value.
158
358
  */
159
359
  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;
160
360
  /**
161
- * Returns the path if valid, otherwise the first possible valid array path based on
162
- * the given value.
361
+ * Returns the path if valid, otherwise the first possible valid array path
362
+ * based on the given value.
163
363
  */
164
364
  type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<Required<TValue>, TPath> ? TPath : LazyArrayPath<Required<TValue>, TPath>;
165
365
  //#endregion
166
366
  //#region src/array/copyItemState/copyItemState.d.ts
167
367
  /**
168
- * Copies the deeply nested state (signal values) from one array item to another.
169
- * This includes the `isTouched`, `isDirty`, `startInput`, `input`, `startItems`, and `items` properties.
368
+ * Copies the deeply nested state (signal values) from one field store to
369
+ * another. This includes the `elements`, `errors`, `startInput`, `input`,
370
+ * `isTouched`, `isDirty`, and for arrays `startItems` and `items` properties.
170
371
  * Recursively walks through the field stores and copies all signal values.
171
372
  *
172
- * @param internalArrayStore - The field store of the array (not the array item)
173
- * @param fromIndex - The source index to copy from
174
- * @param toIndex - The destination index to copy to
373
+ * @param fromInternalFieldStore The source field store to copy from.
374
+ * @param toInternalFieldStore The destination field store to copy to.
175
375
  */
176
376
  //#endregion
177
377
  //#region ../../packages/methods/dist/index.qwik.d.ts
178
378
  //#region src/focus/focus.d.ts
379
+
380
+ /**
381
+ * Focus field config interface.
382
+ */
179
383
  interface FocusFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
180
- readonly form: BaseFormStore<TSchema>;
384
+ /**
385
+ * The path to the field to focus.
386
+ */
181
387
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
182
388
  }
183
- declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(config: FocusFieldConfig<TSchema, TFieldPath>): void;
389
+ /**
390
+ * Focuses the first input element of a field. This is useful for
391
+ * programmatically setting focus to a specific field, such as after
392
+ * validation errors or user interactions.
393
+ *
394
+ * @param form The form store containing the field.
395
+ * @param config The focus field configuration.
396
+ */
397
+ declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
184
398
  //#endregion
185
399
  //#region src/getAllErrors/getAllErrors.d.ts
400
+ /**
401
+ * Retrieves all error messages from all fields in the form by walking through
402
+ * the entire field store tree. This is useful for displaying a summary of all
403
+ * validation errors across the form.
404
+ *
405
+ * @param form The form store to retrieve errors from.
406
+ *
407
+ * @returns A non-empty array of error messages, or null if no errors exist.
408
+ */
186
409
  declare function getAllErrors(form: BaseFormStore): [string, ...string[]] | null;
187
410
  //#endregion
188
411
  //#region src/getErrors/getErrors.d.ts
412
+ /**
413
+ * Get form errors config interface.
414
+ */
189
415
  interface GetFormErrorsConfig {
416
+ /**
417
+ * The path to a field. Leave undefined to get form-level errors.
418
+ */
190
419
  readonly path?: undefined;
191
420
  }
421
+ /**
422
+ * Get field errors config interface.
423
+ */
192
424
  interface GetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
425
+ /**
426
+ * The path to the field to retrieve errors from.
427
+ */
193
428
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
194
429
  }
430
+ /**
431
+ * Retrieves error messages from the form. When called without a config,
432
+ * returns form-level errors. When called with a path, returns errors for
433
+ * that specific field.
434
+ *
435
+ * @param form The form store to retrieve errors from.
436
+ *
437
+ * @returns A non-empty array of error messages, or null if no errors exist.
438
+ */
195
439
  declare function getErrors<TSchema extends Schema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
440
+ /**
441
+ * Retrieves error messages from the form. When called without a config,
442
+ * returns form-level errors. When called with a path, returns errors for
443
+ * that specific field.
444
+ *
445
+ * @param form The form store to retrieve errors from.
446
+ * @param config The get errors configuration.
447
+ *
448
+ * @returns A non-empty array of error messages, or null if no errors exist.
449
+ */
196
450
  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;
197
451
  //#endregion
198
452
  //#region src/getInput/getInput.d.ts
453
+ /**
454
+ * Get form input config interface.
455
+ */
199
456
  interface GetFormInputConfig {
457
+ /**
458
+ * The path to a field. Leave undefined to get the entire form input.
459
+ */
200
460
  readonly path?: undefined;
201
461
  }
462
+ /**
463
+ * Get field input config interface.
464
+ */
202
465
  interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
466
+ /**
467
+ * The path to the field to retrieve input from.
468
+ */
203
469
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
204
470
  }
471
+ /**
472
+ * Retrieves the current input value of a specific field or the entire form.
473
+ * Returns a partial object as not all fields may have been set.
474
+ *
475
+ * @param form The form store to retrieve input from.
476
+ *
477
+ * @returns The partial input values of the form or the specified field.
478
+ */
205
479
  declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
480
+ /**
481
+ * Retrieves the current input value of a specific field or the entire form.
482
+ * Returns a partial object as not all fields may have been set.
483
+ *
484
+ * @param form The form store to retrieve input from.
485
+ * @param config The get input configuration.
486
+ *
487
+ * @returns The partial input values of the form or the specified field.
488
+ */
206
489
  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>>;
207
490
  //#endregion
208
491
  //#region src/handleSubmit/handleSubmit.d.ts
492
+ /**
493
+ * Creates a submit event handler for the form that prevents default browser
494
+ * submission, validates the form input, and calls the provided handler if
495
+ * validation succeeds. This is designed to be used with the form's onsubmit event.
496
+ *
497
+ * @param form The form store to handle submission for.
498
+ * @param handler The submit handler function called with validated output if validation succeeds.
499
+ *
500
+ * @returns A submit event handler function to attach to the form element.
501
+ */
209
502
  declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): (event: SubmitEvent) => void;
210
503
  //#endregion
211
504
  //#region src/insert/insert.d.ts
505
+ /**
506
+ * Insert array field config interface.
507
+ */
212
508
  interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
509
+ /**
510
+ * The path to the field array to insert into.
511
+ */
213
512
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
513
+ /**
514
+ * The index to insert the new item at. If undefined, appends to the end.
515
+ */
214
516
  readonly at?: number | undefined;
517
+ /**
518
+ * The partial initial input value for the new item.
519
+ */
215
520
  readonly initialInput?: DeepPartial<PathValue<v.InferInput<TSchema>, [...TFieldArrayPath, number]>> | undefined;
216
521
  }
522
+ /**
523
+ * Inserts a new item into a field array at the specified index. All items at
524
+ * or after the insertion point are shifted up by one index.
525
+ *
526
+ * @param form The form store containing the field array.
527
+ * @param config The insert configuration specifying the path, index, and initial value.
528
+ */
217
529
  declare function insert<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
218
530
  //#endregion
219
531
  //#region src/move/move.d.ts
532
+ /**
533
+ * Move array field config interface.
534
+ */
220
535
  interface MoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
536
+ /**
537
+ * The path to the field array to move an item within.
538
+ */
221
539
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
540
+ /**
541
+ * The index of the item to move from.
542
+ */
222
543
  readonly from: number;
544
+ /**
545
+ * The index to move the item to.
546
+ */
223
547
  readonly to: number;
224
548
  }
549
+ /**
550
+ * Moves an item from one index to another within a field array. All items
551
+ * between the source and destination indices are shifted accordingly.
552
+ *
553
+ * @param form The form store containing the field array.
554
+ * @param config The move configuration specifying the path and source/destination indices.
555
+ */
225
556
  declare function move<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: MoveConfig<TSchema, TFieldArrayPath>): void;
226
557
  //#endregion
227
558
  //#region src/remove/remove.d.ts
559
+ /**
560
+ * Remove array field config interface.
561
+ */
228
562
  interface RemoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
563
+ /**
564
+ * The path to the field array to remove an item from.
565
+ */
229
566
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
567
+ /**
568
+ * The index of the item to remove.
569
+ */
230
570
  readonly at: number;
231
571
  }
572
+ /**
573
+ * Removes an item from a field array at the specified index. All items after
574
+ * the removed item are shifted down by one index.
575
+ *
576
+ * @param form The form store containing the field array.
577
+ * @param config The remove configuration specifying the path and index.
578
+ */
232
579
  declare function remove<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: RemoveConfig<TSchema, TFieldArrayPath>): void;
233
580
  //#endregion
234
581
  //#region src/replace/replace.d.ts
582
+ /**
583
+ * Replace array field config interface.
584
+ */
235
585
  interface ReplaceConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
586
+ /**
587
+ * The path to the field array to replace an item within.
588
+ */
236
589
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
590
+ /**
591
+ * The index of the item to replace.
592
+ */
237
593
  readonly at: number;
594
+ /**
595
+ * The partial initial input value for the replacement item.
596
+ */
238
597
  readonly initialInput?: DeepPartial<PathValue<v.InferInput<TSchema>, [...TFieldArrayPath, number]>> | undefined;
239
598
  }
599
+ /**
600
+ * Replaces an item in a field array at the specified index with new initial input.
601
+ *
602
+ * @param form The form store containing the field array.
603
+ * @param config The replace configuration specifying the path, index, and initial input.
604
+ */
240
605
  declare function replace<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: ReplaceConfig<TSchema, TFieldArrayPath>): void;
241
606
  //#endregion
242
607
  //#region src/reset/reset.d.ts
608
+ /**
609
+ * Reset base config interface.
610
+ */
243
611
  interface ResetBaseConfig {
612
+ /**
613
+ * Whether to keep the current input values during reset. Defaults to false.
614
+ */
244
615
  readonly keepInput?: boolean | undefined;
616
+ /**
617
+ * Whether to keep the touched state during reset. Defaults to false.
618
+ */
245
619
  readonly keepTouched?: boolean | undefined;
620
+ /**
621
+ * Whether to keep the error messages during reset. Defaults to false.
622
+ */
246
623
  readonly keepErrors?: boolean | undefined;
247
624
  }
625
+ /**
626
+ * Reset form config interface.
627
+ */
248
628
  interface ResetFormConfig<TSchema extends Schema> extends ResetBaseConfig {
629
+ /**
630
+ * The path to a field. Leave undefined to reset the entire form.
631
+ */
249
632
  readonly path?: undefined;
633
+ /**
634
+ * The new initial input to reset to. If provided, replaces the form's
635
+ * initial input.
636
+ */
250
637
  readonly initialInput?: DeepPartial<v.InferInput<TSchema>> | undefined;
251
- readonly keepSubmitCount?: boolean | undefined;
638
+ /**
639
+ * Whether to keep the submitted state during reset. Defaults to false.
640
+ */
252
641
  readonly keepSubmitted?: boolean | undefined;
253
642
  }
643
+ /**
644
+ * Reset field config interface.
645
+ */
254
646
  interface ResetFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> extends ResetBaseConfig {
647
+ /**
648
+ * The path to the field to reset.
649
+ */
255
650
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
651
+ /**
652
+ * The new initial input to reset the field to. If provided, replaces the
653
+ * field's initial input.
654
+ */
256
655
  readonly initialInput?: DeepPartial<PathValue<v.InferInput<TSchema>, TFieldPath>>;
257
656
  }
657
+ /**
658
+ * Resets a specific field or the entire form to its initial state. Provides
659
+ * fine-grained control over which state to preserve during reset through the
660
+ * configuration options.
661
+ *
662
+ * @param form The form store to reset.
663
+ */
258
664
  declare function reset(form: BaseFormStore): void;
665
+ /**
666
+ * Resets a specific field or the entire form to its initial state. Provides
667
+ * fine-grained control over which state to preserve during reset through the
668
+ * configuration options.
669
+ *
670
+ * @param form The form store to reset.
671
+ * @param config The reset configuration specifying what to reset and what to keep.
672
+ */
259
673
  declare function reset<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? ResetFieldConfig<TSchema, TFieldPath> : ResetFormConfig<TSchema>): void;
260
674
  //#endregion
261
675
  //#region src/setErrors/setErrors.d.ts
676
+ /**
677
+ * Set form errors config interface.
678
+ */
262
679
  interface SetFormErrorsConfig {
680
+ /**
681
+ * The path to a field. Leave undefined to set form-level errors.
682
+ */
263
683
  readonly path?: undefined;
684
+ /**
685
+ * The error messages to set, or null to clear errors.
686
+ */
264
687
  readonly errors: [string, ...string[]] | null;
265
688
  }
689
+ /**
690
+ * Set field errors config interface.
691
+ */
266
692
  interface SetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
693
+ /**
694
+ * The path to the field to set errors on.
695
+ */
267
696
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
697
+ /**
698
+ * The error messages to set, or null to clear errors.
699
+ */
268
700
  readonly errors: [string, ...string[]] | null;
269
701
  }
702
+ /**
703
+ * Sets or clears error messages on the form or a specific field. This is
704
+ * useful for setting custom validation errors that don't come from schema
705
+ * validation.
706
+ *
707
+ * @param form The form store to set errors on.
708
+ * @param config The set errors configuration specifying the path and error messages.
709
+ */
270
710
  declare function setErrors<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldErrorsConfig<TSchema, TFieldPath> : SetFormErrorsConfig): void;
271
711
  //#endregion
272
712
  //#region src/setInput/setInput.d.ts
713
+ /**
714
+ * Set form input config interface.
715
+ */
273
716
  interface SetFormInputConfig<TSchema extends Schema> {
717
+ /**
718
+ * The path to a field. Leave undefined to set the entire form input.
719
+ */
274
720
  readonly path?: undefined;
721
+ /**
722
+ * The input value to set for the form.
723
+ */
275
724
  readonly input: v.InferInput<TSchema>;
276
725
  }
726
+ /**
727
+ * Set field input config interface.
728
+ */
277
729
  interface SetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
730
+ /**
731
+ * The path to the field to set input on.
732
+ */
278
733
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
734
+ /**
735
+ * The input value to set for the field.
736
+ */
279
737
  readonly input: PathValue<v.InferInput<TSchema>, TFieldPath>;
280
738
  }
739
+ /**
740
+ * Sets the input value of a specific field or the entire form. This updates
741
+ * the field value(s) and triggers validation if required by the form's
742
+ * validation mode.
743
+ *
744
+ * @param form The form store to set input on.
745
+ * @param config The set form input configuration specifying the new input values.
746
+ */
281
747
  declare function setInput<TSchema extends Schema>(form: BaseFormStore<TSchema>, config: SetFormInputConfig<TSchema>): void;
748
+ /**
749
+ * Sets the input value of a specific field or the entire form. This updates
750
+ * the field value(s) and triggers validation if required by the form's
751
+ * validation mode.
752
+ *
753
+ * @param form The form store to set input on.
754
+ * @param config The set input configuration specifying the path and new value.
755
+ */
282
756
  declare function setInput<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldInputConfig<TSchema, TFieldPath> : SetFormInputConfig<TSchema>): void;
283
757
  //#endregion
284
758
  //#region src/submit/submit.d.ts
759
+ /**
760
+ * Programmatically requests form submission by calling the native
761
+ * `requestSubmit()` method on the underlying form element.
762
+ *
763
+ * @param form The form store to submit.
764
+ */
285
765
  declare function submit(form: BaseFormStore): void;
286
766
  //#endregion
287
767
  //#region src/swap/swap.d.ts
768
+ /**
769
+ * Swap array field config interface.
770
+ */
288
771
  interface SwapConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
772
+ /**
773
+ * The path to the field array to swap items within.
774
+ */
289
775
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
776
+ /**
777
+ * The index of the first item to swap.
778
+ */
290
779
  readonly at: number;
780
+ /**
781
+ * The index of the second item to swap with the first.
782
+ */
291
783
  readonly and: number;
292
784
  }
785
+ /**
786
+ * Swaps two items in a field array by exchanging their positions.
787
+ *
788
+ * @param form The form store containing the field array.
789
+ * @param config The swap configuration specifying the path and indices to swap.
790
+ */
293
791
  declare function swap<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: SwapConfig<TSchema, TFieldArrayPath>): void;
294
792
  //#endregion
295
793
  //#region src/validate/validate.d.ts
794
+ /**
795
+ * Validate form config interface.
796
+ */
296
797
  interface ValidateFormConfig {
798
+ /**
799
+ * Whether to focus the first field with errors after validation. Defaults to false.
800
+ */
297
801
  readonly shouldFocus?: boolean | undefined;
298
802
  }
803
+ /**
804
+ * Validates the entire form input against its schema. Returns a safe parse result
805
+ * indicating success or failure with detailed issues. Optionally focuses the first
806
+ * field with validation errors.
807
+ *
808
+ * @param form The form store to validate.
809
+ * @param config The validate form configuration specifying focus behavior.
810
+ *
811
+ * @returns A promise resolving to the validation result.
812
+ */
299
813
  declare function validate<TSchema extends Schema>(form: BaseFormStore<TSchema>, config?: ValidateFormConfig): Promise<v.SafeParseResult<TSchema>>;
300
814
  //#endregion
301
815
  //#endregion
302
816
  //#region src/types/field.d.ts
303
817
  /**
304
- * Value type of the field element props.
818
+ * Field element props interface.
305
819
  */
306
820
  interface FieldElementProps {
821
+ /**
822
+ * The name attribute of the field element.
823
+ */
307
824
  readonly name: string;
825
+ /**
826
+ * Whether to autofocus the field element when there are errors.
827
+ */
308
828
  readonly autofocus: boolean;
829
+ /**
830
+ * The ref callback to register the field element.
831
+ */
309
832
  readonly ref: QRL<(element: FieldElement) => void>;
833
+ /**
834
+ * The focus event handler of the field element.
835
+ */
310
836
  readonly onFocus$: QRL<(event: FocusEvent, element: FieldElement) => void>;
837
+ /**
838
+ * The input event handler of the field element.
839
+ */
311
840
  readonly onInput$: QRL<(event: InputEvent, element: FieldElement) => void>;
841
+ /**
842
+ * The change event handler of the field element.
843
+ */
312
844
  readonly onChange$: QRL<(event: Event, element: FieldElement) => void>;
845
+ /**
846
+ * The blur event handler of the field element.
847
+ */
313
848
  readonly onBlur$: QRL<(event: FocusEvent, element: FieldElement) => void>;
314
849
  }
315
850
  /**
316
- * Value type of the field store.
851
+ * Field store interface.
317
852
  */
318
853
  interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
854
+ /**
855
+ * The path to the field within the form.
856
+ */
319
857
  readonly path: ReadonlySignal<ValidPath<v.InferInput<TSchema>, TFieldPath>>;
858
+ /**
859
+ * The current input value of the field.
860
+ */
320
861
  readonly input: ReadonlySignal<PartialValues<PathValue<v.InferInput<TSchema>, TFieldPath>>>;
862
+ /**
863
+ * The current error messages of the field.
864
+ */
321
865
  readonly errors: ReadonlySignal<[string, ...string[]] | null>;
866
+ /**
867
+ * Whether the field has been touched.
868
+ */
322
869
  readonly isTouched: ReadonlySignal<boolean>;
870
+ /**
871
+ * Whether the field input differs from its initial value.
872
+ */
323
873
  readonly isDirty: ReadonlySignal<boolean>;
874
+ /**
875
+ * Whether the field is valid according to the schema.
876
+ */
324
877
  readonly isValid: ReadonlySignal<boolean>;
878
+ /**
879
+ * The props to spread onto the field element for integration.
880
+ */
325
881
  readonly props: FieldElementProps;
326
882
  }
327
883
  /**
328
- * Value type of the field array store.
884
+ * Field array store interface.
329
885
  */
330
886
  interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
887
+ /**
888
+ * The path to the array field within the form.
889
+ */
331
890
  readonly path: ReadonlySignal<ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>>;
891
+ /**
892
+ * The item IDs of the array field.
893
+ */
332
894
  readonly items: ReadonlySignal<string[]>;
895
+ /**
896
+ * The current error messages of the field array.
897
+ */
333
898
  readonly errors: ReadonlySignal<[string, ...string[]] | null>;
899
+ /**
900
+ * Whether the field array has been touched.
901
+ */
334
902
  readonly isTouched: ReadonlySignal<boolean>;
903
+ /**
904
+ * Whether the field array input differs from its initial value.
905
+ */
335
906
  readonly isDirty: ReadonlySignal<boolean>;
907
+ /**
908
+ * Whether the field array is valid according to the schema.
909
+ */
336
910
  readonly isValid: ReadonlySignal<boolean>;
337
911
  }
338
912
  //#endregion
339
913
  //#region src/types/form.d.ts
914
+ /**
915
+ * Form store interface.
916
+ */
340
917
  interface FormStore<TSchema extends Schema = Schema> extends BaseFormStore<TSchema> {
918
+ /**
919
+ * Whether the form is currently submitting.
920
+ */
341
921
  readonly isSubmitting: ReadonlySignal<boolean>;
922
+ /**
923
+ * Whether the form has been submitted.
924
+ */
342
925
  readonly isSubmitted: ReadonlySignal<boolean>;
926
+ /**
927
+ * Whether the form is currently validating.
928
+ */
343
929
  readonly isValidating: ReadonlySignal<boolean>;
930
+ /**
931
+ * Whether any field in the form has been touched.
932
+ */
344
933
  readonly isTouched: ReadonlySignal<boolean>;
934
+ /**
935
+ * Whether any field in the form differs from its initial value.
936
+ */
345
937
  readonly isDirty: ReadonlySignal<boolean>;
938
+ /**
939
+ * Whether the form is valid according to the schema.
940
+ */
346
941
  readonly isValid: ReadonlySignal<boolean>;
942
+ /**
943
+ * The current error messages of the form.
944
+ *
945
+ * Hint: This property only contains validation errors at the root level
946
+ * of the form. To get all errors from all fields, use `getAllErrors`.
947
+ */
347
948
  readonly errors: ReadonlySignal<[string, ...string[]] | null>;
348
949
  }
349
950
  //#endregion
350
951
  //#region src/components/Field/Field.d.ts
351
952
  /**
352
- * Properties of the `Field` component.
953
+ * Field component props interface.
353
954
  */
354
955
  interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
956
+ /**
957
+ * The form store to which the field belongs.
958
+ */
355
959
  readonly of: FormStore<TSchema>;
960
+ /**
961
+ * The path to the field within the form schema.
962
+ */
356
963
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
964
+ /**
965
+ * The render function that receives the field store and returns JSX output.
966
+ */
357
967
  readonly render$: QRL<(store: FieldStore<TSchema, TFieldPath>) => JSXOutput>;
358
968
  }
359
969
  /**
360
- * Headless form field that provides reactive properties and state.
970
+ * Headless form field component that provides reactive properties and state.
971
+ * The field component takes a form store, path to field, and a render function
972
+ * that receives a field store to display field state and handle user interactions.
973
+ *
974
+ * @returns The UI of the field to be rendered.
361
975
  */
362
976
  declare const Field: <TSchema extends Schema, TFieldPath extends RequiredPath>(props: _qwik_dev_core_internal1.PublicProps<FieldProps<TSchema, TFieldPath>>, key: string | null, flags: number, dev?: _qwik_dev_core_internal1.DevJSX) => JSXOutput;
363
977
  //#endregion
364
978
  //#region src/components/FieldArray/FieldArray.d.ts
365
979
  /**
366
- * Properties of the `FieldArray` component.
980
+ * FieldArray component props interface.
367
981
  */
368
982
  interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
983
+ /**
984
+ * The form store to which the field array belongs.
985
+ */
369
986
  readonly of: FormStore<TSchema>;
987
+ /**
988
+ * The path to the field array within the form schema.
989
+ */
370
990
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
991
+ /**
992
+ * The render function that receives the field array store and returns JSX output.
993
+ */
371
994
  readonly render$: QRL<(store: FieldArrayStore<TSchema, TFieldArrayPath>) => JSXOutput>;
372
995
  }
373
996
  /**
374
- * Headless field array that provides reactive properties and state.
997
+ * Headless field array component that provides reactive properties and state.
998
+ * The field array component takes a form store, path to array field, and a render
999
+ * function that receives a field array store to manage array items and handle
1000
+ * array operations.
1001
+ *
1002
+ * @returns The UI of the field array to be rendered.
375
1003
  */
376
1004
  declare const FieldArray: <TSchema extends Schema, TFieldArrayPath extends RequiredPath>(props: _qwik_dev_core_internal1.PublicProps<FieldArrayProps<TSchema, TFieldArrayPath>>, key: string | null, flags: number, dev?: _qwik_dev_core_internal1.DevJSX) => JSXOutput;
377
1005
  //#endregion
378
1006
  //#region src/components/Form/Form.d.ts
1007
+ /**
1008
+ * Form component props type.
1009
+ */
379
1010
  type FormProps<TSchema extends Schema = Schema> = Omit<PropsOf<'form'>, 'onSubmit$' | 'noValidate'> & {
380
- of: FormStore<TSchema>;
381
- onSubmit$: QRL<SubmitHandler<TSchema>>;
1011
+ /**
1012
+ * The form store instance.
1013
+ */
1014
+ readonly of: FormStore<TSchema>;
1015
+ /**
1016
+ * The submit handler called when the form is submitted and validation succeeds.
1017
+ */
1018
+ readonly onSubmit$: QRL<SubmitHandler<TSchema>>;
382
1019
  };
1020
+ /**
1021
+ * Form component that manages form submission and applies internal state.
1022
+ * Wraps form element and passes submission events to the provided handler.
1023
+ *
1024
+ * @returns The a native form element.
1025
+ */
383
1026
  declare const Form: <TSchema extends Schema>(props: _qwik_dev_core_internal1.PublicProps<FormProps<TSchema>>, key: string | null, flags: number, dev?: _qwik_dev_core_internal1.DevJSX) => JSXOutput;
384
1027
  //#endregion
385
1028
  //#region src/hooks/useField/useField.d.ts
1029
+ /**
1030
+ * Use field config interface.
1031
+ */
386
1032
  interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
1033
+ /**
1034
+ * The path to the field within the form schema.
1035
+ */
387
1036
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
388
1037
  }
1038
+ /**
1039
+ * Creates a reactive field store of a specific field within a form store.
1040
+ *
1041
+ * @returns The field store with reactive properties and element props.
1042
+ */
389
1043
  declare function useField<TSchema extends Schema, TFieldPath extends RequiredPath>(form: FormStore<TSchema>, config: UseFieldConfig<TSchema, TFieldPath>): FieldStore<TSchema, TFieldPath>;
390
1044
  //#endregion
391
1045
  //#region src/hooks/useFieldArray/useFieldArray.d.ts
1046
+ /**
1047
+ * Use field array config interface.
1048
+ */
392
1049
  interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
1050
+ /**
1051
+ * The path to the field array within the form schema.
1052
+ */
393
1053
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
394
1054
  }
1055
+ /**
1056
+ * Creates a reactive field array store of a specific field array within a form store.
1057
+ *
1058
+ * @returns The field array store with reactive properties for array management.
1059
+ */
395
1060
  declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: FormStore<TSchema>, config: UseFieldArrayConfig<TSchema, TFieldArrayPath>): FieldArrayStore<TSchema, TFieldArrayPath>;
396
1061
  //#endregion
397
1062
  //#region src/hooks/useForm$/useForm$.d.ts
1063
+ /**
1064
+ * Creates a reactive form store from a form configuration. The form store
1065
+ * manages form state and provides reactive properties.
1066
+ *
1067
+ * @returns The form store with reactive properties.
1068
+ */
398
1069
  declare function useFormQrl<TSchema extends Schema>(configQrl: QRL<FormConfig<TSchema>>): FormStore<TSchema>;
1070
+ /**
1071
+ * Creates a reactive form store from a form configuration. The form store
1072
+ * manages form state and provides reactive properties.
1073
+ *
1074
+ * @returns The form store with reactive properties.
1075
+ */
399
1076
  declare const useForm$: <TSchema extends Schema>(qrl: FormConfig<TSchema>) => FormStore<TSchema>;
400
1077
  //#endregion
401
1078
  export { type DeepPartial, Field, FieldArray, FieldArrayProps, FieldArrayStore, type FieldElement, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, type FormConfig, FormProps, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MoveConfig, type PartialValues, type PathValue, RemoveConfig, ReplaceConfig, type RequiredPath, ResetFieldConfig, ResetFormConfig, type Schema, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, 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$, useFormQrl, validate };