staffa 0.15.0 → 0.17.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 +99 -271
- package/dist/components/autocomplete.js +4 -5
- package/dist/components/box.js +11 -21
- package/dist/components/button.d.ts +20 -5
- package/dist/components/button.js +55 -47
- package/dist/components/buttonChooser.js +1 -3
- package/dist/components/checkbox.js +1 -2
- package/dist/components/dialog.d.ts +9 -2
- package/dist/components/dialog.js +28 -32
- package/dist/components/field.d.ts +5 -8
- package/dist/components/field.js +4 -6
- package/dist/components/form.d.ts +5 -7
- package/dist/components/form.js +6 -9
- package/dist/components/keyhelp.d.ts +22 -0
- package/dist/components/keyhelp.js +91 -0
- package/dist/components/main.js +188 -271
- package/dist/components/menu.d.ts +48 -10
- package/dist/components/menu.js +228 -147
- package/dist/components/panels.d.ts +151 -239
- package/dist/components/panels.js +331 -558
- package/dist/components/select.js +1 -3
- package/dist/components/tabs.d.ts +10 -13
- package/dist/components/tabs.js +38 -58
- package/dist/components/textline.d.ts +3 -5
- package/dist/components/textline.js +3 -5
- package/dist/components/toast.d.ts +1 -3
- package/dist/components/toast.js +2 -3
- package/dist/components/tooltip.d.ts +4 -5
- package/dist/components/tooltip.js +13 -11
- package/dist/core.d.ts +17 -24
- package/dist/core.js +13 -18
- package/dist/icons-helpers.d.ts +3 -3
- package/dist/icons-helpers.js +6 -11
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -4
- package/dist/keys.d.ts +92 -0
- package/dist/keys.js +279 -0
- package/dist/staffa.esm.js +1 -1
- package/dist/theme.d.ts +4 -10
- package/dist/theme.js +58 -123
- package/package.json +2 -2
- package/skill/ButtonOptions.md +12 -0
- package/skill/DialogOptions.md +11 -2
- package/skill/FieldOptions.md +3 -5
- package/skill/IconButtonOptions.md +8 -0
- package/skill/MenuItem.md +32 -3
- package/skill/Panel.md +11 -3
- package/skill/SKILL.md +161 -294
- package/skill/addTooltip.md +4 -5
- package/skill/bindKey.md +51 -0
- package/skill/box.md +1 -1
- package/skill/form.md +5 -7
- package/skill/formatKey.md +21 -0
- package/skill/iconButton.md +4 -5
- package/skill/scrollStrip.md +7 -9
- package/skill/showFloatingMenu.md +2 -2
- package/skill/showKeyHelp.md +17 -0
- package/skill/tabs.md +3 -4
- package/skill/textline.md +3 -5
- package/src/components/autocomplete.ts +4 -5
- package/src/components/box.ts +11 -21
- package/src/components/button.ts +70 -47
- package/src/components/buttonChooser.ts +1 -3
- package/src/components/checkbox.ts +1 -2
- package/src/components/dialog.ts +38 -34
- package/src/components/field.ts +7 -11
- package/src/components/form.ts +6 -9
- package/src/components/keyhelp.ts +96 -0
- package/src/components/main.ts +191 -270
- package/src/components/menu.ts +258 -150
- package/src/components/panels.ts +378 -623
- package/src/components/select.ts +1 -3
- package/src/components/tabs.ts +38 -58
- package/src/components/textline.ts +3 -5
- package/src/components/toast.ts +3 -6
- package/src/components/tooltip.ts +12 -11
- package/src/core.ts +17 -24
- package/src/icons-helpers.ts +6 -11
- package/src/index.ts +5 -4
- package/src/keys.ts +300 -0
- package/src/theme.ts +58 -123
- package/skill/Attributes.md +0 -10
|
@@ -26,15 +26,40 @@ export interface MenuItem {
|
|
|
26
26
|
* `attrs: "data-panel=push"` for a row that should stack instead.
|
|
27
27
|
*/
|
|
28
28
|
href?: string;
|
|
29
|
+
/**
|
|
30
|
+
* A keyboard shortcut that activates this item: `"mod+k"`, `"f2"`, a bare
|
|
31
|
+
* `"?"`. The spelling, and which keystrokes are yours to take, are
|
|
32
|
+
* documented on {@link bindKey}. In a dropdown or context menu the
|
|
33
|
+
* combination shows at the right end of the row (not on a touch device); a
|
|
34
|
+
* nav row — `S.main`'s sidebar, {@link menu} — keeps its label clean and
|
|
35
|
+
* tells it in its {@link MenuItem.tooltip | tooltip} instead. Either way
|
|
36
|
+
* it reaches screen readers as `aria-keyshortcuts`, and the `?` overview
|
|
37
|
+
* ({@link showKeyHelp}) lists it under the item's label. Activating runs
|
|
38
|
+
* `click` with the `KeyboardEvent` and follows `href` as a fresh navigation
|
|
39
|
+
* to it — the target getting its own panel stack, as a nav item's does.
|
|
40
|
+
*
|
|
41
|
+
* The shortcut works with the menu shut — rather the point of one on a
|
|
42
|
+
* dropdown or context menu — for as long as whatever owns the items is
|
|
43
|
+
* drawn: the {@link menu}, {@link menuButton} or {@link addContextMenu}
|
|
44
|
+
* call, or `S.main`'s `nav`. (The bare {@link showFloatingMenu} binds
|
|
45
|
+
* nothing: its menu exists only while it is up.) A disabled item's key is
|
|
46
|
+
* not bound.
|
|
47
|
+
*/
|
|
48
|
+
key?: string;
|
|
49
|
+
/**
|
|
50
|
+
* A tooltip for this item, shown on hover and keyboard focus. A string
|
|
51
|
+
* renders as rich text. In a nav, the item's `key` is shown underneath it,
|
|
52
|
+
* behind a subtle separator (see {@link MenuItem.key}).
|
|
53
|
+
*/
|
|
54
|
+
tooltip?: Slot;
|
|
29
55
|
/**
|
|
30
56
|
* Pages this item claims *beyond* its own `href`: a string claims that path
|
|
31
57
|
* and everything under it (`"/mail"` claims `/mail/…`, not `/mailbox`), a
|
|
32
58
|
* function is asked with the current path. While a claimed page is current,
|
|
33
59
|
* the item is highlighted and the branches above it stay unfolded — for the
|
|
34
60
|
* detail screens a menu has no row of their own: the `/thread/[id]` a
|
|
35
|
-
* notification lands on, an icon's page under the gallery's row. Claims
|
|
36
|
-
*
|
|
37
|
-
* which no amount of fold-state keeping can.
|
|
61
|
+
* notification lands on, an icon's page under the gallery's row. Claims work
|
|
62
|
+
* from the first paint, so cold deep links are covered too.
|
|
38
63
|
*/
|
|
39
64
|
match?: string | ((path: string) => boolean);
|
|
40
65
|
/** `target` for the link (`_blank`, etc.). Only meaningful with `href`. */
|
|
@@ -154,15 +179,28 @@ export type ContextMenuOptions = Omit<FloatingMenuOptions, "anchor" | "at" | "cl
|
|
|
154
179
|
* @param onLeafSelect Optional — run when a *leaf* item is activated (used by
|
|
155
180
|
* the floating menu to close itself on selection). A branch expanding is
|
|
156
181
|
* not a selection, so it doesn't run this.
|
|
182
|
+
* @param keyHints Print each row's `key` at its right end, as the floating
|
|
183
|
+
* menus do. Off — any kind of nav — a row tells its key in its tooltip
|
|
184
|
+
* instead, keeping the resting rows quiet.
|
|
157
185
|
*/
|
|
158
|
-
export declare function drawMenu(items: MenuEntry[], onLeafSelect?: () => void): void;
|
|
186
|
+
export declare function drawMenu(items: MenuEntry[], onLeafSelect?: () => void, keyHints?: boolean): void;
|
|
159
187
|
/**
|
|
160
|
-
* Whether any item anywhere in `items` — branches, their leaves, `match`
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* so the two can never disagree with the highlighting.
|
|
188
|
+
* Whether any item anywhere in `items` — branches, their leaves, `match` claims — is
|
|
189
|
+
* the current page. Exported because the shell's tagline rule (`taglineFits` in
|
|
190
|
+
* main.ts) must agree with the highlighting.
|
|
164
191
|
*/
|
|
165
192
|
export declare function anyCurrent(items: MenuEntry[]): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Bind the shortcuts of every item in a menu — see {@link MenuItem.key} — for as
|
|
195
|
+
* long as the calling scope lives. The `?` overview lists each binding under its
|
|
196
|
+
* item's label. No `aria-keyshortcuts` here — the rows announce their own.
|
|
197
|
+
*
|
|
198
|
+
* `getItems` is a function rather than the array itself, so that the read happens
|
|
199
|
+
* in this scope and not the caller's: a menu's items are often a reactive array,
|
|
200
|
+
* and subscribing the caller (`S.main()`'s whole shell, say) to it would redraw
|
|
201
|
+
* far more than the menu.
|
|
202
|
+
*/
|
|
203
|
+
export declare function registerMenuKeys(getItems: () => MenuEntry[], onSelect?: () => void): void;
|
|
166
204
|
/**
|
|
167
205
|
* Whether the navigation that just landed on `path` was a branch row expanding
|
|
168
206
|
* (consuming the note it left). Internal — used by the floating menu below and
|
|
@@ -210,8 +248,8 @@ export declare function menu(opts: MenuListOptions): void;
|
|
|
210
248
|
/**
|
|
211
249
|
* Open a floating dropdown menu anchored to an element. Portals to
|
|
212
250
|
* `document.body` (never clipped), positions itself (flipping up when there's
|
|
213
|
-
* no room below), and closes on Escape, Tab, item selection,
|
|
214
|
-
* outside the panel and anchor. Returns a `close()` function.
|
|
251
|
+
* no room below), and closes on Escape, Tab, item selection, a navigation, or
|
|
252
|
+
* any click outside the panel and anchor. Returns a `close()` function.
|
|
215
253
|
*
|
|
216
254
|
* Menus are usually opened through {@link menuButton} or
|
|
217
255
|
* {@link addContextMenu}; reach for this primitive when you need to trigger a
|