@owanturist/signal-form 0.1.1 → 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.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;
@@ -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 _initialState: Signal<{
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, _initialState: Signal<{
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>;
@@ -414,63 +408,59 @@ declare function FormUnit<TInput, TError>(input: TInput, options?: FormUnitOptio
414
408
 
415
409
  declare function isFormUnit(value: unknown): value is FormUnit$1<unknown, unknown, unknown>;
416
410
 
417
- type FormShapeFields = Record<string, any>;
418
-
419
- type Compute<Obj> = unknown & {
420
- [K in keyof Obj]: Obj[K];
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;
421
422
  };
422
423
 
423
- type FilterKeys<TObject, TValue> = {
424
- [K in keyof TObject]: TObject[K] extends TValue ? K : never;
425
- }[keyof TObject];
426
-
427
- type OmitValues<TObject, TValue> = Compute<Omit<TObject, FilterKeys<TObject, TValue>>>;
428
-
429
- type FallbackParamWhenNever<TKey extends keyof SignalFormParams, TFallback, TParam> = [
430
- TParam
431
- ] extends [never] ? TKey extends "input.schema" | "output.schema" | "output.schema.verbose" ? TFallback : never : TParam;
432
- type GetFormShapeParam<TFields extends FormShapeFields, TKey extends keyof SignalFormParams> = OmitValues<{
433
- readonly [TField in keyof TFields]: FallbackParamWhenNever<TKey, TFields[TField], GetSignalFormParam<TFields[TField], TKey>>;
434
- }, never>;
424
+ type GetFormShapeParam<TFields extends FormShapeFields<TFields>, TKey extends keyof SignalFormParams> = {
425
+ readonly [TField in keyof TFields]: GetSignalFormParam<TFields[TField], TKey>;
426
+ };
435
427
 
436
- type FormShapeErrorVerbose<TFields extends FormShapeFields> = GetFormShapeParam<TFields, "error.schema.verbose">;
428
+ type FormShapeErrorVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "error.schema.verbose">;
437
429
 
438
- type FormShapeErrorSetter<TFields extends FormShapeFields> = Setter<null | Partial<GetFormShapeParam<TFields, "error.setter">>, [
430
+ type FormShapeErrorSetter<TFields extends FormShapeFields<TFields>> = Setter<null | Partial<GetFormShapeParam<TFields, "error.setter">>, [
439
431
  FormShapeErrorVerbose<TFields>
440
432
  ]>;
441
433
 
442
- type FormShapeFlagVerbose<TFields extends FormShapeFields> = GetFormShapeParam<TFields, "flag.schema.verbose">;
434
+ type FormShapeFlagVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "flag.schema.verbose">;
443
435
 
444
- type FormShapeFlagSetter<TFields extends FormShapeFields> = Setter<boolean | Partial<GetFormShapeParam<TFields, "flag.setter">>, [
436
+ type FormShapeFlagSetter<TFields extends FormShapeFields<TFields>> = Setter<boolean | Partial<GetFormShapeParam<TFields, "flag.setter">>, [
445
437
  FormShapeFlagVerbose<TFields>
446
438
  ]>;
447
439
 
448
- type FormShapeInput<TFields extends FormShapeFields> = GetFormShapeParam<TFields, "input.schema">;
440
+ type FormShapeInput<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "input.schema">;
449
441
 
450
- type FormShapeInputSetter<TFields extends FormShapeFields> = Setter<Partial<GetFormShapeParam<TFields, "input.setter">>, [
442
+ type FormShapeInputSetter<TFields extends FormShapeFields<TFields>> = Setter<Partial<GetFormShapeParam<TFields, "input.setter">>, [
451
443
  FormShapeInput<TFields>,
452
444
  FormShapeInput<TFields>
453
445
  ]>;
454
446
 
455
- type FormShapeValidateOnVerbose<TFields extends FormShapeFields> = GetFormShapeParam<TFields, "validateOn.schema.verbose">;
447
+ type FormShapeValidateOnVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "validateOn.schema.verbose">;
456
448
 
457
- type FormShapeValidateOnSetter<TFields extends FormShapeFields> = Setter<ValidateStrategy | Partial<GetFormShapeParam<TFields, "validateOn.setter">>, [
449
+ type FormShapeValidateOnSetter<TFields extends FormShapeFields<TFields>> = Setter<ValidateStrategy | Partial<GetFormShapeParam<TFields, "validateOn.setter">>, [
458
450
  FormShapeValidateOnVerbose<TFields>
459
451
  ]>;
460
452
 
461
- type FormMeta<TValue> = (monitor: Monitor) => TValue;
453
+ type FormShapeError<TFields extends FormShapeFields<TFields>> = null | GetFormShapeParam<TFields, "error.schema">;
462
454
 
463
- type FormShapeError<TFields extends FormShapeFields> = null | GetFormShapeParam<TFields, "error.schema">;
455
+ type FormShapeFlag<TFields extends FormShapeFields<TFields>> = boolean | GetFormShapeParam<TFields, "flag.schema">;
464
456
 
465
- type FormShapeFlag<TFields extends FormShapeFields> = boolean | GetFormShapeParam<TFields, "flag.schema">;
457
+ type FormShapeOutput<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "output.schema">;
466
458
 
467
- type FormShapeOutput<TFields extends FormShapeFields> = GetFormShapeParam<TFields, "output.schema">;
459
+ type FormShapeOutputVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "output.schema.verbose">;
468
460
 
469
- type FormShapeOutputVerbose<TFields extends FormShapeFields> = GetFormShapeParam<TFields, "output.schema.verbose">;
461
+ type FormShapeValidateOn<TFields extends FormShapeFields<TFields>> = ValidateStrategy | GetFormShapeParam<TFields, "validateOn.schema">;
470
462
 
471
- type FormShapeValidateOn<TFields extends FormShapeFields> = ValidateStrategy | GetFormShapeParam<TFields, "validateOn.schema">;
472
-
473
- interface FormShapeParams<TFields extends FormShapeFields> extends SignalFormParams {
463
+ interface FormShapeParams<TFields extends FormShapeFields<TFields>> extends SignalFormParams {
474
464
  readonly "input.schema": FormShapeInput<TFields>;
475
465
  readonly "input.setter": FormShapeInputSetter<TFields>;
476
466
  readonly "output.schema": FormShapeOutput<TFields>;
@@ -486,68 +476,60 @@ interface FormShapeParams<TFields extends FormShapeFields> extends SignalFormPar
486
476
  readonly "error.schema.verbose": FormShapeErrorVerbose<TFields>;
487
477
  }
488
478
 
489
- type FormShapeStateFields<TFields extends FormShapeFields> = OmitValues<{
490
- [TField in keyof TFields]: TFields[TField] extends SignalForm<infer TParams> ? SignalFormState<TParams> : never;
491
- }, never>;
492
- type FormShapeStateMeta<TFields extends FormShapeFields> = OmitValues<{
493
- [TField in keyof TFields]: TFields[TField] extends SignalForm ? never : Signal<TFields[TField]>;
494
- }, never>;
495
- 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>> {
496
483
  readonly _host: Lazy<FormShape$1<TFields>>;
497
484
  readonly _fields: FormShapeStateFields<TFields>;
498
- readonly _meta: FormShapeStateMeta<TFields>;
499
- constructor(parent: null | SignalFormState, fields: FormShapeStateFields<TFields>, meta: FormShapeStateMeta<TFields>);
485
+ constructor(parent: null | SignalFormState, fields: FormShapeStateFields<TFields>);
500
486
  _childOf(parent: null | SignalFormState): FormShapeState<TFields>;
501
- readonly _initial: _owanturist_signal.ReadonlySignal<Omit<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "input.schema">] extends [never] ? TFields[TField] : GetSignalFormParam<TFields[TField], "input.schema">; }, FilterKeys<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "input.schema">] extends [never] ? TFields[TField] : GetSignalFormParam<TFields[TField], "input.schema">; }, never>> extends infer T ? { [K in keyof T]: T[K]; } : never>;
502
- _replaceInitial(monitor: Monitor, state: undefined | FormShapeState<TFields>, isMounting: boolean): void;
487
+ readonly _initial: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "input.schema">>;
503
488
  _setInitial(monitor: Monitor, setter: FormShapeInputSetter<TFields>): void;
504
- readonly _input: _owanturist_signal.ReadonlySignal<Omit<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "input.schema">] extends [never] ? TFields[TField] : GetSignalFormParam<TFields[TField], "input.schema">; }, FilterKeys<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "input.schema">] extends [never] ? TFields[TField] : GetSignalFormParam<TFields[TField], "input.schema">; }, never>> extends infer T ? { [K in keyof T]: T[K]; } : never>;
489
+ _patchInitial(monitor: Monitor, initials: FormShapeInput<TFields>): void;
490
+ readonly _input: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "input.schema">>;
505
491
  _setInput(monitor: Monitor, setter: FormShapeInputSetter<TFields>): void;
506
492
  readonly _error: _owanturist_signal.ReadonlySignal<FormShapeError<TFields>>;
507
- readonly _errorVerbose: _owanturist_signal.ReadonlySignal<Omit<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "error.schema.verbose">] extends [never] ? never : GetSignalFormParam<TFields[TField], "error.schema.verbose">; }, FilterKeys<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "error.schema.verbose">] extends [never] ? never : GetSignalFormParam<TFields[TField], "error.schema.verbose">; }, never>> extends infer T ? { [K in keyof T]: T[K]; } : never>;
493
+ readonly _errorVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "error.schema.verbose">>;
508
494
  _setError(monitor: Monitor, setter: FormShapeErrorSetter<TFields>): void;
509
495
  readonly _validateOn: _owanturist_signal.ReadonlySignal<FormShapeValidateOn<TFields>>;
510
- readonly _validateOnVerbose: _owanturist_signal.ReadonlySignal<Omit<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "validateOn.schema.verbose">] extends [never] ? never : GetSignalFormParam<TFields[TField], "validateOn.schema.verbose">; }, FilterKeys<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "validateOn.schema.verbose">] extends [never] ? never : GetSignalFormParam<TFields[TField], "validateOn.schema.verbose">; }, never>> extends infer T ? { [K in keyof T]: T[K]; } : never>;
496
+ readonly _validateOnVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "validateOn.schema.verbose">>;
511
497
  _setValidateOn(monitor: Monitor, setter: FormShapeValidateOnSetter<TFields>): void;
512
498
  readonly _touched: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
513
- readonly _touchedVerbose: _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>;
499
+ readonly _touchedVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
514
500
  _setTouched(monitor: Monitor, setter: FormShapeFlagSetter<TFields>): void;
515
- readonly _output: _owanturist_signal.ReadonlySignal<(Omit<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "output.schema">] extends [never] ? TFields[TField] : GetSignalFormParam<TFields[TField], "output.schema">; }, FilterKeys<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "output.schema">] extends [never] ? TFields[TField] : GetSignalFormParam<TFields[TField], "output.schema">; }, never>> extends infer T ? { [K in keyof T]: T[K]; } : never) | null>;
516
- readonly _outputVerbose: _owanturist_signal.ReadonlySignal<Omit<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "output.schema.verbose">] extends [never] ? TFields[TField] : GetSignalFormParam<TFields[TField], "output.schema.verbose">; }, FilterKeys<{ readonly [TField in keyof TFields]: [GetSignalFormParam<TFields[TField], "output.schema.verbose">] extends [never] ? TFields[TField] : GetSignalFormParam<TFields[TField], "output.schema.verbose">; }, never>> extends infer T ? { [K in keyof T]: T[K]; } : never>;
501
+ readonly _output: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "output.schema"> | null>;
502
+ readonly _outputVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "output.schema.verbose">>;
517
503
  readonly _valid: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
518
- readonly _validVerbose: _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>;
504
+ readonly _validVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
519
505
  readonly _invalid: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
520
- readonly _invalidVerbose: _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>;
506
+ readonly _invalidVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
521
507
  readonly _validated: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
522
- readonly _validatedVerbose: _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>;
508
+ readonly _validatedVerbose: _owanturist_signal.ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
523
509
  _forceValidated(monitor: Monitor): void;
524
510
  readonly _dirty: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
525
- readonly _dirtyVerbose: _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>;
526
- readonly _dirtyOn: _owanturist_signal.ReadonlySignal<FormShapeFlag<TFields>>;
527
- 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">>;
528
513
  _reset(monitor: Monitor, resetter: undefined | FormShapeInputSetter<TFields>): void;
529
514
  _getChildren<TChildParams extends SignalFormParams>(): ReadonlyArray<SignalFormChild<TChildParams, FormShapeParams<TFields>>>;
530
515
  }
531
516
 
532
- type FormShapeField<TField> = TField extends SignalForm ? TField : FormMeta<TField>;
533
- declare class FormShape$1<TFields extends FormShapeFields> extends SignalForm<FormShapeParams<TFields>> {
517
+ declare class FormShape$1<TFields extends FormShapeFields<TFields>> extends SignalForm<FormShapeParams<TFields>> {
534
518
  readonly _state: FormShapeState<TFields>;
535
519
  static _getState: typeof SignalForm._getState;
536
- readonly fields: {
537
- readonly [TField in keyof TFields]: FormShapeField<TFields[TField]>;
538
- };
520
+ readonly fields: TFields;
539
521
  constructor(_state: FormShapeState<TFields>);
540
522
  }
541
523
 
542
- interface FormShapeOptions<TFields extends FormShapeFields> {
524
+ interface FormShapeOptions<TFields extends FormShapeFields<TFields>> {
543
525
  readonly input?: FormShapeInputSetter<TFields>;
544
526
  readonly initial?: FormShapeInputSetter<TFields>;
545
527
  readonly touched?: FormShapeFlagSetter<TFields>;
546
528
  readonly validateOn?: FormShapeValidateOnSetter<TFields>;
547
529
  readonly error?: FormShapeErrorSetter<TFields>;
548
530
  }
549
- type FormShape<TFields extends FormShapeFields> = FormShape$1<TFields>;
550
- declare function FormShape<TFields extends FormShapeFields>(fields: TFields, { input, initial, touched, validateOn, error }?: FormShapeOptions<TFields>): FormShape<TFields>;
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>;
551
533
 
552
534
  declare function isFormShape(value: unknown): value is FormShape$1<FormShapeFields>;
553
535
 
@@ -565,7 +547,7 @@ type FormListFlagSetter<TElement extends SignalForm> = Setter<boolean | Readonly
565
547
 
566
548
  type FormListInput<TElement extends SignalForm> = ReadonlyArray<GetSignalFormInput<TElement>>;
567
549
 
568
- type FormListInputSetter<TElement extends SignalForm> = Setter<ReadonlyArray<undefined | GetSignalFormInputSetter<TElement>>, [
550
+ type FormListInputSetter<TElement extends SignalForm> = Setter<ReadonlyArray<GetSignalFormInput<TElement>>, [
569
551
  FormListInput<TElement>,
570
552
  FormListInput<TElement>
571
553
  ]>;
@@ -602,17 +584,18 @@ interface FormListParams<TElement extends SignalForm> extends SignalFormParams {
602
584
  "error.schema.verbose": FormListErrorVerbose<TElement>;
603
585
  }
604
586
 
587
+ type FormListElementFactoryInternal<TElement extends SignalForm> = (input: GetSignalFormInput<TElement>, index: number) => SignalFormState<GetSignalFormParams<TElement>>;
605
588
  declare class FormListState<TElement extends SignalForm = SignalForm> extends SignalFormState<FormListParams<TElement>> {
589
+ private readonly _factory;
590
+ readonly _initialInputs: Signal<ReadonlyArray<GetSignalFormInput<TElement>>>;
606
591
  readonly _host: Lazy<FormList$1<TElement>>;
607
592
  readonly _elements: Signal<ReadonlyArray<SignalFormState<GetSignalFormParams<TElement>>>>;
608
- private readonly _initialElements;
609
- 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>>>);
610
594
  _childOf(parent: null | SignalFormState): FormListState<TElement>;
611
595
  _getElements(monitor: Monitor): ReadonlyArray<TElement>;
612
- _getInitialElements(monitor: Monitor): ReadonlyArray<SignalFormState<GetSignalFormParams<TElement>>>;
613
596
  readonly _initial: _owanturist_signal.ReadonlySignal<FormListInput<TElement>>;
614
- _replaceInitial(monitor: Monitor, state: undefined | FormListState<TElement>, isMounting: boolean): void;
615
597
  _setInitial(monitor: Monitor, setter: FormListInputSetter<TElement>): void;
598
+ _patchInitial(monitor: Monitor, initials: FormListInput<TElement>): void;
616
599
  readonly _input: _owanturist_signal.ReadonlySignal<FormListInput<TElement>>;
617
600
  _setInput(monitor: Monitor, setter: FormListInputSetter<TElement>): void;
618
601
  readonly _error: _owanturist_signal.ReadonlySignal<FormListError<TElement>>;
@@ -635,7 +618,6 @@ declare class FormListState<TElement extends SignalForm = SignalForm> extends Si
635
618
  _forceValidated(monitor: Monitor): void;
636
619
  readonly _dirty: _owanturist_signal.ReadonlySignal<FormListFlag<TElement>>;
637
620
  readonly _dirtyVerbose: _owanturist_signal.ReadonlySignal<FormListFlagVerbose<TElement>>;
638
- readonly _dirtyOn: _owanturist_signal.ReadonlySignal<FormListFlag<TElement>>;
639
621
  readonly _dirtyOnVerbose: _owanturist_signal.ReadonlySignal<FormListFlagVerbose<TElement>>;
640
622
  _reset(monitor: Monitor, resetter: undefined | FormListInputSetter<TElement>): void;
641
623
  _getChildren<TChildParams extends SignalFormParams>(monitor: Monitor): ReadonlyArray<SignalFormChild<TChildParams, FormListParams<TElement>>>;
@@ -651,15 +633,22 @@ declare class FormList$1<TElement extends SignalForm> extends SignalForm<FormLis
651
633
  setElements(setter: Setter<ReadonlyArray<TElement>, [ReadonlyArray<TElement>, Monitor]>): void;
652
634
  }
653
635
 
636
+ type FormListElementFactory<TElement extends SignalForm> = (input: GetSignalFormInput<TElement>, index: number) => TElement;
654
637
  interface FormListOptions<TElement extends SignalForm> {
655
- readonly input?: FormListInputSetter<TElement>;
638
+ /**
639
+ * @default []
640
+ */
656
641
  readonly initial?: FormListInputSetter<TElement>;
642
+ /**
643
+ * @default {@link initial}
644
+ */
645
+ readonly input?: FormListInputSetter<TElement>;
657
646
  readonly touched?: FormListFlagSetter<TElement>;
658
647
  readonly validateOn?: FormListValidateOnSetter<TElement>;
659
648
  readonly error?: FormListErrorSetter<TElement>;
660
649
  }
661
650
  type FormList<TElement extends SignalForm> = FormList$1<TElement>;
662
- declare function FormList<TElement extends SignalForm>(elements: ReadonlyArray<TElement>, { input, initial, touched, validateOn, error }?: FormListOptions<TElement>): FormList<TElement>;
651
+ declare function FormList<TElement extends SignalForm>(factory: FormListElementFactory<TElement>, { input, initial, touched, validateOn, error }?: FormListOptions<TElement>): FormList<TElement>;
663
652
 
664
653
  declare function isFormList(value: unknown): value is FormList$1<SignalForm>;
665
654
 
@@ -735,7 +724,7 @@ declare class FormOptionalState<TEnabled extends SignalForm, TElement extends Si
735
724
  private _toVerbose;
736
725
  readonly _initial: _owanturist_signal.ReadonlySignal<FormOptionalInput<TEnabled, TElement>>;
737
726
  _setInitial(monitor: Monitor, setter: FormOptionalInputSetter<TEnabled, TElement>): void;
738
- _replaceInitial(monitor: Monitor, state: undefined | FormOptionalState<TEnabled, TElement>, isMounting: boolean): void;
727
+ _patchInitial(monitor: Monitor, initial: FormOptionalInput<TEnabled, TElement>): void;
739
728
  readonly _input: _owanturist_signal.ReadonlySignal<FormOptionalInput<TEnabled, TElement>>;
740
729
  _setInput(monitor: Monitor, setter: FormOptionalInputSetter<TEnabled, TElement>): void;
741
730
  readonly _error: _owanturist_signal.ReadonlySignal<FormOptionalError<TEnabled, TElement>>;
@@ -758,7 +747,6 @@ declare class FormOptionalState<TEnabled extends SignalForm, TElement extends Si
758
747
  _forceValidated(monitor: Monitor): void;
759
748
  readonly _dirty: _owanturist_signal.ReadonlySignal<FormOptionalFlag<TEnabled, TElement>>;
760
749
  readonly _dirtyVerbose: _owanturist_signal.ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
761
- readonly _dirtyOn: _owanturist_signal.ReadonlySignal<FormOptionalFlag<TEnabled, TElement>>;
762
750
  readonly _dirtyOnVerbose: _owanturist_signal.ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
763
751
  _reset(monitor: Monitor, resetter: undefined | FormOptionalInputSetter<TEnabled, TElement>): void;
764
752
  _getChildren<TChildParams extends SignalFormParams>(monitor: Monitor): ReadonlyArray<SignalFormChild<TChildParams, FormOptionalParams<TEnabled, TElement>>>;
@@ -792,6 +780,10 @@ interface FormSwitchConciseSchema<TActive, TBranch> {
792
780
  readonly branch: TBranch;
793
781
  }
794
782
 
783
+ type Compute<Obj> = unknown & {
784
+ [K in keyof Obj]: Obj[K];
785
+ };
786
+
795
787
  interface FormSwitchVerboseSchema<TActive, TBranches> {
796
788
  readonly active: TActive;
797
789
  readonly branches: TBranches;
@@ -902,7 +894,7 @@ declare class FormSwitchState<TKind extends SignalForm, TBranches extends FormSw
902
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]; };
903
895
  }>;
904
896
  _setInitial(monitor: Monitor, setter: FormSwitchInputSetter<TKind, TBranches>): void;
905
- _replaceInitial(monitor: Monitor, state: undefined | FormSwitchState<TKind, TBranches>, isMounting: boolean): void;
897
+ _patchInitial(monitor: Monitor, initial: FormSwitchInput<TKind, TBranches>): void;
906
898
  readonly _input: _owanturist_signal.ReadonlySignal<{
907
899
  readonly active: GetSignalFormParam<TKind, "input.schema">;
908
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]; };
@@ -952,7 +944,6 @@ declare class FormSwitchState<TKind extends SignalForm, TBranches extends FormSw
952
944
  readonly active: GetSignalFormParam<TKind, "flag.schema.verbose">;
953
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]; };
954
946
  }>;
955
- readonly _dirtyOn: _owanturist_signal.ReadonlySignal<FormSwitchFlag<TKind, TBranches>>;
956
947
  readonly _dirtyOnVerbose: _owanturist_signal.ReadonlySignal<{
957
948
  readonly active: GetSignalFormParam<TKind, "flag.schema.verbose">;
958
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]; };
@@ -982,4 +973,4 @@ declare function FormSwitch<TKind extends SignalForm, TBranches extends FormSwit
982
973
 
983
974
  declare function isFormSwitch(anything: unknown): anything is FormSwitch$1<SignalForm, FormSwitchBranches<SignalForm>>;
984
975
 
985
- 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, type FormMeta, 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 };
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 };