@owanturist/signal-form 0.1.0 → 0.2.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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -96
- package/dist/index.d.ts +118 -96
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/dist/index.d.cts
CHANGED
|
@@ -44,8 +44,11 @@ declare abstract class SignalFormState<TParams extends SignalFormParams = any> {
|
|
|
44
44
|
_parentOf<TChild extends SignalFormState>(child: TChild): TChild;
|
|
45
45
|
_hasSameRootWith(another: SignalFormState): boolean;
|
|
46
46
|
abstract readonly _initial: ReadonlySignal<TParams["input.schema"]>;
|
|
47
|
-
abstract _replaceInitial(monitor: Monitor, state: undefined | this, isMounting: boolean): void;
|
|
48
47
|
abstract _setInitial(monitor: Monitor, setter: TParams["input.setter"]): void;
|
|
48
|
+
/**
|
|
49
|
+
* Like {@link _setInitial} but a no-op for explicitly set initials.
|
|
50
|
+
*/
|
|
51
|
+
abstract _patchInitial(monitor: Monitor, initial: TParams["input.schema"]): void;
|
|
49
52
|
abstract readonly _input: ReadonlySignal<TParams["input.schema"]>;
|
|
50
53
|
abstract _setInput(monitor: Monitor, setter: TParams["input.setter"]): void;
|
|
51
54
|
abstract readonly _error: ReadonlySignal<null | TParams["error.schema"]>;
|
|
@@ -68,7 +71,6 @@ declare abstract class SignalFormState<TParams extends SignalFormParams = any> {
|
|
|
68
71
|
abstract _forceValidated(monitor: Monitor): void;
|
|
69
72
|
abstract readonly _dirty: ReadonlySignal<TParams["flag.schema"]>;
|
|
70
73
|
abstract readonly _dirtyVerbose: ReadonlySignal<TParams["flag.schema.verbose"]>;
|
|
71
|
-
abstract readonly _dirtyOn: ReadonlySignal<TParams["flag.schema"]>;
|
|
72
74
|
abstract readonly _dirtyOnVerbose: ReadonlySignal<TParams["flag.schema.verbose"]>;
|
|
73
75
|
readonly _onFocus: Emitter<unknown, void>;
|
|
74
76
|
_getFocusFirstInvalid(monitor: Monitor): null | VoidFunction;
|
|
@@ -89,7 +91,7 @@ declare abstract class SignalFormState<TParams extends SignalFormParams = any> {
|
|
|
89
91
|
}
|
|
90
92
|
interface SignalFormChild<TChildParams extends SignalFormParams, TParams extends SignalFormParams> {
|
|
91
93
|
_state: SignalFormState<TChildParams>;
|
|
92
|
-
_mapToChild(this: void, parentValue: TParams["output.schema"])
|
|
94
|
+
_mapToChild: (this: void, parentValue: TParams["output.schema"]) => TChildParams["output.schema"];
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
declare abstract class SignalForm<TParams extends SignalFormParams = any> {
|
|
@@ -220,28 +222,21 @@ interface FormUnitTransform<TInput, TError, TOutput> {
|
|
|
220
222
|
}
|
|
221
223
|
|
|
222
224
|
declare class FormUnitState<TInput, TError, TOutput> extends SignalFormState<FormUnitParams<TInput, TError, TOutput>> {
|
|
223
|
-
readonly
|
|
224
|
-
_explicit: Signal<boolean>;
|
|
225
|
-
_current: Signal<TInput>;
|
|
226
|
-
}>;
|
|
225
|
+
readonly _initial: Signal<TInput>;
|
|
227
226
|
readonly _input: Signal<TInput>;
|
|
228
227
|
private readonly _customError;
|
|
229
228
|
readonly _validateOn: Signal<ValidateStrategy>;
|
|
230
229
|
readonly _touched: Signal<boolean>;
|
|
231
230
|
private readonly _transform;
|
|
232
231
|
private readonly _isInputDirty;
|
|
233
|
-
private readonly _isInputEqual;
|
|
234
232
|
private readonly _isOutputEqual;
|
|
235
233
|
private readonly _isErrorEqual;
|
|
234
|
+
private _isInitialExplicit;
|
|
236
235
|
readonly _host: Lazy<FormUnit$1<TInput, TError, TOutput>>;
|
|
237
|
-
constructor(parent: null | SignalFormState,
|
|
238
|
-
_explicit: Signal<boolean>;
|
|
239
|
-
_current: Signal<TInput>;
|
|
240
|
-
}>, _input: Signal<TInput>, _customError: Signal<null | TError>, _validateOn: Signal<ValidateStrategy>, _touched: Signal<boolean>, _transform: Signal<FormUnitTransform<TInput, TError, TOutput>>, _isInputDirty: Equal<TInput>, _isInputEqual: Equal<TInput>, _isOutputEqual: Equal<null | TOutput>, _isErrorEqual: Equal<null | TError>);
|
|
236
|
+
constructor(parent: null | SignalFormState, _initial: Signal<TInput>, _input: Signal<TInput>, _customError: Signal<null | TError>, _validateOn: Signal<ValidateStrategy>, _touched: Signal<boolean>, _transform: Signal<FormUnitTransform<TInput, TError, TOutput>>, _isInputDirty: Equal<TInput>, _isOutputEqual: Equal<null | TOutput>, _isErrorEqual: Equal<null | TError>, _isInitialExplicit: boolean);
|
|
241
237
|
_childOf(parent: null | SignalFormState): FormUnitState<TInput, TError, TOutput>;
|
|
242
|
-
_initial: ReadonlySignal<TInput>;
|
|
243
|
-
_replaceInitial(monitor: Monitor, state: undefined | FormUnitState<TInput, TError, TOutput>, isMounting: boolean): void;
|
|
244
238
|
_setInitial(monitor: Monitor, setter: FormUnitInputSetter<TInput>): void;
|
|
239
|
+
_patchInitial(_monitor: Monitor, candidate: TInput): void;
|
|
245
240
|
_setInput(monitor: Monitor, setter: FormUnitInputSetter<TInput>): void;
|
|
246
241
|
readonly _error: ReadonlySignal<null | TError>;
|
|
247
242
|
readonly _errorVerbose: ReadonlySignal<null | TError>;
|
|
@@ -261,7 +256,6 @@ declare class FormUnitState<TInput, TError, TOutput> extends SignalFormState<For
|
|
|
261
256
|
_forceValidated(): void;
|
|
262
257
|
readonly _dirty: ReadonlySignal<boolean>;
|
|
263
258
|
readonly _dirtyVerbose: ReadonlySignal<boolean>;
|
|
264
|
-
readonly _dirtyOn: Signal<boolean>;
|
|
265
259
|
readonly _dirtyOnVerbose: Signal<boolean>;
|
|
266
260
|
_reset(monitor: Monitor, resetter: undefined | FormUnitInputSetter<TInput>): void;
|
|
267
261
|
_getChildren(): ReadonlyArray<never>;
|
|
@@ -346,8 +340,11 @@ interface FormUnitOptions<TInput, TError = null> {
|
|
|
346
340
|
*/
|
|
347
341
|
readonly initial?: TInput;
|
|
348
342
|
}
|
|
349
|
-
interface FormUnitTransformedOptions<TInput, TError = null, TOutput = TInput> extends
|
|
343
|
+
interface FormUnitTransformedOptions<TInput, TError = null, TOutput = TInput> extends FormUnitOptions<TInput, TError> {
|
|
350
344
|
readonly transform: FormUnitTransformer<TInput, TOutput>;
|
|
345
|
+
readonly validate?: never;
|
|
346
|
+
readonly schema?: never;
|
|
347
|
+
readonly validateOn?: never;
|
|
351
348
|
/**
|
|
352
349
|
* PERFORMANCE OPTIMIZATION
|
|
353
350
|
*
|
|
@@ -361,19 +358,47 @@ interface FormUnitTransformedOptions<TInput, TError = null, TOutput = TInput> ex
|
|
|
361
358
|
*/
|
|
362
359
|
readonly isOutputEqual?: Equal<TOutput>;
|
|
363
360
|
}
|
|
364
|
-
interface FormUnitSchemaOptions<TInput, TOutput = TInput> extends Omit<
|
|
361
|
+
interface FormUnitSchemaOptions<TInput, TOutput = TInput> extends Omit<FormUnitOptions<TInput, ReadonlyArray<string>>, "isErrorEqual"> {
|
|
362
|
+
readonly schema: ZodLikeSchema<TOutput>;
|
|
365
363
|
/**
|
|
366
364
|
* @default "onTouch"
|
|
367
365
|
*/
|
|
368
366
|
readonly validateOn?: ValidateStrategy;
|
|
369
|
-
readonly
|
|
367
|
+
readonly transform?: never;
|
|
368
|
+
readonly validate?: never;
|
|
369
|
+
/**
|
|
370
|
+
* PERFORMANCE OPTIMIZATION
|
|
371
|
+
*
|
|
372
|
+
* A equality check function that determines whether the output value changes.
|
|
373
|
+
* When it does, the {@link SignalForm.getOutput} returns the new value.
|
|
374
|
+
*
|
|
375
|
+
* Useful for none primitive values such as Objects, Arrays, Date, etc.
|
|
376
|
+
* Intended to improve performance but do not affect business logic.
|
|
377
|
+
*
|
|
378
|
+
* @default Object.is
|
|
379
|
+
*/
|
|
380
|
+
readonly isOutputEqual?: Equal<TOutput>;
|
|
370
381
|
}
|
|
371
|
-
interface FormUnitValidatedOptions<TInput, TError = null, TOutput = TInput> extends
|
|
382
|
+
interface FormUnitValidatedOptions<TInput, TError = null, TOutput = TInput> extends FormUnitOptions<TInput, TError> {
|
|
383
|
+
readonly validate: FormUnitValidator<TInput, TError, TOutput>;
|
|
372
384
|
/**
|
|
373
385
|
* @default "onTouch"
|
|
374
386
|
*/
|
|
375
387
|
readonly validateOn?: ValidateStrategy;
|
|
376
|
-
readonly
|
|
388
|
+
readonly transform?: never;
|
|
389
|
+
readonly schema?: never;
|
|
390
|
+
/**
|
|
391
|
+
* PERFORMANCE OPTIMIZATION
|
|
392
|
+
*
|
|
393
|
+
* A equality check function that determines whether the output value changes.
|
|
394
|
+
* When it does, the {@link SignalForm.getOutput} returns the new value.
|
|
395
|
+
*
|
|
396
|
+
* Useful for none primitive values such as Objects, Arrays, Date, etc.
|
|
397
|
+
* Intended to improve performance but do not affect business logic.
|
|
398
|
+
*
|
|
399
|
+
* @default Object.is
|
|
400
|
+
*/
|
|
401
|
+
readonly isOutputEqual?: Equal<TOutput>;
|
|
377
402
|
}
|
|
378
403
|
type FormUnit<TInput, TError = null, TOutput = TInput> = FormUnit$1<TInput, TError, TOutput>;
|
|
379
404
|
declare function FormUnit<TInput, TError = null, TOutput = TInput>(input: TInput, options: FormUnitValidatedOptions<TInput, TError, TOutput> | FormUnitTransformedOptions<TInput, TError, TOutput>): FormUnit<TInput, TError, TOutput>;
|
|
@@ -383,63 +408,59 @@ declare function FormUnit<TInput, TError>(input: TInput, options?: FormUnitOptio
|
|
|
383
408
|
|
|
384
409
|
declare function isFormUnit(value: unknown): value is FormUnit$1<unknown, unknown, unknown>;
|
|
385
410
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
411
|
+
/**
|
|
412
|
+
* Self-referential homomorphic constraint: use as `<TFields extends FormShapeFields<TFields>>`.
|
|
413
|
+
*
|
|
414
|
+
* `Record<string, SignalForm>` would reject `interface X { ... }` at user call sites
|
|
415
|
+
* because TS does not infer an implicit string index signature on interfaces (they can
|
|
416
|
+
* be augmented via declaration merging). Mapping over `keyof TFields` instead checks
|
|
417
|
+
* each known key against `SignalForm` without requiring an index signature, so both
|
|
418
|
+
* `interface` and `type` declarations satisfy the constraint.
|
|
419
|
+
*/
|
|
420
|
+
type FormShapeFields<TFields = Record<string, SignalForm>> = {
|
|
421
|
+
readonly [TField in keyof TFields]: SignalForm;
|
|
390
422
|
};
|
|
391
423
|
|
|
392
|
-
type
|
|
393
|
-
[
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
type OmitValues<TObject, TValue> = Compute<Omit<TObject, FilterKeys<TObject, TValue>>>;
|
|
397
|
-
|
|
398
|
-
type FallbackParamWhenNever<TKey extends keyof SignalFormParams, TFallback, TParam> = [
|
|
399
|
-
TParam
|
|
400
|
-
] extends [never] ? TKey extends "input.schema" | "output.schema" | "output.schema.verbose" ? TFallback : never : TParam;
|
|
401
|
-
type GetFormShapeParam<TFields extends FormShapeFields, TKey extends keyof SignalFormParams> = OmitValues<{
|
|
402
|
-
readonly [TField in keyof TFields]: FallbackParamWhenNever<TKey, TFields[TField], GetSignalFormParam<TFields[TField], TKey>>;
|
|
403
|
-
}, never>;
|
|
424
|
+
type GetFormShapeParam<TFields extends FormShapeFields<TFields>, TKey extends keyof SignalFormParams> = {
|
|
425
|
+
readonly [TField in keyof TFields]: GetSignalFormParam<TFields[TField], TKey>;
|
|
426
|
+
};
|
|
404
427
|
|
|
405
|
-
type FormShapeErrorVerbose<TFields extends FormShapeFields
|
|
428
|
+
type FormShapeErrorVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "error.schema.verbose">;
|
|
406
429
|
|
|
407
|
-
type FormShapeErrorSetter<TFields extends FormShapeFields
|
|
430
|
+
type FormShapeErrorSetter<TFields extends FormShapeFields<TFields>> = Setter<null | Partial<GetFormShapeParam<TFields, "error.setter">>, [
|
|
408
431
|
FormShapeErrorVerbose<TFields>
|
|
409
432
|
]>;
|
|
410
433
|
|
|
411
|
-
type FormShapeFlagVerbose<TFields extends FormShapeFields
|
|
434
|
+
type FormShapeFlagVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "flag.schema.verbose">;
|
|
412
435
|
|
|
413
|
-
type FormShapeFlagSetter<TFields extends FormShapeFields
|
|
436
|
+
type FormShapeFlagSetter<TFields extends FormShapeFields<TFields>> = Setter<boolean | Partial<GetFormShapeParam<TFields, "flag.setter">>, [
|
|
414
437
|
FormShapeFlagVerbose<TFields>
|
|
415
438
|
]>;
|
|
416
439
|
|
|
417
|
-
type FormShapeInput<TFields extends FormShapeFields
|
|
440
|
+
type FormShapeInput<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "input.schema">;
|
|
418
441
|
|
|
419
|
-
type FormShapeInputSetter<TFields extends FormShapeFields
|
|
442
|
+
type FormShapeInputSetter<TFields extends FormShapeFields<TFields>> = Setter<Partial<GetFormShapeParam<TFields, "input.setter">>, [
|
|
420
443
|
FormShapeInput<TFields>,
|
|
421
444
|
FormShapeInput<TFields>
|
|
422
445
|
]>;
|
|
423
446
|
|
|
424
|
-
type FormShapeValidateOnVerbose<TFields extends FormShapeFields
|
|
447
|
+
type FormShapeValidateOnVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "validateOn.schema.verbose">;
|
|
425
448
|
|
|
426
|
-
type FormShapeValidateOnSetter<TFields extends FormShapeFields
|
|
449
|
+
type FormShapeValidateOnSetter<TFields extends FormShapeFields<TFields>> = Setter<ValidateStrategy | Partial<GetFormShapeParam<TFields, "validateOn.setter">>, [
|
|
427
450
|
FormShapeValidateOnVerbose<TFields>
|
|
428
451
|
]>;
|
|
429
452
|
|
|
430
|
-
type
|
|
453
|
+
type FormShapeError<TFields extends FormShapeFields<TFields>> = null | GetFormShapeParam<TFields, "error.schema">;
|
|
431
454
|
|
|
432
|
-
type
|
|
455
|
+
type FormShapeFlag<TFields extends FormShapeFields<TFields>> = boolean | GetFormShapeParam<TFields, "flag.schema">;
|
|
433
456
|
|
|
434
|
-
type
|
|
457
|
+
type FormShapeOutput<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "output.schema">;
|
|
435
458
|
|
|
436
|
-
type
|
|
459
|
+
type FormShapeOutputVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "output.schema.verbose">;
|
|
437
460
|
|
|
438
|
-
type
|
|
461
|
+
type FormShapeValidateOn<TFields extends FormShapeFields<TFields>> = ValidateStrategy | GetFormShapeParam<TFields, "validateOn.schema">;
|
|
439
462
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
interface FormShapeParams<TFields extends FormShapeFields> extends SignalFormParams {
|
|
463
|
+
interface FormShapeParams<TFields extends FormShapeFields<TFields>> extends SignalFormParams {
|
|
443
464
|
readonly "input.schema": FormShapeInput<TFields>;
|
|
444
465
|
readonly "input.setter": FormShapeInputSetter<TFields>;
|
|
445
466
|
readonly "output.schema": FormShapeOutput<TFields>;
|
|
@@ -455,68 +476,60 @@ interface FormShapeParams<TFields extends FormShapeFields> extends SignalFormPar
|
|
|
455
476
|
readonly "error.schema.verbose": FormShapeErrorVerbose<TFields>;
|
|
456
477
|
}
|
|
457
478
|
|
|
458
|
-
type FormShapeStateFields<TFields extends FormShapeFields
|
|
459
|
-
[TField in keyof TFields]: TFields[TField]
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
[TField in keyof TFields]: TFields[TField] extends SignalForm ? never : Signal<TFields[TField]>;
|
|
463
|
-
}, never>;
|
|
464
|
-
declare class FormShapeState<TFields extends FormShapeFields = FormShapeFields> extends SignalFormState<FormShapeParams<TFields>> {
|
|
479
|
+
type FormShapeStateFields<TFields extends FormShapeFields<TFields>> = {
|
|
480
|
+
[TField in keyof TFields]: SignalFormState<GetSignalFormParams<TFields[TField]>>;
|
|
481
|
+
};
|
|
482
|
+
declare class FormShapeState<TFields extends FormShapeFields<TFields> = Record<string, SignalForm>> extends SignalFormState<FormShapeParams<TFields>> {
|
|
465
483
|
readonly _host: Lazy<FormShape$1<TFields>>;
|
|
466
484
|
readonly _fields: FormShapeStateFields<TFields>;
|
|
467
|
-
|
|
468
|
-
constructor(parent: null | SignalFormState, fields: FormShapeStateFields<TFields>, meta: FormShapeStateMeta<TFields>);
|
|
485
|
+
constructor(parent: null | SignalFormState, fields: FormShapeStateFields<TFields>);
|
|
469
486
|
_childOf(parent: null | SignalFormState): FormShapeState<TFields>;
|
|
470
|
-
readonly _initial: _owanturist_signal.ReadonlySignal<
|
|
471
|
-
_replaceInitial(monitor: Monitor, state: undefined | FormShapeState<TFields>, isMounting: boolean): void;
|
|
487
|
+
readonly _initial: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "input.schema">>;
|
|
472
488
|
_setInitial(monitor: Monitor, setter: FormShapeInputSetter<TFields>): void;
|
|
473
|
-
|
|
489
|
+
_patchInitial(monitor: Monitor, initials: FormShapeInput<TFields>): void;
|
|
490
|
+
readonly _input: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "input.schema">>;
|
|
474
491
|
_setInput(monitor: Monitor, setter: FormShapeInputSetter<TFields>): void;
|
|
475
492
|
readonly _error: _owanturist_signal.ReadonlySignal<FormShapeError<TFields>>;
|
|
476
|
-
readonly _errorVerbose: _owanturist_signal.ReadonlySignal<
|
|
493
|
+
readonly _errorVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "error.schema.verbose">>;
|
|
477
494
|
_setError(monitor: Monitor, setter: FormShapeErrorSetter<TFields>): void;
|
|
478
495
|
readonly _validateOn: _owanturist_signal.ReadonlySignal<FormShapeValidateOn<TFields>>;
|
|
479
|
-
readonly _validateOnVerbose: _owanturist_signal.ReadonlySignal<
|
|
496
|
+
readonly _validateOnVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "validateOn.schema.verbose">>;
|
|
480
497
|
_setValidateOn(monitor: Monitor, setter: FormShapeValidateOnSetter<TFields>): void;
|
|
481
498
|
readonly _touched: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
|
|
482
|
-
readonly _touchedVerbose: _owanturist_signal.ReadonlySignal<
|
|
499
|
+
readonly _touchedVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
483
500
|
_setTouched(monitor: Monitor, setter: FormShapeFlagSetter<TFields>): void;
|
|
484
|
-
readonly _output: _owanturist_signal.ReadonlySignal<
|
|
485
|
-
readonly _outputVerbose: _owanturist_signal.ReadonlySignal<
|
|
501
|
+
readonly _output: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "output.schema"> | null>;
|
|
502
|
+
readonly _outputVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "output.schema.verbose">>;
|
|
486
503
|
readonly _valid: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
|
|
487
|
-
readonly _validVerbose: _owanturist_signal.ReadonlySignal<
|
|
504
|
+
readonly _validVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
488
505
|
readonly _invalid: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
|
|
489
|
-
readonly _invalidVerbose: _owanturist_signal.ReadonlySignal<
|
|
506
|
+
readonly _invalidVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
490
507
|
readonly _validated: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
|
|
491
|
-
readonly _validatedVerbose: _owanturist_signal.ReadonlySignal<
|
|
508
|
+
readonly _validatedVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
492
509
|
_forceValidated(monitor: Monitor): void;
|
|
493
510
|
readonly _dirty: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
|
|
494
|
-
readonly _dirtyVerbose: _owanturist_signal.ReadonlySignal<
|
|
495
|
-
readonly
|
|
496
|
-
readonly _dirtyOnVerbose: _owanturist_signal.ReadonlySignal<Omit<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "flag.schema.verbose">] extends [never] ? never : GetSignalFormParam<TFields[TField], "flag.schema.verbose">; }, FilterKeys<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "flag.schema.verbose">] extends [never] ? never : GetSignalFormParam<TFields[TField], "flag.schema.verbose">; }, never>> extends infer T ? { [K in keyof T]: T[K]; } : never>;
|
|
511
|
+
readonly _dirtyVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
512
|
+
readonly _dirtyOnVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
497
513
|
_reset(monitor: Monitor, resetter: undefined | FormShapeInputSetter<TFields>): void;
|
|
498
514
|
_getChildren<TChildParams extends SignalFormParams>(): ReadonlyArray<SignalFormChild<TChildParams, FormShapeParams<TFields>>>;
|
|
499
515
|
}
|
|
500
516
|
|
|
501
|
-
|
|
502
|
-
declare class FormShape$1<TFields extends FormShapeFields> extends SignalForm<FormShapeParams<TFields>> {
|
|
517
|
+
declare class FormShape$1<TFields extends FormShapeFields<TFields>> extends SignalForm<FormShapeParams<TFields>> {
|
|
503
518
|
readonly _state: FormShapeState<TFields>;
|
|
504
519
|
static _getState: typeof SignalForm._getState;
|
|
505
|
-
readonly fields:
|
|
506
|
-
readonly [TField in keyof TFields]: FormShapeField<TFields[TField]>;
|
|
507
|
-
};
|
|
520
|
+
readonly fields: TFields;
|
|
508
521
|
constructor(_state: FormShapeState<TFields>);
|
|
509
522
|
}
|
|
510
523
|
|
|
511
|
-
interface FormShapeOptions<TFields extends FormShapeFields
|
|
524
|
+
interface FormShapeOptions<TFields extends FormShapeFields<TFields>> {
|
|
512
525
|
readonly input?: FormShapeInputSetter<TFields>;
|
|
513
526
|
readonly initial?: FormShapeInputSetter<TFields>;
|
|
514
527
|
readonly touched?: FormShapeFlagSetter<TFields>;
|
|
515
528
|
readonly validateOn?: FormShapeValidateOnSetter<TFields>;
|
|
516
529
|
readonly error?: FormShapeErrorSetter<TFields>;
|
|
517
530
|
}
|
|
518
|
-
type FormShape<TFields extends FormShapeFields
|
|
519
|
-
declare function FormShape<TFields extends FormShapeFields
|
|
531
|
+
type FormShape<TFields extends FormShapeFields<TFields>> = FormShape$1<TFields>;
|
|
532
|
+
declare function FormShape<TFields extends FormShapeFields<TFields>>(fields: TFields, { input, initial, touched, validateOn, error }?: FormShapeOptions<NoInfer<TFields>>): FormShape<TFields>;
|
|
520
533
|
|
|
521
534
|
declare function isFormShape(value: unknown): value is FormShape$1<FormShapeFields>;
|
|
522
535
|
|
|
@@ -534,7 +547,7 @@ type FormListFlagSetter<TElement extends SignalForm> = Setter<boolean | Readonly
|
|
|
534
547
|
|
|
535
548
|
type FormListInput<TElement extends SignalForm> = ReadonlyArray<GetSignalFormInput<TElement>>;
|
|
536
549
|
|
|
537
|
-
type FormListInputSetter<TElement extends SignalForm> = Setter<ReadonlyArray<
|
|
550
|
+
type FormListInputSetter<TElement extends SignalForm> = Setter<ReadonlyArray<GetSignalFormInput<TElement>>, [
|
|
538
551
|
FormListInput<TElement>,
|
|
539
552
|
FormListInput<TElement>
|
|
540
553
|
]>;
|
|
@@ -571,17 +584,18 @@ interface FormListParams<TElement extends SignalForm> extends SignalFormParams {
|
|
|
571
584
|
"error.schema.verbose": FormListErrorVerbose<TElement>;
|
|
572
585
|
}
|
|
573
586
|
|
|
587
|
+
type FormListElementFactoryInternal<TElement extends SignalForm> = (input: GetSignalFormInput<TElement>, index: number) => SignalFormState<GetSignalFormParams<TElement>>;
|
|
574
588
|
declare class FormListState<TElement extends SignalForm = SignalForm> extends SignalFormState<FormListParams<TElement>> {
|
|
589
|
+
private readonly _factory;
|
|
590
|
+
readonly _initialInputs: Signal<ReadonlyArray<GetSignalFormInput<TElement>>>;
|
|
575
591
|
readonly _host: Lazy<FormList$1<TElement>>;
|
|
576
592
|
readonly _elements: Signal<ReadonlyArray<SignalFormState<GetSignalFormParams<TElement>>>>;
|
|
577
|
-
|
|
578
|
-
constructor(parent: null | SignalFormState, elements: ReadonlyArray<SignalFormState<GetSignalFormParams<TElement>>>);
|
|
593
|
+
constructor(parent: null | SignalFormState, _factory: FormListElementFactoryInternal<TElement>, _initialInputs: Signal<ReadonlyArray<GetSignalFormInput<TElement>>>, elements?: ReadonlyArray<SignalFormState<GetSignalFormParams<TElement>>>);
|
|
579
594
|
_childOf(parent: null | SignalFormState): FormListState<TElement>;
|
|
580
595
|
_getElements(monitor: Monitor): ReadonlyArray<TElement>;
|
|
581
|
-
_getInitialElements(monitor: Monitor): ReadonlyArray<SignalFormState<GetSignalFormParams<TElement>>>;
|
|
582
596
|
readonly _initial: _owanturist_signal.ReadonlySignal<FormListInput<TElement>>;
|
|
583
|
-
_replaceInitial(monitor: Monitor, state: undefined | FormListState<TElement>, isMounting: boolean): void;
|
|
584
597
|
_setInitial(monitor: Monitor, setter: FormListInputSetter<TElement>): void;
|
|
598
|
+
_patchInitial(monitor: Monitor, initials: FormListInput<TElement>): void;
|
|
585
599
|
readonly _input: _owanturist_signal.ReadonlySignal<FormListInput<TElement>>;
|
|
586
600
|
_setInput(monitor: Monitor, setter: FormListInputSetter<TElement>): void;
|
|
587
601
|
readonly _error: _owanturist_signal.ReadonlySignal<FormListError<TElement>>;
|
|
@@ -604,7 +618,6 @@ declare class FormListState<TElement extends SignalForm = SignalForm> extends Si
|
|
|
604
618
|
_forceValidated(monitor: Monitor): void;
|
|
605
619
|
readonly _dirty: _owanturist_signal.ReadonlySignal<FormListFlag<TElement>>;
|
|
606
620
|
readonly _dirtyVerbose: _owanturist_signal.ReadonlySignal<FormListFlagVerbose<TElement>>;
|
|
607
|
-
readonly _dirtyOn: _owanturist_signal.ReadonlySignal<FormListFlag<TElement>>;
|
|
608
621
|
readonly _dirtyOnVerbose: _owanturist_signal.ReadonlySignal<FormListFlagVerbose<TElement>>;
|
|
609
622
|
_reset(monitor: Monitor, resetter: undefined | FormListInputSetter<TElement>): void;
|
|
610
623
|
_getChildren<TChildParams extends SignalFormParams>(monitor: Monitor): ReadonlyArray<SignalFormChild<TChildParams, FormListParams<TElement>>>;
|
|
@@ -620,15 +633,22 @@ declare class FormList$1<TElement extends SignalForm> extends SignalForm<FormLis
|
|
|
620
633
|
setElements(setter: Setter<ReadonlyArray<TElement>, [ReadonlyArray<TElement>, Monitor]>): void;
|
|
621
634
|
}
|
|
622
635
|
|
|
636
|
+
type FormListElementFactory<TElement extends SignalForm> = (input: GetSignalFormInput<TElement>, index: number) => TElement;
|
|
623
637
|
interface FormListOptions<TElement extends SignalForm> {
|
|
624
|
-
|
|
638
|
+
/**
|
|
639
|
+
* @default []
|
|
640
|
+
*/
|
|
625
641
|
readonly initial?: FormListInputSetter<TElement>;
|
|
642
|
+
/**
|
|
643
|
+
* @default {@link initial}
|
|
644
|
+
*/
|
|
645
|
+
readonly input?: FormListInputSetter<TElement>;
|
|
626
646
|
readonly touched?: FormListFlagSetter<TElement>;
|
|
627
647
|
readonly validateOn?: FormListValidateOnSetter<TElement>;
|
|
628
648
|
readonly error?: FormListErrorSetter<TElement>;
|
|
629
649
|
}
|
|
630
650
|
type FormList<TElement extends SignalForm> = FormList$1<TElement>;
|
|
631
|
-
declare function FormList<TElement extends SignalForm>(
|
|
651
|
+
declare function FormList<TElement extends SignalForm>(factory: FormListElementFactory<TElement>, { input, initial, touched, validateOn, error }?: FormListOptions<TElement>): FormList<TElement>;
|
|
632
652
|
|
|
633
653
|
declare function isFormList(value: unknown): value is FormList$1<SignalForm>;
|
|
634
654
|
|
|
@@ -704,7 +724,7 @@ declare class FormOptionalState<TEnabled extends SignalForm, TElement extends Si
|
|
|
704
724
|
private _toVerbose;
|
|
705
725
|
readonly _initial: _owanturist_signal.ReadonlySignal<FormOptionalInput<TEnabled, TElement>>;
|
|
706
726
|
_setInitial(monitor: Monitor, setter: FormOptionalInputSetter<TEnabled, TElement>): void;
|
|
707
|
-
|
|
727
|
+
_patchInitial(monitor: Monitor, initial: FormOptionalInput<TEnabled, TElement>): void;
|
|
708
728
|
readonly _input: _owanturist_signal.ReadonlySignal<FormOptionalInput<TEnabled, TElement>>;
|
|
709
729
|
_setInput(monitor: Monitor, setter: FormOptionalInputSetter<TEnabled, TElement>): void;
|
|
710
730
|
readonly _error: _owanturist_signal.ReadonlySignal<FormOptionalError<TEnabled, TElement>>;
|
|
@@ -727,7 +747,6 @@ declare class FormOptionalState<TEnabled extends SignalForm, TElement extends Si
|
|
|
727
747
|
_forceValidated(monitor: Monitor): void;
|
|
728
748
|
readonly _dirty: _owanturist_signal.ReadonlySignal<FormOptionalFlag<TEnabled, TElement>>;
|
|
729
749
|
readonly _dirtyVerbose: _owanturist_signal.ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
|
|
730
|
-
readonly _dirtyOn: _owanturist_signal.ReadonlySignal<FormOptionalFlag<TEnabled, TElement>>;
|
|
731
750
|
readonly _dirtyOnVerbose: _owanturist_signal.ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
|
|
732
751
|
_reset(monitor: Monitor, resetter: undefined | FormOptionalInputSetter<TEnabled, TElement>): void;
|
|
733
752
|
_getChildren<TChildParams extends SignalFormParams>(monitor: Monitor): ReadonlyArray<SignalFormChild<TChildParams, FormOptionalParams<TEnabled, TElement>>>;
|
|
@@ -761,6 +780,10 @@ interface FormSwitchConciseSchema<TActive, TBranch> {
|
|
|
761
780
|
readonly branch: TBranch;
|
|
762
781
|
}
|
|
763
782
|
|
|
783
|
+
type Compute<Obj> = unknown & {
|
|
784
|
+
[K in keyof Obj]: Obj[K];
|
|
785
|
+
};
|
|
786
|
+
|
|
764
787
|
interface FormSwitchVerboseSchema<TActive, TBranches> {
|
|
765
788
|
readonly active: TActive;
|
|
766
789
|
readonly branches: TBranches;
|
|
@@ -871,7 +894,7 @@ declare class FormSwitchState<TKind extends SignalForm, TBranches extends FormSw
|
|
|
871
894
|
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetSignalFormParam<TBranches[TBranch], "input.schema">; }]: { readonly [TBranch in keyof TBranches]: GetSignalFormParam<TBranches[TBranch], "input.schema">; }[K]; };
|
|
872
895
|
}>;
|
|
873
896
|
_setInitial(monitor: Monitor, setter: FormSwitchInputSetter<TKind, TBranches>): void;
|
|
874
|
-
|
|
897
|
+
_patchInitial(monitor: Monitor, initial: FormSwitchInput<TKind, TBranches>): void;
|
|
875
898
|
readonly _input: _owanturist_signal.ReadonlySignal<{
|
|
876
899
|
readonly active: GetSignalFormParam<TKind, "input.schema">;
|
|
877
900
|
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetSignalFormParam<TBranches[TBranch], "input.schema">; }]: { readonly [TBranch in keyof TBranches]: GetSignalFormParam<TBranches[TBranch], "input.schema">; }[K]; };
|
|
@@ -921,7 +944,6 @@ declare class FormSwitchState<TKind extends SignalForm, TBranches extends FormSw
|
|
|
921
944
|
readonly active: GetSignalFormParam<TKind, "flag.schema.verbose">;
|
|
922
945
|
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetSignalFormParam<TBranches[TBranch], "flag.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetSignalFormParam<TBranches[TBranch], "flag.schema.verbose">; }[K]; };
|
|
923
946
|
}>;
|
|
924
|
-
readonly _dirtyOn: _owanturist_signal.ReadonlySignal<FormSwitchFlag<TKind, TBranches>>;
|
|
925
947
|
readonly _dirtyOnVerbose: _owanturist_signal.ReadonlySignal<{
|
|
926
948
|
readonly active: GetSignalFormParam<TKind, "flag.schema.verbose">;
|
|
927
949
|
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetSignalFormParam<TBranches[TBranch], "flag.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetSignalFormParam<TBranches[TBranch], "flag.schema.verbose">; }[K]; };
|
|
@@ -951,4 +973,4 @@ declare function FormSwitch<TKind extends SignalForm, TBranches extends FormSwit
|
|
|
951
973
|
|
|
952
974
|
declare function isFormSwitch(anything: unknown): anything is FormSwitch$1<SignalForm, FormSwitchBranches<SignalForm>>;
|
|
953
975
|
|
|
954
|
-
export { FormList, type FormListError, type FormListErrorSetter, type FormListErrorVerbose, type FormListFlag, type FormListFlagSetter, type FormListFlagVerbose, type FormListInput, type FormListInputSetter, type FormListOptions, type FormListOutput, type FormListOutputVerbose, type FormListParams, type FormListValidateOn, type FormListValidateOnSetter, type FormListValidateOnVerbose,
|
|
976
|
+
export { FormList, type FormListElementFactory, type FormListError, type FormListErrorSetter, type FormListErrorVerbose, type FormListFlag, type FormListFlagSetter, type FormListFlagVerbose, type FormListInput, type FormListInputSetter, type FormListOptions, type FormListOutput, type FormListOutputVerbose, type FormListParams, type FormListValidateOn, type FormListValidateOnSetter, type FormListValidateOnVerbose, FormOptional, type FormOptionalError, type FormOptionalErrorSetter, type FormOptionalErrorVerbose, type FormOptionalFlag, type FormOptionalFlagSetter, type FormOptionalFlagVerbose, type FormOptionalInput, type FormOptionalInputSetter, type FormOptionalOptions, type FormOptionalOutput, type FormOptionalOutputVerbose, type FormOptionalParams, type FormOptionalSchema, type FormOptionalValidateOn, type FormOptionalValidateOnSetter, type FormOptionalValidateOnVerbose, FormShape, type FormShapeError, type FormShapeErrorSetter, type FormShapeErrorVerbose, type FormShapeFields, type FormShapeFlag, type FormShapeFlagSetter, type FormShapeFlagVerbose, type FormShapeInput, type FormShapeInputSetter, type FormShapeOptions, type FormShapeOutput, type FormShapeOutputVerbose, type FormShapeParams, type FormShapeValidateOn, type FormShapeValidateOnSetter, type FormShapeValidateOnVerbose, FormSwitch, type FormSwitchActiveBranch, type FormSwitchBranch, type FormSwitchBranches, type FormSwitchConciseSchema, type FormSwitchError, type FormSwitchErrorSetter, type FormSwitchErrorVerbose, type FormSwitchFlag, type FormSwitchFlagSetter, type FormSwitchFlagVerbose, type FormSwitchInput, type FormSwitchInputSetter, type FormSwitchOptions, type FormSwitchOutput, type FormSwitchOutputVerbose, type FormSwitchParams, type FormSwitchValidateOn, type FormSwitchValidateOnSetter, type FormSwitchValidateOnVerbose, type FormSwitchVerboseSchema, FormUnit, type FormUnitErrorSetter, type FormUnitFlagSetter, type FormUnitInputSetter, type FormUnitOptions, type FormUnitParams, type FormUnitSchemaOptions, type FormUnitTransformedOptions, type FormUnitTransformer, type FormUnitValidateOnSetter, type FormUnitValidatedOptions, type FormUnitValidator, type GetFormShapeParam, type GetFormSwitchBranchesParam, type GetSignalFormError, type GetSignalFormErrorSetter, type GetSignalFormErrorVerbose, type GetSignalFormFlag, type GetSignalFormFlagSetter, type GetSignalFormFlagVerbose, type GetSignalFormInput, type GetSignalFormInputSetter, type GetSignalFormOutput, type GetSignalFormOutputVerbose, type GetSignalFormParam, type GetSignalFormValidateOn, type GetSignalFormValidateOnSetter, type GetSignalFormValidateOnVerbose, type Result, SignalForm, type SignalFormParams, VALIDATE_ON_CHANGE, VALIDATE_ON_INIT, VALIDATE_ON_SUBMIT, VALIDATE_ON_TOUCH, type ValidateStrategy, type ZodLikeError, type ZodLikeIssue, type ZodLikeSafeParseResult, type ZodLikeSchema, isFormList, isFormOptional, isFormShape, isFormSwitch, isFormUnit, isSignalForm, zodLikeParse };
|