@sentropic/design-system-svelte 0.34.71 → 0.34.73

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.
@@ -6,6 +6,7 @@
6
6
  export type AppShellUtilityMode = "reserve" | "overlay" | "floating";
7
7
  export type AppShellUtilitySide = "left" | "right" | "bottom";
8
8
  export type AppShellPanelCollapse = "stack" | "accordion";
9
+ export type AppShellPanelKey = "navigationPanel" | "contextPanel" | "utilityPanel";
9
10
 
10
11
  export type AppShellProps = {
11
12
  variant?: AppShellVariant;
@@ -43,6 +44,18 @@
43
44
  contextPanelLabel?: string;
44
45
  /** Disclosure label for `utilityPanel` when `panelCollapse="accordion"`. Defaults to `utilityLabel`. */
45
46
  utilityPanelLabel?: string;
47
+ /** Enables drag-to-resize handles on side panels above 48rem. Default false — zero regression. */
48
+ panelResize?: boolean;
49
+ /** Controlled panel widths in px. When provided the component never mutates width itself. */
50
+ panelWidths?: Partial<Record<AppShellPanelKey, number>>;
51
+ /** Seeds uncontrolled widths in px. */
52
+ defaultPanelWidths?: Partial<Record<AppShellPanelKey, number>>;
53
+ /** Fired on every committed resize. Persistence is the CONSUMER's job — the DS stays presentational. */
54
+ onPanelResize?: (key: AppShellPanelKey, width: number) => void;
55
+ /** Lower clamp in px. Default 180. */
56
+ panelMinWidth?: number;
57
+ /** Upper clamp in px. Default 640. */
58
+ panelMaxWidth?: number;
46
59
  class?: string;
47
60
  };
48
61
  </script>
@@ -53,6 +66,7 @@
53
66
  // identité = DS IdentityMenu ; barre = DS Header. Le look vient donc des tokens DS
54
67
  // (--st-component-control-*) → pixel-cohérent avec le header de référence, et les
55
68
  // menus sont ceux du DS (fonctionnels). Piloté par `siteConfig`.
69
+ import { untrack } from "svelte";
56
70
  import Header from "./Header.svelte";
57
71
  import Button from "./Button.svelte";
58
72
  import IconButton from "./IconButton.svelte";
@@ -61,6 +75,31 @@
61
75
  import { Boxes, ChevronDown, Globe, Moon, Palette, Search as SearchIcon, Sun } from "@lucide/svelte";
62
76
  import IdentityButton from "./IdentityButton.svelte";
63
77
 
78
+ // CSS custom property each resizable panel is sized by (see the
79
+ // `.st-appShell` base rule in the style block below) — setting it inline
80
+ // on the shell root is the intended resize mechanism, it simply
81
+ // out-specificities the token-driven default declared there.
82
+ const PANEL_VAR: Record<AppShellPanelKey, string> = {
83
+ navigationPanel: "--st-appShell-navigation-width",
84
+ contextPanel: "--st-appShell-context-width",
85
+ utilityPanel: "--st-appShell-utility-width",
86
+ };
87
+
88
+ // Nominal px equivalent of each panel's own CSS-token default (navigation
89
+ // 20rem, context 22rem, utility 24rem, all at a 16px root) — used ONLY as a
90
+ // display/ARIA fallback (aria-valuenow, drag-start anchor) before any width
91
+ // has ever been supplied or committed. Never written back as an inline
92
+ // style, so a themed override of the underlying token is never fought
93
+ // until the consumer/user actually establishes a concrete width.
94
+ // NOTE: `primaryRail` is intentionally NOT a resizable panel — it is a
95
+ // fixed-width icon rail (à la VS Code's activity bar), not a splittable
96
+ // pane; see `AppShellPanelKey` above.
97
+ const PANEL_NOMINAL_PX: Record<AppShellPanelKey, number> = {
98
+ navigationPanel: 320,
99
+ contextPanel: 352,
100
+ utilityPanel: 384,
101
+ };
102
+
64
103
  let {
65
104
  variant,
66
105
  config,
@@ -83,6 +122,12 @@
83
122
  navigationPanelLabel,
84
123
  contextPanelLabel,
85
124
  utilityPanelLabel,
125
+ panelResize = false,
126
+ panelWidths,
127
+ defaultPanelWidths,
128
+ onPanelResize,
129
+ panelMinWidth = 180,
130
+ panelMaxWidth = 640,
86
131
  class: className
87
132
  }: AppShellProps = $props();
88
133
 
@@ -101,6 +146,124 @@
101
146
  let contextPanelOpen = $state(false);
102
147
  let utilityPanelOpen = $state(false);
103
148
 
149
+ // ── Resizable panels (panelResize) ────────────────────────────────────────
150
+ // Controlled/uncontrolled mirrors RangeSlider.svelte: `panelWidths` present
151
+ // (even as `{}`) means controlled — the component reads it but never writes
152
+ // it; otherwise widths live in `internalWidths`, seeded once from
153
+ // `defaultPanelWidths`.
154
+ let internalWidths = $state<Partial<Record<AppShellPanelKey, number>>>(untrack(() => ({ ...defaultPanelWidths })));
155
+
156
+ let navigationPanelEl = $state<HTMLElement | null>(null);
157
+ let contextPanelEl = $state<HTMLElement | null>(null);
158
+ let utilityPanelEl = $state<HTMLElement | null>(null);
159
+
160
+ const isWidthControlled = $derived(panelWidths !== undefined);
161
+
162
+ // `utilityPanel` mirrors a left panel (grow-on-drag-right) unless it sits on
163
+ // the right edge; the "bottom" side never renders a handle at all (checked
164
+ // at the call sites), so its `positive` value is never read.
165
+ const utilityPositive = $derived(utilitySide !== "right");
166
+
167
+ function widthFor(key: AppShellPanelKey): number | undefined {
168
+ const source = isWidthControlled ? panelWidths : internalWidths;
169
+ return source?.[key];
170
+ }
171
+
172
+ function clampWidth(n: number): number {
173
+ return Math.min(Math.max(n, panelMinWidth), panelMaxWidth);
174
+ }
175
+
176
+ // Current width for rendering/ARIA — always a concrete, clamped number so
177
+ // aria-valuenow is never NaN and is always within [aria-valuemin, aria-valuemax].
178
+ function displayWidth(key: AppShellPanelKey): number {
179
+ return clampWidth(widthFor(key) ?? PANEL_NOMINAL_PX[key]);
180
+ }
181
+
182
+ function panelElFor(key: AppShellPanelKey): HTMLElement | null {
183
+ if (key === "navigationPanel") return navigationPanelEl;
184
+ if (key === "contextPanel") return contextPanelEl;
185
+ return utilityPanelEl;
186
+ }
187
+
188
+ // Only the CSS vars for panels with an explicit (controlled or committed)
189
+ // width are emitted — an untouched panel keeps deferring to its token
190
+ // default (`.st-appShell` base rule), so a theme's own width override is
191
+ // never silently overridden just because `panelResize` is on.
192
+ const panelStyle = $derived.by(() => {
193
+ if (!panelResize) return undefined;
194
+ const parts: string[] = [];
195
+ for (const key of Object.keys(PANEL_VAR) as AppShellPanelKey[]) {
196
+ const width = widthFor(key);
197
+ if (width !== undefined) parts.push(`${PANEL_VAR[key]}: ${clampWidth(width)}px`);
198
+ }
199
+ return parts.length ? parts.join("; ") : undefined;
200
+ });
201
+
202
+ function commitWidth(key: AppShellPanelKey, next: number) {
203
+ const clamped = clampWidth(next);
204
+ if (!isWidthControlled) internalWidths = { ...internalWidths, [key]: clamped };
205
+ onPanelResize?.(key, clamped);
206
+ }
207
+
208
+ // Pointer-drag bookkeeping — plain (non-reactive) fields, never read from
209
+ // the template, only from the pointer handlers below.
210
+ let dragKey: AppShellPanelKey | null = null;
211
+ let dragPositive = true;
212
+ let dragStartX = 0;
213
+ let dragStartWidth = 0;
214
+
215
+ function onHandlePointerDown(event: PointerEvent, key: AppShellPanelKey, positive: boolean) {
216
+ const handle = event.currentTarget as HTMLElement;
217
+ handle.setPointerCapture?.(event.pointerId);
218
+ dragKey = key;
219
+ dragPositive = positive;
220
+ dragStartX = event.clientX;
221
+ const measured = panelElFor(key)?.getBoundingClientRect().width ?? 0;
222
+ dragStartWidth = measured > 0 ? measured : displayWidth(key);
223
+ event.preventDefault();
224
+ }
225
+
226
+ function onHandlePointerMove(event: PointerEvent) {
227
+ if (dragKey === null) return;
228
+ const dx = event.clientX - dragStartX;
229
+ const delta = dragPositive ? dx : -dx;
230
+ commitWidth(dragKey, dragStartWidth + delta);
231
+ }
232
+
233
+ function onHandlePointerUp(event: PointerEvent) {
234
+ if (dragKey === null) return;
235
+ const handle = event.currentTarget as HTMLElement;
236
+ if (handle.hasPointerCapture?.(event.pointerId)) handle.releasePointerCapture?.(event.pointerId);
237
+ dragKey = null;
238
+ }
239
+
240
+ // Arrow keys move the splitter itself (WAI-ARIA window-splitter pattern):
241
+ // for a "positive" (left-edge) panel, moving the splitter right grows it;
242
+ // for a "negative" (right-edge) panel, moving the splitter right shrinks
243
+ // it. Home/End always jump to the absolute clamp bounds.
244
+ function onHandleKeydown(event: KeyboardEvent, key: AppShellPanelKey, positive: boolean) {
245
+ const current = displayWidth(key);
246
+ let next: number;
247
+ switch (event.key) {
248
+ case "ArrowLeft":
249
+ next = current + (positive ? -16 : 16);
250
+ break;
251
+ case "ArrowRight":
252
+ next = current + (positive ? 16 : -16);
253
+ break;
254
+ case "Home":
255
+ next = panelMinWidth;
256
+ break;
257
+ case "End":
258
+ next = panelMaxWidth;
259
+ break;
260
+ default:
261
+ return;
262
+ }
263
+ event.preventDefault();
264
+ commitWidth(key, next);
265
+ }
266
+
104
267
  const mode = $derived(variant ?? (config ? "site" : "workspace"));
105
268
  const siteConfig = $derived(config ?? ({ brand: { name: "Sentropic" }, nav: [], theming: { themes: [], theme: "" } } as SiteConfig));
106
269
  const brand = $derived(siteConfig.brand ?? { name: "Sentropic" });
@@ -223,6 +386,7 @@
223
386
  data-utility-mode={utilityMode}
224
387
  data-utility-side={utilitySide}
225
388
  data-panel-collapse={panelCollapse}
389
+ style={panelStyle}
226
390
  >
227
391
  {#if topChrome}
228
392
  <div class="st-appShell__topChrome">
@@ -258,10 +422,13 @@
258
422
  {:else}
259
423
  {@render primaryRail()}
260
424
  {/if}
425
+ <!-- No resize handle here: `primaryRail` is a fixed-width icon
426
+ rail (à la VS Code's activity bar), not a resizable panel —
427
+ see `AppShellPanelKey`. -->
261
428
  </aside>
262
429
  {/if}
263
430
  {#if navigationPanel}
264
- <aside class="st-appShell__navigationPanel" aria-label={navigationLabel}>
431
+ <aside class="st-appShell__navigationPanel" aria-label={navigationLabel} bind:this={navigationPanelEl}>
265
432
  {#if panelCollapse === "accordion"}
266
433
  <button
267
434
  type="button"
@@ -288,6 +455,23 @@
288
455
  {:else}
289
456
  {@render navigationPanel()}
290
457
  {/if}
458
+ {#if panelResize}
459
+ <div
460
+ class="st-appShell__resizeHandle"
461
+ role="separator"
462
+ aria-orientation="vertical"
463
+ tabindex="0"
464
+ aria-valuenow={displayWidth("navigationPanel")}
465
+ aria-valuemin={panelMinWidth}
466
+ aria-valuemax={panelMaxWidth}
467
+ aria-label={`Resize ${navigationLabel}`}
468
+ onpointerdown={(event) => onHandlePointerDown(event, "navigationPanel", true)}
469
+ onpointermove={onHandlePointerMove}
470
+ onpointerup={onHandlePointerUp}
471
+ onpointercancel={onHandlePointerUp}
472
+ onkeydown={(event) => onHandleKeydown(event, "navigationPanel", true)}
473
+ ></div>
474
+ {/if}
291
475
  </aside>
292
476
  {/if}
293
477
  <main class="st-appShell__main" id={mainId}>
@@ -298,7 +482,7 @@
298
482
  {/if}
299
483
  </main>
300
484
  {#if contextPanel}
301
- <aside class="st-appShell__contextPanel" aria-label={contextLabel}>
485
+ <aside class="st-appShell__contextPanel" aria-label={contextLabel} bind:this={contextPanelEl}>
302
486
  {#if panelCollapse === "accordion"}
303
487
  <button
304
488
  type="button"
@@ -325,10 +509,27 @@
325
509
  {:else}
326
510
  {@render contextPanel()}
327
511
  {/if}
512
+ {#if panelResize}
513
+ <div
514
+ class="st-appShell__resizeHandle"
515
+ role="separator"
516
+ aria-orientation="vertical"
517
+ tabindex="0"
518
+ aria-valuenow={displayWidth("contextPanel")}
519
+ aria-valuemin={panelMinWidth}
520
+ aria-valuemax={panelMaxWidth}
521
+ aria-label={`Resize ${contextLabel}`}
522
+ onpointerdown={(event) => onHandlePointerDown(event, "contextPanel", false)}
523
+ onpointermove={onHandlePointerMove}
524
+ onpointerup={onHandlePointerUp}
525
+ onpointercancel={onHandlePointerUp}
526
+ onkeydown={(event) => onHandleKeydown(event, "contextPanel", false)}
527
+ ></div>
528
+ {/if}
328
529
  </aside>
329
530
  {/if}
330
531
  {#if utilityPanel}
331
- <aside class="st-appShell__utilityPanel" aria-label={utilityLabel}>
532
+ <aside class="st-appShell__utilityPanel" aria-label={utilityLabel} bind:this={utilityPanelEl}>
332
533
  {#if panelCollapse === "accordion"}
333
534
  <button
334
535
  type="button"
@@ -355,6 +556,23 @@
355
556
  {:else}
356
557
  {@render utilityPanel()}
357
558
  {/if}
559
+ {#if panelResize && utilitySide !== "bottom"}
560
+ <div
561
+ class="st-appShell__resizeHandle"
562
+ role="separator"
563
+ aria-orientation="vertical"
564
+ tabindex="0"
565
+ aria-valuenow={displayWidth("utilityPanel")}
566
+ aria-valuemin={panelMinWidth}
567
+ aria-valuemax={panelMaxWidth}
568
+ aria-label={`Resize ${utilityLabel}`}
569
+ onpointerdown={(event) => onHandlePointerDown(event, "utilityPanel", utilityPositive)}
570
+ onpointermove={onHandlePointerMove}
571
+ onpointerup={onHandlePointerUp}
572
+ onpointercancel={onHandlePointerUp}
573
+ onkeydown={(event) => onHandleKeydown(event, "utilityPanel", utilityPositive)}
574
+ ></div>
575
+ {/if}
358
576
  </aside>
359
577
  {/if}
360
578
  </div>
@@ -484,6 +702,7 @@
484
702
  min-block-size: 0;
485
703
  min-inline-size: 0;
486
704
  overflow: hidden;
705
+ position: relative;
487
706
  }
488
707
 
489
708
  .st-appShell__primaryRail,
@@ -582,7 +801,7 @@
582
801
  }
583
802
 
584
803
  .st-appShell__panelDisclosure:focus-visible {
585
- outline: 2px solid var(--st-semantic-border-focus, var(--st-semantic-brand-default, #2563eb));
804
+ outline: 2px solid var(--st-semantic-border-focus, var(--st-semantic-brand-default));
586
805
  outline-offset: -2px;
587
806
  }
588
807
 
@@ -604,6 +823,50 @@
604
823
  min-inline-size: 0;
605
824
  }
606
825
 
826
+ /* Drag-to-resize handle (panelResize). Desktop-only: visible by default
827
+ here, forced to `display:none` under the 48rem breakpoint below — the
828
+ element is only ever rendered to the DOM at all when `panelResize` is
829
+ true, so a `panelResize`-less shell never pays for or shows any of this.
830
+ Sits fully inside its panel's own `overflow:hidden` box (no negative
831
+ inset), flush against the edge shared with the next region in flow. */
832
+ .st-appShell__resizeHandle {
833
+ background: transparent;
834
+ block-size: auto;
835
+ cursor: col-resize;
836
+ display: block;
837
+ inset-block: 0;
838
+ inline-size: var(--st-component-appShell-resizeHandle-width, 0.5rem);
839
+ position: absolute;
840
+ touch-action: none;
841
+ z-index: var(--st-component-appShell-resizeHandle-zIndex, 5);
842
+ }
843
+
844
+ .st-appShell__resizeHandle:hover,
845
+ .st-appShell__resizeHandle:focus-visible {
846
+ background: var(--st-component-appShell-resizeHandle-activeBackground, var(--st-semantic-border-interactive));
847
+ }
848
+
849
+ .st-appShell__resizeHandle:focus-visible {
850
+ outline: 2px solid var(--st-semantic-border-focus, var(--st-semantic-brand-default));
851
+ outline-offset: -2px;
852
+ }
853
+
854
+ .st-appShell__navigationPanel > .st-appShell__resizeHandle {
855
+ inset-inline-end: 0;
856
+ }
857
+
858
+ .st-appShell__contextPanel > .st-appShell__resizeHandle {
859
+ inset-inline-start: 0;
860
+ }
861
+
862
+ .st-appShell[data-utility-side="left"] .st-appShell__utilityPanel > .st-appShell__resizeHandle {
863
+ inset-inline-end: 0;
864
+ }
865
+
866
+ .st-appShell[data-utility-side="right"] .st-appShell__utilityPanel > .st-appShell__resizeHandle {
867
+ inset-inline-start: 0;
868
+ }
869
+
607
870
  @media (max-width: 48rem) {
608
871
  .st-appShell__body {
609
872
  flex-flow: column nowrap;
@@ -619,6 +882,12 @@
619
882
  max-block-size: min(60vh, 28rem);
620
883
  }
621
884
 
885
+ /* Resize is desktop-only (>48rem) — panels stack/accordion below this
886
+ breakpoint instead, where a drag handle has no meaning. */
887
+ .st-appShell__resizeHandle {
888
+ display: none;
889
+ }
890
+
622
891
  /* Accordion mode: the panel's own max-block-size cap is superseded by the
623
892
  region's (below) so a collapsed panel can shrink to 0 and an expanded
624
893
  one keeps the same 60vh/28rem ceiling the stack mode always had. */
@@ -4,6 +4,7 @@ export type AppShellVariant = "site" | "workspace";
4
4
  export type AppShellUtilityMode = "reserve" | "overlay" | "floating";
5
5
  export type AppShellUtilitySide = "left" | "right" | "bottom";
6
6
  export type AppShellPanelCollapse = "stack" | "accordion";
7
+ export type AppShellPanelKey = "navigationPanel" | "contextPanel" | "utilityPanel";
7
8
  export type AppShellProps = {
8
9
  variant?: AppShellVariant;
9
10
  config?: SiteConfig;
@@ -40,6 +41,18 @@ export type AppShellProps = {
40
41
  contextPanelLabel?: string;
41
42
  /** Disclosure label for `utilityPanel` when `panelCollapse="accordion"`. Defaults to `utilityLabel`. */
42
43
  utilityPanelLabel?: string;
44
+ /** Enables drag-to-resize handles on side panels above 48rem. Default false — zero regression. */
45
+ panelResize?: boolean;
46
+ /** Controlled panel widths in px. When provided the component never mutates width itself. */
47
+ panelWidths?: Partial<Record<AppShellPanelKey, number>>;
48
+ /** Seeds uncontrolled widths in px. */
49
+ defaultPanelWidths?: Partial<Record<AppShellPanelKey, number>>;
50
+ /** Fired on every committed resize. Persistence is the CONSUMER's job — the DS stays presentational. */
51
+ onPanelResize?: (key: AppShellPanelKey, width: number) => void;
52
+ /** Lower clamp in px. Default 180. */
53
+ panelMinWidth?: number;
54
+ /** Upper clamp in px. Default 640. */
55
+ panelMaxWidth?: number;
43
56
  class?: string;
44
57
  };
45
58
  declare const AppShell: import("svelte").Component<AppShellProps, {}, "">;
@@ -1 +1 @@
1
- {"version":3,"file":"AppShell.svelte.d.ts","sourceRoot":"","sources":["../src/lib/AppShell.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,WAAW,CAAC;AACnD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AACrE,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAC9D,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,WAAW,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,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KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/D,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAsbJ,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,243 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+
4
+ export type PanelSectionProps = {
5
+ id: string;
6
+ label: string;
7
+ children?: Snippet;
8
+ /** Optional header-trailing controls (buttons, counts…). */
9
+ actions?: Snippet;
10
+ class?: string;
11
+ };
12
+ </script>
13
+
14
+ <script lang="ts">
15
+ import { getContext } from "svelte";
16
+ import { ChevronDown } from "@lucide/svelte";
17
+ import { PANEL_STACK_KEY, type PanelStackContext } from "./PanelStack.svelte";
18
+
19
+ let { id, label, children, actions, class: className }: PanelSectionProps = $props();
20
+
21
+ // A PanelSection outside a PanelStack (no context) falls back to a fully
22
+ // expanded, scroll-owning, non-primary section so it still renders sanely in
23
+ // isolation — but the component is designed to always live inside a stack.
24
+ const stack = getContext<PanelStackContext | undefined>(PANEL_STACK_KEY);
25
+
26
+ let rootEl: HTMLElement | null = $state(null);
27
+ // The header is also registered (not just the root): split-primary's
28
+ // auto-collapse measures whichever section is CURRENTLY primary by its
29
+ // header height specifically — see PanelStack.svelte's `register` doc.
30
+ let headerEl: HTMLElement | null = $state(null);
31
+
32
+ // Register with the parent stack (mount order) so it can fall back to "the
33
+ // first section" whenever nothing else designates a scroll owner (unset or
34
+ // stale `expanded`/`primary`) — see PanelStack.svelte's `register`. Same
35
+ // register-in-an-effect / return-the-unregister-callback idiom as
36
+ // SelectableRow.
37
+ $effect(() => {
38
+ if (!stack || !rootEl || !headerEl) return;
39
+ return stack.register(id, rootEl, headerEl);
40
+ });
41
+
42
+ const triggerId = $derived(`st-panelSection-trigger-${id}`);
43
+ const regionId = $derived(`st-panelSection-region-${id}`);
44
+
45
+ const isPrimary = $derived(stack?.isPrimary(id) ?? false);
46
+ const expanded = $derived(stack?.isExpanded(id) ?? true);
47
+ const scrollOwner = $derived(stack?.isScrollOwner(id) ?? true);
48
+
49
+ function onTriggerClick() {
50
+ stack?.toggle(id);
51
+ }
52
+
53
+ const rootClasses = $derived(
54
+ ["st-panelSection", scrollOwner ? "st-panelSection--scrollOwner" : null, className]
55
+ .filter(Boolean)
56
+ .join(" ")
57
+ );
58
+
59
+ const bodyClasses = $derived(
60
+ [
61
+ "st-panelSection__body",
62
+ scrollOwner ? "st-panelSection__body--scrollOwner" : !expanded ? "st-panelSection__body--collapsed" : null
63
+ ]
64
+ .filter(Boolean)
65
+ .join(" ")
66
+ );
67
+ </script>
68
+
69
+ <div class={rootClasses} data-panel-section-id={id} bind:this={rootEl}>
70
+ <div class="st-panelSection__header" bind:this={headerEl}>
71
+ <h3 class="st-panelSection__heading">
72
+ {#if isPrimary}
73
+ <span class="st-panelSection__title st-panelSection__title--primary" id={triggerId}>
74
+ {label}
75
+ </span>
76
+ {:else}
77
+ <button
78
+ type="button"
79
+ class="st-panelSection__trigger"
80
+ aria-expanded={expanded ? "true" : "false"}
81
+ aria-controls={regionId}
82
+ id={triggerId}
83
+ onclick={onTriggerClick}
84
+ >
85
+ <span class="st-panelSection__title">{label}</span>
86
+ <span
87
+ class="st-panelSection__icon"
88
+ class:st-panelSection__icon--expanded={expanded}
89
+ aria-hidden="true"
90
+ >
91
+ <ChevronDown size={18} strokeWidth={2.25} />
92
+ </span>
93
+ </button>
94
+ {/if}
95
+ </h3>
96
+ {#if actions}
97
+ <div class="st-panelSection__actions">
98
+ {@render actions()}
99
+ </div>
100
+ {/if}
101
+ </div>
102
+ <!-- Mounted once, always — collapsing is purely a class/CSS concern (sizing
103
+ + hiding this region), never a conditional block. A chat session, a map
104
+ or any other stateful widget rendered here survives collapse/expand
105
+ without remounting; see AppShell's panelCollapse="accordion" region for
106
+ the same technique. -->
107
+ <div class={bodyClasses} role="region" id={regionId} aria-labelledby={triggerId}>
108
+ {@render children?.()}
109
+ </div>
110
+ </div>
111
+
112
+ <style>
113
+ .st-panelSection {
114
+ display: flex;
115
+ flex: 0 0 auto;
116
+ flex-direction: column;
117
+ min-block-size: 0;
118
+ }
119
+
120
+ /* The scroll-owning section grows to fill the stack; every other section
121
+ stays content-sized. */
122
+ .st-panelSection--scrollOwner {
123
+ flex: 1 1 0;
124
+ min-block-size: 0;
125
+ overflow: hidden;
126
+ }
127
+
128
+ .st-panelSection__header {
129
+ align-items: center;
130
+ display: flex;
131
+ flex: 0 0 auto;
132
+ }
133
+
134
+ .st-panelSection__heading {
135
+ flex: 1 1 auto;
136
+ margin: 0;
137
+ min-inline-size: 0;
138
+ }
139
+
140
+ .st-panelSection__trigger {
141
+ align-items: center;
142
+ background: transparent;
143
+ border: 0;
144
+ color: var(--st-component-accordion-text, inherit);
145
+ cursor: pointer;
146
+ display: flex;
147
+ font: inherit;
148
+ font-size: var(--st-component-accordion-fontSize, inherit);
149
+ font-weight: var(--st-component-accordion-fontWeight, 600);
150
+ gap: 0.75rem;
151
+ inline-size: 100%;
152
+ justify-content: space-between;
153
+ line-height: var(--st-component-accordion-lineHeight, normal);
154
+ padding: var(--st-component-accordion-paddingBlock, 0.875rem)
155
+ var(--st-component-accordion-paddingInline, 0.5rem);
156
+ text-align: start;
157
+ transition: background-color var(--st-motion-fast, 120ms) var(--st-motion-easing, ease);
158
+ }
159
+
160
+ .st-panelSection__trigger:hover {
161
+ background: var(--st-component-control-hoverBackground, var(--st-semantic-surface-subtle));
162
+ }
163
+
164
+ .st-panelSection__trigger:focus-visible {
165
+ outline: 2px solid var(--st-semantic-border-focus, var(--st-semantic-brand-default));
166
+ outline-offset: -2px;
167
+ }
168
+
169
+ .st-panelSection__title {
170
+ flex: 1 1 auto;
171
+ }
172
+
173
+ /* Primary heading (split-primary): same box/typography as a trigger's title
174
+ so switching shapes doesn't reflow the header row, but it is a plain
175
+ `<span>` inside the `<h3>` — never a `<button>` — because it cannot
176
+ collapse and a disclosure affordance would lie. */
177
+ .st-panelSection__title--primary {
178
+ color: var(--st-semantic-text-primary);
179
+ display: block;
180
+ font-weight: 600;
181
+ padding: var(--st-component-accordion-paddingBlock, 0.875rem)
182
+ var(--st-component-accordion-paddingInline, 0.5rem);
183
+ }
184
+
185
+ .st-panelSection__icon {
186
+ align-items: center;
187
+ block-size: 1.25rem;
188
+ color: var(--st-semantic-text-secondary);
189
+ display: inline-flex;
190
+ flex: 0 0 auto;
191
+ inline-size: 1.25rem;
192
+ justify-content: center;
193
+ transition: transform var(--st-motion-fast, 120ms) var(--st-motion-easing, ease);
194
+ }
195
+
196
+ .st-panelSection__icon--expanded {
197
+ transform: rotate(180deg);
198
+ }
199
+
200
+ .st-panelSection__actions {
201
+ align-items: center;
202
+ display: inline-flex;
203
+ flex: 0 0 auto;
204
+ gap: 0.5rem;
205
+ padding-inline-end: 0.5rem;
206
+ }
207
+
208
+ .st-panelSection__body {
209
+ color: var(--st-semantic-text-secondary);
210
+ flex: 0 0 auto;
211
+ line-height: 1.5;
212
+ overflow: hidden;
213
+ padding: 0 0.5rem 0.875rem;
214
+ }
215
+
216
+ /* THE single scroll owner across the whole stack: at any moment exactly one
217
+ PanelSection body carries this class (see PanelStack.svelte's context
218
+ contract, which is the only place deciding who gets it) — every other
219
+ body stays `overflow: hidden`, content-sized or collapsed to zero.
220
+
221
+ `min-block-size` is the floor split-primary's auto-collapse protects (see
222
+ PanelStack.svelte's `primaryMinHeight` prop): PanelStack emits that prop,
223
+ live, as this very custom property on its own root, so the JS threshold
224
+ and this CSS floor read the SAME number and can never drift apart. The
225
+ `160px` fallback only matters when a PanelSection renders without a
226
+ PanelStack ancestor at all. Harmless for sticky-item too (there is only
227
+ ever one scroll owner in that shape as well). */
228
+ .st-panelSection__body--scrollOwner {
229
+ flex: 1 1 0;
230
+ min-block-size: var(--st-component-panelStack-primaryMinBlockSize, 160px);
231
+ overflow: auto;
232
+ }
233
+
234
+ /* Collapsed (sticky-item, not the expanded item): header-only. The region
235
+ stays mounted — never removed — only sized to zero and hidden. */
236
+ .st-panelSection__body--collapsed {
237
+ block-size: 0;
238
+ max-block-size: 0;
239
+ overflow: hidden;
240
+ padding-block: 0;
241
+ visibility: hidden;
242
+ }
243
+ </style>
@@ -0,0 +1,13 @@
1
+ import type { Snippet } from "svelte";
2
+ export type PanelSectionProps = {
3
+ id: string;
4
+ label: string;
5
+ children?: Snippet;
6
+ /** Optional header-trailing controls (buttons, counts…). */
7
+ actions?: Snippet;
8
+ class?: string;
9
+ };
10
+ declare const PanelSection: import("svelte").Component<PanelSectionProps, {}, "">;
11
+ type PanelSection = ReturnType<typeof PanelSection>;
12
+ export default PanelSection;
13
+ //# sourceMappingURL=PanelSection.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PanelSection.svelte.d.ts","sourceRoot":"","sources":["../src/lib/PanelSection.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAgGJ,QAAA,MAAM,YAAY,uDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}