foldkit-mixins-form 0.13.0 → 0.14.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 +227 -19
- package/dist/index.d.mts +30 -24
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/recipes.d.mts +2 -2
- package/dist/recipes.d.mts.map +1 -1
- package/dist/recipes.mjs +5 -5
- package/dist/recipes.mjs.map +1 -1
- package/dist/{src-CwD995oQ.mjs → src-DKt2l7dw.mjs} +18 -13
- package/dist/src-DKt2l7dw.mjs.map +1 -0
- package/dist/ui.mjs +1 -1
- package/package.json +7 -7
- package/dist/src-CwD995oQ.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -55,6 +55,49 @@ pnpm add effect foldkit foldkit-bundle foldkit-form foldkit-mixins foldkit-mixin
|
|
|
55
55
|
Given `Edit`, a `Form.make` result from the
|
|
56
56
|
[Form example](../form/README.md#example), the default rendering path is:
|
|
57
57
|
|
|
58
|
+
<!-- docs-check standalone
|
|
59
|
+
import { Schema } from 'effect'
|
|
60
|
+
import { Entity, Relation } from 'foldkit-entity'
|
|
61
|
+
import { Form as FormKit, Input } from 'foldkit-form'
|
|
62
|
+
|
|
63
|
+
const Author = Entity.define('Author', Schema.Struct({ id: Schema.String, name: Schema.String }))
|
|
64
|
+
const Tag = Entity.define('Tag', Schema.Struct({ id: Schema.String, name: Schema.String }))
|
|
65
|
+
const Post = Entity.define(
|
|
66
|
+
'Post',
|
|
67
|
+
Schema.Struct({
|
|
68
|
+
id: Schema.String,
|
|
69
|
+
title: Schema.String.check(Schema.isMinLength(1)).annotate({ title: 'Title' }),
|
|
70
|
+
body: Schema.String,
|
|
71
|
+
status: Schema.Literals(['draft', 'live']),
|
|
72
|
+
featured: Schema.Boolean,
|
|
73
|
+
}),
|
|
74
|
+
)
|
|
75
|
+
const Blog = Entity.relate(
|
|
76
|
+
{ Author, Tag, Post },
|
|
77
|
+
{ Post: { editor: Relation.one(Author, { optional: true }), tags: Relation.many(Tag) } },
|
|
78
|
+
)
|
|
79
|
+
const Edit = FormKit.make(
|
|
80
|
+
'Edit',
|
|
81
|
+
Entity.input(
|
|
82
|
+
Blog.Post,
|
|
83
|
+
Schema.Struct({
|
|
84
|
+
id: Schema.String,
|
|
85
|
+
title: Blog.Post.fields.title.schema,
|
|
86
|
+
body: Schema.optional(Schema.String),
|
|
87
|
+
status: Schema.Literals(['draft', 'live']),
|
|
88
|
+
featured: Schema.Boolean,
|
|
89
|
+
editorId: Schema.NullOr(Schema.String),
|
|
90
|
+
tagIds: Schema.Array(Schema.String),
|
|
91
|
+
}),
|
|
92
|
+
{
|
|
93
|
+
editorId: Relation.input(Blog.Post.relations.editor),
|
|
94
|
+
tagIds: Relation.input(Blog.Post.relations.tags),
|
|
95
|
+
},
|
|
96
|
+
),
|
|
97
|
+
{ inputs: { id: Input.hidden() } },
|
|
98
|
+
)
|
|
99
|
+
-->
|
|
100
|
+
|
|
58
101
|
```ts
|
|
59
102
|
import { Bundle } from 'foldkit-bundle'
|
|
60
103
|
import { FormView } from 'foldkit-mixins-form'
|
|
@@ -155,19 +198,63 @@ provide another override.
|
|
|
155
198
|
Use the override with `Fields.field` for a custom layout or the per-key
|
|
156
199
|
`overrides` table for `Fields.view`. Submit buttons in a custom layout use
|
|
157
200
|
`Button.view` from `foldkit-mixins-ui`; the form still owns submission and the
|
|
158
|
-
parent owns any request. The generated view retains its
|
|
201
|
+
parent owns any request. The generated view retains its submit button, drawn
|
|
202
|
+
`aria-disabled` while the form cannot submit (see below).
|
|
159
203
|
|
|
160
204
|
The [waitlist](../../examples/foldkit/form/src/main.ts) and
|
|
161
205
|
[login](../../examples/foldkit/auth/src/page/loggedOut/page/login.ts) are real
|
|
162
206
|
custom-layout adopters. The [UI integration tests](test/ui.test.ts) demonstrate
|
|
163
|
-
the generated view with UI field overrides through a Submodel and a
|
|
164
|
-
`FormView.submodel(..., { canSubmit: form.isValid })`
|
|
207
|
+
the generated view with UI field overrides through a Submodel and a
|
|
208
|
+
`FormView.submodel(..., { canSubmit: form.isValid })` marking.
|
|
165
209
|
|
|
166
210
|
## Example
|
|
167
211
|
|
|
168
212
|
`Edit` is a `Form.make` result, as in the
|
|
169
213
|
[`foldkit-form` README](../form/README.md#example).
|
|
170
214
|
|
|
215
|
+
<!-- docs-check standalone
|
|
216
|
+
import { Schema } from 'effect'
|
|
217
|
+
import { Entity, Relation } from 'foldkit-entity'
|
|
218
|
+
import { Form as FormKit, Input } from 'foldkit-form'
|
|
219
|
+
|
|
220
|
+
const Author = Entity.define('Author', Schema.Struct({ id: Schema.String, name: Schema.String }))
|
|
221
|
+
const Tag = Entity.define('Tag', Schema.Struct({ id: Schema.String, name: Schema.String }))
|
|
222
|
+
const Post = Entity.define(
|
|
223
|
+
'Post',
|
|
224
|
+
Schema.Struct({
|
|
225
|
+
id: Schema.String,
|
|
226
|
+
title: Schema.String.check(Schema.isMinLength(1)).annotate({ title: 'Title' }),
|
|
227
|
+
body: Schema.String,
|
|
228
|
+
status: Schema.Literals(['draft', 'live']),
|
|
229
|
+
featured: Schema.Boolean,
|
|
230
|
+
}),
|
|
231
|
+
)
|
|
232
|
+
const Blog = Entity.relate(
|
|
233
|
+
{ Author, Tag, Post },
|
|
234
|
+
{ Post: { editor: Relation.one(Author, { optional: true }), tags: Relation.many(Tag) } },
|
|
235
|
+
)
|
|
236
|
+
const Edit = FormKit.make(
|
|
237
|
+
'Edit',
|
|
238
|
+
Entity.input(
|
|
239
|
+
Blog.Post,
|
|
240
|
+
Schema.Struct({
|
|
241
|
+
id: Schema.String,
|
|
242
|
+
title: Blog.Post.fields.title.schema,
|
|
243
|
+
body: Schema.optional(Schema.String),
|
|
244
|
+
status: Schema.Literals(['draft', 'live']),
|
|
245
|
+
featured: Schema.Boolean,
|
|
246
|
+
editorId: Schema.NullOr(Schema.String),
|
|
247
|
+
tagIds: Schema.Array(Schema.String),
|
|
248
|
+
}),
|
|
249
|
+
{
|
|
250
|
+
editorId: Relation.input(Blog.Post.relations.editor),
|
|
251
|
+
tagIds: Relation.input(Blog.Post.relations.tags),
|
|
252
|
+
},
|
|
253
|
+
),
|
|
254
|
+
{ inputs: { id: Input.hidden() } },
|
|
255
|
+
)
|
|
256
|
+
-->
|
|
257
|
+
|
|
171
258
|
```ts
|
|
172
259
|
import { Bundle } from 'foldkit-bundle'
|
|
173
260
|
import { Style } from 'foldkit-mixins'
|
|
@@ -194,7 +281,7 @@ In the following integration fragment, `EditForm` is the placement of `Drawn`,
|
|
|
194
281
|
`model` and `h` are the parent view arguments, and `authors` is the loaded picker
|
|
195
282
|
data. Where the parent draws the placement:
|
|
196
283
|
|
|
197
|
-
```ts
|
|
284
|
+
```ts sketch
|
|
198
285
|
EditForm.view(model, h, {
|
|
199
286
|
options: { editorId: authors.map(author => ({ value: author.id, label: author.name })) },
|
|
200
287
|
words: { submit: 'Save' },
|
|
@@ -238,7 +325,8 @@ and naming the picker it controls with `aria-controls`. `words.search` in the
|
|
|
238
325
|
view inputs replaces the word. The blank choice of a `select` has no words
|
|
239
326
|
unless `words.none` gives it some ("none"). A picker of the form itself that
|
|
240
327
|
the view inputs' `more` names (`more: { authorId: true }`, which
|
|
241
|
-
`foldkit-crud`'s `Crud.options` gives as `pickers.more(model)
|
|
328
|
+
`foldkit-crud`'s `Crud.options` gives as `pickers.more(model)`; another key is
|
|
329
|
+
a type error, and a form with no picker takes no `more`) gets a
|
|
242
330
|
`button type="button"` under it, in the `more` slot, worded by `words.more`
|
|
243
331
|
(default `Show more`) and naming the picker with `aria-controls`; a press sends
|
|
244
332
|
the form's `AskedForMore({ key })`, for the page that owns the list to answer.
|
|
@@ -258,6 +346,40 @@ The table above is a set of renderers found by a control's `kind`, and the
|
|
|
258
346
|
shipped ones are entries like any other. Add a kind of your own, or draw a
|
|
259
347
|
shipped one another way, by passing renderers beside them:
|
|
260
348
|
|
|
349
|
+
<!-- docs-check standalone
|
|
350
|
+
import { Schema } from 'effect'
|
|
351
|
+
import { Entity } from 'foldkit-entity'
|
|
352
|
+
import { Form, Input } from 'foldkit-form'
|
|
353
|
+
import { Style, SlotView } from 'foldkit-mixins'
|
|
354
|
+
import { FieldSlots, FormView, type Renderer } from 'foldkit-mixins-form'
|
|
355
|
+
|
|
356
|
+
const Cents = Input.kind<{ readonly currency: string }>('Cents', { draft: 'text' })
|
|
357
|
+
const Priced = Entity.define(
|
|
358
|
+
'Priced',
|
|
359
|
+
Schema.Struct({
|
|
360
|
+
id: Schema.String,
|
|
361
|
+
cents: Schema.Number,
|
|
362
|
+
code: Schema.String,
|
|
363
|
+
total: Schema.String,
|
|
364
|
+
email: Schema.String,
|
|
365
|
+
}),
|
|
366
|
+
)
|
|
367
|
+
const PriceForm = Form.make(
|
|
368
|
+
'Price',
|
|
369
|
+
Entity.input(
|
|
370
|
+
Priced,
|
|
371
|
+
Schema.Struct({
|
|
372
|
+
cents: Schema.Number,
|
|
373
|
+
code: Schema.String,
|
|
374
|
+
total: Schema.String,
|
|
375
|
+
email: Schema.String,
|
|
376
|
+
}),
|
|
377
|
+
),
|
|
378
|
+
{ inputs: { cents: Cents.of({ currency: 'USD' }) } },
|
|
379
|
+
)
|
|
380
|
+
declare const myCombobox: Renderer<{ readonly _tag: string }>
|
|
381
|
+
-->
|
|
382
|
+
|
|
261
383
|
```ts
|
|
262
384
|
FormView.define(PriceForm, {
|
|
263
385
|
renderers: {
|
|
@@ -285,6 +407,9 @@ no renderer throws when it is drawn, naming the kind and the key.
|
|
|
285
407
|
control for a layout the caller owns:
|
|
286
408
|
|
|
287
409
|
```ts
|
|
410
|
+
import { Style } from 'foldkit-mixins'
|
|
411
|
+
import { FieldSlots } from 'foldkit-mixins-form'
|
|
412
|
+
|
|
288
413
|
const Fields = FormView.fields(PriceForm, {
|
|
289
414
|
overrides: {
|
|
290
415
|
// Drawn through the whole-form view, in the form's own universe.
|
|
@@ -307,6 +432,12 @@ known kind needs nothing new; unknown keys in every map are type errors.
|
|
|
307
432
|
`Fields.view` is the whole form. `Fields.field(control, model, id, h)` draws
|
|
308
433
|
one flat key for a custom layout, or with the override it is given, in any `h`:
|
|
309
434
|
|
|
435
|
+
<!-- docs-check
|
|
436
|
+
const control = PriceForm.controls[0]!
|
|
437
|
+
const formModel = PriceForm.initial
|
|
438
|
+
const h = SlotView.inertBuilder<typeof PriceForm.Message.Type>()
|
|
439
|
+
-->
|
|
440
|
+
|
|
310
441
|
```ts
|
|
311
442
|
Fields.field(control, formModel, control.key, h, (input, draw) =>
|
|
312
443
|
draw.input([draw.Id(input.id), draw.Value(String(input.field.value))]),
|
|
@@ -404,11 +535,10 @@ write in flight, which ignores it. Busy ends when the write is
|
|
|
404
535
|
answered: a list refreshed after it shows that through its own `Refreshing`.
|
|
405
536
|
|
|
406
537
|
A write that landed may leave the form unable to submit: a create's form
|
|
407
|
-
starts again blank
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
form lacks. `foldkit-crud`'s editor passes it.
|
|
538
|
+
starts again blank. Its button reads `aria-disabled`, as it does whenever the
|
|
539
|
+
form cannot submit, so it keeps the focus a press gave it, and a press shows
|
|
540
|
+
what the blank form lacks. The view input `saved`, which once chose between
|
|
541
|
+
`disabled` and `aria-disabled`, has no effect any more and is deprecated.
|
|
412
542
|
|
|
413
543
|
When the write did not land, the view input `failure` (`{ error, retry }`) says
|
|
414
544
|
why, in the `failure` slot (`role="alert"`, above the submit button): a refusal
|
|
@@ -418,21 +548,99 @@ button reads `words.resubmit` (default `Try again`), for a page whose next
|
|
|
418
548
|
submit sends the same write again; the editor's does, through Remote's retry.
|
|
419
549
|
Where `writing` is the request id the page kept:
|
|
420
550
|
|
|
421
|
-
```ts
|
|
551
|
+
```ts sketch
|
|
422
552
|
EditForm.view(model, h, {
|
|
423
553
|
submitting: Option.exists(model.writing, id => Data.mutation(model, id)._tag === 'Pending'),
|
|
424
554
|
words: { submit: 'Save', submitting: 'Saving…', resubmit: 'Save again' },
|
|
425
555
|
})
|
|
426
556
|
```
|
|
427
557
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
`form.canSubmit
|
|
431
|
-
|
|
432
|
-
`(
|
|
558
|
+
A submit made while a check runs waits for the answer by default, rather than
|
|
559
|
+
being refused, and the button stays unmarked meanwhile. That leniency is the
|
|
560
|
+
form's, in `update`; `form.canSubmit` reads it. A page that wants a submit
|
|
561
|
+
refused until every check answers makes the form with `submitWaits: false`
|
|
562
|
+
(`Form.make(…, { submitWaits: false })`): `update` then hands out nothing while
|
|
563
|
+
a check runs, and `form.canSubmit`, which `FormView.submodel` reads by default,
|
|
564
|
+
is false until the answers land, so the button reads `aria-disabled` to match.
|
|
565
|
+
A checked key never checked yet (a form filled from an existing record) is
|
|
566
|
+
such a check: the first submit starts it and is refused, and the reader
|
|
567
|
+
submits again after the answer.
|
|
568
|
+
`FormView.submodel`'s `canSubmit` option only chooses when the button is marked
|
|
569
|
+
(`() => true` never marks it, and validates wholly at submit); it cannot make
|
|
570
|
+
a submit be refused or accepted, so the drawn frame is never what decides.
|
|
571
|
+
|
|
572
|
+
The generated button is never natively `disabled`: it reads `aria-disabled`
|
|
573
|
+
while the form cannot submit or is submitting, so Enter in a field always
|
|
574
|
+
submits through it and the browser has no say. Natively disabled, it dropped
|
|
575
|
+
an Enter sent in the same frame as the edit that made the form valid (a paste
|
|
576
|
+
or an autofill and Enter), before the frame that enabled it, with no word. The
|
|
577
|
+
decision is `update`'s, from the Model: `Submitted` validates every key, so a
|
|
578
|
+
submit the form cannot take marks each missing key invalid and shows why (the
|
|
579
|
+
fields to fix, the errors), hands out nothing, and one the Model can take
|
|
580
|
+
goes through. A press of the button does the same. The button looks disabled
|
|
581
|
+
through the `disabled` treatment of the recipes, which reads
|
|
582
|
+
`[aria-disabled="true"]`, and a screen reader hears it disabled. A style of
|
|
583
|
+
your own on the `submit` Slot must match `[aria-disabled="true"]` as well as
|
|
584
|
+
`:disabled`, and keep it out of its hover and press rules. Moving focus
|
|
585
|
+
to the first missing key is the page's, as the waitlist's `FocusField` does:
|
|
586
|
+
without it a repeated refused press changes nothing a person can perceive once
|
|
587
|
+
the errors are shown. A
|
|
588
|
+
custom submit drawn with `Button.view` is likewise only `aria-disabled`, so a
|
|
589
|
+
strict page also refuses a `Submitted` in
|
|
590
|
+
`update` while a check runs: the
|
|
591
|
+
[waitlist](../../examples/foldkit/form/src/main.ts) does, and its browser
|
|
592
|
+
test presses Enter and the button during a check.
|
|
593
|
+
|
|
594
|
+
<!-- docs-check standalone
|
|
595
|
+
import { Schema } from 'effect'
|
|
596
|
+
import { Entity, Relation } from 'foldkit-entity'
|
|
597
|
+
import { Form as FormKit, Input } from 'foldkit-form'
|
|
598
|
+
|
|
599
|
+
const Author = Entity.define('Author', Schema.Struct({ id: Schema.String, name: Schema.String }))
|
|
600
|
+
const Tag = Entity.define('Tag', Schema.Struct({ id: Schema.String, name: Schema.String }))
|
|
601
|
+
const Post = Entity.define(
|
|
602
|
+
'Post',
|
|
603
|
+
Schema.Struct({
|
|
604
|
+
id: Schema.String,
|
|
605
|
+
title: Schema.String.check(Schema.isMinLength(1)).annotate({ title: 'Title' }),
|
|
606
|
+
body: Schema.String,
|
|
607
|
+
status: Schema.Literals(['draft', 'live']),
|
|
608
|
+
featured: Schema.Boolean,
|
|
609
|
+
}),
|
|
610
|
+
)
|
|
611
|
+
const Blog = Entity.relate(
|
|
612
|
+
{ Author, Tag, Post },
|
|
613
|
+
{ Post: { editor: Relation.one(Author, { optional: true }), tags: Relation.many(Tag) } },
|
|
614
|
+
)
|
|
615
|
+
const Edit = FormKit.make(
|
|
616
|
+
'Edit',
|
|
617
|
+
Entity.input(
|
|
618
|
+
Blog.Post,
|
|
619
|
+
Schema.Struct({
|
|
620
|
+
id: Schema.String,
|
|
621
|
+
title: Blog.Post.fields.title.schema,
|
|
622
|
+
body: Schema.optional(Schema.String),
|
|
623
|
+
status: Schema.Literals(['draft', 'live']),
|
|
624
|
+
featured: Schema.Boolean,
|
|
625
|
+
editorId: Schema.NullOr(Schema.String),
|
|
626
|
+
tagIds: Schema.Array(Schema.String),
|
|
627
|
+
}),
|
|
628
|
+
{
|
|
629
|
+
editorId: Relation.input(Blog.Post.relations.editor),
|
|
630
|
+
tagIds: Relation.input(Blog.Post.relations.tags),
|
|
631
|
+
},
|
|
632
|
+
),
|
|
633
|
+
{ inputs: { id: Input.hidden() } },
|
|
634
|
+
)
|
|
635
|
+
import { FormView } from 'foldkit-mixins-form'
|
|
636
|
+
|
|
637
|
+
const View = FormView.define(Edit)
|
|
638
|
+
-->
|
|
433
639
|
|
|
434
640
|
```ts
|
|
435
|
-
|
|
641
|
+
import { Bundle } from 'foldkit-bundle'
|
|
642
|
+
|
|
643
|
+
const NeverPreDisabled = Edit.bundle.pipe(
|
|
436
644
|
Bundle.withView(FormView.submodel(Edit, View, { canSubmit: () => true })),
|
|
437
645
|
)
|
|
438
646
|
```
|
|
@@ -444,8 +652,8 @@ Each control has an `id` of `<form name>-<key>` (in a row,
|
|
|
444
652
|
`aria-busy` while a check runs, `aria-invalid`, `aria-required` when the key is
|
|
445
653
|
required, and `aria-describedby` naming its description, the `checking` line
|
|
446
654
|
while a check runs, and its error while invalid. An error is `role="alert"`.
|
|
447
|
-
The submit button is disabled until the form would submit
|
|
448
|
-
|
|
655
|
+
The submit button is `aria-disabled` (never `disabled`) until the form would submit
|
|
656
|
+
and while it is submitting, so it keeps its focus and Enter always reaches `update`.
|
|
449
657
|
|
|
450
658
|
Those attributes belong to the view: an attachment that also supplies one is an
|
|
451
659
|
attribute conflict, reported when the view renders. The slots declare
|
package/dist/index.d.mts
CHANGED
|
@@ -52,15 +52,15 @@ export interface FormViewWords {
|
|
|
52
52
|
* What the view needs that the form does not own: the choices of each relation
|
|
53
53
|
* picker (a query the application makes), and the submit button's words.
|
|
54
54
|
*/
|
|
55
|
-
export interface FormViewInputs<Key extends string = string, ControlKey extends string = never> {
|
|
55
|
+
export interface FormViewInputs<Key extends string = string, ControlKey extends string = never, PickerKey extends string = Key> {
|
|
56
56
|
readonly options?: { readonly [K in Key]?: ReadonlyArray<Option>; } | undefined;
|
|
57
57
|
/**
|
|
58
58
|
* The pickers whose list has more rows than `options` holds (`Crud.options`'
|
|
59
59
|
* `more`): each draws a button that sends the form's `AskedForMore`, for the
|
|
60
60
|
* page that owns the list to answer. Relation pickers of the form itself
|
|
61
|
-
* only, and none while locked.
|
|
61
|
+
* only, so another key is a type error, and none while locked.
|
|
62
62
|
*/
|
|
63
|
-
readonly more?: { readonly [K in
|
|
63
|
+
readonly more?: ([PickerKey] extends [never] ? never : { readonly [K in PickerKey]?: boolean; }) | undefined;
|
|
64
64
|
/**
|
|
65
65
|
* The choices of a picker inside a nested key, by its path, the same for every
|
|
66
66
|
* row: `'author.country'`.
|
|
@@ -107,10 +107,10 @@ export interface FormViewInputs<Key extends string = string, ControlKey extends
|
|
|
107
107
|
readonly failure?: SubmitFailure | undefined;
|
|
108
108
|
/**
|
|
109
109
|
* Whether the write the last submit started landed, and the form is not
|
|
110
|
-
* edited since.
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
110
|
+
* edited since.
|
|
111
|
+
*
|
|
112
|
+
* @deprecated No effect: the submit button is `aria-disabled`, never
|
|
113
|
+
* `disabled`, so it keeps the focus whatever this says. Removed next release.
|
|
114
114
|
*/
|
|
115
115
|
readonly saved?: boolean | undefined;
|
|
116
116
|
}
|
|
@@ -178,9 +178,15 @@ export interface BundleInput {
|
|
|
178
178
|
readonly viewInputs?: unknown;
|
|
179
179
|
}
|
|
180
180
|
/** What the form's own Style and Behavior attachments may read. */
|
|
181
|
-
export interface FormInput<Model, Key extends string = string, ControlKey extends string = never> extends FormViewInputs<Key, ControlKey> {
|
|
181
|
+
export interface FormInput<Model, Key extends string = string, ControlKey extends string = never, PickerKey extends string = Key> extends FormViewInputs<Key, ControlKey, PickerKey> {
|
|
182
182
|
readonly model: Model;
|
|
183
183
|
readonly errors: ReadonlyArray<string>;
|
|
184
|
+
/**
|
|
185
|
+
* Whether the submit button is drawn without `aria-disabled`. It only marks
|
|
186
|
+
* the button: a press or Enter still reaches `update`, which decides from the
|
|
187
|
+
* Model. Whether a submit made while a check runs is refused is the form's
|
|
188
|
+
* `submitWaits` option, not this.
|
|
189
|
+
*/
|
|
184
190
|
readonly canSubmit: boolean;
|
|
185
191
|
/**
|
|
186
192
|
* Whether the form is submitting: a submit waits for a check, or the
|
|
@@ -251,7 +257,7 @@ export declare const FormSlots: Slots.Contract<{
|
|
|
251
257
|
readonly remove: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
252
258
|
}>;
|
|
253
259
|
/** The parts of a `Form.make` result the view reads. */
|
|
254
|
-
interface FormLike<Key extends string, Model, Message, ControlKey extends string = never> {
|
|
260
|
+
interface FormLike<Key extends string, Model, Message, ControlKey extends string = never, PickerKey extends string = never> {
|
|
255
261
|
/** Every key, nested ones too; `Key` is the keys that hold a draft. */
|
|
256
262
|
readonly controls: ReadonlyArray<FormControl>;
|
|
257
263
|
readonly field: (model: Model, key: Key) => FieldValidation.Field<Draft>;
|
|
@@ -287,8 +293,9 @@ interface FormLike<Key extends string, Model, Message, ControlKey extends string
|
|
|
287
293
|
readonly FollowedIssue: (payload: {
|
|
288
294
|
readonly id: string;
|
|
289
295
|
}) => NoInfer<Message>;
|
|
296
|
+
/** Only a relation picker asks, so its key is one of those: what `more` is keyed by. */
|
|
290
297
|
readonly AskedForMore: (payload: {
|
|
291
|
-
readonly key:
|
|
298
|
+
readonly key: PickerKey;
|
|
292
299
|
}) => NoInfer<Message>;
|
|
293
300
|
readonly Control: (payload: {
|
|
294
301
|
readonly key: never;
|
|
@@ -450,7 +457,7 @@ export declare const FormView: {
|
|
|
450
457
|
*/
|
|
451
458
|
define: <Key extends string, Model, Message extends {
|
|
452
459
|
readonly _tag: string;
|
|
453
|
-
}, ControlKey extends string = never>(form: FormLike<Key, Model, Message, ControlKey> & {
|
|
460
|
+
}, ControlKey extends string = never, PickerKey extends string = never>(form: FormLike<Key, Model, Message, ControlKey, PickerKey> & {
|
|
454
461
|
readonly bundle: {
|
|
455
462
|
readonly name: string;
|
|
456
463
|
};
|
|
@@ -458,7 +465,7 @@ export declare const FormView: {
|
|
|
458
465
|
readonly field?: FieldView<Key, Message>;
|
|
459
466
|
/** Renderers by kind, for the field view this makes. With `field` given, give them to `FormView.field`. */
|
|
460
467
|
readonly renderers?: Renderers<Message>;
|
|
461
|
-
}) => SlotView.SlotView<typeof FormSlots, FormInput<Model, Key, ControlKey>, Message>;
|
|
468
|
+
}) => SlotView.SlotView<typeof FormSlots, FormInput<Model, Key, ControlKey, PickerKey>, Message>;
|
|
462
469
|
/**
|
|
463
470
|
* The whole form, as `define` draws it, with per-key overrides; and one flat
|
|
464
471
|
* key's control, for a layout the caller owns. Keys with no override render
|
|
@@ -471,7 +478,7 @@ export declare const FormView: {
|
|
|
471
478
|
*/
|
|
472
479
|
fields: <Key extends string, Model, FormMessage extends {
|
|
473
480
|
readonly _tag: string;
|
|
474
|
-
}, ControlKey extends string = never>(form: FormLike<Key, Model, FormMessage, ControlKey> & {
|
|
481
|
+
}, ControlKey extends string = never, PickerKey extends string = never>(form: FormLike<Key, Model, FormMessage, ControlKey, PickerKey> & {
|
|
475
482
|
readonly bundle: {
|
|
476
483
|
readonly name: string;
|
|
477
484
|
};
|
|
@@ -480,7 +487,7 @@ export declare const FormView: {
|
|
|
480
487
|
/** Renderers by kind, for the field views this makes. */
|
|
481
488
|
readonly renderers?: Renderers<FormMessage>;
|
|
482
489
|
} & FieldsOptions<Key, FormMessage>) => {
|
|
483
|
-
readonly view: SlotView.SlotView<typeof FormSlots, FormInput<Model, Key, ControlKey>, FormMessage>;
|
|
490
|
+
readonly view: SlotView.SlotView<typeof FormSlots, FormInput<Model, Key, ControlKey, PickerKey>, FormMessage>;
|
|
484
491
|
readonly field: FieldsField<Key, Model, FormMessage>;
|
|
485
492
|
};
|
|
486
493
|
/**
|
|
@@ -496,19 +503,18 @@ export declare const FormView: {
|
|
|
496
503
|
readonly submitPending: boolean;
|
|
497
504
|
}, Message extends {
|
|
498
505
|
readonly _tag: string;
|
|
499
|
-
}, ControlKey extends string = never>(form: FormLike<Key, Model, Message, ControlKey>, view: SlotView.SlotView<typeof FormSlots, FormInput<Model, Key, ControlKey>, Message>, options?: {
|
|
506
|
+
}, ControlKey extends string = never, PickerKey extends string = never>(form: FormLike<Key, Model, Message, ControlKey, PickerKey>, view: SlotView.SlotView<typeof FormSlots, FormInput<Model, Key, ControlKey, PickerKey>, Message>, options?: {
|
|
500
507
|
/**
|
|
501
|
-
* When the
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* at submit.
|
|
508
|
+
* When the button reads `aria-disabled`. It marks the button and nothing
|
|
509
|
+
* more: `update` decides every submit from the Model. Default
|
|
510
|
+
* `form.canSubmit`, which follows the form's `submitWaits`: with the
|
|
511
|
+
* default `true` a submit made mid-check waits for the answer and the
|
|
512
|
+
* button stays enabled; with `false` the form refuses it and the button
|
|
513
|
+
* reads disabled through the check. Pass `() => true` to never mark it and
|
|
514
|
+
* validate wholly at submit.
|
|
509
515
|
*/
|
|
510
516
|
readonly canSubmit?: (model: Model) => boolean;
|
|
511
|
-
}) => Submodel.View<Model, Message, FormViewInputs<Key, ControlKey>>;
|
|
517
|
+
}) => Submodel.View<Model, Message, FormViewInputs<Key, ControlKey, PickerKey>>;
|
|
512
518
|
};
|
|
513
519
|
export {};
|
|
514
520
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;iBAoCiB;WACN;WACA;;;;;;;;;iBAUM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;WAKA;;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WACP,UAAU,OAAO,KAAK,YAAY,YAClC,UACD;;;;;;;;;;aAWU,aAAa,OAAO;QAE9B,SAAS,KAAK,OAAO,SAAS,eAAe,KAAK,YAAY"}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as FieldSlots, n as FormSlots, r as FormView } from "./src-
|
|
1
|
+
export { t as FieldSlots, n as FormSlots, r as FormView } from "./src-DKt2l7dw.mjs";
|
package/dist/recipes.d.mts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const Field: import("foldkit-mixins").SlotRecipe<import("foldkit-
|
|
|
24
24
|
readonly choiceLabel: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Base", readonly []>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
25
25
|
readonly search: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"TextInput", readonly [import("foldkit-mixins").CapabilityShape<"Focusable", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>]>, readonly [import("foldkit-mixins").EventToken<"input">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
26
26
|
readonly more: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
27
|
-
}>, {}>;
|
|
27
|
+
}>, {}, "affix" | "checking" | "choice" | "choiceLabel" | "choices" | "description" | "error" | "group" | "label" | "more" | "multiline" | "number" | "root" | "search" | "select" | "text" | "toggle">;
|
|
28
28
|
/**
|
|
29
29
|
* A form: its fields in a column, a failure that is no one field's (or its
|
|
30
30
|
* write's) in the error's ink, the list of fields to fix in a box of the
|
|
@@ -46,5 +46,5 @@ export declare const Form: import("foldkit-mixins").SlotRecipe<import("foldkit-m
|
|
|
46
46
|
readonly row: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Container", readonly [import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>]>, readonly import("foldkit-mixins").EventName[], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
47
47
|
readonly add: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
48
48
|
readonly remove: import("foldkit-mixins").UnnamedSlot<import("foldkit-mixins").CapabilityShape<"Interactive", readonly [import("foldkit-mixins").CapabilityShape<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly import("foldkit-mixins").AttributeName[], readonly import("foldkit-mixins").RequirementName[], boolean>;
|
|
49
|
-
}>, {}>;
|
|
49
|
+
}>, {}, "add" | "errors" | "failure" | "group" | "issueLink" | "issues" | "legend" | "remove" | "root" | "row" | "submit" | "summary" | "summaryTitle">;
|
|
50
50
|
//# sourceMappingURL=recipes.d.mts.map
|
package/dist/recipes.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipes.d.mts","names":[],"sources":["../src/recipes.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"recipes.d.mts","names":[],"sources":["../src/recipes.ts"],"mappings":";;;;;;qBAyCa,gCAAK,oCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqCL,+BAAI,oCAAA"}
|
package/dist/recipes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as FormSlots, t as FieldSlots } from "./src-
|
|
1
|
+
import { n as FormSlots, t as FieldSlots } from "./src-DKt2l7dw.mjs";
|
|
2
2
|
import { Layers, Style } from "foldkit-mixins";
|
|
3
3
|
import { Recipes } from "foldkit-mixins-ui";
|
|
4
4
|
import { Theme } from "foldkit-mixins/theme";
|
|
@@ -12,8 +12,8 @@ import { Theme } from "foldkit-mixins/theme";
|
|
|
12
12
|
*/
|
|
13
13
|
const ref = Theme.ref(Theme.standard());
|
|
14
14
|
const component = (...pieces) => Layers.standard.in("components", Style.compose(...pieces));
|
|
15
|
-
const input = Recipes.Input({}).input
|
|
16
|
-
const button = (options) => Recipes.Button(options).button
|
|
15
|
+
const input = Recipes.Input({}).input;
|
|
16
|
+
const button = (options) => Recipes.Button(options).button;
|
|
17
17
|
/** A small button that keeps its own width in a field or form that stretches its parts. */
|
|
18
18
|
const small = component(button({
|
|
19
19
|
tone: "neutral",
|
|
@@ -54,8 +54,8 @@ const Field = Style.recipeFor(FieldSlots)({ base: {
|
|
|
54
54
|
error: said(ref.error.ink),
|
|
55
55
|
text: input,
|
|
56
56
|
number: input,
|
|
57
|
-
multiline: Recipes.Textarea({}).textarea
|
|
58
|
-
select: Recipes.Select({}).select
|
|
57
|
+
multiline: Recipes.Textarea({}).textarea,
|
|
58
|
+
select: Recipes.Select({}).select,
|
|
59
59
|
toggle: box,
|
|
60
60
|
choices: component(Style.self({
|
|
61
61
|
display: "grid",
|
package/dist/recipes.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipes.mjs","names":[],"sources":["../src/recipes.ts"],"sourcesContent":["/**\n * Looks for the form view's Slots over the shipped tokens, from\n * `foldkit-mixins-form/recipes`: `Style.forSlots(FieldSlots)(Field({}))` and\n * `Style.forSlots(FormSlots)(Form({}))`. Text, number, select and the relation\n * picker's search box take `foldkit-mixins-ui`'s own field looks, so a form drawn\n * with the plain renderers and one drawn with `UiForm.renderers` look the same.\n */\nimport { Layers, Style, type StyleValue } from 'foldkit-mixins'\nimport { Theme } from 'foldkit-mixins/theme'\nimport { Recipes } from 'foldkit-mixins-ui'\nimport { FieldSlots, FormSlots } from './index.js'\n\nconst ref = Theme.ref(Theme.standard())\nconst component = (...pieces: ReadonlyArray<StyleValue>): StyleValue =>\n Layers.standard.in('components', Style.compose(...pieces))\n\nconst input = Recipes.Input({}).input
|
|
1
|
+
{"version":3,"file":"recipes.mjs","names":[],"sources":["../src/recipes.ts"],"sourcesContent":["/**\n * Looks for the form view's Slots over the shipped tokens, from\n * `foldkit-mixins-form/recipes`: `Style.forSlots(FieldSlots)(Field({}))` and\n * `Style.forSlots(FormSlots)(Form({}))`. Text, number, select and the relation\n * picker's search box take `foldkit-mixins-ui`'s own field looks, so a form drawn\n * with the plain renderers and one drawn with `UiForm.renderers` look the same.\n */\nimport { Layers, Style, type StyleValue } from 'foldkit-mixins'\nimport { Theme } from 'foldkit-mixins/theme'\nimport { Recipes } from 'foldkit-mixins-ui'\nimport { FieldSlots, FormSlots } from './index.js'\n\nconst ref = Theme.ref(Theme.standard())\nconst component = (...pieces: ReadonlyArray<StyleValue>): StyleValue =>\n Layers.standard.in('components', Style.compose(...pieces))\n\nconst input = Recipes.Input({}).input\nconst button = (options: Parameters<typeof Recipes.Button>[0]) => Recipes.Button(options).button\n/** A small button that keeps its own width in a field or form that stretches its parts. */\nconst small = component(\n button({ tone: 'neutral', variant: 'outline', size: 'sm' }),\n Style.self({ justifySelf: 'start' }),\n)\n/** A checkbox the browser draws, a size to see and in the accent. */\nconst box = component(\n Style.self({\n inlineSize: '1rem',\n blockSize: '1rem',\n margin: '0',\n accentColor: ref.accent.default,\n }),\n)\n/** A line the field says under its control. */\nconst said = (color: string) => component(Style.self({ margin: '0', fontSize: ref.size.sm, color }))\n\n/**\n * A field: its label over its control, then what it says about it, in a grid,\n * which stretches a control with no width of its own and leaves a checkbox its\n * size. A failure reads in the error's ink; a choice of many is a row a finger's\n * height, its box beside its words.\n */\nexport const Field = Style.recipeFor(FieldSlots)({\n base: {\n root: component(Style.self({ display: 'grid', gap: ref.space['2xs'] })),\n label: component(\n Style.self({ fontSize: ref.size.sm, fontWeight: ref.weight.medium, color: ref.text.overt }),\n ),\n description: said(ref.text.muted),\n checking: said(ref.text.muted),\n error: said(ref.error.ink),\n text: input,\n number: input,\n multiline: Recipes.Textarea({}).textarea,\n select: Recipes.Select({}).select,\n toggle: box,\n choices: component(Style.self({ display: 'grid', gap: ref.space['3xs'] })),\n choiceLabel: component(\n Style.self({\n display: 'flex',\n alignItems: 'center',\n gap: ref.space.xs,\n minBlockSize: '1.5rem',\n }),\n ),\n choice: box,\n group: Recipes.InputGroup.group,\n affix: Recipes.InputGroup.affix,\n search: input,\n more: small,\n },\n})\n\n/**\n * A form: its fields in a column, a failure that is no one field's (or its\n * write's) in the error's ink, the list of fields to fix in a box of the\n * error's colours, and the submit as the page's primary button, as wide as its\n * words.\n */\nexport const Form = Style.recipeFor(FormSlots)({\n base: {\n root: component(Style.self({ display: 'grid', gap: ref.space.md })),\n errors: said(ref.error.ink),\n failure: said(ref.error.ink),\n summary: component(\n Style.self({\n display: 'grid',\n gap: ref.space.xs,\n padding: ref.space.md,\n border: `${ref.border.thin} solid ${ref.error.outline}`,\n borderRadius: ref.radius.md,\n background: ref.error.subtle,\n color: ref.text.default,\n }),\n ),\n summaryTitle: component(\n Style.self({ margin: '0', fontWeight: ref.weight.semibold, color: ref.error.ink }),\n ),\n issues: component(Style.self({ margin: '0', paddingInlineStart: ref.space.lg })),\n issueLink: component(\n Style.self({ color: ref.text.link, textDecoration: 'underline', textUnderlineOffset: '3px' }),\n ),\n submit: component(button({}), Style.self({ justifySelf: 'start' })),\n group: component(\n Style.self({\n display: 'grid',\n gap: ref.space.sm,\n margin: '0',\n padding: ref.space.md,\n border: `${ref.border.thin} solid ${ref.outline.subtle}`,\n borderRadius: ref.radius.md,\n }),\n ),\n legend: component(\n Style.self({ paddingInline: ref.space['2xs'], fontWeight: ref.weight.semibold }),\n ),\n row: component(Style.self({ display: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S,IAAI,QAAQ;EAChD,cAAc,IAAI,OAAO;CAC3B,CAAC,CACH;CACA,QAAQ,UACN,MAAM,KAAK;EAAE,eAAe,IAAI,MAAM;EAAQ,YAAY,IAAI,OAAO;CAAS,CAAC,CACjF;CACA,KAAK,UAAU,MAAM,KAAK;EAAE,SAAS;EAAQ,KAAK,IAAI,MAAM;CAAG,CAAC,CAAC;CACjE,KAAK;CACL,QAAQ;AACV,EACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Option } from "effect";
|
|
1
|
+
import { Match, Option } from "effect";
|
|
2
2
|
import { Input, fillWords } from "foldkit-form";
|
|
3
3
|
import { Attr, Capability, Event, Slot, SlotView, Slots, Style } from "foldkit-mixins";
|
|
4
4
|
import * as FieldValidation from "foldkit/fieldValidation";
|
|
@@ -248,15 +248,25 @@ const rowWalk = (parent, key, row, form) => ({
|
|
|
248
248
|
})),
|
|
249
249
|
make: form.Message
|
|
250
250
|
});
|
|
251
|
-
const errorsOf = (field) =>
|
|
251
|
+
const errorsOf = (field) => Match.valueTags(field, {
|
|
252
|
+
Invalid: ({ errors }) => errors,
|
|
253
|
+
NotValidated: () => [],
|
|
254
|
+
Validating: () => [],
|
|
255
|
+
Valid: () => []
|
|
256
|
+
});
|
|
252
257
|
/**
|
|
253
258
|
* The state of a key a control backed by a Bundle edits, as a field is drawn:
|
|
254
259
|
* its validation state, with no draft. The Bundle's Model travels as `bundle`.
|
|
255
260
|
*/
|
|
256
|
-
const withoutDraft = (field) => field
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
261
|
+
const withoutDraft = (field) => Match.valueTags(field, {
|
|
262
|
+
Invalid: ({ errors }) => FieldValidation.Invalid({
|
|
263
|
+
value: "",
|
|
264
|
+
errors
|
|
265
|
+
}),
|
|
266
|
+
Valid: () => FieldValidation.Valid({ value: "" }),
|
|
267
|
+
Validating: () => FieldValidation.Validating({ value: "" }),
|
|
268
|
+
NotValidated: () => FieldValidation.NotValidated({ value: "" })
|
|
269
|
+
});
|
|
260
270
|
/**
|
|
261
271
|
* A control backed by a Bundle that no renderer names is drawn with the
|
|
262
272
|
* Bundle's own view, inside the field's `control` slot, which carries the
|
|
@@ -506,7 +516,6 @@ const FormView = {
|
|
|
506
516
|
make: form.Message
|
|
507
517
|
};
|
|
508
518
|
const submitting = input.submitting === true;
|
|
509
|
-
const saved = input.saved === true;
|
|
510
519
|
const fields = draw(top, form.bundle.name, "");
|
|
511
520
|
return h.form(slots.root.attrs([h.OnSubmit(form.Message.Submitted()), ...submitting ? [h.AriaBusy(true), h.DataAttribute("submitting", "")] : []]), [
|
|
512
521
|
...fields,
|
|
@@ -519,11 +528,7 @@ const FormView = {
|
|
|
519
528
|
})])])))])],
|
|
520
529
|
...input.errors.length === 0 ? [] : [h.p(slots.errors.attrs([h.Role("alert")]), [...input.errors])],
|
|
521
530
|
...input.failure === void 0 ? [] : [h.p(slots.failure.attrs([h.Role("alert")]), [input.failure.error])],
|
|
522
|
-
...input.submits === false ? [] : [h.button(slots.submit.attrs([
|
|
523
|
-
h.Type("submit"),
|
|
524
|
-
h.Disabled(!input.canSubmit && !saved),
|
|
525
|
-
...submitting || saved && !input.canSubmit ? [h.AriaDisabled(true)] : []
|
|
526
|
-
]), [submitting ? input.words?.submitting ?? "Submitting…" : input.failure?.retry === true ? input.words?.resubmit ?? "Try again" : input.words?.submit ?? "Submit"])]
|
|
531
|
+
...input.submits === false ? [] : [h.button(slots.submit.attrs([h.Type("submit"), ...!input.canSubmit || submitting ? [h.AriaDisabled(true)] : []]), [submitting ? input.words?.submitting ?? "Submitting…" : input.failure?.retry === true ? input.words?.resubmit ?? "Try again" : input.words?.submit ?? "Submit"])]
|
|
527
532
|
]);
|
|
528
533
|
}, { name: form.bundle.name });
|
|
529
534
|
},
|
|
@@ -617,4 +622,4 @@ const FormView = {
|
|
|
617
622
|
};
|
|
618
623
|
export { groupState as a, withChosen as c, chosenOf as i, FormSlots as n, literalOptions as o, FormView as r, plainRenderers as s, FieldSlots as t };
|
|
619
624
|
|
|
620
|
-
//# sourceMappingURL=src-
|
|
625
|
+
//# sourceMappingURL=src-DKt2l7dw.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-DKt2l7dw.mjs","names":["Maybe"],"sources":["../src/renderers.ts","../src/index.ts"],"sourcesContent":["/**\n * The renderers this package ships, by kind. They live apart from the view so\n * the `/ui` entry can draw the same elements through another component's\n * Slots.\n */\nimport { Input } from 'foldkit-form'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport type { FieldAttrs, Option, RenderContext, Renderer } from './index.js'\n\n/** A renderer for every kind of control `foldkit-form` ships and shows. */\nexport type Shipped<Message> = {\n readonly [\n Kind in\n | 'Text'\n | 'Multiline'\n | 'Number'\n | 'Toggle'\n | 'Select'\n | 'RelationOne'\n | 'Choices'\n | 'RelationMany'\n ]: Renderer<Message>\n}\n\n/** What a `Select` or a `Choices` control offers: the options its schema spells out. */\nexport const literalOptions = (control: RenderContext<unknown>['control']): ReadonlyArray<Option> =>\n (Input.Select.is(control) || Input.Choices.is(control) ? control.data.options : []).map(\n option => ({ value: String(option), label: String(option) }),\n )\n\n/** Types whose text is an address or a number, which a keyboard must not capitalize or correct. */\nexport const LITERAL_TYPES: ReadonlySet<string> = new Set(['email', 'tel', 'url'])\n\n/**\n * The choices, and after them each chosen value they lack, as `? value`: a\n * stored id whose row is gone, or a value the choices have not loaded yet,\n * stays shown and can be let go, rather than dropped from sight.\n */\nexport const withChosen = (\n options: ReadonlyArray<Option>,\n chosen: ReadonlyArray<string>,\n): ReadonlyArray<Option> => {\n const known = new Set(options.map(option => option.value))\n return [\n ...options,\n ...chosen\n .filter(value => value !== '' && !known.has(value))\n .map(value => ({ value, label: `? ${value}` })),\n ]\n}\n\n/**\n * The renderers this package ships, by kind. They are entries like any other: an\n * application adds `Date`, or replaces `RelationOne` with a combobox, by passing\n * its own beside them.\n */\nexport const plainRenderers = <Message>(): Shipped<Message> => {\n const typed = ({ state, draft, change, blurred, h }: RenderContext<Message>) => [\n ...state,\n h.Value(String(draft)),\n h.OnInput(change),\n h.OnBlur(blurred),\n ]\n // A blank option whenever nothing is chosen, required or not: without one the\n // browser shows its first option as chosen while the draft is still empty.\n const pick = (\n { state, draft, change, blurred, input, slots, h }: RenderContext<Message>,\n options: ReadonlyArray<Option>,\n blank: boolean,\n ): Html =>\n h.select(slots.select.attrs([...state, h.OnChange(change), h.OnBlur(blurred)]), [\n ...(blank || draft === ''\n ? [\n h.option(slots.option.attrs([h.Value(''), h.Selected(draft === '')]), [\n input.noneWord ?? '',\n ]),\n ]\n : []),\n ...withChosen(options, typeof draft === 'string' ? [draft] : []).map(option =>\n h.option(slots.option.attrs([h.Value(option.value), h.Selected(draft === option.value)]), [\n option.label,\n ]),\n ),\n ])\n /** What a phone's keyboard and the browser's autofill should offer, from the key's attrs. */\n const keyboard = <M>({\n attrs,\n h,\n }: {\n readonly attrs: FieldAttrs\n readonly h: HtmlBuilder<M>\n }) => {\n const literal = attrs.type !== undefined && LITERAL_TYPES.has(attrs.type)\n const capitalize = attrs.autocapitalize ?? (literal ? 'none' : undefined)\n const spellcheck = attrs.spellcheck ?? (literal ? false : undefined)\n return [\n ...(attrs.autocomplete === undefined\n ? []\n : [h.Attribute('autocomplete', attrs.autocomplete)]),\n ...(attrs.enterKeyHint === undefined\n ? []\n : [h.Attribute('enterkeyhint', attrs.enterKeyHint)]),\n ...(capitalize === undefined ? [] : [h.Attribute('autocapitalize', capitalize)]),\n ...(spellcheck === undefined ? [] : [h.Attribute('spellcheck', String(spellcheck))]),\n ]\n }\n return {\n Text: context =>\n context.h.input(\n context.slots.text.attrs([\n ...typed(context),\n ...keyboard(context),\n ...(context.attrs.inputMode === undefined\n ? []\n : [context.h.InputMode(context.attrs.inputMode)]),\n context.h.Type(context.attrs.type ?? 'text'),\n ...(context.attrs.placeholder === undefined\n ? []\n : [context.h.Placeholder(context.attrs.placeholder)]),\n ]),\n ),\n Multiline: context =>\n context.h.textarea(\n context.slots.multiline.attrs([\n ...typed(context),\n ...keyboard(context),\n ...(context.attrs.placeholder === undefined\n ? []\n : [context.h.Placeholder(context.attrs.placeholder)]),\n ...(context.attrs.rows === undefined\n ? []\n : [context.h.Attribute('rows', String(context.attrs.rows))]),\n ]),\n ),\n // A number is a text input because its draft is text: `\"4.\"` is a fine thing to\n // have typed, and `type=\"number\"` would refuse to report it.\n Number: context =>\n context.h.input(\n context.slots.number.attrs([\n ...typed(context),\n ...keyboard(context),\n context.h.Type('text'),\n // `decimal` has no minus on iOS: a field that takes negatives says `text`, and one of\n // whole numbers `numeric`.\n context.h.InputMode(context.attrs.inputMode ?? 'decimal'),\n ...(context.attrs.placeholder === undefined\n ? []\n : [context.h.Placeholder(context.attrs.placeholder)]),\n ]),\n ),\n Toggle: ({ state, draft, toggled, blurred, slots, h }) =>\n h.input(\n slots.toggle.attrs([\n ...state,\n h.Type('checkbox'),\n h.Checked(draft === true),\n h.OnClick(toggled()),\n h.OnBlur(blurred),\n ]),\n ),\n Select: context =>\n pick(context, literalOptions(context.control), !context.input.control.required),\n RelationOne: context => pick(context, context.input.options, true),\n // A key of any number of choices, whether the options come from the schema\n // (`Choices`) or from the application's own list (`RelationMany`).\n Choices: context => choiceGroup(context, literalOptions(context.control)),\n RelationMany: context => choiceGroup(context, context.input.options),\n }\n}\n\ntype StateTag = RenderContext<unknown>['state'][number]['_tag']\n\n// Typed by the attributes' own tags, so a misspelt one does not compile.\nconst GROUP_STATE: ReadonlySet<StateTag> = new Set<StateTag>([\n 'Id',\n 'AriaInvalid',\n 'AriaBusy',\n 'AriaDescribedBy',\n])\n\n/**\n * A group's share of the control's state: its id, validity and descriptions.\n * The name and `disabled` go on each checkbox, and a group takes no `aria-required`.\n */\nexport const groupState = <Message>(\n state: RenderContext<Message>['state'],\n): RenderContext<Message>['state'] => state.filter(attribute => GROUP_STATE.has(attribute._tag))\n\n/** The values a choice draft holds. */\nexport const chosenOf = (draft: RenderContext<unknown>['draft']): ReadonlyArray<string> =>\n Array.isArray(draft) ? (draft as ReadonlyArray<string>) : []\n\n/** A key of any number of choices: each one a checkbox in its own label. */\nexport const choiceGroup = <Message>(\n { input, draft, toggled, state, slots, h }: RenderContext<Message>,\n options: ReadonlyArray<Option>,\n): Html => {\n const chosen = chosenOf(draft)\n const isChosen = new Set(chosen)\n return h.div(\n slots.choices.attrs([...groupState(state), h.Role('group'), h.AriaLabel(input.control.label)]),\n withChosen(options, chosen).map(option =>\n h.label(slots.choiceLabel.attrs(), [\n h.input(\n slots.choice.attrs([\n h.Type('checkbox'),\n h.Name(input.control.key),\n h.Value(option.value),\n h.Checked(isChosen.has(option.value)),\n ...(input.locked === true ? [h.Disabled(true)] : []),\n h.OnClick(toggled(option.value)),\n ]),\n ),\n option.label,\n ]),\n ),\n )\n}\n","/**\n * `foldkit-mixins-form` — a `foldkit-form` form drawn through slots.\n *\n * `foldkit-form` describes each control and draws nothing. This package draws\n * them as plain, accessible HTML and publishes every element as a Slot, so an\n * application styles and extends a generated form the way it does any other\n * SlotView, and the form stays free of a view dependency.\n */\n// `Option` is this package's own name, a picker's choice: Effect's goes by another here.\nimport { Match, Option as Maybe } from 'effect'\nimport {\n Input,\n fillWords,\n type Control,\n type Draft,\n type FormControl,\n type FormRow,\n type NestedForm,\n} from 'foldkit-form'\nimport {\n Attr,\n Capability,\n Event,\n Slot,\n Slots,\n SlotView,\n Style,\n type NamedStyle,\n type SlotBuilders,\n} from 'foldkit-mixins'\nimport * as FieldValidation from 'foldkit/fieldValidation'\nimport type { Attribute, Html, HtmlBuilder } from 'foldkit/html'\nimport * as Submodel from 'foldkit/submodel'\nimport { plainRenderers } from './renderers.js'\n\n/** One thing a select or a relation picker offers. */\nexport interface Option {\n readonly value: string\n readonly label: string\n}\n\n/**\n * The words the drawn form says itself. Its keys are its own, so one object can\n * hold these, `foldkit-mixins-crud`'s `ViewWords`, and a form's `FormMessages`:\n * an application's words, written and translated in one place. They are text\n * with blanks (`{label}`), never functions: Foldkit admits no function nested in\n * a placed view's inputs.\n */\nexport interface FormViewWords {\n /** On the submit button. Default `Submit`. */\n readonly submit?: string | undefined\n /** Before the label on a picker's search box (`Search Author`). Default `Search`. */\n readonly search?: string | undefined\n /** The choice of nothing, in a picker that may be left empty. Default: blank. */\n readonly none?: string | undefined\n /** On the button that adds a row to a nested key. Default `Add {label}`. */\n readonly add?: string | undefined\n /** On the button that removes a row; `{position}` counts from 1. Default `Remove {label} {position}`. */\n readonly remove?: string | undefined\n /** Under a control while its check runs. Default `Checking…`. */\n readonly checking?: string | undefined\n /** On the submit button while the form is submitting. Default `Submitting…`. */\n readonly submitting?: string | undefined\n /**\n * On the submit button after its write failed, when a submit sends that\n * write again (`failure.retry`). Default `Try again`.\n */\n readonly resubmit?: string | undefined\n /** Above the list of fields to fix. Default `Check these fields:`. */\n readonly summary?: string | undefined\n /** One field to fix, a link to it. Default `{label}: {error}`. */\n readonly issue?: string | undefined\n /**\n * A field of a row as the fields to fix name it, so two rows' links differ:\n * `{row}` is the nested key's label, with the row's position when it holds\n * many. Default `{row}, {label}`.\n */\n readonly inRow?: string | undefined\n /** On the button under a picker whose list has more rows than it shows. Default `Show more`. */\n readonly more?: string | undefined\n}\n\n/**\n * What the view needs that the form does not own: the choices of each relation\n * picker (a query the application makes), and the submit button's words.\n */\nexport interface FormViewInputs<\n Key extends string = string,\n ControlKey extends string = never,\n PickerKey extends string = Key,\n> {\n readonly options?: { readonly [K in Key]?: ReadonlyArray<Option> } | undefined\n /**\n * The pickers whose list has more rows than `options` holds (`Crud.options`'\n * `more`): each draws a button that sends the form's `AskedForMore`, for the\n * page that owns the list to answer. Relation pickers of the form itself\n * only, so another key is a type error, and none while locked.\n */\n readonly more?:\n | ([PickerKey] extends [never] ? never : { readonly [K in PickerKey]?: boolean })\n | undefined\n /**\n * The choices of a picker inside a nested key, by its path, the same for every\n * row: `'author.country'`.\n */\n readonly nestedOptions?: Readonly<Record<string, ReadonlyArray<Option>>> | undefined\n /**\n * What a control backed by a Bundle is drawn with, by key: its view's inputs,\n * such as the page Builder's `BuilderView.inputs({ data })`. A key in a nested\n * row is named by its path, as in `nestedOptions`. Keyed by text, as those\n * paths are, and typed where each entry is made, since only the control's\n * Bundle knows its view's inputs.\n */\n readonly controls?: Readonly<Record<string, unknown>> | undefined\n /** The view's own words, for wording and for translation. */\n readonly words?: FormViewWords | undefined\n /**\n * Whether the form is drawn with its submit button. Default: it is. `false`\n * for someone who may not submit it, such as a writer where submitting\n * publishes, so what would be refused is not offered.\n */\n readonly submits?: boolean | undefined\n /**\n * Keys shown but not editable, drawn `disabled`: one the person may not set,\n * such as a member `foldkit-guard`'s `May.canSet` says no to. A hint, not a\n * check: the server checks the write. A key edited by a Bundle with no\n * renderer has its Bundle's view drawn in a disabled fieldset, which disables\n * the buttons and inputs it draws; a key in a nested row is not locked by this.\n */\n readonly locked?: ReadonlyArray<Key | ControlKey> | undefined\n /**\n * Whether the write a submit started is in flight: the form hands its value\n * over and cannot see what follows. `Crud.editor` gives it, read from\n * Remote's ledger by the write's request id; a form placed with an `onOut`\n * of its own passes `Data.mutation(model, requestId)._tag === 'Pending'`.\n */\n readonly submitting?: boolean | undefined\n /**\n * Why the write the last submit started did not land, as the page reads it\n * where the write runs: a refusal naming none of the form's keys, or a\n * failure. Drawn as the form's alert (the `failure` Slot). `retry` says a\n * submit sends that same write again (a failure; a refusal would only be\n * refused again), and the button then reads `words.resubmit`.\n */\n readonly failure?: SubmitFailure | undefined\n /**\n * Whether the write the last submit started landed, and the form is not\n * edited since.\n *\n * @deprecated No effect: the submit button is `aria-disabled`, never\n * `disabled`, so it keeps the focus whatever this says. Removed next release.\n */\n readonly saved?: boolean | undefined\n}\n\n/** Why a submitted write did not land, for `FormViewInputs.failure`. */\nexport interface SubmitFailure {\n readonly error: string\n /** Whether a submit sends the same write again. */\n readonly retry: boolean\n}\n\n/** What a field's Style and Behavior attachments may read. */\nexport interface FieldInput<Key extends string = string> {\n readonly control: FormControl<Key>\n readonly field: FieldValidation.Field<Draft>\n readonly invalid: boolean\n readonly errors: ReadonlyArray<string>\n readonly options: ReadonlyArray<Option>\n /** Unique within the form, for `label for`, and as the prefix of the ids beside it. */\n readonly id: string\n /** The word before the label on its search box: the view's `words.search`. */\n readonly searchWord?: string | undefined\n /** The choice of nothing in a picker: the view's `words.none`. */\n readonly noneWord?: string | undefined\n /** What is said while the key's check runs: the view's `words.checking`. */\n readonly checkingWord?: string | undefined\n /**\n * The form's list of fields to fix announces this failure, so the error\n * beside the field is drawn without its own `role=\"alert\"`.\n */\n readonly quiet?: boolean | undefined\n /** The Message a press of the picker's \"more\" button sends; none draws no button. */\n readonly more?: unknown\n /** On that button: the view's `words.more`. */\n readonly moreWord?: string | undefined\n /**\n * Set for a field in a row of a nested key: its Messages, wrapped for the row.\n * A field of the form itself sends the form's own.\n */\n readonly send?:\n | {\n readonly changed: (value: Draft) => unknown\n readonly blurred: unknown\n readonly searched: (text: string) => unknown\n readonly toggled: (choice?: string) => unknown\n }\n | undefined\n /**\n * Set for a key edited by a control backed by a Bundle (`Input.bundle`): the\n * Bundle's Model, and the Message that carries one of its own. Such a key has\n * no draft, so `field.value` is `''`; its validation state is `field`'s.\n */\n readonly bundle?: BundleInput | undefined\n /** What was typed to find a choice, for a relation picker that searches. */\n readonly search: string\n /** Shown but not editable: the view's `locked` names the key. */\n readonly locked?: boolean | undefined\n /**\n * Whether the key is still written from the key it follows. A renderer offers\n * \"regenerate\" when it is not, by sending the key an empty draft.\n */\n readonly following: boolean\n}\n\n/** A control backed by a Bundle, as its field is drawn: its Model, and how its Messages leave. */\nexport interface BundleInput {\n readonly model: unknown\n readonly send: (message: unknown) => unknown\n /** What the view's `controls` gives this key, for the Bundle's own view. */\n readonly viewInputs?: unknown\n}\n\n/** What the form's own Style and Behavior attachments may read. */\nexport interface FormInput<\n Model,\n Key extends string = string,\n ControlKey extends string = never,\n PickerKey extends string = Key,\n> extends FormViewInputs<Key, ControlKey, PickerKey> {\n readonly model: Model\n readonly errors: ReadonlyArray<string>\n /**\n * Whether the submit button is drawn without `aria-disabled`. It only marks\n * the button: a press or Enter still reaches `update`, which decides from the\n * Model. Whether a submit made while a check runs is refused is the form's\n * `submitWaits` option, not this.\n */\n readonly canSubmit: boolean\n /**\n * Whether the form is submitting: a submit waits for a check, or the\n * application's work with the value is in flight. `FormView.submodel` reads both.\n */\n readonly submitting?: boolean | undefined\n}\n\nconst textual = {\n capability: Capability.TextInput,\n events: [Event.Input, Event.Blur],\n attributes: [Attr.AriaInvalid, Attr.AriaDescribedby],\n} as const\n\n/** One field: the control for a key, and what stands around it. */\nexport const FieldSlots = Slots.define({\n root: Slot.make({ capability: Capability.Container }),\n label: Slot.make({ capability: Capability.Base }),\n description: Slot.make({ capability: Capability.Base }),\n error: Slot.make({ capability: Capability.Base }),\n /** Says the key's check is running, while it runs. The control names it in `aria-describedby`. */\n checking: Slot.make({ capability: Capability.Base }),\n text: Slot.make(textual),\n multiline: Slot.make(textual),\n number: Slot.make(textual),\n toggle: Slot.make({\n capability: Capability.Interactive,\n events: [Event.Click, Event.Blur],\n attributes: [Attr.AriaInvalid, Attr.AriaDescribedby],\n }),\n /** A `Select`, and a `RelationOne` picker. */\n select: Slot.make({\n capability: Capability.Focusable,\n events: [Event.Change, Event.Blur],\n attributes: [Attr.AriaInvalid, Attr.AriaDescribedby],\n }),\n /** One choice of a `select`. */\n option: Slot.make({ capability: Capability.Base }),\n /** Around the view of a control backed by a Bundle, when it is drawn with the Bundle's own view. */\n control: Slot.make({ capability: Capability.Container }),\n /** Around a control and its affixes, such as an address's prefix and its input. */\n group: Slot.make({ capability: Capability.Container }),\n /** Text beside a control, before or after it: a prefix, or a unit. */\n affix: Slot.make({ capability: Capability.Base }),\n /** A `RelationMany` picker: the group, and each thing in it. */\n choices: Slot.make({ capability: Capability.Collection }),\n choice: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n /** Around one choice's checkbox and its words. */\n choiceLabel: Slot.make({ capability: Capability.Base }),\n /** Over a relation picker that searches: where the user types to find a choice. */\n search: Slot.make({ capability: Capability.TextInput, events: [Event.Input] }),\n /** Under a relation picker whose list has more rows: asks for them. */\n more: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n})\n\n/** The form around its fields. */\nexport const FormSlots = Slots.define({\n root: Slot.make({ capability: Capability.Container, events: [Event.Submit] }),\n /** Failures that belong to no one field: a rule that spans keys. */\n errors: Slot.make({ capability: Capability.Base }),\n /**\n * Why the write the last submit started did not land (`failure`): a refusal\n * that names no key, or a failure a submit sends again. Above the submit button.\n */\n failure: Slot.make({ capability: Capability.Base }),\n /**\n * The fields to fix, after a submit while any is invalid, in a form of more\n * than one control: its words (`summaryTitle`), then a list (`issues`) of\n * `issue`s, each holding an `issueLink` to one field's control. Beside\n * `errors`, above the submit button. It is the alert for those failures.\n */\n summary: Slot.make({ capability: Capability.Container }),\n summaryTitle: Slot.make({ capability: Capability.Base }),\n issues: Slot.make({ capability: Capability.Collection }),\n issue: Slot.make({ capability: Capability.Base }),\n /** A link to one field's control, which a press focuses. */\n issueLink: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n submit: Slot.make({\n capability: Capability.Interactive,\n events: [Event.Click],\n attributes: [Attr.Disabled, Attr.AriaDisabled],\n }),\n /** A nested key: the group around its rows, its name, each row, and the buttons that add and remove one. */\n group: Slot.make({ capability: Capability.Container }),\n legend: Slot.make({ capability: Capability.Base }),\n row: Slot.make({ capability: Capability.Container }),\n add: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n remove: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n})\n\n/** The parts of a `Form.make` result the view reads. */\ninterface FormLike<\n Key extends string,\n Model,\n Message,\n ControlKey extends string = never,\n PickerKey extends string = never,\n> {\n /** Every key, nested ones too; `Key` is the keys that hold a draft. */\n readonly controls: ReadonlyArray<FormControl>\n readonly field: (model: Model, key: Key) => FieldValidation.Field<Draft>\n /** A key edited by a control backed by a Bundle. A form with none takes no key here. */\n readonly control: (key: ControlKey) => {\n readonly field: (model: Model) => FieldValidation.Field<unknown>\n }\n /** The rows of a nested key. A form with none takes no key here. */\n readonly rows: (model: Model, key: never) => ReadonlyArray<FormRow>\n readonly search: (model: Model, key: Key) => string\n readonly isFollowing: (model: Model, key: Key) => boolean\n readonly canSubmit: (model: Model) => boolean\n readonly attempted: (model: Model) => boolean\n readonly Message: {\n /** The union, so `Message` is inferred from it and not from one constructor's case. */\n readonly Type: Message\n readonly Changed: (payload: { readonly key: Key; readonly value: Draft }) => NoInfer<Message>\n readonly Blurred: (payload: { readonly key: Key }) => NoInfer<Message>\n readonly Searched: (payload: { readonly key: Key; readonly text: string }) => NoInfer<Message>\n readonly Toggled: (payload: { readonly key: Key; readonly choice?: string }) => NoInfer<Message>\n readonly Submitted: () => NoInfer<Message>\n readonly FollowedIssue: (payload: { readonly id: string }) => NoInfer<Message>\n /** Only a relation picker asks, so its key is one of those: what `more` is keyed by. */\n readonly AskedForMore: (payload: { readonly key: PickerKey }) => NoInfer<Message>\n readonly Control: (payload: {\n readonly key: never\n readonly message: unknown\n }) => NoInfer<Message>\n readonly Nested: (payload: {\n readonly key: string\n readonly row: string\n readonly message: unknown\n }) => NoInfer<Message>\n readonly RowAdded: (payload: { readonly key: string }) => NoInfer<Message>\n readonly RowRemoved: (payload: {\n readonly key: string\n readonly row: string\n }) => NoInfer<Message>\n }\n}\n\n/**\n * A form or a row of one, as the view walks it: what to draw, and how each\n * Message leaves. A row's Messages leave wrapped, once per form they pass through.\n */\ninterface Walk<Message> {\n readonly controls: ReadonlyArray<FormControl>\n readonly field: (key: string) => FieldValidation.Field<Draft>\n /** The state of a key edited by a control backed by a Bundle, its Model as the value. */\n readonly controlField: (key: string) => FieldValidation.Field<unknown>\n readonly rows: (key: string) => ReadonlyArray<FormRow>\n readonly search: (key: string) => string\n readonly following: (key: string) => boolean\n readonly wrap: (message: unknown) => Message\n readonly make: NestedForm['Message']\n}\n\nconst rowWalk = <Message>(\n parent: Walk<Message>,\n key: string,\n row: FormRow,\n form: NestedForm,\n): Walk<Message> => ({\n controls: form.controls as ReadonlyArray<FormControl>,\n field: inner =>\n (form.field as (model: unknown, key: string) => FieldValidation.Field<Draft>)(row.model, inner),\n controlField: inner =>\n (\n form.control as (key: string) => {\n readonly field: (model: unknown) => FieldValidation.Field<unknown>\n }\n )(inner).field(row.model),\n rows: inner =>\n (form.rows as (model: unknown, key: string) => ReadonlyArray<FormRow>)(row.model, inner),\n search: inner => (form.search as (model: unknown, key: string) => string)(row.model, inner),\n following: inner =>\n (form.isFollowing as (model: unknown, key: string) => boolean)(row.model, inner),\n wrap: message =>\n parent.wrap(\n (parent.make.Nested as (payload: object) => unknown)({ key, row: row.id, message }),\n ),\n make: form.Message,\n})\n\ntype FieldView<Key extends string, Message> = SlotView.SlotView<\n typeof FieldSlots,\n FieldInput<Key>,\n Message\n>\n\nconst errorsOf = (field: FieldValidation.Field<unknown>): ReadonlyArray<string> =>\n Match.valueTags(field, {\n Invalid: ({ errors }) => errors,\n NotValidated: () => [],\n Validating: () => [],\n Valid: () => [],\n })\n\n/**\n * The state of a key a control backed by a Bundle edits, as a field is drawn:\n * its validation state, with no draft. The Bundle's Model travels as `bundle`.\n */\nconst withoutDraft = (field: FieldValidation.Field<unknown>): FieldValidation.Field<Draft> =>\n Match.valueTags(field, {\n Invalid: ({ errors }) => FieldValidation.Invalid({ value: '', errors }),\n Valid: () => FieldValidation.Valid({ value: '' }),\n Validating: () => FieldValidation.Validating({ value: '' }),\n NotValidated: () => FieldValidation.NotValidated({ value: '' }),\n })\n\n/** What a renderer draws one control from. */\nexport interface RenderContext<Message> {\n readonly input: FieldInput\n /** The control, whose `data` is its kind's: narrow it with the kind's `is`. */\n readonly control: Control\n readonly draft: Draft\n readonly change: (value: Draft) => Message\n /**\n * A press on a flag (no `choice`) or on one choice of a list, applied to the\n * draft as it stands when it lands: send it for a press, rather than a\n * `change` built from the draft as drawn, which a second press before the\n * next draw would undo.\n */\n readonly toggled: (choice?: string) => Message\n readonly blurred: Message\n /**\n * For a control backed by a Bundle: its Model, and the Message carrying one of\n * its own. Its `draft` is `''`.\n */\n readonly bundle:\n | {\n readonly model: unknown\n readonly send: (message: unknown) => Message\n /** The inputs its view is drawn with: the form view's `controls` entry for this key. */\n readonly viewInputs: unknown\n }\n | undefined\n /**\n * The control's id and its accessibility state. Put them on the element that\n * holds the value: no `InnerHTML`, so a textarea takes them too.\n */\n readonly state: ReadonlyArray<Exclude<Attribute<Message>, { readonly _tag: 'InnerHTML' }>>\n /** What the key's element takes beyond the base field view. */\n readonly attrs: FieldAttrs\n readonly slots: SlotBuilders<typeof FieldSlots, Message>\n readonly h: HtmlBuilder<Message>\n}\n\n/** Draws the control of one kind. The label, description and error around it are the field's. */\nexport type Renderer<Message> = (context: RenderContext<Message>) => Html\n\n/**\n * A control backed by a Bundle that no renderer names is drawn with the\n * Bundle's own view, inside the field's `control` slot, which carries the\n * control's id and accessibility state. A Bundle with no view needs a renderer.\n */\nconst bundleRenderer =\n <Message>(control: Control): Renderer<Message> =>\n ({ bundle, input, state, slots, h }) => {\n const view = Input.isBundle(control) ? control.data.bundle.view : undefined\n if (bundle === undefined || view === undefined)\n throw new Error(\n `FormView: the \"${control.kind}\" control (\"${input.control.key}\") has no view; pass a renderer under \"renderers\"`,\n )\n const drawn = h.submodel(\n bundle.viewInputs === undefined\n ? { slotId: input.id, model: bundle.model, view, toParentMessage: bundle.send }\n : // A Bundle's view takes the inputs its application gives it in `controls`,\n // whose type the form cannot know. A view given inputs is called with them.\n ({\n slotId: input.id,\n model: bundle.model,\n view,\n toParentMessage: bundle.send,\n viewInputs: bundle.viewInputs,\n } as Parameters<typeof h.submodel>[0]),\n )\n // The label's `for` names this div, which labels nothing: as a group named by\n // the label, the controls the Bundle draws inside are announced under it.\n // `disabled` on the div disables nothing inside it; a disabled fieldset\n // disables every button and input the Bundle draws, and draws no box of its own.\n return h.div(\n slots.control.attrs([\n ...state.filter(attribute => attribute._tag !== 'Name'),\n h.Role('group'),\n h.AriaLabelledBy(`${input.id}-label`),\n ]),\n [\n input.locked === true\n ? h.fieldset([h.Disabled(true), h.Style({ display: 'contents' })], [drawn])\n : drawn,\n ],\n )\n }\n\n/** Renderers by the `kind` of control they draw. */\nexport type Renderers<Message> = Readonly<Record<string, Renderer<Message>>>\n\n/**\n * What a per-key override receives: everything to draw the control, and the\n * Messages that leave it, in the form's own universe. The `h` an override\n * draws with stays the caller's: the whole-form view's, or a custom layout's.\n */\nexport interface FieldOverrideInput<Key extends string = string, Changed = unknown> {\n readonly control: FormControl<Key>\n readonly field: FieldValidation.Field<Draft>\n readonly id: string\n readonly invalid: boolean\n readonly errors: ReadonlyArray<string>\n readonly changed: (value: Draft) => Changed\n /**\n * A press on a flag (no `choice`) or one choice, applied to the draft as it\n * lands: send it for a press, so two before the next draw both count.\n */\n readonly toggled: (choice?: string) => Changed\n readonly blurred: Changed\n /** What the key's element takes beyond the base field view. */\n readonly attrs: FieldAttrs\n}\n\n/**\n * Draws one key's control, for a layout the base field view does not own.\n * `Changed` is the form's Message; `Message` the universe of the `h` that\n * draws, which is the form's in the whole-form view and the application's\n * in a custom layout.\n */\nexport type FieldOverride<Key extends string = string, Changed = unknown, Message = unknown> = (\n input: FieldOverrideInput<Key, Changed>,\n h: HtmlBuilder<Message>,\n) => Html\n\n/**\n * What one key's element takes beyond the base field view: an HTML input\n * type, a placeholder, a textarea's rows, and what a phone's keyboard and the\n * browser's autofill should offer. A renderer reads what fits its element and\n * ignores the rest.\n */\nexport interface FieldAttrs {\n readonly type?: string | undefined\n readonly placeholder?: string | undefined\n readonly rows?: number | undefined\n /** What the browser may fill in: `email`, `name`, `street-address`, `one-time-code`, `off`. */\n readonly autocomplete?: string | undefined\n /** The keypad a phone shows: `numeric`, `decimal`, `tel`, `email`, `url`, `search`, `text`. A number field is `decimal` unless this says otherwise. */\n readonly inputMode?: string | undefined\n /** What a phone keyboard's Enter key says: `next`, `done`, `go`, `search`, `send`. */\n readonly enterKeyHint?: string | undefined\n /** `none`, `sentences`, `words`, `characters`. Off by default for an `email`, `tel` or `url` type. */\n readonly autocapitalize?: string | undefined\n /** Off by default for an `email`, `tel` or `url` type, where a correction is a wrong address. */\n readonly spellcheck?: boolean | undefined\n}\n\n/**\n * Per-key overrides for `FormView.fields`. `overrides` draw through the\n * whole-form view; `styles` style one key's base field view there. Unknown\n * keys in either are type errors. A custom layout passes its override to\n * `field` itself, with its own `h`.\n */\nexport interface FieldsOptions<Key extends string, Changed> {\n /** A key drawn by this instead of the base field view (or its styled one). */\n readonly overrides?: { readonly [K in Key]?: FieldOverride<Key, Changed, Changed> } | undefined\n /** A style around a key's base field view, kept for keys with no override. */\n readonly styles?: { readonly [K in Key]?: NamedStyle<typeof FieldSlots> } | undefined\n /**\n * What one key's element takes beyond the base field view. The text,\n * multiline, and number renderers read them for a base field view, and a\n * per-key override is handed them as its own `attrs` too, so it decides what\n * to do with them; a bundle-backed kind drawn by `bundleRenderer` reads none.\n * Passing `field` draws through the base view directly, skipping both\n * `renderers` and `attrs`.\n */\n readonly attrs?: { readonly [K in Key]?: FieldAttrs } | undefined\n}\n\n/**\n * One flat key's control, for a layout the caller owns: through the base\n * field view with a form-universe `h`, or through the override it is given,\n * with any `h`. A call with neither a form `h` nor an override is a type\n * error, since the base view's Messages are the form's own.\n */\nexport interface FieldsField<\n Key extends string,\n Model,\n FormMessage extends { readonly _tag: string },\n> {\n (\n control: FormControl<Key>,\n model: Model,\n id: string,\n h: HtmlBuilder<FormMessage>,\n override?: FieldOverride<Key, FormMessage, FormMessage>,\n ): Html\n <Message>(\n control: FormControl<Key>,\n model: Model,\n id: string,\n h: HtmlBuilder<Message>,\n override: FieldOverride<Key, FormMessage, Message>,\n ): Html\n}\n\n/** The Messages of one key, through its row's send or the form's own. */\nconst changedOf =\n <Key extends string, Model, Message>(\n form: FormLike<Key, Model, Message>,\n key: Key,\n send: FieldInput<Key>['send'],\n ): ((value: Draft) => Message) =>\n value =>\n (send === undefined ? form.Message.Changed({ key, value }) : send.changed(value)) as Message\n\n/** The press Message of one key, through its row's send or the form's own. */\nconst toggledOf =\n <Key extends string, Model, Message>(\n form: FormLike<Key, Model, Message>,\n key: Key,\n send: FieldInput<Key>['send'],\n ): ((choice?: string) => Message) =>\n choice =>\n (send === undefined\n ? form.Message.Toggled(choice === undefined ? { key } : { key, choice })\n : send.toggled(choice)) as Message\n\n/** The blur Message of one key, through its row's send or the form's own. */\nconst blurredOf = <Key extends string, Model, Message>(\n form: FormLike<Key, Model, Message>,\n key: Key,\n send: FieldInput<Key>['send'],\n): Message => (send === undefined ? form.Message.Blurred({ key }) : send.blurred) as Message\n\n/** The view of one field, to style or extend before handing it to `FormView.define`. */\nconst field = <Key extends string, Model, Message extends { readonly _tag: string }>(\n form: FormLike<Key, Model, Message>,\n options: {\n /** Renderers by kind, beside the ones shipped: a new kind, or another way to draw a shipped one. */\n readonly renderers?: Renderers<Message>\n /** What one key's element takes beyond the base field view. */\n readonly attrs?: { readonly [K in Key]?: FieldAttrs }\n } = {},\n): FieldView<Key, Message> => {\n // No prototype: a kind named `constructor` or `toString` has a renderer only if given one.\n const renderers: Renderers<Message> = Object.assign(\n Object.create(null),\n plainRenderers<Message>(),\n options.renderers,\n )\n return SlotView.forMessages<Message>().define(\n FieldSlots,\n (input: FieldInput<Key>, slots, h) => {\n const { control, id, invalid } = input\n const { key, label, description, required } = control\n const draft = input.field.value\n const { send } = input\n const change = changedOf(form, key, send)\n const blurred = blurredOf(form, key, send)\n const toggled = toggledOf(form, key, send)\n const searched = (text: string): Message =>\n send === undefined ? form.Message.Searched({ key, text }) : (send.searched(text) as Message)\n const searches = control.control.searches\n // A check is running: the control is neither valid nor invalid yet.\n const checking = input.field._tag === 'Validating'\n // A Bundle's control says its own state (an upload's \"Sending\"), so the\n // field adds no second live line for it; it is still marked busy.\n const saysChecking = checking && input.bundle === undefined\n const describedBy = [\n ...(description === undefined ? [] : [`${id}-description`]),\n ...(saysChecking ? [`${id}-checking`] : []),\n ...(invalid ? [`${id}-error`] : []),\n ]\n const state = [\n h.Id(id),\n // The key is the field's name, so a form posts its drafts with scripts off.\n h.Name(key),\n h.AriaInvalid(invalid),\n ...(checking ? [h.AriaBusy(true)] : []),\n ...(required ? [h.AriaRequired(true)] : []),\n ...(describedBy.length === 0 ? [] : [h.AriaDescribedBy(describedBy.join(' '))]),\n ...(input.locked === true ? [h.Disabled(true)] : []),\n ]\n // The Message leaves the way the input says: wrapped for a row, or the form's own.\n const held = input.bundle\n const bundle =\n held === undefined\n ? undefined\n : {\n model: held.model,\n send: (message: unknown) => held.send(message) as Message,\n viewInputs: held.viewInputs,\n }\n const render =\n renderers[control.control.kind] ??\n (bundle !== undefined ? bundleRenderer<Message>(control.control) : undefined)\n if (render === undefined)\n throw new Error(\n `FormView: no renderer for a \"${control.control.kind}\" control (\"${key}\"); pass one under \"renderers\"`,\n )\n const body = render({\n input: input as FieldInput,\n control: control.control,\n draft,\n change,\n toggled,\n blurred,\n bundle,\n state,\n attrs: options.attrs?.[key] ?? {},\n slots,\n h,\n })\n\n // The field's state by Foldkit's own tag, for a stylesheet: `[data-validation='Valid']`.\n return h.div(slots.root.attrs([h.DataAttribute('validation', input.field._tag)]), [\n h.label(slots.label.attrs([h.Id(`${id}-label`), h.For(id)]), [label]),\n // Typing here changes which choices the picker below is offered.\n ...(searches\n ? [\n h.input(\n slots.search.attrs([\n h.Id(`${id}-search`),\n h.Type('search'),\n h.AriaLabel(`${input.searchWord ?? 'Search'} ${label}`),\n h.AriaControls(id),\n h.Value(input.search),\n h.OnInput(searched),\n ]),\n ),\n ]\n : []),\n body,\n ...(input.more === undefined\n ? []\n : [\n h.button(\n slots.more.attrs([\n h.Type('button'),\n h.AriaControls(id),\n h.OnClick(input.more as Message),\n ]),\n [input.moreWord ?? 'Show more'],\n ),\n ]),\n // A disabled control is left out of a post, so a locked key's value goes\n // as hidden inputs: a form posted with scripts off still carries it.\n // Attributes, not properties, so a server's markup holds them.\n ...(input.locked === true\n ? posted(draft).map(value =>\n h.input([\n h.Attribute('type', 'hidden'),\n h.Attribute('name', key),\n h.Attribute('value', value),\n ]),\n )\n : []),\n ...(description === undefined\n ? []\n : [h.p(slots.description.attrs([h.Id(`${id}-description`)]), [description])]),\n ...(saysChecking\n ? [\n h.p(slots.checking.attrs([h.Id(`${id}-checking`), h.Role('status')]), [\n input.checkingWord ?? 'Checking…',\n ]),\n ]\n : []),\n ...(invalid\n ? [\n h.p(\n slots.error.attrs([\n h.Id(`${id}-error`),\n ...(input.quiet === true ? [] : [h.Role('alert')]),\n ]),\n [...input.errors],\n ),\n ]\n : []),\n ])\n },\n { name: 'FormField' },\n )\n}\n\n/**\n * The control drawn with this id, or the first one inside it, such as a choice\n * group's first box. The id is quoted, since it may hold what a selector reads\n * as syntax.\n */\nconst controlAt = (id: string): string => {\n const at = `[id=${JSON.stringify(id)}]`\n const control = ':is(input, select, textarea, button)'\n return `${at}${control}, ${at} ${control}`\n}\n\n/**\n * What a draft posts as: its text, each of its values, `on` for a checked box\n * (a checkbox's own default), or nothing for an unchecked one or a control's\n * own Model.\n */\nconst posted = (draft: unknown): ReadonlyArray<string> => {\n if (typeof draft === 'string') return [draft]\n if (typeof draft === 'boolean') return draft ? ['on'] : []\n return Array.isArray(draft) ? draft.map(String) : []\n}\n\nexport const FormView = {\n field,\n\n /**\n * The view of the whole form: each control through `field`, in the input's\n * order, a hidden key left out. Pass a styled `field` to change how fields\n * look; attach Style and Behavior to the result to change the form around them.\n */\n define: <\n Key extends string,\n Model,\n Message extends { readonly _tag: string },\n ControlKey extends string = never,\n PickerKey extends string = never,\n >(\n form: FormLike<Key, Model, Message, ControlKey, PickerKey> & {\n readonly bundle: { readonly name: string }\n },\n options: {\n readonly field?: FieldView<Key, Message>\n /** Renderers by kind, for the field view this makes. With `field` given, give them to `FormView.field`. */\n readonly renderers?: Renderers<Message>\n } = {},\n ): SlotView.SlotView<typeof FormSlots, FormInput<Model, Key, ControlKey, PickerKey>, Message> => {\n const fieldView =\n options.field ??\n field(form, options.renderers === undefined ? {} : { renderers: options.renderers })\n type Make = (payload: object) => unknown\n return SlotView.forMessages<Message>().define(\n FormSlots,\n (input: FormInput<Model, Key, ControlKey, PickerKey>, slots, h) => {\n const options: Readonly<Record<string, ReadonlyArray<Option> | undefined>> = {\n ...input.nestedOptions,\n ...input.options,\n }\n const controls: Readonly<Record<string, unknown>> = input.controls ?? {}\n const locked: ReadonlySet<string> = new Set(input.locked ?? [])\n const more: Readonly<Record<string, boolean | undefined>> = input.more ?? {}\n\n // The list of fields to fix belongs to a submit, and a form of one\n // control has nothing to navigate between: its error is the summary.\n // A nested key's rows hold fields of their own.\n const shown = form.controls.filter(control => control.control.shown)\n const listed =\n form.attempted(input.model) &&\n (shown.length > 1 || shown.some(control => Input.Nested.is(control.control)))\n\n // Each invalid field, in the order drawn, for the summary.\n const issues: Array<{\n readonly id: string\n readonly label: string\n readonly error: string\n }> = []\n\n /** The controls of a form or of a row. `id` and `path` say where: both are empty for the form itself. */\n /** `within` names the row being drawn, for its issues; none for the form itself. */\n const draw = (\n walk: Walk<Message>,\n id: string,\n path: string,\n within: Maybe.Option<string> = Maybe.none(),\n ): ReadonlyArray<Html> =>\n walk.controls\n .filter(control => control.control.shown)\n .map((control): Html => {\n const { key, label } = control\n const here = `${id}-${key}`\n if (!Input.Nested.is(control.control)) {\n const bundled = Input.isBundle(control.control)\n const held = bundled ? walk.controlField(key) : walk.field(key)\n const state = bundled ? withoutDraft(held) : (held as FieldValidation.Field<Draft>)\n if (FieldValidation.isInvalid(state))\n issues.push({\n id: here,\n label: Maybe.match(within, {\n onNone: () => label,\n onSome: named =>\n fillWords(input.words?.inRow ?? '{row}, {label}', { row: named, label }),\n }),\n error: errorsOf(state).join(' '),\n })\n return fieldView(\n {\n control: control as FormControl<Key>,\n field: state,\n bundle: bundled\n ? {\n model: held.value,\n send: message => walk.wrap((walk.make.Control as Make)({ key, message })),\n viewInputs: controls[`${path}${key}`],\n }\n : undefined,\n invalid: FieldValidation.isInvalid(state),\n errors: errorsOf(state),\n options: options[`${path}${key}`] ?? [],\n id: here,\n search: walk.search(key),\n following: walk.following(key),\n locked: path === '' && locked.has(key),\n searchWord: input.words?.search,\n noneWord: input.words?.none,\n checkingWord: input.words?.checking,\n quiet: listed,\n // Only the form's own pickers, and only while they can be used: a\n // row's are named by path, and a locked key takes no choice.\n more:\n path === '' &&\n more[key] === true &&\n !locked.has(key) &&\n (Input.RelationOne.is(control.control) ||\n Input.RelationMany.is(control.control))\n ? form.Message.AskedForMore({ key: key as PickerKey })\n : undefined,\n moreWord: input.words?.more,\n send: {\n changed: value => walk.wrap((walk.make.Changed as Make)({ key, value })),\n blurred: walk.wrap((walk.make.Blurred as Make)({ key })),\n searched: text => walk.wrap((walk.make.Searched as Make)({ key, text })),\n toggled: choice =>\n walk.wrap(\n (walk.make.Toggled as Make)(\n choice === undefined ? { key } : { key, choice },\n ),\n ),\n },\n },\n h,\n )\n }\n const { form: nested, cardinality, optional } = control.control.data\n const rowName = (index: number) =>\n cardinality === 'many' ? `${label} ${index + 1}` : label\n const rows = walk.rows(key)\n const addLabel = fillWords(input.words?.add ?? 'Add {label}', { label })\n return h.fieldset(slots.group.attrs([h.Id(here)]), [\n h.legend(slots.legend.attrs(), [label]),\n ...rows.map((row, index) =>\n h.div(slots.row.attrs([h.Id(`${here}-${row.id}`)]), [\n ...draw(\n rowWalk(walk, key, row, nested),\n `${here}-${row.id}`,\n `${path}${key}.`,\n // Named through every row it is in: `authors 1, books 2`.\n Maybe.some(\n Maybe.match(within, {\n onNone: () => rowName(index),\n onSome: outer => `${outer}, ${rowName(index)}`,\n }),\n ),\n ),\n // A row that must be there has no way out.\n ...(optional\n ? [\n h.button(\n slots.remove.attrs([\n h.Type('button'),\n h.OnClick(\n walk.wrap((walk.make.RowRemoved as Make)({ key, row: row.id })),\n ),\n ]),\n [\n fillWords(input.words?.remove ?? 'Remove {label} {position}', {\n label,\n position: index + 1,\n }),\n ],\n ),\n ]\n : []),\n ]),\n ),\n // A `one` takes one row: the way in goes once it is there.\n ...(cardinality === 'many' || rows.length === 0\n ? [\n h.button(\n slots.add.attrs([\n h.Type('button'),\n h.OnClick(walk.wrap((walk.make.RowAdded as Make)({ key }))),\n ]),\n [addLabel],\n ),\n ]\n : []),\n ])\n })\n\n const top: Walk<Message> = {\n controls: form.controls,\n field: key => form.field(input.model, key as Key),\n controlField: key => form.control(key as never).field(input.model),\n rows: key => form.rows(input.model, key as never),\n search: key => form.search(input.model, key as Key),\n following: key => form.isFollowing(input.model, key as Key),\n wrap: message => message as Message,\n make: form.Message as unknown as NestedForm['Message'],\n }\n const submitting = input.submitting === true\n const fields = draw(top, form.bundle.name, '')\n return h.form(\n slots.root.attrs([\n h.OnSubmit(form.Message.Submitted()),\n ...(submitting ? [h.AriaBusy(true), h.DataAttribute('submitting', '')] : []),\n ]),\n [\n ...fields,\n ...(!listed || issues.length === 0\n ? []\n : [\n // No id of its own: a key named `summary` would hold it already.\n // It announces the submit's failures once, for every field.\n h.div(slots.summary.attrs([h.Role('alert')]), [\n h.p(slots.summaryTitle.attrs(), [\n input.words?.summary ?? 'Check these fields:',\n ]),\n h.ul(\n slots.issues.attrs(),\n issues.map(issue =>\n h.li(slots.issue.attrs(), [\n // A link, so with scripts off it still goes to the field.\n // With them on, the press focuses the control itself and\n // goes nowhere, since an application takes a link as a\n // navigation.\n h.a(\n slots.issueLink.attrs([\n h.Href(`#${issue.id}`),\n h.OnClick(form.Message.FollowedIssue({ id: issue.id }), {\n defaultAction: 'Prevent',\n focusSelector: controlAt(issue.id),\n }),\n ]),\n [\n fillWords(input.words?.issue ?? '{label}: {error}', {\n label: issue.label,\n error: issue.error,\n }),\n ],\n ),\n ]),\n ),\n ),\n ]),\n ]),\n ...(input.errors.length === 0\n ? []\n : [h.p(slots.errors.attrs([h.Role('alert')]), [...input.errors])]),\n ...(input.failure === undefined\n ? []\n : [h.p(slots.failure.attrs([h.Role('alert')]), [input.failure.error])]),\n ...(input.submits === false\n ? []\n : [\n h.button(\n slots.submit.attrs([\n h.Type('submit'),\n // Never natively `disabled`: the browser submits through the\n // form's default button only if it is enabled, so an Enter sent\n // before the frame that enables it was dropped silently, and a\n // disabled button also drops the focus a press gave it. It\n // reads `aria-disabled` instead, and `update` decides from the\n // Model: a submit the form cannot take marks every key and shows\n // why, a valid one goes through.\n ...(!input.canSubmit || submitting ? [h.AriaDisabled(true)] : []),\n ]),\n [\n submitting\n ? (input.words?.submitting ?? 'Submitting…')\n : input.failure?.retry === true\n ? (input.words?.resubmit ?? 'Try again')\n : (input.words?.submit ?? 'Submit'),\n ],\n ),\n ]),\n ],\n )\n },\n { name: form.bundle.name },\n )\n },\n\n /**\n * The whole form, as `define` draws it, with per-key overrides; and one flat\n * key's control, for a layout the caller owns. Keys with no override render\n * through the base field view (a new key of a known kind needs nothing new),\n * each through its style when one is given and with its element attrs. `field`\n * draws through the base view with a form-universe `h`, or through the\n * override it is given, with any `h`. Nested keys and Bundle-backed keys draw\n * only through `view` (or an override); `field` without one refuses them,\n * naming the key.\n */\n fields: <\n Key extends string,\n Model,\n FormMessage extends { readonly _tag: string },\n ControlKey extends string = never,\n PickerKey extends string = never,\n >(\n form: FormLike<Key, Model, FormMessage, ControlKey, PickerKey> & {\n readonly bundle: { readonly name: string }\n },\n options: {\n readonly field?: FieldView<Key, FormMessage>\n /** Renderers by kind, for the field views this makes. */\n readonly renderers?: Renderers<FormMessage>\n } & FieldsOptions<Key, FormMessage> = {},\n ): {\n readonly view: SlotView.SlotView<\n typeof FormSlots,\n FormInput<Model, Key, ControlKey, PickerKey>,\n FormMessage\n >\n readonly field: FieldsField<Key, Model, FormMessage>\n } => {\n const base =\n options.field ??\n field(\n form,\n options.renderers === undefined && options.attrs === undefined\n ? {}\n : {\n ...(options.renderers === undefined ? {} : { renderers: options.renderers }),\n ...(options.attrs === undefined ? {} : { attrs: options.attrs }),\n },\n )\n const styled = new Map<Key, FieldView<Key, FormMessage>>()\n const viewOf = (key: Key): FieldView<Key, FormMessage> => {\n const known = styled.get(key)\n if (known !== undefined) return known\n const style = options.styles?.[key]\n const made = style === undefined ? base : Style.attach(style)(base)\n styled.set(key, made)\n return made\n }\n const drawn = (input: FieldInput<Key>, h: HtmlBuilder<FormMessage>): Html => {\n const override = options.overrides?.[input.control.key]\n if (override === undefined) return viewOf(input.control.key)(input, h)\n return override(\n {\n control: input.control,\n field: input.field,\n id: input.id,\n invalid: input.invalid,\n errors: input.errors,\n changed: changedOf(form, input.control.key, input.send),\n toggled: toggledOf(form, input.control.key, input.send),\n blurred: blurredOf(form, input.control.key, input.send),\n attrs: options.attrs?.[input.control.key] ?? {},\n },\n h,\n )\n }\n return {\n view: FormView.define(form, {\n field: SlotView.forMessages<FormMessage>().define(\n FieldSlots,\n (input: FieldInput<Key>, _slots, h) => drawn(input, h),\n { name: `${form.bundle.name}Fields` },\n ),\n }),\n field: (<M>(\n control: FormControl<Key>,\n model: Model,\n id: string,\n h: HtmlBuilder<M> | HtmlBuilder<FormMessage>,\n override?: FieldOverride<Key, FormMessage, M>,\n ): Html => {\n const state = form.field(model, control.key)\n if (override !== undefined)\n return override(\n {\n control,\n field: state,\n id,\n invalid: FieldValidation.isInvalid(state),\n errors: errorsOf(state),\n changed: value => form.Message.Changed({ key: control.key, value }),\n toggled: toggledOf(form, control.key, undefined),\n blurred: form.Message.Blurred({ key: control.key }),\n attrs: options.attrs?.[control.key] ?? {},\n },\n h as HtmlBuilder<M>,\n )\n if (Input.Nested.is(control.control) || Input.isBundle(control.control))\n throw new Error(\n `FormView.fields: \"${control.key}\" nests rows or a Bundle; draw it with the whole-form view, or give an override for it`,\n )\n return viewOf(control.key)(\n {\n control,\n field: state,\n bundle: undefined,\n invalid: FieldValidation.isInvalid(state),\n errors: errorsOf(state),\n options: [],\n id,\n search: form.search(model, control.key),\n following: form.isFollowing(model, control.key),\n },\n h as HtmlBuilder<FormMessage>,\n )\n }) as FieldsField<Key, Model, FormMessage>,\n }\n },\n\n /**\n * For `Bundle.withView`: the Submodel view that draws `view`, so a placement\n * renders the form with `placed.view(model, h, { options })`.\n *\n * ```ts\n * const Drawn = EditPost.bundle.pipe(Bundle.withView(FormView.submodel(EditPost, View)))\n * ```\n */\n submodel: <\n Key extends string,\n Model extends { readonly errors: ReadonlyArray<string>; readonly submitPending: boolean },\n Message extends { readonly _tag: string },\n ControlKey extends string = never,\n PickerKey extends string = never,\n >(\n form: FormLike<Key, Model, Message, ControlKey, PickerKey>,\n view: SlotView.SlotView<\n typeof FormSlots,\n FormInput<Model, Key, ControlKey, PickerKey>,\n Message\n >,\n options: {\n /**\n * When the button reads `aria-disabled`. It marks the button and nothing\n * more: `update` decides every submit from the Model. Default\n * `form.canSubmit`, which follows the form's `submitWaits`: with the\n * default `true` a submit made mid-check waits for the answer and the\n * button stays enabled; with `false` the form refuses it and the button\n * reads disabled through the check. Pass `() => true` to never mark it and\n * validate wholly at submit.\n */\n readonly canSubmit?: (model: Model) => boolean\n } = {},\n ): Submodel.View<Model, Message, FormViewInputs<Key, ControlKey, PickerKey>> =>\n Submodel.defineView<Model, Message, FormViewInputs<Key, ControlKey, PickerKey>>(\n (model, inputs, h) =>\n view(\n {\n ...inputs,\n model,\n errors: model.errors,\n canSubmit: (options.canSubmit ?? form.canSubmit)(model),\n submitting: model.submitPending || inputs.submitting === true,\n },\n h,\n ),\n ),\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAa,kBAAkB,aAC5B,MAAM,OAAO,GAAG,OAAO,KAAK,MAAM,QAAQ,GAAG,OAAO,IAAI,QAAQ,KAAK,UAAU,CAAC,EAAA,CAAG,KAClF,YAAW;CAAE,OAAO,OAAO,MAAM;CAAG,OAAO,OAAO,MAAM;AAAE,EAC5D;;AAGF,MAAa,gCAAqC,IAAI,IAAI;CAAC;CAAS;CAAO;AAAK,CAAC;;;;;;AAOjF,MAAa,cACX,SACA,WAC0B;CAC1B,MAAM,QAAQ,IAAI,IAAI,QAAQ,KAAI,WAAU,OAAO,KAAK,CAAC;CACzD,OAAO,CACL,GAAG,SACH,GAAG,OACA,QAAO,U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OAAO,OAAO,QAAQ,GAAG,CAAC,CACxB;KACE;KACA,OAAO;KACP,QAAQ,KAAA;KACR,SAAS,gBAAgB,UAAU,KAAK;KACxC,QAAQ,SAAS,KAAK;KACtB,SAAS,CAAC;KACV;KACA,QAAQ,KAAK,OAAO,OAAO,QAAQ,GAAG;KACtC,WAAW,KAAK,YAAY,OAAO,QAAQ,GAAG;IAChD,GACA,CACF;GACF;EACF;CACF;;;;;;;;;CAUA,WAOE,MACA,MAKA,UAWI,CAAC,MAEL,SAAS,YACN,OAAO,QAAQ,MACd,KACE;EACE,GAAG;EACH;EACA,QAAQ,MAAM;EACd,YAAY,QAAQ,aAAa,KAAK,UAAA,CAAW,KAAK;EACtD,YAAY,MAAM,iBAAiB,OAAO,eAAe;CAC3D,GACA,CACF,CACJ;AACJ"}
|
package/dist/ui.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as groupState, c as withChosen, i as chosenOf, o as literalOptions, s as plainRenderers, t as FieldSlots } from "./src-
|
|
1
|
+
import { a as groupState, c as withChosen, i as chosenOf, o as literalOptions, s as plainRenderers, t as FieldSlots } from "./src-DKt2l7dw.mjs";
|
|
2
2
|
import { Input } from "foldkit-form";
|
|
3
3
|
import { SlotView } from "foldkit-mixins";
|
|
4
4
|
import { CheckboxGroupSlots, CheckboxSlots, Input as Input$1, InputSlots, SelectSlots, Textarea, TextareaSlots } from "foldkit-mixins-ui";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-mixins-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "A foldkit-form form drawn through foldkit-mixins slots: styleable, extensible, and accessible by contract.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"LICENSE"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"foldkit-
|
|
53
|
-
"foldkit-
|
|
54
|
-
"foldkit-
|
|
52
|
+
"foldkit-bundle": "0.12.0",
|
|
53
|
+
"foldkit-form": "0.12.0",
|
|
54
|
+
"foldkit-mixins": "0.24.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"effect": "^4.1.0",
|
|
58
58
|
"foldkit": "^0.170.0",
|
|
59
|
-
"foldkit-mixins-ui": "0.
|
|
59
|
+
"foldkit-mixins-ui": "0.25.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|
|
62
62
|
"foldkit-mixins-ui": {
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"jsdom": "30.1.3",
|
|
71
71
|
"tsdown": "^0.23.1",
|
|
72
72
|
"typescript": "7.0.2",
|
|
73
|
-
"foldkit-
|
|
74
|
-
"foldkit-
|
|
73
|
+
"foldkit-entity": "0.17.0",
|
|
74
|
+
"foldkit-mixins-ui": "0.25.0"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "node ../../scripts/declarations.mjs . && tsdown && node ../../scripts/declared-any.mjs .",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"src-CwD995oQ.mjs","names":["Maybe"],"sources":["../src/renderers.ts","../src/index.ts"],"sourcesContent":["/**\n * The renderers this package ships, by kind. They live apart from the view so\n * the `/ui` entry can draw the same elements through another component's\n * Slots.\n */\nimport { Input } from 'foldkit-form'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport type { FieldAttrs, Option, RenderContext, Renderer } from './index.js'\n\n/** A renderer for every kind of control `foldkit-form` ships and shows. */\nexport type Shipped<Message> = {\n readonly [\n Kind in\n | 'Text'\n | 'Multiline'\n | 'Number'\n | 'Toggle'\n | 'Select'\n | 'RelationOne'\n | 'Choices'\n | 'RelationMany'\n ]: Renderer<Message>\n}\n\n/** What a `Select` or a `Choices` control offers: the options its schema spells out. */\nexport const literalOptions = (control: RenderContext<unknown>['control']): ReadonlyArray<Option> =>\n (Input.Select.is(control) || Input.Choices.is(control) ? control.data.options : []).map(\n option => ({ value: String(option), label: String(option) }),\n )\n\n/** Types whose text is an address or a number, which a keyboard must not capitalize or correct. */\nexport const LITERAL_TYPES: ReadonlySet<string> = new Set(['email', 'tel', 'url'])\n\n/**\n * The choices, and after them each chosen value they lack, as `? value`: a\n * stored id whose row is gone, or a value the choices have not loaded yet,\n * stays shown and can be let go, rather than dropped from sight.\n */\nexport const withChosen = (\n options: ReadonlyArray<Option>,\n chosen: ReadonlyArray<string>,\n): ReadonlyArray<Option> => {\n const known = new Set(options.map(option => option.value))\n return [\n ...options,\n ...chosen\n .filter(value => value !== '' && !known.has(value))\n .map(value => ({ value, label: `? ${value}` })),\n ]\n}\n\n/**\n * The renderers this package ships, by kind. They are entries like any other: an\n * application adds `Date`, or replaces `RelationOne` with a combobox, by passing\n * its own beside them.\n */\nexport const plainRenderers = <Message>(): Shipped<Message> => {\n const typed = ({ state, draft, change, blurred, h }: RenderContext<Message>) => [\n ...state,\n h.Value(String(draft)),\n h.OnInput(change),\n h.OnBlur(blurred),\n ]\n // A blank option whenever nothing is chosen, required or not: without one the\n // browser shows its first option as chosen while the draft is still empty.\n const pick = (\n { state, draft, change, blurred, input, slots, h }: RenderContext<Message>,\n options: ReadonlyArray<Option>,\n blank: boolean,\n ): Html =>\n h.select(slots.select.attrs([...state, h.OnChange(change), h.OnBlur(blurred)]), [\n ...(blank || draft === ''\n ? [\n h.option(slots.option.attrs([h.Value(''), h.Selected(draft === '')]), [\n input.noneWord ?? '',\n ]),\n ]\n : []),\n ...withChosen(options, typeof draft === 'string' ? [draft] : []).map(option =>\n h.option(slots.option.attrs([h.Value(option.value), h.Selected(draft === option.value)]), [\n option.label,\n ]),\n ),\n ])\n /** What a phone's keyboard and the browser's autofill should offer, from the key's attrs. */\n const keyboard = <M>({\n attrs,\n h,\n }: {\n readonly attrs: FieldAttrs\n readonly h: HtmlBuilder<M>\n }) => {\n const literal = attrs.type !== undefined && LITERAL_TYPES.has(attrs.type)\n const capitalize = attrs.autocapitalize ?? (literal ? 'none' : undefined)\n const spellcheck = attrs.spellcheck ?? (literal ? false : undefined)\n return [\n ...(attrs.autocomplete === undefined\n ? []\n : [h.Attribute('autocomplete', attrs.autocomplete)]),\n ...(attrs.enterKeyHint === undefined\n ? []\n : [h.Attribute('enterkeyhint', attrs.enterKeyHint)]),\n ...(capitalize === undefined ? [] : [h.Attribute('autocapitalize', capitalize)]),\n ...(spellcheck === undefined ? [] : [h.Attribute('spellcheck', String(spellcheck))]),\n ]\n }\n return {\n Text: context =>\n context.h.input(\n context.slots.text.attrs([\n ...typed(context),\n ...keyboard(context),\n ...(context.attrs.inputMode === undefined\n ? []\n : [context.h.InputMode(context.attrs.inputMode)]),\n context.h.Type(context.attrs.type ?? 'text'),\n ...(context.attrs.placeholder === undefined\n ? []\n : [context.h.Placeholder(context.attrs.placeholder)]),\n ]),\n ),\n Multiline: context =>\n context.h.textarea(\n context.slots.multiline.attrs([\n ...typed(context),\n ...keyboard(context),\n ...(context.attrs.placeholder === undefined\n ? []\n : [context.h.Placeholder(context.attrs.placeholder)]),\n ...(context.attrs.rows === undefined\n ? []\n : [context.h.Attribute('rows', String(context.attrs.rows))]),\n ]),\n ),\n // A number is a text input because its draft is text: `\"4.\"` is a fine thing to\n // have typed, and `type=\"number\"` would refuse to report it.\n Number: context =>\n context.h.input(\n context.slots.number.attrs([\n ...typed(context),\n ...keyboard(context),\n context.h.Type('text'),\n // `decimal` has no minus on iOS: a field that takes negatives says `text`, and one of\n // whole numbers `numeric`.\n context.h.InputMode(context.attrs.inputMode ?? 'decimal'),\n ...(context.attrs.placeholder === undefined\n ? []\n : [context.h.Placeholder(context.attrs.placeholder)]),\n ]),\n ),\n Toggle: ({ state, draft, toggled, blurred, slots, h }) =>\n h.input(\n slots.toggle.attrs([\n ...state,\n h.Type('checkbox'),\n h.Checked(draft === true),\n h.OnClick(toggled()),\n h.OnBlur(blurred),\n ]),\n ),\n Select: context =>\n pick(context, literalOptions(context.control), !context.input.control.required),\n RelationOne: context => pick(context, context.input.options, true),\n // A key of any number of choices, whether the options come from the schema\n // (`Choices`) or from the application's own list (`RelationMany`).\n Choices: context => choiceGroup(context, literalOptions(context.control)),\n RelationMany: context => choiceGroup(context, context.input.options),\n }\n}\n\ntype StateTag = RenderContext<unknown>['state'][number]['_tag']\n\n// Typed by the attributes' own tags, so a misspelt one does not compile.\nconst GROUP_STATE: ReadonlySet<StateTag> = new Set<StateTag>([\n 'Id',\n 'AriaInvalid',\n 'AriaBusy',\n 'AriaDescribedBy',\n])\n\n/**\n * A group's share of the control's state: its id, validity and descriptions.\n * The name and `disabled` go on each checkbox, and a group takes no `aria-required`.\n */\nexport const groupState = <Message>(\n state: RenderContext<Message>['state'],\n): RenderContext<Message>['state'] => state.filter(attribute => GROUP_STATE.has(attribute._tag))\n\n/** The values a choice draft holds. */\nexport const chosenOf = (draft: RenderContext<unknown>['draft']): ReadonlyArray<string> =>\n Array.isArray(draft) ? (draft as ReadonlyArray<string>) : []\n\n/** A key of any number of choices: each one a checkbox in its own label. */\nexport const choiceGroup = <Message>(\n { input, draft, toggled, state, slots, h }: RenderContext<Message>,\n options: ReadonlyArray<Option>,\n): Html => {\n const chosen = chosenOf(draft)\n const isChosen = new Set(chosen)\n return h.div(\n slots.choices.attrs([...groupState(state), h.Role('group'), h.AriaLabel(input.control.label)]),\n withChosen(options, chosen).map(option =>\n h.label(slots.choiceLabel.attrs(), [\n h.input(\n slots.choice.attrs([\n h.Type('checkbox'),\n h.Name(input.control.key),\n h.Value(option.value),\n h.Checked(isChosen.has(option.value)),\n ...(input.locked === true ? [h.Disabled(true)] : []),\n h.OnClick(toggled(option.value)),\n ]),\n ),\n option.label,\n ]),\n ),\n )\n}\n","/**\n * `foldkit-mixins-form` — a `foldkit-form` form drawn through slots.\n *\n * `foldkit-form` describes each control and draws nothing. This package draws\n * them as plain, accessible HTML and publishes every element as a Slot, so an\n * application styles and extends a generated form the way it does any other\n * SlotView, and the form stays free of a view dependency.\n */\n// `Option` is this package's own name, a picker's choice: Effect's goes by another here.\nimport { Option as Maybe } from 'effect'\nimport {\n Input,\n fillWords,\n type Control,\n type Draft,\n type FormControl,\n type FormRow,\n type NestedForm,\n} from 'foldkit-form'\nimport {\n Attr,\n Capability,\n Event,\n Slot,\n Slots,\n SlotView,\n Style,\n type NamedStyle,\n type SlotBuilders,\n} from 'foldkit-mixins'\nimport * as FieldValidation from 'foldkit/fieldValidation'\nimport type { Attribute, Html, HtmlBuilder } from 'foldkit/html'\nimport * as Submodel from 'foldkit/submodel'\nimport { plainRenderers } from './renderers.js'\n\n/** One thing a select or a relation picker offers. */\nexport interface Option {\n readonly value: string\n readonly label: string\n}\n\n/**\n * The words the drawn form says itself. Its keys are its own, so one object can\n * hold these, `foldkit-mixins-crud`'s `ViewWords`, and a form's `FormMessages`:\n * an application's words, written and translated in one place. They are text\n * with blanks (`{label}`), never functions: Foldkit admits no function nested in\n * a placed view's inputs.\n */\nexport interface FormViewWords {\n /** On the submit button. Default `Submit`. */\n readonly submit?: string | undefined\n /** Before the label on a picker's search box (`Search Author`). Default `Search`. */\n readonly search?: string | undefined\n /** The choice of nothing, in a picker that may be left empty. Default: blank. */\n readonly none?: string | undefined\n /** On the button that adds a row to a nested key. Default `Add {label}`. */\n readonly add?: string | undefined\n /** On the button that removes a row; `{position}` counts from 1. Default `Remove {label} {position}`. */\n readonly remove?: string | undefined\n /** Under a control while its check runs. Default `Checking…`. */\n readonly checking?: string | undefined\n /** On the submit button while the form is submitting. Default `Submitting…`. */\n readonly submitting?: string | undefined\n /**\n * On the submit button after its write failed, when a submit sends that\n * write again (`failure.retry`). Default `Try again`.\n */\n readonly resubmit?: string | undefined\n /** Above the list of fields to fix. Default `Check these fields:`. */\n readonly summary?: string | undefined\n /** One field to fix, a link to it. Default `{label}: {error}`. */\n readonly issue?: string | undefined\n /**\n * A field of a row as the fields to fix name it, so two rows' links differ:\n * `{row}` is the nested key's label, with the row's position when it holds\n * many. Default `{row}, {label}`.\n */\n readonly inRow?: string | undefined\n /** On the button under a picker whose list has more rows than it shows. Default `Show more`. */\n readonly more?: string | undefined\n}\n\n/**\n * What the view needs that the form does not own: the choices of each relation\n * picker (a query the application makes), and the submit button's words.\n */\nexport interface FormViewInputs<Key extends string = string, ControlKey extends string = never> {\n readonly options?: { readonly [K in Key]?: ReadonlyArray<Option> } | undefined\n /**\n * The pickers whose list has more rows than `options` holds (`Crud.options`'\n * `more`): each draws a button that sends the form's `AskedForMore`, for the\n * page that owns the list to answer. Relation pickers of the form itself\n * only, and none while locked.\n */\n readonly more?: { readonly [K in Key]?: boolean } | undefined\n /**\n * The choices of a picker inside a nested key, by its path, the same for every\n * row: `'author.country'`.\n */\n readonly nestedOptions?: Readonly<Record<string, ReadonlyArray<Option>>> | undefined\n /**\n * What a control backed by a Bundle is drawn with, by key: its view's inputs,\n * such as the page Builder's `BuilderView.inputs({ data })`. A key in a nested\n * row is named by its path, as in `nestedOptions`. Keyed by text, as those\n * paths are, and typed where each entry is made, since only the control's\n * Bundle knows its view's inputs.\n */\n readonly controls?: Readonly<Record<string, unknown>> | undefined\n /** The view's own words, for wording and for translation. */\n readonly words?: FormViewWords | undefined\n /**\n * Whether the form is drawn with its submit button. Default: it is. `false`\n * for someone who may not submit it, such as a writer where submitting\n * publishes, so what would be refused is not offered.\n */\n readonly submits?: boolean | undefined\n /**\n * Keys shown but not editable, drawn `disabled`: one the person may not set,\n * such as a member `foldkit-guard`'s `May.canSet` says no to. A hint, not a\n * check: the server checks the write. A key edited by a Bundle with no\n * renderer has its Bundle's view drawn in a disabled fieldset, which disables\n * the buttons and inputs it draws; a key in a nested row is not locked by this.\n */\n readonly locked?: ReadonlyArray<Key | ControlKey> | undefined\n /**\n * Whether the write a submit started is in flight: the form hands its value\n * over and cannot see what follows. `Crud.editor` gives it, read from\n * Remote's ledger by the write's request id; a form placed with an `onOut`\n * of its own passes `Data.mutation(model, requestId)._tag === 'Pending'`.\n */\n readonly submitting?: boolean | undefined\n /**\n * Why the write the last submit started did not land, as the page reads it\n * where the write runs: a refusal naming none of the form's keys, or a\n * failure. Drawn as the form's alert (the `failure` Slot). `retry` says a\n * submit sends that same write again (a failure; a refusal would only be\n * refused again), and the button then reads `words.resubmit`.\n */\n readonly failure?: SubmitFailure | undefined\n /**\n * Whether the write the last submit started landed, and the form is not\n * edited since. A form a save started again blank cannot submit, so its\n * button would be `disabled`, and the focus a press gave it would drop to\n * the page; while `saved` it is `aria-disabled` instead. `Crud.editor`\n * gives it.\n */\n readonly saved?: boolean | undefined\n}\n\n/** Why a submitted write did not land, for `FormViewInputs.failure`. */\nexport interface SubmitFailure {\n readonly error: string\n /** Whether a submit sends the same write again. */\n readonly retry: boolean\n}\n\n/** What a field's Style and Behavior attachments may read. */\nexport interface FieldInput<Key extends string = string> {\n readonly control: FormControl<Key>\n readonly field: FieldValidation.Field<Draft>\n readonly invalid: boolean\n readonly errors: ReadonlyArray<string>\n readonly options: ReadonlyArray<Option>\n /** Unique within the form, for `label for`, and as the prefix of the ids beside it. */\n readonly id: string\n /** The word before the label on its search box: the view's `words.search`. */\n readonly searchWord?: string | undefined\n /** The choice of nothing in a picker: the view's `words.none`. */\n readonly noneWord?: string | undefined\n /** What is said while the key's check runs: the view's `words.checking`. */\n readonly checkingWord?: string | undefined\n /**\n * The form's list of fields to fix announces this failure, so the error\n * beside the field is drawn without its own `role=\"alert\"`.\n */\n readonly quiet?: boolean | undefined\n /** The Message a press of the picker's \"more\" button sends; none draws no button. */\n readonly more?: unknown\n /** On that button: the view's `words.more`. */\n readonly moreWord?: string | undefined\n /**\n * Set for a field in a row of a nested key: its Messages, wrapped for the row.\n * A field of the form itself sends the form's own.\n */\n readonly send?:\n | {\n readonly changed: (value: Draft) => unknown\n readonly blurred: unknown\n readonly searched: (text: string) => unknown\n readonly toggled: (choice?: string) => unknown\n }\n | undefined\n /**\n * Set for a key edited by a control backed by a Bundle (`Input.bundle`): the\n * Bundle's Model, and the Message that carries one of its own. Such a key has\n * no draft, so `field.value` is `''`; its validation state is `field`'s.\n */\n readonly bundle?: BundleInput | undefined\n /** What was typed to find a choice, for a relation picker that searches. */\n readonly search: string\n /** Shown but not editable: the view's `locked` names the key. */\n readonly locked?: boolean | undefined\n /**\n * Whether the key is still written from the key it follows. A renderer offers\n * \"regenerate\" when it is not, by sending the key an empty draft.\n */\n readonly following: boolean\n}\n\n/** A control backed by a Bundle, as its field is drawn: its Model, and how its Messages leave. */\nexport interface BundleInput {\n readonly model: unknown\n readonly send: (message: unknown) => unknown\n /** What the view's `controls` gives this key, for the Bundle's own view. */\n readonly viewInputs?: unknown\n}\n\n/** What the form's own Style and Behavior attachments may read. */\nexport interface FormInput<\n Model,\n Key extends string = string,\n ControlKey extends string = never,\n> extends FormViewInputs<Key, ControlKey> {\n readonly model: Model\n readonly errors: ReadonlyArray<string>\n readonly canSubmit: boolean\n /**\n * Whether the form is submitting: a submit waits for a check, or the\n * application's work with the value is in flight. `FormView.submodel` reads both.\n */\n readonly submitting?: boolean | undefined\n}\n\nconst textual = {\n capability: Capability.TextInput,\n events: [Event.Input, Event.Blur],\n attributes: [Attr.AriaInvalid, Attr.AriaDescribedby],\n} as const\n\n/** One field: the control for a key, and what stands around it. */\nexport const FieldSlots = Slots.define({\n root: Slot.make({ capability: Capability.Container }),\n label: Slot.make({ capability: Capability.Base }),\n description: Slot.make({ capability: Capability.Base }),\n error: Slot.make({ capability: Capability.Base }),\n /** Says the key's check is running, while it runs. The control names it in `aria-describedby`. */\n checking: Slot.make({ capability: Capability.Base }),\n text: Slot.make(textual),\n multiline: Slot.make(textual),\n number: Slot.make(textual),\n toggle: Slot.make({\n capability: Capability.Interactive,\n events: [Event.Click, Event.Blur],\n attributes: [Attr.AriaInvalid, Attr.AriaDescribedby],\n }),\n /** A `Select`, and a `RelationOne` picker. */\n select: Slot.make({\n capability: Capability.Focusable,\n events: [Event.Change, Event.Blur],\n attributes: [Attr.AriaInvalid, Attr.AriaDescribedby],\n }),\n /** One choice of a `select`. */\n option: Slot.make({ capability: Capability.Base }),\n /** Around the view of a control backed by a Bundle, when it is drawn with the Bundle's own view. */\n control: Slot.make({ capability: Capability.Container }),\n /** Around a control and its affixes, such as an address's prefix and its input. */\n group: Slot.make({ capability: Capability.Container }),\n /** Text beside a control, before or after it: a prefix, or a unit. */\n affix: Slot.make({ capability: Capability.Base }),\n /** A `RelationMany` picker: the group, and each thing in it. */\n choices: Slot.make({ capability: Capability.Collection }),\n choice: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n /** Around one choice's checkbox and its words. */\n choiceLabel: Slot.make({ capability: Capability.Base }),\n /** Over a relation picker that searches: where the user types to find a choice. */\n search: Slot.make({ capability: Capability.TextInput, events: [Event.Input] }),\n /** Under a relation picker whose list has more rows: asks for them. */\n more: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n})\n\n/** The form around its fields. */\nexport const FormSlots = Slots.define({\n root: Slot.make({ capability: Capability.Container, events: [Event.Submit] }),\n /** Failures that belong to no one field: a rule that spans keys. */\n errors: Slot.make({ capability: Capability.Base }),\n /**\n * Why the write the last submit started did not land (`failure`): a refusal\n * that names no key, or a failure a submit sends again. Above the submit button.\n */\n failure: Slot.make({ capability: Capability.Base }),\n /**\n * The fields to fix, after a submit while any is invalid, in a form of more\n * than one control: its words (`summaryTitle`), then a list (`issues`) of\n * `issue`s, each holding an `issueLink` to one field's control. Beside\n * `errors`, above the submit button. It is the alert for those failures.\n */\n summary: Slot.make({ capability: Capability.Container }),\n summaryTitle: Slot.make({ capability: Capability.Base }),\n issues: Slot.make({ capability: Capability.Collection }),\n issue: Slot.make({ capability: Capability.Base }),\n /** A link to one field's control, which a press focuses. */\n issueLink: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n submit: Slot.make({\n capability: Capability.Interactive,\n events: [Event.Click],\n attributes: [Attr.Disabled, Attr.AriaDisabled],\n }),\n /** A nested key: the group around its rows, its name, each row, and the buttons that add and remove one. */\n group: Slot.make({ capability: Capability.Container }),\n legend: Slot.make({ capability: Capability.Base }),\n row: Slot.make({ capability: Capability.Container }),\n add: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n remove: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }),\n})\n\n/** The parts of a `Form.make` result the view reads. */\ninterface FormLike<Key extends string, Model, Message, ControlKey extends string = never> {\n /** Every key, nested ones too; `Key` is the keys that hold a draft. */\n readonly controls: ReadonlyArray<FormControl>\n readonly field: (model: Model, key: Key) => FieldValidation.Field<Draft>\n /** A key edited by a control backed by a Bundle. A form with none takes no key here. */\n readonly control: (key: ControlKey) => {\n readonly field: (model: Model) => FieldValidation.Field<unknown>\n }\n /** The rows of a nested key. A form with none takes no key here. */\n readonly rows: (model: Model, key: never) => ReadonlyArray<FormRow>\n readonly search: (model: Model, key: Key) => string\n readonly isFollowing: (model: Model, key: Key) => boolean\n readonly canSubmit: (model: Model) => boolean\n readonly attempted: (model: Model) => boolean\n readonly Message: {\n /** The union, so `Message` is inferred from it and not from one constructor's case. */\n readonly Type: Message\n readonly Changed: (payload: { readonly key: Key; readonly value: Draft }) => NoInfer<Message>\n readonly Blurred: (payload: { readonly key: Key }) => NoInfer<Message>\n readonly Searched: (payload: { readonly key: Key; readonly text: string }) => NoInfer<Message>\n readonly Toggled: (payload: { readonly key: Key; readonly choice?: string }) => NoInfer<Message>\n readonly Submitted: () => NoInfer<Message>\n readonly FollowedIssue: (payload: { readonly id: string }) => NoInfer<Message>\n readonly AskedForMore: (payload: { readonly key: Key }) => NoInfer<Message>\n readonly Control: (payload: {\n readonly key: never\n readonly message: unknown\n }) => NoInfer<Message>\n readonly Nested: (payload: {\n readonly key: string\n readonly row: string\n readonly message: unknown\n }) => NoInfer<Message>\n readonly RowAdded: (payload: { readonly key: string }) => NoInfer<Message>\n readonly RowRemoved: (payload: {\n readonly key: string\n readonly row: string\n }) => NoInfer<Message>\n }\n}\n\n/**\n * A form or a row of one, as the view walks it: what to draw, and how each\n * Message leaves. A row's Messages leave wrapped, once per form they pass through.\n */\ninterface Walk<Message> {\n readonly controls: ReadonlyArray<FormControl>\n readonly field: (key: string) => FieldValidation.Field<Draft>\n /** The state of a key edited by a control backed by a Bundle, its Model as the value. */\n readonly controlField: (key: string) => FieldValidation.Field<unknown>\n readonly rows: (key: string) => ReadonlyArray<FormRow>\n readonly search: (key: string) => string\n readonly following: (key: string) => boolean\n readonly wrap: (message: unknown) => Message\n readonly make: NestedForm['Message']\n}\n\nconst rowWalk = <Message>(\n parent: Walk<Message>,\n key: string,\n row: FormRow,\n form: NestedForm,\n): Walk<Message> => ({\n controls: form.controls as ReadonlyArray<FormControl>,\n field: inner =>\n (form.field as (model: unknown, key: string) => FieldValidation.Field<Draft>)(row.model, inner),\n controlField: inner =>\n (\n form.control as (key: string) => {\n readonly field: (model: unknown) => FieldValidation.Field<unknown>\n }\n )(inner).field(row.model),\n rows: inner =>\n (form.rows as (model: unknown, key: string) => ReadonlyArray<FormRow>)(row.model, inner),\n search: inner => (form.search as (model: unknown, key: string) => string)(row.model, inner),\n following: inner =>\n (form.isFollowing as (model: unknown, key: string) => boolean)(row.model, inner),\n wrap: message =>\n parent.wrap(\n (parent.make.Nested as (payload: object) => unknown)({ key, row: row.id, message }),\n ),\n make: form.Message,\n})\n\ntype FieldView<Key extends string, Message> = SlotView.SlotView<\n typeof FieldSlots,\n FieldInput<Key>,\n Message\n>\n\nconst errorsOf = (field: FieldValidation.Field<unknown>): ReadonlyArray<string> =>\n field._tag === 'Invalid' ? field.errors : []\n\n/**\n * The state of a key a control backed by a Bundle edits, as a field is drawn:\n * its validation state, with no draft. The Bundle's Model travels as `bundle`.\n */\nconst withoutDraft = (field: FieldValidation.Field<unknown>): FieldValidation.Field<Draft> =>\n field._tag === 'Invalid'\n ? FieldValidation.Invalid({ value: '', errors: field.errors })\n : field._tag === 'Valid'\n ? FieldValidation.Valid({ value: '' })\n : field._tag === 'Validating'\n ? FieldValidation.Validating({ value: '' })\n : FieldValidation.NotValidated({ value: '' })\n\n/** What a renderer draws one control from. */\nexport interface RenderContext<Message> {\n readonly input: FieldInput\n /** The control, whose `data` is its kind's: narrow it with the kind's `is`. */\n readonly control: Control\n readonly draft: Draft\n readonly change: (value: Draft) => Message\n /**\n * A press on a flag (no `choice`) or on one choice of a list, applied to the\n * draft as it stands when it lands: send it for a press, rather than a\n * `change` built from the draft as drawn, which a second press before the\n * next draw would undo.\n */\n readonly toggled: (choice?: string) => Message\n readonly blurred: Message\n /**\n * For a control backed by a Bundle: its Model, and the Message carrying one of\n * its own. Its `draft` is `''`.\n */\n readonly bundle:\n | {\n readonly model: unknown\n readonly send: (message: unknown) => Message\n /** The inputs its view is drawn with: the form view's `controls` entry for this key. */\n readonly viewInputs: unknown\n }\n | undefined\n /**\n * The control's id and its accessibility state. Put them on the element that\n * holds the value: no `InnerHTML`, so a textarea takes them too.\n */\n readonly state: ReadonlyArray<Exclude<Attribute<Message>, { readonly _tag: 'InnerHTML' }>>\n /** What the key's element takes beyond the base field view. */\n readonly attrs: FieldAttrs\n readonly slots: SlotBuilders<typeof FieldSlots, Message>\n readonly h: HtmlBuilder<Message>\n}\n\n/** Draws the control of one kind. The label, description and error around it are the field's. */\nexport type Renderer<Message> = (context: RenderContext<Message>) => Html\n\n/**\n * A control backed by a Bundle that no renderer names is drawn with the\n * Bundle's own view, inside the field's `control` slot, which carries the\n * control's id and accessibility state. A Bundle with no view needs a renderer.\n */\nconst bundleRenderer =\n <Message>(control: Control): Renderer<Message> =>\n ({ bundle, input, state, slots, h }) => {\n const view = Input.isBundle(control) ? control.data.bundle.view : undefined\n if (bundle === undefined || view === undefined)\n throw new Error(\n `FormView: the \"${control.kind}\" control (\"${input.control.key}\") has no view; pass a renderer under \"renderers\"`,\n )\n const drawn = h.submodel(\n bundle.viewInputs === undefined\n ? { slotId: input.id, model: bundle.model, view, toParentMessage: bundle.send }\n : // A Bundle's view takes the inputs its application gives it in `controls`,\n // whose type the form cannot know. A view given inputs is called with them.\n ({\n slotId: input.id,\n model: bundle.model,\n view,\n toParentMessage: bundle.send,\n viewInputs: bundle.viewInputs,\n } as Parameters<typeof h.submodel>[0]),\n )\n // The label's `for` names this div, which labels nothing: as a group named by\n // the label, the controls the Bundle draws inside are announced under it.\n // `disabled` on the div disables nothing inside it; a disabled fieldset\n // disables every button and input the Bundle draws, and draws no box of its own.\n return h.div(\n slots.control.attrs([\n ...state.filter(attribute => attribute._tag !== 'Name'),\n h.Role('group'),\n h.AriaLabelledBy(`${input.id}-label`),\n ]),\n [\n input.locked === true\n ? h.fieldset([h.Disabled(true), h.Style({ display: 'contents' })], [drawn])\n : drawn,\n ],\n )\n }\n\n/** Renderers by the `kind` of control they draw. */\nexport type Renderers<Message> = Readonly<Record<string, Renderer<Message>>>\n\n/**\n * What a per-key override receives: everything to draw the control, and the\n * Messages that leave it, in the form's own universe. The `h` an override\n * draws with stays the caller's: the whole-form view's, or a custom layout's.\n */\nexport interface FieldOverrideInput<Key extends string = string, Changed = unknown> {\n readonly control: FormControl<Key>\n readonly field: FieldValidation.Field<Draft>\n readonly id: string\n readonly invalid: boolean\n readonly errors: ReadonlyArray<string>\n readonly changed: (value: Draft) => Changed\n /**\n * A press on a flag (no `choice`) or one choice, applied to the draft as it\n * lands: send it for a press, so two before the next draw both count.\n */\n readonly toggled: (choice?: string) => Changed\n readonly blurred: Changed\n /** What the key's element takes beyond the base field view. */\n readonly attrs: FieldAttrs\n}\n\n/**\n * Draws one key's control, for a layout the base field view does not own.\n * `Changed` is the form's Message; `Message` the universe of the `h` that\n * draws, which is the form's in the whole-form view and the application's\n * in a custom layout.\n */\nexport type FieldOverride<Key extends string = string, Changed = unknown, Message = unknown> = (\n input: FieldOverrideInput<Key, Changed>,\n h: HtmlBuilder<Message>,\n) => Html\n\n/**\n * What one key's element takes beyond the base field view: an HTML input\n * type, a placeholder, a textarea's rows, and what a phone's keyboard and the\n * browser's autofill should offer. A renderer reads what fits its element and\n * ignores the rest.\n */\nexport interface FieldAttrs {\n readonly type?: string | undefined\n readonly placeholder?: string | undefined\n readonly rows?: number | undefined\n /** What the browser may fill in: `email`, `name`, `street-address`, `one-time-code`, `off`. */\n readonly autocomplete?: string | undefined\n /** The keypad a phone shows: `numeric`, `decimal`, `tel`, `email`, `url`, `search`, `text`. A number field is `decimal` unless this says otherwise. */\n readonly inputMode?: string | undefined\n /** What a phone keyboard's Enter key says: `next`, `done`, `go`, `search`, `send`. */\n readonly enterKeyHint?: string | undefined\n /** `none`, `sentences`, `words`, `characters`. Off by default for an `email`, `tel` or `url` type. */\n readonly autocapitalize?: string | undefined\n /** Off by default for an `email`, `tel` or `url` type, where a correction is a wrong address. */\n readonly spellcheck?: boolean | undefined\n}\n\n/**\n * Per-key overrides for `FormView.fields`. `overrides` draw through the\n * whole-form view; `styles` style one key's base field view there. Unknown\n * keys in either are type errors. A custom layout passes its override to\n * `field` itself, with its own `h`.\n */\nexport interface FieldsOptions<Key extends string, Changed> {\n /** A key drawn by this instead of the base field view (or its styled one). */\n readonly overrides?: { readonly [K in Key]?: FieldOverride<Key, Changed, Changed> } | undefined\n /** A style around a key's base field view, kept for keys with no override. */\n readonly styles?: { readonly [K in Key]?: NamedStyle<typeof FieldSlots> } | undefined\n /**\n * What one key's element takes beyond the base field view. The text,\n * multiline, and number renderers read them for a base field view, and a\n * per-key override is handed them as its own `attrs` too, so it decides what\n * to do with them; a bundle-backed kind drawn by `bundleRenderer` reads none.\n * Passing `field` draws through the base view directly, skipping both\n * `renderers` and `attrs`.\n */\n readonly attrs?: { readonly [K in Key]?: FieldAttrs } | undefined\n}\n\n/**\n * One flat key's control, for a layout the caller owns: through the base\n * field view with a form-universe `h`, or through the override it is given,\n * with any `h`. A call with neither a form `h` nor an override is a type\n * error, since the base view's Messages are the form's own.\n */\nexport interface FieldsField<\n Key extends string,\n Model,\n FormMessage extends { readonly _tag: string },\n> {\n (\n control: FormControl<Key>,\n model: Model,\n id: string,\n h: HtmlBuilder<FormMessage>,\n override?: FieldOverride<Key, FormMessage, FormMessage>,\n ): Html\n <Message>(\n control: FormControl<Key>,\n model: Model,\n id: string,\n h: HtmlBuilder<Message>,\n override: FieldOverride<Key, FormMessage, Message>,\n ): Html\n}\n\n/** The Messages of one key, through its row's send or the form's own. */\nconst changedOf =\n <Key extends string, Model, Message>(\n form: FormLike<Key, Model, Message>,\n key: Key,\n send: FieldInput<Key>['send'],\n ): ((value: Draft) => Message) =>\n value =>\n (send === undefined ? form.Message.Changed({ key, value }) : send.changed(value)) as Message\n\n/** The press Message of one key, through its row's send or the form's own. */\nconst toggledOf =\n <Key extends string, Model, Message>(\n form: FormLike<Key, Model, Message>,\n key: Key,\n send: FieldInput<Key>['send'],\n ): ((choice?: string) => Message) =>\n choice =>\n (send === undefined\n ? form.Message.Toggled(choice === undefined ? { key } : { key, choice })\n : send.toggled(choice)) as Message\n\n/** The blur Message of one key, through its row's send or the form's own. */\nconst blurredOf = <Key extends string, Model, Message>(\n form: FormLike<Key, Model, Message>,\n key: Key,\n send: FieldInput<Key>['send'],\n): Message => (send === undefined ? form.Message.Blurred({ key }) : send.blurred) as Message\n\n/** The view of one field, to style or extend before handing it to `FormView.define`. */\nconst field = <Key extends string, Model, Message extends { readonly _tag: string }>(\n form: FormLike<Key, Model, Message>,\n options: {\n /** Renderers by kind, beside the ones shipped: a new kind, or another way to draw a shipped one. */\n readonly renderers?: Renderers<Message>\n /** What one key's element takes beyond the base field view. */\n readonly attrs?: { readonly [K in Key]?: FieldAttrs }\n } = {},\n): FieldView<Key, Message> => {\n // No prototype: a kind named `constructor` or `toString` has a renderer only if given one.\n const renderers: Renderers<Message> = Object.assign(\n Object.create(null),\n plainRenderers<Message>(),\n options.renderers,\n )\n return SlotView.forMessages<Message>().define(\n FieldSlots,\n (input: FieldInput<Key>, slots, h) => {\n const { control, id, invalid } = input\n const { key, label, description, required } = control\n const draft = input.field.value\n const { send } = input\n const change = changedOf(form, key, send)\n const blurred = blurredOf(form, key, send)\n const toggled = toggledOf(form, key, send)\n const searched = (text: string): Message =>\n send === undefined ? form.Message.Searched({ key, text }) : (send.searched(text) as Message)\n const searches = control.control.searches\n // A check is running: the control is neither valid nor invalid yet.\n const checking = input.field._tag === 'Validating'\n // A Bundle's control says its own state (an upload's \"Sending\"), so the\n // field adds no second live line for it; it is still marked busy.\n const saysChecking = checking && input.bundle === undefined\n const describedBy = [\n ...(description === undefined ? [] : [`${id}-description`]),\n ...(saysChecking ? [`${id}-checking`] : []),\n ...(invalid ? [`${id}-error`] : []),\n ]\n const state = [\n h.Id(id),\n // The key is the field's name, so a form posts its drafts with scripts off.\n h.Name(key),\n h.AriaInvalid(invalid),\n ...(checking ? [h.AriaBusy(true)] : []),\n ...(required ? [h.AriaRequired(true)] : []),\n ...(describedBy.length === 0 ? [] : [h.AriaDescribedBy(describedBy.join(' '))]),\n ...(input.locked === true ? [h.Disabled(true)] : []),\n ]\n // The Message leaves the way the input says: wrapped for a row, or the form's own.\n const held = input.bundle\n const bundle =\n held === undefined\n ? undefined\n : {\n model: held.model,\n send: (message: unknown) => held.send(message) as Message,\n viewInputs: held.viewInputs,\n }\n const render =\n renderers[control.control.kind] ??\n (bundle !== undefined ? bundleRenderer<Message>(control.control) : undefined)\n if (render === undefined)\n throw new Error(\n `FormView: no renderer for a \"${control.control.kind}\" control (\"${key}\"); pass one under \"renderers\"`,\n )\n const body = render({\n input: input as FieldInput,\n control: control.control,\n draft,\n change,\n toggled,\n blurred,\n bundle,\n state,\n attrs: options.attrs?.[key] ?? {},\n slots,\n h,\n })\n\n // The field's state by Foldkit's own tag, for a stylesheet: `[data-validation='Valid']`.\n return h.div(slots.root.attrs([h.DataAttribute('validation', input.field._tag)]), [\n h.label(slots.label.attrs([h.Id(`${id}-label`), h.For(id)]), [label]),\n // Typing here changes which choices the picker below is offered.\n ...(searches\n ? [\n h.input(\n slots.search.attrs([\n h.Id(`${id}-search`),\n h.Type('search'),\n h.AriaLabel(`${input.searchWord ?? 'Search'} ${label}`),\n h.AriaControls(id),\n h.Value(input.search),\n h.OnInput(searched),\n ]),\n ),\n ]\n : []),\n body,\n ...(input.more === undefined\n ? []\n : [\n h.button(\n slots.more.attrs([\n h.Type('button'),\n h.AriaControls(id),\n h.OnClick(input.more as Message),\n ]),\n [input.moreWord ?? 'Show more'],\n ),\n ]),\n // A disabled control is left out of a post, so a locked key's value goes\n // as hidden inputs: a form posted with scripts off still carries it.\n // Attributes, not properties, so a server's markup holds them.\n ...(input.locked === true\n ? posted(draft).map(value =>\n h.input([\n h.Attribute('type', 'hidden'),\n h.Attribute('name', key),\n h.Attribute('value', value),\n ]),\n )\n : []),\n ...(description === undefined\n ? []\n : [h.p(slots.description.attrs([h.Id(`${id}-description`)]), [description])]),\n ...(saysChecking\n ? [\n h.p(slots.checking.attrs([h.Id(`${id}-checking`), h.Role('status')]), [\n input.checkingWord ?? 'Checking…',\n ]),\n ]\n : []),\n ...(invalid\n ? [\n h.p(\n slots.error.attrs([\n h.Id(`${id}-error`),\n ...(input.quiet === true ? [] : [h.Role('alert')]),\n ]),\n [...input.errors],\n ),\n ]\n : []),\n ])\n },\n { name: 'FormField' },\n )\n}\n\n/**\n * The control drawn with this id, or the first one inside it, such as a choice\n * group's first box. The id is quoted, since it may hold what a selector reads\n * as syntax.\n */\nconst controlAt = (id: string): string => {\n const at = `[id=${JSON.stringify(id)}]`\n const control = ':is(input, select, textarea, button)'\n return `${at}${control}, ${at} ${control}`\n}\n\n/**\n * What a draft posts as: its text, each of its values, `on` for a checked box\n * (a checkbox's own default), or nothing for an unchecked one or a control's\n * own Model.\n */\nconst posted = (draft: unknown): ReadonlyArray<string> => {\n if (typeof draft === 'string') return [draft]\n if (typeof draft === 'boolean') return draft ? ['on'] : []\n return Array.isArray(draft) ? draft.map(String) : []\n}\n\nexport const FormView = {\n field,\n\n /**\n * The view of the whole form: each control through `field`, in the input's\n * order, a hidden key left out. Pass a styled `field` to change how fields\n * look; attach Style and Behavior to the result to change the form around them.\n */\n define: <\n Key extends string,\n Model,\n Message extends { readonly _tag: string },\n ControlKey extends string = never,\n >(\n form: FormLike<Key, Model, Message, ControlKey> & {\n readonly bundle: { readonly name: string }\n },\n options: {\n readonly field?: FieldView<Key, Message>\n /** Renderers by kind, for the field view this makes. With `field` given, give them to `FormView.field`. */\n readonly renderers?: Renderers<Message>\n } = {},\n ): SlotView.SlotView<typeof FormSlots, FormInput<Model, Key, ControlKey>, Message> => {\n const fieldView =\n options.field ??\n field(form, options.renderers === undefined ? {} : { renderers: options.renderers })\n type Make = (payload: object) => unknown\n return SlotView.forMessages<Message>().define(\n FormSlots,\n (input: FormInput<Model, Key, ControlKey>, slots, h) => {\n const options: Readonly<Record<string, ReadonlyArray<Option> | undefined>> = {\n ...input.nestedOptions,\n ...input.options,\n }\n const controls: Readonly<Record<string, unknown>> = input.controls ?? {}\n const locked: ReadonlySet<string> = new Set(input.locked ?? [])\n const more: Readonly<Record<string, boolean | undefined>> = input.more ?? {}\n\n // The list of fields to fix belongs to a submit, and a form of one\n // control has nothing to navigate between: its error is the summary.\n // A nested key's rows hold fields of their own.\n const shown = form.controls.filter(control => control.control.shown)\n const listed =\n form.attempted(input.model) &&\n (shown.length > 1 || shown.some(control => Input.Nested.is(control.control)))\n\n // Each invalid field, in the order drawn, for the summary.\n const issues: Array<{\n readonly id: string\n readonly label: string\n readonly error: string\n }> = []\n\n /** The controls of a form or of a row. `id` and `path` say where: both are empty for the form itself. */\n /** `within` names the row being drawn, for its issues; none for the form itself. */\n const draw = (\n walk: Walk<Message>,\n id: string,\n path: string,\n within: Maybe.Option<string> = Maybe.none(),\n ): ReadonlyArray<Html> =>\n walk.controls\n .filter(control => control.control.shown)\n .map((control): Html => {\n const { key, label } = control\n const here = `${id}-${key}`\n if (!Input.Nested.is(control.control)) {\n const bundled = Input.isBundle(control.control)\n const held = bundled ? walk.controlField(key) : walk.field(key)\n const state = bundled ? withoutDraft(held) : (held as FieldValidation.Field<Draft>)\n if (FieldValidation.isInvalid(state))\n issues.push({\n id: here,\n label: Maybe.match(within, {\n onNone: () => label,\n onSome: named =>\n fillWords(input.words?.inRow ?? '{row}, {label}', { row: named, label }),\n }),\n error: errorsOf(state).join(' '),\n })\n return fieldView(\n {\n control: control as FormControl<Key>,\n field: state,\n bundle: bundled\n ? {\n model: held.value,\n send: message => walk.wrap((walk.make.Control as Make)({ key, message })),\n viewInputs: controls[`${path}${key}`],\n }\n : undefined,\n invalid: FieldValidation.isInvalid(state),\n errors: errorsOf(state),\n options: options[`${path}${key}`] ?? [],\n id: here,\n search: walk.search(key),\n following: walk.following(key),\n locked: path === '' && locked.has(key),\n searchWord: input.words?.search,\n noneWord: input.words?.none,\n checkingWord: input.words?.checking,\n quiet: listed,\n // Only the form's own pickers, and only while they can be used: a\n // row's are named by path, and a locked key takes no choice.\n more:\n path === '' &&\n more[key] === true &&\n !locked.has(key) &&\n (Input.RelationOne.is(control.control) ||\n Input.RelationMany.is(control.control))\n ? form.Message.AskedForMore({ key: key as Key })\n : undefined,\n moreWord: input.words?.more,\n send: {\n changed: value => walk.wrap((walk.make.Changed as Make)({ key, value })),\n blurred: walk.wrap((walk.make.Blurred as Make)({ key })),\n searched: text => walk.wrap((walk.make.Searched as Make)({ key, text })),\n toggled: choice =>\n walk.wrap(\n (walk.make.Toggled as Make)(\n choice === undefined ? { key } : { key, choice },\n ),\n ),\n },\n },\n h,\n )\n }\n const { form: nested, cardinality, optional } = control.control.data\n const rowName = (index: number) =>\n cardinality === 'many' ? `${label} ${index + 1}` : label\n const rows = walk.rows(key)\n const addLabel = fillWords(input.words?.add ?? 'Add {label}', { label })\n return h.fieldset(slots.group.attrs([h.Id(here)]), [\n h.legend(slots.legend.attrs(), [label]),\n ...rows.map((row, index) =>\n h.div(slots.row.attrs([h.Id(`${here}-${row.id}`)]), [\n ...draw(\n rowWalk(walk, key, row, nested),\n `${here}-${row.id}`,\n `${path}${key}.`,\n // Named through every row it is in: `authors 1, books 2`.\n Maybe.some(\n Maybe.match(within, {\n onNone: () => rowName(index),\n onSome: outer => `${outer}, ${rowName(index)}`,\n }),\n ),\n ),\n // A row that must be there has no way out.\n ...(optional\n ? [\n h.button(\n slots.remove.attrs([\n h.Type('button'),\n h.OnClick(\n walk.wrap((walk.make.RowRemoved as Make)({ key, row: row.id })),\n ),\n ]),\n [\n fillWords(input.words?.remove ?? 'Remove {label} {position}', {\n label,\n position: index + 1,\n }),\n ],\n ),\n ]\n : []),\n ]),\n ),\n // A `one` takes one row: the way in goes once it is there.\n ...(cardinality === 'many' || rows.length === 0\n ? [\n h.button(\n slots.add.attrs([\n h.Type('button'),\n h.OnClick(walk.wrap((walk.make.RowAdded as Make)({ key }))),\n ]),\n [addLabel],\n ),\n ]\n : []),\n ])\n })\n\n const top: Walk<Message> = {\n controls: form.controls,\n field: key => form.field(input.model, key as Key),\n controlField: key => form.control(key as never).field(input.model),\n rows: key => form.rows(input.model, key as never),\n search: key => form.search(input.model, key as Key),\n following: key => form.isFollowing(input.model, key as Key),\n wrap: message => message as Message,\n make: form.Message as unknown as NestedForm['Message'],\n }\n const submitting = input.submitting === true\n const saved = input.saved === true\n const fields = draw(top, form.bundle.name, '')\n return h.form(\n slots.root.attrs([\n h.OnSubmit(form.Message.Submitted()),\n ...(submitting ? [h.AriaBusy(true), h.DataAttribute('submitting', '')] : []),\n ]),\n [\n ...fields,\n ...(!listed || issues.length === 0\n ? []\n : [\n // No id of its own: a key named `summary` would hold it already.\n // It announces the submit's failures once, for every field.\n h.div(slots.summary.attrs([h.Role('alert')]), [\n h.p(slots.summaryTitle.attrs(), [\n input.words?.summary ?? 'Check these fields:',\n ]),\n h.ul(\n slots.issues.attrs(),\n issues.map(issue =>\n h.li(slots.issue.attrs(), [\n // A link, so with scripts off it still goes to the field.\n // With them on, the press focuses the control itself and\n // goes nowhere, since an application takes a link as a\n // navigation.\n h.a(\n slots.issueLink.attrs([\n h.Href(`#${issue.id}`),\n h.OnClick(form.Message.FollowedIssue({ id: issue.id }), {\n defaultAction: 'Prevent',\n focusSelector: controlAt(issue.id),\n }),\n ]),\n [\n fillWords(input.words?.issue ?? '{label}: {error}', {\n label: issue.label,\n error: issue.error,\n }),\n ],\n ),\n ]),\n ),\n ),\n ]),\n ]),\n ...(input.errors.length === 0\n ? []\n : [h.p(slots.errors.attrs([h.Role('alert')]), [...input.errors])]),\n ...(input.failure === undefined\n ? []\n : [h.p(slots.failure.attrs([h.Role('alert')]), [input.failure.error])]),\n ...(input.submits === false\n ? []\n : [\n h.button(\n slots.submit.attrs([\n h.Type('submit'),\n // Disabling it would drop the focus a press gave it: while\n // submitting a press reaches a submit that waits or a\n // write in flight, which ignores it, and once saved one\n // shows what the blank form lacks.\n h.Disabled(!input.canSubmit && !saved),\n ...(submitting || (saved && !input.canSubmit) ? [h.AriaDisabled(true)] : []),\n ]),\n [\n submitting\n ? (input.words?.submitting ?? 'Submitting…')\n : input.failure?.retry === true\n ? (input.words?.resubmit ?? 'Try again')\n : (input.words?.submit ?? 'Submit'),\n ],\n ),\n ]),\n ],\n )\n },\n { name: form.bundle.name },\n )\n },\n\n /**\n * The whole form, as `define` draws it, with per-key overrides; and one flat\n * key's control, for a layout the caller owns. Keys with no override render\n * through the base field view (a new key of a known kind needs nothing new),\n * each through its style when one is given and with its element attrs. `field`\n * draws through the base view with a form-universe `h`, or through the\n * override it is given, with any `h`. Nested keys and Bundle-backed keys draw\n * only through `view` (or an override); `field` without one refuses them,\n * naming the key.\n */\n fields: <\n Key extends string,\n Model,\n FormMessage extends { readonly _tag: string },\n ControlKey extends string = never,\n >(\n form: FormLike<Key, Model, FormMessage, ControlKey> & {\n readonly bundle: { readonly name: string }\n },\n options: {\n readonly field?: FieldView<Key, FormMessage>\n /** Renderers by kind, for the field views this makes. */\n readonly renderers?: Renderers<FormMessage>\n } & FieldsOptions<Key, FormMessage> = {},\n ): {\n readonly view: SlotView.SlotView<\n typeof FormSlots,\n FormInput<Model, Key, ControlKey>,\n FormMessage\n >\n readonly field: FieldsField<Key, Model, FormMessage>\n } => {\n const base =\n options.field ??\n field(\n form,\n options.renderers === undefined && options.attrs === undefined\n ? {}\n : {\n ...(options.renderers === undefined ? {} : { renderers: options.renderers }),\n ...(options.attrs === undefined ? {} : { attrs: options.attrs }),\n },\n )\n const styled = new Map<Key, FieldView<Key, FormMessage>>()\n const viewOf = (key: Key): FieldView<Key, FormMessage> => {\n const known = styled.get(key)\n if (known !== undefined) return known\n const style = options.styles?.[key]\n const made = style === undefined ? base : Style.attach(style)(base)\n styled.set(key, made)\n return made\n }\n const drawn = (input: FieldInput<Key>, h: HtmlBuilder<FormMessage>): Html => {\n const override = options.overrides?.[input.control.key]\n if (override === undefined) return viewOf(input.control.key)(input, h)\n return override(\n {\n control: input.control,\n field: input.field,\n id: input.id,\n invalid: input.invalid,\n errors: input.errors,\n changed: changedOf(form, input.control.key, input.send),\n toggled: toggledOf(form, input.control.key, input.send),\n blurred: blurredOf(form, input.control.key, input.send),\n attrs: options.attrs?.[input.control.key] ?? {},\n },\n h,\n )\n }\n return {\n view: FormView.define(form, {\n field: SlotView.forMessages<FormMessage>().define(\n FieldSlots,\n (input: FieldInput<Key>, _slots, h) => drawn(input, h),\n { name: `${form.bundle.name}Fields` },\n ),\n }),\n field: (<M>(\n control: FormControl<Key>,\n model: Model,\n id: string,\n h: HtmlBuilder<M> | HtmlBuilder<FormMessage>,\n override?: FieldOverride<Key, FormMessage, M>,\n ): Html => {\n const state = form.field(model, control.key)\n if (override !== undefined)\n return override(\n {\n control,\n field: state,\n id,\n invalid: FieldValidation.isInvalid(state),\n errors: errorsOf(state),\n changed: value => form.Message.Changed({ key: control.key, value }),\n toggled: toggledOf(form, control.key, undefined),\n blurred: form.Message.Blurred({ key: control.key }),\n attrs: options.attrs?.[control.key] ?? {},\n },\n h as HtmlBuilder<M>,\n )\n if (Input.Nested.is(control.control) || Input.isBundle(control.control))\n throw new Error(\n `FormView.fields: \"${control.key}\" nests rows or a Bundle; draw it with the whole-form view, or give an override for it`,\n )\n return viewOf(control.key)(\n {\n control,\n field: state,\n bundle: undefined,\n invalid: FieldValidation.isInvalid(state),\n errors: errorsOf(state),\n options: [],\n id,\n search: form.search(model, control.key),\n following: form.isFollowing(model, control.key),\n },\n h as HtmlBuilder<FormMessage>,\n )\n }) as FieldsField<Key, Model, FormMessage>,\n }\n },\n\n /**\n * For `Bundle.withView`: the Submodel view that draws `view`, so a placement\n * renders the form with `placed.view(model, h, { options })`.\n *\n * ```ts\n * const Drawn = EditPost.bundle.pipe(Bundle.withView(FormView.submodel(EditPost, View)))\n * ```\n */\n submodel: <\n Key extends string,\n Model extends { readonly errors: ReadonlyArray<string>; readonly submitPending: boolean },\n Message extends { readonly _tag: string },\n ControlKey extends string = never,\n >(\n form: FormLike<Key, Model, Message, ControlKey>,\n view: SlotView.SlotView<typeof FormSlots, FormInput<Model, Key, ControlKey>, Message>,\n options: {\n /**\n * When the submit waits instead of staying disabled. `true` while a\n * check is running means submitted work waits for it, and the button\n * stays enabled; `false` keeps the button disabled until every key is\n * valid. Default `form.canSubmit` (lenient): a submit made mid-check\n * waits for it. Pass a strict predicate to disable through checks\n * instead, such as `model => PostForm.engine.value(model.form) !==\n * undefined`, or `() => true` to never pre-disable and validate wholly\n * at submit.\n */\n readonly canSubmit?: (model: Model) => boolean\n } = {},\n ): Submodel.View<Model, Message, FormViewInputs<Key, ControlKey>> =>\n Submodel.defineView<Model, Message, FormViewInputs<Key, ControlKey>>((model, inputs, h) =>\n view(\n {\n ...inputs,\n model,\n errors: model.errors,\n canSubmit: (options.canSubmit ?? form.canSubmit)(model),\n submitting: model.submitPending || inputs.submitting === true,\n },\n h,\n ),\n ),\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAa,kBAAkB,aAC5B,MAAM,OAAO,GAAG,OAAO,KAAK,MAAM,QAAQ,GAAG,OAAO,IAAI,QAAQ,KAAK,UAAU,CAAC,EAAA,CAAG,KAClF,YAAW;CAAE,OAAO,OAAO,MAAM;CAAG,OAAO,OAAO,MAAM;AAAE,EAC5D;;AAGF,MAAa,gCAAqC,IAAI,IAAI;CAAC;CAAS;CAAO;AAAK,CAAC;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