staffa 0.22.2 → 0.23.1
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 +2 -2
- package/dist/components/autocomplete.js +7 -2
- package/dist/components/main.d.ts +23 -1
- package/dist/components/main.js +59 -3
- package/dist/components/panels.d.ts +13 -0
- package/dist/components/panels.js +21 -8
- package/dist/components/textarea.js +11 -4
- package/dist/index.d.ts +1 -1
- package/dist/staffa.esm.js +1 -1
- package/package.json +2 -1
- package/skill/MainOptions.md +26 -0
- package/skill/Panel.md +4 -0
- package/skill/SKILL.md +9 -2
- package/src/components/autocomplete.ts +8 -2
- package/src/components/main.ts +79 -4
- package/src/components/panels.ts +33 -8
- package/src/components/textarea.ts +10 -4
- package/src/index.ts +1 -1
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ Each handler gets a `$panel` proxy: the params from its route, plus what the she
|
|
|
164
164
|
|
|
165
165
|
**The stack is an object, not a global.** `S.main()` hands back the `PanelStack` — `pushPanel`, `replacePanel`, `openPanelStack`, `closePanel`, and the live, reactive `panels` / `currentPanel` / `currentPanelIndex` — and every panel gets that same object as `$panel.stack`, which is what a route handler uses, since it runs while the `S.main()` call is still going. Every navigation settles asynchronously (closes travel through the browser's history), so each method returns a `Promise<boolean>`. Don't hold a `Panel` across a navigation; read it fresh. To navigate on behalf of one particular screen — a row's click handler — use that panel's own `$panel.open(href, how?)`, which does exactly what a link inside it does; `pushPanel` builds on the *current* panel instead.
|
|
166
166
|
|
|
167
|
-
**Columns and widths.** The content area is the window minus the nav sidebar, or `S.main({ maxWidth })` of it, centred — the same width whatever is open, so the sidebar, top bar and footer never move. It divides into the fewest whole number of columns of at most **540px** each, never narrower than **360px**; `$panel.maxWidth` asks for one, two (the default), three of them or the lot. A column's width depends only on the window, never on what else is open, so opening or closing a panel never resizes another. Its ask is a ceiling, never a floor: aim your layout at 360px and let it degrade gracefully below that. `$panel.width` is the resolved figure in pixels, correct before your handler draws.
|
|
167
|
+
**Columns and widths.** The content area is the window minus the nav sidebar, or `S.main({ maxWidth })` of it, centred — the same width whatever is open, so the sidebar, top bar and footer never move. It divides into the fewest whole number of columns of at most **540px** each, never narrower than **360px**; `$panel.maxWidth` asks for one, two (the default), three of them or the lot. A column's width depends only on the window, never on what else is open, so opening or closing a panel never resizes another. Its ask is a ceiling, never a floor: aim your layout at 360px and let it degrade gracefully below that. `$panel.width` is the resolved figure in pixels, correct before your handler draws. Columns that don't fill the area centre in it; `S.main({ alignment })` puts them `"left"`, `"right"` or `"spaced"` (the leftover room shared out evenly beside and between them) instead.
|
|
168
168
|
|
|
169
169
|
**A panel declares its chrome; the shell places it.** A screen says what it is called and what it can do; everything else in its column — headings, cards, boxes — is the screen's own content, drawn like any other.
|
|
170
170
|
|
|
@@ -215,7 +215,7 @@ Return the paths shallowest first, or nothing to fall back to the parent-path wa
|
|
|
215
215
|
|
|
216
216
|
- Search params and the `#hash` belong to the current panel only; anything another panel needs in order to redraw itself has to live in its path. (A panel you browse away from does get its search and hash back when a crumb makes it current again.)
|
|
217
217
|
- A closed panel is torn down at once: its `A.clean()` hooks run the moment it closes, so subscriptions, timers and requests stop there and then.
|
|
218
|
-
- `columns: "single"` shows only the current panel however wide the screen — only the display changes. It, `linkNavigation` and `maxWidth` are live: pass a proxied options object and a change is adopted in place, every panel keeping its state.
|
|
218
|
+
- `columns: "single"` shows only the current panel however wide the screen — only the display changes. It, `alignment`, `linkNavigation` and `maxWidth` are live: pass a proxied options object and a change is adopted in place, every panel keeping its state.
|
|
219
219
|
- Only one routed `S.main()` can be mounted at a time; a second one throws, since the URL is global. Nothing else is.
|
|
220
220
|
- Aberdeen's own `route.go()` works, but builds the whole stack from the path; prefer the stack's methods. A guard your app registered with `route.setGuard` keeps working — Staffa registers none of its own.
|
|
221
221
|
- Deep links need your static server to serve the app for unknown paths (the usual SPA fallback; `-P` for `http-server`, as in the demo command below).
|
|
@@ -306,11 +306,11 @@ export function autocomplete(opts) {
|
|
|
306
306
|
if (e.key === "ArrowDown") {
|
|
307
307
|
e.preventDefault();
|
|
308
308
|
$st.open = true;
|
|
309
|
-
|
|
309
|
+
moveTo(Math.min(max, $st.active + 1));
|
|
310
310
|
}
|
|
311
311
|
else if (e.key === "ArrowUp") {
|
|
312
312
|
e.preventDefault();
|
|
313
|
-
|
|
313
|
+
moveTo(Math.max(0, $st.active - 1));
|
|
314
314
|
}
|
|
315
315
|
else if (e.key === "Enter") {
|
|
316
316
|
// Always prevent default to avoid accidental form submission.
|
|
@@ -347,6 +347,11 @@ export function autocomplete(opts) {
|
|
|
347
347
|
remove(sel[sel.length - 1]);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
+
/** Highlight row `i`, scrolling the list to keep it in view. */
|
|
351
|
+
function moveTo(i) {
|
|
352
|
+
$st.active = i;
|
|
353
|
+
document.getElementById(`${menuId}-opt-${i}`)?.scrollIntoView({ block: "nearest" });
|
|
354
|
+
}
|
|
350
355
|
function onBlur() {
|
|
351
356
|
$st.open = false;
|
|
352
357
|
if (opts.multi) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Slot, type Attributes } from "../core.js";
|
|
2
2
|
import { type MenuOptions } from "./menu.js";
|
|
3
|
-
import { type PanelStack, type AncestorTable, type RouteHandler, type RouteTable, type Routes } from "./panels.js";
|
|
3
|
+
import { type PanelStack, type PanelAlignment, type AncestorTable, type RouteHandler, type RouteTable, type Routes } from "./panels.js";
|
|
4
4
|
/** Options for {@link main}. */
|
|
5
5
|
export interface MainOptions<R = Routes> {
|
|
6
6
|
/** Aberdeen attr/style string applied to the outermost shell element. */
|
|
@@ -190,6 +190,19 @@ export interface MainOptions<R = Routes> {
|
|
|
190
190
|
* state.
|
|
191
191
|
*/
|
|
192
192
|
columns?: "auto" | "single";
|
|
193
|
+
/**
|
|
194
|
+
* Where the open columns sit when they don't fill the content area — on a
|
|
195
|
+
* wide screen with a single small panel open, say. `"center"` (the default)
|
|
196
|
+
* splits the leftover room between both sides, `"left"` and `"right"` put it
|
|
197
|
+
* all on one side, and `"spaced"` shares it out evenly over the gutters
|
|
198
|
+
* beside *and between* the columns. Columns crowded out on the left take
|
|
199
|
+
* precedence: while there are any, the run hugs the left edge whatever this
|
|
200
|
+
* says. Routed mode only.
|
|
201
|
+
*
|
|
202
|
+
* Live, like {@link MainOptions.columns}: a change is adopted in one layout
|
|
203
|
+
* pass, every panel keeping its state.
|
|
204
|
+
*/
|
|
205
|
+
alignment?: PanelAlignment;
|
|
193
206
|
/**
|
|
194
207
|
* What a link *without* a `data-panel` attribute does — the per-link
|
|
195
208
|
* attribute always wins. The three keep less and less of the link's own
|
|
@@ -257,6 +270,15 @@ export interface MainOptions<R = Routes> {
|
|
|
257
270
|
* Live, like {@link MainOptions.maxWidth}.
|
|
258
271
|
*/
|
|
259
272
|
navWidth?: number;
|
|
273
|
+
/**
|
|
274
|
+
* Lets the user resize the nav sidebar by dragging the hairline between it
|
|
275
|
+
* and the content area, or with the arrow keys once it has focus. Defaults
|
|
276
|
+
* to `false`.
|
|
277
|
+
*
|
|
278
|
+
* A dragged width stands until {@link MainOptions.navWidth} changes, and
|
|
279
|
+
* stays between 120 px and half the shell.
|
|
280
|
+
*/
|
|
281
|
+
navResizable?: boolean;
|
|
260
282
|
/** Aberdeen attr/style string applied to the sidebar nav panel. */
|
|
261
283
|
navAttrs?: Attributes;
|
|
262
284
|
/** Aberdeen attr/style string applied to the narrow-screen full-page nav. */
|
package/dist/components/main.js
CHANGED
|
@@ -10,6 +10,8 @@ import { isDialogOpen } from "./dialog.js";
|
|
|
10
10
|
import { PAGE_MS, PanelStackController, SMALL_MAX_PX } from "./panels.js";
|
|
11
11
|
/** The default nav column, hairline included — see {@link MainOptions.navWidth}. */
|
|
12
12
|
const NAV_W = 200;
|
|
13
|
+
/** The narrowest a user can drag the nav column — see {@link MainOptions.navResizable}. */
|
|
14
|
+
const NAV_MIN_W = 120;
|
|
13
15
|
A.insertGlobalCss({
|
|
14
16
|
".s-main": {
|
|
15
17
|
// container-type so @container queries below can respond to shell width.
|
|
@@ -61,6 +63,12 @@ A.insertGlobalCss({
|
|
|
61
63
|
// A vertical hairline between sidebar and content, fading out at both ends —
|
|
62
64
|
// the vertical sibling of the menu's `hr.s-menu-sep`.
|
|
63
65
|
".s-nav-sep": "width:1px flex-shrink:0 align-self:stretch margin: 0.6rem 0; border:0 background: linear-gradient(to bottom, transparent, $s-faint 18%, $s-faint 82%, transparent);",
|
|
66
|
+
// A resizable one is a handle, its hit area widened beyond the hairline.
|
|
67
|
+
".s-nav-sep[role=separator]": {
|
|
68
|
+
"&": "cursor:col-resize position:relative z-index:1 touch-action:none",
|
|
69
|
+
"&::before": "content:'' position:absolute inset: -0.6rem -4px;",
|
|
70
|
+
"&:hover, &:active, &:focus-visible": "background:$s-accent",
|
|
71
|
+
},
|
|
64
72
|
// min-height/min-width:0 override flex's `auto`, so <main> can shrink to its
|
|
65
73
|
// container instead of letting wide content push the body — and any sidebar
|
|
66
74
|
// — past the viewport edge. The transition is dormant except for the
|
|
@@ -138,6 +146,9 @@ export function main(opts = {}) {
|
|
|
138
146
|
// Whether the narrow-screen full-page nav is showing. Per shell, so nested or
|
|
139
147
|
// sibling `main()`s can't fight over it.
|
|
140
148
|
const $nav = A.proxy({ open: false });
|
|
149
|
+
// The sidebar column's width: `navWidth`, until the user drags it elsewhere.
|
|
150
|
+
const $navW = A.proxy({ px: NAV_W });
|
|
151
|
+
A(() => { $navW.px = opts.navWidth ?? NAV_W; });
|
|
141
152
|
// Whether the shell is narrow, at the same NARROW_PX the `@container` queries
|
|
142
153
|
// above use. One boolean for everything that must agree on the regime — the
|
|
143
154
|
// bar's layout, what the ☰ does, where a panel's chrome goes — so they can't
|
|
@@ -166,6 +177,7 @@ export function main(opts = {}) {
|
|
|
166
177
|
// Live: each in its own scope, so a change on a proxied options object
|
|
167
178
|
// re-runs only that scope — the columns relayout in place, panels intact.
|
|
168
179
|
A(() => ctl.setColumns(opts.columns));
|
|
180
|
+
A(() => ctl.setAlignment(opts.alignment));
|
|
169
181
|
A(() => ctl.setLinkNavigation(opts.linkNavigation));
|
|
170
182
|
}
|
|
171
183
|
// Where the brand mark and the app's name link; nowhere under `home: null`.
|
|
@@ -183,7 +195,7 @@ export function main(opts = {}) {
|
|
|
183
195
|
if (nav == null || !nav.items.length)
|
|
184
196
|
A("--s-nav-w: 0px");
|
|
185
197
|
else
|
|
186
|
-
A(`.s-nav-${navPos}`, `--s-nav-w: ${
|
|
198
|
+
A(`.s-nav-${navPos}`, `--s-nav-w: ${$navW.px}px`);
|
|
187
199
|
});
|
|
188
200
|
// Top bar: `[leading] [identity] …spacer… [trailing]`, each slot's contents
|
|
189
201
|
// depending on the room available and on what the current panel declared.
|
|
@@ -242,8 +254,15 @@ export function main(opts = {}) {
|
|
|
242
254
|
// falling back to the app's chrome. Promoted actions are marked
|
|
243
255
|
// `.s-panel-origin`, so a link among them still builds on the
|
|
244
256
|
// current panel — see `interceptLinks` in panels.ts.
|
|
257
|
+
//
|
|
258
|
+
// Which slot wins is derived, so a panel swap that doesn't change
|
|
259
|
+
// the answer — neither screen declaring actions, the app's `menu`
|
|
260
|
+
// standing on both sides — leaves the slot's DOM alone. This is
|
|
261
|
+
// where an app puts its stateful chrome (`menu`'s search box), and
|
|
262
|
+
// rebuilding it would drop focus, caret and IME composition.
|
|
263
|
+
const $promoted = A.derive(() => ($shell.narrow ? ctl?.currentPanel?.actions : undefined));
|
|
245
264
|
A(() => {
|
|
246
|
-
const actions = $
|
|
265
|
+
const actions = $promoted.value;
|
|
247
266
|
const slot = actions ?? opts.menu;
|
|
248
267
|
if (slot != null)
|
|
249
268
|
A(`div.s-menu${actions != null ? ".s-panel-origin" : ""}`, () => drawSlot(slot));
|
|
@@ -264,7 +283,10 @@ export function main(opts = {}) {
|
|
|
264
283
|
A(`nav.s-nav-panel.s-nav-${navPos}`, opts.navAttrs, () => {
|
|
265
284
|
drawMenu(nav.items);
|
|
266
285
|
});
|
|
267
|
-
|
|
286
|
+
if (opts.navResizable)
|
|
287
|
+
drawNavHandle(navPos, $navW);
|
|
288
|
+
else
|
|
289
|
+
A("div.s-nav-sep aria-hidden=true");
|
|
268
290
|
});
|
|
269
291
|
drawMainContent(opts, ctl);
|
|
270
292
|
});
|
|
@@ -437,6 +459,40 @@ function drawNavTrigger(nav, $nav) {
|
|
|
437
459
|
click: () => { $nav.open = !$nav.open; },
|
|
438
460
|
});
|
|
439
461
|
}
|
|
462
|
+
/**
|
|
463
|
+
* The hairline between sidebar and content as a window splitter: dragging it, or
|
|
464
|
+
* pressing ←/→ while it has focus, sets `$navW.px` — the sidebar's whole column.
|
|
465
|
+
*/
|
|
466
|
+
function drawNavHandle(navPos, $navW) {
|
|
467
|
+
// Which way the sidebar grows: away from the shell edge it sits against.
|
|
468
|
+
const dir = navPos === "right" ? -1 : 1;
|
|
469
|
+
A("div.s-nav-sep role=separator aria-orientation=vertical aria-label='Resize navigation' tabindex=0", () => {
|
|
470
|
+
A(() => A("aria-valuenow=", $navW.px));
|
|
471
|
+
const handle = A();
|
|
472
|
+
const resize = (px) => {
|
|
473
|
+
const max = handle.parentElement.clientWidth / 2;
|
|
474
|
+
$navW.px = Math.round(Math.max(NAV_MIN_W, Math.min(max, px)));
|
|
475
|
+
};
|
|
476
|
+
A("pointerdown=", (e) => {
|
|
477
|
+
if (e.button !== 0)
|
|
478
|
+
return;
|
|
479
|
+
e.preventDefault();
|
|
480
|
+
const x0 = e.clientX;
|
|
481
|
+
const w0 = $navW.px;
|
|
482
|
+
const move = (e) => resize(w0 + dir * (e.clientX - x0));
|
|
483
|
+
handle.setPointerCapture(e.pointerId);
|
|
484
|
+
handle.addEventListener("pointermove", move);
|
|
485
|
+
handle.addEventListener("lostpointercapture", () => handle.removeEventListener("pointermove", move), { once: true });
|
|
486
|
+
});
|
|
487
|
+
A("keydown=", (e) => {
|
|
488
|
+
const step = e.key === "ArrowRight" ? 10 : e.key === "ArrowLeft" ? -10 : 0;
|
|
489
|
+
if (!step)
|
|
490
|
+
return;
|
|
491
|
+
e.preventDefault();
|
|
492
|
+
resize($navW.px + dir * step);
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
}
|
|
440
496
|
/**
|
|
441
497
|
* The narrow-screen navigation: a full panel sliding in over the content from
|
|
442
498
|
* the left. Picking an item slides it back out as the chosen screen enters from
|
|
@@ -84,6 +84,11 @@ export type AncestorTable<R> = {
|
|
|
84
84
|
* they all come to the same thing.
|
|
85
85
|
*/
|
|
86
86
|
export type PanelSize = "small" | "medium" | "large" | "none";
|
|
87
|
+
/**
|
|
88
|
+
* Where the open columns sit when they don't fill the content area; see
|
|
89
|
+
* {@link MainOptions.alignment}.
|
|
90
|
+
*/
|
|
91
|
+
export type PanelAlignment = "left" | "right" | "center" | "spaced";
|
|
87
92
|
/**
|
|
88
93
|
* What a route handler gets: the params from its route, plus everything the
|
|
89
94
|
* shell needs to know about the panel it is drawing. It's an Aberdeen proxy, so
|
|
@@ -135,6 +140,10 @@ export interface Panel<P = Record<string, string | number | string[]>> {
|
|
|
135
140
|
* They are drawn in exactly one of those places at a time, so crossing the
|
|
136
141
|
* threshold redraws them; anything stateful inside (the focus in a search
|
|
137
142
|
* box) is lost. Buttons and menus are fine.
|
|
143
|
+
*
|
|
144
|
+
* Assign one function and keep it: a fresh closure on every redraw of your
|
|
145
|
+
* handler is a new slot, so the shell redraws the actions — and on a narrow
|
|
146
|
+
* shell, where they sit in the top bar, the app's own chrome with them.
|
|
138
147
|
*/
|
|
139
148
|
actions?: Slot;
|
|
140
149
|
/**
|
|
@@ -303,6 +312,8 @@ export interface PanelStackOptions {
|
|
|
303
312
|
ancestors?: Record<string, AncestorsHandler | undefined>;
|
|
304
313
|
/** How many panels are shown at a time. See {@link MainOptions.columns}. */
|
|
305
314
|
columns?: "auto" | "single";
|
|
315
|
+
/** Where a short run of columns sits in the area. See {@link MainOptions.alignment}. */
|
|
316
|
+
alignment?: PanelAlignment;
|
|
306
317
|
/** What a bare link does. See {@link MainOptions.linkNavigation}. */
|
|
307
318
|
linkNavigation?: "push" | "replace" | "open";
|
|
308
319
|
/** The shell's own title, used as the suffix of `document.title`. */
|
|
@@ -639,6 +650,8 @@ export declare class PanelStackController implements PanelStack {
|
|
|
639
650
|
closePanel(path?: string): Promise<boolean>;
|
|
640
651
|
/** Adopt a changed `columns` setting: one layout pass, nothing redrawn. */
|
|
641
652
|
setColumns(columns: "auto" | "single" | undefined): void;
|
|
653
|
+
/** Adopt a changed `alignment`: one layout pass, nothing redrawn. */
|
|
654
|
+
setAlignment(alignment: PanelAlignment | undefined): void;
|
|
642
655
|
/** Adopt a changed `linkNavigation` default; the next click reads it. */
|
|
643
656
|
setLinkNavigation(mode: "push" | "replace" | "open" | undefined): void;
|
|
644
657
|
/**
|
|
@@ -167,7 +167,8 @@ A.insertGlobalCss({
|
|
|
167
167
|
`z-index:2 transition: transform ${PAGE_MS}ms ease-out, opacity ${PAGE_MS}ms linear;`,
|
|
168
168
|
// The hairline between two columns, fading at both ends (like the sidebar's
|
|
169
169
|
// `.s-nav-sep`). Columns tile with no gutter — each brings its own `$3` of
|
|
170
|
-
// padding — so this sits exactly on the boundary.
|
|
170
|
+
// padding — so this sits exactly on the boundary. A `"spaced"` alignment,
|
|
171
|
+
// which does put a gutter between them, leaves it off (see `layout`).
|
|
171
172
|
"&.s-panel-sep::before": "content:'' position:absolute left:0 top:0.6rem bottom:0.6rem width:1px z-index:1 " +
|
|
172
173
|
"background: linear-gradient(to bottom, transparent, $s-faint 18%, $s-faint 82%, transparent);",
|
|
173
174
|
// Still owed or playing its entry fade: beneath the settled panels, so
|
|
@@ -952,6 +953,13 @@ export class PanelStackController {
|
|
|
952
953
|
this.opts.columns = columns;
|
|
953
954
|
this.scheduleLayout();
|
|
954
955
|
}
|
|
956
|
+
/** Adopt a changed `alignment`: one layout pass, nothing redrawn. */
|
|
957
|
+
setAlignment(alignment) {
|
|
958
|
+
if (this.opts.alignment === alignment)
|
|
959
|
+
return;
|
|
960
|
+
this.opts.alignment = alignment;
|
|
961
|
+
this.scheduleLayout();
|
|
962
|
+
}
|
|
955
963
|
/** Adopt a changed `linkNavigation` default; the next click reads it. */
|
|
956
964
|
setLinkNavigation(mode) {
|
|
957
965
|
this.opts.linkNavigation = mode;
|
|
@@ -1294,11 +1302,16 @@ export class PanelStackController {
|
|
|
1294
1302
|
first = i;
|
|
1295
1303
|
}
|
|
1296
1304
|
}
|
|
1297
|
-
// A run that doesn't fill the fixed-width area
|
|
1298
|
-
//
|
|
1299
|
-
//
|
|
1300
|
-
//
|
|
1301
|
-
|
|
1305
|
+
// A run that doesn't fill the fixed-width area is placed in it by the
|
|
1306
|
+
// shell's `alignment`, `"spaced"` sharing the slack out over the gutters
|
|
1307
|
+
// around and between the columns. Unless panels sit crowded out on the
|
|
1308
|
+
// run's left: then it hugs the left edge, so the strip crosses that edge
|
|
1309
|
+
// with no gap, a reveal is a plain slide back in, and no gutter lets a
|
|
1310
|
+
// crowded-out panel peek through.
|
|
1311
|
+
const slack = first > 0 ? 0 : geom.area - runSum;
|
|
1312
|
+
const align = this.opts.alignment ?? "center";
|
|
1313
|
+
const gap = align === "spaced" ? slack / (cur - first + 2) : 0;
|
|
1314
|
+
const left = align === "left" ? 0 : align === "right" ? slack : align === "spaced" ? gap : slack / 2;
|
|
1302
1315
|
for (let i = first; i <= cur; i++)
|
|
1303
1316
|
live[i].width = width(live[i]);
|
|
1304
1317
|
// Never-visible panels get their would-be width, so a reveal doesn't start
|
|
@@ -1378,14 +1391,14 @@ export class PanelStackController {
|
|
|
1378
1391
|
}
|
|
1379
1392
|
}
|
|
1380
1393
|
el.style.width = `${entry.width}px`;
|
|
1381
|
-
x += entry.width;
|
|
1394
|
+
x += entry.width + gap;
|
|
1382
1395
|
// Written only on a change, so per-panel UI hanging off `visible` or
|
|
1383
1396
|
// `width` isn't rebuilt by every pass.
|
|
1384
1397
|
if (entry.$panel.visible !== shown)
|
|
1385
1398
|
entry.$panel.visible = shown;
|
|
1386
1399
|
if (entry.$panel.width !== entry.width)
|
|
1387
1400
|
entry.$panel.width = entry.width;
|
|
1388
|
-
el.classList.toggle("s-panel-sep", shown && i > first);
|
|
1401
|
+
el.classList.toggle("s-panel-sep", shown && i > first && !gap);
|
|
1389
1402
|
// Off-screen panels stop rendering, keeping their DOM. A revealed
|
|
1390
1403
|
// panel is visible at once; one sliding offstage stays visible for
|
|
1391
1404
|
// the whole slide, its visibility class deferred to the slide's
|
|
@@ -10,9 +10,9 @@ A.insertGlobalCss({
|
|
|
10
10
|
// a prefix/suffix gives it one.
|
|
11
11
|
"textarea.s-input, .s-inset.s-inset-bottom": "flex: 0 1 100%; min-height:0",
|
|
12
12
|
"textarea.s-input": "resize:vertical min-height:3em line-height:1.45",
|
|
13
|
-
// Sized to its text there is nothing to scroll
|
|
14
|
-
// a caller caps the height (`inputAttrs: "max-height:12em"`)
|
|
15
|
-
"textarea.s-input.s-autoGrow": "resize:none min-height:2.5em overflow-y:
|
|
13
|
+
// Sized to its text there is nothing to scroll; `fitToContent` turns scrolling
|
|
14
|
+
// on once a caller caps the height (`inputAttrs: "max-height:12em"`).
|
|
15
|
+
"textarea.s-input.s-autoGrow": "resize:none min-height:2.5em overflow-y:hidden",
|
|
16
16
|
});
|
|
17
17
|
/**
|
|
18
18
|
* A multi-line text input. Shares the field chrome and styling of
|
|
@@ -78,8 +78,15 @@ export function textarea(opts = {}) {
|
|
|
78
78
|
}
|
|
79
79
|
function fitToContent(el) {
|
|
80
80
|
el.style.height = "auto";
|
|
81
|
+
// Measure without a scrollbar: one would narrow the text and wrap it early.
|
|
82
|
+
el.style.overflowY = "";
|
|
81
83
|
// `scrollHeight` measures the padding box, while the height we set sizes the
|
|
82
84
|
// border box: add the borders back, or the text ends up two pixels too tall
|
|
83
85
|
// for its box and the textarea scrolls by that much.
|
|
84
|
-
|
|
86
|
+
const height = el.scrollHeight + el.offsetHeight - el.clientHeight;
|
|
87
|
+
el.style.height = `${height}px`;
|
|
88
|
+
// Scroll only once a `max-height` caps the box: `scrollHeight` is rounded, so
|
|
89
|
+
// an uncapped box can fall a fraction of a pixel short and show a bar.
|
|
90
|
+
if (el.offsetHeight < height)
|
|
91
|
+
el.style.overflowY = "auto";
|
|
85
92
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export { buttonGroup, type ButtonGroupOptions } from "./components/buttonGroup.j
|
|
|
40
40
|
export { checkbox, type CheckboxOptions } from "./components/checkbox.js";
|
|
41
41
|
export { form, type FormOptions } from "./components/form.js";
|
|
42
42
|
export { main, closeNav, type MainOptions } from "./components/main.js";
|
|
43
|
-
export { type PanelStack, type Panel, type PanelSize, type Routes, type RouteHandler, type RouteTable, type AncestorsHandler, type AncestorTable, type PathParams, type SegParams } from "./components/panels.js";
|
|
43
|
+
export { type PanelStack, type Panel, type PanelSize, type PanelAlignment, type Routes, type RouteHandler, type RouteTable, type AncestorsHandler, type AncestorTable, type PathParams, type SegParams } from "./components/panels.js";
|
|
44
44
|
export { menu, menuButton, showFloatingMenu, addContextMenu, isFloatingMenuOpen, closeFloatingMenu, type MenuListOptions, type MenuOptions, type MenuEntry, type MenuItem, type MenuSeparator, type FloatingMenuOptions, type ContextMenuOptions } from "./components/menu.js";
|
|
45
45
|
export { dialog, alert, confirm, prompt, isDialogOpen, type DialogOptions } from "./components/dialog.js";
|
|
46
46
|
export { select, type SelectOptions, type SelectOptionInput } from "./components/select.js";
|