@lipsjs/lips 0.4.0 → 0.6.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/dist/lips.js +14 -3
- package/dist/lips.js.map +4 -4
- package/dist/lips.min.js +7 -7
- package/dist/lips.min.js.map +4 -4
- package/dist/lynx-background.min.js +2 -2
- package/dist/lynx-background.min.js.map +3 -3
- package/dist/lynx.min.js +8 -8
- package/dist/lynx.min.js.map +6 -4
- package/dist/parts.min.js +89 -8
- package/dist/parts.min.js.map +13 -5
- package/dist/precompile.min.js +13 -13
- package/dist/precompile.min.js.map +5 -4
- package/dist/runtime.min.js +3 -3
- package/dist/runtime.min.js.map +4 -4
- package/dist/types/ir/facade.d.ts +9 -1
- package/dist/types/lynx/components.d.ts +28 -0
- package/dist/types/lynx.d.ts +1 -0
- package/dist/types/parts/combobox.d.ts +47 -0
- package/dist/types/parts/date.d.ts +75 -0
- package/dist/types/parts/dialog.d.ts +42 -0
- package/dist/types/parts/icon.d.ts +31 -0
- package/dist/types/parts/layer.d.ts +28 -0
- package/dist/types/parts/list.d.ts +45 -0
- package/dist/types/parts/popover.d.ts +3 -5
- package/dist/types/parts/reveal.d.ts +24 -0
- package/dist/types/parts/toast.d.ts +36 -0
- package/dist/types/parts.d.ts +8 -0
- package/dist/types/plugins.d.ts +15 -0
- package/dist/types/precompile.d.ts +30 -1
- package/dist/types/types.d.ts +18 -0
- package/package.json +1 -1
|
@@ -125,11 +125,19 @@ export declare class IRLips<Context extends Object = Shape<{}>['context']> {
|
|
|
125
125
|
* Install a plugin: what it requires first, then its components, then
|
|
126
126
|
* its own setup. Once per Lips: using it again, or another plugin that
|
|
127
127
|
* requires it, does nothing. Refused: another plugin of the same name,
|
|
128
|
-
* and a component name something else holds.
|
|
128
|
+
* and a component name something else holds. A component the config's
|
|
129
|
+
* `precompiled` holds IR for is registered with it.
|
|
129
130
|
*
|
|
130
131
|
* lips.use( menu ) // and the popover it is built on
|
|
131
132
|
*/
|
|
132
133
|
use<O>(plugin: Plugin<O>, options?: O): this;
|
|
134
|
+
/**
|
|
135
|
+
* A plugin's component with the IR its build made for `name`, where the
|
|
136
|
+
* config holds one (`precompiled`); one copy per component, so two
|
|
137
|
+
* plugins that bring the same component still hold the same one.
|
|
138
|
+
*/
|
|
139
|
+
private built;
|
|
140
|
+
private withIR;
|
|
133
141
|
unregister(name: string): this;
|
|
134
142
|
has(name: string): boolean;
|
|
135
143
|
private compile;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugins on Lynx (RFC-008 §4): each component of each plugin, and of what
|
|
3
|
+
* it requires, compiled for Lynx, as `renderIR`'s `components`.
|
|
4
|
+
*
|
|
5
|
+
* const { components, diagnostics } = lynxComponents([ menu, dialog ])
|
|
6
|
+
* renderIR( ir, setup, { host: bg.host, components })
|
|
7
|
+
*
|
|
8
|
+
* On Lynx an app renders its compiled IR with `renderIR`, not through
|
|
9
|
+
* `new Lips()`, so `lips.use()` has no instance to install into: this is
|
|
10
|
+
* its counterpart, by the same rules (`../plugins`). What a plugin
|
|
11
|
+
* requires comes first, each plugin once; another plugin of the same
|
|
12
|
+
* name, and a component name something else holds, are refused.
|
|
13
|
+
*
|
|
14
|
+
* A component's `lynx` source, where it has one, is compiled in place of
|
|
15
|
+
* its `default`: where its markup differs by host. A plugin's `install`
|
|
16
|
+
* has no Lips to run against, a component's `stylesheet` cannot be added
|
|
17
|
+
* on Lynx at run time (`./plugin`), and precompiled `ir` is the DOM's:
|
|
18
|
+
* each is refused, not dropped.
|
|
19
|
+
*/
|
|
20
|
+
import type { Plugin } from '../types';
|
|
21
|
+
import type { IRComponentDef } from '../ir/runtime';
|
|
22
|
+
import type { TemplateDiagnostic } from '../ir/parser';
|
|
23
|
+
export interface LynxComponents {
|
|
24
|
+
components: Record<string, IRComponentDef>;
|
|
25
|
+
/** What each component's template reported, by its name */
|
|
26
|
+
diagnostics: Record<string, TemplateDiagnostic[]>;
|
|
27
|
+
}
|
|
28
|
+
export declare function lynxComponents(plugins: readonly Plugin<any>[]): LynxComponents;
|
package/dist/types/lynx.d.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
* In a form, the field is the app's: `id` names it, for a `<label for>`
|
|
30
|
+
* and for the app to focus it; `labelledby` labels it and its list by an
|
|
31
|
+
* element of the app's in place of `label`; `describedby`, `required` and
|
|
32
|
+
* `invalid` say what the app says of its own fields. Text typed and left,
|
|
33
|
+
* by Escape or Tab, goes back to the chosen option's label: the field
|
|
34
|
+
* shows what is chosen, never what was only typed.
|
|
35
|
+
*
|
|
36
|
+
* The active option has the class `is-active`; the chosen one,
|
|
37
|
+
* `is-selected`; a disabled one, `aria-disabled` and `is-disabled`. Each
|
|
38
|
+
* is drawn as its label, or by the slot, which gets `option`, `active`
|
|
39
|
+
* and `selected`.
|
|
40
|
+
*/
|
|
41
|
+
import type { Plugin } from '../types';
|
|
42
|
+
import { type MenuItem } from './menu';
|
|
43
|
+
export type Option = MenuItem;
|
|
44
|
+
export type Match = (option: Option, text: string) => boolean;
|
|
45
|
+
/** The label holds the text, in any case */
|
|
46
|
+
export declare const contains: Match;
|
|
47
|
+
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;
|
|
@@ -14,11 +14,9 @@
|
|
|
14
14
|
* §4.4). A piece given `of` uses that instead, so a piece can be driven by
|
|
15
15
|
* any controller of the same shape.
|
|
16
16
|
*
|
|
17
|
-
* `popover-content` renders, while open, a layer over the whole page
|
|
18
|
-
* backdrop in it and the panel.
|
|
19
|
-
*
|
|
20
|
-
* what Lynx asks of a page that is all Lynx (its `overlay` is for Lynx
|
|
21
|
-
* inside a native page). Each time it opens, the panel is drawn invisible,
|
|
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,
|
|
22
20
|
* then the trigger, the layer and the panel are measured and the panel is
|
|
23
21
|
* placed (`place`, or the app's own as `place=`), and focus goes to it.
|
|
24
22
|
*
|
|
@@ -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;
|
package/dist/types/parts.d.ts
CHANGED
|
@@ -12,5 +12,13 @@
|
|
|
12
12
|
* `precompile()` (`@lipsjs/lips/precompile`), as it does its own; on Lynx,
|
|
13
13
|
* with `compileLynxTemplate()`.
|
|
14
14
|
*/
|
|
15
|
+
export { layer, LAYER, CENTER, FILL } from './parts/layer';
|
|
15
16
|
export { popover, place, type PopoverApi, type Placement, type Box } from './parts/popover';
|
|
16
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';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugins compiled ahead of `use()` (RFC-008 §4): each plugin and what it
|
|
3
|
+
* requires, in the order `lips.use()` installs them — what a plugin
|
|
4
|
+
* requires first, each plugin once, a cycle ended — with the components
|
|
5
|
+
* each brings. `lynxComponents()` (`./lynx`) and `precompilePlugins()`
|
|
6
|
+
* (`./precompile`) both walk them so, by the same rules `use()` holds to:
|
|
7
|
+
* another plugin of the same name, and a component name something else
|
|
8
|
+
* holds, are refused.
|
|
9
|
+
*/
|
|
10
|
+
import type { Plugin, Component } from './types';
|
|
11
|
+
export interface Installed {
|
|
12
|
+
plugin: Plugin<any>;
|
|
13
|
+
components: [string, Component<any>][];
|
|
14
|
+
}
|
|
15
|
+
export declare function installed(plugins: readonly Plugin<any>[]): Installed[];
|
|
@@ -16,7 +16,7 @@
|
|
|
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
|
-
import type { Component, TypedComponent, Shape } from './types';
|
|
19
|
+
import type { Component, TypedComponent, Shape, Plugin } from './types';
|
|
20
20
|
/** What `precompile()` returns: the template it was given, with `ir` (and `style`) for its sources */
|
|
21
21
|
/** A component with its markup and stylesheet compiled: no source ships */
|
|
22
22
|
export type PrecompiledComponent<S extends Shape = Shape> = Omit<TypedComponent<S>, 'default' | 'macros' | 'stylesheet'> & {
|
|
@@ -49,6 +49,35 @@ export interface PrecompileResult<S extends Shape = Shape> {
|
|
|
49
49
|
* preprocessor either (RFC-004 §1).
|
|
50
50
|
*/
|
|
51
51
|
export declare function precompile<S extends Shape = Shape>(template: Component<S>, options?: PrecompileOptions): PrecompileResult<S>;
|
|
52
|
+
/** A plugin's component as its build made it: plain JSON, its handlers left in the plugin */
|
|
53
|
+
export interface PrecompiledPart {
|
|
54
|
+
ir: TemplateIR;
|
|
55
|
+
style?: StyleIR;
|
|
56
|
+
}
|
|
57
|
+
export interface PrecompiledPlugins {
|
|
58
|
+
/** Each component's IR, and its sheet's, by the name it is registered under */
|
|
59
|
+
components: Record<string, PrecompiledPart>;
|
|
60
|
+
/** What each component's template and sheet reported, by its name */
|
|
61
|
+
diagnostics: Record<string, TemplateDiagnostic[]>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Plugins precompiled (RFC-008 §4): each component of each plugin, and of
|
|
65
|
+
* what it requires, compiled as `use()` would install it, for a build that
|
|
66
|
+
* ships no compiler. What comes back is data, so a build writes it beside
|
|
67
|
+
* its own templates' IR; the app hands it to its Lips and uses the plugins
|
|
68
|
+
* as ever, each component taking the IR made for its name:
|
|
69
|
+
*
|
|
70
|
+
* // in the build
|
|
71
|
+
* const { components } = precompilePlugins([ combobox, dialog ])
|
|
72
|
+
* // in the page, on `@lipsjs/lips/runtime`
|
|
73
|
+
* const lips = new Lips({ mode: 'interpreted', precompiled: components })
|
|
74
|
+
* lips.use( combobox ).use( dialog )
|
|
75
|
+
*
|
|
76
|
+
* Walked by the same rules as `use()` and `lynxComponents()` (`./plugins`).
|
|
77
|
+
* A component that carries `ir` already is taken as it is. Its sheet is
|
|
78
|
+
* scoped by its name, as `register()` scopes it.
|
|
79
|
+
*/
|
|
80
|
+
export declare function precompilePlugins(plugins: readonly Plugin<any>[], options?: Omit<PrecompileOptions, 'name'>): PrecompiledPlugins;
|
|
52
81
|
/** Serialize an IR for embedding in generated source */
|
|
53
82
|
export declare const serializeIR: (ir: TemplateIR) => string;
|
|
54
83
|
export declare const serializeStyleIR: (ir: StyleIR) => string;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -156,6 +156,13 @@ export type Component<S extends Shape = Shape> = {
|
|
|
156
156
|
name?: string;
|
|
157
157
|
/** Template source — the component's markup */
|
|
158
158
|
default?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Template source for Lynx, where the markup differs by host: a part
|
|
161
|
+
* that renders Lynx's own `list` on Lynx and windowed rows on the web.
|
|
162
|
+
* `lynxComponents()` (`./lynx`) compiles it in place of `default`. Left
|
|
163
|
+
* out, `default` serves both hosts, as it should wherever it can.
|
|
164
|
+
*/
|
|
165
|
+
lynx?: string;
|
|
159
166
|
/** Precompiled template IR — used instead of `default` (see `precompile`) */
|
|
160
167
|
ir?: TemplateIR;
|
|
161
168
|
state?: S['state'];
|
|
@@ -271,6 +278,17 @@ export type LipsConfig<Context extends Object = {}> = {
|
|
|
271
278
|
* entries are separate bundles with separate module state.
|
|
272
279
|
*/
|
|
273
280
|
stylePreprocessor?: (css: string) => string;
|
|
281
|
+
/**
|
|
282
|
+
* Plugins' components as a build compiled them (`precompilePlugins()`
|
|
283
|
+
* from `@lipsjs/lips/precompile`), by name: `use()` registers each
|
|
284
|
+
* component of a plugin with the IR made for its name, so a plugin's
|
|
285
|
+
* source templates run on `./runtime`, which has no compiler (RFC-008
|
|
286
|
+
* §4). A component with none here is registered as it is.
|
|
287
|
+
*/
|
|
288
|
+
precompiled?: Readonly<Record<string, {
|
|
289
|
+
ir: TemplateIR;
|
|
290
|
+
style?: StyleIR;
|
|
291
|
+
}>>;
|
|
274
292
|
/**
|
|
275
293
|
* The MessageFormat 2 engine dictionaries are formatted with. The full
|
|
276
294
|
* build wires it in; the precompiled `./runtime` entry ships without it
|