@owanturist/signal-form 0.5.0 → 0.5.1
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 +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +639 -830
- package/dist/index.d.ts +639 -830
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,413 +1,374 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ReadonlySignal, Monitor, Signal, Equal } from '@owanturist/signal';
|
|
3
|
-
|
|
1
|
+
import { Equal, Monitor, ReadonlySignal, Signal } from "@owanturist/signal";
|
|
4
2
|
type Result<TError, TData> = [TError, null] | [null, TData];
|
|
5
|
-
|
|
6
3
|
type ValidateStrategy = "onTouch" | "onChange" | "onSubmit" | "onInit";
|
|
7
4
|
declare const VALIDATE_ON_TOUCH: "onTouch";
|
|
8
5
|
declare const VALIDATE_ON_CHANGE: "onChange";
|
|
9
6
|
declare const VALIDATE_ON_SUBMIT: "onSubmit";
|
|
10
7
|
declare const VALIDATE_ON_INIT: "onInit";
|
|
11
|
-
|
|
12
8
|
interface SignalFormParams {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
9
|
+
readonly "input.setter": unknown;
|
|
10
|
+
readonly "input.schema": unknown;
|
|
11
|
+
readonly "output.schema": unknown;
|
|
12
|
+
readonly "output.schema.verbose": unknown;
|
|
13
|
+
readonly "flag.setter": unknown;
|
|
14
|
+
readonly "flag.schema": unknown;
|
|
15
|
+
readonly "flag.schema.verbose": unknown;
|
|
16
|
+
readonly "validateOn.setter": unknown;
|
|
17
|
+
readonly "validateOn.schema": unknown;
|
|
18
|
+
readonly "validateOn.schema.verbose": unknown;
|
|
19
|
+
readonly "error.setter": unknown;
|
|
20
|
+
readonly "error.schema": unknown;
|
|
21
|
+
readonly "error.schema.verbose": unknown;
|
|
22
|
+
}
|
|
28
23
|
declare class Emitter<TPayload = unknown, TResult = void> {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
private readonly _listeners;
|
|
25
|
+
_subscribe(listener: (payload: TPayload) => TResult): VoidFunction;
|
|
26
|
+
_emit(payload: TPayload): ReadonlyArray<TResult>;
|
|
27
|
+
_isEmpty(): boolean;
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
type Lazy<T> = () => T;
|
|
36
|
-
declare
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
30
|
+
declare abstract class SignalFormState<TParams extends SignalFormParams = any, THost extends SignalForm<TParams> = SignalForm<TParams>> {
|
|
31
|
+
abstract readonly _host: Lazy<THost>;
|
|
32
|
+
readonly _root: SignalFormState;
|
|
33
|
+
constructor(parent: null | SignalFormState);
|
|
34
|
+
protected abstract _childOf(parent: null | SignalFormState): SignalFormState<TParams, THost>;
|
|
35
|
+
_clone(): SignalFormState<TParams, THost>;
|
|
36
|
+
_parentOf<TChildParams extends SignalFormParams, TChildHost extends SignalForm<TChildParams>>(child: SignalFormState<TChildParams, TChildHost>): SignalFormState<TChildParams, TChildHost>;
|
|
37
|
+
_hasSameRootWith(another: SignalFormState): boolean;
|
|
38
|
+
abstract readonly _initial: ReadonlySignal<TParams["input.schema"]>;
|
|
39
|
+
abstract _setInitial(monitor: Monitor, setter: TParams["input.setter"]): void;
|
|
40
|
+
/**
|
|
41
|
+
* Like {@link _setInitial} but a no-op for explicitly set initials.
|
|
42
|
+
*/
|
|
43
|
+
abstract _patchInitial(monitor: Monitor, initial: TParams["input.schema"]): void;
|
|
44
|
+
abstract readonly _input: ReadonlySignal<TParams["input.schema"]>;
|
|
45
|
+
abstract _setInput(monitor: Monitor, setter: TParams["input.setter"]): void;
|
|
46
|
+
abstract readonly _error: ReadonlySignal<null | TParams["error.schema"]>;
|
|
47
|
+
abstract readonly _errorVerbose: ReadonlySignal<TParams["error.schema.verbose"]>;
|
|
48
|
+
abstract _setError(monitor: Monitor, setter: TParams["error.setter"]): void;
|
|
49
|
+
abstract readonly _validateOn: ReadonlySignal<TParams["validateOn.schema"]>;
|
|
50
|
+
abstract readonly _validateOnVerbose: ReadonlySignal<TParams["validateOn.schema.verbose"]>;
|
|
51
|
+
abstract _setValidateOn(monitor: Monitor, setter: TParams["validateOn.setter"]): void;
|
|
52
|
+
abstract readonly _touched: ReadonlySignal<TParams["flag.schema"]>;
|
|
53
|
+
abstract readonly _touchedVerbose: ReadonlySignal<TParams["flag.schema.verbose"]>;
|
|
54
|
+
abstract _setTouched(monitor: Monitor, setter: TParams["flag.setter"]): void;
|
|
55
|
+
abstract readonly _output: ReadonlySignal<null | TParams["output.schema"]>;
|
|
56
|
+
abstract readonly _outputVerbose: ReadonlySignal<TParams["output.schema.verbose"]>;
|
|
57
|
+
abstract readonly _valid: ReadonlySignal<TParams["flag.schema"]>;
|
|
58
|
+
abstract readonly _validVerbose: ReadonlySignal<TParams["flag.schema.verbose"]>;
|
|
59
|
+
abstract readonly _invalid: ReadonlySignal<TParams["flag.schema"]>;
|
|
60
|
+
abstract readonly _invalidVerbose: ReadonlySignal<TParams["flag.schema.verbose"]>;
|
|
61
|
+
abstract readonly _validated: ReadonlySignal<TParams["flag.schema"]>;
|
|
62
|
+
abstract readonly _validatedVerbose: ReadonlySignal<TParams["flag.schema.verbose"]>;
|
|
63
|
+
abstract _forceValidated(monitor: Monitor): void;
|
|
64
|
+
abstract readonly _dirty: ReadonlySignal<TParams["flag.schema"]>;
|
|
65
|
+
abstract readonly _dirtyVerbose: ReadonlySignal<TParams["flag.schema.verbose"]>;
|
|
66
|
+
abstract readonly _dirtyOnVerbose: ReadonlySignal<TParams["flag.schema.verbose"]>;
|
|
67
|
+
readonly _onFocus: Emitter<unknown, void>;
|
|
68
|
+
_getFocusFirstInvalid(monitor: Monitor): null | VoidFunction;
|
|
69
|
+
readonly _onSubmit: Emitter<unknown, void | Promise<unknown>>;
|
|
70
|
+
readonly _submitAttempts: Signal<number>;
|
|
71
|
+
readonly _submittingCount: Signal<number>;
|
|
72
|
+
_submitWith(monitor: Monitor, output: TParams["output.schema"]): ReadonlyArray<void | Promise<unknown>>;
|
|
73
|
+
/**
|
|
74
|
+
* Comparing to {@link _setInitial} where the setter is always provided,
|
|
75
|
+
* this method allows the resetter to be undefined.
|
|
76
|
+
* This is for cases when the initial value is not changed BUT
|
|
77
|
+
* the {@link SignalForm} should perform the rest of reset operations,
|
|
78
|
+
* in comparison to {@link _setInitial} which only sets the initial value AND
|
|
79
|
+
* not called at all if the setter is not provided.
|
|
80
|
+
*/
|
|
81
|
+
abstract _reset(monitor: Monitor, resetter: undefined | TParams["input.setter"]): void;
|
|
82
|
+
abstract _getChildren(monitor: Monitor): ReadonlyArray<SignalFormChild<TParams>>;
|
|
83
|
+
}
|
|
84
|
+
interface SignalFormChild<TParams extends SignalFormParams> {
|
|
85
|
+
_state: SignalFormState;
|
|
86
|
+
_mapToChild: (this: void, parentValue: TParams["output.schema"]) => unknown;
|
|
87
|
+
}
|
|
88
|
+
type GetFormState<TForm extends SignalForm> = SignalFormState<GetFormParams<TForm>, TForm>;
|
|
97
89
|
declare abstract class SignalForm<TParams extends SignalFormParams = any> {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
90
|
+
protected static _getState<TForm extends SignalForm>(form: TForm): GetFormState<TForm>;
|
|
91
|
+
protected abstract readonly _state: SignalFormState<TParams>;
|
|
92
|
+
clone(): SignalForm<TParams>;
|
|
93
|
+
getOutput(monitor: Monitor): null | TParams["output.schema"];
|
|
94
|
+
getOutput<TResult>(monitor: Monitor, select: (concise: null | TParams["output.schema"], verbose: TParams["output.schema.verbose"]) => TResult): TResult;
|
|
95
|
+
getInitial(monitor: Monitor): TParams["input.schema"];
|
|
96
|
+
setInitial(setter: TParams["input.setter"]): void;
|
|
97
|
+
getInput(monitor: Monitor): TParams["input.schema"];
|
|
98
|
+
setInput(setter: TParams["input.setter"]): void;
|
|
99
|
+
getError(monitor: Monitor): null | TParams["error.schema"];
|
|
100
|
+
getError<TResult>(monitor: Monitor, select: (concise: null | TParams["error.schema"], verbose: TParams["error.schema.verbose"]) => TResult): TResult;
|
|
101
|
+
setError(setter: TParams["error.setter"]): void;
|
|
102
|
+
getValidateOn(monitor: Monitor): TParams["validateOn.schema"];
|
|
103
|
+
getValidateOn<TResult>(monitor: Monitor, select: (concise: TParams["validateOn.schema"], verbose: TParams["validateOn.schema.verbose"]) => TResult): TResult;
|
|
104
|
+
setValidateOn(setter: TParams["validateOn.setter"]): void;
|
|
105
|
+
isValid(monitor: Monitor): boolean;
|
|
106
|
+
isValid<TResult>(monitor: Monitor, select: (concise: TParams["flag.schema"], verbose: TParams["flag.schema.verbose"]) => TResult): TResult;
|
|
107
|
+
isInvalid(monitor: Monitor): boolean;
|
|
108
|
+
isInvalid<TResult>(monitor: Monitor, select: (concise: TParams["flag.schema"], verbose: TParams["flag.schema.verbose"]) => TResult): TResult;
|
|
109
|
+
isValidated(monitor: Monitor): boolean;
|
|
110
|
+
isValidated<TResult>(monitor: Monitor, select: (concise: TParams["flag.schema"], verbose: TParams["flag.schema.verbose"]) => TResult): TResult;
|
|
111
|
+
isDirty(monitor: Monitor): boolean;
|
|
112
|
+
isDirty<TResult>(monitor: Monitor, select: (concise: TParams["flag.schema"], verbose: TParams["flag.schema.verbose"]) => TResult): TResult;
|
|
113
|
+
isTouched(monitor: Monitor): boolean;
|
|
114
|
+
isTouched<TResult>(monitor: Monitor, select: (concise: TParams["flag.schema"], verbose: TParams["flag.schema.verbose"]) => TResult): TResult;
|
|
115
|
+
setTouched(setter: TParams["flag.setter"]): void;
|
|
116
|
+
reset(resetter?: TParams["input.setter"]): void;
|
|
117
|
+
onFocusWhenInvalid(onFocus: (error: TParams["error.schema.verbose"]) => void): VoidFunction;
|
|
118
|
+
focusFirstInvalid(): void;
|
|
119
|
+
getSubmitCount(monitor: Monitor): number;
|
|
120
|
+
isSubmitting(monitor: Monitor): boolean;
|
|
121
|
+
onSubmit(listener: (output: TParams["output.schema"]) => void | Promise<unknown>): VoidFunction;
|
|
122
|
+
submit(): Promise<void>;
|
|
123
|
+
}
|
|
133
124
|
type GetFormParams<TTarget> = TTarget extends SignalForm<infer TParams> ? TParams : never;
|
|
134
|
-
|
|
135
125
|
type GetFormParam<TTarget, TKey extends keyof SignalFormParams> = GetFormParams<TTarget>[TKey];
|
|
136
|
-
|
|
137
126
|
type GetFormError<TForm extends SignalForm> = GetFormParam<TForm, "error.schema">;
|
|
138
|
-
|
|
139
127
|
type GetFormErrorSetter<TForm extends SignalForm> = GetFormParam<TForm, "error.setter">;
|
|
140
|
-
|
|
141
128
|
type GetFormErrorVerbose<TForm extends SignalForm> = GetFormParam<TForm, "error.schema.verbose">;
|
|
142
|
-
|
|
143
129
|
type GetFormFlag<TForm extends SignalForm> = GetFormParam<TForm, "flag.schema">;
|
|
144
|
-
|
|
145
130
|
type GetFormFlagSetter<TForm extends SignalForm> = GetFormParam<TForm, "flag.setter">;
|
|
146
|
-
|
|
147
131
|
type GetFormFlagVerbose<TForm extends SignalForm> = GetFormParam<TForm, "flag.schema.verbose">;
|
|
148
|
-
|
|
149
132
|
type GetFormInput<TForm extends SignalForm> = GetFormParam<TForm, "input.schema">;
|
|
150
|
-
|
|
151
133
|
type GetFormInputSetter<TForm extends SignalForm> = GetFormParam<TForm, "input.setter">;
|
|
152
|
-
|
|
153
134
|
type GetFormOutput<TForm extends SignalForm> = GetFormParam<TForm, "output.schema">;
|
|
154
|
-
|
|
155
135
|
type GetFormOutputVerbose<TForm extends SignalForm> = GetFormParam<TForm, "output.schema.verbose">;
|
|
156
|
-
|
|
157
136
|
type GetFormValidateOn<TForm extends SignalForm> = GetFormParam<TForm, "validateOn.schema">;
|
|
158
|
-
|
|
159
137
|
type GetFormValidateOnSetter<TForm extends SignalForm> = GetFormParam<TForm, "validateOn.setter">;
|
|
160
|
-
|
|
161
138
|
type GetFormValidateOnVerbose<TForm extends SignalForm> = GetFormParam<TForm, "validateOn.schema.verbose">;
|
|
162
|
-
|
|
163
139
|
declare function isSignalForm(value: unknown): value is SignalForm;
|
|
164
|
-
|
|
165
140
|
type FormUnitTransformer<TInput, TOutput> = (input: TInput) => TOutput;
|
|
166
|
-
|
|
167
141
|
type FormUnitValidator<TInput, TError, TOutput> = (input: TInput) => Result<TError, TOutput>;
|
|
168
|
-
|
|
169
142
|
type Setter<TValue, TPrevValues extends ReadonlyArray<unknown> = [TValue]> = TValue | ((...args: TPrevValues) => TValue);
|
|
170
|
-
|
|
171
143
|
type FormUnitErrorSetter<TError> = Setter<null | TError>;
|
|
172
|
-
|
|
173
144
|
type FormUnitFlagSetter = Setter<boolean>;
|
|
174
|
-
|
|
175
145
|
type FormUnitInputSetter<TInput> = Setter<TInput, [TInput, TInput]>;
|
|
176
|
-
|
|
177
146
|
type FormUnitValidateOnSetter = Setter<ValidateStrategy>;
|
|
178
|
-
|
|
179
147
|
interface FormUnitParams<TInput, TError, TOutput> extends SignalFormParams {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
148
|
+
readonly "input.setter": FormUnitInputSetter<TInput>;
|
|
149
|
+
readonly "input.schema": TInput;
|
|
150
|
+
readonly "output.schema": TOutput;
|
|
151
|
+
readonly "output.schema.verbose": null | TOutput;
|
|
152
|
+
readonly "flag.setter": FormUnitFlagSetter;
|
|
153
|
+
readonly "flag.schema": boolean;
|
|
154
|
+
readonly "flag.schema.verbose": boolean;
|
|
155
|
+
readonly "validateOn.setter": FormUnitValidateOnSetter;
|
|
156
|
+
readonly "validateOn.schema": ValidateStrategy;
|
|
157
|
+
readonly "validateOn.schema.verbose": ValidateStrategy;
|
|
158
|
+
readonly "error.setter": FormUnitErrorSetter<TError>;
|
|
159
|
+
readonly "error.schema": null | TError;
|
|
160
|
+
readonly "error.schema.verbose": null | TError;
|
|
161
|
+
}
|
|
195
162
|
interface ZodLikeIssue {
|
|
196
|
-
|
|
163
|
+
message: string;
|
|
197
164
|
}
|
|
198
165
|
type ZodLikeError = {
|
|
199
|
-
|
|
166
|
+
get errors(): ReadonlyArray<ZodLikeIssue>;
|
|
200
167
|
} | {
|
|
201
|
-
|
|
168
|
+
errors: ReadonlyArray<ZodLikeIssue>;
|
|
202
169
|
} | {
|
|
203
|
-
|
|
170
|
+
issues: ReadonlyArray<ZodLikeIssue>;
|
|
204
171
|
};
|
|
205
172
|
type ZodLikeSafeParseResult<TOutput> = {
|
|
206
|
-
|
|
207
|
-
|
|
173
|
+
success: false;
|
|
174
|
+
error: ZodLikeError;
|
|
208
175
|
} | {
|
|
209
|
-
|
|
210
|
-
|
|
176
|
+
success: true;
|
|
177
|
+
data: TOutput;
|
|
211
178
|
};
|
|
212
179
|
type ZodLikeSchema<TOutput> = {
|
|
213
|
-
|
|
180
|
+
parse(input: unknown): TOutput;
|
|
214
181
|
} | {
|
|
215
|
-
|
|
182
|
+
safeParse(input: unknown): ZodLikeSafeParseResult<TOutput>;
|
|
216
183
|
};
|
|
217
184
|
declare function zodLikeParse<TOutput>(schema: ZodLikeSchema<TOutput>, input: unknown): Result<ReadonlyArray<string>, TOutput>;
|
|
218
|
-
|
|
219
185
|
interface FormUnitTransform<TInput, TError, TOutput> {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
186
|
+
readonly _transformer: boolean;
|
|
187
|
+
readonly _validator: FormUnitValidator<TInput, TError, TOutput>;
|
|
188
|
+
}
|
|
189
|
+
declare class FormUnitState<TInput, TError, TOutput> extends SignalFormState<FormUnitParams<TInput, TError, TOutput>, FormUnit$1<TInput, TError, TOutput>> {
|
|
190
|
+
readonly _initial: Signal<TInput>;
|
|
191
|
+
readonly _input: Signal<TInput>;
|
|
192
|
+
private readonly _customError;
|
|
193
|
+
readonly _validateOn: Signal<ValidateStrategy>;
|
|
194
|
+
readonly _touched: Signal<boolean>;
|
|
195
|
+
private readonly _transform;
|
|
196
|
+
private readonly _isInputDirty;
|
|
197
|
+
private readonly _isOutputEqual;
|
|
198
|
+
private readonly _isErrorEqual;
|
|
199
|
+
private _isInitialExplicit;
|
|
200
|
+
readonly _host: Lazy<FormUnit$1<TInput, TError, TOutput>>;
|
|
201
|
+
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);
|
|
202
|
+
_childOf(parent: null | SignalFormState): FormUnitState<TInput, TError, TOutput>;
|
|
203
|
+
_setInitial(monitor: Monitor, setter: FormUnitInputSetter<TInput>): void;
|
|
204
|
+
_patchInitial(_monitor: Monitor, candidate: TInput): void;
|
|
205
|
+
_setInput(monitor: Monitor, setter: FormUnitInputSetter<TInput>): void;
|
|
206
|
+
readonly _error: ReadonlySignal<null | TError>;
|
|
207
|
+
readonly _errorVerbose: ReadonlySignal<null | TError>;
|
|
208
|
+
_setError(_monitor: Monitor, setter: FormUnitErrorSetter<TError>): void;
|
|
209
|
+
readonly _validateOnVerbose: ReadonlySignal<ValidateStrategy>;
|
|
210
|
+
_setValidateOn(monitor: Monitor, setter: FormUnitValidateOnSetter): void;
|
|
211
|
+
readonly _touchedVerbose: ReadonlySignal<boolean>;
|
|
212
|
+
_setTouched(_monitor: Monitor, setter: FormUnitParams<TInput, TError, TOutput>["flag.setter"]): void;
|
|
213
|
+
readonly _output: ReadonlySignal<null | TOutput>;
|
|
214
|
+
readonly _outputVerbose: ReadonlySignal<null | TOutput>;
|
|
215
|
+
readonly _valid: ReadonlySignal<boolean>;
|
|
216
|
+
readonly _validVerbose: ReadonlySignal<boolean>;
|
|
217
|
+
readonly _invalid: ReadonlySignal<boolean>;
|
|
218
|
+
readonly _invalidVerbose: ReadonlySignal<boolean>;
|
|
219
|
+
readonly _validated: Signal<boolean>;
|
|
220
|
+
readonly _validatedVerbose: ReadonlySignal<boolean>;
|
|
221
|
+
_forceValidated(): void;
|
|
222
|
+
readonly _dirty: ReadonlySignal<boolean>;
|
|
223
|
+
readonly _dirtyVerbose: ReadonlySignal<boolean>;
|
|
224
|
+
readonly _dirtyOnVerbose: Signal<boolean>;
|
|
225
|
+
_reset(monitor: Monitor, resetter: undefined | FormUnitInputSetter<TInput>): void;
|
|
226
|
+
_getChildren(): ReadonlyArray<never>;
|
|
227
|
+
_setTransform(transformer: FormUnitTransformer<TInput, TOutput>): void;
|
|
228
|
+
}
|
|
265
229
|
declare class FormUnit$1<TInput, TError, TOutput> extends SignalForm<FormUnitParams<TInput, TError, TOutput>> {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
230
|
+
readonly _state: FormUnitState<TInput, TError, TOutput>;
|
|
231
|
+
constructor(_state: FormUnitState<TInput, TError, TOutput>);
|
|
232
|
+
setTransform(transformer: FormUnitTransformer<TInput, TOutput>): void;
|
|
269
233
|
}
|
|
270
|
-
|
|
234
|
+
type FormUnit<TInput, TError = null, TOutput = TInput> = FormUnit$1<TInput, TError, TOutput>;
|
|
271
235
|
interface FormUnitOptions<TInput, TError = null> {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
236
|
+
/**
|
|
237
|
+
* The initial or custom error associated with the form value.
|
|
238
|
+
* This can be used to set an error state manually.
|
|
239
|
+
*
|
|
240
|
+
* @default null
|
|
241
|
+
*/
|
|
242
|
+
readonly error?: null | TError;
|
|
243
|
+
readonly touched?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* PERFORMANCE OPTIMIZATION
|
|
246
|
+
*
|
|
247
|
+
* A equality check function that determines whether the input value changes.
|
|
248
|
+
* When it does, the {@link SignalForm.getInput} returns the new value.
|
|
249
|
+
* Otherwise, it returns the previous value.
|
|
250
|
+
*
|
|
251
|
+
* Useful for none primitive values such as Objects, Arrays, Date, etc.
|
|
252
|
+
* Intended to improve performance but do not affect business logic.
|
|
253
|
+
*
|
|
254
|
+
* @default Object.is
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* const initial = { count: 0 }
|
|
258
|
+
*
|
|
259
|
+
* const form = FormUnit(initial, {
|
|
260
|
+
* isInputEqual: (left, right) => left.count === right.count,
|
|
261
|
+
* })
|
|
262
|
+
*
|
|
263
|
+
* form.setInput({ count: 0 })
|
|
264
|
+
* form.getInput(monitor) === initial // true
|
|
265
|
+
*/
|
|
266
|
+
readonly isInputEqual?: Equal<TInput>;
|
|
267
|
+
/**
|
|
268
|
+
* BUSINESS LOGIC TUNING
|
|
269
|
+
*
|
|
270
|
+
* A equality check function that determines whether the input is dirty.
|
|
271
|
+
* When it is, the {@link SignalForm.isDirty} returns true.
|
|
272
|
+
* Fallbacks to not(isInputEqual) if not provided.
|
|
273
|
+
*
|
|
274
|
+
* Useful for values that have intermediate states deviating from the initial value,
|
|
275
|
+
* but should not be considered dirty such as strings, unsorted arrays, etc.
|
|
276
|
+
* Intended to tune business logic and avoid false positives for dirty states.
|
|
277
|
+
*
|
|
278
|
+
* @default not(isInputEqual)
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* const form = FormUnit("", {
|
|
282
|
+
* isInputDirty: (left, right) => left.trim() !== right.trim(),
|
|
283
|
+
* })
|
|
284
|
+
*
|
|
285
|
+
* form.setInput(" ")
|
|
286
|
+
* form.isDirty(monitor) === false
|
|
287
|
+
*/
|
|
288
|
+
readonly isInputDirty?: Equal<TInput>;
|
|
289
|
+
/**
|
|
290
|
+
* PERFORMANCE OPTIMIZATION
|
|
291
|
+
*
|
|
292
|
+
* A equality check function that determines whether the validation error change.
|
|
293
|
+
* When it does, the {@link SignalForm.getError} returns the new value.
|
|
294
|
+
* Otherwise, it returns the previous value.
|
|
295
|
+
*
|
|
296
|
+
* Useful for none primitive values such as Objects, Arrays, Date, etc.
|
|
297
|
+
* Intended to improve performance but do not affect business logic.
|
|
298
|
+
*
|
|
299
|
+
* @default Object.is
|
|
300
|
+
*/
|
|
301
|
+
readonly isErrorEqual?: Equal<TError>;
|
|
302
|
+
/**
|
|
303
|
+
* @default input
|
|
304
|
+
*/
|
|
305
|
+
readonly initial?: TInput;
|
|
342
306
|
}
|
|
343
307
|
interface FormUnitTransformedOptions<TInput, TError = null, TOutput = TInput> extends FormUnitOptions<TInput, TError> {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
308
|
+
readonly transform: FormUnitTransformer<TInput, TOutput>;
|
|
309
|
+
readonly validate?: never;
|
|
310
|
+
readonly schema?: never;
|
|
311
|
+
readonly validateOn?: never;
|
|
312
|
+
/**
|
|
313
|
+
* PERFORMANCE OPTIMIZATION
|
|
314
|
+
*
|
|
315
|
+
* A equality check function that determines whether the output value changes.
|
|
316
|
+
* When it does, the {@link SignalForm.getOutput} returns the new value.
|
|
317
|
+
*
|
|
318
|
+
* Useful for none primitive values such as Objects, Arrays, Date, etc.
|
|
319
|
+
* Intended to improve performance but do not affect business logic.
|
|
320
|
+
*
|
|
321
|
+
* @default Object.is
|
|
322
|
+
*/
|
|
323
|
+
readonly isOutputEqual?: Equal<TOutput>;
|
|
360
324
|
}
|
|
361
325
|
interface FormUnitSchemaOptions<TInput, TOutput = TInput> extends Omit<FormUnitOptions<TInput, ReadonlyArray<string>>, "isErrorEqual"> {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
326
|
+
readonly schema: ZodLikeSchema<TOutput>;
|
|
327
|
+
/**
|
|
328
|
+
* @default "onTouch"
|
|
329
|
+
*/
|
|
330
|
+
readonly validateOn?: ValidateStrategy;
|
|
331
|
+
readonly transform?: never;
|
|
332
|
+
readonly validate?: never;
|
|
333
|
+
/**
|
|
334
|
+
* PERFORMANCE OPTIMIZATION
|
|
335
|
+
*
|
|
336
|
+
* A equality check function that determines whether the output value changes.
|
|
337
|
+
* When it does, the {@link SignalForm.getOutput} returns the new value.
|
|
338
|
+
*
|
|
339
|
+
* Useful for none primitive values such as Objects, Arrays, Date, etc.
|
|
340
|
+
* Intended to improve performance but do not affect business logic.
|
|
341
|
+
*
|
|
342
|
+
* @default Object.is
|
|
343
|
+
*/
|
|
344
|
+
readonly isOutputEqual?: Equal<TOutput>;
|
|
381
345
|
}
|
|
382
346
|
interface FormUnitValidatedOptions<TInput, TError = null, TOutput = TInput> extends FormUnitOptions<TInput, TError> {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
347
|
+
readonly validate: FormUnitValidator<TInput, TError, TOutput>;
|
|
348
|
+
/**
|
|
349
|
+
* @default "onTouch"
|
|
350
|
+
*/
|
|
351
|
+
readonly validateOn?: ValidateStrategy;
|
|
352
|
+
readonly transform?: never;
|
|
353
|
+
readonly schema?: never;
|
|
354
|
+
/**
|
|
355
|
+
* PERFORMANCE OPTIMIZATION
|
|
356
|
+
*
|
|
357
|
+
* A equality check function that determines whether the output value changes.
|
|
358
|
+
* When it does, the {@link SignalForm.getOutput} returns the new value.
|
|
359
|
+
*
|
|
360
|
+
* Useful for none primitive values such as Objects, Arrays, Date, etc.
|
|
361
|
+
* Intended to improve performance but do not affect business logic.
|
|
362
|
+
*
|
|
363
|
+
* @default Object.is
|
|
364
|
+
*/
|
|
365
|
+
readonly isOutputEqual?: Equal<TOutput>;
|
|
402
366
|
}
|
|
403
|
-
type FormUnit<TInput, TError = null, TOutput = TInput> = FormUnit$1<TInput, TError, TOutput>;
|
|
404
367
|
declare function FormUnit<TInput, TError = null, TOutput = TInput>(input: TInput, options: FormUnitValidatedOptions<TInput, TError, TOutput> | FormUnitTransformedOptions<TInput, TError, TOutput>): FormUnit<TInput, TError, TOutput>;
|
|
405
368
|
declare function FormUnit<TInput, TOutput = TInput>(input: TInput, options: FormUnitSchemaOptions<TInput, TOutput>): FormUnit<TInput, ReadonlyArray<string>, TOutput>;
|
|
406
369
|
declare function FormUnit<TInput>(input: TInput, options?: FormUnitOptions<TInput>): FormUnit<TInput, null, TInput>;
|
|
407
370
|
declare function FormUnit<TInput, TError>(input: TInput, options?: FormUnitOptions<TInput, TError>): FormUnit<TInput, TError, TInput>;
|
|
408
|
-
|
|
409
371
|
declare function isFormUnit(value: unknown): value is FormUnit$1<unknown, unknown, unknown>;
|
|
410
|
-
|
|
411
372
|
/**
|
|
412
373
|
* Self-referential homomorphic constraint: use as `<TFields extends FormShapeFields<TFields>>`.
|
|
413
374
|
*
|
|
@@ -417,560 +378,408 @@ declare function isFormUnit(value: unknown): value is FormUnit$1<unknown, unknow
|
|
|
417
378
|
* each known key against `SignalForm` without requiring an index signature, so both
|
|
418
379
|
* `interface` and `type` declarations satisfy the constraint.
|
|
419
380
|
*/
|
|
420
|
-
type FormShapeFields<TFields = Record<string, SignalForm>> = {
|
|
421
|
-
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
type GetFormShapeParam<TFields extends FormShapeFields<TFields>, TKey extends keyof SignalFormParams> = {
|
|
425
|
-
readonly [TField in keyof TFields]: GetFormParam<TFields[TField], TKey>;
|
|
426
|
-
};
|
|
427
|
-
|
|
381
|
+
type FormShapeFields<TFields = Record<string, SignalForm>> = { readonly [TField in keyof TFields]: SignalForm; };
|
|
382
|
+
type GetFormShapeParam<TFields extends FormShapeFields<TFields>, TKey extends keyof SignalFormParams> = { readonly [TField in keyof TFields]: GetFormParam<TFields[TField], TKey>; };
|
|
428
383
|
type FormShapeErrorVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "error.schema.verbose">;
|
|
429
|
-
|
|
430
|
-
type FormShapeErrorSetter<TFields extends FormShapeFields<TFields>> = Setter<null | Partial<GetFormShapeParam<TFields, "error.setter">>, [
|
|
431
|
-
FormShapeErrorVerbose<TFields>
|
|
432
|
-
]>;
|
|
433
|
-
|
|
384
|
+
type FormShapeErrorSetter<TFields extends FormShapeFields<TFields>> = Setter<null | Partial<GetFormShapeParam<TFields, "error.setter">>, [FormShapeErrorVerbose<TFields>]>;
|
|
434
385
|
type FormShapeFlagVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "flag.schema.verbose">;
|
|
435
|
-
|
|
436
|
-
type FormShapeFlagSetter<TFields extends FormShapeFields<TFields>> = Setter<boolean | Partial<GetFormShapeParam<TFields, "flag.setter">>, [
|
|
437
|
-
FormShapeFlagVerbose<TFields>
|
|
438
|
-
]>;
|
|
439
|
-
|
|
386
|
+
type FormShapeFlagSetter<TFields extends FormShapeFields<TFields>> = Setter<boolean | Partial<GetFormShapeParam<TFields, "flag.setter">>, [FormShapeFlagVerbose<TFields>]>;
|
|
440
387
|
type FormShapeInput<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "input.schema">;
|
|
441
|
-
|
|
442
|
-
type FormShapeInputSetter<TFields extends FormShapeFields<TFields>> = Setter<Partial<GetFormShapeParam<TFields, "input.setter">>, [
|
|
443
|
-
FormShapeInput<TFields>,
|
|
444
|
-
FormShapeInput<TFields>
|
|
445
|
-
]>;
|
|
446
|
-
|
|
388
|
+
type FormShapeInputSetter<TFields extends FormShapeFields<TFields>> = Setter<Partial<GetFormShapeParam<TFields, "input.setter">>, [FormShapeInput<TFields>, FormShapeInput<TFields>]>;
|
|
447
389
|
type FormShapeValidateOnVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "validateOn.schema.verbose">;
|
|
448
|
-
|
|
449
|
-
type FormShapeValidateOnSetter<TFields extends FormShapeFields<TFields>> = Setter<ValidateStrategy | Partial<GetFormShapeParam<TFields, "validateOn.setter">>, [
|
|
450
|
-
FormShapeValidateOnVerbose<TFields>
|
|
451
|
-
]>;
|
|
452
|
-
|
|
390
|
+
type FormShapeValidateOnSetter<TFields extends FormShapeFields<TFields>> = Setter<ValidateStrategy | Partial<GetFormShapeParam<TFields, "validateOn.setter">>, [FormShapeValidateOnVerbose<TFields>]>;
|
|
453
391
|
type FormShapeError<TFields extends FormShapeFields<TFields>> = null | GetFormShapeParam<TFields, "error.schema">;
|
|
454
|
-
|
|
455
392
|
type FormShapeFlag<TFields extends FormShapeFields<TFields>> = boolean | GetFormShapeParam<TFields, "flag.schema">;
|
|
456
|
-
|
|
457
393
|
type FormShapeOutput<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "output.schema">;
|
|
458
|
-
|
|
459
394
|
type FormShapeOutputVerbose<TFields extends FormShapeFields<TFields>> = GetFormShapeParam<TFields, "output.schema.verbose">;
|
|
460
|
-
|
|
461
395
|
type FormShapeValidateOn<TFields extends FormShapeFields<TFields>> = ValidateStrategy | GetFormShapeParam<TFields, "validateOn.schema">;
|
|
462
|
-
|
|
463
396
|
interface FormShapeParams<TFields extends FormShapeFields<TFields>> extends SignalFormParams {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
type
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
|
|
397
|
+
readonly "input.schema": FormShapeInput<TFields>;
|
|
398
|
+
readonly "input.setter": FormShapeInputSetter<TFields>;
|
|
399
|
+
readonly "output.schema": FormShapeOutput<TFields>;
|
|
400
|
+
readonly "output.schema.verbose": FormShapeOutputVerbose<TFields>;
|
|
401
|
+
readonly "flag.setter": FormShapeFlagSetter<TFields>;
|
|
402
|
+
readonly "flag.schema": FormShapeFlag<TFields>;
|
|
403
|
+
readonly "flag.schema.verbose": FormShapeFlagVerbose<TFields>;
|
|
404
|
+
readonly "validateOn.setter": FormShapeValidateOnSetter<TFields>;
|
|
405
|
+
readonly "validateOn.schema": FormShapeValidateOn<TFields>;
|
|
406
|
+
readonly "validateOn.schema.verbose": FormShapeValidateOnVerbose<TFields>;
|
|
407
|
+
readonly "error.setter": FormShapeErrorSetter<TFields>;
|
|
408
|
+
readonly "error.schema": FormShapeError<TFields>;
|
|
409
|
+
readonly "error.schema.verbose": FormShapeErrorVerbose<TFields>;
|
|
410
|
+
}
|
|
411
|
+
type SignalFormRecord<TForms> = { readonly [TKey in keyof TForms]: SignalForm; };
|
|
412
|
+
type GetFormStates<TForms extends SignalFormRecord<TForms>> = { [TKey in keyof TForms]: GetFormState<TForms[TKey]>; };
|
|
413
|
+
type FormShapeStateFields<TFields extends FormShapeFields<TFields>> = GetFormStates<TFields>;
|
|
414
|
+
declare class FormShapeState<TFields extends FormShapeFields<TFields> = Record<string, SignalForm>> extends SignalFormState<FormShapeParams<TFields>, FormShape$1<TFields>> {
|
|
415
|
+
readonly _host: Lazy<FormShape$1<TFields>>;
|
|
416
|
+
readonly _fields: FormShapeStateFields<TFields>;
|
|
417
|
+
constructor(parent: null | SignalFormState, fields: FormShapeStateFields<TFields>);
|
|
418
|
+
_childOf(parent: null | SignalFormState): FormShapeState<TFields>;
|
|
419
|
+
readonly _initial: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "input.schema">>;
|
|
420
|
+
_setInitial(monitor: Monitor, setter: FormShapeInputSetter<TFields>): void;
|
|
421
|
+
_patchInitial(monitor: Monitor, initials: FormShapeInput<TFields>): void;
|
|
422
|
+
readonly _input: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "input.schema">>;
|
|
423
|
+
_setInput(monitor: Monitor, setter: FormShapeInputSetter<TFields>): void;
|
|
424
|
+
readonly _error: import("@owanturist/signal").ReadonlySignal<FormShapeError<TFields>>;
|
|
425
|
+
readonly _errorVerbose: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "error.schema.verbose">>;
|
|
426
|
+
_setError(monitor: Monitor, setter: FormShapeErrorSetter<TFields>): void;
|
|
427
|
+
readonly _validateOn: import("@owanturist/signal").ReadonlySignal<FormShapeValidateOn<TFields>>;
|
|
428
|
+
readonly _validateOnVerbose: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "validateOn.schema.verbose">>;
|
|
429
|
+
_setValidateOn(monitor: Monitor, setter: FormShapeValidateOnSetter<TFields>): void;
|
|
430
|
+
readonly _touched: import("@owanturist/signal").ReadonlySignal<FormShapeFlag<TFields>>;
|
|
431
|
+
readonly _touchedVerbose: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
432
|
+
_setTouched(monitor: Monitor, setter: FormShapeFlagSetter<TFields>): void;
|
|
433
|
+
readonly _output: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "output.schema"> | null>;
|
|
434
|
+
readonly _outputVerbose: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "output.schema.verbose">>;
|
|
435
|
+
readonly _valid: import("@owanturist/signal").ReadonlySignal<FormShapeFlag<TFields>>;
|
|
436
|
+
readonly _validVerbose: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
437
|
+
readonly _invalid: import("@owanturist/signal").ReadonlySignal<FormShapeFlag<TFields>>;
|
|
438
|
+
readonly _invalidVerbose: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
439
|
+
readonly _validated: import("@owanturist/signal").ReadonlySignal<FormShapeFlag<TFields>>;
|
|
440
|
+
readonly _validatedVerbose: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
441
|
+
_forceValidated(monitor: Monitor): void;
|
|
442
|
+
readonly _dirty: import("@owanturist/signal").ReadonlySignal<FormShapeFlag<TFields>>;
|
|
443
|
+
readonly _dirtyVerbose: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
444
|
+
readonly _dirtyOnVerbose: import("@owanturist/signal").ReadonlySignal<GetFormShapeParam<TFields, "flag.schema.verbose">>;
|
|
445
|
+
_reset(monitor: Monitor, resetter: undefined | FormShapeInputSetter<TFields>): void;
|
|
446
|
+
_getChildren(): ReadonlyArray<SignalFormChild<FormShapeParams<TFields>>>;
|
|
447
|
+
}
|
|
517
448
|
declare class FormShape$1<TFields extends FormShapeFields<TFields>> extends SignalForm<FormShapeParams<TFields>> {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
449
|
+
readonly _state: FormShapeState<TFields>;
|
|
450
|
+
static _getState: typeof SignalForm._getState;
|
|
451
|
+
readonly fields: TFields;
|
|
452
|
+
constructor(_state: FormShapeState<TFields>);
|
|
522
453
|
}
|
|
523
|
-
|
|
454
|
+
type FormShape<TFields extends FormShapeFields<TFields>> = FormShape$1<TFields>;
|
|
524
455
|
interface FormShapeOptions<TFields extends FormShapeFields<TFields>> {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
456
|
+
readonly input?: FormShapeInputSetter<TFields>;
|
|
457
|
+
readonly initial?: FormShapeInputSetter<TFields>;
|
|
458
|
+
readonly touched?: FormShapeFlagSetter<TFields>;
|
|
459
|
+
readonly validateOn?: FormShapeValidateOnSetter<TFields>;
|
|
460
|
+
readonly error?: FormShapeErrorSetter<TFields>;
|
|
530
461
|
}
|
|
531
|
-
type FormShape<TFields extends FormShapeFields<TFields>> = FormShape$1<TFields>;
|
|
532
462
|
declare function FormShape<TFields extends FormShapeFields<TFields>>(fields: TFields, { input, initial, touched, validateOn, error }?: FormShapeOptions<NoInfer<TFields>>): FormShape<TFields>;
|
|
533
|
-
|
|
534
463
|
declare function isFormShape(value: unknown): value is FormShape$1<FormShapeFields>;
|
|
535
|
-
|
|
536
464
|
type FormListErrorVerbose<TElement extends SignalForm> = ReadonlyArray<GetFormErrorVerbose<TElement>>;
|
|
537
|
-
|
|
538
|
-
type FormListErrorSetter<TElement extends SignalForm> = Setter<null | ReadonlyArray<undefined | GetFormErrorSetter<TElement>>, [
|
|
539
|
-
FormListErrorVerbose<TElement>
|
|
540
|
-
]>;
|
|
541
|
-
|
|
465
|
+
type FormListErrorSetter<TElement extends SignalForm> = Setter<null | ReadonlyArray<undefined | GetFormErrorSetter<TElement>>, [FormListErrorVerbose<TElement>]>;
|
|
542
466
|
type FormListFlagVerbose<TElement extends SignalForm> = ReadonlyArray<GetFormFlagVerbose<TElement>>;
|
|
543
|
-
|
|
544
|
-
type FormListFlagSetter<TElement extends SignalForm> = Setter<boolean | ReadonlyArray<undefined | GetFormFlagSetter<TElement>>, [
|
|
545
|
-
FormListFlagVerbose<TElement>
|
|
546
|
-
]>;
|
|
547
|
-
|
|
467
|
+
type FormListFlagSetter<TElement extends SignalForm> = Setter<boolean | ReadonlyArray<undefined | GetFormFlagSetter<TElement>>, [FormListFlagVerbose<TElement>]>;
|
|
548
468
|
type FormListInput<TElement extends SignalForm> = ReadonlyArray<GetFormInput<TElement>>;
|
|
549
|
-
|
|
550
469
|
type FormListValidateOnVerbose<TElement extends SignalForm> = ReadonlyArray<GetFormValidateOnVerbose<TElement>>;
|
|
551
|
-
|
|
552
|
-
type FormListValidateOnSetter<TElement extends SignalForm> = Setter<ValidateStrategy | ReadonlyArray<undefined | GetFormValidateOnSetter<TElement>>, [
|
|
553
|
-
FormListValidateOnVerbose<TElement>
|
|
554
|
-
]>;
|
|
555
|
-
|
|
470
|
+
type FormListValidateOnSetter<TElement extends SignalForm> = Setter<ValidateStrategy | ReadonlyArray<undefined | GetFormValidateOnSetter<TElement>>, [FormListValidateOnVerbose<TElement>]>;
|
|
556
471
|
type FormListError<TElement extends SignalForm> = null | ReadonlyArray<GetFormError<TElement>>;
|
|
557
|
-
|
|
558
472
|
type FormListFlag<TElement extends SignalForm> = boolean | ReadonlyArray<GetFormFlag<TElement>>;
|
|
559
|
-
|
|
560
|
-
type FormListInputSetter<TElement extends SignalForm> = Setter<ReadonlyArray<GetFormInput<TElement>>, [
|
|
561
|
-
FormListInput<TElement>,
|
|
562
|
-
FormListInput<TElement>
|
|
563
|
-
]>;
|
|
564
|
-
|
|
473
|
+
type FormListInputSetter<TElement extends SignalForm> = Setter<ReadonlyArray<GetFormInput<TElement>>, [FormListInput<TElement>, FormListInput<TElement>]>;
|
|
565
474
|
type FormListOutput<TElement extends SignalForm> = ReadonlyArray<GetFormOutput<TElement>>;
|
|
566
|
-
|
|
567
475
|
type FormListOutputVerbose<TElement extends SignalForm> = ReadonlyArray<GetFormOutputVerbose<TElement>>;
|
|
568
|
-
|
|
569
476
|
type FormListValidateOn<TElement extends SignalForm> = ValidateStrategy | ReadonlyArray<GetFormValidateOn<TElement>>;
|
|
570
|
-
|
|
571
477
|
interface FormListParams<TElement extends SignalForm> extends SignalFormParams {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
}
|
|
625
|
-
|
|
478
|
+
"input.schema": FormListInput<TElement>;
|
|
479
|
+
"input.setter": FormListInputSetter<TElement>;
|
|
480
|
+
"output.schema": FormListOutput<TElement>;
|
|
481
|
+
"output.schema.verbose": FormListOutputVerbose<TElement>;
|
|
482
|
+
"flag.setter": FormListFlagSetter<TElement>;
|
|
483
|
+
"flag.schema": FormListFlag<TElement>;
|
|
484
|
+
"flag.schema.verbose": FormListFlagVerbose<TElement>;
|
|
485
|
+
"validateOn.setter": FormListValidateOnSetter<TElement>;
|
|
486
|
+
"validateOn.schema": FormListValidateOn<TElement>;
|
|
487
|
+
"validateOn.schema.verbose": FormListValidateOnVerbose<TElement>;
|
|
488
|
+
"error.setter": FormListErrorSetter<TElement>;
|
|
489
|
+
"error.schema": FormListError<TElement>;
|
|
490
|
+
"error.schema.verbose": FormListErrorVerbose<TElement>;
|
|
491
|
+
}
|
|
492
|
+
type FormListElementFactoryInternal<TElement extends SignalForm> = (input: GetFormInput<TElement>, index: number) => GetFormState<TElement>;
|
|
493
|
+
declare class FormListState<TElement extends SignalForm = SignalForm> extends SignalFormState<FormListParams<TElement>, FormList$1<TElement>> {
|
|
494
|
+
private readonly _factory;
|
|
495
|
+
readonly _initialInputs: Signal<ReadonlyArray<GetFormInput<TElement>>>;
|
|
496
|
+
readonly _host: Lazy<FormList$1<TElement>>;
|
|
497
|
+
readonly _elements: Signal<ReadonlyArray<GetFormState<TElement>>>;
|
|
498
|
+
constructor(parent: null | SignalFormState, _factory: FormListElementFactoryInternal<TElement>, _initialInputs: Signal<ReadonlyArray<GetFormInput<TElement>>>, elements?: ReadonlyArray<GetFormState<TElement>>);
|
|
499
|
+
_childOf(parent: null | SignalFormState): FormListState<TElement>;
|
|
500
|
+
_getElements(monitor: Monitor): ReadonlyArray<TElement>;
|
|
501
|
+
readonly _initial: import("@owanturist/signal").ReadonlySignal<FormListInput<TElement>>;
|
|
502
|
+
_setInitial(monitor: Monitor, setter: FormListInputSetter<TElement>): void;
|
|
503
|
+
_patchInitial(monitor: Monitor, initials: FormListInput<TElement>): void;
|
|
504
|
+
readonly _input: import("@owanturist/signal").ReadonlySignal<FormListInput<TElement>>;
|
|
505
|
+
_setInput(monitor: Monitor, setter: FormListInputSetter<TElement>): void;
|
|
506
|
+
readonly _error: import("@owanturist/signal").ReadonlySignal<FormListError<TElement>>;
|
|
507
|
+
readonly _errorVerbose: import("@owanturist/signal").ReadonlySignal<FormListErrorVerbose<TElement>>;
|
|
508
|
+
_setError(monitor: Monitor, setter: FormListErrorSetter<TElement>): void;
|
|
509
|
+
readonly _validateOn: import("@owanturist/signal").ReadonlySignal<FormListValidateOn<TElement>>;
|
|
510
|
+
readonly _validateOnVerbose: import("@owanturist/signal").ReadonlySignal<FormListValidateOnVerbose<TElement>>;
|
|
511
|
+
_setValidateOn(monitor: Monitor, setter: FormListValidateOnSetter<TElement>): void;
|
|
512
|
+
readonly _touched: import("@owanturist/signal").ReadonlySignal<FormListFlag<TElement>>;
|
|
513
|
+
readonly _touchedVerbose: import("@owanturist/signal").ReadonlySignal<FormListFlagVerbose<TElement>>;
|
|
514
|
+
_setTouched(monitor: Monitor, setter: FormListFlagSetter<TElement>): void;
|
|
515
|
+
readonly _output: import("@owanturist/signal").ReadonlySignal<FormListOutput<TElement> | null>;
|
|
516
|
+
readonly _outputVerbose: import("@owanturist/signal").ReadonlySignal<FormListOutputVerbose<TElement>>;
|
|
517
|
+
readonly _valid: import("@owanturist/signal").ReadonlySignal<FormListFlag<TElement>>;
|
|
518
|
+
readonly _validVerbose: import("@owanturist/signal").ReadonlySignal<FormListFlagVerbose<TElement>>;
|
|
519
|
+
readonly _invalid: import("@owanturist/signal").ReadonlySignal<FormListFlag<TElement>>;
|
|
520
|
+
readonly _invalidVerbose: import("@owanturist/signal").ReadonlySignal<FormListFlagVerbose<TElement>>;
|
|
521
|
+
readonly _validated: import("@owanturist/signal").ReadonlySignal<FormListFlag<TElement>>;
|
|
522
|
+
readonly _validatedVerbose: import("@owanturist/signal").ReadonlySignal<FormListFlagVerbose<TElement>>;
|
|
523
|
+
_forceValidated(monitor: Monitor): void;
|
|
524
|
+
readonly _dirty: import("@owanturist/signal").ReadonlySignal<FormListFlag<TElement>>;
|
|
525
|
+
readonly _dirtyVerbose: import("@owanturist/signal").ReadonlySignal<FormListFlagVerbose<TElement>>;
|
|
526
|
+
readonly _dirtyOnVerbose: import("@owanturist/signal").ReadonlySignal<FormListFlagVerbose<TElement>>;
|
|
527
|
+
_reset(monitor: Monitor, resetter: undefined | FormListInputSetter<TElement>): void;
|
|
528
|
+
_getChildren(monitor: Monitor): ReadonlyArray<SignalFormChild<FormListParams<TElement>>>;
|
|
529
|
+
}
|
|
626
530
|
declare class FormList$1<TElement extends SignalForm> extends SignalForm<FormListParams<TElement>> {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
|
|
531
|
+
readonly _state: FormListState<TElement>;
|
|
532
|
+
static _getState: typeof SignalForm._getState;
|
|
533
|
+
private readonly _elements;
|
|
534
|
+
constructor(_state: FormListState<TElement>);
|
|
535
|
+
getElements(monitor: Monitor): ReadonlyArray<TElement>;
|
|
536
|
+
getElements<TResult>(monitor: Monitor, select: (elements: ReadonlyArray<TElement>) => TResult): TResult;
|
|
537
|
+
setElements(setter: Setter<ReadonlyArray<TElement>, [ReadonlyArray<TElement>, Monitor]>): void;
|
|
538
|
+
}
|
|
539
|
+
type FormList<TElement extends SignalForm> = FormList$1<TElement>;
|
|
636
540
|
type FormListElementFactory<TElement extends SignalForm> = (input: GetFormInput<TElement>, index: number) => TElement;
|
|
637
541
|
interface FormListOptions<TElement extends SignalForm> {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
542
|
+
/**
|
|
543
|
+
* @default []
|
|
544
|
+
*/
|
|
545
|
+
readonly initial?: FormListInput<TElement>;
|
|
546
|
+
/**
|
|
547
|
+
* @default {@link initial}
|
|
548
|
+
*/
|
|
549
|
+
readonly input?: FormListInput<TElement>;
|
|
550
|
+
readonly touched?: FormListFlagSetter<TElement>;
|
|
551
|
+
readonly validateOn?: FormListValidateOnSetter<TElement>;
|
|
552
|
+
readonly error?: FormListErrorSetter<TElement>;
|
|
649
553
|
}
|
|
650
|
-
type FormList<TElement extends SignalForm> = FormList$1<TElement>;
|
|
651
554
|
declare function FormList<TElement extends SignalForm>(factory: FormListElementFactory<TElement>, { input, initial, touched, validateOn, error }?: FormListOptions<TElement>): FormList<TElement>;
|
|
652
|
-
|
|
653
555
|
declare function isFormList(value: unknown): value is FormList$1<SignalForm>;
|
|
654
|
-
|
|
655
556
|
type IsEqualType<TLeft, TRight> = [TLeft, TRight] extends [TRight, TLeft] ? true : false;
|
|
656
|
-
|
|
657
557
|
interface FormOptionalSchema<TEnabled, TElement> {
|
|
658
|
-
|
|
659
|
-
|
|
558
|
+
readonly enabled: TEnabled;
|
|
559
|
+
readonly element: TElement;
|
|
660
560
|
}
|
|
661
|
-
|
|
662
561
|
type FormOptionalParam<TEnabled extends SignalForm, TElement extends SignalForm, TKey extends keyof SignalFormParams, TConcise = never> = TConcise | FormOptionalSchema<TConcise | GetFormParam<TEnabled, TKey>, TConcise | GetFormParam<TElement, TKey>>;
|
|
663
|
-
|
|
664
562
|
type FormOptionalErrorVerbose<TEnabled extends SignalForm, TElement extends SignalForm> = FormOptionalParam<TEnabled, TElement, "error.schema.verbose">;
|
|
665
|
-
|
|
666
|
-
type FormOptionalErrorSetter<TEnabled extends SignalForm, TElement extends SignalForm> = Setter<null | Partial<FormOptionalSchema<GetFormParam<TEnabled, "error.setter">, GetFormParam<TElement, "error.setter">>>, [
|
|
667
|
-
FormOptionalErrorVerbose<TEnabled, TElement>
|
|
668
|
-
]>;
|
|
669
|
-
|
|
563
|
+
type FormOptionalErrorSetter<TEnabled extends SignalForm, TElement extends SignalForm> = Setter<null | Partial<FormOptionalSchema<GetFormParam<TEnabled, "error.setter">, GetFormParam<TElement, "error.setter">>>, [FormOptionalErrorVerbose<TEnabled, TElement>]>;
|
|
670
564
|
type FormOptionalFlagVerbose<TEnabled extends SignalForm, TElement extends SignalForm> = FormOptionalParam<TEnabled, TElement, "flag.schema.verbose">;
|
|
671
|
-
|
|
672
|
-
type FormOptionalFlagSetter<TEnabled extends SignalForm, TElement extends SignalForm> = Setter<boolean | Partial<FormOptionalSchema<GetFormParam<TEnabled, "flag.setter">, GetFormParam<TElement, "flag.setter">>>, [
|
|
673
|
-
FormOptionalFlagVerbose<TEnabled, TElement>
|
|
674
|
-
]>;
|
|
675
|
-
|
|
565
|
+
type FormOptionalFlagSetter<TEnabled extends SignalForm, TElement extends SignalForm> = Setter<boolean | Partial<FormOptionalSchema<GetFormParam<TEnabled, "flag.setter">, GetFormParam<TElement, "flag.setter">>>, [FormOptionalFlagVerbose<TEnabled, TElement>]>;
|
|
676
566
|
type FormOptionalInput<TEnabled extends SignalForm, TElement extends SignalForm> = FormOptionalSchema<GetFormParam<TEnabled, "input.schema">, GetFormParam<TElement, "input.schema">>;
|
|
677
|
-
|
|
678
|
-
type FormOptionalInputSetter<TEnabled extends SignalForm, TElement extends SignalForm> = Setter<Partial<FormOptionalSchema<GetFormParam<TEnabled, "input.setter">, GetFormParam<TElement, "input.setter">>>, [
|
|
679
|
-
FormOptionalInput<TEnabled, TElement>,
|
|
680
|
-
FormOptionalInput<TEnabled, TElement>
|
|
681
|
-
]>;
|
|
682
|
-
|
|
567
|
+
type FormOptionalInputSetter<TEnabled extends SignalForm, TElement extends SignalForm> = Setter<Partial<FormOptionalSchema<GetFormParam<TEnabled, "input.setter">, GetFormParam<TElement, "input.setter">>>, [FormOptionalInput<TEnabled, TElement>, FormOptionalInput<TEnabled, TElement>]>;
|
|
683
568
|
type FormOptionalValidateOnVerbose<TEnabled extends SignalForm, TElement extends SignalForm> = FormOptionalParam<TEnabled, TElement, "validateOn.schema.verbose">;
|
|
684
|
-
|
|
685
|
-
type FormOptionalValidateOnSetter<TEnabled extends SignalForm, TElement extends SignalForm> = Setter<ValidateStrategy | Partial<FormOptionalSchema<GetFormParam<TEnabled, "validateOn.setter">, GetFormParam<TElement, "validateOn.setter">>>, [
|
|
686
|
-
FormOptionalValidateOnVerbose<TEnabled, TElement>
|
|
687
|
-
]>;
|
|
688
|
-
|
|
569
|
+
type FormOptionalValidateOnSetter<TEnabled extends SignalForm, TElement extends SignalForm> = Setter<ValidateStrategy | Partial<FormOptionalSchema<GetFormParam<TEnabled, "validateOn.setter">, GetFormParam<TElement, "validateOn.setter">>>, [FormOptionalValidateOnVerbose<TEnabled, TElement>]>;
|
|
689
570
|
type FormOptionalError<TEnabled extends SignalForm, TElement extends SignalForm> = FormOptionalParam<TEnabled, TElement, "error.schema", null>;
|
|
690
|
-
|
|
691
571
|
type FormOptionalFlag<TEnabled extends SignalForm, TElement extends SignalForm> = FormOptionalParam<TEnabled, TElement, "flag.schema", boolean>;
|
|
692
|
-
|
|
693
572
|
type FormOptionalOutput<TElement extends SignalForm> = undefined | GetFormParam<TElement, "output.schema">;
|
|
694
|
-
|
|
695
573
|
type FormOptionalOutputVerbose<TEnabled extends SignalForm, TElement extends SignalForm> = FormOptionalParam<TEnabled, TElement, "output.schema.verbose">;
|
|
696
|
-
|
|
697
574
|
type FormOptionalValidateOn<TEnabled extends SignalForm, TElement extends SignalForm> = FormOptionalParam<TEnabled, TElement, "validateOn.schema", ValidateStrategy>;
|
|
698
|
-
|
|
699
575
|
interface FormOptionalParams<TEnabled extends SignalForm, TElement extends SignalForm> extends SignalFormParams {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
_getChildren<TChildParams extends SignalFormParams>(monitor: Monitor): ReadonlyArray<SignalFormChild<TChildParams, FormOptionalParams<TEnabled, TElement>>>;
|
|
753
|
-
}
|
|
754
|
-
|
|
576
|
+
"input.schema": FormOptionalInput<TEnabled, TElement>;
|
|
577
|
+
"input.setter": FormOptionalInputSetter<TEnabled, TElement>;
|
|
578
|
+
"output.schema": FormOptionalOutput<TElement>;
|
|
579
|
+
"output.schema.verbose": FormOptionalOutputVerbose<TEnabled, TElement>;
|
|
580
|
+
"flag.setter": FormOptionalFlagSetter<TEnabled, TElement>;
|
|
581
|
+
"flag.schema": FormOptionalFlag<TEnabled, TElement>;
|
|
582
|
+
"flag.schema.verbose": FormOptionalFlagVerbose<TEnabled, TElement>;
|
|
583
|
+
"validateOn.setter": FormOptionalValidateOnSetter<TEnabled, TElement>;
|
|
584
|
+
"validateOn.schema": FormOptionalValidateOn<TEnabled, TElement>;
|
|
585
|
+
"validateOn.schema.verbose": FormOptionalValidateOnVerbose<TEnabled, TElement>;
|
|
586
|
+
"error.setter": FormOptionalErrorSetter<TEnabled, TElement>;
|
|
587
|
+
"error.schema": FormOptionalError<TEnabled, TElement>;
|
|
588
|
+
"error.schema.verbose": FormOptionalErrorVerbose<TEnabled, TElement>;
|
|
589
|
+
}
|
|
590
|
+
declare class FormOptionalState<TEnabled extends SignalForm, TElement extends SignalForm> extends SignalFormState<FormOptionalParams<TEnabled, TElement>, FormOptional$1<TEnabled, TElement>> {
|
|
591
|
+
readonly _host: Lazy<FormOptional$1<TEnabled, TElement>>;
|
|
592
|
+
readonly _enabled: GetFormState<TEnabled>;
|
|
593
|
+
readonly _element: GetFormState<TElement>;
|
|
594
|
+
constructor(parent: null | SignalFormState, enabled: GetFormState<TEnabled>, element: GetFormState<TElement>);
|
|
595
|
+
private _isEnabled;
|
|
596
|
+
_getEnabledElement(monitor: Monitor): undefined | GetFormState<TElement>;
|
|
597
|
+
_childOf(parent: null | SignalFormState): FormOptionalState<TEnabled, TElement>;
|
|
598
|
+
private _toConcise;
|
|
599
|
+
readonly _initial: import("@owanturist/signal").ReadonlySignal<FormOptionalInput<TEnabled, TElement>>;
|
|
600
|
+
_setInitial(monitor: Monitor, setter: FormOptionalInputSetter<TEnabled, TElement>): void;
|
|
601
|
+
_patchInitial(monitor: Monitor, initial: FormOptionalInput<TEnabled, TElement>): void;
|
|
602
|
+
readonly _input: import("@owanturist/signal").ReadonlySignal<FormOptionalInput<TEnabled, TElement>>;
|
|
603
|
+
_setInput(monitor: Monitor, setter: FormOptionalInputSetter<TEnabled, TElement>): void;
|
|
604
|
+
readonly _error: import("@owanturist/signal").ReadonlySignal<FormOptionalError<TEnabled, TElement>>;
|
|
605
|
+
readonly _errorVerbose: import("@owanturist/signal").ReadonlySignal<FormOptionalErrorVerbose<TEnabled, TElement>>;
|
|
606
|
+
_setError(monitor: Monitor, setter: FormOptionalErrorSetter<TEnabled, TElement>): void;
|
|
607
|
+
readonly _validateOn: import("@owanturist/signal").ReadonlySignal<FormOptionalValidateOn<TEnabled, TElement>>;
|
|
608
|
+
readonly _validateOnVerbose: import("@owanturist/signal").ReadonlySignal<FormOptionalValidateOnVerbose<TEnabled, TElement>>;
|
|
609
|
+
_setValidateOn(monitor: Monitor, setter: FormOptionalValidateOnSetter<TEnabled, TElement>): void;
|
|
610
|
+
readonly _touched: import("@owanturist/signal").ReadonlySignal<FormOptionalFlag<TEnabled, TElement>>;
|
|
611
|
+
readonly _touchedVerbose: import("@owanturist/signal").ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
|
|
612
|
+
_setTouched(monitor: Monitor, setter: FormOptionalFlagSetter<TEnabled, TElement>): void;
|
|
613
|
+
readonly _output: import("@owanturist/signal").ReadonlySignal<FormOptionalOutput<TElement> | null>;
|
|
614
|
+
readonly _outputVerbose: import("@owanturist/signal").ReadonlySignal<FormOptionalOutputVerbose<TEnabled, TElement>>;
|
|
615
|
+
readonly _valid: import("@owanturist/signal").ReadonlySignal<FormOptionalFlag<TEnabled, TElement>>;
|
|
616
|
+
readonly _validVerbose: import("@owanturist/signal").ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
|
|
617
|
+
readonly _invalid: import("@owanturist/signal").ReadonlySignal<FormOptionalFlag<TEnabled, TElement>>;
|
|
618
|
+
readonly _invalidVerbose: import("@owanturist/signal").ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
|
|
619
|
+
readonly _validated: import("@owanturist/signal").ReadonlySignal<FormOptionalFlag<TEnabled, TElement>>;
|
|
620
|
+
readonly _validatedVerbose: import("@owanturist/signal").ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
|
|
621
|
+
_forceValidated(monitor: Monitor): void;
|
|
622
|
+
readonly _dirty: import("@owanturist/signal").ReadonlySignal<FormOptionalFlag<TEnabled, TElement>>;
|
|
623
|
+
readonly _dirtyVerbose: import("@owanturist/signal").ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
|
|
624
|
+
readonly _dirtyOnVerbose: import("@owanturist/signal").ReadonlySignal<FormOptionalFlagVerbose<TEnabled, TElement>>;
|
|
625
|
+
_reset(monitor: Monitor, resetter: undefined | FormOptionalInputSetter<TEnabled, TElement>): void;
|
|
626
|
+
_getChildren(monitor: Monitor): ReadonlyArray<SignalFormChild<FormOptionalParams<TEnabled, TElement>>>;
|
|
627
|
+
}
|
|
755
628
|
declare class FormOptional$1<TEnabled extends SignalForm, TElement extends SignalForm> extends SignalForm<FormOptionalParams<TEnabled, TElement>> {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
interface FormOptionalOptions<TEnabled extends SignalForm, TElement extends SignalForm> {
|
|
765
|
-
input?: FormOptionalInputSetter<TEnabled, TElement>;
|
|
766
|
-
initial?: FormOptionalInputSetter<TEnabled, TElement>;
|
|
767
|
-
touched?: FormOptionalFlagSetter<TEnabled, TElement>;
|
|
768
|
-
validateOn?: FormOptionalValidateOnSetter<TEnabled, TElement>;
|
|
769
|
-
error?: FormOptionalErrorSetter<TEnabled, TElement>;
|
|
629
|
+
readonly _state: FormOptionalState<TEnabled, TElement>;
|
|
630
|
+
static _getState: typeof SignalForm._getState;
|
|
631
|
+
readonly enabled: TEnabled;
|
|
632
|
+
readonly element: TElement;
|
|
633
|
+
constructor(_state: FormOptionalState<TEnabled, TElement>);
|
|
634
|
+
getEnabledElement(monitor: Monitor): undefined | TElement;
|
|
770
635
|
}
|
|
771
636
|
type FormOptional<TEnabled extends SignalForm, TElement extends SignalForm> = FormOptional$1<TEnabled, TElement>;
|
|
637
|
+
interface FormOptionalOptions<TEnabled extends SignalForm, TElement extends SignalForm> {
|
|
638
|
+
input?: FormOptionalInputSetter<TEnabled, TElement>;
|
|
639
|
+
initial?: FormOptionalInputSetter<TEnabled, TElement>;
|
|
640
|
+
touched?: FormOptionalFlagSetter<TEnabled, TElement>;
|
|
641
|
+
validateOn?: FormOptionalValidateOnSetter<TEnabled, TElement>;
|
|
642
|
+
error?: FormOptionalErrorSetter<TEnabled, TElement>;
|
|
643
|
+
}
|
|
772
644
|
declare function FormOptional<TEnabled extends SignalForm, TElement extends SignalForm>(enabled: IsEqualType<GetFormParam<TEnabled, "output.schema">, boolean> extends true ? TEnabled : never, element: TElement, { input, initial, touched, validateOn, error }?: FormOptionalOptions<TEnabled, TElement>): FormOptional<TEnabled, TElement>;
|
|
773
|
-
|
|
774
645
|
declare function isFormOptional(anything: unknown): anything is FormOptional$1<SignalForm, SignalForm>;
|
|
775
|
-
|
|
776
646
|
type FormSwitchBranches<TKind extends SignalForm> = GetFormParam<TKind, "output.schema"> extends string ? Record<GetFormParam<TKind, "output.schema">, SignalForm> : never;
|
|
777
|
-
|
|
778
647
|
interface FormSwitchConciseSchema<TActive, TBranch> {
|
|
779
|
-
|
|
780
|
-
|
|
648
|
+
readonly active: TActive;
|
|
649
|
+
readonly branch: TBranch;
|
|
781
650
|
}
|
|
782
|
-
|
|
783
|
-
type Compute<Obj> = unknown & {
|
|
784
|
-
[K in keyof Obj]: Obj[K];
|
|
785
|
-
};
|
|
786
|
-
|
|
651
|
+
type Compute<Obj> = unknown & { [K in keyof Obj]: Obj[K]; };
|
|
787
652
|
interface FormSwitchVerboseSchema<TActive, TBranches> {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
type GetFormSwitchBranchesParam<TBranches extends FormSwitchBranches<SignalForm>, TKey extends keyof SignalFormParams> = Compute<{
|
|
793
|
-
readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], TKey>;
|
|
794
|
-
}>;
|
|
795
|
-
|
|
653
|
+
readonly active: TActive;
|
|
654
|
+
readonly branches: TBranches;
|
|
655
|
+
}
|
|
656
|
+
type GetFormSwitchBranchesParam<TBranches extends FormSwitchBranches<SignalForm>, TKey extends keyof SignalFormParams> = Compute<{ readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], TKey>; }>;
|
|
796
657
|
type FormSwitchVerboseParam<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>, TKey extends keyof SignalFormParams> = Compute<FormSwitchVerboseSchema<GetFormParam<TKind, TKey>, GetFormSwitchBranchesParam<TBranches, TKey>>>;
|
|
797
|
-
|
|
798
658
|
type FormSwitchErrorVerbose<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitchVerboseParam<TKind, TBranches, "error.schema.verbose">;
|
|
799
|
-
|
|
800
659
|
interface FormSwitchBranch<TKind, TValue> {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
type
|
|
806
|
-
[TBranch in GetFormOutput<TKind>]: FormSwitchBranch<TBranch, GetFormParam<TBranches[TBranch], TKey>>;
|
|
807
|
-
}[GetFormOutput<TKind>];
|
|
808
|
-
|
|
809
|
-
type FormSwitchErrorSetter<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = Setter<null | Partial<FormSwitchConciseSchema<GetFormParam<TKind, "error.setter">, Setter<null | FormSwitchBranchUnion<TKind, TBranches, "error.setter">, [
|
|
810
|
-
FormSwitchBranchUnion<TKind, TBranches, "error.schema.verbose">
|
|
811
|
-
]>>> | Partial<FormSwitchVerboseSchema<GetFormParam<TKind, "error.setter">, Setter<null | Partial<GetFormSwitchBranchesParam<TBranches, "error.setter">>, [
|
|
812
|
-
GetFormSwitchBranchesParam<TBranches, "error.schema.verbose">
|
|
813
|
-
]>>>, [
|
|
814
|
-
FormSwitchErrorVerbose<TKind, TBranches>
|
|
815
|
-
]>;
|
|
816
|
-
|
|
660
|
+
readonly kind: TKind;
|
|
661
|
+
readonly value: TValue;
|
|
662
|
+
}
|
|
663
|
+
type FormSwitchBranchUnion<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>, TKey extends keyof SignalFormParams> = { [TBranch in GetFormOutput<TKind>]: FormSwitchBranch<TBranch, GetFormParam<TBranches[TBranch], TKey>>; }[GetFormOutput<TKind>];
|
|
664
|
+
type FormSwitchErrorSetter<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = Setter<null | Partial<FormSwitchConciseSchema<GetFormParam<TKind, "error.setter">, Setter<null | FormSwitchBranchUnion<TKind, TBranches, "error.setter">, [FormSwitchBranchUnion<TKind, TBranches, "error.schema.verbose">]>>> | Partial<FormSwitchVerboseSchema<GetFormParam<TKind, "error.setter">, Setter<null | Partial<GetFormSwitchBranchesParam<TBranches, "error.setter">>, [GetFormSwitchBranchesParam<TBranches, "error.schema.verbose">]>>>, [FormSwitchErrorVerbose<TKind, TBranches>]>;
|
|
817
665
|
type FormSwitchFlagVerbose<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitchVerboseParam<TKind, TBranches, "flag.schema.verbose">;
|
|
818
|
-
|
|
819
|
-
type FormSwitchFlagSetter<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = Setter<boolean | Partial<FormSwitchConciseSchema<GetFormParam<TKind, "flag.setter">, Setter<boolean | FormSwitchBranchUnion<TKind, TBranches, "flag.setter">, [
|
|
820
|
-
FormSwitchBranchUnion<TKind, TBranches, "flag.schema.verbose">
|
|
821
|
-
]>>> | Partial<FormSwitchVerboseSchema<GetFormParam<TKind, "flag.setter">, Setter<boolean | Partial<GetFormSwitchBranchesParam<TBranches, "flag.setter">>, [
|
|
822
|
-
GetFormSwitchBranchesParam<TBranches, "flag.schema.verbose">
|
|
823
|
-
]>>>, [
|
|
824
|
-
FormSwitchFlagVerbose<TKind, TBranches>
|
|
825
|
-
]>;
|
|
826
|
-
|
|
666
|
+
type FormSwitchFlagSetter<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = Setter<boolean | Partial<FormSwitchConciseSchema<GetFormParam<TKind, "flag.setter">, Setter<boolean | FormSwitchBranchUnion<TKind, TBranches, "flag.setter">, [FormSwitchBranchUnion<TKind, TBranches, "flag.schema.verbose">]>>> | Partial<FormSwitchVerboseSchema<GetFormParam<TKind, "flag.setter">, Setter<boolean | Partial<GetFormSwitchBranchesParam<TBranches, "flag.setter">>, [GetFormSwitchBranchesParam<TBranches, "flag.schema.verbose">]>>>, [FormSwitchFlagVerbose<TKind, TBranches>]>;
|
|
827
667
|
type FormSwitchInput<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitchVerboseParam<TKind, TBranches, "input.schema">;
|
|
828
|
-
|
|
829
|
-
type FormSwitchInputSetter<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = Setter<Partial<FormSwitchVerboseSchema<GetFormParam<TKind, "input.setter">, Setter<Partial<GetFormSwitchBranchesParam<TBranches, "input.setter">>, [
|
|
830
|
-
GetFormSwitchBranchesParam<TBranches, "input.schema">,
|
|
831
|
-
GetFormSwitchBranchesParam<TBranches, "input.schema">
|
|
832
|
-
]>>>, [
|
|
833
|
-
FormSwitchInput<TKind, TBranches>,
|
|
834
|
-
FormSwitchInput<TKind, TBranches>
|
|
835
|
-
]>;
|
|
836
|
-
|
|
668
|
+
type FormSwitchInputSetter<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = Setter<Partial<FormSwitchVerboseSchema<GetFormParam<TKind, "input.setter">, Setter<Partial<GetFormSwitchBranchesParam<TBranches, "input.setter">>, [GetFormSwitchBranchesParam<TBranches, "input.schema">, GetFormSwitchBranchesParam<TBranches, "input.schema">]>>>, [FormSwitchInput<TKind, TBranches>, FormSwitchInput<TKind, TBranches>]>;
|
|
837
669
|
type FormSwitchValidateOnVerbose<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitchVerboseParam<TKind, TBranches, "validateOn.schema.verbose">;
|
|
838
|
-
|
|
839
|
-
type
|
|
840
|
-
FormSwitchBranchUnion<TKind, TBranches, "validateOn.schema.verbose">
|
|
841
|
-
]>>> | Partial<FormSwitchVerboseSchema<GetFormParam<TKind, "validateOn.setter">, Setter<ValidateStrategy | Partial<GetFormSwitchBranchesParam<TBranches, "validateOn.setter">>, [
|
|
842
|
-
GetFormSwitchBranchesParam<TBranches, "validateOn.schema.verbose">
|
|
843
|
-
]>>>, [
|
|
844
|
-
FormSwitchValidateOnVerbose<TKind, TBranches>
|
|
845
|
-
]>;
|
|
846
|
-
|
|
847
|
-
type FormSwitchActiveBranch<TBranches extends FormSwitchBranches<SignalForm>> = {
|
|
848
|
-
[TBranch in keyof TBranches]: FormSwitchBranch<TBranch, TBranches[TBranch]>;
|
|
849
|
-
}[keyof TBranches];
|
|
850
|
-
|
|
670
|
+
type FormSwitchValidateOnSetter<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = Setter<ValidateStrategy | Partial<FormSwitchConciseSchema<GetFormParam<TKind, "validateOn.setter">, Setter<ValidateStrategy | FormSwitchBranchUnion<TKind, TBranches, "validateOn.setter">, [FormSwitchBranchUnion<TKind, TBranches, "validateOn.schema.verbose">]>>> | Partial<FormSwitchVerboseSchema<GetFormParam<TKind, "validateOn.setter">, Setter<ValidateStrategy | Partial<GetFormSwitchBranchesParam<TBranches, "validateOn.setter">>, [GetFormSwitchBranchesParam<TBranches, "validateOn.schema.verbose">]>>>, [FormSwitchValidateOnVerbose<TKind, TBranches>]>;
|
|
671
|
+
type FormSwitchActiveBranch<TBranches extends FormSwitchBranches<SignalForm>> = { [TBranch in keyof TBranches]: FormSwitchBranch<TBranch, TBranches[TBranch]>; }[keyof TBranches];
|
|
851
672
|
type FormSwitchConciseParam<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>, TKey extends keyof SignalFormParams, TConcise> = TConcise | FormSwitchConciseSchema<TConcise | GetFormParam<TKind, TKey>, TConcise | FormSwitchBranchUnion<TKind, TBranches, TKey>>;
|
|
852
|
-
|
|
853
673
|
type FormSwitchError<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitchConciseParam<TKind, TBranches, "error.schema", null>;
|
|
854
|
-
|
|
855
674
|
type FormSwitchFlag<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitchConciseParam<TKind, TBranches, "flag.schema", boolean>;
|
|
856
|
-
|
|
857
675
|
type FormSwitchOutput<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitchBranchUnion<TKind, TBranches, "output.schema">;
|
|
858
|
-
|
|
859
676
|
type FormSwitchOutputVerbose<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitchVerboseParam<TKind, TBranches, "output.schema.verbose">;
|
|
860
|
-
|
|
861
677
|
type FormSwitchValidateOn<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitchConciseParam<TKind, TBranches, "validateOn.schema", ValidateStrategy>;
|
|
862
|
-
|
|
863
678
|
interface FormSwitchParams<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> extends SignalFormParams {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
type FormSwitchStateBranches<TBranches>
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
readonly
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
readonly
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
readonly
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
readonly
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
readonly
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
readonly
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
readonly
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
readonly
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}>;
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
_reset(monitor: Monitor, resetter: undefined | FormSwitchInputSetter<TKind, TBranches>): void;
|
|
952
|
-
_getChildren<TChildParams extends SignalFormParams>(monitor: Monitor): ReadonlyArray<SignalFormChild<TChildParams, FormSwitchParams<TKind, TBranches>>>;
|
|
953
|
-
}
|
|
954
|
-
|
|
679
|
+
"input.schema": FormSwitchInput<TKind, TBranches>;
|
|
680
|
+
"input.setter": FormSwitchInputSetter<TKind, TBranches>;
|
|
681
|
+
"output.schema": FormSwitchOutput<TKind, TBranches>;
|
|
682
|
+
"output.schema.verbose": FormSwitchOutputVerbose<TKind, TBranches>;
|
|
683
|
+
"flag.setter": FormSwitchFlagSetter<TKind, TBranches>;
|
|
684
|
+
"flag.schema": FormSwitchFlag<TKind, TBranches>;
|
|
685
|
+
"flag.schema.verbose": FormSwitchFlagVerbose<TKind, TBranches>;
|
|
686
|
+
"validateOn.setter": FormSwitchValidateOnSetter<TKind, TBranches>;
|
|
687
|
+
"validateOn.schema": FormSwitchValidateOn<TKind, TBranches>;
|
|
688
|
+
"validateOn.schema.verbose": FormSwitchValidateOnVerbose<TKind, TBranches>;
|
|
689
|
+
"error.setter": FormSwitchErrorSetter<TKind, TBranches>;
|
|
690
|
+
"error.schema": FormSwitchError<TKind, TBranches>;
|
|
691
|
+
"error.schema.verbose": FormSwitchErrorVerbose<TKind, TBranches>;
|
|
692
|
+
}
|
|
693
|
+
type FormSwitchStateBranches<TBranches extends SignalFormRecord<TBranches>> = GetFormStates<TBranches>;
|
|
694
|
+
type ActiveSwitchStateBranch<TBranches extends SignalFormRecord<TBranches>> = FormSwitchBranch<keyof TBranches, FormSwitchStateBranches<TBranches>[keyof TBranches]>;
|
|
695
|
+
declare class FormSwitchState<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> extends SignalFormState<FormSwitchParams<TKind, TBranches>, FormSwitch$1<TKind, TBranches>> {
|
|
696
|
+
readonly _host: Lazy<FormSwitch$1<TKind, TBranches>>;
|
|
697
|
+
readonly _active: GetFormState<TKind>;
|
|
698
|
+
readonly _branches: FormSwitchStateBranches<TBranches>;
|
|
699
|
+
constructor(parent: null | SignalFormState, active: GetFormState<TKind>, branches: FormSwitchStateBranches<TBranches>);
|
|
700
|
+
_getActiveBranch(monitor: Monitor): undefined | ActiveSwitchStateBranch<TBranches>;
|
|
701
|
+
private _toConcise;
|
|
702
|
+
private _toVerbose;
|
|
703
|
+
_childOf(parent: null | SignalFormState): FormSwitchState<TKind, TBranches>;
|
|
704
|
+
readonly _initial: import("@owanturist/signal").ReadonlySignal<{
|
|
705
|
+
readonly active: GetFormParam<TKind, "input.schema">;
|
|
706
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "input.schema">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "input.schema">; }[K]; };
|
|
707
|
+
}>;
|
|
708
|
+
_setInitial(monitor: Monitor, setter: FormSwitchInputSetter<TKind, TBranches>): void;
|
|
709
|
+
_patchInitial(monitor: Monitor, initial: FormSwitchInput<TKind, TBranches>): void;
|
|
710
|
+
readonly _input: import("@owanturist/signal").ReadonlySignal<{
|
|
711
|
+
readonly active: GetFormParam<TKind, "input.schema">;
|
|
712
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "input.schema">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "input.schema">; }[K]; };
|
|
713
|
+
}>;
|
|
714
|
+
_setInput(monitor: Monitor, setter: FormSwitchInputSetter<TKind, TBranches>): void;
|
|
715
|
+
readonly _error: import("@owanturist/signal").ReadonlySignal<FormSwitchError<TKind, TBranches>>;
|
|
716
|
+
readonly _errorVerbose: import("@owanturist/signal").ReadonlySignal<{
|
|
717
|
+
readonly active: GetFormParam<TKind, "error.schema.verbose">;
|
|
718
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "error.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "error.schema.verbose">; }[K]; };
|
|
719
|
+
}>;
|
|
720
|
+
_setError(monitor: Monitor, setter: FormSwitchErrorSetter<TKind, TBranches>): void;
|
|
721
|
+
readonly _validateOn: import("@owanturist/signal").ReadonlySignal<FormSwitchValidateOn<TKind, TBranches>>;
|
|
722
|
+
readonly _validateOnVerbose: import("@owanturist/signal").ReadonlySignal<{
|
|
723
|
+
readonly active: GetFormParam<TKind, "validateOn.schema.verbose">;
|
|
724
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "validateOn.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "validateOn.schema.verbose">; }[K]; };
|
|
725
|
+
}>;
|
|
726
|
+
_setValidateOn(monitor: Monitor, setter: FormSwitchValidateOnSetter<TKind, TBranches>): void;
|
|
727
|
+
readonly _touched: import("@owanturist/signal").ReadonlySignal<FormSwitchFlag<TKind, TBranches>>;
|
|
728
|
+
readonly _touchedVerbose: import("@owanturist/signal").ReadonlySignal<{
|
|
729
|
+
readonly active: GetFormParam<TKind, "flag.schema.verbose">;
|
|
730
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }[K]; };
|
|
731
|
+
}>;
|
|
732
|
+
_setTouched(monitor: Monitor, setter: FormSwitchFlagSetter<TKind, TBranches>): void;
|
|
733
|
+
readonly _output: import("@owanturist/signal").ReadonlySignal<FormSwitchOutput<TKind, TBranches> | null>;
|
|
734
|
+
readonly _outputVerbose: import("@owanturist/signal").ReadonlySignal<{
|
|
735
|
+
readonly active: GetFormParam<TKind, "output.schema.verbose">;
|
|
736
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "output.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "output.schema.verbose">; }[K]; };
|
|
737
|
+
}>;
|
|
738
|
+
readonly _valid: import("@owanturist/signal").ReadonlySignal<FormSwitchFlag<TKind, TBranches>>;
|
|
739
|
+
readonly _validVerbose: import("@owanturist/signal").ReadonlySignal<{
|
|
740
|
+
readonly active: GetFormParam<TKind, "flag.schema.verbose">;
|
|
741
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }[K]; };
|
|
742
|
+
}>;
|
|
743
|
+
readonly _invalid: import("@owanturist/signal").ReadonlySignal<FormSwitchFlag<TKind, TBranches>>;
|
|
744
|
+
readonly _invalidVerbose: import("@owanturist/signal").ReadonlySignal<{
|
|
745
|
+
readonly active: GetFormParam<TKind, "flag.schema.verbose">;
|
|
746
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }[K]; };
|
|
747
|
+
}>;
|
|
748
|
+
readonly _validated: import("@owanturist/signal").ReadonlySignal<FormSwitchFlag<TKind, TBranches>>;
|
|
749
|
+
readonly _validatedVerbose: import("@owanturist/signal").ReadonlySignal<{
|
|
750
|
+
readonly active: GetFormParam<TKind, "flag.schema.verbose">;
|
|
751
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }[K]; };
|
|
752
|
+
}>;
|
|
753
|
+
_forceValidated(monitor: Monitor): void;
|
|
754
|
+
readonly _dirty: import("@owanturist/signal").ReadonlySignal<FormSwitchFlag<TKind, TBranches>>;
|
|
755
|
+
readonly _dirtyVerbose: import("@owanturist/signal").ReadonlySignal<{
|
|
756
|
+
readonly active: GetFormParam<TKind, "flag.schema.verbose">;
|
|
757
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }[K]; };
|
|
758
|
+
}>;
|
|
759
|
+
readonly _dirtyOnVerbose: import("@owanturist/signal").ReadonlySignal<{
|
|
760
|
+
readonly active: GetFormParam<TKind, "flag.schema.verbose">;
|
|
761
|
+
readonly branches: { [K in keyof { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }]: { readonly [TBranch in keyof TBranches]: GetFormParam<TBranches[TBranch], "flag.schema.verbose">; }[K]; };
|
|
762
|
+
}>;
|
|
763
|
+
_reset(monitor: Monitor, resetter: undefined | FormSwitchInputSetter<TKind, TBranches>): void;
|
|
764
|
+
_getChildren(monitor: Monitor): ReadonlyArray<SignalFormChild<FormSwitchParams<TKind, TBranches>>>;
|
|
765
|
+
}
|
|
955
766
|
declare class FormSwitch$1<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> extends SignalForm<FormSwitchParams<TKind, TBranches>> {
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
interface FormSwitchOptions<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> {
|
|
965
|
-
input?: FormSwitchInputSetter<TKind, TBranches>;
|
|
966
|
-
initial?: FormSwitchInputSetter<TKind, TBranches>;
|
|
967
|
-
touched?: FormSwitchFlagSetter<TKind, TBranches>;
|
|
968
|
-
validateOn?: FormSwitchValidateOnSetter<TKind, TBranches>;
|
|
969
|
-
error?: FormSwitchErrorSetter<TKind, TBranches>;
|
|
767
|
+
readonly _state: FormSwitchState<TKind, TBranches>;
|
|
768
|
+
static _getState: typeof SignalForm._getState;
|
|
769
|
+
readonly active: TKind;
|
|
770
|
+
readonly branches: Readonly<TBranches>;
|
|
771
|
+
constructor(_state: FormSwitchState<TKind, TBranches>);
|
|
772
|
+
getActiveBranch(monitor: Monitor): undefined | FormSwitchActiveBranch<TBranches>;
|
|
970
773
|
}
|
|
971
774
|
type FormSwitch<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> = FormSwitch$1<TKind, TBranches>;
|
|
775
|
+
interface FormSwitchOptions<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>> {
|
|
776
|
+
input?: FormSwitchInputSetter<TKind, TBranches>;
|
|
777
|
+
initial?: FormSwitchInputSetter<TKind, TBranches>;
|
|
778
|
+
touched?: FormSwitchFlagSetter<TKind, TBranches>;
|
|
779
|
+
validateOn?: FormSwitchValidateOnSetter<TKind, TBranches>;
|
|
780
|
+
error?: FormSwitchErrorSetter<TKind, TBranches>;
|
|
781
|
+
}
|
|
972
782
|
declare function FormSwitch<TKind extends SignalForm, TBranches extends FormSwitchBranches<TKind>>(active: TKind, branches: IsEqualType<GetFormParam<TKind, "output.schema">, keyof TBranches> extends true ? TBranches : never, { input, initial, touched, validateOn, error }?: FormSwitchOptions<TKind, TBranches>): FormSwitch<TKind, TBranches>;
|
|
973
|
-
|
|
974
783
|
declare function isFormSwitch(anything: unknown): anything is FormSwitch$1<SignalForm, FormSwitchBranches<SignalForm>>;
|
|
975
|
-
|
|
976
|
-
|
|
784
|
+
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 GetFormError, type GetFormErrorSetter, type GetFormErrorVerbose, type GetFormFlag, type GetFormFlagSetter, type GetFormFlagVerbose, type GetFormInput, type GetFormInputSetter, type GetFormOutput, type GetFormOutputVerbose, type GetFormParam, type GetFormShapeParam, type GetFormSwitchBranchesParam, type GetFormValidateOn, type GetFormValidateOnSetter, type GetFormValidateOnVerbose, type Result, type 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, type zodLikeParse };
|
|
785
|
+
//# sourceMappingURL=index.d.ts.map
|