staffa 0.12.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -15
- package/dist/components/dialog.js +3 -1
- package/dist/components/main.d.ts +43 -29
- package/dist/components/main.js +85 -51
- package/dist/components/menu.d.ts +8 -0
- package/dist/components/menu.js +48 -13
- package/dist/components/panels.d.ts +105 -82
- package/dist/components/panels.js +185 -230
- package/dist/components/select.js +4 -2
- package/dist/components/tabs.js +9 -5
- package/dist/components/toast.js +3 -1
- package/dist/components/tooltip.js +12 -5
- package/dist/core.d.ts +15 -0
- package/dist/core.js +17 -0
- package/dist/index.d.ts +1 -1
- package/dist/staffa.esm.js +1 -1
- package/dist/theme.d.ts +13 -65
- package/dist/theme.js +21 -8
- package/package.json +1 -1
- package/skill/FloatingMenuOptions.md +10 -0
- package/skill/MainOptions.md +43 -28
- package/skill/Panel.md +31 -30
- package/skill/PanelStack.md +4 -4
- package/skill/SKILL.md +30 -15
- package/skill/main.md +2 -1
- package/src/components/dialog.ts +3 -1
- package/src/components/main.ts +128 -79
- package/src/components/menu.ts +56 -12
- package/src/components/panels.ts +252 -286
- package/src/components/select.ts +4 -2
- package/src/components/tabs.ts +7 -3
- package/src/components/toast.ts +3 -1
- package/src/components/tooltip.ts +12 -5
- package/src/core.ts +19 -0
- package/src/index.ts +1 -1
- package/src/theme.ts +24 -9
|
@@ -4,20 +4,24 @@ import { type Slot } from "../core.js";
|
|
|
4
4
|
* Routed, multi-column panel navigation for {@link main}.
|
|
5
5
|
*
|
|
6
6
|
* Each route draws one screen of the app, called a *panel*. The open panels
|
|
7
|
-
* form a **stack**,
|
|
7
|
+
* form a **stack**, whose last panel is the **current** one: the panel the URL
|
|
8
8
|
* names, and the rightmost column on screen. As many panels as fit are shown,
|
|
9
9
|
* ending at the current one — on a phone that is one at a time, on a wider
|
|
10
10
|
* screen the panels that would have covered each other sit side by side
|
|
11
11
|
* instead. The app's own code is the same either way.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
13
|
+
* Whatever a navigation lands on becomes the top of that stack, and the same
|
|
14
|
+
* path is never in it twice. Opening a new panel closes everything after the
|
|
15
|
+
* panel it came from; a plain link to a panel that is already open — a
|
|
16
|
+
* breadcrumb, a nav item for the section you are in — returns to its own
|
|
17
|
+
* place, closing whatever was stacked on top, while a `replace` or `open`
|
|
18
|
+
* applies its usual shape, the open panel moving into it alive.
|
|
19
|
+
* Two kinds of panel survive that: the ones the user pinned, which ride along,
|
|
20
|
+
* and the ones holding unsaved work, which no navigation ever tears down.
|
|
21
|
+
* Those wait parked out of sight past the rightmost column, which is the only
|
|
22
|
+
* way a panel ever sits *after* the current one. Escape closes the current
|
|
23
|
+
* panel — or just steps left, when it holds unsaved work or panels sit parked
|
|
24
|
+
* beyond it.
|
|
21
25
|
*
|
|
22
26
|
* Navigation runs through `aberdeen/route`: the URL holds the current panel,
|
|
23
27
|
* and the rest of the arrangement — the panels before it, the ones parked
|
|
@@ -83,6 +87,14 @@ export type AncestorsHandler<P = any> = (params: P, path: string) => readonly st
|
|
|
83
87
|
export type AncestorTable<R> = {
|
|
84
88
|
[K in keyof R & string]?: (params: Prettify<PathParams<K>>, path: string) => readonly string[] | undefined | void;
|
|
85
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* How wide a panel asks to be — a ceiling the shell never exceeds; see
|
|
92
|
+
* {@link Panel.maxWidth}. `"small"` is the column the content area is divided
|
|
93
|
+
* into; `"medium"` and `"large"` are two and three of those, and `"none"` is
|
|
94
|
+
* the whole area. Each is capped at the content area, so on a narrow window
|
|
95
|
+
* they all come to the same thing.
|
|
96
|
+
*/
|
|
97
|
+
export type PanelSize = "small" | "medium" | "large" | "none";
|
|
86
98
|
/**
|
|
87
99
|
* What a route handler gets: the params from its route, plus everything the
|
|
88
100
|
* shell needs to know about the panel it is drawing. It's an Aberdeen proxy, so
|
|
@@ -153,33 +165,35 @@ export interface Panel<P = Record<string, string | number | string[]>> {
|
|
|
153
165
|
*/
|
|
154
166
|
readonly visible: boolean;
|
|
155
167
|
/**
|
|
156
|
-
* The widest this panel can usefully be
|
|
157
|
-
*
|
|
158
|
-
* *
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
168
|
+
* The widest this panel can usefully be — a ceiling the shell never
|
|
169
|
+
* exceeds, so the draw function never has to look right past it. It is
|
|
170
|
+
* counted in the shell's *columns*: the content area divides into the
|
|
171
|
+
* narrowest whole number of columns of at least 360px each (three columns
|
|
172
|
+
* of 360 in a 1080px area, four of 380 in 1520px), and a column is never
|
|
173
|
+
* wider than 540 — where the area holds just one, a small centres in it
|
|
174
|
+
* rather than stretching. So an ask never exceeds its column count × 540:
|
|
175
|
+
*
|
|
176
|
+
* - `"small"` — one column, never above 540px: lists, detail forms.
|
|
177
|
+
* - `"medium"` (the default) — two columns, never above 1080px.
|
|
178
|
+
* - `"large"` — three columns, never above 1620px: wide tables.
|
|
179
|
+
* - `"none"` — the whole content area, unbounded: boards, dashboards.
|
|
180
|
+
* Bound it with the shell's own `maxWidth` where that matters.
|
|
181
|
+
*
|
|
182
|
+
* Every size is capped at the content area, so on a phone they all come to
|
|
183
|
+
* the same thing: one screen at a time. And a width depends only on the
|
|
184
|
+
* window, never on what else is open, so opening or closing a panel never
|
|
185
|
+
* resizes another — the run of columns just recentres in the area.
|
|
186
|
+
*
|
|
187
|
+
* Ask only for what your content can actually use: a panel that would cap
|
|
188
|
+
* its own content narrower than its ask is holding room that would have
|
|
189
|
+
* let another column fit beside it.
|
|
176
190
|
*
|
|
177
191
|
* Set it at the top of your handler and the panel is already that wide when
|
|
178
192
|
* you draw (see {@link Panel.width}); set it later — when your data tells you
|
|
179
193
|
* — and the panel reflows without being redrawn, keeping its state, while
|
|
180
194
|
* the columns beside it move over.
|
|
181
195
|
*/
|
|
182
|
-
maxWidth?:
|
|
196
|
+
maxWidth?: PanelSize;
|
|
183
197
|
/**
|
|
184
198
|
* Set this while you're fetching what the panel needs, and back to `false`
|
|
185
199
|
* when you're done. A new panel waits a moment before sliding in, so it can
|
|
@@ -190,10 +204,10 @@ export interface Panel<P = Record<string, string | number | string[]>> {
|
|
|
190
204
|
loading?: boolean;
|
|
191
205
|
/**
|
|
192
206
|
* Keeps this panel from being closed by navigation happening *elsewhere*.
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* click away. The user toggles it from the crumb's context menu
|
|
207
|
+
* A navigation normally closes everything after the panel it came from (or
|
|
208
|
+
* returned to); a pinned panel survives that, staying in the stack — slotted
|
|
209
|
+
* in beneath the new panel, or parked out of sight when the new panel was
|
|
210
|
+
* already beneath it. Either way it is one crumb click away. The user toggles it from the crumb's context menu
|
|
197
211
|
* (right-click or long-press), which is also where the pin shows; setting
|
|
198
212
|
* it from code does the same thing.
|
|
199
213
|
*
|
|
@@ -205,12 +219,11 @@ export interface Panel<P = Record<string, string | number | string[]>> {
|
|
|
205
219
|
/**
|
|
206
220
|
* Set this while the panel holds work that must not be lost — a dirty form,
|
|
207
221
|
* an upload in flight. An unsaved panel cannot be closed, by anything:
|
|
208
|
-
* navigation that would prune it parks it instead,
|
|
209
|
-
*
|
|
210
|
-
* only parks it. {@link Panel.close} and the crumb menu's Close refuse,
|
|
222
|
+
* navigation that would prune it parks it out of sight instead, wearing a
|
|
223
|
+
* ● in its crumb — even the browser's back button only parks it. {@link Panel.close} and the crumb menu's Close refuse,
|
|
211
224
|
* Escape on it steps left along the stack rather than closing, and closing
|
|
212
|
-
* the browser tab runs into the browser's own are-you-sure
|
|
213
|
-
*
|
|
225
|
+
* the browser tab runs into the browser's own are-you-sure, the unsaved
|
|
226
|
+
* panel brought on screen as the question is raised.
|
|
214
227
|
*
|
|
215
228
|
* Only the app clears it; the user has no toggle. A Save or Discard button
|
|
216
229
|
* clears it and then closes:
|
|
@@ -275,14 +288,7 @@ export interface Panel<P = Record<string, string | number | string[]>> {
|
|
|
275
288
|
*/
|
|
276
289
|
open(href: string, how?: "push" | "replace" | "open"): Promise<boolean>;
|
|
277
290
|
}
|
|
278
|
-
|
|
279
|
-
* The standard page width: sidebar plus content area, capped by the window.
|
|
280
|
-
* `"full"` fills the content-area part of this exactly; only a `"screen"`
|
|
281
|
-
* page makes the shell grow past it. The top bar and footer keep to this
|
|
282
|
-
* width even then (see main.ts), so the chrome holds still while the
|
|
283
|
-
* columns stretch.
|
|
284
|
-
*/
|
|
285
|
-
export declare const SHELL_PX = 1280;
|
|
291
|
+
export declare const SMALL_MAX_PX = 540;
|
|
286
292
|
/** Options the stack needs from its shell. */
|
|
287
293
|
export interface PanelStackOptions {
|
|
288
294
|
routes: Routes;
|
|
@@ -350,10 +356,10 @@ export interface PanelStack {
|
|
|
350
356
|
* the new panel).
|
|
351
357
|
*
|
|
352
358
|
* The same rules as a link click apply: pushing a path that is already open
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
359
|
+
* returns to it — closing whatever was stacked on top — rather than opening
|
|
360
|
+
* it twice, and a panel holding {@link Panel.unsaved} work is never closed,
|
|
361
|
+
* only parked. That's what a plain link does, and what `data-panel=push`
|
|
362
|
+
* says outright.
|
|
357
363
|
*
|
|
358
364
|
* Note that a link builds on the panel it is *drawn in*, which is the
|
|
359
365
|
* current panel only while no column beside it has the focus. Code
|
|
@@ -455,8 +461,8 @@ export declare class PanelStackController implements PanelStack {
|
|
|
455
461
|
private containerEl?;
|
|
456
462
|
/** The shell's measurements, shared by everything drawn since they were taken. */
|
|
457
463
|
private geom?;
|
|
458
|
-
/** The
|
|
459
|
-
private
|
|
464
|
+
/** The measurements the last layout ran on; a change in them → snap. */
|
|
465
|
+
private lastGeom?;
|
|
460
466
|
private layoutQueued;
|
|
461
467
|
private timers;
|
|
462
468
|
/** The arrangement the navigation in flight is heading for; see {@link intended}. */
|
|
@@ -588,19 +594,21 @@ export declare class PanelStackController implements PanelStack {
|
|
|
588
594
|
private issue;
|
|
589
595
|
private start;
|
|
590
596
|
/**
|
|
591
|
-
* Make the stack's `index`th panel current
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
*
|
|
597
|
+
* Make the stack's `index`th panel current without closing anything, leaving
|
|
598
|
+
* the panels right of it parked out of sight.
|
|
599
|
+
*
|
|
600
|
+
* Only ever a step around a panel that refuses to close — nothing else is
|
|
601
|
+
* left sitting after the current one — so this is Escape's way past an
|
|
602
|
+
* unsaved panel, and the way back to one. It is a history entry, so the
|
|
603
|
+
* browser's back button returns the focus to where it was.
|
|
596
604
|
*/
|
|
597
605
|
private focusAt;
|
|
598
606
|
/**
|
|
599
607
|
* One step back along the stack — what Escape does (`main()` calls this;
|
|
600
|
-
* it is not {@link PanelStack} API).
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
608
|
+
* it is not {@link PanelStack} API). Normally that closes the current panel,
|
|
609
|
+
* which is the stack's end. When it holds {@link Panel.unsaved} work — or
|
|
610
|
+
* panels sit parked beyond it — it stays open instead, and the focus
|
|
611
|
+
* simply moves to the panel on its left.
|
|
604
612
|
* Resolves `false` at the stack's start, where there is no left to go.
|
|
605
613
|
*/
|
|
606
614
|
back(): Promise<boolean>;
|
|
@@ -636,11 +644,14 @@ export declare class PanelStackController implements PanelStack {
|
|
|
636
644
|
* that know it.
|
|
637
645
|
*
|
|
638
646
|
* `how` is the link's `data-panel` attribute (or the caller's word for
|
|
639
|
-
* it)
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
* `"open"`
|
|
643
|
-
*
|
|
647
|
+
* it), picking how much of `from`'s context the target keeps: a push (the
|
|
648
|
+
* default, and what unrecognised values fall back to) keeps `from` and
|
|
649
|
+
* builds on it, `"replace"` keeps only what is beneath `from`, and
|
|
650
|
+
* `"open"` keeps nothing — the target arrives with its own stack, the way
|
|
651
|
+
* a nav item's link does. Absent, it is the shell's `linkNavigation`
|
|
652
|
+
* default, like a link without the attribute. A target that is already
|
|
653
|
+
* open is returned to by a push, and *moved* — alive, state intact — by
|
|
654
|
+
* the other two: the stack never holds a path twice.
|
|
644
655
|
*
|
|
645
656
|
* Resolves the way every {@link PanelStack} method does: `true` once the
|
|
646
657
|
* navigation lands, `false` when it doesn't (already there counts as
|
|
@@ -677,11 +688,11 @@ export declare class PanelStackController implements PanelStack {
|
|
|
677
688
|
* The breadcrumb stack, drawn by `main()` into the top bar: every open
|
|
678
689
|
* panel, oldest first, the ones on screen right now in bold, pinned ones
|
|
679
690
|
* wearing their pin. Every crumb but the current panel's is a plain link to
|
|
680
|
-
* that panel, and a link to an open panel
|
|
681
|
-
* so clicking
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
*
|
|
691
|
+
* that panel, and a link to an open panel returns to it (see `navigate`) —
|
|
692
|
+
* so clicking a crumb goes back to that panel and closes what was stacked on
|
|
693
|
+
* top of it, pinned and unsaved panels excepted. Right-click (or long-press)
|
|
694
|
+
* offers pinning, and closing just that one panel — the close that splices
|
|
695
|
+
* it out of the middle when it isn't last.
|
|
685
696
|
*/
|
|
686
697
|
drawCrumbs(): void;
|
|
687
698
|
private drawCrumb;
|
|
@@ -700,9 +711,9 @@ export declare class PanelStackController implements PanelStack {
|
|
|
700
711
|
private watchTitle;
|
|
701
712
|
/**
|
|
702
713
|
* While any open panel holds unsaved work, closing the tab — or navigating
|
|
703
|
-
* the whole browser away — runs into the browser's own are-you-sure
|
|
704
|
-
* the
|
|
705
|
-
*
|
|
714
|
+
* the whole browser away — runs into the browser's own are-you-sure, with
|
|
715
|
+
* the unsaved panel brought on screen as the question is raised, so what is
|
|
716
|
+
* holding the tab is in front of the user rather than parked out of sight.
|
|
706
717
|
*/
|
|
707
718
|
private guardTabClose;
|
|
708
719
|
/**
|
|
@@ -724,11 +735,24 @@ export declare class PanelStackController implements PanelStack {
|
|
|
724
735
|
private drawActions;
|
|
725
736
|
scheduleLayout(): void;
|
|
726
737
|
/**
|
|
727
|
-
* Measure the
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
738
|
+
* Measure the content area, and with it the width a panel of each size gets.
|
|
739
|
+
*
|
|
740
|
+
* The column region *is* the content area: it takes whatever the shell has
|
|
741
|
+
* left beside the sidebar, capped by the shell's own `maxWidth` — all of it
|
|
742
|
+
* CSS's doing, so there is nothing to add up here and nothing that could
|
|
743
|
+
* drift from the width the bars above and below line up with. Fractional
|
|
744
|
+
* widths throughout: a rounded column edge would drift a pixel away from that
|
|
745
|
+
* chrome.
|
|
746
|
+
*
|
|
747
|
+
* The area divides into the narrowest whole number of columns that keeps each
|
|
748
|
+
* at least {@link SMALL_MIN_PX} wide — the `"small"` unit every other size is
|
|
749
|
+
* a multiple of, capped at the area itself. So 1080px is three columns of 360
|
|
750
|
+
* and 1520px four of 380. An area too narrow for two is a single column,
|
|
751
|
+
* itself capped at {@link SMALL_MAX_PX}: a small centres there instead of
|
|
752
|
+
* stretching toward 720, so its ceiling holds, while the larger sizes still
|
|
753
|
+
* take the whole area. A width is thus a pure function of the window: a panel
|
|
754
|
+
* NEVER resizes because a neighbour came or went, and only a window resize
|
|
755
|
+
* (the snap pass in `layout`) changes one.
|
|
732
756
|
*
|
|
733
757
|
* `undefined` while the shell has no width to speak of (it isn't in a document
|
|
734
758
|
* yet, or it's `display:none`); the next pass tries again.
|
|
@@ -744,8 +768,7 @@ export declare class PanelStackController implements PanelStack {
|
|
|
744
768
|
/** How wide a panel asking for this is, right now; 0 while the shell can't be measured. */
|
|
745
769
|
private roomFor;
|
|
746
770
|
/**
|
|
747
|
-
* Size and position every panel
|
|
748
|
-
* (sidebar + separator + columns) for the shell to centre itself on.
|
|
771
|
+
* Size and position every panel.
|
|
749
772
|
*
|
|
750
773
|
* This is everything CSS can't work out for itself: which panels exist, which
|
|
751
774
|
* of them are visible, how wide each one is and where it sits. All the motion
|