@formisch/solid 0.9.5 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/dev.js +70 -16
- package/dist/dev.jsx +72 -15
- package/dist/index.d.ts +274 -69
- package/dist/index.js +70 -16
- package/dist/index.jsx +72 -15
- package/package.json +8 -4
package/dist/index.d.ts
CHANGED
|
@@ -3,13 +3,38 @@ import { JSX } from "solid-js";
|
|
|
3
3
|
|
|
4
4
|
//#region ../../packages/core/dist/index.solid.d.ts
|
|
5
5
|
|
|
6
|
-
//#region src/types/schema.d.ts
|
|
6
|
+
//#region src/types/schema/schema.d.ts
|
|
7
7
|
/**
|
|
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
|
-
//#region src/types/signal.d.ts
|
|
37
|
+
//#region src/types/signal/signal.d.ts
|
|
13
38
|
/**
|
|
14
39
|
* Signal interface.
|
|
15
40
|
*/
|
|
@@ -24,7 +49,7 @@ interface Signal<T> {
|
|
|
24
49
|
*/
|
|
25
50
|
|
|
26
51
|
//#endregion
|
|
27
|
-
//#region src/types/field.d.ts
|
|
52
|
+
//#region src/types/field/field.d.ts
|
|
28
53
|
/**
|
|
29
54
|
* Field element type.
|
|
30
55
|
*/
|
|
@@ -190,7 +215,7 @@ type InternalFieldStore = InternalArrayStore | InternalObjectStore | InternalVal
|
|
|
190
215
|
*/
|
|
191
216
|
declare const INTERNAL: "~internal";
|
|
192
217
|
//#endregion
|
|
193
|
-
//#region src/types/utils.d.ts
|
|
218
|
+
//#region src/types/utils/utils.d.ts
|
|
194
219
|
/**
|
|
195
220
|
* Checks if a type is `any`.
|
|
196
221
|
*/
|
|
@@ -216,7 +241,7 @@ type DeepPartial<TValue> = TValue extends Record<PropertyKey, unknown> | readonl
|
|
|
216
241
|
*/
|
|
217
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;
|
|
218
243
|
//#endregion
|
|
219
|
-
//#region src/types/form.d.ts
|
|
244
|
+
//#region src/types/form/form.d.ts
|
|
220
245
|
/**
|
|
221
246
|
* Validation mode type.
|
|
222
247
|
*/
|
|
@@ -224,7 +249,7 @@ type ValidationMode = "initial" | "touch" | "input" | "change" | "blur" | "submi
|
|
|
224
249
|
/**
|
|
225
250
|
* Form config interface.
|
|
226
251
|
*/
|
|
227
|
-
interface FormConfig<TSchema extends
|
|
252
|
+
interface FormConfig<TSchema extends FormSchema = FormSchema> {
|
|
228
253
|
/**
|
|
229
254
|
* The schema of the form.
|
|
230
255
|
*/
|
|
@@ -245,7 +270,7 @@ interface FormConfig<TSchema extends Schema = Schema> {
|
|
|
245
270
|
/**
|
|
246
271
|
* Internal form store interface.
|
|
247
272
|
*/
|
|
248
|
-
interface InternalFormStore<TSchema extends
|
|
273
|
+
interface InternalFormStore<TSchema extends FormSchema = FormSchema> extends InternalObjectStore {
|
|
249
274
|
/**
|
|
250
275
|
* The element of the form.
|
|
251
276
|
*/
|
|
@@ -282,7 +307,7 @@ interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObj
|
|
|
282
307
|
/**
|
|
283
308
|
* Base form store interface.
|
|
284
309
|
*/
|
|
285
|
-
interface BaseFormStore<TSchema extends
|
|
310
|
+
interface BaseFormStore<TSchema extends FormSchema = FormSchema> {
|
|
286
311
|
/**
|
|
287
312
|
* The internal form store.
|
|
288
313
|
*
|
|
@@ -293,13 +318,13 @@ interface BaseFormStore<TSchema extends Schema = Schema> {
|
|
|
293
318
|
/**
|
|
294
319
|
* Submit handler type.
|
|
295
320
|
*/
|
|
296
|
-
type SubmitHandler<TSchema extends
|
|
321
|
+
type SubmitHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>) => MaybePromise<unknown>;
|
|
297
322
|
/**
|
|
298
323
|
* Submit event handler type.
|
|
299
324
|
*/
|
|
300
|
-
type SubmitEventHandler<TSchema extends
|
|
325
|
+
type SubmitEventHandler<TSchema extends FormSchema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
|
|
301
326
|
//#endregion
|
|
302
|
-
//#region src/types/path.d.ts
|
|
327
|
+
//#region src/types/path/path.d.ts
|
|
303
328
|
/**
|
|
304
329
|
* Path key type.
|
|
305
330
|
*/
|
|
@@ -313,47 +338,115 @@ type Path = readonly PathKey[];
|
|
|
313
338
|
*/
|
|
314
339
|
type RequiredPath = readonly [PathKey, ...Path];
|
|
315
340
|
/**
|
|
316
|
-
* Extracts the exact keys of a tuple, array or object.
|
|
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`.
|
|
317
344
|
*/
|
|
318
|
-
type
|
|
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;
|
|
319
346
|
/**
|
|
320
|
-
*
|
|
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
|
+
* `{}`.
|
|
321
351
|
*
|
|
322
|
-
* Hint: This is necessary to make
|
|
323
|
-
* properties that do not exist in all union options are not
|
|
324
|
-
* and result in "any" when accessed.
|
|
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.
|
|
325
355
|
*/
|
|
326
|
-
type
|
|
356
|
+
type PropertiesOf<TValue> = { [TKey in ExactKeysOf<TValue>]: TValue extends Record<TKey, infer TItem> ? TItem : never };
|
|
327
357
|
/**
|
|
328
358
|
* Lazily evaluates only the first valid path segment based on the given value.
|
|
329
359
|
*/
|
|
330
|
-
type LazyPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValidPath : TPathToCheck extends readonly [infer TFirstKey extends
|
|
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;
|
|
331
361
|
/**
|
|
332
362
|
* Returns the path if valid, otherwise the first possible valid path based on
|
|
333
363
|
* the given value.
|
|
334
364
|
*/
|
|
335
365
|
type ValidPath<TValue, TPath extends RequiredPath> = TPath extends LazyPath<Required<TValue>, TPath> ? TPath : LazyPath<Required<TValue>, TPath>;
|
|
336
366
|
/**
|
|
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`.
|
|
373
|
+
*/
|
|
374
|
+
type IsExactOptionalProps = Required<{
|
|
375
|
+
key?: undefined;
|
|
376
|
+
}>["key"] extends never ? false : true;
|
|
377
|
+
/**
|
|
378
|
+
* Like the built-in `Required<T>`, but preserves `| undefined` in two
|
|
379
|
+
* places where `Required<T>` strips it:
|
|
380
|
+
*
|
|
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
|
+
/**
|
|
337
392
|
* Extracts the value type at the given path.
|
|
338
393
|
*/
|
|
339
|
-
type PathValue<TValue, TPath extends Path> = TPath extends readonly [infer TKey, ...infer TRest extends Path] ? TKey extends
|
|
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;
|
|
340
395
|
/**
|
|
341
|
-
* Checks
|
|
396
|
+
* Checks whether a value is an array or contains one anywhere in its shape.
|
|
397
|
+
*
|
|
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`.
|
|
342
406
|
*/
|
|
343
|
-
type IsOrHasArray<TValue> = IsAny<TValue> extends true ? false : TValue extends readonly unknown[] ? true : TValue extends Record<
|
|
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;
|
|
344
408
|
/**
|
|
345
409
|
* Extracts the exact keys of a tuple, array or object that contain arrays.
|
|
346
410
|
*/
|
|
347
|
-
type
|
|
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 };
|
|
348
419
|
/**
|
|
349
420
|
* Lazily evaluates only the first valid array path segment based on the given value.
|
|
350
421
|
*/
|
|
351
|
-
type LazyArrayPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValue extends readonly unknown[] ? TValidPath : readonly [...TValidPath,
|
|
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;
|
|
352
423
|
/**
|
|
353
424
|
* Returns the path if valid, otherwise the first possible valid array path
|
|
354
425
|
* based on the given value.
|
|
355
426
|
*/
|
|
356
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.
|
|
438
|
+
*
|
|
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.
|
|
442
|
+
*
|
|
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.
|
|
448
|
+
*/
|
|
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;
|
|
357
450
|
//#endregion
|
|
358
451
|
//#region src/array/copyItemState/copyItemState.d.ts
|
|
359
452
|
/**
|
|
@@ -372,7 +465,7 @@ type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArra
|
|
|
372
465
|
/**
|
|
373
466
|
* Focus field config interface.
|
|
374
467
|
*/
|
|
375
|
-
interface FocusFieldConfig<TSchema extends
|
|
468
|
+
interface FocusFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
|
|
376
469
|
/**
|
|
377
470
|
* The path to the field to focus.
|
|
378
471
|
*/
|
|
@@ -386,7 +479,7 @@ interface FocusFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPa
|
|
|
386
479
|
* @param form The form store containing the field.
|
|
387
480
|
* @param config The focus field configuration.
|
|
388
481
|
*/
|
|
389
|
-
declare function focus<TSchema extends
|
|
482
|
+
declare function focus<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: FocusFieldConfig<TSchema, TFieldPath>): void;
|
|
390
483
|
//#endregion
|
|
391
484
|
//#region src/getAllErrors/getAllErrors.d.ts
|
|
392
485
|
/**
|
|
@@ -400,6 +493,93 @@ declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(
|
|
|
400
493
|
*/
|
|
401
494
|
declare function getAllErrors(form: BaseFormStore): [string, ...string[]] | null;
|
|
402
495
|
//#endregion
|
|
496
|
+
//#region src/getDirtyInput/getDirtyInput.d.ts
|
|
497
|
+
/**
|
|
498
|
+
* Get form dirty input config interface.
|
|
499
|
+
*/
|
|
500
|
+
interface GetFormDirtyInputConfig {
|
|
501
|
+
/**
|
|
502
|
+
* The path to a field. Leave undefined to get the dirty input of the entire
|
|
503
|
+
* form.
|
|
504
|
+
*/
|
|
505
|
+
readonly path?: undefined;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Get field dirty input config interface.
|
|
509
|
+
*/
|
|
510
|
+
interface GetFieldDirtyInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
|
|
511
|
+
/**
|
|
512
|
+
* The path to the field to retrieve the dirty input from.
|
|
513
|
+
*/
|
|
514
|
+
readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Retrieves only the dirty input values of a specific field or the entire
|
|
518
|
+
* form. Arrays are treated as atomic and returned in full if any item is
|
|
519
|
+
* dirty, while object keys without a dirty descendant are omitted. Returns
|
|
520
|
+
* `undefined` if no field in the inspected subtree is dirty.
|
|
521
|
+
*
|
|
522
|
+
* @param form The form store to retrieve dirty input from.
|
|
523
|
+
*
|
|
524
|
+
* @returns The dirty input of the form or specified field, or `undefined`.
|
|
525
|
+
*/
|
|
526
|
+
declare function getDirtyInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): DeepPartial<v.InferInput<TSchema>> | undefined;
|
|
527
|
+
/**
|
|
528
|
+
* Retrieves only the dirty input values of a specific field or the entire
|
|
529
|
+
* form. Arrays are treated as atomic and returned in full if any item is
|
|
530
|
+
* dirty, while object keys without a dirty descendant are omitted. Returns
|
|
531
|
+
* `undefined` if no field in the inspected subtree is dirty.
|
|
532
|
+
*
|
|
533
|
+
* @param form The form store to retrieve dirty input from.
|
|
534
|
+
* @param config The get dirty input configuration.
|
|
535
|
+
*
|
|
536
|
+
* @returns The dirty input of the form or specified field, or `undefined`.
|
|
537
|
+
*/
|
|
538
|
+
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;
|
|
539
|
+
//#endregion
|
|
540
|
+
//#region src/getDirtyPaths/getDirtyPaths.d.ts
|
|
541
|
+
/**
|
|
542
|
+
* Get form dirty paths config interface.
|
|
543
|
+
*/
|
|
544
|
+
interface GetFormDirtyPathsConfig {
|
|
545
|
+
/**
|
|
546
|
+
* The path to a field. Leave undefined to inspect the entire form.
|
|
547
|
+
*/
|
|
548
|
+
readonly path?: undefined;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Get field dirty paths config interface.
|
|
552
|
+
*/
|
|
553
|
+
interface GetFieldDirtyPathsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
|
|
554
|
+
/**
|
|
555
|
+
* The path to the field to inspect.
|
|
556
|
+
*/
|
|
557
|
+
readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Returns a list of paths to the dirty fields of a specific field or the
|
|
561
|
+
* entire form. Arrays are treated as atomic and contribute only their own
|
|
562
|
+
* path if any item is dirty, while object branches are recursed into. Returns
|
|
563
|
+
* an empty list if no field in the inspected subtree is dirty.
|
|
564
|
+
*
|
|
565
|
+
* @param form The form store to inspect.
|
|
566
|
+
*
|
|
567
|
+
* @returns The list of paths to the dirty fields.
|
|
568
|
+
*/
|
|
569
|
+
declare function getDirtyPaths<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): DirtyPath<v.InferInput<TSchema>>[];
|
|
570
|
+
/**
|
|
571
|
+
* Returns a list of paths to the dirty fields of a specific field or the
|
|
572
|
+
* entire form. Arrays are treated as atomic and contribute only their own
|
|
573
|
+
* path if any item is dirty, while object branches are recursed into. Returns
|
|
574
|
+
* an empty list if no field in the inspected subtree is dirty.
|
|
575
|
+
*
|
|
576
|
+
* @param form The form store to inspect.
|
|
577
|
+
* @param config The get dirty paths configuration.
|
|
578
|
+
*
|
|
579
|
+
* @returns The list of paths to the dirty fields.
|
|
580
|
+
*/
|
|
581
|
+
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>>[];
|
|
582
|
+
//#endregion
|
|
403
583
|
//#region src/getErrors/getErrors.d.ts
|
|
404
584
|
/**
|
|
405
585
|
* Get form errors config interface.
|
|
@@ -413,7 +593,7 @@ interface GetFormErrorsConfig {
|
|
|
413
593
|
/**
|
|
414
594
|
* Get field errors config interface.
|
|
415
595
|
*/
|
|
416
|
-
interface GetFieldErrorsConfig<TSchema extends
|
|
596
|
+
interface GetFieldErrorsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
|
|
417
597
|
/**
|
|
418
598
|
* The path to the field to retrieve errors from.
|
|
419
599
|
*/
|
|
@@ -428,7 +608,7 @@ interface GetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends Requir
|
|
|
428
608
|
*
|
|
429
609
|
* @returns A non-empty array of error messages, or null if no errors exist.
|
|
430
610
|
*/
|
|
431
|
-
declare function getErrors<TSchema extends
|
|
611
|
+
declare function getErrors<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
|
|
432
612
|
/**
|
|
433
613
|
* Retrieves error messages from the form. When called without a config,
|
|
434
614
|
* returns form-level errors. When called with a path, returns errors for
|
|
@@ -439,7 +619,7 @@ declare function getErrors<TSchema extends Schema>(form: BaseFormStore<TSchema>)
|
|
|
439
619
|
*
|
|
440
620
|
* @returns A non-empty array of error messages, or null if no errors exist.
|
|
441
621
|
*/
|
|
442
|
-
declare function getErrors<TSchema extends
|
|
622
|
+
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;
|
|
443
623
|
//#endregion
|
|
444
624
|
//#region src/getInput/getInput.d.ts
|
|
445
625
|
/**
|
|
@@ -454,7 +634,7 @@ interface GetFormInputConfig {
|
|
|
454
634
|
/**
|
|
455
635
|
* Get field input config interface.
|
|
456
636
|
*/
|
|
457
|
-
interface GetFieldInputConfig<TSchema extends
|
|
637
|
+
interface GetFieldInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
|
|
458
638
|
/**
|
|
459
639
|
* The path to the field to retrieve input from.
|
|
460
640
|
*/
|
|
@@ -468,7 +648,7 @@ interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends Require
|
|
|
468
648
|
*
|
|
469
649
|
* @returns The partial input values of the form or the specified field.
|
|
470
650
|
*/
|
|
471
|
-
declare function getInput<TSchema extends
|
|
651
|
+
declare function getInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
|
|
472
652
|
/**
|
|
473
653
|
* Retrieves the current input value of a specific field or the entire form.
|
|
474
654
|
* Returns a partial object as not all fields may have been set.
|
|
@@ -478,7 +658,7 @@ declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>):
|
|
|
478
658
|
*
|
|
479
659
|
* @returns The partial input values of the form or the specified field.
|
|
480
660
|
*/
|
|
481
|
-
declare function getInput<TSchema extends
|
|
661
|
+
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>>;
|
|
482
662
|
//#endregion
|
|
483
663
|
//#region src/handleSubmit/handleSubmit.d.ts
|
|
484
664
|
/**
|
|
@@ -491,7 +671,7 @@ declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPat
|
|
|
491
671
|
*
|
|
492
672
|
* @returns A submit event handler function to attach to the form element.
|
|
493
673
|
*/
|
|
494
|
-
declare function handleSubmit<TSchema extends
|
|
674
|
+
declare function handleSubmit<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): () => Promise<void>;
|
|
495
675
|
/**
|
|
496
676
|
* Creates a submit event handler for the form that prevents default browser
|
|
497
677
|
* submission, validates the form input, and calls the provided handler if
|
|
@@ -502,13 +682,13 @@ declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchem
|
|
|
502
682
|
*
|
|
503
683
|
* @returns A submit event handler function to attach to the form element.
|
|
504
684
|
*/
|
|
505
|
-
declare function handleSubmit<TSchema extends
|
|
685
|
+
declare function handleSubmit<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, handler: SubmitEventHandler<TSchema>): (event: SubmitEvent) => Promise<void>;
|
|
506
686
|
//#endregion
|
|
507
687
|
//#region src/insert/insert.d.ts
|
|
508
688
|
/**
|
|
509
689
|
* Insert array field config interface.
|
|
510
690
|
*/
|
|
511
|
-
interface InsertConfig<TSchema extends
|
|
691
|
+
interface InsertConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
|
|
512
692
|
/**
|
|
513
693
|
* The path to the field array to insert into.
|
|
514
694
|
*/
|
|
@@ -529,13 +709,13 @@ interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredP
|
|
|
529
709
|
* @param form The form store containing the field array.
|
|
530
710
|
* @param config The insert configuration specifying the path, index, and initial value.
|
|
531
711
|
*/
|
|
532
|
-
declare function insert<TSchema extends
|
|
712
|
+
declare function insert<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
|
|
533
713
|
//#endregion
|
|
534
714
|
//#region src/move/move.d.ts
|
|
535
715
|
/**
|
|
536
716
|
* Move array field config interface.
|
|
537
717
|
*/
|
|
538
|
-
interface MoveConfig<TSchema extends
|
|
718
|
+
interface MoveConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
|
|
539
719
|
/**
|
|
540
720
|
* The path to the field array to move an item within.
|
|
541
721
|
*/
|
|
@@ -556,13 +736,38 @@ interface MoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPat
|
|
|
556
736
|
* @param form The form store containing the field array.
|
|
557
737
|
* @param config The move configuration specifying the path and source/destination indices.
|
|
558
738
|
*/
|
|
559
|
-
declare function move<TSchema extends
|
|
739
|
+
declare function move<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: MoveConfig<TSchema, TFieldArrayPath>): void;
|
|
740
|
+
//#endregion
|
|
741
|
+
//#region src/pickDirty/pickDirty.d.ts
|
|
742
|
+
/**
|
|
743
|
+
* Pick dirty config interface.
|
|
744
|
+
*/
|
|
745
|
+
interface PickDirtyConfig<TValue extends object> {
|
|
746
|
+
/**
|
|
747
|
+
* The value to filter down to its dirty parts. Must be structurally
|
|
748
|
+
* compatible with the form's schema.
|
|
749
|
+
*/
|
|
750
|
+
readonly from: TValue;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Picks only the dirty parts of the given value, using the form's dirty fields
|
|
754
|
+
* as a structural mask. Arrays are treated as atomic and object keys without a
|
|
755
|
+
* dirty descendant are omitted. Returns `undefined` if no field is dirty.
|
|
756
|
+
* Useful for filtering a validated output down to its changed parts before
|
|
757
|
+
* submitting.
|
|
758
|
+
*
|
|
759
|
+
* @param form The form store providing the dirty mask.
|
|
760
|
+
* @param config The pick dirty configuration.
|
|
761
|
+
*
|
|
762
|
+
* @returns The dirty parts of the value, or `undefined`.
|
|
763
|
+
*/
|
|
764
|
+
declare function pickDirty<TSchema extends FormSchema, TValue extends object>(form: BaseFormStore<TSchema>, config: PickDirtyConfig<TValue>): DeepPartial<TValue> | undefined;
|
|
560
765
|
//#endregion
|
|
561
766
|
//#region src/remove/remove.d.ts
|
|
562
767
|
/**
|
|
563
768
|
* Remove array field config interface.
|
|
564
769
|
*/
|
|
565
|
-
interface RemoveConfig<TSchema extends
|
|
770
|
+
interface RemoveConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
|
|
566
771
|
/**
|
|
567
772
|
* The path to the field array to remove an item from.
|
|
568
773
|
*/
|
|
@@ -579,13 +784,13 @@ interface RemoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredP
|
|
|
579
784
|
* @param form The form store containing the field array.
|
|
580
785
|
* @param config The remove configuration specifying the path and index.
|
|
581
786
|
*/
|
|
582
|
-
declare function remove<TSchema extends
|
|
787
|
+
declare function remove<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: RemoveConfig<TSchema, TFieldArrayPath>): void;
|
|
583
788
|
//#endregion
|
|
584
789
|
//#region src/replace/replace.d.ts
|
|
585
790
|
/**
|
|
586
791
|
* Replace array field config interface.
|
|
587
792
|
*/
|
|
588
|
-
interface ReplaceConfig<TSchema extends
|
|
793
|
+
interface ReplaceConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
|
|
589
794
|
/**
|
|
590
795
|
* The path to the field array to replace an item within.
|
|
591
796
|
*/
|
|
@@ -605,7 +810,7 @@ interface ReplaceConfig<TSchema extends Schema, TFieldArrayPath extends Required
|
|
|
605
810
|
* @param form The form store containing the field array.
|
|
606
811
|
* @param config The replace configuration specifying the path, index, and initial input.
|
|
607
812
|
*/
|
|
608
|
-
declare function replace<TSchema extends
|
|
813
|
+
declare function replace<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: ReplaceConfig<TSchema, TFieldArrayPath>): void;
|
|
609
814
|
//#endregion
|
|
610
815
|
//#region src/reset/reset.d.ts
|
|
611
816
|
/**
|
|
@@ -628,7 +833,7 @@ interface ResetBaseConfig {
|
|
|
628
833
|
/**
|
|
629
834
|
* Reset form config interface.
|
|
630
835
|
*/
|
|
631
|
-
interface ResetFormConfig<TSchema extends
|
|
836
|
+
interface ResetFormConfig<TSchema extends FormSchema> extends ResetBaseConfig {
|
|
632
837
|
/**
|
|
633
838
|
* The path to a field. Leave undefined to reset the entire form.
|
|
634
839
|
*/
|
|
@@ -646,7 +851,7 @@ interface ResetFormConfig<TSchema extends Schema> extends ResetBaseConfig {
|
|
|
646
851
|
/**
|
|
647
852
|
* Reset field config interface.
|
|
648
853
|
*/
|
|
649
|
-
interface ResetFieldConfig<TSchema extends
|
|
854
|
+
interface ResetFieldConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> extends ResetBaseConfig {
|
|
650
855
|
/**
|
|
651
856
|
* The path to the field to reset.
|
|
652
857
|
*/
|
|
@@ -673,7 +878,7 @@ declare function reset(form: BaseFormStore): void;
|
|
|
673
878
|
* @param form The form store to reset.
|
|
674
879
|
* @param config The reset configuration specifying what to reset and what to keep.
|
|
675
880
|
*/
|
|
676
|
-
declare function reset<TSchema extends
|
|
881
|
+
declare function reset<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? ResetFieldConfig<TSchema, TFieldPath> : ResetFormConfig<TSchema>): void;
|
|
677
882
|
//#endregion
|
|
678
883
|
//#region src/setErrors/setErrors.d.ts
|
|
679
884
|
/**
|
|
@@ -692,7 +897,7 @@ interface SetFormErrorsConfig {
|
|
|
692
897
|
/**
|
|
693
898
|
* Set field errors config interface.
|
|
694
899
|
*/
|
|
695
|
-
interface SetFieldErrorsConfig<TSchema extends
|
|
900
|
+
interface SetFieldErrorsConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
|
|
696
901
|
/**
|
|
697
902
|
* The path to the field to set errors on.
|
|
698
903
|
*/
|
|
@@ -710,13 +915,13 @@ interface SetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends Requir
|
|
|
710
915
|
* @param form The form store to set errors on.
|
|
711
916
|
* @param config The set errors configuration specifying the path and error messages.
|
|
712
917
|
*/
|
|
713
|
-
declare function setErrors<TSchema extends
|
|
918
|
+
declare function setErrors<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldErrorsConfig<TSchema, TFieldPath> : SetFormErrorsConfig): void;
|
|
714
919
|
//#endregion
|
|
715
920
|
//#region src/setInput/setInput.d.ts
|
|
716
921
|
/**
|
|
717
922
|
* Set form input config interface.
|
|
718
923
|
*/
|
|
719
|
-
interface SetFormInputConfig<TSchema extends
|
|
924
|
+
interface SetFormInputConfig<TSchema extends FormSchema> {
|
|
720
925
|
/**
|
|
721
926
|
* The path to a field. Leave undefined to set the entire form input.
|
|
722
927
|
*/
|
|
@@ -729,7 +934,7 @@ interface SetFormInputConfig<TSchema extends Schema> {
|
|
|
729
934
|
/**
|
|
730
935
|
* Set field input config interface.
|
|
731
936
|
*/
|
|
732
|
-
interface SetFieldInputConfig<TSchema extends
|
|
937
|
+
interface SetFieldInputConfig<TSchema extends FormSchema, TFieldPath extends RequiredPath> {
|
|
733
938
|
/**
|
|
734
939
|
* The path to the field to set input on.
|
|
735
940
|
*/
|
|
@@ -747,7 +952,7 @@ interface SetFieldInputConfig<TSchema extends Schema, TFieldPath extends Require
|
|
|
747
952
|
* @param form The form store to set input on.
|
|
748
953
|
* @param config The set form input configuration specifying the new input values.
|
|
749
954
|
*/
|
|
750
|
-
declare function setInput<TSchema extends
|
|
955
|
+
declare function setInput<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, config: SetFormInputConfig<TSchema>): void;
|
|
751
956
|
/**
|
|
752
957
|
* Sets the input value of a specific field or the entire form. This updates
|
|
753
958
|
* the field value(s) and triggers validation if required by the form's
|
|
@@ -756,7 +961,7 @@ declare function setInput<TSchema extends Schema>(form: BaseFormStore<TSchema>,
|
|
|
756
961
|
* @param form The form store to set input on.
|
|
757
962
|
* @param config The set input configuration specifying the path and new value.
|
|
758
963
|
*/
|
|
759
|
-
declare function setInput<TSchema extends
|
|
964
|
+
declare function setInput<TSchema extends FormSchema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldInputConfig<TSchema, TFieldPath> : SetFormInputConfig<TSchema>): void;
|
|
760
965
|
//#endregion
|
|
761
966
|
//#region src/submit/submit.d.ts
|
|
762
967
|
/**
|
|
@@ -771,7 +976,7 @@ declare function submit(form: BaseFormStore): void;
|
|
|
771
976
|
/**
|
|
772
977
|
* Swap array field config interface.
|
|
773
978
|
*/
|
|
774
|
-
interface SwapConfig<TSchema extends
|
|
979
|
+
interface SwapConfig<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath> {
|
|
775
980
|
/**
|
|
776
981
|
* The path to the field array to swap items within.
|
|
777
982
|
*/
|
|
@@ -791,7 +996,7 @@ interface SwapConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPat
|
|
|
791
996
|
* @param form The form store containing the field array.
|
|
792
997
|
* @param config The swap configuration specifying the path and indices to swap.
|
|
793
998
|
*/
|
|
794
|
-
declare function swap<TSchema extends
|
|
999
|
+
declare function swap<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: SwapConfig<TSchema, TFieldArrayPath>): void;
|
|
795
1000
|
//#endregion
|
|
796
1001
|
//#region src/validate/validate.d.ts
|
|
797
1002
|
/**
|
|
@@ -813,7 +1018,7 @@ interface ValidateFormConfig {
|
|
|
813
1018
|
*
|
|
814
1019
|
* @returns A promise resolving to the validation result.
|
|
815
1020
|
*/
|
|
816
|
-
declare function validate<TSchema extends
|
|
1021
|
+
declare function validate<TSchema extends FormSchema>(form: BaseFormStore<TSchema>, config?: ValidateFormConfig): Promise<v.SafeParseResult<TSchema>>;
|
|
817
1022
|
//#endregion
|
|
818
1023
|
//#endregion
|
|
819
1024
|
//#region src/types/field.d.ts
|
|
@@ -853,7 +1058,7 @@ interface FieldElementProps {
|
|
|
853
1058
|
/**
|
|
854
1059
|
* Field store interface.
|
|
855
1060
|
*/
|
|
856
|
-
interface FieldStore<TSchema extends
|
|
1061
|
+
interface FieldStore<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
|
|
857
1062
|
/**
|
|
858
1063
|
* The path to the field within the form.
|
|
859
1064
|
*/
|
|
@@ -890,7 +1095,7 @@ interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends Require
|
|
|
890
1095
|
/**
|
|
891
1096
|
* Field array store interface.
|
|
892
1097
|
*/
|
|
893
|
-
interface FieldArrayStore<TSchema extends
|
|
1098
|
+
interface FieldArrayStore<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
|
|
894
1099
|
/**
|
|
895
1100
|
* The path to the array field within the form.
|
|
896
1101
|
*/
|
|
@@ -921,7 +1126,7 @@ interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath exten
|
|
|
921
1126
|
/**
|
|
922
1127
|
* Form store interface.
|
|
923
1128
|
*/
|
|
924
|
-
interface FormStore<TSchema extends
|
|
1129
|
+
interface FormStore<TSchema extends FormSchema = FormSchema> extends BaseFormStore<TSchema> {
|
|
925
1130
|
/**
|
|
926
1131
|
* Whether the form is currently submitting.
|
|
927
1132
|
*/
|
|
@@ -965,7 +1170,7 @@ type MaybeGetter<TValue> = TValue | (() => TValue);
|
|
|
965
1170
|
/**
|
|
966
1171
|
* Field component props interface.
|
|
967
1172
|
*/
|
|
968
|
-
interface FieldProps<TSchema extends
|
|
1173
|
+
interface FieldProps<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
|
|
969
1174
|
/**
|
|
970
1175
|
* The form store to which the field belongs.
|
|
971
1176
|
*/
|
|
@@ -988,13 +1193,13 @@ interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends Require
|
|
|
988
1193
|
*
|
|
989
1194
|
* @returns The UI of the field to be rendered.
|
|
990
1195
|
*/
|
|
991
|
-
declare function Field<TSchema extends
|
|
1196
|
+
declare function Field<TSchema extends FormSchema, TFieldPath extends RequiredPath>(props: FieldProps<TSchema, TFieldPath>): JSX.Element;
|
|
992
1197
|
//#endregion
|
|
993
1198
|
//#region src/components/FieldArray/FieldArray.d.ts
|
|
994
1199
|
/**
|
|
995
1200
|
* FieldArray component props interface.
|
|
996
1201
|
*/
|
|
997
|
-
interface FieldArrayProps<TSchema extends
|
|
1202
|
+
interface FieldArrayProps<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
|
|
998
1203
|
/**
|
|
999
1204
|
* The form store to which the field array belongs.
|
|
1000
1205
|
*/
|
|
@@ -1017,13 +1222,13 @@ interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath exten
|
|
|
1017
1222
|
*
|
|
1018
1223
|
* @returns The UI of the field array to be rendered.
|
|
1019
1224
|
*/
|
|
1020
|
-
declare function FieldArray<TSchema extends
|
|
1225
|
+
declare function FieldArray<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(props: FieldArrayProps<TSchema, TFieldArrayPath>): JSX.Element;
|
|
1021
1226
|
//#endregion
|
|
1022
1227
|
//#region src/components/Form/Form.d.ts
|
|
1023
1228
|
/**
|
|
1024
1229
|
* Form component props type.
|
|
1025
1230
|
*/
|
|
1026
|
-
type FormProps<TSchema extends
|
|
1231
|
+
type FormProps<TSchema extends FormSchema = FormSchema> = Omit<JSX.FormHTMLAttributes<HTMLFormElement>, "onSubmit" | "novalidate" | "noValidate"> & {
|
|
1027
1232
|
/**
|
|
1028
1233
|
* The form store instance.
|
|
1029
1234
|
*/
|
|
@@ -1045,7 +1250,7 @@ type FormProps<TSchema extends Schema = Schema> = Omit<JSX.FormHTMLAttributes<HT
|
|
|
1045
1250
|
*
|
|
1046
1251
|
* @returns The a native form element.
|
|
1047
1252
|
*/
|
|
1048
|
-
declare function Form<TSchema extends
|
|
1253
|
+
declare function Form<TSchema extends FormSchema>(props: FormProps<TSchema>): JSX.Element;
|
|
1049
1254
|
//#endregion
|
|
1050
1255
|
//#region src/primitives/createForm/createForm.d.ts
|
|
1051
1256
|
/**
|
|
@@ -1056,13 +1261,13 @@ declare function Form<TSchema extends Schema>(props: FormProps<TSchema>): JSX.El
|
|
|
1056
1261
|
*
|
|
1057
1262
|
* @returns The form store with reactive properties.
|
|
1058
1263
|
*/
|
|
1059
|
-
declare function createForm<TSchema extends
|
|
1264
|
+
declare function createForm<TSchema extends FormSchema>(config: FormConfig<TSchema>): FormStore<TSchema>;
|
|
1060
1265
|
//#endregion
|
|
1061
1266
|
//#region src/primitives/useField/useField.d.ts
|
|
1062
1267
|
/**
|
|
1063
1268
|
* Use field config interface.
|
|
1064
1269
|
*/
|
|
1065
|
-
interface UseFieldConfig<TSchema extends
|
|
1270
|
+
interface UseFieldConfig<TSchema extends FormSchema = FormSchema, TFieldPath extends RequiredPath = RequiredPath> {
|
|
1066
1271
|
/**
|
|
1067
1272
|
* The path to the field within the form schema.
|
|
1068
1273
|
*/
|
|
@@ -1076,13 +1281,13 @@ interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends Req
|
|
|
1076
1281
|
*
|
|
1077
1282
|
* @returns The field store with reactive properties and element props.
|
|
1078
1283
|
*/
|
|
1079
|
-
declare function useField<TSchema extends
|
|
1284
|
+
declare function useField<TSchema extends FormSchema, TFieldPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldConfig<TSchema, TFieldPath>>): FieldStore<TSchema, TFieldPath>;
|
|
1080
1285
|
//#endregion
|
|
1081
1286
|
//#region src/primitives/useFieldArray/useFieldArray.d.ts
|
|
1082
1287
|
/**
|
|
1083
1288
|
* Use field array config interface.
|
|
1084
1289
|
*/
|
|
1085
|
-
interface UseFieldArrayConfig<TSchema extends
|
|
1290
|
+
interface UseFieldArrayConfig<TSchema extends FormSchema = FormSchema, TFieldArrayPath extends RequiredPath = RequiredPath> {
|
|
1086
1291
|
/**
|
|
1087
1292
|
* The path to the field array within the form schema.
|
|
1088
1293
|
*/
|
|
@@ -1096,6 +1301,6 @@ interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath e
|
|
|
1096
1301
|
*
|
|
1097
1302
|
* @returns The field array store with reactive properties for array management.
|
|
1098
1303
|
*/
|
|
1099
|
-
declare function useFieldArray<TSchema extends
|
|
1304
|
+
declare function useFieldArray<TSchema extends FormSchema, TFieldArrayPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
|
|
1100
1305
|
//#endregion
|
|
1101
|
-
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 };
|
|
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 };
|