@taprootio/espalier 2.10.0 → 2.12.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.
@@ -3,6 +3,23 @@ import { EspalierElementBase } from "../shared/esp-element-base.js";
3
3
  import { type EspalierDialog } from "../dialog/esp-dialog.js";
4
4
  import "../toaster/esp-toaster.js";
5
5
  type HeaderPosition = "normal" | "sticky" | "fixed";
6
+ export type PageWorkspaceSeparator = "main-preview" | "preview-flyout" | "main-flyout";
7
+ export type PageWorkspaceResizeSource = "keyboard" | "pointer";
8
+ /** Detail emitted while an `esp-page` workspace separator changes pane sizes. */
9
+ export interface PageWorkspaceResizeDetail {
10
+ /**
11
+ * Separator that initiated the resize. The second physical seam reports
12
+ * `"preview-flyout"` while preview is visible and `"main-flyout"` when it
13
+ * sits directly between main and help because preview is hidden or closed.
14
+ */
15
+ separator: PageWorkspaceSeparator;
16
+ /** Input modality that initiated the resize. */
17
+ source: PageWorkspaceResizeSource;
18
+ /** Currently allocated preview width in CSS pixels, or zero while preview is hidden. */
19
+ previewWidth: number;
20
+ /** Currently allocated in-grid flyout/help width in CSS pixels, or zero when closed. */
21
+ flyoutWidth: number;
22
+ }
6
23
  /**
7
24
  * Used to lay out standard page structure.
8
25
  *
@@ -32,38 +49,34 @@ type HeaderPosition = "normal" | "sticky" | "fixed";
32
49
  * </esp-page>
33
50
  * ```
34
51
  *
35
- * A persistent preview uses spare trailing canvas first. Set a main-well
36
- * floor to let it reclaim surface width, and opt into collapsing a directly
37
- * paired header/sidebar navigation to its accessible burger/drawer mode:
38
- *
39
- * ```html
40
- * <esp-page
41
- * preview-open
42
- * preview-collapse-sidebar
43
- * style="--esp-page-preview-width: 20rem; --esp-page-preview-min-main-width: 900px;"
44
- * >
45
- * <esp-header slot="header" drawer-target="site-nav"></esp-header>
46
- * <esp-menu id="site-nav" slot="sidebar" mode="vertical"></esp-menu>
47
- * <article>Primary content</article>
48
- * <aside slot="preview">Preview content</aside>
49
- * </esp-page>
50
- * ```
52
+ * The authoring workspace is ordered main, preview, then help. Each region
53
+ * negotiates between public minimum and maximum widths; preview grows first,
54
+ * then help. Set `workspace-resizable` to expose accessible drag and keyboard
55
+ * separators on the dotted seams. Preferred pane sizes remain attached to the
56
+ * mounted page instance and are re-clamped by the same allocator whenever the
57
+ * available inline size changes. Opt into collapsing a directly paired
58
+ * header/sidebar navigation to its accessible burger/drawer mode when the
59
+ * combined workspace needs it.
51
60
  *
52
61
  * @slot sidebar - Contextual navigation placed in the left aside.
53
62
  * @slot right - Content to place in the right aside.
54
- * @slot preview - Persistent preview content that uses spare right canvas
55
- * width first, then optionally reclaims navigation and main-well width down
56
- * to `--esp-page-preview-min-main-width`. Unlike flyout content, preview
57
- * content is never replaced by the flyout request bus.
63
+ * @slot preview - Persistent preview content placed after the main surface and
64
+ * before help. It grows from `--esp-page-preview-min-width` to
65
+ * `--esp-page-preview-max-width`, starts at viewport top, and gives its content
66
+ * an independent `100dvh` vertical scroller. At either scroll boundary, wheel
67
+ * and trackpad motion chains back to the main document. Unlike flyout content,
68
+ * preview content is never replaced by the flyout request bus.
58
69
  * @slot flyout - A transient `esp-flyout` panel that lives on the
59
- * canvas, outside the content surface. Closed it costs no width; open
60
- * it claims the right canvas gutter first — the surface keeps its
61
- * alignment weighting and shifts only as far as the flyout's width
62
- * requires then docks as a width-competing right sidebar when no
63
- * gutter exists, and becomes an overlay drawer on small viewports.
70
+ * canvas after preview. Closed it costs no width; open it grows from
71
+ * `--esp-page-flyout-min-width` to `--esp-page-flyout-max-width` after preview
72
+ * receives flexible space, then docks as a width-competing right sidebar when
73
+ * no gutter exists, and becomes an overlay drawer on small viewports.
64
74
  * The persistent `right` aside and the transient flyout are
65
75
  * complementary, not alternatives. A flyout opened with an `anchor`
66
- * aligns to that trigger and stays in the same document scroll flow.
76
+ * aligns to that trigger and stays in the same document scroll flow. When a
77
+ * preview is visible, its caret and non-interactive dotted bridge cross the
78
+ * preview back to the anchor, ending at a short thick marker on the
79
+ * preview/help seam.
67
80
  * @slot footer - Content to place in the footer. Slot `esp-footer` directly
68
81
  * to receive the page's surface-alignment custom-property contract. A wrapper
69
82
  * can preserve landmark semantics but does not receive that direct contract.
@@ -73,6 +86,12 @@ type HeaderPosition = "normal" | "sticky" | "fixed";
73
86
  * slotted children are constrained to `max-inline-size: 66ch`
74
87
  * for optimal reading measure.
75
88
  *
89
+ * @event {CustomEvent<PageWorkspaceResizeDetail>} esp-page-workspace-resize -
90
+ * Fired while a pointer or keyboard interaction changes a preferred workspace
91
+ * allocation. `separator` is `"main-preview"`, `"preview-flyout"`, or
92
+ * `"main-flyout"` (the second seam without a visible preview). Bubbles and
93
+ * crosses the shadow boundary.
94
+ *
76
95
  * ```html
77
96
  * <esp-page class="docs">
78
97
  * <esp-header slot="header">
@@ -131,10 +150,13 @@ type HeaderPosition = "normal" | "sticky" | "fixed";
131
150
  * @cssprop --esp-page-background - The background color of the page. Fills
132
151
  * both the surface and the canvas gutters; the canvas tokens paint over it
133
152
  * in the gutters only. Defaults to `var(--esp-color-background)`.
134
- * @cssprop --esp-page-max-width - The maximum width of the main content
135
- * well. Set automatically by the `kind` attribute: `1536px` (wide),
136
- * `768px` (narrow), or `none` (full). This cap now sizes the main grid
137
- * track; surplus width beyond it becomes the canvas gutters.
153
+ * @cssprop --esp-page-main-min-width - Minimum width of the main content well
154
+ * while preview or in-grid help competes for space. Defaults to `30rem`.
155
+ * @cssprop --esp-page-main-max-width - Maximum width of the main content well.
156
+ * Defaults from `kind`: `1536px` (wide), `768px` (narrow), or unbounded (full).
157
+ * Surplus width beyond it becomes canvas gutters.
158
+ * @cssprop --esp-page-max-width - Legacy fallback for
159
+ * `--esp-page-main-max-width`.
138
160
  * @cssprop --esp-page-background-image - The background image to
139
161
  * display behind page content. Defaults to `none`.
140
162
  * @cssprop --esp-page-background-image-opacity - The opacity of the
@@ -162,14 +184,37 @@ type HeaderPosition = "normal" | "sticky" | "fixed";
162
184
  * background). Set it to give the content well its own card color, or
163
185
  * pair the transparent default with `--esp-page-surface-shadow: none`
164
186
  * for content that floats directly on the page with no frame.
165
- * @cssprop --esp-page-flyout-width - The width of the open flyout
166
- * track (and of the `esp-flyout` overlay drawer). Defaults to `20rem`.
167
- * @cssprop --esp-page-preview-width - Width of the persistent preview
168
- * panel. Defaults to `20rem`.
169
- * @cssprop --esp-page-preview-min-main-width - Optional minimum width of
170
- * the main content well while preview is reclaiming canvas/surface space.
171
- * Unset by default, so preview uses spare canvas only. Set a length such
172
- * as `900px` to opt into reclaim behavior.
187
+ * @cssprop --esp-page-preview-background - Background of the persistent
188
+ * preview surface. Defaults to the main background, then the page background.
189
+ * @cssprop --esp-page-preview-border - Leading tear-off edge between main and
190
+ * preview. Defaults to `1px dotted var(--esp-color-border)`.
191
+ * @cssprop --esp-page-preview-shadow - Shadow cast from the preview's trailing
192
+ * edge. Defaults to the page surface edge shadow. Set to `none` for a flat
193
+ * additive surface.
194
+ * @cssprop --esp-page-preview-min-width - Minimum preview width. Defaults to
195
+ * `22.5rem` (360px, a reasonable mobile-device surface).
196
+ * @cssprop --esp-page-preview-max-width - Maximum preview width. Defaults to
197
+ * `48rem`. Preview receives flexible trailing space before help grows.
198
+ * @cssprop --esp-page-flyout-min-width - Minimum in-grid help width. Defaults
199
+ * to `20rem`.
200
+ * @cssprop --esp-page-flyout-max-width - Maximum help width and overlay drawer
201
+ * cap before the `85vw` viewport cap. Defaults to `30rem`.
202
+ * @cssprop --esp-page-resize-step - Arrow-key resize step. Defaults to `1rem`.
203
+ * @cssprop --esp-page-resize-large-step - Shift+Arrow resize step. Defaults to
204
+ * `4rem`.
205
+ * @cssprop --esp-page-resize-handle-hit-size - Transparent inline hit target
206
+ * centered on each dotted seam. Defaults to `2.75rem`.
207
+ * @cssprop --esp-page-resize-focus-outline - Keyboard-focus line drawn along
208
+ * the focused seam, spanning the visible dotted edge up to one viewport
209
+ * height. Defaults to `2px dashed var(--esp-color-link)`.
210
+ * @cssprop --esp-page-resize-focus-shadow - Glow cast by the focused seam
211
+ * line, in the line's color. Defaults to `0 0 0.75rem var(--esp-color-link)`.
212
+ * @cssprop --esp-page-preview-width - Legacy fixed-width alias that pins both
213
+ * preview bounds.
214
+ * @cssprop --esp-page-flyout-width - Legacy fixed-width alias that pins both
215
+ * help bounds.
216
+ * @cssprop --esp-page-preview-min-main-width - Legacy fallback for
217
+ * `--esp-page-main-min-width`.
173
218
  * @cssprop --esp-page-fixed-header-offset - Offset reserved for fixed
174
219
  * headers. Defaults to `var(--esp-header-height)`.
175
220
  * @cssprop --esp-page-sticky-header-top - Top inset for sticky headers.
@@ -181,6 +226,13 @@ type HeaderPosition = "normal" | "sticky" | "fixed";
181
226
  * @csspart surface - The surface backdrop carrying the edge shadow/border.
182
227
  * @csspart preview - The persistent preview complementary landmark.
183
228
  * @csspart preview-content - The sticky wrapper around preview content.
229
+ * @csspart main-preview-resize-handle - Separator between main and preview.
230
+ * Announces main's width.
231
+ * @csspart preview-flyout-resize-handle - Separator between preview and
232
+ * in-grid flyout/help while preview is visible. Announces help's width.
233
+ * @csspart main-flyout-resize-handle - The same physical seam while preview
234
+ * is hidden or closed: it then sits between main and in-grid help, sizes
235
+ * help directly against main, and reports `separator: "main-flyout"`.
184
236
  *
185
237
  * ```html
186
238
  * <style>
@@ -230,6 +282,128 @@ type HeaderPosition = "normal" | "sticky" | "fixed";
230
282
  * @menuLabel Page
231
283
  * @menuIcon layout
232
284
  *
285
+ *
286
+ * @example Resizable preview
287
+ * ```html
288
+ * <style>
289
+ * .page-preview-resize-demo {
290
+ * --esp-page-main-min-width: 100px;
291
+ * --esp-page-main-max-width: 100vw;
292
+ * --esp-page-preview-min-width: 100px;
293
+ * --esp-page-preview-max-width: 100vw;
294
+ * }
295
+ *
296
+ * .page-preview-resize-demo > main,
297
+ * .page-preview-resize-demo > [slot="preview"] {
298
+ * box-sizing: border-box;
299
+ * padding: var(--esp-size-padding-page);
300
+ * }
301
+ * </style>
302
+ *
303
+ * <esp-page
304
+ * class="page-preview-resize-demo"
305
+ * preview-open
306
+ * preview-label="Article preview"
307
+ * workspace-resizable
308
+ * >
309
+ * <main>
310
+ * <h2>Article editor</h2>
311
+ * <p>
312
+ * Preview starts at its minimum width. Drag the dotted seam left to
313
+ * enlarge it, then resize in either direction. You can also focus the
314
+ * seam and use Left/Right Arrow.
315
+ * </p>
316
+ * </main>
317
+ * <article slot="preview">
318
+ * <h2>Article preview</h2>
319
+ * <p>The selected width stays with this mounted page and adapts when its container changes.</p>
320
+ * </article>
321
+ * </esp-page>
322
+ * ```
323
+ *
324
+ * @example Main, preview, and contextual help
325
+ * ```html
326
+ * <style>
327
+ * .page-workspace-demo {
328
+ * --esp-page-main-min-width: 100px;
329
+ * --esp-page-main-max-width: 100vw;
330
+ * --esp-page-preview-min-width: 100px;
331
+ * --esp-page-preview-max-width: 100vw;
332
+ * --esp-page-flyout-min-width: 100px;
333
+ * --esp-page-flyout-max-width: 100vw;
334
+ * }
335
+ *
336
+ * .page-workspace-demo > main,
337
+ * .page-workspace-demo > [slot="preview"] {
338
+ * box-sizing: border-box;
339
+ * padding: var(--esp-size-padding-page);
340
+ * }
341
+ *
342
+ * .page-workspace-demo > main {
343
+ * min-block-size: 120vh;
344
+ * }
345
+ * </style>
346
+ *
347
+ * <esp-page
348
+ * id="page-workspace-demo"
349
+ * class="page-workspace-demo"
350
+ * preview-open
351
+ * preview-label="Rendered page preview"
352
+ * workspace-resizable
353
+ * >
354
+ * <main>
355
+ * <h2>Page details</h2>
356
+ * <esp-form-item label="Site title">
357
+ * <esp-input id="page-workspace-title" name="title" value="Field notes"></esp-input>
358
+ * </esp-form-item>
359
+ * <p>
360
+ * Help is anchored to the title field in this main editor. Its caret and
361
+ * dotted connector cross the persistent preview without blocking it.
362
+ * Both dotted pane seams are resize handles while their panes are in-grid.
363
+ * </p>
364
+ * <esp-button id="page-workspace-preview-toggle" label="Toggle preview"></esp-button>
365
+ * <esp-button id="page-workspace-help-toggle" label="Toggle title help"></esp-button>
366
+ * </main>
367
+ *
368
+ * <article slot="preview">
369
+ * <h2>Field notes</h2>
370
+ * <p>This preview is a full-viewport secondary surface with its own scroller.</p>
371
+ * </article>
372
+ *
373
+ * <esp-flyout
374
+ * id="page-workspace-help"
375
+ * slot="flyout"
376
+ * heading="Site title help"
377
+ * standalone
378
+ * >
379
+ * <p>Use a short, recognizable title. It appears in navigation and browser tabs.</p>
380
+ * </esp-flyout>
381
+ * </esp-page>
382
+ *
383
+ * <script>
384
+ * const page = findById("page-workspace-demo");
385
+ * const title = findById("page-workspace-title");
386
+ * const help = findById("page-workspace-help");
387
+ * help.anchor = title;
388
+ *
389
+ * const syncMainWidth = () => {
390
+ * page.kind = page.previewOpen || help.open ? "wide" : "full";
391
+ * };
392
+ *
393
+ * findById("page-workspace-preview-toggle").addEventListener("clicked", () => {
394
+ * page.togglePreview();
395
+ * syncMainWidth();
396
+ * });
397
+ * findById("page-workspace-help-toggle").addEventListener("clicked", () => {
398
+ * help.anchor = title;
399
+ * help.toggle();
400
+ * syncMainWidth();
401
+ * });
402
+ * help.addEventListener("flyout-opened", syncMainWidth);
403
+ * help.addEventListener("flyout-closed", syncMainWidth);
404
+ * syncMainWidth();
405
+ * </script>
406
+ * ```
233
407
  */
234
408
  export declare class EspalierPage extends EspalierElementBase {
235
409
  constructor();
@@ -308,6 +482,12 @@ export declare class EspalierPage extends EspalierElementBase {
308
482
  * collapse to its burger/drawer presentation when preview needs more room.
309
483
  */
310
484
  previewCollapseSidebar: boolean;
485
+ /**
486
+ * Expose accessible pointer and keyboard separators for the visible
487
+ * Main → Preview → Flyout/Help workspace seams. Preferred sizes remain on
488
+ * this mounted instance and are continuously re-clamped by page allocation.
489
+ */
490
+ workspaceResizable: boolean;
311
491
  /**
312
492
  * Whether preview content is currently rendered. Managed by the page's
313
493
  * space negotiation; consumers should treat this reflected property as read-only.
@@ -315,7 +495,7 @@ export declare class EspalierPage extends EspalierElementBase {
315
495
  previewVisible: boolean;
316
496
  /**
317
497
  * Whether preview is currently reserving width and allowing the main well
318
- * to shrink toward `--esp-page-preview-min-main-width`. Managed by the page.
498
+ * to shrink toward `--esp-page-main-min-width`. Managed by the page.
319
499
  */
320
500
  previewReclaiming: boolean;
321
501
  /** Request the persistent preview without moving focus. */