@lipsjs/lips 0.3.1 → 0.5.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.
Files changed (55) hide show
  1. package/README.md +122 -9
  2. package/dist/lips.js +917 -669
  3. package/dist/lips.js.map +15 -12
  4. package/dist/lips.min.js +12 -12
  5. package/dist/lips.min.js.map +15 -12
  6. package/dist/lynx-background.min.js +3 -0
  7. package/dist/lynx-background.min.js.map +13 -0
  8. package/dist/lynx-main.min.js +3 -0
  9. package/dist/lynx-main.min.js.map +11 -0
  10. package/dist/lynx-plugin.mjs +1487 -0
  11. package/dist/lynx.min.js +8 -8
  12. package/dist/lynx.min.js.map +12 -10
  13. package/dist/mf2.min.js.map +1 -1
  14. package/dist/parts.min.js +100 -0
  15. package/dist/parts.min.js.map +19 -0
  16. package/dist/precompile.min.js +15 -15
  17. package/dist/precompile.min.js.map +8 -7
  18. package/dist/runtime.min.js +4 -4
  19. package/dist/runtime.min.js.map +11 -9
  20. package/dist/stylis.min.js.map +1 -1
  21. package/dist/types/component.d.ts +32 -0
  22. package/dist/types/ir/compiler.d.ts +2 -4
  23. package/dist/types/ir/facade.d.ts +63 -12
  24. package/dist/types/ir/host.d.ts +9 -1
  25. package/dist/types/ir/initial.d.ts +16 -0
  26. package/dist/types/ir/router.d.ts +2 -0
  27. package/dist/types/ir/tags.d.ts +16 -0
  28. package/dist/types/lips.d.ts +7 -7
  29. package/dist/types/lynx/a11y.d.ts +1 -0
  30. package/dist/types/lynx/background.d.ts +52 -3
  31. package/dist/types/lynx/components.d.ts +28 -0
  32. package/dist/types/lynx/main.d.ts +9 -5
  33. package/dist/types/lynx/plugin.d.ts +8 -0
  34. package/dist/types/lynx/protocol.d.ts +55 -4
  35. package/dist/types/lynx/style.d.ts +7 -0
  36. package/dist/types/lynx/template.d.ts +6 -0
  37. package/dist/types/lynx.d.ts +1 -0
  38. package/dist/types/parts/combobox.d.ts +40 -0
  39. package/dist/types/parts/date.d.ts +75 -0
  40. package/dist/types/parts/dialog.d.ts +42 -0
  41. package/dist/types/parts/icon.d.ts +31 -0
  42. package/dist/types/parts/layer.d.ts +28 -0
  43. package/dist/types/parts/list.d.ts +45 -0
  44. package/dist/types/parts/menu.d.ts +44 -0
  45. package/dist/types/parts/popover.d.ts +81 -0
  46. package/dist/types/parts/reveal.d.ts +24 -0
  47. package/dist/types/parts/toast.d.ts +36 -0
  48. package/dist/types/parts.d.ts +24 -0
  49. package/dist/types/precompile.d.ts +8 -11
  50. package/dist/types/runtime.d.ts +1 -0
  51. package/dist/types/types.d.ts +188 -57
  52. package/dist/untrusted.min.js +4 -4
  53. package/dist/untrusted.min.js.map +7 -7
  54. package/package.json +24 -3
  55. package/dist/types/i18n/formatters.d.ts +0 -3
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Combobox: a text field and the options it finds as the person types
3
+ * (RFC-008 §5; WAI-ARIA's combobox with a listbox, list autocomplete).
4
+ *
5
+ * lips.use( combobox ) // and the popover it is built on
6
+ *
7
+ * <popover open=state.open on-change( setOpen )>
8
+ * <popover-combobox options=state.people value=state.owner class="field" list="options" option="option" on-change( setOwner )/>
9
+ * </popover>
10
+ *
11
+ * Its options are data, `{ id, label, disabled? }`, as a menu's items are;
12
+ * `value` is the chosen option's id, the app's, and a choice comes back as
13
+ * `change` with the option. What is typed is the combobox's own: it finds
14
+ * the options that `match` it (`contains` by default, the label holding
15
+ * the text, in any case), and says `query` with it for an app that finds
16
+ * them itself, which gives `match=( () => true )` and its own `options`.
17
+ *
18
+ * The field is the popover's trigger: typing opens the list, on the first
19
+ * option found. Focus stays in the field, which names the active option
20
+ * with `aria-activedescendant`; ArrowDown and ArrowUp open the list and
21
+ * move through it past disabled options, Enter chooses, Escape closes,
22
+ * Tab closes and lets focus go on. Home and End stay the field's own. A
23
+ * tap chooses the option tapped. Chosen, the field shows its label.
24
+ *
25
+ * On Lynx, which has neither a combobox nor a listbox role, and no keys
26
+ * but the soft keyboard's: the person types and taps, each option is a
27
+ * button, and the chosen one says so (`aria-selected`).
28
+ *
29
+ * The active option has the class `is-active`; the chosen one,
30
+ * `is-selected`; a disabled one, `aria-disabled` and `is-disabled`. Each
31
+ * is drawn as its label, or by the slot, which gets `option`, `active`
32
+ * and `selected`.
33
+ */
34
+ import type { Plugin } from '../types';
35
+ import { type MenuItem } from './menu';
36
+ export type Option = MenuItem;
37
+ export type Match = (option: Option, text: string) => boolean;
38
+ /** The label holds the text, in any case */
39
+ export declare const contains: Match;
40
+ export declare const combobox: Plugin;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Date picker: a month as a grid of days (RFC-008 §5; WAI-ARIA's date
3
+ * picker grid).
4
+ *
5
+ * lips.use( datePicker ) // and the popover it is built on
6
+ *
7
+ * <date-grid value=state.due min="2026-01-01" class="cal" day="day" on-change( setDue )/>
8
+ *
9
+ * <popover open=state.picking on-change( setPicking )>
10
+ * <popover-trigger haspopup="dialog"><span>{state.due}</span></popover-trigger>
11
+ * <popover-date value=state.due label="Due date" class="sheet" day="day" on-change( setDue )/>
12
+ * </popover>
13
+ *
14
+ * Dates are ISO days, `YYYY-MM-DD`, computed in UTC so no clock change
15
+ * moves one. `value` is the app's, and a choice comes back as `change`;
16
+ * the month shown and the day under the keyboard are the grid's own, and
17
+ * a new month shown says `month` (`YYYY-MM`).
18
+ *
19
+ * The grid keeps focus and names the active day with
20
+ * `aria-activedescendant`, as a menu does. Left and Right move a day, Up
21
+ * and Down a week, Home and End to the week's ends, Page Up and Page Down
22
+ * a month (with Shift, a year), Enter or Space chooses; the buttons each
23
+ * side of the title move a month. A day before `min`, after `max`, or one
24
+ * `disabled( iso )` refuses is `aria-disabled` and cannot be chosen.
25
+ *
26
+ * The names of months and days, and the first day of the week, are the
27
+ * reader's language's (`lang`, or the component's): from `Intl` where it
28
+ * formats dates, which Lynx's PrimJS is not known to (`./i18n`), and from
29
+ * `words` where it does not, or English. `first` (0 for Sunday) overrides
30
+ * the week's start.
31
+ *
32
+ * Each day has the class `day` and, as it is, `is-active`, `is-selected`,
33
+ * `is-today`, `is-outside` (of the month shown) and `is-disabled`. On
34
+ * Lynx, which has no grid role, each day is a button, and the chosen one
35
+ * says so (`aria-selected`): its markup is its `lynx` source.
36
+ *
37
+ * `popover-date` is the grid in a popover's layer, as a dialog of its
38
+ * `label`: focused on the chosen day, or today, when it opens, and closed,
39
+ * focus back on the trigger, when a day is chosen.
40
+ */
41
+ import type { Plugin } from '../types';
42
+ /** The ISO day of a year, a month from 0 and a day, carried over as `Date.UTC` carries it */
43
+ export declare function isoOf(y: number, m: number, d: number): string;
44
+ /** `days` later, or earlier */
45
+ export declare const addDays: (iso: string, days: number) => string;
46
+ /** `months` later, or earlier, on the same day or the month's last where it has fewer */
47
+ export declare function addMonths(iso: string, months: number): string;
48
+ /** The weeks a month's grid shows, each its seven ISO days, from the week holding its 1st */
49
+ export declare function weeksOf(month: string, first?: number): string[][];
50
+ export interface CalendarWords {
51
+ /** January first */
52
+ readonly months: readonly string[];
53
+ /** Sunday first */
54
+ readonly days: readonly string[];
55
+ /** Sunday first: a column's head */
56
+ readonly short: readonly string[];
57
+ readonly prev: string;
58
+ readonly next: string;
59
+ /** The grid's title: a month of a year, month from 0. Left out, the month's name and the year */
60
+ readonly title?: (year: number, month: number) => string;
61
+ /** What a day is called to a screen reader, its weekday from Sunday's 0. Left out, the four in a row */
62
+ readonly day?: (year: number, month: number, date: number, weekday: number) => string;
63
+ }
64
+ export declare const ENGLISH: CalendarWords;
65
+ /**
66
+ * The names of months and days in `lang`, from `Intl`; English where it
67
+ * does not format dates (the least of `Intl` that `./i18n` installs writes
68
+ * a date whole, year and all). The title and a day's name are in the
69
+ * language's order. The buttons' words are not `Intl`'s: they are
70
+ * `words`' or English.
71
+ */
72
+ export declare function calendarWords(lang: string): CalendarWords;
73
+ /** The day `lang`'s week starts on, 0 for Sunday, from `Intl.Locale`'s week info; Monday where it has none */
74
+ export declare function firstDay(lang: string): number;
75
+ export declare const datePicker: Plugin;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Dialog: a panel over the whole page that holds the page still until it
3
+ * closes (RFC-008 §5; WAI-ARIA's modal dialog).
4
+ *
5
+ * lips.use( dialog ) // and the popover and layer it is built on
6
+ *
7
+ * <popover open=state.editing on-change( setEditing )>
8
+ * <popover-trigger haspopup="dialog"><span>Rename</span></popover-trigger>
9
+ * <popover-dialog class="sheet" blur=8 on-placed( started )>
10
+ * <dialog-title class="title"><span>Rename the file</span></dialog-title>
11
+ * …
12
+ * </popover-dialog>
13
+ * </popover>
14
+ *
15
+ * It is a popover's: the popover holds whether it is open (the app's
16
+ * `open`), its id and its trigger, and a dialog opened with no trigger is
17
+ * the same with none written. Named `popover-dialog`: `dialog` is an HTML
18
+ * element.
19
+ *
20
+ * Open, it is a centred panel in the layer (`page-layer`, `./layer`),
21
+ * `role="dialog"` (or the app's `role`, as `alertdialog`), `aria-modal`,
22
+ * labelled by its `dialog-title`, or by `label` where it has none. Focus
23
+ * goes to the panel, which a screen reader reads by its title; it says
24
+ * `placed` then, for the app to move focus on to a field. The page behind
25
+ * it is held still:
26
+ * - on the web, the rest of the page is `inert`, and Tab and Shift+Tab
27
+ * go round what can be focused in it;
28
+ * - on Lynx, `aria-modal` is `accessibility-exclusive-focus` (RFC-006
29
+ * §4.8): a screen reader stays inside it. Lynx has no Tab.
30
+ *
31
+ * It closes on Escape and on a tap on the backdrop, and whenever the app's
32
+ * `open` turns false (its own button, a saved form); then the page is
33
+ * given back and focus goes back to the trigger.
34
+ */
35
+ import type { Plugin } from '../types';
36
+ /**
37
+ * Everything in the page's body but `el` and what holds it made `inert`;
38
+ * what undoes it. What is already inert is left as it is, and stays. On
39
+ * the DOM only: a Lynx node has no `parentElement`.
40
+ */
41
+ export declare function inert(el: any): () => void;
42
+ export declare const dialog: Plugin;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Icons: a set as data, drawn as inline svg (RFC-008 §5; lips#34).
3
+ *
4
+ * lips.use( icons({ check: { paths: [ 'M5 12l5 5L20 7' ], stroke: 2 }, … }) )
5
+ *
6
+ * <icon name="check" size=16 color=state.tone/>
7
+ * <button><icon name="close" label="Close"/></button>
8
+ *
9
+ * Each icon is its paths (`d`), its `box` (`0 0 24 24` by default), and a
10
+ * stroke width for a line icon (drawn with no fill, round ends), or none
11
+ * for a filled one. Its colour is bound into its markup: `color`, or the
12
+ * text's (`currentColor`) on the web. On Lynx give `color`: Lynx draws an
13
+ * svg from its markup, where neither a custom property nor the text's
14
+ * colour reaches (RFC-008 §3).
15
+ *
16
+ * An icon with no `label` is `aria-hidden`; one with a label is an image
17
+ * by that name, and alone in a button gives the button its label, on both
18
+ * hosts. A name the set does not hold draws nothing.
19
+ *
20
+ * One set per Lips: a second `icons(…)` is refused as another plugin of
21
+ * the same name. Merge sets before using them.
22
+ */
23
+ import type { Plugin } from '../types';
24
+ export interface Icon {
25
+ readonly paths: readonly string[];
26
+ readonly box?: string;
27
+ /** A line icon's stroke width; none for a filled icon */
28
+ readonly stroke?: number;
29
+ }
30
+ export type IconSet = Readonly<Record<string, Icon>>;
31
+ export declare const icons: (set: IconSet) => Plugin;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Layer: what floats, over the whole page (RFC-008 §5). The popover and the
3
+ * dialog stand on it; an app rarely uses it alone.
4
+ *
5
+ * <page-layer on-dismiss( close ) on-live( measure )>…</page-layer>
6
+ * <page-layer center=true blur=12 backdrop="scrim" on-dismiss( close )>…</page-layer>
7
+ *
8
+ * One fixed element on both hosts, a backdrop in it, and what it is given
9
+ * over the backdrop. On Lynx `fixed` places it as a child of the page's
10
+ * root, which is what Lynx asks of a page that is all Lynx (its `overlay`
11
+ * is for Lynx inside a native page). `center` centres what it is given,
12
+ * as a dialog sits.
13
+ *
14
+ * The backdrop takes a tap outside whole, so nothing beneath is reached,
15
+ * and the layer says `dismiss`; so does Escape anywhere in it. It says
16
+ * `live` with its element once it is in the page, laid out, so what sits
17
+ * in it can measure where it is.
18
+ *
19
+ * The backdrop is plain, or blurred (`blur`, a radius in px; `effect`, iOS's
20
+ * material): `backdrop-blur` below. `backdrop` is its class, for its look.
21
+ *
22
+ * Its mechanics are inline styles: Lynx cannot add a sheet at run time, so
23
+ * a part's own sheet would have to reach the app's build, and nothing here
24
+ * needs what only a sheet reaches.
25
+ */
26
+ import type { Plugin } from '../types';
27
+ export declare const LAYER = "position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000", CENTER = "position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; align-items: center; justify-content: center", FILL = "position: absolute; top: 0; left: 0; right: 0; bottom: 0";
28
+ export declare const layer: Plugin;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Virtual list and grid: a long list of rows of one size, of which only
3
+ * what is in view is drawn (RFC-008 §5).
4
+ *
5
+ * lips.use( virtualList )
6
+ *
7
+ * <virtual-list items=state.rows size=40 class="rows" row="row" [item, index]>
8
+ * <span>{item.name}</span>
9
+ * </virtual-list>
10
+ * <virtual-list items=state.photos size=120 columns=3 …/>
11
+ * <virtual-list items=state.lines size=32 role="grid" …/>
12
+ *
13
+ * Its items are data, each with an `id`; `size` is a row's height in px,
14
+ * `columns` how many items a row holds (1 by default), `overscan` how many
15
+ * rows past the view are drawn too (3). Each item is drawn by the slot,
16
+ * which gets `item` and `index`, in a box of the class `row`.
17
+ *
18
+ * On the web, the list is a box that scrolls, and only the rows in view
19
+ * and the overscan are in the page, each placed where it falls. As
20
+ * `grid` or `table` (`role`), a list of one column says how many rows it
21
+ * has (`aria-rowcount`) and each row which it is (`aria-rowindex`), so a
22
+ * screen reader knows where it is among rows that are not drawn.
23
+ *
24
+ * On Lynx, it is Lynx's own `list`, which draws only the cells in view and
25
+ * recycles them (RFC-006 §4.5): every row is a `list-item`, `size` its
26
+ * estimated height, `columns` its `span-count`. Its markup is its `lynx`
27
+ * source (`lynxComponents`, `./lynx`).
28
+ *
29
+ * Not yet: rows of different heights, measured as they are drawn.
30
+ */
31
+ import type { Plugin } from '../types';
32
+ /** What is drawn of a list: each item in view, its index, and where its box goes */
33
+ export interface Placed<T = any> {
34
+ id: unknown;
35
+ item: T;
36
+ index: number;
37
+ style: string;
38
+ }
39
+ /**
40
+ * The items of a list of `count` in view of a box scrolled to `top` and
41
+ * `height` high, in rows of `size` px holding `columns` each, with
42
+ * `overscan` rows each side: from the first index, to the one past the last.
43
+ */
44
+ export declare function frame(count: number, top: number, height: number, size: number, columns?: number, overscan?: number): [number, number];
45
+ export declare const virtualList: Plugin;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Menu: a popover's panel of actions (RFC-008 §5; WAI-ARIA's menu button).
3
+ *
4
+ * lips.use( menu ) // and the popover it is built on
5
+ *
6
+ * <popover open=state.open on-change( setOpen )>
7
+ * <popover-trigger haspopup="menu"><span>Actions</span></popover-trigger>
8
+ * <popover-menu items=state.actions class="menu" item="menu-item" on-select( run )/>
9
+ * </popover>
10
+ *
11
+ * Named `popover-menu`: `menu` is an HTML element, which the compiler
12
+ * reads as one.
13
+ *
14
+ * Its items are data, `{ id, label, disabled? }`, each drawn as its label
15
+ * or by the slot, which gets `item` and `active`:
16
+ * `<popover-menu … [item, active]><span>{item.label}</span></popover-menu>`.
17
+ *
18
+ * Its list is the popup (`popup="content"`): mounted each time the menu
19
+ * opens, it starts on the item the trigger asked for, takes focus, and
20
+ * names the active item with `aria-activedescendant`. Arrows move it, Home
21
+ * and End go to the first and last, a letter to the next item it starts,
22
+ * all past disabled items. Enter or Space selects it; a tap selects the
23
+ * item tapped. Selecting emits `select` with the item and closes the menu,
24
+ * giving focus back to the trigger. Tab closes it and lets focus move on.
25
+ * On Lynx, which has no menu role, each item is a button.
26
+ *
27
+ * The active item has the class `is-active`; a disabled one,
28
+ * `aria-disabled` and `is-disabled`.
29
+ */
30
+ import type { Plugin } from '../types';
31
+ export interface MenuItem {
32
+ readonly id: string;
33
+ readonly label: string;
34
+ readonly disabled?: boolean;
35
+ }
36
+ /**
37
+ * The next item to make active from `from`, by `step` (±1), wrapping and
38
+ * skipping disabled ones; -1 when none can be. `from` -1 starts before the
39
+ * first item, `items.length` after the last.
40
+ */
41
+ export declare function move(items: readonly MenuItem[], from: number, step: 1 | -1): number;
42
+ /** The next enabled item after `from` whose label starts with `letter`, wrapping; -1 when none */
43
+ export declare function typed(items: readonly MenuItem[], from: number, letter: string): number;
44
+ export declare const menu: Plugin;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Popover: a trigger and the panel it opens, over the page (RFC-008 §5).
3
+ *
4
+ * lips.use( popover )
5
+ *
6
+ * <popover open=state.open on-change( setOpen )>
7
+ * <popover-trigger class="btn"><span>Actions</span></popover-trigger>
8
+ * <popover-content class="panel">…</popover-content>
9
+ * </popover>
10
+ *
11
+ * It is controlled: `open` is the app's, and a change comes back as
12
+ * `change`. `popover` provides what its pieces share as `context.popover`
13
+ * (`PopoverApi`), which reaches them where its slot places them (RFC-005
14
+ * §4.4). A piece given `of` uses that instead, so a piece can be driven by
15
+ * any controller of the same shape.
16
+ *
17
+ * `popover-content` renders, while open, a layer over the whole page
18
+ * (`page-layer`, `./layer`), a backdrop in it and the panel. Each time it
19
+ * opens, the panel is drawn invisible,
20
+ * then the trigger, the layer and the panel are measured and the panel is
21
+ * placed (`place`, or the app's own as `place=`), and focus goes to it.
22
+ *
23
+ * Closing: Escape, a tap on the backdrop, and whatever the content asks
24
+ * (`p.set( false )`); focus goes back to the trigger. The backdrop takes a
25
+ * tap outside whole, so it closes the panel and reaches nothing beneath,
26
+ * as a menu on a phone does. `.outside` would not do: it listens in the
27
+ * capture phase on both hosts, before the trigger's own tap, which would
28
+ * close the panel and open it again.
29
+ *
30
+ * `popup` says which element is the popup a screen reader is told of:
31
+ * `"panel"` (the default) gives the panel the popover's id, its `role`,
32
+ * the trigger as its label, and focus; `"content"` leaves all of that to
33
+ * the content, as a menu's list takes it (`./menu`).
34
+ *
35
+ * Its mechanics (the layer over the page, where the panel sits) are
36
+ * inline styles: Lynx cannot add a sheet at run time, so a part's own
37
+ * sheet would have to reach the app's build, and nothing here needs what
38
+ * only a sheet reaches (`:hover`, `@keyframes`, `@media`). Its look is the
39
+ * app's, through the classes it is given.
40
+ */
41
+ import type { Plugin } from '../types';
42
+ /** What a popover's pieces share: `context.popover`, or a piece's `of` */
43
+ export interface PopoverApi {
44
+ /** The popup's id; the trigger's is this with `-trigger` */
45
+ readonly id: string;
46
+ /** The app's `open`, read live */
47
+ readonly open: boolean;
48
+ /** The popup's id while it is open: what `aria-controls` names */
49
+ readonly controls: string | null;
50
+ /** The trigger's element, set by the trigger */
51
+ trigger?: {
52
+ focus(): void;
53
+ getBoundingClientRect(): unknown;
54
+ };
55
+ /** Where content with items starts when it opens, as the trigger's key asked */
56
+ start: 'first' | 'last';
57
+ /** Ask for `open`; closed, focus goes back to the trigger unless `back` is false */
58
+ set(open: boolean, back?: boolean): void;
59
+ toggle(): void;
60
+ }
61
+ /** A box as the DOM and Lips's Lynx refs both give it */
62
+ export interface Box {
63
+ top: number;
64
+ left: number;
65
+ right: number;
66
+ bottom: number;
67
+ width: number;
68
+ height: number;
69
+ }
70
+ /** Where a panel goes in its layer, from the three boxes measured */
71
+ export type Placement = (trigger: Box, layer: Box, panel: Box, rtl?: boolean) => {
72
+ top: number;
73
+ left: number;
74
+ };
75
+ /**
76
+ * Below the trigger, or above it where it does not fit below and does
77
+ * above; its start edge on the trigger's, or its end edge in right-to-left;
78
+ * kept inside the layer.
79
+ */
80
+ export declare const place: Placement;
81
+ export declare const popover: Plugin;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A region that reveals and folds: a button and the content it shows, in
3
+ * the page's flow (RFC-008 §5; WAI-ARIA's disclosure).
4
+ *
5
+ * lips.use( reveal ) // and the popover it is built on
6
+ *
7
+ * <popover open=state.more on-change( setMore )>
8
+ * <popover-trigger class="more"><span>Details</span></popover-trigger>
9
+ * <reveal-region class="details" keep=true>…</reveal-region>
10
+ * </popover>
11
+ *
12
+ * It is a popover's: the popover holds whether it is open (the app's
13
+ * `open`) and its id, and its trigger is the button, `aria-expanded`
14
+ * and controlling the region while it shows. The region is not a layer:
15
+ * it takes its place in the page, takes no focus, and nothing closes it
16
+ * but the button and the app.
17
+ *
18
+ * Folded, it renders nothing, or with `keep` stays rendered and hidden
19
+ * (`display: none`, which hides it from a screen reader on both hosts), so
20
+ * what was typed in it stays. With a `role` (`region`), it is named by
21
+ * its button.
22
+ */
23
+ import type { Plugin } from '../types';
24
+ export declare const reveal: Plugin;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Toasts: short messages in a region a screen reader is told of as they
3
+ * come (RFC-008 §5; WAI-ARIA's status and alert).
4
+ *
5
+ * lips.use( toast )
6
+ *
7
+ * <toast-region items=state.toasts class="toasts" item="toast" act="toast-act" on-dismiss( drop ) on-act( undo )/>
8
+ * <toast-region items=state.errors role="alert" … />
9
+ *
10
+ * The queue is the app's: `items` are data, `{ id, text, action?,
11
+ * duration? }`, and the region asks for one to go with `dismiss`, which
12
+ * the app does by taking it out. It is controlled, as every part is; it
13
+ * holds only each toast's time left.
14
+ *
15
+ * The region is always drawn, empty or not, so what comes into it is
16
+ * announced: `role="status"` (polite) by default, or `alert` (assertive),
17
+ * for errors. On Lynx, Lips announces a live region's new text through
18
+ * `lynx.accessibilityAnnounce` (RFC-006 §4.8).
19
+ *
20
+ * A toast leaves by itself after its `duration` (or the region's, 5 s by
21
+ * default), and not while the pointer or the focus is on it: its time is
22
+ * held, and goes on from where it was. One that offers an `action` never
23
+ * leaves by itself (WCAG 2.2.1): its button says `act`, and the app
24
+ * decides when it goes. Each toast is drawn as its text and its action, or
25
+ * by the slot, which gets `item`.
26
+ */
27
+ import type { Plugin } from '../types';
28
+ export interface Toast {
29
+ readonly id: string;
30
+ readonly text: string;
31
+ /** A button's words: a toast with one stays until the app takes it out */
32
+ readonly action?: string;
33
+ /** How long it stays, in ms */
34
+ readonly duration?: number;
35
+ }
36
+ export declare const toast: Plugin;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `@lipsjs/lips/parts`: headless components (RFC-008).
3
+ *
4
+ * Each part is a plugin: `lips.use()` installs its components and what it
5
+ * is built on, once.
6
+ *
7
+ * import { menu } from '@lipsjs/lips/parts'
8
+ * lips.use( menu ) // and the popover it is built on
9
+ *
10
+ * A part's templates are source. An app that runs in interpreted mode
11
+ * under a content security policy precompiles them in its build with
12
+ * `precompile()` (`@lipsjs/lips/precompile`), as it does its own; on Lynx,
13
+ * with `compileLynxTemplate()`.
14
+ */
15
+ export { layer, LAYER, CENTER, FILL } from './parts/layer';
16
+ export { popover, place, type PopoverApi, type Placement, type Box } from './parts/popover';
17
+ export { menu, move, typed, type MenuItem } from './parts/menu';
18
+ export { dialog, inert } from './parts/dialog';
19
+ export { toast, type Toast } from './parts/toast';
20
+ export { icons, type Icon, type IconSet } from './parts/icon';
21
+ export { combobox, contains, type Option, type Match } from './parts/combobox';
22
+ export { reveal } from './parts/reveal';
23
+ export { virtualList, frame, type Placed } from './parts/list';
24
+ export { datePicker, isoOf, addDays, addMonths, weeksOf, calendarWords, firstDay, ENGLISH, type CalendarWords } from './parts/date';
@@ -16,15 +16,12 @@
16
16
  import type { TemplateIR, CompileOptions } from './ir/compiler';
17
17
  import type { StyleIR, StylePreprocessor } from './ir/style';
18
18
  import type { TemplateDiagnostic } from './ir/parser';
19
- export interface PrecompiledTemplate {
19
+ import type { Component, TypedComponent, Shape } from './types';
20
+ /** What `precompile()` returns: the template it was given, with `ir` (and `style`) for its sources */
21
+ /** A component with its markup and stylesheet compiled: no source ships */
22
+ export type PrecompiledComponent<S extends Shape = Shape> = Omit<TypedComponent<S>, 'default' | 'macros' | 'stylesheet'> & {
20
23
  ir: TemplateIR;
21
- /** Compiled stylesheet — replaces `stylesheet` source (RFC-004) */
22
- style?: StyleIR;
23
- state?: Record<string, any>;
24
- _static?: Record<string, any>;
25
- context?: string[];
26
- handler?: Record<string, (...args: any[]) => any>;
27
- }
24
+ };
28
25
  export interface PrecompileOptions {
29
26
  /**
30
27
  * Scope name for the stylesheet — baked into the StyleIR, so it must
@@ -41,8 +38,8 @@ export interface PrecompileOptions {
41
38
  /** The kind of host the IR is for — see `CompileOptions.target` */
42
39
  target?: CompileOptions['target'];
43
40
  }
44
- export interface PrecompileResult {
45
- template: PrecompiledTemplate;
41
+ export interface PrecompileResult<S extends Shape = Shape> {
42
+ template: PrecompiledComponent<S>;
46
43
  diagnostics: TemplateDiagnostic[];
47
44
  }
48
45
  /**
@@ -51,7 +48,7 @@ export interface PrecompileResult {
51
48
  * is compiled to StyleIR, so the `./runtime` build needs no CSS
52
49
  * preprocessor either (RFC-004 §1).
53
50
  */
54
- export declare function precompile(template: Record<string, any>, options?: PrecompileOptions): PrecompileResult;
51
+ export declare function precompile<S extends Shape = Shape>(template: Component<S>, options?: PrecompileOptions): PrecompileResult<S>;
55
52
  /** Serialize an IR for embedding in generated source */
56
53
  export declare const serializeIR: (ir: TemplateIR) => string;
57
54
  export declare const serializeStyleIR: (ir: StyleIR) => string;
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import { IRLips } from './ir/facade';
12
12
  export * from './types';
13
+ export { component } from './component';
13
14
  export { renderIR } from './ir/runtime';
14
15
  export { signal, effect, untrack, reactive } from './ir/signal';
15
16
  export type { TemplateIR, IRInstance, RuntimeOptions, RenderSetup, SwapReport, Host } from './ir';