foldkit-form 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -9
- package/dist/index.d.mts +559 -123
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +342 -99
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { Duration, Effect, Schema } from "effect";
|
|
1
|
+
import { Duration, Effect, Option, Schema } from "effect";
|
|
2
2
|
import { Bundle } from "foldkit-bundle";
|
|
3
|
+
import { AnyEntity, EntityInput, InputMember, NestedInput } from "foldkit-entity";
|
|
3
4
|
import { Metadata } from "foldkit-metadata";
|
|
4
5
|
import { Command } from "foldkit/command";
|
|
5
6
|
import * as FieldValidation from "foldkit/fieldValidation";
|
|
6
|
-
import { AnyEntity, EntityInput, InputMember, NestedInput } from "foldkit-entity";
|
|
7
7
|
//#region src/input.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* What a control holds while it is edited, which is not the value it submits: a
|
|
10
10
|
* number being typed is text, and an unchosen relation is the empty string.
|
|
11
11
|
*/
|
|
12
12
|
type Draft = string | boolean | ReadonlyArray<string>;
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The draft a control holds. `rows` is a nested key: rows of a form, not a
|
|
15
|
+
* draft. `model` is a control backed by a Bundle (`Input.bundle`): its draft is
|
|
16
|
+
* the Bundle's Model.
|
|
17
|
+
*/
|
|
18
|
+
type DraftKind = 'text' | 'flag' | 'list' | 'rows' | 'model';
|
|
15
19
|
/** What edits one key: the primitive every kind of control is a value of. */
|
|
16
20
|
interface Control<Data = unknown> {
|
|
17
21
|
/** The name a renderer is found by. */
|
|
@@ -28,9 +32,10 @@ interface Control<Data = unknown> {
|
|
|
28
32
|
readonly data: Data;
|
|
29
33
|
/**
|
|
30
34
|
* For a `text` draft: the value the key's schema is given, when that is not the
|
|
31
|
-
* text itself
|
|
35
|
+
* text itself, read with the control's `data` (a select's options). `undefined`
|
|
36
|
+
* means the text does not read as one.
|
|
32
37
|
*/
|
|
33
|
-
|
|
38
|
+
parse?(draft: string, data: Data): unknown;
|
|
34
39
|
/** What to say when `parse` gives `undefined`. */
|
|
35
40
|
readonly unparsed?: string | undefined;
|
|
36
41
|
/**
|
|
@@ -75,8 +80,13 @@ interface NestedForm {
|
|
|
75
80
|
readonly rows: (model: never, key: never) => ReadonlyArray<FormRow>;
|
|
76
81
|
readonly search: (model: never, key: never) => string;
|
|
77
82
|
readonly isFollowing: (model: never, key: never) => boolean;
|
|
83
|
+
/** A key edited by a control backed by a Bundle: its state, with the Bundle's Model as the value. */
|
|
84
|
+
readonly control: (key: never) => {
|
|
85
|
+
readonly field: (model: never) => unknown;
|
|
86
|
+
};
|
|
78
87
|
readonly Message: {
|
|
79
88
|
readonly Changed: (payload: never) => unknown;
|
|
89
|
+
readonly Control: (payload: never) => unknown;
|
|
80
90
|
readonly Blurred: (payload: never) => unknown;
|
|
81
91
|
readonly Searched: (payload: never) => unknown;
|
|
82
92
|
readonly Nested: (payload: never) => unknown;
|
|
@@ -84,6 +94,53 @@ interface NestedForm {
|
|
|
84
94
|
readonly RowRemoved: (payload: never) => unknown;
|
|
85
95
|
};
|
|
86
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* What a control backed by a Bundle carries: the Bundle, its args, and how the
|
|
99
|
+
* key's value is read from its Model and written into it.
|
|
100
|
+
*/
|
|
101
|
+
interface BundleData<Model = any, Value = any> {
|
|
102
|
+
readonly bundle: Bundle.AnyBundle;
|
|
103
|
+
readonly args: unknown;
|
|
104
|
+
/** The value the key validates and submits. `undefined` or `null` is nothing entered. */
|
|
105
|
+
readonly value: (model: Model) => Value | null | undefined;
|
|
106
|
+
/** The Model showing a value the form was given, from the Model the control holds. */
|
|
107
|
+
readonly fill: (model: Model, value: Value) => Model;
|
|
108
|
+
/** The Model with nothing in flight, for a stored form shown again. */
|
|
109
|
+
readonly settled: (model: Model) => Model;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A control backed by a Bundle. Its draft is the Bundle's Model, its Messages
|
|
113
|
+
* reach it through the form, and its Commands, Subscriptions and Resources are
|
|
114
|
+
* the form's.
|
|
115
|
+
*/
|
|
116
|
+
interface BundleControl<Model, Message, Value, Resources = {}> extends Control<BundleData<Model, Value>> {
|
|
117
|
+
readonly draft: 'model';
|
|
118
|
+
/** Type-only: the Bundle's Message, for `form.control(key).send`. Never set. */
|
|
119
|
+
readonly Message?: Message;
|
|
120
|
+
/** Type-only: the Bundle's Resources, which a runtime running the form must provide. Never set. */
|
|
121
|
+
readonly Resources?: Resources;
|
|
122
|
+
}
|
|
123
|
+
/** What `Input.bundle` takes: the Bundle, then how the key's value lives in its Model. */
|
|
124
|
+
type BundleControlSpec<Args, Model, Message extends {
|
|
125
|
+
readonly _tag: string;
|
|
126
|
+
}, Value, Resources extends Bundle.ResourceEntries<Model, Message> = {}> = {
|
|
127
|
+
/**
|
|
128
|
+
* The Bundle. Its Commands may need no services, and it has no OutMessage: a
|
|
129
|
+
* form key has no parent to hand one to, and an OutMessage is never dropped
|
|
130
|
+
* by omission.
|
|
131
|
+
*/
|
|
132
|
+
readonly bundle: Bundle.Bundle<any, Args, Model, Message, never, never, any, any, Resources, any>;
|
|
133
|
+
/** The value the key validates and submits. `undefined` or `null` is nothing entered. */
|
|
134
|
+
readonly value: (model: Model) => Value | null | undefined;
|
|
135
|
+
/** The Model showing a value the form was given (`fill`), from the Model the control holds. */
|
|
136
|
+
readonly fill: (model: Model, value: Value) => Model;
|
|
137
|
+
/** The Model with nothing in flight, for a stored form shown again. Default: as it is. */
|
|
138
|
+
readonly settled?: (model: Model) => Model;
|
|
139
|
+
} & ([Args] extends [void] ? {
|
|
140
|
+
readonly args?: undefined;
|
|
141
|
+
} : {
|
|
142
|
+
readonly args: Args;
|
|
143
|
+
});
|
|
87
144
|
/** A relation picker: what it chooses from, and whether it searches. */
|
|
88
145
|
interface RelationData {
|
|
89
146
|
readonly target: AnyEntity;
|
|
@@ -106,7 +163,8 @@ export declare const Input: {
|
|
|
106
163
|
readonly draft: DraftKind;
|
|
107
164
|
readonly shown?: boolean;
|
|
108
165
|
readonly searches?: boolean | ((data: Data) => boolean);
|
|
109
|
-
|
|
166
|
+
/** The value a text draft stands for, given the control's data; `undefined` when it stands for none. */
|
|
167
|
+
readonly parse?: (draft: string, data: Data) => unknown;
|
|
110
168
|
readonly unparsed?: string;
|
|
111
169
|
}) => ControlKind<Data>;
|
|
112
170
|
Text: ControlKind<Record<string, never>>;
|
|
@@ -115,18 +173,39 @@ export declare const Input: {
|
|
|
115
173
|
Number: ControlKind<Record<string, never>>;
|
|
116
174
|
Toggle: ControlKind<Record<string, never>>;
|
|
117
175
|
Select: ControlKind<{
|
|
118
|
-
readonly options: ReadonlyArray<string>;
|
|
176
|
+
readonly options: ReadonlyArray<string | number>;
|
|
119
177
|
}>;
|
|
120
178
|
RelationOne: ControlKind<RelationData>;
|
|
121
179
|
RelationMany: ControlKind<RelationData>;
|
|
122
180
|
Nested: ControlKind<NestedData>;
|
|
181
|
+
/**
|
|
182
|
+
* A control backed by a Bundle, for a draft that is a Model of its own: a
|
|
183
|
+
* color picker with a popover, a page builder, a rich-text editor. The key's
|
|
184
|
+
* draft is the Bundle's Model; `value` reads what the key validates and
|
|
185
|
+
* submits from it, and `fill` writes a given value into it. The Bundle's
|
|
186
|
+
* Messages travel as the form's `Control` Message, and its Commands,
|
|
187
|
+
* Subscriptions and Resources become the form's.
|
|
188
|
+
*/
|
|
189
|
+
bundle: <Args, Model, Message extends {
|
|
190
|
+
readonly _tag: string;
|
|
191
|
+
}, Value, Resources extends Bundle.ResourceEntries<Model, Message> = {}>(kind: string, spec: BundleControlSpec<Args, Model, Message, Value, Resources>) => BundleControl<Model, Message, Value, Resources>;
|
|
192
|
+
/** Whether a control is backed by a Bundle, whatever its kind is called. */
|
|
193
|
+
isBundle: (control: Control) => control is Control<BundleData>;
|
|
123
194
|
text: () => Control;
|
|
124
195
|
/** Carried and submitted, not shown: the id of the thing being edited. Set it with `fill`. */
|
|
125
196
|
hidden: () => Control;
|
|
126
197
|
multiline: () => Control;
|
|
127
198
|
number: () => Control;
|
|
128
199
|
toggle: () => Control;
|
|
129
|
-
select: (options: ReadonlyArray<string>) => Control;
|
|
200
|
+
select: (options: ReadonlyArray<string | number>) => Control;
|
|
201
|
+
/**
|
|
202
|
+
* A picker of one of `target`, for a value that is not a relation of the
|
|
203
|
+
* form's Entity: a page Builder's Block prop that holds an id. A relation key
|
|
204
|
+
* resolves to its picker without asking.
|
|
205
|
+
*/
|
|
206
|
+
relationOne: (target: AnyEntity) => Control;
|
|
207
|
+
/** A picker of any number of `target`, as `relationOne` is of one. */
|
|
208
|
+
relationMany: (target: AnyEntity) => Control;
|
|
130
209
|
/**
|
|
131
210
|
* For a relation key, under `inputs`: its picker, with a search. Too many to
|
|
132
211
|
* list is the usual case for a relation; the form holds the search text, and
|
|
@@ -162,8 +241,23 @@ export type DraftOf<Value> = [Exclude<Value, null | undefined>] extends [boolean
|
|
|
162
241
|
export type NestedKey<Members> = { [K in keyof Members]: Members[K] extends NestedInput<any, any> ? K : never; }[keyof Members];
|
|
163
242
|
/** The Model of the form a nested key's rows hold. */
|
|
164
243
|
export type NestedModel<Member> = Member extends NestedInput<any, EntityInput<any, infer Fields, infer Members>> ? FormModel<Fields, Members> : never;
|
|
165
|
-
|
|
166
|
-
|
|
244
|
+
/** The controls a form may be given under `inputs`, by key. */
|
|
245
|
+
export type InputsFor<Fields extends Schema.Struct.Fields, Members> = { readonly [K in Exclude<keyof Fields, NestedKey<Members>>]?: Control | ControlChange; };
|
|
246
|
+
/** The keys given a control backed by a Bundle, each with the Bundle's Model: that key's draft. */
|
|
247
|
+
export type ControlsOf<Inputs> = { readonly [K in keyof Inputs as Inputs[K] extends BundleControl<any, any, any> ? K : never]: Inputs[K] extends BundleControl<infer Model, any, any> ? Model : never; };
|
|
248
|
+
/**
|
|
249
|
+
* Whether any control backed by a Bundle holds Resources: then the form's
|
|
250
|
+
* Bundle has Resources, and a runtime running it must provide them.
|
|
251
|
+
*/
|
|
252
|
+
export type ControlResourcesOf<Inputs> = true extends { readonly [K in keyof Inputs]: Inputs[K] extends BundleControl<any, any, any, infer Resources> ? [keyof Resources] extends [never] ? false : true : false; }[keyof Inputs] ? Readonly<Record<string, never>> : {};
|
|
253
|
+
/** The Message of the Bundle behind a key's control. */
|
|
254
|
+
export type ControlMessageOf<C> = C extends BundleControl<any, infer Message, any> ? Message : never;
|
|
255
|
+
export interface FormModel<Fields extends Schema.Struct.Fields, Members = {}, Controls = {}> {
|
|
256
|
+
/**
|
|
257
|
+
* One `fieldValidation` Field per key that holds a draft. A key given a
|
|
258
|
+
* control backed by a Bundle holds that Bundle's Model as its draft.
|
|
259
|
+
*/
|
|
260
|
+
readonly fields: { readonly [K in keyof Fields as K extends NestedKey<Members> ? never : K]: FieldValidation.Field<K extends keyof Controls ? Controls[K] : DraftOf<Schema.Schema.Type<Fields[K]>>>; };
|
|
167
261
|
/** The rows of each nested key, each a Model of the nested form. */
|
|
168
262
|
readonly rows: { readonly [K in keyof Fields as K extends NestedKey<Members> ? K : never]: ReadonlyArray<FormRow<NestedModel<Members[K & keyof Members]>>>; };
|
|
169
263
|
/** Counts the rows ever added, so a row's id is never reused. */
|
|
@@ -247,17 +341,17 @@ export declare const fillWords: (template: string, values: Readonly<Record<strin
|
|
|
247
341
|
* A form made with `Form.make` from the input a key nests. It is an ordinary
|
|
248
342
|
* form: the one that edits an author alone is the one a post's form nests.
|
|
249
343
|
*/
|
|
250
|
-
export interface FormFor<Fields extends Schema.Struct.Fields, Members, R = never> extends NestedForm {
|
|
344
|
+
export interface FormFor<Fields extends Schema.Struct.Fields, Members, R = never, Controls = any> extends NestedForm {
|
|
251
345
|
readonly input: EntityInput<any, Fields, Members>;
|
|
252
346
|
readonly bundle: {
|
|
253
|
-
readonly Model: Schema.Codec<FormModel<Fields, Members>, unknown>;
|
|
347
|
+
readonly Model: Schema.Codec<FormModel<Fields, Members, Controls>, unknown>;
|
|
254
348
|
readonly Message: Schema.Codec<any, unknown>;
|
|
255
349
|
readonly update: (model: any, message: any, args: void) => {
|
|
256
350
|
readonly model: any;
|
|
257
351
|
readonly commands?: ReadonlyArray<Command<any, never, R>> | undefined;
|
|
258
352
|
};
|
|
259
353
|
};
|
|
260
|
-
readonly initial: FormModel<Fields, Members>;
|
|
354
|
+
readonly initial: FormModel<Fields, Members, Controls>;
|
|
261
355
|
readonly fill: (model: any, values: any) => {
|
|
262
356
|
readonly model: any;
|
|
263
357
|
};
|
|
@@ -266,19 +360,29 @@ export interface FormFor<Fields extends Schema.Struct.Fields, Members, R = never
|
|
|
266
360
|
readonly model: any;
|
|
267
361
|
readonly commands: ReadonlyArray<Command<any, never, R>>;
|
|
268
362
|
};
|
|
363
|
+
readonly validateAll: (model: any) => {
|
|
364
|
+
readonly model: any;
|
|
365
|
+
readonly commands: ReadonlyArray<Command<any, never, R>>;
|
|
366
|
+
};
|
|
269
367
|
readonly isValidating: (model: any) => boolean;
|
|
270
368
|
readonly value: (model: any) => unknown;
|
|
271
369
|
/** Whether a transition changed authored content, so a nesting form recurses. */
|
|
272
370
|
readonly authoredChanged: (before: any, after: any) => boolean;
|
|
273
371
|
};
|
|
274
372
|
readonly settled: (model: any) => any;
|
|
373
|
+
/**
|
|
374
|
+
* The decoded input as `Some` only when every key and row is valid as the
|
|
375
|
+
* form stands; `None` otherwise. All or nothing, unlike `partial`, so a
|
|
376
|
+
* parent submitting several forms reads one complete value per form.
|
|
377
|
+
*/
|
|
378
|
+
readonly value: (model: any) => Option.Option<Schema.Struct.Type<Fields>>;
|
|
275
379
|
/** Whether a completed transition changed authored content. */
|
|
276
380
|
readonly authoredChanged: (before: any, after: any) => boolean;
|
|
277
381
|
}
|
|
278
382
|
/** The forms a form may be given for its nested keys: each one made from that key's nested input. */
|
|
279
383
|
export type NestedForms<Fields extends Schema.Struct.Fields, Members, R> = { readonly [K in NestedKey<Members> & keyof Fields]?: Members[K] extends NestedInput<any, EntityInput<any, infer NestedFields, infer NestedMembers>> ? NestedFields extends Schema.Struct.Fields ? FormFor<NestedFields, NestedMembers, R> : never : never; };
|
|
280
384
|
/** The constructors of a form's Messages that a row's handle offers, wrapped for the row. */
|
|
281
|
-
type RowConstructor = 'Changed' | 'Blurred' | 'Searched' | 'Submitted' | 'Reset' | 'RowAdded' | 'RowRemoved';
|
|
385
|
+
type RowConstructor = 'Changed' | 'Blurred' | 'ValidatedAll' | 'Searched' | 'Submitted' | 'Reset' | 'RowAdded' | 'RowRemoved';
|
|
282
386
|
/**
|
|
283
387
|
* One row of a nested key, addressed: the nested form's own Message constructors,
|
|
284
388
|
* each giving the Message of the form the row is in. `send` wraps a Message
|
|
@@ -290,12 +394,13 @@ export type RowHandle<Child, Message> = { readonly [T in RowConstructor]: Child
|
|
|
290
394
|
readonly send: (message: unknown) => Message;
|
|
291
395
|
};
|
|
292
396
|
/** What `Form.make` takes beside the input. */
|
|
293
|
-
export interface FormOptions<Fields extends Schema.Struct.Fields, Members, R, Nest extends NestedForms<Fields, Members, R> = {}> {
|
|
397
|
+
export interface FormOptions<Fields extends Schema.Struct.Fields, Members, R, Nest extends NestedForms<Fields, Members, R> = {}, Inputs extends InputsFor<Fields, Members> = InputsFor<Fields, Members>> {
|
|
294
398
|
/**
|
|
295
399
|
* The control for a key the resolver cannot decide, or should not: an unmapped
|
|
296
|
-
* key with an unusual schema,
|
|
400
|
+
* key with an unusual schema, text that wants a multiline control here only,
|
|
401
|
+
* or a control backed by a Bundle (`Input.bundle`).
|
|
297
402
|
*/
|
|
298
|
-
readonly inputs?:
|
|
403
|
+
readonly inputs?: Inputs;
|
|
299
404
|
/** The form's own words, and a rewrite of Schema's: for wording and for translation. */
|
|
300
405
|
readonly messages?: FormMessages<keyof Fields & string>;
|
|
301
406
|
/** Rules answered outside the form, by key. The key reads `Validating` while one runs. */
|
|
@@ -327,14 +432,16 @@ declare const Core: {
|
|
|
327
432
|
* holds a draft. `options` names what the input cannot say: a control, the
|
|
328
433
|
* words, the checks.
|
|
329
434
|
*/
|
|
330
|
-
make: <const Name extends string, E extends AnyEntity, Fields extends Schema.Struct.Fields, Members extends { readonly [K in keyof Fields]: InputMember; }, R = never, const Nest extends NestedForms<Fields, Members, R> = {}>(name: Name, input: EntityInput<E, Fields, Members>, options?: FormOptions<Fields, Members, R, Nest>) => {
|
|
331
|
-
bundle: Bundle.Bundle<Name, void, FormModel<Fields, Members
|
|
435
|
+
make: <const Name extends string, E extends AnyEntity, Fields extends Schema.Struct.Fields, Members extends { readonly [K in keyof Fields]: InputMember; }, R = never, const Nest extends NestedForms<Fields, Members, R> = {}, const Inputs extends InputsFor<Fields, Members> = {}>(name: Name, input: EntityInput<E, Fields, Members>, options?: FormOptions<Fields, Members, R, Nest, Inputs>) => {
|
|
436
|
+
bundle: Bundle.Bundle<Name, void, FormModel<Fields, Members, ControlsOf<Inputs>>, {
|
|
332
437
|
readonly _tag: "Changed";
|
|
333
438
|
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
334
439
|
readonly value: string | boolean | readonly string[];
|
|
335
440
|
} | {
|
|
336
441
|
readonly _tag: "Blurred";
|
|
337
442
|
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
443
|
+
} | {
|
|
444
|
+
readonly _tag: "ValidatedAll";
|
|
338
445
|
} | {
|
|
339
446
|
readonly _tag: "Submitted";
|
|
340
447
|
} | {
|
|
@@ -362,6 +469,10 @@ declare const Core: {
|
|
|
362
469
|
readonly key: string;
|
|
363
470
|
readonly row: string;
|
|
364
471
|
readonly message: unknown;
|
|
472
|
+
} | {
|
|
473
|
+
readonly _tag: "Control";
|
|
474
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
475
|
+
readonly message: unknown;
|
|
365
476
|
} | {
|
|
366
477
|
readonly _tag: "RowAdded";
|
|
367
478
|
readonly key: string;
|
|
@@ -369,27 +480,33 @@ declare const Core: {
|
|
|
369
480
|
readonly _tag: "RowRemoved";
|
|
370
481
|
readonly key: string;
|
|
371
482
|
readonly row: string;
|
|
372
|
-
}, Submitted<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>, R, never, void,
|
|
373
|
-
fill: (model: FormModel<Fields, Members
|
|
374
|
-
readonly model: FormModel<Fields, Members
|
|
483
|
+
}, Submitted<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>, R, never, void, ControlResourcesOf<Inputs>, {
|
|
484
|
+
fill: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, values: Partial<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>) => {
|
|
485
|
+
readonly model: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
375
486
|
};
|
|
376
487
|
}>;
|
|
377
488
|
Message: import("foldkit/message").MessageUnion<{
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
489
|
+
Changed: {
|
|
490
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
491
|
+
value: Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.$Array<Schema.String>]>;
|
|
381
492
|
};
|
|
382
493
|
/** Validates the key as it stands, so a required key left empty says so. */
|
|
383
|
-
|
|
384
|
-
|
|
494
|
+
Blurred: {
|
|
495
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
385
496
|
};
|
|
386
|
-
|
|
387
|
-
|
|
497
|
+
/**
|
|
498
|
+
* Validates every key not validated yet, in every row too, as a submit
|
|
499
|
+
* would, and submits nothing: for a page that submits several forms at once.
|
|
500
|
+
* A rule spanning keys is said only by a submit.
|
|
501
|
+
*/
|
|
502
|
+
ValidatedAll: {};
|
|
503
|
+
Submitted: {};
|
|
504
|
+
Reset: {};
|
|
388
505
|
/** The answer of a check for the draft it was asked about; one for an older draft is dropped. */
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
506
|
+
Checked: {
|
|
507
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
508
|
+
draft: Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.$Array<Schema.String>]>;
|
|
509
|
+
error: Schema.NullOr<Schema.String>;
|
|
393
510
|
};
|
|
394
511
|
/**
|
|
395
512
|
* The outside world refused this key's value: a unique index, a rule only a
|
|
@@ -397,9 +514,9 @@ declare const Core: {
|
|
|
397
514
|
* typed, until it is edited again. Unlike `Checked`, it answers no question
|
|
398
515
|
* the form asked, so it lands whatever state the key is in.
|
|
399
516
|
*/
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
517
|
+
Refused: {
|
|
518
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
519
|
+
error: Schema.String;
|
|
403
520
|
};
|
|
404
521
|
/**
|
|
405
522
|
* What the form is editing, for the checks that need to know: a post's own
|
|
@@ -407,40 +524,49 @@ declare const Core: {
|
|
|
407
524
|
* It changes no draft and validates nothing; a form that creates something
|
|
408
525
|
* never sends it. See `FormModel.subject`.
|
|
409
526
|
*/
|
|
410
|
-
|
|
411
|
-
|
|
527
|
+
About: {
|
|
528
|
+
subject: Schema.$Record<Schema.String, Schema.String>;
|
|
412
529
|
};
|
|
413
530
|
/** What was typed to find a choice for a relation key. It changes no draft and validates nothing. */
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
531
|
+
Searched: {
|
|
532
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
533
|
+
text: Schema.String;
|
|
417
534
|
};
|
|
418
535
|
/** A Message of the nested form in one row of a nested key. One that row does not take is dropped. */
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
536
|
+
Nested: {
|
|
537
|
+
key: Schema.String;
|
|
538
|
+
row: Schema.String;
|
|
539
|
+
message: Schema.Unknown;
|
|
540
|
+
};
|
|
541
|
+
/**
|
|
542
|
+
* A Message of the control backed by a Bundle that edits `key`. One the
|
|
543
|
+
* Bundle does not take is dropped. It is an edit when it changes the key's
|
|
544
|
+
* value, and is then validated as `Changed` would be.
|
|
545
|
+
*/
|
|
546
|
+
Control: {
|
|
547
|
+
key: Schema.Literals<readonly [keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>, ...(keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>)[]]>;
|
|
548
|
+
message: Schema.Unknown;
|
|
423
549
|
};
|
|
424
550
|
/** A new, empty row. A `one` that already has its row takes no other. */
|
|
425
|
-
|
|
426
|
-
|
|
551
|
+
RowAdded: {
|
|
552
|
+
key: Schema.String;
|
|
427
553
|
};
|
|
428
554
|
/** Removes a row. A `one` that must be there stays. */
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
555
|
+
RowRemoved: {
|
|
556
|
+
key: Schema.String;
|
|
557
|
+
row: Schema.String;
|
|
432
558
|
};
|
|
433
559
|
}>;
|
|
434
560
|
/** The reading the form was made from, for `Entity.selectFor` and `Entity.valuesFor`. */
|
|
435
561
|
input: EntityInput<E, Fields, Members>;
|
|
436
562
|
/** Whether a completed transition changed authored content. See the note above. */
|
|
437
|
-
authoredChanged: (before: FormModel<Fields, Members
|
|
563
|
+
authoredChanged: (before: FormModel<Fields, Members, ControlsOf<Inputs>>, after: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
438
564
|
/** The `fill` helper as a plain function of the form's Model, for a package that wraps the form. */
|
|
439
|
-
fill: (model: FormModel<Fields, Members
|
|
440
|
-
readonly model: FormModel<Fields, Members
|
|
565
|
+
fill: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, values: Partial<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>) => {
|
|
566
|
+
readonly model: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
441
567
|
};
|
|
442
568
|
/** The Model the form starts from and resets to: every key empty and not validated. */
|
|
443
|
-
initial: FormModel<Fields, Members
|
|
569
|
+
initial: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
444
570
|
/** The keys in the input's order, each with its control, label, and member. */
|
|
445
571
|
controls: FormControl<keyof Fields & string>[];
|
|
446
572
|
/**
|
|
@@ -448,11 +574,67 @@ declare const Core: {
|
|
|
448
574
|
* `controls`. `model.fields.title` is the same value, typed to that key. A
|
|
449
575
|
* nested key has rows and no draft.
|
|
450
576
|
*/
|
|
451
|
-
field: (model: FormModel<Fields, Members
|
|
577
|
+
field: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, key: Exclude<Exclude<keyof Fields & string, NestedKey<Members>>, keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>>) => FieldValidation.Field<Draft>;
|
|
578
|
+
/**
|
|
579
|
+
* The key edited by a control backed by a Bundle, addressed: `field` is its
|
|
580
|
+
* state with the Bundle's Model as its value, and `send` gives the form's
|
|
581
|
+
* Message for one of the Bundle's own.
|
|
582
|
+
*/
|
|
583
|
+
control: <K extends keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>>(key: K) => {
|
|
584
|
+
readonly field: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => { readonly [K_1 in keyof Fields as K_1 extends NestedKey<Members> ? never : K_1]: FieldValidation.Field<K_1 extends keyof ControlsOf<Inputs> ? ControlsOf<Inputs>[K_1] : DraftOf<Schema.Schema.Type<Fields[K_1]>>>; }[K];
|
|
585
|
+
readonly send: (message: ControlMessageOf<Inputs[K]>) => {
|
|
586
|
+
readonly _tag: "Changed";
|
|
587
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
588
|
+
readonly value: string | boolean | readonly string[];
|
|
589
|
+
} | {
|
|
590
|
+
readonly _tag: "Blurred";
|
|
591
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
592
|
+
} | {
|
|
593
|
+
readonly _tag: "ValidatedAll";
|
|
594
|
+
} | {
|
|
595
|
+
readonly _tag: "Submitted";
|
|
596
|
+
} | {
|
|
597
|
+
readonly _tag: "Reset";
|
|
598
|
+
} | {
|
|
599
|
+
readonly _tag: "Checked";
|
|
600
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
601
|
+
readonly draft: string | boolean | readonly string[];
|
|
602
|
+
readonly error: string | null;
|
|
603
|
+
} | {
|
|
604
|
+
readonly _tag: "Refused";
|
|
605
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
606
|
+
readonly error: string;
|
|
607
|
+
} | {
|
|
608
|
+
readonly _tag: "About";
|
|
609
|
+
readonly subject: {
|
|
610
|
+
readonly [x: string]: string;
|
|
611
|
+
};
|
|
612
|
+
} | {
|
|
613
|
+
readonly _tag: "Searched";
|
|
614
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
615
|
+
readonly text: string;
|
|
616
|
+
} | {
|
|
617
|
+
readonly _tag: "Nested";
|
|
618
|
+
readonly key: string;
|
|
619
|
+
readonly row: string;
|
|
620
|
+
readonly message: unknown;
|
|
621
|
+
} | {
|
|
622
|
+
readonly _tag: "Control";
|
|
623
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
624
|
+
readonly message: unknown;
|
|
625
|
+
} | {
|
|
626
|
+
readonly _tag: "RowAdded";
|
|
627
|
+
readonly key: string;
|
|
628
|
+
} | {
|
|
629
|
+
readonly _tag: "RowRemoved";
|
|
630
|
+
readonly key: string;
|
|
631
|
+
readonly row: string;
|
|
632
|
+
};
|
|
633
|
+
};
|
|
452
634
|
/** What was typed to find a choice for a relation key that searches; `''` until something is. */
|
|
453
|
-
search: (model: FormModel<Fields, Members
|
|
635
|
+
search: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, key: Exclude<keyof Fields & string, NestedKey<Members>>) => string;
|
|
454
636
|
/** What the form is editing; `{}` while it creates. See `FormModel.subject`. */
|
|
455
|
-
subject: (model: FormModel<Fields, Members
|
|
637
|
+
subject: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => Readonly<Record<string, string>>;
|
|
456
638
|
/**
|
|
457
639
|
* The form of each nested key, typed when it was given under `nested`: its
|
|
458
640
|
* `controls`, its `field`, its Messages.
|
|
@@ -469,6 +651,8 @@ declare const Core: {
|
|
|
469
651
|
} | {
|
|
470
652
|
readonly _tag: "Blurred";
|
|
471
653
|
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
654
|
+
} | {
|
|
655
|
+
readonly _tag: "ValidatedAll";
|
|
472
656
|
} | {
|
|
473
657
|
readonly _tag: "Submitted";
|
|
474
658
|
} | {
|
|
@@ -496,6 +680,10 @@ declare const Core: {
|
|
|
496
680
|
readonly key: string;
|
|
497
681
|
readonly row: string;
|
|
498
682
|
readonly message: unknown;
|
|
683
|
+
} | {
|
|
684
|
+
readonly _tag: "Control";
|
|
685
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
686
|
+
readonly message: unknown;
|
|
499
687
|
} | {
|
|
500
688
|
readonly _tag: "RowAdded";
|
|
501
689
|
readonly key: string;
|
|
@@ -508,30 +696,44 @@ declare const Core: {
|
|
|
508
696
|
* Whether a key that follows another still does: `false` once the author has
|
|
509
697
|
* written it themselves. A view offers "regenerate" by sending the key an empty draft.
|
|
510
698
|
*/
|
|
511
|
-
isFollowing: (model: FormModel<Fields, Members
|
|
699
|
+
isFollowing: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, key: Exclude<keyof Fields & string, NestedKey<Members>>) => boolean;
|
|
512
700
|
/** The rows of a nested key, each a Model of `control.form`. */
|
|
513
|
-
rows: (model: FormModel<Fields, Members
|
|
701
|
+
rows: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, key: Extract<keyof Fields & string, NestedKey<Members>>) => { readonly [K in keyof Fields as K extends NestedKey<Members> ? K : never]: readonly FormRow<NestedModel<Members[K & keyof Members]>>[]; }[Extract<keyof Fields & string, NestedKey<Members>>];
|
|
514
702
|
/**
|
|
515
703
|
* Whether a submit now could go through: nothing is invalid. A check still
|
|
516
704
|
* running does not stop it; the submit waits for the answer.
|
|
517
705
|
*/
|
|
518
|
-
canSubmit: (model: FormModel<Fields, Members
|
|
706
|
+
canSubmit: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
707
|
+
/**
|
|
708
|
+
* Whether the form is valid right now: a submit now would hand over the
|
|
709
|
+
* value at once. Unlike `canSubmit`, a check running, or one a key has not
|
|
710
|
+
* had yet, is not valid until it answers.
|
|
711
|
+
*/
|
|
712
|
+
isValid: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
713
|
+
/**
|
|
714
|
+
* The decoded input as `Some` only when every key and row is valid as the
|
|
715
|
+
* form stands; `None` otherwise. Unlike `partial`, it is all or nothing,
|
|
716
|
+
* so a parent that submits several forms can read one complete value per
|
|
717
|
+
* form. It validates nothing: reveal drafts first (a submit, or
|
|
718
|
+
* `Message.ValidatedAll()`), or read after one did.
|
|
719
|
+
*/
|
|
720
|
+
value: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => Option.Option<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>;
|
|
519
721
|
/**
|
|
520
722
|
* The Model with nothing in flight, for one that was stored and is shown
|
|
521
723
|
* again: a check that was running when it was stored will never answer, so
|
|
522
724
|
* its key is not validated yet, and no submit is waiting. Rows too.
|
|
523
725
|
*/
|
|
524
|
-
settled: (model: FormModel<Fields, Members
|
|
726
|
+
settled: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
525
727
|
/**
|
|
526
728
|
* What of the form decodes as it stands, by key: the value, less every key
|
|
527
729
|
* that is not valid yet. For saving unfinished work, which `engine.value`
|
|
528
730
|
* cannot give. A nested key is there once each of its rows has a value.
|
|
529
731
|
*/
|
|
530
|
-
partial: (model: FormModel<Fields, Members
|
|
732
|
+
partial: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => Partial<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>;
|
|
531
733
|
/** The form as the form that nests it drives it. */
|
|
532
734
|
engine: {
|
|
533
|
-
submit: (model: FormModel<Fields, Members
|
|
534
|
-
model: FormModel<Fields, Members
|
|
735
|
+
submit: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => {
|
|
736
|
+
model: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
535
737
|
commands: readonly Readonly<{
|
|
536
738
|
name: string;
|
|
537
739
|
args?: Record<string, unknown>;
|
|
@@ -543,6 +745,8 @@ declare const Core: {
|
|
|
543
745
|
} | {
|
|
544
746
|
readonly _tag: "Blurred";
|
|
545
747
|
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
748
|
+
} | {
|
|
749
|
+
readonly _tag: "ValidatedAll";
|
|
546
750
|
} | {
|
|
547
751
|
readonly _tag: "Submitted";
|
|
548
752
|
} | {
|
|
@@ -570,6 +774,10 @@ declare const Core: {
|
|
|
570
774
|
readonly key: string;
|
|
571
775
|
readonly row: string;
|
|
572
776
|
readonly message: unknown;
|
|
777
|
+
} | {
|
|
778
|
+
readonly _tag: "Control";
|
|
779
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
780
|
+
readonly message: unknown;
|
|
573
781
|
} | {
|
|
574
782
|
readonly _tag: "RowAdded";
|
|
575
783
|
readonly key: string;
|
|
@@ -580,11 +788,67 @@ declare const Core: {
|
|
|
580
788
|
}, never, R>;
|
|
581
789
|
}>[];
|
|
582
790
|
};
|
|
583
|
-
|
|
791
|
+
validateAll: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => {
|
|
792
|
+
readonly model: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
793
|
+
readonly commands: readonly Readonly<{
|
|
794
|
+
name: string;
|
|
795
|
+
args?: Record<string, unknown>;
|
|
796
|
+
key?: string;
|
|
797
|
+
effect: Effect.Effect<{
|
|
798
|
+
readonly _tag: "Changed";
|
|
799
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
800
|
+
readonly value: string | boolean | readonly string[];
|
|
801
|
+
} | {
|
|
802
|
+
readonly _tag: "Blurred";
|
|
803
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
804
|
+
} | {
|
|
805
|
+
readonly _tag: "ValidatedAll";
|
|
806
|
+
} | {
|
|
807
|
+
readonly _tag: "Submitted";
|
|
808
|
+
} | {
|
|
809
|
+
readonly _tag: "Reset";
|
|
810
|
+
} | {
|
|
811
|
+
readonly _tag: "Checked";
|
|
812
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
813
|
+
readonly draft: string | boolean | readonly string[];
|
|
814
|
+
readonly error: string | null;
|
|
815
|
+
} | {
|
|
816
|
+
readonly _tag: "Refused";
|
|
817
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
818
|
+
readonly error: string;
|
|
819
|
+
} | {
|
|
820
|
+
readonly _tag: "About";
|
|
821
|
+
readonly subject: {
|
|
822
|
+
readonly [x: string]: string;
|
|
823
|
+
};
|
|
824
|
+
} | {
|
|
825
|
+
readonly _tag: "Searched";
|
|
826
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
827
|
+
readonly text: string;
|
|
828
|
+
} | {
|
|
829
|
+
readonly _tag: "Nested";
|
|
830
|
+
readonly key: string;
|
|
831
|
+
readonly row: string;
|
|
832
|
+
readonly message: unknown;
|
|
833
|
+
} | {
|
|
834
|
+
readonly _tag: "Control";
|
|
835
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
836
|
+
readonly message: unknown;
|
|
837
|
+
} | {
|
|
838
|
+
readonly _tag: "RowAdded";
|
|
839
|
+
readonly key: string;
|
|
840
|
+
} | {
|
|
841
|
+
readonly _tag: "RowRemoved";
|
|
842
|
+
readonly key: string;
|
|
843
|
+
readonly row: string;
|
|
844
|
+
}, never, R>;
|
|
845
|
+
}>[];
|
|
846
|
+
};
|
|
847
|
+
isValidating: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
584
848
|
/** Whether a transition changed authored content, so a nesting form recurses. */
|
|
585
|
-
authoredChanged: (before: FormModel<Fields, Members
|
|
849
|
+
authoredChanged: (before: FormModel<Fields, Members, ControlsOf<Inputs>>, after: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
586
850
|
/** The decoded input when every key and row is valid as it stands; validates nothing. */
|
|
587
|
-
value: (model: FormModel<Fields, Members
|
|
851
|
+
value: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>> | undefined;
|
|
588
852
|
};
|
|
589
853
|
pipe<A>(this: A): A;
|
|
590
854
|
pipe<A, B = never>(this: A, ab: (_: A) => B): B;
|
|
@@ -610,7 +874,7 @@ declare const Core: {
|
|
|
610
874
|
pipe<A, B_20 = never, C_19 = never, D_18 = never, E_18 = never, F_16 = never, G_15 = never, H_14 = never, I_13 = never, J_12 = never, K_11 = never, L_10 = never, M_9 = never, N_8 = never, O_7 = never, P_6 = never, Q_5 = never, R_5 = never, S_3 = never, T_2 = never, U_1 = never>(this: A, ab: (_: A) => B_20, bc: (_: B_20) => C_19, cd: (_: C_19) => D_18, de: (_: D_18) => E_18, ef: (_: E_18) => F_16, fg: (_: F_16) => G_15, gh: (_: G_15) => H_14, hi: (_: H_14) => I_13, ij: (_: I_13) => J_12, jk: (_: J_12) => K_11, kl: (_: K_11) => L_10, lm: (_: L_10) => M_9, mn: (_: M_9) => N_8, no: (_: N_8) => O_7, op: (_: O_7) => P_6, pq: (_: P_6) => Q_5, qr: (_: Q_5) => R_5, rs: (_: R_5) => S_3, st: (_: S_3) => T_2, tu: (_: T_2) => U_1): U_1;
|
|
611
875
|
/** The name, input and options the form was made from: what a pipe step makes the next form from. */
|
|
612
876
|
name: Name;
|
|
613
|
-
options: FormOptions<Fields, Members, R, Nest>;
|
|
877
|
+
options: FormOptions<Fields, Members, R, Nest, Inputs>;
|
|
614
878
|
/** Type-only: the form's type parameters, for a pipe step to read. Never set. */
|
|
615
879
|
types: {
|
|
616
880
|
readonly Name: Name;
|
|
@@ -619,6 +883,7 @@ declare const Core: {
|
|
|
619
883
|
readonly Members: Members;
|
|
620
884
|
readonly R: R;
|
|
621
885
|
readonly Nest: Nest;
|
|
886
|
+
readonly Inputs: Inputs;
|
|
622
887
|
};
|
|
623
888
|
};
|
|
624
889
|
/**
|
|
@@ -643,6 +908,7 @@ interface FormTypes {
|
|
|
643
908
|
readonly Members: any;
|
|
644
909
|
readonly R: unknown;
|
|
645
910
|
readonly Nest: any;
|
|
911
|
+
readonly Inputs: any;
|
|
646
912
|
}
|
|
647
913
|
/** A form as a pipe step takes it: what it was made from, and its type parameters. */
|
|
648
914
|
interface Remakeable<T extends FormTypes = FormTypes> {
|
|
@@ -652,11 +918,19 @@ interface Remakeable<T extends FormTypes = FormTypes> {
|
|
|
652
918
|
readonly types: T;
|
|
653
919
|
}
|
|
654
920
|
/** The form `Form.make` gives for these type parameters. */
|
|
655
|
-
type Made<T extends FormTypes> = ReturnType<typeof Core.make<T['Name'], T['E'], T['Fields'], T['Members'], T['R'], T['Nest']>>;
|
|
921
|
+
type Made<T extends FormTypes> = ReturnType<typeof Core.make<T['Name'], T['E'], T['Fields'], T['Members'], T['R'], T['Nest'], T['Inputs']>>;
|
|
656
922
|
type OptionsOf<T extends FormTypes> = FormOptions<T['Fields'], T['Members'], T['R'], T['Nest']>;
|
|
657
923
|
export declare const Form: {
|
|
658
924
|
/** Controls by key, beside the ones the form already names. */
|
|
659
|
-
inputs: <F extends Remakeable
|
|
925
|
+
inputs: <F extends Remakeable, const I extends InputsFor<F["types"]["Fields"], F["types"]["Members"]>>(inputs: I) => (form: F) => [keyof ControlsOf<I>] extends [never] ? F : Made<{
|
|
926
|
+
readonly Name: F["types"]["Name"];
|
|
927
|
+
readonly E: F["types"]["E"];
|
|
928
|
+
readonly Fields: F["types"]["Fields"];
|
|
929
|
+
readonly Members: F["types"]["Members"];
|
|
930
|
+
readonly R: F["types"]["R"];
|
|
931
|
+
readonly Nest: F["types"]["Nest"];
|
|
932
|
+
readonly Inputs: Omit<F["types"]["Inputs"], keyof I> & I;
|
|
933
|
+
}>;
|
|
660
934
|
/** The form's words, beside the ones it already has. */
|
|
661
935
|
messages: <F extends Remakeable>(messages: NonNullable<OptionsOf<F["types"]>["messages"]>) => (form: F) => F;
|
|
662
936
|
/** How long a key rests before its check runs. */
|
|
@@ -672,6 +946,7 @@ export declare const Form: {
|
|
|
672
946
|
readonly Members: F["types"]["Members"];
|
|
673
947
|
readonly R: F["types"]["R"] | RequirementOf<C>;
|
|
674
948
|
readonly Nest: F["types"]["Nest"];
|
|
949
|
+
readonly Inputs: F["types"]["Inputs"];
|
|
675
950
|
}>;
|
|
676
951
|
/** The forms of nested keys, beside the ones the form was already given. */
|
|
677
952
|
nested: <F extends Remakeable, const N extends NestedForms<F["types"]["Fields"], F["types"]["Members"], F["types"]["R"]>>(forms: N) => (form: F) => Made<{
|
|
@@ -681,6 +956,7 @@ export declare const Form: {
|
|
|
681
956
|
readonly Members: F["types"]["Members"];
|
|
682
957
|
readonly R: F["types"]["R"];
|
|
683
958
|
readonly Nest: F["types"]["Nest"] & N;
|
|
959
|
+
readonly Inputs: F["types"]["Inputs"];
|
|
684
960
|
}>;
|
|
685
961
|
/**
|
|
686
962
|
* A form for one operation's input. A key mapped with `Relation.nested` holds
|
|
@@ -688,14 +964,16 @@ export declare const Form: {
|
|
|
688
964
|
* holds a draft. `options` names what the input cannot say: a control, the
|
|
689
965
|
* words, the checks.
|
|
690
966
|
*/
|
|
691
|
-
make: <const Name extends string, E extends AnyEntity, Fields extends Schema.Struct.Fields, Members extends { readonly [K in keyof Fields]: InputMember; }, R = never, const Nest extends NestedForms<Fields, Members, R> = {}>(name: Name, input: EntityInput<E, Fields, Members>, options?: FormOptions<Fields, Members, R, Nest>) => {
|
|
692
|
-
bundle: Bundle.Bundle<Name, void, FormModel<Fields, Members
|
|
967
|
+
make: <const Name extends string, E extends AnyEntity, Fields extends Schema.Struct.Fields, Members extends { readonly [K in keyof Fields]: InputMember; }, R = never, const Nest extends NestedForms<Fields, Members, R> = {}, const Inputs extends InputsFor<Fields, Members> = {}>(name: Name, input: EntityInput<E, Fields, Members>, options?: FormOptions<Fields, Members, R, Nest, Inputs>) => {
|
|
968
|
+
bundle: Bundle.Bundle<Name, void, FormModel<Fields, Members, ControlsOf<Inputs>>, {
|
|
693
969
|
readonly _tag: "Changed";
|
|
694
970
|
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
695
971
|
readonly value: string | boolean | readonly string[];
|
|
696
972
|
} | {
|
|
697
973
|
readonly _tag: "Blurred";
|
|
698
974
|
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
975
|
+
} | {
|
|
976
|
+
readonly _tag: "ValidatedAll";
|
|
699
977
|
} | {
|
|
700
978
|
readonly _tag: "Submitted";
|
|
701
979
|
} | {
|
|
@@ -723,6 +1001,10 @@ export declare const Form: {
|
|
|
723
1001
|
readonly key: string;
|
|
724
1002
|
readonly row: string;
|
|
725
1003
|
readonly message: unknown;
|
|
1004
|
+
} | {
|
|
1005
|
+
readonly _tag: "Control";
|
|
1006
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1007
|
+
readonly message: unknown;
|
|
726
1008
|
} | {
|
|
727
1009
|
readonly _tag: "RowAdded";
|
|
728
1010
|
readonly key: string;
|
|
@@ -730,27 +1012,33 @@ export declare const Form: {
|
|
|
730
1012
|
readonly _tag: "RowRemoved";
|
|
731
1013
|
readonly key: string;
|
|
732
1014
|
readonly row: string;
|
|
733
|
-
}, Submitted<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>, R, never, void,
|
|
734
|
-
fill: (model: FormModel<Fields, Members
|
|
735
|
-
readonly model: FormModel<Fields, Members
|
|
1015
|
+
}, Submitted<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>, R, never, void, ControlResourcesOf<Inputs>, {
|
|
1016
|
+
fill: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, values: Partial<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>) => {
|
|
1017
|
+
readonly model: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
736
1018
|
};
|
|
737
1019
|
}>;
|
|
738
1020
|
Message: import("foldkit/message").MessageUnion<{
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
1021
|
+
Changed: {
|
|
1022
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
1023
|
+
value: Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.$Array<Schema.String>]>;
|
|
742
1024
|
};
|
|
743
1025
|
/** Validates the key as it stands, so a required key left empty says so. */
|
|
744
|
-
|
|
745
|
-
|
|
1026
|
+
Blurred: {
|
|
1027
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
746
1028
|
};
|
|
747
|
-
|
|
748
|
-
|
|
1029
|
+
/**
|
|
1030
|
+
* Validates every key not validated yet, in every row too, as a submit
|
|
1031
|
+
* would, and submits nothing: for a page that submits several forms at once.
|
|
1032
|
+
* A rule spanning keys is said only by a submit.
|
|
1033
|
+
*/
|
|
1034
|
+
ValidatedAll: {};
|
|
1035
|
+
Submitted: {};
|
|
1036
|
+
Reset: {};
|
|
749
1037
|
/** The answer of a check for the draft it was asked about; one for an older draft is dropped. */
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
1038
|
+
Checked: {
|
|
1039
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
1040
|
+
draft: Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.$Array<Schema.String>]>;
|
|
1041
|
+
error: Schema.NullOr<Schema.String>;
|
|
754
1042
|
};
|
|
755
1043
|
/**
|
|
756
1044
|
* The outside world refused this key's value: a unique index, a rule only a
|
|
@@ -758,9 +1046,9 @@ export declare const Form: {
|
|
|
758
1046
|
* typed, until it is edited again. Unlike `Checked`, it answers no question
|
|
759
1047
|
* the form asked, so it lands whatever state the key is in.
|
|
760
1048
|
*/
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
1049
|
+
Refused: {
|
|
1050
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
1051
|
+
error: Schema.String;
|
|
764
1052
|
};
|
|
765
1053
|
/**
|
|
766
1054
|
* What the form is editing, for the checks that need to know: a post's own
|
|
@@ -768,40 +1056,49 @@ export declare const Form: {
|
|
|
768
1056
|
* It changes no draft and validates nothing; a form that creates something
|
|
769
1057
|
* never sends it. See `FormModel.subject`.
|
|
770
1058
|
*/
|
|
771
|
-
|
|
772
|
-
|
|
1059
|
+
About: {
|
|
1060
|
+
subject: Schema.$Record<Schema.String, Schema.String>;
|
|
773
1061
|
};
|
|
774
1062
|
/** What was typed to find a choice for a relation key. It changes no draft and validates nothing. */
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
1063
|
+
Searched: {
|
|
1064
|
+
key: Schema.Literals<readonly [Exclude<keyof Fields & string, NestedKey<Members>>, ...Exclude<keyof Fields & string, NestedKey<Members>>[]]>;
|
|
1065
|
+
text: Schema.String;
|
|
778
1066
|
};
|
|
779
1067
|
/** A Message of the nested form in one row of a nested key. One that row does not take is dropped. */
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
1068
|
+
Nested: {
|
|
1069
|
+
key: Schema.String;
|
|
1070
|
+
row: Schema.String;
|
|
1071
|
+
message: Schema.Unknown;
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* A Message of the control backed by a Bundle that edits `key`. One the
|
|
1075
|
+
* Bundle does not take is dropped. It is an edit when it changes the key's
|
|
1076
|
+
* value, and is then validated as `Changed` would be.
|
|
1077
|
+
*/
|
|
1078
|
+
Control: {
|
|
1079
|
+
key: Schema.Literals<readonly [keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>, ...(keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>)[]]>;
|
|
1080
|
+
message: Schema.Unknown;
|
|
784
1081
|
};
|
|
785
1082
|
/** A new, empty row. A `one` that already has its row takes no other. */
|
|
786
|
-
|
|
787
|
-
|
|
1083
|
+
RowAdded: {
|
|
1084
|
+
key: Schema.String;
|
|
788
1085
|
};
|
|
789
1086
|
/** Removes a row. A `one` that must be there stays. */
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1087
|
+
RowRemoved: {
|
|
1088
|
+
key: Schema.String;
|
|
1089
|
+
row: Schema.String;
|
|
793
1090
|
};
|
|
794
1091
|
}>;
|
|
795
1092
|
/** The reading the form was made from, for `Entity.selectFor` and `Entity.valuesFor`. */
|
|
796
1093
|
input: EntityInput<E, Fields, Members>;
|
|
797
1094
|
/** Whether a completed transition changed authored content. See the note above. */
|
|
798
|
-
authoredChanged: (before: FormModel<Fields, Members
|
|
1095
|
+
authoredChanged: (before: FormModel<Fields, Members, ControlsOf<Inputs>>, after: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
799
1096
|
/** The `fill` helper as a plain function of the form's Model, for a package that wraps the form. */
|
|
800
|
-
fill: (model: FormModel<Fields, Members
|
|
801
|
-
readonly model: FormModel<Fields, Members
|
|
1097
|
+
fill: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, values: Partial<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>) => {
|
|
1098
|
+
readonly model: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
802
1099
|
};
|
|
803
1100
|
/** The Model the form starts from and resets to: every key empty and not validated. */
|
|
804
|
-
initial: FormModel<Fields, Members
|
|
1101
|
+
initial: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
805
1102
|
/** The keys in the input's order, each with its control, label, and member. */
|
|
806
1103
|
controls: FormControl<keyof Fields & string>[];
|
|
807
1104
|
/**
|
|
@@ -809,11 +1106,67 @@ export declare const Form: {
|
|
|
809
1106
|
* `controls`. `model.fields.title` is the same value, typed to that key. A
|
|
810
1107
|
* nested key has rows and no draft.
|
|
811
1108
|
*/
|
|
812
|
-
field: (model: FormModel<Fields, Members
|
|
1109
|
+
field: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, key: Exclude<Exclude<keyof Fields & string, NestedKey<Members>>, keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>>) => FieldValidation.Field<Draft>;
|
|
1110
|
+
/**
|
|
1111
|
+
* The key edited by a control backed by a Bundle, addressed: `field` is its
|
|
1112
|
+
* state with the Bundle's Model as its value, and `send` gives the form's
|
|
1113
|
+
* Message for one of the Bundle's own.
|
|
1114
|
+
*/
|
|
1115
|
+
control: <K extends keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>>(key: K) => {
|
|
1116
|
+
readonly field: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => { readonly [K_1 in keyof Fields as K_1 extends NestedKey<Members> ? never : K_1]: FieldValidation.Field<K_1 extends keyof ControlsOf<Inputs> ? ControlsOf<Inputs>[K_1] : DraftOf<Schema.Schema.Type<Fields[K_1]>>>; }[K];
|
|
1117
|
+
readonly send: (message: ControlMessageOf<Inputs[K]>) => {
|
|
1118
|
+
readonly _tag: "Changed";
|
|
1119
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1120
|
+
readonly value: string | boolean | readonly string[];
|
|
1121
|
+
} | {
|
|
1122
|
+
readonly _tag: "Blurred";
|
|
1123
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1124
|
+
} | {
|
|
1125
|
+
readonly _tag: "ValidatedAll";
|
|
1126
|
+
} | {
|
|
1127
|
+
readonly _tag: "Submitted";
|
|
1128
|
+
} | {
|
|
1129
|
+
readonly _tag: "Reset";
|
|
1130
|
+
} | {
|
|
1131
|
+
readonly _tag: "Checked";
|
|
1132
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1133
|
+
readonly draft: string | boolean | readonly string[];
|
|
1134
|
+
readonly error: string | null;
|
|
1135
|
+
} | {
|
|
1136
|
+
readonly _tag: "Refused";
|
|
1137
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1138
|
+
readonly error: string;
|
|
1139
|
+
} | {
|
|
1140
|
+
readonly _tag: "About";
|
|
1141
|
+
readonly subject: {
|
|
1142
|
+
readonly [x: string]: string;
|
|
1143
|
+
};
|
|
1144
|
+
} | {
|
|
1145
|
+
readonly _tag: "Searched";
|
|
1146
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1147
|
+
readonly text: string;
|
|
1148
|
+
} | {
|
|
1149
|
+
readonly _tag: "Nested";
|
|
1150
|
+
readonly key: string;
|
|
1151
|
+
readonly row: string;
|
|
1152
|
+
readonly message: unknown;
|
|
1153
|
+
} | {
|
|
1154
|
+
readonly _tag: "Control";
|
|
1155
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1156
|
+
readonly message: unknown;
|
|
1157
|
+
} | {
|
|
1158
|
+
readonly _tag: "RowAdded";
|
|
1159
|
+
readonly key: string;
|
|
1160
|
+
} | {
|
|
1161
|
+
readonly _tag: "RowRemoved";
|
|
1162
|
+
readonly key: string;
|
|
1163
|
+
readonly row: string;
|
|
1164
|
+
};
|
|
1165
|
+
};
|
|
813
1166
|
/** What was typed to find a choice for a relation key that searches; `''` until something is. */
|
|
814
|
-
search: (model: FormModel<Fields, Members
|
|
1167
|
+
search: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, key: Exclude<keyof Fields & string, NestedKey<Members>>) => string;
|
|
815
1168
|
/** What the form is editing; `{}` while it creates. See `FormModel.subject`. */
|
|
816
|
-
subject: (model: FormModel<Fields, Members
|
|
1169
|
+
subject: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => Readonly<Record<string, string>>;
|
|
817
1170
|
/**
|
|
818
1171
|
* The form of each nested key, typed when it was given under `nested`: its
|
|
819
1172
|
* `controls`, its `field`, its Messages.
|
|
@@ -830,6 +1183,8 @@ export declare const Form: {
|
|
|
830
1183
|
} | {
|
|
831
1184
|
readonly _tag: "Blurred";
|
|
832
1185
|
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1186
|
+
} | {
|
|
1187
|
+
readonly _tag: "ValidatedAll";
|
|
833
1188
|
} | {
|
|
834
1189
|
readonly _tag: "Submitted";
|
|
835
1190
|
} | {
|
|
@@ -857,6 +1212,10 @@ export declare const Form: {
|
|
|
857
1212
|
readonly key: string;
|
|
858
1213
|
readonly row: string;
|
|
859
1214
|
readonly message: unknown;
|
|
1215
|
+
} | {
|
|
1216
|
+
readonly _tag: "Control";
|
|
1217
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1218
|
+
readonly message: unknown;
|
|
860
1219
|
} | {
|
|
861
1220
|
readonly _tag: "RowAdded";
|
|
862
1221
|
readonly key: string;
|
|
@@ -869,30 +1228,44 @@ export declare const Form: {
|
|
|
869
1228
|
* Whether a key that follows another still does: `false` once the author has
|
|
870
1229
|
* written it themselves. A view offers "regenerate" by sending the key an empty draft.
|
|
871
1230
|
*/
|
|
872
|
-
isFollowing: (model: FormModel<Fields, Members
|
|
1231
|
+
isFollowing: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, key: Exclude<keyof Fields & string, NestedKey<Members>>) => boolean;
|
|
873
1232
|
/** The rows of a nested key, each a Model of `control.form`. */
|
|
874
|
-
rows: (model: FormModel<Fields, Members
|
|
1233
|
+
rows: (model: FormModel<Fields, Members, ControlsOf<Inputs>>, key: Extract<keyof Fields & string, NestedKey<Members>>) => { readonly [K in keyof Fields as K extends NestedKey<Members> ? K : never]: readonly FormRow<NestedModel<Members[K & keyof Members]>>[]; }[Extract<keyof Fields & string, NestedKey<Members>>];
|
|
875
1234
|
/**
|
|
876
1235
|
* Whether a submit now could go through: nothing is invalid. A check still
|
|
877
1236
|
* running does not stop it; the submit waits for the answer.
|
|
878
1237
|
*/
|
|
879
|
-
canSubmit: (model: FormModel<Fields, Members
|
|
1238
|
+
canSubmit: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
1239
|
+
/**
|
|
1240
|
+
* Whether the form is valid right now: a submit now would hand over the
|
|
1241
|
+
* value at once. Unlike `canSubmit`, a check running, or one a key has not
|
|
1242
|
+
* had yet, is not valid until it answers.
|
|
1243
|
+
*/
|
|
1244
|
+
isValid: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
1245
|
+
/**
|
|
1246
|
+
* The decoded input as `Some` only when every key and row is valid as the
|
|
1247
|
+
* form stands; `None` otherwise. Unlike `partial`, it is all or nothing,
|
|
1248
|
+
* so a parent that submits several forms can read one complete value per
|
|
1249
|
+
* form. It validates nothing: reveal drafts first (a submit, or
|
|
1250
|
+
* `Message.ValidatedAll()`), or read after one did.
|
|
1251
|
+
*/
|
|
1252
|
+
value: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => Option.Option<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>;
|
|
880
1253
|
/**
|
|
881
1254
|
* The Model with nothing in flight, for one that was stored and is shown
|
|
882
1255
|
* again: a check that was running when it was stored will never answer, so
|
|
883
1256
|
* its key is not validated yet, and no submit is waiting. Rows too.
|
|
884
1257
|
*/
|
|
885
|
-
settled: (model: FormModel<Fields, Members
|
|
1258
|
+
settled: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
886
1259
|
/**
|
|
887
1260
|
* What of the form decodes as it stands, by key: the value, less every key
|
|
888
1261
|
* that is not valid yet. For saving unfinished work, which `engine.value`
|
|
889
1262
|
* cannot give. A nested key is there once each of its rows has a value.
|
|
890
1263
|
*/
|
|
891
|
-
partial: (model: FormModel<Fields, Members
|
|
1264
|
+
partial: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => Partial<Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>>>;
|
|
892
1265
|
/** The form as the form that nests it drives it. */
|
|
893
1266
|
engine: {
|
|
894
|
-
submit: (model: FormModel<Fields, Members
|
|
895
|
-
model: FormModel<Fields, Members
|
|
1267
|
+
submit: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => {
|
|
1268
|
+
model: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
896
1269
|
commands: readonly Readonly<{
|
|
897
1270
|
name: string;
|
|
898
1271
|
args?: Record<string, unknown>;
|
|
@@ -904,6 +1277,64 @@ export declare const Form: {
|
|
|
904
1277
|
} | {
|
|
905
1278
|
readonly _tag: "Blurred";
|
|
906
1279
|
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1280
|
+
} | {
|
|
1281
|
+
readonly _tag: "ValidatedAll";
|
|
1282
|
+
} | {
|
|
1283
|
+
readonly _tag: "Submitted";
|
|
1284
|
+
} | {
|
|
1285
|
+
readonly _tag: "Reset";
|
|
1286
|
+
} | {
|
|
1287
|
+
readonly _tag: "Checked";
|
|
1288
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1289
|
+
readonly draft: string | boolean | readonly string[];
|
|
1290
|
+
readonly error: string | null;
|
|
1291
|
+
} | {
|
|
1292
|
+
readonly _tag: "Refused";
|
|
1293
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1294
|
+
readonly error: string;
|
|
1295
|
+
} | {
|
|
1296
|
+
readonly _tag: "About";
|
|
1297
|
+
readonly subject: {
|
|
1298
|
+
readonly [x: string]: string;
|
|
1299
|
+
};
|
|
1300
|
+
} | {
|
|
1301
|
+
readonly _tag: "Searched";
|
|
1302
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1303
|
+
readonly text: string;
|
|
1304
|
+
} | {
|
|
1305
|
+
readonly _tag: "Nested";
|
|
1306
|
+
readonly key: string;
|
|
1307
|
+
readonly row: string;
|
|
1308
|
+
readonly message: unknown;
|
|
1309
|
+
} | {
|
|
1310
|
+
readonly _tag: "Control";
|
|
1311
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1312
|
+
readonly message: unknown;
|
|
1313
|
+
} | {
|
|
1314
|
+
readonly _tag: "RowAdded";
|
|
1315
|
+
readonly key: string;
|
|
1316
|
+
} | {
|
|
1317
|
+
readonly _tag: "RowRemoved";
|
|
1318
|
+
readonly key: string;
|
|
1319
|
+
readonly row: string;
|
|
1320
|
+
}, never, R>;
|
|
1321
|
+
}>[];
|
|
1322
|
+
};
|
|
1323
|
+
validateAll: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => {
|
|
1324
|
+
readonly model: FormModel<Fields, Members, ControlsOf<Inputs>>;
|
|
1325
|
+
readonly commands: readonly Readonly<{
|
|
1326
|
+
name: string;
|
|
1327
|
+
args?: Record<string, unknown>;
|
|
1328
|
+
key?: string;
|
|
1329
|
+
effect: Effect.Effect<{
|
|
1330
|
+
readonly _tag: "Changed";
|
|
1331
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1332
|
+
readonly value: string | boolean | readonly string[];
|
|
1333
|
+
} | {
|
|
1334
|
+
readonly _tag: "Blurred";
|
|
1335
|
+
readonly key: Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1336
|
+
} | {
|
|
1337
|
+
readonly _tag: "ValidatedAll";
|
|
907
1338
|
} | {
|
|
908
1339
|
readonly _tag: "Submitted";
|
|
909
1340
|
} | {
|
|
@@ -931,6 +1362,10 @@ export declare const Form: {
|
|
|
931
1362
|
readonly key: string;
|
|
932
1363
|
readonly row: string;
|
|
933
1364
|
readonly message: unknown;
|
|
1365
|
+
} | {
|
|
1366
|
+
readonly _tag: "Control";
|
|
1367
|
+
readonly key: keyof ControlsOf<Inputs> & Exclude<keyof Fields & string, NestedKey<Members>>;
|
|
1368
|
+
readonly message: unknown;
|
|
934
1369
|
} | {
|
|
935
1370
|
readonly _tag: "RowAdded";
|
|
936
1371
|
readonly key: string;
|
|
@@ -941,11 +1376,11 @@ export declare const Form: {
|
|
|
941
1376
|
}, never, R>;
|
|
942
1377
|
}>[];
|
|
943
1378
|
};
|
|
944
|
-
isValidating: (model: FormModel<Fields, Members
|
|
1379
|
+
isValidating: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
945
1380
|
/** Whether a transition changed authored content, so a nesting form recurses. */
|
|
946
|
-
authoredChanged: (before: FormModel<Fields, Members
|
|
1381
|
+
authoredChanged: (before: FormModel<Fields, Members, ControlsOf<Inputs>>, after: FormModel<Fields, Members, ControlsOf<Inputs>>) => boolean;
|
|
947
1382
|
/** The decoded input when every key and row is valid as it stands; validates nothing. */
|
|
948
|
-
value: (model: FormModel<Fields, Members
|
|
1383
|
+
value: (model: FormModel<Fields, Members, ControlsOf<Inputs>>) => Schema.Struct.View<Fields, "Type", Schema.Struct.TypeOptionalKeys<Fields>, Schema.Struct.TypeMutableKeys<Fields>> | undefined;
|
|
949
1384
|
};
|
|
950
1385
|
pipe<A>(this: A): A;
|
|
951
1386
|
pipe<A, B = never>(this: A, ab: (_: A) => B): B;
|
|
@@ -971,7 +1406,7 @@ export declare const Form: {
|
|
|
971
1406
|
pipe<A, B_20 = never, C_19 = never, D_18 = never, E_18 = never, F_16 = never, G_15 = never, H_14 = never, I_13 = never, J_12 = never, K_11 = never, L_10 = never, M_9 = never, N_8 = never, O_7 = never, P_6 = never, Q_5 = never, R_5 = never, S_3 = never, T_2 = never, U_1 = never>(this: A, ab: (_: A) => B_20, bc: (_: B_20) => C_19, cd: (_: C_19) => D_18, de: (_: D_18) => E_18, ef: (_: E_18) => F_16, fg: (_: F_16) => G_15, gh: (_: G_15) => H_14, hi: (_: H_14) => I_13, ij: (_: I_13) => J_12, jk: (_: J_12) => K_11, kl: (_: K_11) => L_10, lm: (_: L_10) => M_9, mn: (_: M_9) => N_8, no: (_: N_8) => O_7, op: (_: O_7) => P_6, pq: (_: P_6) => Q_5, qr: (_: Q_5) => R_5, rs: (_: R_5) => S_3, st: (_: S_3) => T_2, tu: (_: T_2) => U_1): U_1;
|
|
972
1407
|
/** The name, input and options the form was made from: what a pipe step makes the next form from. */
|
|
973
1408
|
name: Name;
|
|
974
|
-
options: FormOptions<Fields, Members, R, Nest>;
|
|
1409
|
+
options: FormOptions<Fields, Members, R, Nest, Inputs>;
|
|
975
1410
|
/** Type-only: the form's type parameters, for a pipe step to read. Never set. */
|
|
976
1411
|
types: {
|
|
977
1412
|
readonly Name: Name;
|
|
@@ -980,6 +1415,7 @@ export declare const Form: {
|
|
|
980
1415
|
readonly Members: Members;
|
|
981
1416
|
readonly R: R;
|
|
982
1417
|
readonly Nest: Nest;
|
|
1418
|
+
readonly Inputs: Inputs;
|
|
983
1419
|
};
|
|
984
1420
|
};
|
|
985
1421
|
/**
|
|
@@ -997,5 +1433,5 @@ export declare const Form: {
|
|
|
997
1433
|
}) => string | undefined;
|
|
998
1434
|
};
|
|
999
1435
|
//#endregion
|
|
1000
|
-
export type { Control, ControlChange, ControlKind, Draft, DraftKind, Follows, FormRow, NestedData, NestedForm, RelationData };
|
|
1436
|
+
export type { BundleControl, BundleControlSpec, BundleData, Control, ControlChange, ControlKind, Draft, DraftKind, Follows, FormRow, NestedData, NestedForm, RelationData };
|
|
1001
1437
|
//# sourceMappingURL=index.d.mts.map
|