foldkit-mixins-ui 0.24.0 → 0.26.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 +196 -14
- package/dist/button.d.ts +8 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +16 -4
- package/dist/button.js.map +1 -1
- package/dist/comboboxView.d.ts.map +1 -1
- package/dist/comboboxView.js +15 -4
- package/dist/comboboxView.js.map +1 -1
- package/dist/datePickerView.d.ts +8 -8
- package/dist/field.d.ts +16 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +3 -1
- package/dist/field.js.map +1 -1
- package/dist/fileDrop.d.ts +17 -0
- package/dist/fileDrop.d.ts.map +1 -1
- package/dist/fileDrop.js +16 -1
- package/dist/fileDrop.js.map +1 -1
- package/dist/floatingPanel.js.map +1 -1
- package/dist/input.d.ts +3 -2
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +6 -4
- package/dist/input.js.map +1 -1
- package/dist/leaveDrawn.d.ts +13 -0
- package/dist/leaveDrawn.d.ts.map +1 -0
- package/dist/leaveDrawn.js +23 -0
- package/dist/leaveDrawn.js.map +1 -0
- package/dist/listboxView.d.ts.map +1 -1
- package/dist/listboxView.js +15 -4
- package/dist/listboxView.js.map +1 -1
- package/dist/menu.d.ts.map +1 -1
- package/dist/menu.js.map +1 -1
- package/dist/menuView.d.ts.map +1 -1
- package/dist/menuView.js +11 -9
- package/dist/menuView.js.map +1 -1
- package/dist/passwordInput.d.ts +19 -7
- package/dist/passwordInput.d.ts.map +1 -1
- package/dist/passwordInput.js +12 -11
- package/dist/passwordInput.js.map +1 -1
- package/dist/questionnaire.d.ts.map +1 -1
- package/dist/questionnaire.js +1 -1
- package/dist/questionnaire.js.map +1 -1
- package/dist/recipes/accordion.d.ts +1 -1
- package/dist/recipes/alert.d.ts +1 -1
- package/dist/recipes/angleSlider.d.ts +1 -1
- package/dist/recipes/angleSlider.d.ts.map +1 -1
- package/dist/recipes/angleSlider.js.map +1 -1
- package/dist/recipes/appShell.d.ts +1 -1
- package/dist/recipes/aspectRatio.d.ts +1 -1
- package/dist/recipes/avatar.d.ts +2 -2
- package/dist/recipes/breadcrumb.d.ts +1 -1
- package/dist/recipes/button.d.ts +1 -1
- package/dist/recipes/buttonGroup.d.ts +1 -1
- package/dist/recipes/calendar.d.ts +1 -1
- package/dist/recipes/card.d.ts +2 -2
- package/dist/recipes/carousel.d.ts +1 -1
- package/dist/recipes/cascadeSelect.d.ts +1 -1
- package/dist/recipes/chart.d.ts +1 -1
- package/dist/recipes/chart.d.ts.map +1 -1
- package/dist/recipes/chart.js.map +1 -1
- package/dist/recipes/chatMessage.d.ts +2 -2
- package/dist/recipes/checkboxGroup.d.ts +1 -1
- package/dist/recipes/checkboxGroup.js +2 -2
- package/dist/recipes/checkboxGroup.js.map +1 -1
- package/dist/recipes/codeBlock.d.ts +1 -1
- package/dist/recipes/colorPicker.d.ts +1 -1
- package/dist/recipes/colorPicker.d.ts.map +1 -1
- package/dist/recipes/colorPicker.js.map +1 -1
- package/dist/recipes/combobox.d.ts +1 -1
- package/dist/recipes/command.d.ts +1 -1
- package/dist/recipes/datePicker.d.ts +1 -1
- package/dist/recipes/design.d.ts +6 -2
- package/dist/recipes/design.d.ts.map +1 -1
- package/dist/recipes/design.js +5 -3
- package/dist/recipes/design.js.map +1 -1
- package/dist/recipes/dialog.d.ts +18 -1
- package/dist/recipes/dialog.d.ts.map +1 -1
- package/dist/recipes/dialog.js +28 -13
- package/dist/recipes/dialog.js.map +1 -1
- package/dist/recipes/disclosure.d.ts +23 -0
- package/dist/recipes/disclosure.d.ts.map +1 -0
- package/dist/recipes/disclosure.js +100 -0
- package/dist/recipes/disclosure.js.map +1 -0
- package/dist/recipes/drawer.d.ts +1 -1
- package/dist/recipes/drawer.d.ts.map +1 -1
- package/dist/recipes/drawer.js +2 -2
- package/dist/recipes/drawer.js.map +1 -1
- package/dist/recipes/empty.d.ts +1 -1
- package/dist/recipes/field.d.ts +2 -2
- package/dist/recipes/fieldset.d.ts +16 -0
- package/dist/recipes/fieldset.d.ts.map +1 -0
- package/dist/recipes/fieldset.js +65 -0
- package/dist/recipes/fieldset.js.map +1 -0
- package/dist/recipes/figure.d.ts +1 -1
- package/dist/recipes/fileDrop.d.ts +1 -1
- package/dist/recipes/fileDrop.d.ts.map +1 -1
- package/dist/recipes/fileDrop.js +2 -3
- package/dist/recipes/fileDrop.js.map +1 -1
- package/dist/recipes/floatingPanel.d.ts +1 -1
- package/dist/recipes/floatingPanel.d.ts.map +1 -1
- package/dist/recipes/floatingPanel.js.map +1 -1
- package/dist/recipes/hoverCard.d.ts +1 -1
- package/dist/recipes/icon.d.ts +1 -1
- package/dist/recipes/image.d.ts +1 -1
- package/dist/recipes/imageCropper.d.ts +1 -1
- package/dist/recipes/imageCropper.d.ts.map +1 -1
- package/dist/recipes/imageCropper.js.map +1 -1
- package/dist/recipes/index.d.ts +3 -1
- package/dist/recipes/index.js +3 -1
- package/dist/recipes/inputCopy.d.ts +1 -1
- package/dist/recipes/item.d.ts +2 -2
- package/dist/recipes/kbd.d.ts +1 -1
- package/dist/recipes/label.d.ts +1 -1
- package/dist/recipes/listbox.d.ts +1 -1
- package/dist/recipes/marquee.d.ts +1 -1
- package/dist/recipes/menu.d.ts +1 -1
- package/dist/recipes/menubar.d.ts +2 -2
- package/dist/recipes/messageScroller.d.ts +1 -1
- package/dist/recipes/meter.d.ts +1 -1
- package/dist/recipes/nav.d.ts +1 -1
- package/dist/recipes/numberField.d.ts +1 -1
- package/dist/recipes/otpField.d.ts +1 -1
- package/dist/recipes/pagination.d.ts +1 -1
- package/dist/recipes/passwordInput.d.ts +1 -1
- package/dist/recipes/picker.d.ts +1 -1
- package/dist/recipes/popover.d.ts +1 -1
- package/dist/recipes/popover.d.ts.map +1 -1
- package/dist/recipes/popover.js.map +1 -1
- package/dist/recipes/progress.d.ts +1 -1
- package/dist/recipes/qrCode.d.ts +1 -1
- package/dist/recipes/questionnaire.d.ts +1 -1
- package/dist/recipes/radio.d.ts +1 -1
- package/dist/recipes/rating.d.ts +1 -1
- package/dist/recipes/resizable.d.ts +1 -1
- package/dist/recipes/scrollArea.d.ts +1 -1
- package/dist/recipes/scrollBars.js.map +1 -1
- package/dist/recipes/segmented.d.ts +1 -1
- package/dist/recipes/select.d.ts +1 -1
- package/dist/recipes/separator.d.ts +1 -1
- package/dist/recipes/sheet.d.ts +7 -1
- package/dist/recipes/sheet.d.ts.map +1 -1
- package/dist/recipes/sheet.js +6 -4
- package/dist/recipes/sheet.js.map +1 -1
- package/dist/recipes/sidebar.d.ts +1 -1
- package/dist/recipes/signaturePad.d.ts +1 -1
- package/dist/recipes/signaturePad.d.ts.map +1 -1
- package/dist/recipes/signaturePad.js +3 -3
- package/dist/recipes/signaturePad.js.map +1 -1
- package/dist/recipes/skeleton.d.ts +1 -1
- package/dist/recipes/slider.d.ts +1 -1
- package/dist/recipes/slider.d.ts.map +1 -1
- package/dist/recipes/slider.js.map +1 -1
- package/dist/recipes/spinner.d.ts +1 -1
- package/dist/recipes/steps.d.ts +1 -1
- package/dist/recipes/table.d.ts +1 -1
- package/dist/recipes/tabs.d.ts +1 -1
- package/dist/recipes/tagsInput.d.ts +1 -1
- package/dist/recipes/thinkingIndicator.d.ts +1 -1
- package/dist/recipes/thinkingSteps.d.ts +1 -1
- package/dist/recipes/timer.d.ts +1 -1
- package/dist/recipes/toast.d.ts +1 -1
- package/dist/recipes/toggle.d.ts +2 -2
- package/dist/recipes/toggle.d.ts.map +1 -1
- package/dist/recipes/toggle.js +4 -1
- package/dist/recipes/toggle.js.map +1 -1
- package/dist/recipes/tooltip.d.ts +1 -1
- package/dist/recipes/tour.d.ts +1 -1
- package/dist/recipes/treeView.d.ts +1 -1
- package/dist/recipes/typography.d.ts +1 -1
- package/dist/recipes/virtualList.d.ts +1 -1
- package/dist/recipes/windowList.d.ts +1 -1
- package/dist/recipes/windowList.d.ts.map +1 -1
- package/dist/recipes/windowList.js +2 -1
- package/dist/recipes/windowList.js.map +1 -1
- package/dist/switch.d.ts +10 -0
- package/dist/switch.d.ts.map +1 -1
- package/dist/switch.js +140 -2
- package/dist/switch.js.map +1 -1
- package/dist/toastView.d.ts +4 -4
- package/dist/toastView.d.ts.map +1 -1
- package/dist/toastView.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -143,7 +143,7 @@ const saveButton = (h: HtmlBuilder<Message>) =>
|
|
|
143
143
|
|
|
144
144
|
The important line is:
|
|
145
145
|
|
|
146
|
-
```ts
|
|
146
|
+
```ts sketch
|
|
147
147
|
toView: Button.toView(mixins, { h }, draw)
|
|
148
148
|
```
|
|
149
149
|
|
|
@@ -225,6 +225,56 @@ deliver.
|
|
|
225
225
|
A button drawn as a button needs no `draw` at all. `Button.view` takes the
|
|
226
226
|
label, a style, and `@foldkit/ui`'s own config:
|
|
227
227
|
|
|
228
|
+
<!-- docs-check standalone
|
|
229
|
+
import { Schema } from 'effect'
|
|
230
|
+
import { FieldValidation } from 'foldkit'
|
|
231
|
+
import type { HtmlBuilder } from 'foldkit/html'
|
|
232
|
+
import { defineMessageUnion } from 'foldkit/message'
|
|
233
|
+
import { Capability, Slot, Slots, Style } from 'foldkit-mixins'
|
|
234
|
+
import { Layers } from 'foldkit-mixins'
|
|
235
|
+
import {
|
|
236
|
+
ButtonSlots,
|
|
237
|
+
Icons,
|
|
238
|
+
InputSlots,
|
|
239
|
+
Listbox,
|
|
240
|
+
ListboxSlots,
|
|
241
|
+
Menu,
|
|
242
|
+
MenuSlots,
|
|
243
|
+
ScrollArea,
|
|
244
|
+
SegmentedSlots,
|
|
245
|
+
Segmented,
|
|
246
|
+
Tabs,
|
|
247
|
+
TabsSlots,
|
|
248
|
+
TextareaSlots,
|
|
249
|
+
Touch,
|
|
250
|
+
} from 'foldkit-mixins-ui'
|
|
251
|
+
const Message = defineMessageUnion({
|
|
252
|
+
Saved: {},
|
|
253
|
+
TypedEmail: { value: Schema.String },
|
|
254
|
+
TypedTitle: { value: Schema.String },
|
|
255
|
+
TypedReply: { value: Schema.String },
|
|
256
|
+
TypedPassword: { value: Schema.String },
|
|
257
|
+
ToggledPassword: {},
|
|
258
|
+
ToggledMark: { mark: Schema.String },
|
|
259
|
+
})
|
|
260
|
+
type Message = typeof Message.Type
|
|
261
|
+
const SaveStyle = Style.forSlots(ButtonSlots)({ button: Style.class('btn btn-primary') })
|
|
262
|
+
const FieldStyle = Style.forSlots(InputSlots)({ input: Style.class('field') })
|
|
263
|
+
const TextareaStyle = Style.forSlots(TextareaSlots)({ textarea: Style.class('reply') })
|
|
264
|
+
const Container = Slot.make({ capability: Capability.Container })
|
|
265
|
+
const EntrySlots = Slots.define({ badge: Container })
|
|
266
|
+
const FieldSlots = Slots.define({ group: Container, affix: Container, text: Container })
|
|
267
|
+
const TabsStyle = Style.forSlots(TabsSlots)({})
|
|
268
|
+
const MenuStyle = Style.forSlots(MenuSlots)({})
|
|
269
|
+
const ListboxStyle = Style.forSlots(ListboxSlots)({})
|
|
270
|
+
const ScrollAreaSlots = Slots.define({ root: Container })
|
|
271
|
+
const TileSlots = Slots.define({ tile: Container })
|
|
272
|
+
const MyTabsSlots = Slots.define({ tablist: Container })
|
|
273
|
+
declare const h: HtmlBuilder<Message>
|
|
274
|
+
declare const model: { readonly marks: ReadonlyArray<string> }
|
|
275
|
+
declare const iconUrl: (name: string) => string
|
|
276
|
+
-->
|
|
277
|
+
|
|
228
278
|
```ts
|
|
229
279
|
import { Button } from 'foldkit-mixins-ui'
|
|
230
280
|
|
|
@@ -241,6 +291,17 @@ const saveButton = (disabled: boolean, h: HtmlBuilder<Message>) =>
|
|
|
241
291
|
)
|
|
242
292
|
```
|
|
243
293
|
|
|
294
|
+
`disabled` writes `aria-disabled`, not `disabled`, as upstream does, so the
|
|
295
|
+
button keeps its focus. A `type: 'submit'` one therefore still submits its
|
|
296
|
+
form, on Enter or a press: refuse the submit in `update` while it should not
|
|
297
|
+
go.
|
|
298
|
+
|
|
299
|
+
`attributes: { button?, icon? }` adds what another component hands a slot,
|
|
300
|
+
before the mixins resolve, as `PasswordInput.view`'s do: a Dialog's
|
|
301
|
+
`initialFocus`, so the dialog opens on that button (`attributes: { button:
|
|
302
|
+
dialog.initialFocus }`). A class among them joins the style's, and an event
|
|
303
|
+
or attribute a mixin owns is a conflict.
|
|
304
|
+
|
|
244
305
|
An `icon` (an `svg`) draws before the label in the `icon` slot, hidden from
|
|
245
306
|
assistive technology; `Recipes.Button({ variant: 'icon' })` shows the icon
|
|
246
307
|
alone, the label still the button's name. `shape: 'square'` draws any other
|
|
@@ -271,6 +332,57 @@ const emailField = (value: string, h: HtmlBuilder<Message>) =>
|
|
|
271
332
|
)
|
|
272
333
|
```
|
|
273
334
|
|
|
335
|
+
A closure is not data, so a page that answers before its script runs
|
|
336
|
+
(`foldkit-ssr`'s [resumable pages](https://github.com/doeixd/foldkit-plus/blob/main/packages/ssr/README.md#resumable-pages-answering-before-the-runtime-boots))
|
|
337
|
+
cannot write it into the server's markup. There, give `onInput` the
|
|
338
|
+
`OnInput` attribute the resumable builder makes from a Message member; the
|
|
339
|
+
view adds it as it would the closure, and `KeepTyped` keeps what is typed
|
|
340
|
+
before the script runs:
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
import { Resume } from 'foldkit-ssr/client'
|
|
344
|
+
|
|
345
|
+
const resumableEmail = (value: string, h: HtmlBuilder<Message>) => {
|
|
346
|
+
const rh = Resume.builder(h)
|
|
347
|
+
return Input.view(
|
|
348
|
+
{
|
|
349
|
+
id: 'email',
|
|
350
|
+
value,
|
|
351
|
+
onInput: rh.OnInput(Message.TypedEmail),
|
|
352
|
+
type: 'email',
|
|
353
|
+
draw: ({ input, label }) =>
|
|
354
|
+
rh.div([], [rh.label(label, ['Email']), rh.input([...input, rh.KeepTyped()])]),
|
|
355
|
+
},
|
|
356
|
+
rh,
|
|
357
|
+
)
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
`PasswordInput` draws its own input, so `KeepTyped` goes in its
|
|
362
|
+
`attributes`, which adds to a Slot before the mixins resolve. Give it only
|
|
363
|
+
while the field is enabled: a disabled field sends nothing, and the server
|
|
364
|
+
refuses a kept field with nothing to replay (`UnkeepableField`).
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
import { PasswordInput } from 'foldkit-mixins-ui'
|
|
368
|
+
|
|
369
|
+
const resumablePassword = (password: string, shown: boolean, h: HtmlBuilder<Message>) => {
|
|
370
|
+
const rh = Resume.builder(h)
|
|
371
|
+
return PasswordInput.view(
|
|
372
|
+
{
|
|
373
|
+
id: 'password',
|
|
374
|
+
label: 'Password',
|
|
375
|
+
value: password,
|
|
376
|
+
onInput: rh.OnInput(Message.TypedPassword),
|
|
377
|
+
visible: shown,
|
|
378
|
+
onToggle: Message.ToggledPassword(),
|
|
379
|
+
attributes: { input: [rh.KeepTyped()] },
|
|
380
|
+
},
|
|
381
|
+
rh,
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
274
386
|
`Input.field` and `Textarea.field` draw a whole field from a
|
|
275
387
|
`FieldValidation.Field`: the value, its first error or checking mark as the
|
|
276
388
|
description, and `aria-invalid` where the field is invalid. `changed` maps the
|
|
@@ -451,10 +563,10 @@ adapter.
|
|
|
451
563
|
| Textarea | `textarea`, `label`, `description`, `count`, `frame`, `footer`, `meta` |
|
|
452
564
|
| Select | `select`, `label`, `description`. The native `<select>`; the recipe draws its own chevron and mutes a chosen placeholder. For icons, descriptions, groups or a check in the list, draw a Listbox as a custom select with `Listbox.parts` (below) |
|
|
453
565
|
| Checkbox | `checkbox`, `label`, `description`, `hiddenInput` |
|
|
454
|
-
| Switch | `button`, `label`, `description`, `hiddenInput` |
|
|
455
|
-
| Fieldset | `fieldset`, `legend`, `description` |
|
|
456
|
-
| Disclosure | `button`, `panel` |
|
|
457
|
-
| Dialog | `dialog`, `backdrop`, `panel`, `title`, `description`, `initialFocus`, `closeButton`, and this package's `handle` (the Sheet's grabber, `aria-hidden`), `body`, `scroll`, `scrollBar`, `scrollThumb` and `footer`: draw `scroll` and its bar inside `body` and the answers in `footer`, and a body taller than the screen scrolls under the title while the footer stays (`Dialog.overlayBars` beside the style draws the overlay bar). `Dialog.keyboard` among the mixins of a dialog or sheet that holds a field measures the on-screen keyboard on the panel, and the recipes keep the panel above it (a Dialog shrinks, a bottom Sheet stands on it): iOS Safari and Chrome on Android otherwise leave it under the keys. An alert dialog is this one with `role: 'alertdialog'` in its context (`Dialog.toView(mixins, { h, role: 'alertdialog' }, draw)`), which puts `role="alertdialog"` on the `dialog` bundle; draw no close button, and drop the Messages `Dialog.isDismissal` names (Escape, the backdrop, the close button) in `update`, so only its own buttons, closing with `@foldkit/ui`'s `close`, answer it. `covered: true` in the context marks the panel `data-covered`, for a dialog another was opened from (draw the second inside the first's `dialog`, beside its panel), and the recipe steps it back; `attributes` adds to a bundle before the mixins resolve. Recipe `size`: `sm`, `md` (default), `lg`, `xl`, `full` |
|
|
566
|
+
| Switch | `button`, `label`, `description`, `hiddenInput`. `Switch.draggable(onToggle)` beside the style lets the thumb be dragged: it follows the pointer past 4px, and on release `onToggle` is sent for the side its middle is on (nothing when that is the side it began on); a click after a drag is swallowed, right to left mirrors it, and a disabled or read-only switch does not drag. The thumb is held where it was let go for 300ms or until `aria-checked` changes, so an `update` that refuses the toggle sends it back. Pass the `onToggle` the view was given |
|
|
567
|
+
| Fieldset | `fieldset`, `legend`, `description`. The recipe floats the legend into the group, so a box drawn round it holds the legend, and a disabled fieldset dims its legend and description beside the controls the browser disables. Recipe `variant`: `plain` (default, no box), `bordered`, `filled`; a boxed group pads its fields, and a control in it takes a corner concentric with the box's |
|
|
568
|
+
| Disclosure | `button`, `panel`. The recipe draws the button as a row with a chevron of its own (down shut, up once `data-open`) and the panel's box; draw the panel only while open, or through upstream's `animatePanel`, which keeps a shut panel inert and moves its height itself by an inline transition, which the recipe overrides with an important rule so the `motion` knob scales it and reduced motion snaps it. Recipe `variant`: `plain` (default), `bordered` (one box round the button and the panel, whose lower corners square onto the panel while open), `ghost` (filled under the pointer); `indicator`: `chevron` (default), `none` |
|
|
569
|
+
| Dialog | `dialog`, `backdrop`, `panel`, `title`, `description`, `initialFocus`, `closeButton`, and this package's `handle` (the Sheet's grabber, `aria-hidden`), `body`, `scroll`, `scrollBar`, `scrollThumb` and `footer`: draw `scroll` and its bar inside `body` and the answers in `footer`, and a body taller than the screen scrolls under the title while the footer stays (`Dialog.overlayBars` beside the style draws the overlay bar). `Dialog.keyboard` among the mixins of a dialog or sheet that holds a field measures the on-screen keyboard on the panel, and the recipes keep the panel above it (a Dialog shrinks, a bottom Sheet stands on it): iOS Safari and Chrome on Android otherwise leave it under the keys. An alert dialog is this one with `role: 'alertdialog'` in its context (`Dialog.toView(mixins, { h, role: 'alertdialog' }, draw)`), which puts `role="alertdialog"` on the `dialog` bundle; draw no close button, and drop the Messages `Dialog.isDismissal` names (Escape, the backdrop, the close button) in `update`, so only its own buttons, closing with `@foldkit/ui`'s `close`, answer it. `covered: true` in the context marks the panel `data-covered`, for a dialog another was opened from (draw the second inside the first's `dialog`, beside its panel), and the recipe steps it back; `attributes` adds to a bundle before the mixins resolve. Recipe `size`: `sm`, `md` (default), `lg`, `xl`, `full`; `title`: `shown` (default) or `hidden`, which leaves the heading to a screen reader alone (it still names the dialog, as `display: none` would not). The backdrop is the `overlay.scrim` token |
|
|
458
570
|
| Popover | `button`, `panel`, `backdrop`, `arrow`, and this package's `layer`, drawn around the panel to show it in the top layer (see [The top layer](#the-top-layer)); `Popover.anchor(config?)` is the placement. Recipe `arrow`: `shown` (default), `none` |
|
|
459
571
|
| Tooltip | `trigger`, `panel`, `arrow`, and this package's `layer`. `Tooltip.toView(mixins, { h, id }, draw)` takes the Tooltip's id (`model.id`), whose trigger the arrow points at; `Tooltip.anchor(config?)` is the placement, above by default. Recipe `arrow`: `shown` (default), `none` |
|
|
460
572
|
| HoverIntent | `trigger`, `panel`, `arrow` (open and close delays with intent, for a hover card or a menu). `anchored: { id, anchor? }` in the context anchors the panel to the trigger in the top layer (`HoverIntent.anchor()` unless given), the trigger taking `HoverIntent.triggerId(id)` |
|
|
@@ -463,12 +575,50 @@ adapter.
|
|
|
463
575
|
| Anchor | a Mount and a Behavior over `@foldkit/ui/anchor`: `Anchor.behavior(Slots)({ floating, config })` positions a floating slot against a button by id; `Anchor.topLayer(mount)` shows an in-place panel in the top layer around it (see [The top layer](#the-top-layer)) |
|
|
464
576
|
| Calendar | `root`, `header` (the heading's row, this package's own), `grid`, `headerRow`, `previousMonthButton`, `nextMonthButton`, `headingButton`, `previousPageButton`, `nextPageButton`, `columnHeader`, `weekRow`, `dayCell`, `dayButton`, `monthCell`, `monthButton`, `yearCell`, `yearButton`. `Calendar.readingKeys` as Tabs' |
|
|
465
577
|
| Menu | `wrapper`, `button`, `backdrop`, `items`, `scroll`, `item`, `group`, `heading`, `separator`, and this package's `rows`, `highlight`, `scrollBar` and `scrollThumb` (while the panel has a `scroll`), `label`, `sub` and `chevron` (the component's rows) (over the `MenuView` fork; see [Why some components needed a fork](#why-some-components-needed-a-fork)) |
|
|
466
|
-
| FileDrop | `root`, `input` |
|
|
578
|
+
| FileDrop | `root`, `input`. `FileDrop.Message` is `@foldkit/ui/fileDrop`'s four Messages over a `File` codec that needs no decoding services: upstream's own types its files as `Schema<File>`, whose services are `unknown`, so a Message holding it cannot be a `Bundle.parent`'s. `FileDrop.update` of upstream takes it as it is |
|
|
467
579
|
| Toast | `container`, `entry` (over the `ToastView` fork; the dismiss control stays inside the consumer's `entryToView`), and the slots the `Toast` component draws (see the vocabulary below) |
|
|
468
580
|
| Listbox | `wrapper`, `button`, `backdrop`, `items`, `scroll`, `item`, `group`, `heading`, `separator`, and this package's `rows`, `highlight`, `indicator`, `scrollBar`, `scrollThumb`, and an option's and the trigger's parts (`itemIcon`, `itemLabel`, `itemDescription`, `itemCheck`, `value`, `valueText`, `chevron`, …) (over the `ListboxView` fork; single and multi share one transcription). A custom select is a Listbox drawn with `Listbox.parts(mixins, { h })`: `part.option({ label, description?, icon? })` as an item's content and `part.trigger(chosen, placeholder)` as the button's, its value or the placeholder (muted, `data-placeholder`) and a chevron. Recipe axes `width`: `auto` (default) or `trigger`; `check`: `end` (default), `start`, `none`; `trigger`: `outline` (default), `filled`, `ghost`; `size`: `sm`, `md`, `lg` |
|
|
469
581
|
| Combobox | `wrapper`, `inputWrapper`, `input`, `toggleButton`, `backdrop`, `items`, `scroll`, `item`, `group`, `heading`, `separator`, and this package's `rows`, `highlight`, `indicator`, `scrollBar`, `scrollThumb`, `chips`, `chip`, `chipRemove`, `clearButton`, `empty` and an option's parts (over the `ComboboxView` fork; single and multi share one transcription). The view inputs add `chips: { label?, removeLabel? }` (each chosen value a chip in the field, its remove button choosing it again, which a multiple combobox toggles off: with `ComboboxView.Multi`, a tags field with suggestions), `clearContent` and `clearLabel` (a clear button while the field has text) and `empty` (shown, as a polite status, in the list's place while open with nothing to list; a loading line too). `Combobox.parts(mixins, { h }).option(content, query)` marks the typed text in an option's label. Recipe axis `width`: `trigger` (default) or `auto` |
|
|
470
582
|
| DatePicker | `trigger`, `panel`, `backdrop` (over the `DatePickerView` fork, which keeps upstream's Popover+Calendar composition and seams only the popover assembly). A range or many days in the popover: see [Why some components needed a fork](#why-some-components-needed-a-fork) |
|
|
471
583
|
|
|
584
|
+
A disclosure with its recipe: the recipe draws the button and the panel's box,
|
|
585
|
+
and `animatePanel` keeps the shut panel inert and moves its height.
|
|
586
|
+
|
|
587
|
+
<!-- docs-check
|
|
588
|
+
declare const ToggledDetails: (payload: { readonly isOpen: boolean }) => Message
|
|
589
|
+
-->
|
|
590
|
+
|
|
591
|
+
```ts
|
|
592
|
+
import { Disclosure as UiDisclosure } from '@foldkit/ui'
|
|
593
|
+
import { Style } from 'foldkit-mixins'
|
|
594
|
+
import { Disclosure, DisclosureSlots, Recipes } from 'foldkit-mixins-ui'
|
|
595
|
+
|
|
596
|
+
const DetailsStyle = Style.forSlots(DisclosureSlots)(Recipes.Disclosure({ variant: 'bordered' }))
|
|
597
|
+
|
|
598
|
+
const details = (isOpen: boolean, h: HtmlBuilder<Message>) =>
|
|
599
|
+
UiDisclosure.view(
|
|
600
|
+
{
|
|
601
|
+
id: 'details',
|
|
602
|
+
isOpen,
|
|
603
|
+
onToggle: isOpen => ToggledDetails({ isOpen }),
|
|
604
|
+
toView: attributes => {
|
|
605
|
+
const disclosure = Disclosure.resolve(attributes, [DetailsStyle.mixin], {
|
|
606
|
+
input: undefined,
|
|
607
|
+
h,
|
|
608
|
+
})
|
|
609
|
+
return h.div(
|
|
610
|
+
[],
|
|
611
|
+
[
|
|
612
|
+
h.button(disclosure.button, ['Shipping details']),
|
|
613
|
+
disclosure.animatePanel(h.div(disclosure.panel, ['Shipped in two days.'])),
|
|
614
|
+
],
|
|
615
|
+
)
|
|
616
|
+
},
|
|
617
|
+
},
|
|
618
|
+
h,
|
|
619
|
+
)
|
|
620
|
+
```
|
|
621
|
+
|
|
472
622
|
## Views and components of this package
|
|
473
623
|
|
|
474
624
|
These views take no `@foldkit/ui` bundle. Call `X.view(options, h)`. Most own no
|
|
@@ -547,7 +697,7 @@ glyph with it, so the recipe's size is the drawing's.
|
|
|
547
697
|
| `NumberField` | `{ id, label, description?, value, onChange, min?, max?, step?, page?, format?, disabled? }`; `NumberField.settled(value, bounds)` clamps a value onto its step. The APG's editable spinbutton: an input with `role="spinbutton"` that the arrows, PageUp and PageDown, Home and End step, a typed number committing on change, between steppers out of the tab order that disable at their bound. | No axis. Slots `root`, `label`, `group`, `input`, `decrement`, `increment`, `description`. |
|
|
548
698
|
| `OtpField` | `{ label, value, onChange, length?, pattern?, groups?, disabled? }`; `OtpField.kept(text, length, pattern)` filters a code. shadcn's input-otp: one real input (`autocomplete="one-time-code"`, paste and Backspace the browser's) over cells that mirror it, the next cell marked `data-next` for its caret. | No axis. Slots `root`, `input`, `group`, `cell`, `separator`. |
|
|
549
699
|
| `Pagination` | `{ page, pageCount, onPage, label?, siblings?, boundaries?, numbered?, ends?, range? }`. Fewer than two pages draws nothing. `Pagination.itemsOf(page, pageCount, window?)` is the stops; `Pagination.summaryOf(page, { total, perPage, text? })` is `"1–10 of 97"`, drawn before the stops when `range` is given. `range.choose: { sizes, onPerPage, label? }` adds a select of rows per page (labelled `Rows per page` by default) that sends `onPerPage` with the size; the application sets `perPage` and a page that keeps its rows in view. `numbered: false` leaves previous and next alone; `ends` draws first and last. The current stop holds ` / 12` in a `pageCount` span hidden from assistive technology. | `compact`: `narrow` (default, below a 30rem window), `always` or `never`. Compact shows only the current number, with its ` / 12`, and no ellipses. The current stop reads `aria-current`. Slots `root`, `summary`, `perPage`, `perPageSelect`, `first`, `prev`, `next`, `last`, `page`, `pageCount`, `ellipsis`. |
|
|
550
|
-
| `PasswordInput` | `PasswordInput.view({ id, label, value, onInput, visible, onToggle, autocomplete?, toggleLabel?, description?, invalid?, disabled? }, h)`: a password field whose toggle button (`aria-pressed`, `aria-controls`, one fixed name) shows it as text. `autocomplete` is `current-password` (default) or `new-password`; spellcheck and autocorrect stay off. `strength` is a `Meter
|
|
700
|
+
| `PasswordInput` | `PasswordInput.view({ id, label, value, onInput, visible, onToggle, autocomplete?, toggleLabel?, description?, invalid?, disabled?, attributes? }, h)`: a password field whose toggle button (`aria-pressed`, `aria-controls`, one fixed name) shows it as text. `autocomplete` is `current-password` (default) or `new-password`; spellcheck and autocorrect stay off. `strength` is a gauge the app draws (`Meter.view(…, h)`), placed under the field, so a page with none ships no Meter; `requirements` are `{ label, met }[]` (`PasswordRequirement`), listed and each read as met or not (`requirementStates`); `capsLock: { on, onKey }` says Caps Lock is on, politely, `onKey` given `capsLockOf(key, modifiers)` for each key (an `Option`: none for a key that says nothing of it). The app owns the text, the flag and the Caps Lock reading. `onInput` is a closure or a resumable builder's `OnInput` attribute, and `attributes` adds to any Slot (`{ input: [rh.KeepTyped()] }`), as the resumable examples above show. | `size` (`sm`, `md`, `lg`). Input's pieces in InputGroup's box; the eye is `Icons.glyph` by `aria-pressed`. Slots `root`, `label`, `group`, `input`, `toggle`, `description`, `strength`, `requirements`, `requirement`, `requirementState`, `capsLock`. |
|
|
551
701
|
| `Progress` | `@foldkit/ui`'s Progress: `Progress.view({ id, label, value, min?, max?, valueText?, style? }, h)` draws a `progressbar` named by its label. `value` is an `Option`; none is indeterminate, and the bar's fill sweeps toward the inline end, leftward right to left. The root carries the share done as `--fk-progress`. `showValue` draws the value (`valueText`, else a percentage) at the end of a bar's label line and inside a ring. A `value` given as `ProgressSection`s is one stacked bar of toned parts, read aloud as their sum; `buffer` draws how far the work could go behind the fill; `segments` cuts the track into steps. | `shape`: `bar` (default) or `ring`, Circular Progress; `tone`: `accent`, `neutral`, `success`, `warning`, `error`, `info` (Meter's tokens); `stripes`: `none` (default), `still`, `moving` (travel-aware); `size`: `sm`, `md`, `lg`. Slots `root`, `label`, `track`, `indicator`. |
|
|
552
702
|
| `QrCode` | After Zag's: `QrCode.view({ id, value, label?, level?, quietZone?, overlay?, tooLong?, style? }, h)`, one `img` named `QR code: <value>` (or `label`), every dark module one SVG `path` over a background that carries the quiet zone. `level` is the error correction, `M` by default and `H` under an `overlay` (a logo at the centre). `QrCode.encode(text, level)` gives the matrix, none when no version holds the text, and `pathOf` its path; both are pure. `QrCode.Download({ id, format, filename, pixels })` saves the drawn code as PNG or SVG in the colors it shows; the overlay is not in the file. | `scheme` (`light`, dark on light on any page, or `page`), `size`. Slots `root`, `frame`, `background`, `pattern`, `overlay`, `fallback`. |
|
|
553
703
|
| `Questionnaire` | An assistant's questions answered in the chat. `Questionnaire.init({ id, questions, layout? })` with `Questionnaire.single`, `multiple` and `text` questions (`Question` is a Schema, so a tool's input decodes into it), folded with `Questionnaire.update`, which says what is missing and focuses it, and returns `OutMessage.Answered({ answers })` once every required question is answered; the form then gives way to a summary. `Questionnaire.view({ model, onMessage, title?, style?, radioGroup?, checkboxGroup?, input?, textarea?, button?, submitButton? }, h)`: the controls are the package's RadioGroup, CheckboxGroup, Input and Textarea, each taking its own style. | `variant` (`plain`, `card`), `actions` (`end`, `start`). Slots `root`, `title`, `progress`, `question`, `prompt`, `words`, `field`, `other`, `otherLabel`, `error`, `actions`, `summary`, `asked`, `answer`. |
|
|
@@ -556,7 +706,7 @@ glyph with it, so the recipe's size is the drawing's.
|
|
|
556
706
|
| `ScrollArea` | `{ content }`. The height that makes it scroll is the caller's mixin, on `viewport` or `root`; a width goes on `root`, which the viewport fills and the bars lie over. The viewport is tabbable. A bar per axis is drawn beside the viewport, and `ScrollArea.overlayBars` beside the style lays them over its edge, driven by `ScrollBars` from `foldkit-primitives/dom`: a thumb that rests 4px wide, widens to 6px under the pointer, and fades once scrolling and the pointer rest; a coarse pointer keeps the browser's bar. See [Overlay scroll bars](#overlay-scroll-bars). | `orientation`: `vertical` (default), `horizontal`, `both`; `vertical` and `horizontal` fade the content toward an edge with more past it and draw a hairline there. Slots `root`, `viewport`, `bar`, `thumb`. |
|
|
557
707
|
| `Separator` | `{ orientation?, label?, decorative? }`, horizontal by default. A `label` sits between two drawn rules and is read as text; `decorative` is `role="none"`. The rule and a label's frame carry `data-orientation`, which the recipe reads, so one style draws both orientations. A vertical rule stretches across a flex or grid row, short of it by the inset, and elsewhere (running text) stands as tall as the letters. | `line`: `solid`, `dashed`, `dotted`; `thickness`: `thin`, `thick`; `spacing`: `none`, `sm`, `md`, `lg`; `inset`: `none`, `sm`, `md`. The line is a border in `outline.default`, which a dark page shows. Slots `rule`, `root`, `label`. |
|
|
558
708
|
| `Drawer` | A panel docked to the bottom of the screen that peeks or opens beside the page, not over it: no focus trap, backdrop or scroll lock, so the page under it stays live (a modal one is the `Sheet`). `Drawer.init({ id, open?, swipe? })` (down by default), folded with `Drawer.update`, opened with `Drawer.open` and `Drawer.close`, drawn with `Drawer.view({ model, onMessage, labels: { open, closed }, style?, mixins?, draw }, h)`, `draw` laying out `panel`, `handle`, `body` (the body may sit below what else peeks with the handle) and, optionally, `grip`, more to drag it by (a row of tabs: vertical swipes drag it, sideways ones still scroll). A drag follows the finger and lets go open or down by its speed, then by how far it came. `swipe: { from?, flickSpeed?, closeShare? }` says how it is swiped: a finger drags it from anywhere on the panel (`from: 'panel'`, the default), yielding to content that can still scroll its way, so a long one scrolls back to its top and then goes, and a field or `data-no-swipe` starts no drag; a mouse drags it by the handle, and `from: 'handle'` keeps every pointer there. A release faster than `flickSpeed` (0.4px/ms) is a flick, and a slow one goes once dragged `closeShare` (a quarter) of the panel. A click or Enter on the handle toggles it, and the click a browser sends after a drag does not. The panel's inline style is the drag's: set `--fk-drawer-peek` (default 5rem) and `--fk-drawer-height` (default 70dvh) on an ancestor or in a style. | `Recipes.Drawer`: `dock`: `always` (default), `below-lg` or `below-xl`, above which the panel is the column it sits in, with no handle. The handle's bar bends into a chevron going down, with the finger while dragged. Slots `panel`, `handle`, `body`, `grip`. The handle is a 44px target drawn tight to its bar, and the peek stays above the home indicator. |
|
|
559
|
-
| `Sheet` | A Dialog a finger drags, vaul's Drawer: `Sheet.init({ id, side?, points?, opensAt?, dismissible?, isAnimated?, swipe? })`, folded with `Sheet.update` and opened with `Sheet.open` and `Sheet.close` (each also reporting the Dialog's `Opened` or `Closed`), drawn with `Sheet.view({ model, onMessage, mixins, hasDescription?, covered?, scalesPage?, draw }, h)`, `draw` laying out `DialogSlots`' bundles with `h.div(sheet.handle)` in the panel. The panel stands on `side`'s edge (`data-side`); a drag follows the pointer and settles at the nearest of `points` (the share of the panel shown, ascending; a top or bottom sheet with a point below 1 takes its `size`'s full height, so a short one still shows its start, and below its highest point its content holds still, so a swipe up raises it), or, flicked or dragged far enough past the first, closes it, unless `dismissible: false`. `swipe: { from?, flickSpeed?, closeShare? }` says how it is swiped: a finger drags it from anywhere on the panel (`from: 'panel'`, the default), yielding to content that can still scroll its way, so a long one scrolls back to its top and then goes, and a field or `data-no-swipe` starts no drag; a mouse drags it by the handle, and `from: 'handle'` keeps every pointer there. A release faster than `flickSpeed` (0.4px/ms) is a flick, and a slow one goes once dragged `closeShare` (a quarter) of the panel. The Dialog keeps focus, Escape and scroll lock. `scalesPage` with `Recipes.sheetPage` on the page beside the sheet, never around it, steps the page back while it is open. | `Recipes.Sheet`: `size`: `sm`, `md` (default), `lg`, `full`; `handle`: `bar` (default) or `none`. Slots are `DialogSlots`. |
|
|
709
|
+
| `Sheet` | A Dialog a finger drags, vaul's Drawer: `Sheet.init({ id, side?, points?, opensAt?, dismissible?, isAnimated?, swipe? })`, folded with `Sheet.update` and opened with `Sheet.open` and `Sheet.close` (each also reporting the Dialog's `Opened` or `Closed`), drawn with `Sheet.view({ model, onMessage, mixins, hasDescription?, covered?, scalesPage?, draw }, h)`, `draw` laying out `DialogSlots`' bundles with `h.div(sheet.handle)` in the panel. The panel stands on `side`'s edge (`data-side`); a drag follows the pointer and settles at the nearest of `points` (the share of the panel shown, ascending; a top or bottom sheet with a point below 1 takes its `size`'s full height, so a short one still shows its start, and below its highest point its content holds still, so a swipe up raises it), or, flicked or dragged far enough past the first, closes it, unless `dismissible: false`. `swipe: { from?, flickSpeed?, closeShare? }` says how it is swiped: a finger drags it from anywhere on the panel (`from: 'panel'`, the default), yielding to content that can still scroll its way, so a long one scrolls back to its top and then goes, and a field or `data-no-swipe` starts no drag; a mouse drags it by the handle, and `from: 'handle'` keeps every pointer there. A release faster than `flickSpeed` (0.4px/ms) is a flick, and a slow one goes once dragged `closeShare` (a quarter) of the panel. The Dialog keeps focus, Escape and scroll lock. `scalesPage` with `Recipes.sheetPage` on the page beside the sheet, never around it, steps the page back while it is open. | `Recipes.Sheet`: `size`: `sm`, `md` (default), `lg`, `full`; `handle`: `bar` (default) or `none`; `title`: `shown` (default) or `hidden`. Slots are `DialogSlots`. The panel's padding keeps clear of the safe areas (`Theme.tokens.safe`) on the sides it touches. |
|
|
560
710
|
| `Picker` | A select that is a dropdown on a desktop and a bottom sheet on a phone, with one Model and one set of Messages whatever the width: `Picker.init({ id, sheet? })` (upstream's Listbox Model and a `Sheet`'s), folded with `Picker.update`, which returns `Picker.OutMessage.Chose({ value })` for a choice made either way, drawn with `Picker.view({ model, onMessage, label, options, value, placeholder, anchor?, style?, mixins?, listbox?, sheet? }, h)`. The application keeps the value (`Option`), as with the Listbox; `options` are `{ value, label, description?, icon? }`, `Value` inferred from them. Both halves are drawn and the recipe shows one, so nothing reads the width: the Listbox (its panel kept in place) at or above the breakpoint, and below it an opener whose Sheet lists the options as a listbox, the chosen one (or the first) focused, the arrows, Home and End moving focus, Enter, Space or a tap choosing and closing it. Opening the Sheet closes a Listbox left open. `listbox` takes `Recipes.Listbox`, which also draws the options' and the trigger's content (`Listbox.parts`), and `sheet` takes `Recipes.Sheet`. | `Recipes.Picker`: `sheetBelow`: `sm`, `md` (default) or `lg`, the theme's breakpoint below which the Sheet's half shows; `trigger`: `outline` (default), `filled`, `ghost`, the opener's look, as the Listbox's; `size`: `sm`, `md`, `lg`. Slots `root`, `dropdown`, `opener`, `list`, `option`. |
|
|
561
711
|
| `Sidebar` | shadcn's sidebar with Fluid's collapse, keeping a Model: `Sidebar.init({ id, rows, open?, collapsed?, side?, width? })` (a Tooltip per row id, and the phone's Sheet), folded with `Sidebar.update`, drawn with `Sidebar.view({ model, onMessage, label, groups, header?, footer?, direction?, collapse?, style?, mixins?, tooltip?, sheet? }, h)`. `groups` are `{ id, title?, collapsible?, action?, rows }`, a row a `SidebarLink` (`{ id, label, href, current?, icon?, badge?, action? }`) or a `SidebarBranch` of nested links (`items`). An `action` (`SidebarAction`: `{ label, icon, message }`) is a button at a titled group's heading or beside a link, where it takes the badge's place under the pointer (both show on a touch screen). Groups and branches open like an accordion's, several at once; the current page is `aria-current` and `Sidebar.fluid` glides a marker to it. `collapse: 'offcanvas'` (default) takes the whole column off the page; `'icons'` leaves a rail of icons named in Tooltips (`tooltip`, a Tooltip style). With `sheet` (a Sheet style), an opener shows it in a Sheet on a phone. Shut groups and a collapsed column stay drawn and `inert`. `Sidebar.init({ width: { size?, min?, max? } })` makes the column resizable, its width in the Model: a `resize` handle on its edge drags it, the arrows step it, Enter or a double-click collapses it, and dragged below half `min` it collapses, coming back at the width the drag began at. | `variant`: `sidebar` (flush with the page's edge, the default), `floating` (a card lifted off it), `inset` (no edge, on the surface it stands on, for a page drawn as a card beside it); on a phone with a Sheet the column is its opener alone. Slots `root`, `header`, `footer`, `opener`, `title`, `toggle`, `nav`, `section`, `heading`, `trigger`, `chevron`, `links`, `item`, `branch`, `link`, `icon`, `mark`, `detail`, `label`, `badge`, `action`, `tip`, `indicator`, `highlight`, `resize`. |
|
|
562
712
|
| `SignaturePad` | After Zag's: strokes drawn by one pointer over a dashed line and "Sign here", undo, clear, and a typed name instead. `SignaturePad.init({ id, pen? })` holds the strokes (points with pressure, in the pad's coordinates), folded with `SignaturePad.update`. Drawn with `SignaturePad.view({ model, onMessage, label, fallback?, labels?, disabled?, style? }, h)`. `pathOf(stroke, pen)` and `toSvg(model, { color?, font? })` are pure; `RequestedPng({ scale, background })` returns `ExportPng`, answered by `ExportedPng({ url, width, height })` or `FailedExport`. | `surface` (`plain`, `muted`, `dashed`), `size`. Slots `root`, `label`, `control`, `segments`, `stroke`, `guide`, `placeholder`, `typedName`, `controls`, `undo`, `clear`, `fallback`, `fallbackLabel`, `input`. |
|
|
@@ -574,7 +724,7 @@ glyph with it, so the recipe's size is the drawing's.
|
|
|
574
724
|
| `TreeView` | The APG's and Zag's tree view, a small Model of its own: `TreeView.init({ id, open?, checked? })`, folded with `TreeView.update(nodes, { checkable? })` (curried over the tree, flattened once), drawn with `TreeView.view({ label, model, nodes, onMessage, direction?, style?, mixins? }, h)` over nodes `{ id, label, children?, disabled?, icon?, openIcon? }`. `checkable` (on the view and `update`) gives each row a box: the Model's `checked` holds the leaves, a branch reads checked, mixed or not from them (`TreeView.checksOf`), and Space checks the current row in `update`. One tab stop; Up/Down move through the rows showing, stepping over shut and disabled ones; Right opens or steps in, Left shuts or steps out (swapped under `direction: 'rtl'`, drawn as the root's `dir`); Home/End; a character moves to the next showing row that starts with it; Enter, Space or a click chooses a row and opens or shuts a branch. Keys reach `update`, which decides from its own Model and sends a focus Command. Each item carries `--fk-tree-level`; a shut group stays drawn and `inert`. | `guides`: `none` (default) or `lines`, a guide down each open branch; `data-state` on a branch `item` and its `group`. Slots `root`, `item`, `row`, `chevron`, `checkbox`, `icon`, `label`, `group`. |
|
|
575
725
|
| `Typography` | `{ level, text }`. The level chooses the element (`h1`–`h4`, `lead`, `body`, `small`, `muted`, `quote`, `code`, and the interface roles `display`, `title`, `subtitle`, `caption`, `micro` as paragraphs). | `level`, same set; a role is its size and leading on the size ladder. Defaults to `body`. Slot `text`. |
|
|
576
726
|
| `VirtualList` | `@foldkit/ui`'s virtual list: `VirtualList.view({ model, items, itemToKey, itemToView, onMessage, overscan?, itemToRowHeightPx? \| dynamicRowHeights?, style?, mixins? }, h)` draws only the rows in view. Its Model is upstream's (`@foldkit/ui/virtualList`'s `init`), kept by the application and folded with that module's `update`. A row's mixins may style it, not handle its events, since it is drawn inside the list's submodel. A bar is drawn beside the list, and `VirtualList.overlayBars` lays it over the list's edge: `root` runs `ScrollBars` for upstream's list, which holds a Mount of its own. | No axis. Slots `root` (the box it scrolls within: 18rem tall by default and as wide as its container, offering 20rem where the container takes its width from it, so the rows drawn as it scrolls never resize it), `row`, `bar`, `thumb`. |
|
|
577
|
-
| `WindowList` | A virtual list that scrolls with the window: `WindowList.init({ id, estimatedHeight, unmeasured?, overscan?, viewportHeight?, from? })`, folded with `WindowList.update`, drawn with `WindowList.view({ model, items, itemToKey, itemToView, onMessage, label?, style?, mixins? }, h)`. It draws the rows in view of the document's viewport between spacers as tall as the rest, so the page keeps its own scrolling: the browser restores its offset, a `sticky` header above the list sticks, and Space and End move it. Its one Mount on `root`, `WindowList.Track`, reads where the viewport lies over the list on every scroll, resize and resize of the page (`WindowViewport`), so content above it, or growing above it, counts, and measures each drawn row's border box (`MeasureRows`; space rows with padding: a row is `flow-root`). The rows already drawn when it starts are read at once, so no row leaves before its height is known. A row not yet measured counts `estimatedHeight`, or with `unmeasured: 'mean'` the mean of the rows measured above 0: for rows whose height the window's width decides, which `init` cannot know. A Scene test of a page drawing the list resolves it with `Scene.Mount.resolveAll(WindowList.resolveTrack(onMessage, WindowList.Message.Placed({ top, height })))`, the reading going through the view's own `onMessage`. `WindowList.windowOf(model, keys)` is which rows are drawn, for loading what is in view, and `WindowList.keep(model, keys)` drops the heights of rows that left; a row still drawn is measured again only when it resizes, so keep the keys of the rows drawn. A server's page opens the list at a row with `from` (a page's `?from=`): the window starts at that row, with no overscan above it, and the rows above take no room until `Track` places the list, which gives them their room and scrolls the window by what that moved the first row drawn, so a reader sees the same rows before and after the runtime takes the page over. The first `Placed` sets `from` back to 0, and the list follows the window. For a page without scripts, `WindowList.pageOf(model, keys)` is `{ start, end, previous, next }`: the rows drawn and, as `Option`s, the rows the pages either side open at (`previous` the first whose window reaches this one's start), for links that set `?from=`. Use `VirtualList` for a list in a box of its own. | `Recipes.WindowList`: no look, only the spacers hidden where no script runs (
|
|
727
|
+
| `WindowList` | A virtual list that scrolls with the window: `WindowList.init({ id, estimatedHeight, unmeasured?, overscan?, viewportHeight?, from? })`, folded with `WindowList.update`, drawn with `WindowList.view({ model, items, itemToKey, itemToView, onMessage, label?, style?, mixins? }, h)`. It draws the rows in view of the document's viewport between spacers as tall as the rest, so the page keeps its own scrolling: the browser restores its offset, a `sticky` header above the list sticks, and Space and End move it. Its one Mount on `root`, `WindowList.Track`, reads where the viewport lies over the list on every scroll, resize and resize of the page (`WindowViewport`), so content above it, or growing above it, counts, and measures each drawn row's border box (`MeasureRows`; space rows with padding: a row is `flow-root`). The rows already drawn when it starts are read at once, so no row leaves before its height is known. A row not yet measured counts `estimatedHeight`, or with `unmeasured: 'mean'` the mean of the rows measured above 0: for rows whose height the window's width decides, which `init` cannot know. A Scene test of a page drawing the list resolves it with `Scene.Mount.resolveAll(WindowList.resolveTrack(onMessage, WindowList.Message.Placed({ top, height })))`, the reading going through the view's own `onMessage`. `WindowList.windowOf(model, keys)` is which rows are drawn, for loading what is in view, and `WindowList.keep(model, keys)` drops the heights of rows that left; a row still drawn is measured again only when it resizes, so keep the keys of the rows drawn. A server's page opens the list at a row with `from` (a page's `?from=`): the window starts at that row, with no overscan above it, and the rows above take no room until `Track` places the list, which gives them their room and scrolls the window by what that moved the first row drawn, so a reader sees the same rows before and after the runtime takes the page over. The first `Placed` sets `from` back to 0, and the list follows the window. For a page without scripts, `WindowList.pageOf(model, keys)` is `{ start, end, previous, next }`: the rows drawn and, as `Option`s, the rows the pages either side open at (`previous` the first whose window reaches this one's start), for links that set `?from=`. Use `VirtualList` for a list in a box of its own. | `Recipes.WindowList`: no look, only the spacers hidden where no script runs (`Utilities.scriptedOnly`), so the rows a server drew lie in the page's flow; `.extend` it with the list's look. Slots `root` (`role="list"`), `spacer` (`data-edge` `start` or `end`, hidden from assistive technology), `row` (`role="listitem"`). |
|
|
578
728
|
|
|
579
729
|
## Recipes
|
|
580
730
|
|
|
@@ -745,7 +895,7 @@ publishes them:
|
|
|
745
895
|
const AddressStyle = Style.forSlots(FieldSlots)({
|
|
746
896
|
group: Recipes.InputGroup.group,
|
|
747
897
|
affix: Recipes.InputGroup.affix,
|
|
748
|
-
text: Style.compose(Recipes.Input({}).input
|
|
898
|
+
text: Style.compose(Recipes.Input({}).input, Recipes.InputGroup.control),
|
|
749
899
|
})
|
|
750
900
|
```
|
|
751
901
|
|
|
@@ -811,8 +961,9 @@ as before a page hydrates, so does the browser's bar.
|
|
|
811
961
|
Every one is the same shape, a mixin list passed beside the style:
|
|
812
962
|
`ScrollArea.overlayBars`, `Command.overlayBars` and `VirtualList.overlayBars`
|
|
813
963
|
in the view's `mixins`, and `Menu.overlayBars`, `Listbox.overlayBars` and
|
|
814
|
-
`Combobox.overlayBars` in `toView`'s for a popup whose list scrolls
|
|
815
|
-
|
|
964
|
+
`Combobox.overlayBars` in `toView`'s for a popup whose list scrolls: upstream
|
|
965
|
+
draws that `scroll` region only when given `itemsScrollClassName` or
|
|
966
|
+
`itemsScrollAttributes`, and its class joins the recipe's. Like `fluid`, it is off by default: a Scene test
|
|
816
967
|
resolves every Mount with a Message, and this one sends none, so a default
|
|
817
968
|
would burden the tests of every page that drew one.
|
|
818
969
|
|
|
@@ -861,8 +1012,8 @@ itself:
|
|
|
861
1012
|
```ts
|
|
862
1013
|
const SegmentedStyle = Style.forSlots(SegmentedSlots)(
|
|
863
1014
|
{
|
|
864
|
-
group: Recipes.Segmented({ tray: 'plain', size: 'sm' }).group
|
|
865
|
-
option: Recipes.Segmented({ tray: 'plain', size: 'sm' }).option
|
|
1015
|
+
group: Recipes.Segmented({ tray: 'plain', size: 'sm' }).group,
|
|
1016
|
+
option: Recipes.Segmented({ tray: 'plain', size: 'sm' }).option,
|
|
866
1017
|
},
|
|
867
1018
|
{ layer: L.layer('app') },
|
|
868
1019
|
)
|
|
@@ -1032,6 +1183,37 @@ battery draws the fork and upstream's view over the same models; state,
|
|
|
1032
1183
|
Messages, update, Commands, and Mounts stay upstream in every case. If
|
|
1033
1184
|
upstream gains seams, the forks go away.
|
|
1034
1185
|
|
|
1186
|
+
That seam is what makes a row styleable. Drawn through `@foldkit/ui`'s own
|
|
1187
|
+
view, a Menu item or a Listbox or Combobox option takes only a `className`
|
|
1188
|
+
(its `itemToConfig`), so no Slot's attributes reach it and no Mixin can land
|
|
1189
|
+
on it: the page can style it only from the panel's Slot, with a rule under it
|
|
1190
|
+
keyed on the role and the state attributes upstream writes. Drawn through
|
|
1191
|
+
the fork, the row is the `item` Slot, styled like any other:
|
|
1192
|
+
|
|
1193
|
+
```ts standalone
|
|
1194
|
+
import { Capability, Slot, Slots, Style } from 'foldkit-mixins'
|
|
1195
|
+
import { Theme } from 'foldkit-mixins/theme'
|
|
1196
|
+
import { ListboxSlots } from 'foldkit-mixins-ui'
|
|
1197
|
+
|
|
1198
|
+
const t = Theme.ref(Theme.standard(Theme.make({})))
|
|
1199
|
+
|
|
1200
|
+
// Through `Listbox.toView`: each option is the `item` Slot.
|
|
1201
|
+
const ListboxStyle = Style.forSlots(ListboxSlots)({
|
|
1202
|
+
item: [{ cursor: 'pointer' }, Style.pseudo('[data-active]', { background: t.surface.muted })],
|
|
1203
|
+
})
|
|
1204
|
+
|
|
1205
|
+
// Through upstream's view: the options are reached from the panel's Slot.
|
|
1206
|
+
const PanelSlots = Slots.define({ items: Slot.make({ capability: Capability.Container }) })
|
|
1207
|
+
const PanelStyle = Style.forSlots(PanelSlots)({
|
|
1208
|
+
items: Style.nest('[role="option"][data-active]', { background: t.surface.muted }),
|
|
1209
|
+
})
|
|
1210
|
+
```
|
|
1211
|
+
|
|
1212
|
+
The second keeps the rule in the panel's layer and reads only what
|
|
1213
|
+
`@foldkit/ui` publishes (`role`, `data-active`, `data-selected`,
|
|
1214
|
+
`data-disabled`), but no Behavior or Mount can reach the row that way. Use
|
|
1215
|
+
it for a port that keeps upstream's view; draw through the adapter otherwise.
|
|
1216
|
+
|
|
1035
1217
|
`Listbox`, `Combobox` and `Calendar` draw the standard markup from the
|
|
1036
1218
|
styled bundles when `toView` is given no `draw`; pass a `draw` to arrange the
|
|
1037
1219
|
parts yourself.
|
package/dist/button.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attr, Capability, Event, NamedStyle, Slot, Slots } from "foldkit-mixins";
|
|
1
|
+
import { Attr, Capability, Event, NamedStyle, Slot, SlotAttributes, Slots } from "foldkit-mixins";
|
|
2
2
|
import { ButtonAttributes } from "@foldkit/ui/button";
|
|
3
3
|
import { MixinList, ResolveContext, Resolved } from "./resolve.js";
|
|
4
4
|
import { Html, HtmlBuilder } from "foldkit/html";
|
|
@@ -45,6 +45,13 @@ export interface ButtonView<Message> {
|
|
|
45
45
|
* recipe's pressed look. Omit it for a button that is not a toggle.
|
|
46
46
|
*/
|
|
47
47
|
readonly pressed?: boolean | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Attributes another component hands this button, added to its Slot before
|
|
50
|
+
* the mixins resolve, as `PasswordInput.view`'s are: a Dialog's
|
|
51
|
+
* `initialFocus`, so the dialog opens on it. A class among them joins the
|
|
52
|
+
* recipe's, and an owned event or attribute among them is a conflict.
|
|
53
|
+
*/
|
|
54
|
+
readonly attributes?: { readonly [K in keyof typeof ButtonSlots]?: SlotAttributes<Message>; };
|
|
48
55
|
}
|
|
49
56
|
export declare const view: <Message>(options: ButtonView<Message>, h: HtmlBuilder<Message>) => Html;
|
|
50
57
|
//# sourceMappingURL=button.d.ts.map
|
package/dist/button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","names":[],"sources":["../src/button.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"button.d.ts","names":[],"sources":["../src/button.ts"],"mappings":";;;;;;;;;;qBAmBa,aAAW,MAAA;;;;;YAUZ,eAAe,WAAW,SACpC,iBAAiB,iBACV,aACP;;qBAIW,UAAW,OAAO,SAAO,YACxB,iBAAiB,UAAQ,QAC7B,UAAU,UAAQ,SACjB,eAAe,OAAO,aAC9B,eAAe;;qBAGL,SACV,SAAO,QACE,UAAU,UAAQ,SACjB,wBAAwB,UAAQ,OAClC,UAAU,eAAe,aAAa,UAAI,YAEtC,iBAAiB,aAAW;;;;;;iBAQ1B,WAAW;;;;;WAKjB;;WAEA,OAAO;;WAEP,QAAQ,kBAAkB;;WAE1B,SAAS,UAAU;;WAEnB;WACA;WACA;WACA,UAAU;;;;;WAKV;;;;;;;WAOA,yBAAyB,kBAAkB,eAAe,eAAe;;qBAGvE,OAAQ,SAAO,SAAW,WAAW,UAAQ,GAAK,YAAY,aAAW"}
|
package/dist/button.js
CHANGED
|
@@ -29,10 +29,22 @@ const view = (options, h) => view$1({
|
|
|
29
29
|
...options.type === void 0 ? {} : { type: options.type },
|
|
30
30
|
...options.disabled === void 0 ? {} : { isDisabled: options.disabled },
|
|
31
31
|
...options.onClick === void 0 ? {} : { onClick: options.onClick },
|
|
32
|
-
toView:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
toView: (attributes) => {
|
|
33
|
+
const base = [
|
|
34
|
+
...attributes.button,
|
|
35
|
+
...options.pressed === void 0 ? [] : [h.AriaPressed(String(options.pressed))],
|
|
36
|
+
...options.attributes?.button ?? []
|
|
37
|
+
];
|
|
38
|
+
const { button, icon } = resolveFor(ButtonSlots, [...options.style === void 0 ? [] : [options.style.mixin], ...options.mixins ?? []], {
|
|
39
|
+
input: options.input,
|
|
40
|
+
h
|
|
41
|
+
})({
|
|
42
|
+
...attributes,
|
|
43
|
+
button: base,
|
|
44
|
+
icon: options.attributes?.icon ?? []
|
|
45
|
+
});
|
|
46
|
+
return h.button(button, options.icon === void 0 ? [options.label] : [h.span([...icon, h.AriaHidden(true)], [options.icon]), options.label]);
|
|
47
|
+
}
|
|
36
48
|
}, h);
|
|
37
49
|
export { ButtonSlots, resolve, toView, view };
|
|
38
50
|
|
package/dist/button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","names":["buttonView"],"sources":["../src/button.ts"],"sourcesContent":["import { view as buttonView, type ButtonAttributes } from '@foldkit/ui/button'\nimport {
|
|
1
|
+
{"version":3,"file":"button.js","names":["buttonView"],"sources":["../src/button.ts"],"sourcesContent":["import { view as buttonView, type ButtonAttributes } from '@foldkit/ui/button'\nimport {\n Attr,\n Capability,\n Event,\n Slot,\n Slots,\n type NamedStyle,\n type SlotAttributes,\n} from 'foldkit-mixins'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport { resolveFor, type MixinList, type ResolveContext, type Resolved } from './resolve.js'\n\n/**\n * The button publishes the button and the box its `icon` stands in. `click`\n * is owned by the base `OnClick` when the button is interactive, so a Behavior\n * that adds its own click handler is a conflict rather than a second silent\n * owner.\n */\nexport const ButtonSlots = Slots.define({\n button: Slot.make({\n capability: Capability.Interactive,\n events: [Event.Click],\n attributes: [Attr.Role, Attr.AriaDisabled, Attr.Disabled, Attr.AriaPressed],\n }),\n icon: Slot.make({ capability: Capability.Container }),\n})\n\n/** The button's bundles with the attached Mixins applied. */\nexport type ResolvedButton<Message> = Resolved<\n ButtonAttributes<Message>,\n typeof ButtonSlots,\n Message\n>\n\n/** Applies `mixins` to the button's bundles. */\nexport const resolve = <Input, Message>(\n attributes: ButtonAttributes<Message>,\n mixins: MixinList<Message>,\n context: ResolveContext<Input, Message>,\n): ResolvedButton<Message> => resolveFor(ButtonSlots, mixins, context)(attributes)\n\n/** The button's `toView`: `draw` receives its bundles with `mixins` applied. */\nexport const toView =\n <Message>(\n mixins: MixinList<Message>,\n context: ResolveContext<unknown, Message>,\n draw: (resolved: ResolvedButton<Message>) => Html,\n ) =>\n (attributes: ButtonAttributes<Message>): Html =>\n draw(resolve(attributes, mixins, context))\n\n/**\n * A button in one call: the label, a style for its slot, and the rest of\n * `@foldkit/ui`'s own config. `toView` stays for a button drawn as something\n * else (an `a`, a split control); this covers the common case.\n */\nexport interface ButtonView<Message> {\n /**\n * The button's text, and its accessible name. The recipe's `icon` variant\n * hides it from sight and draws the `icon` alone.\n */\n readonly label: string\n /** A drawing before the label (an `svg`), hidden from assistive technology. */\n readonly icon?: Html | undefined\n /** A style of `ButtonSlots`, for the button's own look. */\n readonly style?: NamedStyle<typeof ButtonSlots> | undefined\n /** Mixins beside the style, for state or behavior the style does not own. */\n readonly mixins?: MixinList<Message> | undefined\n /** What an input-driven Mixin reads; omit it when no attached Mixin reads one. */\n readonly input?: unknown\n readonly type?: 'button' | 'submit' | 'reset' | undefined\n readonly disabled?: boolean | undefined\n readonly onClick?: Message | undefined\n /**\n * Whether the button is on, as a toggle button: `aria-pressed`, and the\n * recipe's pressed look. Omit it for a button that is not a toggle.\n */\n readonly pressed?: boolean | undefined\n /**\n * Attributes another component hands this button, added to its Slot before\n * the mixins resolve, as `PasswordInput.view`'s are: a Dialog's\n * `initialFocus`, so the dialog opens on it. A class among them joins the\n * recipe's, and an owned event or attribute among them is a conflict.\n */\n readonly attributes?: { readonly [K in keyof typeof ButtonSlots]?: SlotAttributes<Message> }\n}\n\nexport const view = <Message>(options: ButtonView<Message>, h: HtmlBuilder<Message>): Html =>\n buttonView(\n {\n ...(options.type === undefined ? {} : { type: options.type }),\n ...(options.disabled === undefined ? {} : { isDisabled: options.disabled }),\n ...(options.onClick === undefined ? {} : { onClick: options.onClick }),\n toView: attributes => {\n const base: SlotAttributes<Message> = [\n ...attributes.button,\n ...(options.pressed === undefined ? [] : [h.AriaPressed(String(options.pressed))]),\n ...(options.attributes?.button ?? []),\n ]\n const { button, icon } = resolveFor(\n ButtonSlots,\n [\n ...(options.style === undefined ? [] : [options.style.mixin]),\n ...(options.mixins ?? []),\n ],\n { input: options.input, h },\n )({ ...attributes, button: base, icon: options.attributes?.icon ?? [] })\n return h.button(\n button,\n options.icon === undefined\n ? [options.label]\n : [h.span([...icon, h.AriaHidden(true)], [options.icon]), options.label],\n )\n },\n },\n h,\n )\n"],"mappings":";;;;;;;;;;AAmBA,MAAa,cAAc,MAAM,OAAO;CACtC,QAAQ,KAAK,KAAK;EAChB,YAAY,WAAW;EACvB,QAAQ,CAAC,MAAM,KAAK;EACpB,YAAY;GAAC,KAAK;GAAM,KAAK;GAAc,KAAK;GAAU,KAAK;EAAW;CAC5E,CAAC;CACD,MAAM,KAAK,KAAK,EAAE,YAAY,WAAW,UAAU,CAAC;AACtD,CAAC;;AAUD,MAAa,WACX,YACA,QACA,YAC4B,WAAW,aAAa,QAAQ,OAAO,CAAC,CAAC,UAAU;;AAGjF,MAAa,UAET,QACA,SACA,UAED,eACC,KAAK,QAAQ,YAAY,QAAQ,OAAO,CAAC;AAsC7C,MAAa,QAAiB,SAA8B,MAC1DA,OACE;CACE,GAAI,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,QAAQ,KAAK;CAC3D,GAAI,QAAQ,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,QAAQ,SAAS;CACzE,GAAI,QAAQ,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,QAAQ,QAAQ;CACpE,SAAQ,eAAc;EACpB,MAAM,OAAgC;GACpC,GAAG,WAAW;GACd,GAAI,QAAQ,YAAY,KAAA,IAAY,CAAC,IAAI,CAAC,EAAE,YAAY,OAAO,QAAQ,OAAO,CAAC,CAAC;GAChF,GAAI,QAAQ,YAAY,UAAU,CAAC;EACrC;EACA,MAAM,EAAE,QAAQ,SAAS,WACvB,aACA,CACE,GAAI,QAAQ,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,QAAQ,MAAM,KAAK,GAC3D,GAAI,QAAQ,UAAU,CAAC,CACzB,GACA;GAAE,OAAO,QAAQ;GAAO;EAAE,CAC5B,CAAC,CAAC;GAAE,GAAG;GAAY,QAAQ;GAAM,MAAM,QAAQ,YAAY,QAAQ,CAAC;EAAE,CAAC;EACvE,OAAO,EAAE,OACP,QACA,QAAQ,SAAS,KAAA,IACb,CAAC,QAAQ,KAAK,IACd,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,QAAQ,KAAK,CAC3E;CACF;AACF,GACA,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comboboxView.d.ts","names":["ComboboxRenderInfo","UpstreamSingleInputs","ExtraInputs","UpstreamSingleBundle","SingleModel","SubmodelView"],"sources":["../src/comboboxView.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"comboboxView.d.ts","names":["ComboboxRenderInfo","UpstreamSingleInputs","ExtraInputs","UpstreamSingleBundle","SingleModel","SubmodelView"],"sources":["../src/comboboxView.ts"],"mappings":";;;;;YA6BY,mBAAmB;EAC7B,WAAW,QAAQA,yBAAuB;;YAGhC,iBAAiB;EAAW;;;qBAG3B,gBAAa,GACpB,YAAY,cAAQ,QACfA,yBAAqB;;YA8BpB,iBAAiB,uBAAuBC,WAAqB,QACvE;EAAW,UAAU,QAAQD,yBAAuB;KACpDE;;YAGU,gBAAgB,uBAAuB,iBAAiB,MAAM,WAAW,QACnF;EAAW,UAAU,QAAQF,yBAAuB;KACpDE;KAEG,aAAa,iBAAiB,MAAM;KAEpC,oBAAoB,uBAAuB,iBAAiB,MAAM,OAAO;;YAgBlE,aAAa,gCAAgC,KACvDC,OAAqB;WAGZ,MAAME,KAAaD,OAAa,SAAS,iBAAiB;;;qBAQxD,SAAU,mCAAiC,aAAa;;YAiBzD,YAAY,gCAAgC,KAAK,oBAAoB;WACtE,MAAMC,KAAa,YAAY,SAAS,gBAAgB;;;qBAItD;EACX,SAAS,mCAAiC,YAAY"}
|
package/dist/comboboxView.js
CHANGED
|
@@ -3,12 +3,14 @@ import { drawCombobox } from "./popupView.js";
|
|
|
3
3
|
import * as UpstreamCombobox from "@foldkit/ui/combobox";
|
|
4
4
|
import { defineView } from "foldkit/submodel";
|
|
5
5
|
import { computeRender } from "./comboboxShared.js";
|
|
6
|
+
import { leaveDrawn } from "./leaveDrawn.js";
|
|
6
7
|
// src/comboboxView.ts
|
|
7
8
|
/**
|
|
8
9
|
* Forked combobox views: the single and multi variants over the shared
|
|
9
10
|
* transcription in `./comboboxShared.js`. Each `create` binds the upstream
|
|
10
|
-
* bundle for the item type and swaps in
|
|
11
|
-
* update, Commands, Mounts, and
|
|
11
|
+
* bundle for the item type and swaps in the view, and ends a leave only
|
|
12
|
+
* once it is drawn (#400); state, Messages, update, Commands, Mounts, and
|
|
13
|
+
* subscriptions stay upstream. If upstream
|
|
12
14
|
* gains a seam, delete both modules; on a bump, re-transcribe and re-run
|
|
13
15
|
* the battery.
|
|
14
16
|
*/
|
|
@@ -28,10 +30,15 @@ const singleViewImpl = defineView((model, { maybeSelectedValue, toView, ...baseI
|
|
|
28
30
|
selectedValues: Option.toArray(maybeSelectedValue),
|
|
29
31
|
toView
|
|
30
32
|
}, h));
|
|
33
|
+
const drawn = (result) => leaveDrawn(UpstreamCombobox.DetectMovementOrAnimationEnd, result);
|
|
31
34
|
/** Pairs the forked single view with upstream's `update` and helpers. */
|
|
32
35
|
const create = () => {
|
|
36
|
+
const bound = UpstreamCombobox.create();
|
|
33
37
|
return {
|
|
34
|
-
|
|
38
|
+
update: (model, message) => drawn(bound.update(model, message)),
|
|
39
|
+
selectItem: (model, item, displayText) => drawn(bound.selectItem(model, item, displayText)),
|
|
40
|
+
open: (model) => drawn(bound.open(model)),
|
|
41
|
+
close: (model, restingInputValue) => drawn(bound.close(model, restingInputValue)),
|
|
35
42
|
view: singleViewImpl
|
|
36
43
|
};
|
|
37
44
|
};
|
|
@@ -41,8 +48,12 @@ const multiViewImpl = defineView((model, { toView, ...rest }, h) => multiShared(
|
|
|
41
48
|
}, h));
|
|
42
49
|
/** Pairs the forked multi view with upstream's `update` and helpers. */
|
|
43
50
|
const Multi = { create: () => {
|
|
51
|
+
const bound = UpstreamCombobox.Multi.create();
|
|
44
52
|
return {
|
|
45
|
-
|
|
53
|
+
update: (model, message) => drawn(bound.update(model, message)),
|
|
54
|
+
selectItem: (model, item) => drawn(bound.selectItem(model, item)),
|
|
55
|
+
open: (model) => drawn(bound.open(model)),
|
|
56
|
+
close: (model) => drawn(bound.close(model)),
|
|
46
57
|
view: multiViewImpl
|
|
47
58
|
};
|
|
48
59
|
} };
|
package/dist/comboboxView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comboboxView.js","names":[],"sources":["../src/comboboxView.ts"],"sourcesContent":["/**\n * Forked combobox views: the single and multi variants over the shared\n * transcription in `./comboboxShared.js`. Each `create` binds the upstream\n * bundle for the item type and swaps in only
|
|
1
|
+
{"version":3,"file":"comboboxView.js","names":[],"sources":["../src/comboboxView.ts"],"sourcesContent":["/**\n * Forked combobox views: the single and multi variants over the shared\n * transcription in `./comboboxShared.js`. Each `create` binds the upstream\n * bundle for the item type and swaps in the view, and ends a leave only\n * once it is drawn (#400); state, Messages, update, Commands, Mounts, and\n * subscriptions stay upstream. If upstream\n * gains a seam, delete both modules; on a bump, re-transcribe and re-run\n * the battery.\n */\nimport { Option } from 'effect'\nimport * as UpstreamCombobox from '@foldkit/ui/combobox'\nimport type {\n Bundle as UpstreamSingleBundle,\n Model as SingleModel,\n ViewInputs as UpstreamSingleInputs,\n} from '@foldkit/ui/combobox'\nimport type { Message } from '@foldkit/ui/combobox'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport { defineView, type View as SubmodelView } from 'foldkit/submodel'\nimport type { ReturnWithOutMessage } from 'foldkit/update'\nimport {\n computeRender,\n type ComboboxRenderInfo,\n type ExtraInputs,\n type NormalizedInputs,\n} from './comboboxShared.js'\nimport { leaveDrawn } from './leaveDrawn.js'\nimport { drawCombobox } from './popupView.js'\n\nexport type SharedViewInputs = NormalizedInputs<string> & {\n toView?: ((render: ComboboxRenderInfo) => Html) | undefined\n}\n\nexport type SharedBehavior = Readonly<{ ariaMultiSelectable: boolean }>\n\n/** Upstream's markup from the computed bundles: the default `toView`. */\nexport const defaultToView =\n (h: HtmlBuilder<Message>) =>\n (render: ComboboxRenderInfo): Html =>\n drawCombobox(render, h)\n\nconst makeSharedView = (\n behavior: SharedBehavior,\n): SubmodelView<SingleModel, Message, SharedViewInputs> => {\n const view = (\n model: SingleModel,\n viewInputs: SharedViewInputs,\n h: HtmlBuilder<Message>,\n ): Html => {\n const render = computeRender(model, viewInputs, h, behavior)\n return (viewInputs.toView ?? defaultToView(h))(render)\n }\n return defineView<SingleModel, Message, SharedViewInputs>(view)\n}\n\nconst singleShared = makeSharedView({ ariaMultiSelectable: false })\nconst multiShared = makeSharedView({ ariaMultiSelectable: true })\n\nexport type {\n ComboboxChipRender,\n ComboboxGroupRender,\n ComboboxHeadingRender,\n ComboboxItemRender,\n ComboboxRenderInfo,\n ExtraInputs,\n} from './comboboxShared.js'\n\n/** Upstream single view inputs plus the seam and this package's extras. */\nexport type SingleViewInputs<Item extends string> = UpstreamSingleInputs<Item> &\n Readonly<{ toView?: (render: ComboboxRenderInfo) => Html }> &\n ExtraInputs\n\n/** Upstream multi view inputs plus the seam and this package's extras. */\nexport type MultiViewInputs<Item extends string> = UpstreamCombobox.Multi.ViewInputs<Item> &\n Readonly<{ toView?: (render: ComboboxRenderInfo) => Html }> &\n ExtraInputs\n\ntype MultiModel = UpstreamCombobox.Multi.Model\n\ntype UpstreamMultiBundle<Item extends string> = UpstreamCombobox.Multi.Bundle<Item>\n\nconst singleViewImpl = defineView<SingleModel, Message, SingleViewInputs<string>>(\n (model, { maybeSelectedValue, toView, ...baseInputs }, h) =>\n singleShared(\n model,\n {\n ...baseInputs,\n selectedValues: Option.toArray(maybeSelectedValue),\n toView,\n },\n h,\n ),\n)\n\n/** Upstream single `Bundle` with the forked `view`. */\nexport type SingleBundle<Item extends string = string> = Omit<\n UpstreamSingleBundle<Item>,\n 'view'\n> & {\n readonly view: SubmodelView<SingleModel, Message, SingleViewInputs<Item>>\n}\n\n// Upstream's update and helpers, each ending a leave only once it is drawn (#400).\nconst drawn = <Model, Out>(result: ReturnWithOutMessage<Model, Message, Out>) =>\n leaveDrawn(UpstreamCombobox.DetectMovementOrAnimationEnd, result)\n\n/** Pairs the forked single view with upstream's `update` and helpers. */\nexport const create = <Item extends string = string>(): SingleBundle<Item> => {\n const bound = UpstreamCombobox.create<Item>()\n return {\n update: (model, message) => drawn(bound.update(model, message)),\n selectItem: (model, item, displayText) => drawn(bound.selectItem(model, item, displayText)),\n open: model => drawn(bound.open(model)),\n close: (model, restingInputValue) => drawn(bound.close(model, restingInputValue)),\n view: singleViewImpl as unknown as SubmodelView<SingleModel, Message, SingleViewInputs<Item>>,\n }\n}\n\nconst multiViewImpl = defineView<MultiModel, Message, MultiViewInputs<string>>(\n (model, { toView, ...rest }, h) =>\n multiShared(model as unknown as SingleModel, { ...rest, toView }, h),\n)\n\n/** Upstream multi `Bundle` with the forked `view`. */\nexport type MultiBundle<Item extends string = string> = Omit<UpstreamMultiBundle<Item>, 'view'> & {\n readonly view: SubmodelView<MultiModel, Message, MultiViewInputs<Item>>\n}\n\n/** Pairs the forked multi view with upstream's `update` and helpers. */\nexport const Multi = {\n create: <Item extends string = string>(): MultiBundle<Item> => {\n const bound = UpstreamCombobox.Multi.create<Item>()\n return {\n update: (model, message) => drawn(bound.update(model, message)),\n selectItem: (model, item) => drawn(bound.selectItem(model, item)),\n open: model => drawn(bound.open(model)),\n close: model => drawn(bound.close(model)),\n view: multiViewImpl as unknown as SubmodelView<MultiModel, Message, MultiViewInputs<Item>>,\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAa,iBACV,OACA,WACC,aAAa,QAAQ,CAAC;AAE1B,MAAM,kBACJ,aACyD;CACzD,MAAM,QACJ,OACA,YACA,MACS;EACT,MAAM,SAAS,cAAc,OAAO,YAAY,GAAG,QAAQ;EAC3D,QAAQ,WAAW,UAAU,cAAc,CAAC,EAAA,CAAG,MAAM;CACvD;CACA,OAAO,WAAmD,IAAI;AAChE;AAEA,MAAM,eAAe,eAAe,EAAE,qBAAqB,MAAM,CAAC;AAClE,MAAM,cAAc,eAAe,EAAE,qBAAqB,KAAK,CAAC;AAyBhE,MAAM,iBAAiB,YACpB,OAAO,EAAE,oBAAoB,QAAQ,GAAG,cAAc,MACrD,aACE,OACA;CACE,GAAG;CACH,gBAAgB,OAAO,QAAQ,kBAAkB;CACjD;AACF,GACA,CACF,CACJ;AAWA,MAAM,SAAqB,WACzB,WAAW,iBAAiB,8BAA8B,MAAM;;AAGlE,MAAa,eAAiE;CAC5E,MAAM,QAAQ,iBAAiB,OAAa;CAC5C,OAAO;EACL,SAAS,OAAO,YAAY,MAAM,MAAM,OAAO,OAAO,OAAO,CAAC;EAC9D,aAAa,OAAO,MAAM,gBAAgB,MAAM,MAAM,WAAW,OAAO,MAAM,WAAW,CAAC;EAC1F,OAAM,UAAS,MAAM,MAAM,KAAK,KAAK,CAAC;EACtC,QAAQ,OAAO,sBAAsB,MAAM,MAAM,MAAM,OAAO,iBAAiB,CAAC;EAChF,MAAM;CACR;AACF;AAEA,MAAM,gBAAgB,YACnB,OAAO,EAAE,QAAQ,GAAG,QAAQ,MAC3B,YAAY,OAAiC;CAAE,GAAG;CAAM;AAAO,GAAG,CAAC,CACvE;;AAQA,MAAa,QAAQ,EACnB,cAA+D;CAC7D,MAAM,QAAQ,iBAAiB,MAAM,OAAa;CAClD,OAAO;EACL,SAAS,OAAO,YAAY,MAAM,MAAM,OAAO,OAAO,OAAO,CAAC;EAC9D,aAAa,OAAO,SAAS,MAAM,MAAM,WAAW,OAAO,IAAI,CAAC;EAChE,OAAM,UAAS,MAAM,MAAM,KAAK,KAAK,CAAC;EACtC,QAAO,UAAS,MAAM,MAAM,MAAM,KAAK,CAAC;EACxC,MAAM;CACR;AACF,EACF"}
|
package/dist/datePickerView.d.ts
CHANGED
|
@@ -309,6 +309,10 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
309
309
|
} | {
|
|
310
310
|
readonly _tag: "GotPopoverMessage";
|
|
311
311
|
readonly message: {
|
|
312
|
+
readonly _tag: "ClickedButton";
|
|
313
|
+
} | {
|
|
314
|
+
readonly _tag: "CompletedFocusButton";
|
|
315
|
+
} | {
|
|
312
316
|
readonly _tag: "CompletedInertOthers";
|
|
313
317
|
} | {
|
|
314
318
|
readonly _tag: "CompletedLockScroll";
|
|
@@ -316,10 +320,6 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
316
320
|
readonly _tag: "CompletedRestoreInert";
|
|
317
321
|
} | {
|
|
318
322
|
readonly _tag: "CompletedUnlockScroll";
|
|
319
|
-
} | {
|
|
320
|
-
readonly _tag: "ClickedButton";
|
|
321
|
-
} | {
|
|
322
|
-
readonly _tag: "CompletedFocusButton";
|
|
323
323
|
} | {
|
|
324
324
|
readonly _tag: "IgnoredMouseClick";
|
|
325
325
|
} | {
|
|
@@ -339,15 +339,15 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
339
339
|
} | {
|
|
340
340
|
readonly _tag: "GotAnimationMessage";
|
|
341
341
|
readonly message: {
|
|
342
|
-
readonly _tag: "Hid";
|
|
343
|
-
} | {
|
|
344
|
-
readonly _tag: "Showed";
|
|
345
|
-
} | {
|
|
346
342
|
readonly _tag: "CompletedWaitForPaint";
|
|
347
343
|
readonly generation: number;
|
|
348
344
|
} | {
|
|
349
345
|
readonly _tag: "EndedAnimation";
|
|
350
346
|
readonly generation: number;
|
|
347
|
+
} | {
|
|
348
|
+
readonly _tag: "Hid";
|
|
349
|
+
} | {
|
|
350
|
+
readonly _tag: "Showed";
|
|
351
351
|
};
|
|
352
352
|
} | {
|
|
353
353
|
readonly _tag: "PressedPointerOnButton";
|
package/dist/field.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Option } from "effect";
|
|
2
|
-
import { Html } from "foldkit/html";
|
|
2
|
+
import { Attribute, Html, HtmlBuilder } from "foldkit/html";
|
|
3
3
|
import { FieldValidation } from "foldkit";
|
|
4
4
|
/** A labelled field's pieces, drawn: the label, the control, and its description. */
|
|
5
5
|
export interface FieldParts {
|
|
@@ -7,6 +7,21 @@ export interface FieldParts {
|
|
|
7
7
|
readonly control: Html;
|
|
8
8
|
readonly description: Html;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* What typing into a field sends: a closure from the text to a Message, or
|
|
12
|
+
* the `OnInput` attribute the view's builder makes. The attribute is for a
|
|
13
|
+
* builder whose `OnInput` takes more than a closure: `foldkit-ssr`'s resumable
|
|
14
|
+
* builder takes a Message member (`rh.OnInput(Message.ChangedEmail)`) and
|
|
15
|
+
* names it in the server's markup, which a closure cannot be.
|
|
16
|
+
*/
|
|
17
|
+
export type OnInput<Message> = ((value: string) => Message) | Extract<Attribute<Message>, {
|
|
18
|
+
readonly _tag: 'OnInput';
|
|
19
|
+
}>;
|
|
20
|
+
/** The field's `OnInput` attribute, built by `h` from a closure or passed through as given. */
|
|
21
|
+
export declare const onInputOf: <Message>(h: HtmlBuilder<Message>, onInput: OnInput<Message>) => {
|
|
22
|
+
readonly _tag: "OnInput";
|
|
23
|
+
readonly f: (value: string) => Message;
|
|
24
|
+
};
|
|
10
25
|
/** What a text field says under itself: its first error, or that it is being checked. */
|
|
11
26
|
export declare const descriptionOf: (field: FieldValidation.Field<unknown>) => Option.Option<string>;
|
|
12
27
|
//# sourceMappingURL=field.d.ts.map
|
package/dist/field.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","names":[],"sources":["../src/field.ts"],"mappings":";;;;iBAUiB;WACN,OAAO;WACP,SAAS;WACT,aAAa;;;
|
|
1
|
+
{"version":3,"file":"field.d.ts","names":[],"sources":["../src/field.ts"],"mappings":";;;;iBAUiB;WACN,OAAO;WACP,SAAS;WACT,aAAa;;;;;;;;;YAUZ,QAAQ,aACd,kBAAkB,WACpB,QAAQ,UAAU;WAAqB;;;qBAG9B,YAAa,SAAO,GAAK,YAAY,UAAQ,SAAW,QAAQ;;;;;qBAIhE,gBAAa,OAAW,gBAAgB,mBAAiB,OAAO"}
|
package/dist/field.js
CHANGED
|
@@ -6,6 +6,8 @@ import { FieldValidation } from "foldkit";
|
|
|
6
6
|
* from its validation state, and the parts a custom `draw` places. (The
|
|
7
7
|
* `Field` recipe styles in `recipes/` are the look; this is the wiring.)
|
|
8
8
|
*/
|
|
9
|
+
/** The field's `OnInput` attribute, built by `h` from a closure or passed through as given. */
|
|
10
|
+
const onInputOf = (h, onInput) => typeof onInput === "function" ? h.OnInput(onInput) : onInput;
|
|
9
11
|
/** What a text field says under itself: its first error, or that it is being checked. */
|
|
10
12
|
const descriptionOf = (field) => FieldValidation.match(field, {
|
|
11
13
|
onNotValidated: () => Option.none(),
|
|
@@ -13,6 +15,6 @@ const descriptionOf = (field) => FieldValidation.match(field, {
|
|
|
13
15
|
onValid: () => Option.none(),
|
|
14
16
|
onInvalid: ({ errors }) => Array.head(errors)
|
|
15
17
|
});
|
|
16
|
-
export { descriptionOf };
|
|
18
|
+
export { descriptionOf, onInputOf };
|
|
17
19
|
|
|
18
20
|
//# sourceMappingURL=field.js.map
|