@sentropic/design-system-svelte 0.34.72 → 0.34.75

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.
Files changed (49) hide show
  1. package/README.md +31 -1
  2. package/dist/PanelSection.svelte +243 -0
  3. package/dist/PanelSection.svelte.d.ts +13 -0
  4. package/dist/PanelSection.svelte.d.ts.map +1 -0
  5. package/dist/PanelStack.svelte +509 -0
  6. package/dist/PanelStack.svelte.d.ts +89 -0
  7. package/dist/PanelStack.svelte.d.ts.map +1 -0
  8. package/dist/PanelStackFixture.svelte.d.ts +23 -0
  9. package/dist/PanelStackFixture.svelte.d.ts.map +1 -0
  10. package/dist/index.d.ts +4 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +2 -0
  13. package/package.json +7 -2
  14. package/dist/AppChrome.test.d.ts +0 -2
  15. package/dist/AppChrome.test.d.ts.map +0 -1
  16. package/dist/AppChrome.test.js +0 -146
  17. package/dist/AppShell.panelCollapse.test.d.ts +0 -2
  18. package/dist/AppShell.panelCollapse.test.d.ts.map +0 -1
  19. package/dist/AppShell.panelCollapse.test.js +0 -129
  20. package/dist/AppShell.panelResize.test.d.ts +0 -2
  21. package/dist/AppShell.panelResize.test.d.ts.map +0 -1
  22. package/dist/AppShell.panelResize.test.js +0 -338
  23. package/dist/Collapsible.test.d.ts +0 -2
  24. package/dist/Collapsible.test.d.ts.map +0 -1
  25. package/dist/Collapsible.test.js +0 -76
  26. package/dist/ContourChart.test.d.ts +0 -2
  27. package/dist/ContourChart.test.d.ts.map +0 -1
  28. package/dist/ContourChart.test.js +0 -59
  29. package/dist/EventFeedPanel.test.d.ts +0 -2
  30. package/dist/EventFeedPanel.test.d.ts.map +0 -1
  31. package/dist/EventFeedPanel.test.js +0 -66
  32. package/dist/Icon.test.d.ts +0 -2
  33. package/dist/Icon.test.d.ts.map +0 -1
  34. package/dist/Icon.test.js +0 -38
  35. package/dist/PointAndFigureChart.test.d.ts +0 -2
  36. package/dist/PointAndFigureChart.test.d.ts.map +0 -1
  37. package/dist/PointAndFigureChart.test.js +0 -73
  38. package/dist/RenkoChart.test.d.ts +0 -2
  39. package/dist/RenkoChart.test.d.ts.map +0 -1
  40. package/dist/RenkoChart.test.js +0 -66
  41. package/dist/TimeRangePicker.test.d.ts +0 -2
  42. package/dist/TimeRangePicker.test.d.ts.map +0 -1
  43. package/dist/TimeRangePicker.test.js +0 -482
  44. package/dist/VectorFieldChart.test.d.ts +0 -2
  45. package/dist/VectorFieldChart.test.d.ts.map +0 -1
  46. package/dist/VectorFieldChart.test.js +0 -59
  47. package/dist/WindBarbChart.test.d.ts +0 -2
  48. package/dist/WindBarbChart.test.d.ts.map +0 -1
  49. package/dist/WindBarbChart.test.js +0 -65
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # `@sentropic/design-system-svelte`
2
2
 
3
- Svelte implementation of the Sentropic design-system component catalog. The package ships ESM JavaScript, TypeScript declarations, and the shared component CSS.
3
+ Svelte implementation of the Sentropic design-system component catalog. The package ships TypeScript declarations, the shared component CSS, and the components themselves as **uncompiled `.svelte` source written in TypeScript** — every component file carries `<script lang="ts">`.
4
+
5
+ That last part has a consequence worth reading before you file a bug: **your build must preprocess this package's `.svelte` files, not just compile them.** See [TypeScript source, and what your build must do](#typescript-source-and-what-your-build-must-do).
4
6
 
5
7
  ## Installation
6
8
 
@@ -60,3 +62,31 @@ npm --workspace @sentropic/design-system-svelte run test
60
62
  ```
61
63
 
62
64
  Publishing is handled by `.github/workflows/svelte-publish.yml` with a `svelte-v*` tag.
65
+
66
+ ## TypeScript source, and what your build must do
67
+
68
+ The `.svelte` files in `dist/` are **source**, not compiled output. Each one begins with `<script lang="ts">` and contains type annotations. A Svelte-aware build therefore has to do two distinct things to them:
69
+
70
+ 1. **preprocess** — strip the TypeScript (`vitePreprocess()` from `@sveltejs/vite-plugin-svelte`, or an equivalent);
71
+ 2. **compile** — turn the result into a component.
72
+
73
+ Most setups do the second to dependencies but not the first, because preprocessing is commonly scoped to your own `src/`. When that happens the compiler receives TypeScript it cannot parse, and the error points at *our* file:
74
+
75
+ ```
76
+ RollupError: Parse failure: Expected ',', got '?'
77
+ at node_modules/@sentropic/design-system-svelte/dist/Accordion.svelte
78
+ ```
79
+
80
+ **That error is a build-configuration symptom, not a broken package.** If you hit it, before filing anything, compare your copy against what npm actually served:
81
+
82
+ ```bash
83
+ sha256sum node_modules/@sentropic/design-system-svelte/dist/Accordion.svelte
84
+ head -1 node_modules/@sentropic/design-system-svelte/dist/Accordion.svelte # <script lang="ts" module>
85
+ ```
86
+
87
+ If `lang="ts"` is on line 1 and the annotations are intact, the file on disk is fine and something in your pipeline is transforming it in flight. Usual suspects: a stale `node_modules/.vite` prebundle cache, the package being externalized so your Svelte plugin never sees it, or preprocessing configured only for your own sources.
88
+
89
+ This bites hardest under **vitest with jsdom**, where dependencies are externalized by default and never reach your Svelte plugin at all.
90
+
91
+ Our own packaging test preprocesses and compiles all 220 published `.svelte` files on every release (`scripts/smoke-pack.mjs`), so a genuinely unparseable file cannot ship. What that test does *not* do is reproduce every consumer bundler configuration — if you find an arrangement where a correct tarball still fails to build, that is worth reporting, and please include the `sha256sum` above.
92
+
@@ -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"}