@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
@@ -1,338 +0,0 @@
1
- import { fireEvent, render } from "@testing-library/svelte";
2
- import { createRawSnippet } from "svelte";
3
- import { describe, expect, it, vi } from "vitest";
4
- import AppShell from "./AppShell.svelte";
5
- const snippet = (html) => createRawSnippet(() => ({ render: () => `<div>${html}</div>` }));
6
- const panelProps = {
7
- primaryRail: snippet("rail-content"),
8
- navigationPanel: snippet("nav-content"),
9
- main: snippet("main-content"),
10
- contextPanel: snippet("context-content"),
11
- utilityPanel: snippet("utility-content"),
12
- };
13
- describe("AppShell — panelResize default (false)", () => {
14
- it("renders no resize handles", () => {
15
- const { container } = render(AppShell, { props: { variant: "workspace", ...panelProps } });
16
- expect(container.querySelectorAll(".st-appShell__resizeHandle").length).toBe(0);
17
- });
18
- it("does not set an inline style on the shell root (byte-identical to today)", () => {
19
- const { container } = render(AppShell, {
20
- props: { variant: "workspace", ...panelProps, defaultPanelWidths: { navigationPanel: 400 } },
21
- });
22
- const root = container.querySelector(".st-appShell");
23
- // No `style` attribute at all — panelResize=false never touches width vars,
24
- // even if defaultPanelWidths is (pointlessly) supplied.
25
- expect(root.getAttribute("style")).toBeFalsy();
26
- });
27
- });
28
- describe("AppShell — panelResize=true", () => {
29
- it("renders exactly one resize handle per RESIZABLE present panel (navigation/context/utility)", () => {
30
- const { container } = render(AppShell, { props: { variant: "workspace", panelResize: true, ...panelProps } });
31
- const handles = container.querySelectorAll(".st-appShell__resizeHandle");
32
- expect(handles.length).toBe(3);
33
- handles.forEach((handle) => {
34
- expect(handle.getAttribute("role")).toBe("separator");
35
- expect(handle.getAttribute("aria-orientation")).toBe("vertical");
36
- expect(handle.getAttribute("tabindex")).toBe("0");
37
- });
38
- });
39
- it("renders NO handle on primaryRail, even with panelResize=true and the primaryRail slot present", () => {
40
- const { container } = render(AppShell, { props: { variant: "workspace", panelResize: true, ...panelProps } });
41
- // `primaryRail` is a fixed-width icon rail (à la VS Code's activity bar),
42
- // not a resizable panel — it is not part of `AppShellPanelKey` and must
43
- // never receive a handle, regardless of panelResize/panelWidths.
44
- expect(container.querySelector(".st-appShell__primaryRail .st-appShell__resizeHandle")).toBeNull();
45
- expect(container.querySelector(".st-appShell__primaryRail")).not.toBeNull(); // the rail itself still renders
46
- });
47
- it("labels each handle 'Resize {panel label}', falling back to the existing aria-label props", () => {
48
- const { container } = render(AppShell, {
49
- props: { variant: "workspace", panelResize: true, ...panelProps },
50
- });
51
- expect(container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle')?.getAttribute("aria-label")).toBe("Resize Workspace navigation");
52
- expect(container.querySelector('.st-appShell__contextPanel .st-appShell__resizeHandle')?.getAttribute("aria-label")).toBe("Resize Context panel");
53
- expect(container.querySelector('.st-appShell__utilityPanel .st-appShell__resizeHandle')?.getAttribute("aria-label")).toBe("Resize Utility panel");
54
- });
55
- it("defaults aria-valuemin/aria-valuemax to 180/640 and reports a clamped aria-valuenow", () => {
56
- const { container } = render(AppShell, { props: { variant: "workspace", panelResize: true, ...panelProps } });
57
- const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
58
- expect(handle.getAttribute("aria-valuemin")).toBe("180");
59
- expect(handle.getAttribute("aria-valuemax")).toBe("640");
60
- // No explicit/default width supplied — nominal 320px default is inside [180,640].
61
- expect(handle.getAttribute("aria-valuenow")).toBe("320");
62
- });
63
- it("honors custom panelMinWidth/panelMaxWidth on every handle", () => {
64
- const { container } = render(AppShell, {
65
- props: { variant: "workspace", panelResize: true, ...panelProps, panelMinWidth: 200, panelMaxWidth: 300 },
66
- });
67
- const handles = container.querySelectorAll(".st-appShell__resizeHandle");
68
- expect(handles.length).toBe(3);
69
- handles.forEach((handle) => {
70
- expect(handle.getAttribute("aria-valuemin")).toBe("200");
71
- expect(handle.getAttribute("aria-valuemax")).toBe("300");
72
- });
73
- });
74
- it("renders no handle for a panel that is not provided", () => {
75
- const { container } = render(AppShell, {
76
- props: { variant: "workspace", panelResize: true, navigationPanel: panelProps.navigationPanel, main: panelProps.main },
77
- });
78
- expect(container.querySelectorAll(".st-appShell__resizeHandle").length).toBe(1);
79
- });
80
- it("renders NO handle for utilityPanel when utilitySide='bottom', but keeps handles for the other resizable panels", () => {
81
- const { container } = render(AppShell, {
82
- props: { variant: "workspace", panelResize: true, utilitySide: "bottom", ...panelProps },
83
- });
84
- expect(container.querySelector(".st-appShell__utilityPanel .st-appShell__resizeHandle")).toBeNull();
85
- expect(container.querySelector(".st-appShell__navigationPanel .st-appShell__resizeHandle")).not.toBeNull();
86
- expect(container.querySelector(".st-appShell__contextPanel .st-appShell__resizeHandle")).not.toBeNull();
87
- });
88
- it("applies the width CSS custom properties to the shell root, one per explicitly-widthed panel", () => {
89
- const { container } = render(AppShell, {
90
- props: {
91
- variant: "workspace",
92
- panelResize: true,
93
- ...panelProps,
94
- defaultPanelWidths: { navigationPanel: 300, contextPanel: 260, utilityPanel: 420 },
95
- },
96
- });
97
- const root = container.querySelector(".st-appShell");
98
- expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("300px");
99
- expect(root.style.getPropertyValue("--st-appShell-context-width")).toBe("260px");
100
- expect(root.style.getPropertyValue("--st-appShell-utility-width")).toBe("420px");
101
- // primaryRail is not resizable — no rail-width var is ever emitted, regardless of panelResize.
102
- expect(root.style.getPropertyValue("--st-appShell-rail-width")).toBe("");
103
- });
104
- it("does not set a width var for a panel with no explicit/default/controlled width (defers to the token default)", () => {
105
- const { container } = render(AppShell, {
106
- props: { variant: "workspace", panelResize: true, ...panelProps, defaultPanelWidths: { navigationPanel: 300 } },
107
- });
108
- const root = container.querySelector(".st-appShell");
109
- expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("300px");
110
- expect(root.style.getPropertyValue("--st-appShell-context-width")).toBe("");
111
- expect(root.style.getPropertyValue("--st-appShell-utility-width")).toBe("");
112
- });
113
- });
114
- describe("AppShell — panelResize keyboard interaction (uncontrolled)", () => {
115
- it("ArrowRight grows a left-edge panel (navigationPanel) by 16px and fires onPanelResize", async () => {
116
- const onPanelResize = vi.fn();
117
- const { container } = render(AppShell, {
118
- props: {
119
- variant: "workspace",
120
- panelResize: true,
121
- ...panelProps,
122
- defaultPanelWidths: { navigationPanel: 300 },
123
- onPanelResize,
124
- },
125
- });
126
- const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
127
- await fireEvent.keyDown(handle, { key: "ArrowRight" });
128
- expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 316);
129
- expect(handle.getAttribute("aria-valuenow")).toBe("316");
130
- });
131
- it("ArrowLeft shrinks a left-edge panel (navigationPanel) by 16px", async () => {
132
- const onPanelResize = vi.fn();
133
- const { container } = render(AppShell, {
134
- props: {
135
- variant: "workspace",
136
- panelResize: true,
137
- ...panelProps,
138
- defaultPanelWidths: { navigationPanel: 300 },
139
- onPanelResize,
140
- },
141
- });
142
- const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
143
- await fireEvent.keyDown(handle, { key: "ArrowLeft" });
144
- expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 284);
145
- });
146
- it("ArrowRight SHRINKS a right-edge panel (contextPanel) — moving the splitter right moves toward main", async () => {
147
- const onPanelResize = vi.fn();
148
- const { container } = render(AppShell, {
149
- props: {
150
- variant: "workspace",
151
- panelResize: true,
152
- ...panelProps,
153
- defaultPanelWidths: { contextPanel: 300 },
154
- onPanelResize,
155
- },
156
- });
157
- const handle = container.querySelector('.st-appShell__contextPanel .st-appShell__resizeHandle');
158
- await fireEvent.keyDown(handle, { key: "ArrowRight" });
159
- expect(onPanelResize).toHaveBeenCalledWith("contextPanel", 284);
160
- await fireEvent.keyDown(handle, { key: "ArrowLeft" });
161
- expect(onPanelResize).toHaveBeenLastCalledWith("contextPanel", 300);
162
- });
163
- it("utilityPanel (default utilitySide='right') resizes like a right-edge panel", async () => {
164
- const onPanelResize = vi.fn();
165
- const { container } = render(AppShell, {
166
- props: {
167
- variant: "workspace",
168
- panelResize: true,
169
- ...panelProps,
170
- defaultPanelWidths: { utilityPanel: 300 },
171
- onPanelResize,
172
- },
173
- });
174
- const handle = container.querySelector('.st-appShell__utilityPanel .st-appShell__resizeHandle');
175
- await fireEvent.keyDown(handle, { key: "ArrowRight" });
176
- expect(onPanelResize).toHaveBeenCalledWith("utilityPanel", 284);
177
- });
178
- it("utilityPanel with utilitySide='left' resizes like a left-edge panel", async () => {
179
- const onPanelResize = vi.fn();
180
- const { container } = render(AppShell, {
181
- props: {
182
- variant: "workspace",
183
- panelResize: true,
184
- utilitySide: "left",
185
- ...panelProps,
186
- defaultPanelWidths: { utilityPanel: 300 },
187
- onPanelResize,
188
- },
189
- });
190
- const handle = container.querySelector('.st-appShell__utilityPanel .st-appShell__resizeHandle');
191
- await fireEvent.keyDown(handle, { key: "ArrowRight" });
192
- expect(onPanelResize).toHaveBeenCalledWith("utilityPanel", 316);
193
- });
194
- it("Home jumps to panelMinWidth and End jumps to panelMaxWidth, both firing onPanelResize", async () => {
195
- const onPanelResize = vi.fn();
196
- const { container } = render(AppShell, {
197
- props: {
198
- variant: "workspace",
199
- panelResize: true,
200
- ...panelProps,
201
- defaultPanelWidths: { navigationPanel: 300 },
202
- panelMinWidth: 150,
203
- panelMaxWidth: 500,
204
- onPanelResize,
205
- },
206
- });
207
- const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
208
- await fireEvent.keyDown(handle, { key: "Home" });
209
- expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 150);
210
- expect(handle.getAttribute("aria-valuenow")).toBe("150");
211
- await fireEvent.keyDown(handle, { key: "End" });
212
- expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 500);
213
- expect(handle.getAttribute("aria-valuenow")).toBe("500");
214
- });
215
- it("clamps at the upper bound: repeated ArrowRight never exceeds panelMaxWidth", async () => {
216
- const onPanelResize = vi.fn();
217
- const { container } = render(AppShell, {
218
- props: {
219
- variant: "workspace",
220
- panelResize: true,
221
- ...panelProps,
222
- defaultPanelWidths: { navigationPanel: 495 },
223
- panelMinWidth: 180,
224
- panelMaxWidth: 500,
225
- onPanelResize,
226
- },
227
- });
228
- const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
229
- await fireEvent.keyDown(handle, { key: "ArrowRight" }); // 495 + 16 = 511 -> clamped to 500
230
- expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 500);
231
- await fireEvent.keyDown(handle, { key: "ArrowRight" }); // stays clamped, still fires
232
- expect(onPanelResize).toHaveBeenLastCalledWith("navigationPanel", 500);
233
- expect(handle.getAttribute("aria-valuenow")).toBe("500");
234
- });
235
- it("clamps at the lower bound: repeated ArrowLeft never goes below panelMinWidth", async () => {
236
- const onPanelResize = vi.fn();
237
- const { container } = render(AppShell, {
238
- props: {
239
- variant: "workspace",
240
- panelResize: true,
241
- ...panelProps,
242
- defaultPanelWidths: { navigationPanel: 190 },
243
- panelMinWidth: 180,
244
- onPanelResize,
245
- },
246
- });
247
- const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
248
- await fireEvent.keyDown(handle, { key: "ArrowLeft" }); // 190 - 16 = 174 -> clamped to 180
249
- expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 180);
250
- });
251
- it("ignores keys other than ArrowLeft/ArrowRight/Home/End", async () => {
252
- const onPanelResize = vi.fn();
253
- const { container } = render(AppShell, {
254
- props: { variant: "workspace", panelResize: true, ...panelProps, onPanelResize },
255
- });
256
- const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
257
- await fireEvent.keyDown(handle, { key: "Tab" });
258
- await fireEvent.keyDown(handle, { key: "Enter" });
259
- expect(onPanelResize).not.toHaveBeenCalled();
260
- });
261
- });
262
- describe("AppShell — panelResize pointer drag (uncontrolled)", () => {
263
- it("dragging a left-edge handle rightward grows the panel and fires onPanelResize on move", async () => {
264
- const onPanelResize = vi.fn();
265
- const { container } = render(AppShell, {
266
- props: {
267
- variant: "workspace",
268
- panelResize: true,
269
- ...panelProps,
270
- defaultPanelWidths: { navigationPanel: 300 },
271
- onPanelResize,
272
- },
273
- });
274
- const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
275
- await fireEvent.pointerDown(handle, { clientX: 100, pointerId: 1 });
276
- await fireEvent.pointerMove(handle, { clientX: 140, pointerId: 1 });
277
- expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 340);
278
- await fireEvent.pointerUp(handle, { clientX: 140, pointerId: 1 });
279
- // Further movement after pointerup is a no-op (drag ended).
280
- onPanelResize.mockClear();
281
- await fireEvent.pointerMove(handle, { clientX: 200, pointerId: 1 });
282
- expect(onPanelResize).not.toHaveBeenCalled();
283
- });
284
- it("dragging a right-edge handle rightward shrinks the panel", async () => {
285
- const onPanelResize = vi.fn();
286
- const { container } = render(AppShell, {
287
- props: {
288
- variant: "workspace",
289
- panelResize: true,
290
- ...panelProps,
291
- defaultPanelWidths: { contextPanel: 300 },
292
- onPanelResize,
293
- },
294
- });
295
- const handle = container.querySelector('.st-appShell__contextPanel .st-appShell__resizeHandle');
296
- await fireEvent.pointerDown(handle, { clientX: 100, pointerId: 1 });
297
- await fireEvent.pointerMove(handle, { clientX: 140, pointerId: 1 });
298
- expect(onPanelResize).toHaveBeenCalledWith("contextPanel", 260);
299
- });
300
- });
301
- describe("AppShell — panelResize controlled mode (panelWidths)", () => {
302
- it("never mutates its own state: the rendered width stays exactly what panelWidths says, even after a commit-triggering interaction", async () => {
303
- const onPanelResize = vi.fn();
304
- const { container } = render(AppShell, {
305
- props: {
306
- variant: "workspace",
307
- panelResize: true,
308
- ...panelProps,
309
- panelWidths: { navigationPanel: 250, contextPanel: 300, utilityPanel: 400 },
310
- onPanelResize,
311
- },
312
- });
313
- const root = container.querySelector(".st-appShell");
314
- const handle = container.querySelector('.st-appShell__navigationPanel .st-appShell__resizeHandle');
315
- expect(handle.getAttribute("aria-valuenow")).toBe("250");
316
- expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("250px");
317
- await fireEvent.keyDown(handle, { key: "ArrowRight" });
318
- // onPanelResize told the consumer what the next width *should* be...
319
- expect(onPanelResize).toHaveBeenCalledWith("navigationPanel", 266);
320
- // ...but since the consumer (the test) never fed that back through the
321
- // `panelWidths` prop, the component itself must not have changed anything.
322
- expect(handle.getAttribute("aria-valuenow")).toBe("250");
323
- expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("250px");
324
- await fireEvent.pointerDown(handle, { clientX: 0, pointerId: 2 });
325
- await fireEvent.pointerMove(handle, { clientX: 50, pointerId: 2 });
326
- expect(onPanelResize).toHaveBeenLastCalledWith("navigationPanel", 300);
327
- expect(handle.getAttribute("aria-valuenow")).toBe("250");
328
- });
329
- it("re-renders from a new panelWidths prop (the consumer driving the loop back)", async () => {
330
- const { container, rerender } = render(AppShell, {
331
- props: { variant: "workspace", panelResize: true, ...panelProps, panelWidths: { navigationPanel: 250 } },
332
- });
333
- const root = container.querySelector(".st-appShell");
334
- expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("250px");
335
- await rerender({ variant: "workspace", panelResize: true, ...panelProps, panelWidths: { navigationPanel: 400 } });
336
- expect(root.style.getPropertyValue("--st-appShell-navigation-width")).toBe("400px");
337
- });
338
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Collapsible.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Collapsible.test.d.ts","sourceRoot":"","sources":["../src/lib/Collapsible.test.ts"],"names":[],"mappings":""}
@@ -1,76 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { fileURLToPath } from "node:url";
3
- import { dirname, join } from "node:path";
4
- import { fireEvent, render } from "@testing-library/svelte";
5
- import { createRawSnippet } from "svelte";
6
- import { describe, expect, it } from "vitest";
7
- import Collapsible from "./Collapsible.svelte";
8
- const snippet = (html) => createRawSnippet(() => ({ render: () => `<span>${html}</span>` }));
9
- // Svelte scopes component styles by appending a per-component hash class (e.g.
10
- // "svelte-pav3x3") to every styled element's class list. Compare against the
11
- // SEMANTIC class only (the first token) so the assertions are stable across
12
- // builds and read the structural class, not the scope hash.
13
- const structuralClass = (el) => el.className.split(/\s+/)[0];
14
- describe("Collapsible — base (byte-identity)", () => {
15
- it("renders the default trigger with no trailing span and the md density class", () => {
16
- const { container } = render(Collapsible, { props: { title: "Entities" } });
17
- const root = container.querySelector(".st-collapsible");
18
- expect(root).toBeTruthy();
19
- // Default density is md (additive class), and there is NO trailing span when
20
- // the slot is absent — the trigger keeps its original [title][chevron] shape.
21
- expect(root.classList.contains("st-collapsible--md")).toBe(true);
22
- expect(root.classList.contains("st-collapsible--sm")).toBe(false);
23
- expect(container.querySelector(".st-collapsible__trailing")).toBeNull();
24
- expect(container.querySelector(".st-collapsible__title")?.textContent).toBe("Entities");
25
- // Trigger order is preserved: only the title span then the chevron.
26
- const trigger = container.querySelector(".st-collapsible__trigger");
27
- const spans = Array.from(trigger.children).map(structuralClass);
28
- expect(spans).toEqual(["st-collapsible__title", "st-collapsible__icon"]);
29
- });
30
- });
31
- describe("Collapsible — size", () => {
32
- it("size=\"sm\" toggles st-collapsible--sm", () => {
33
- const { container } = render(Collapsible, { props: { title: "Type", size: "sm" } });
34
- const root = container.querySelector(".st-collapsible");
35
- expect(root.classList.contains("st-collapsible--sm")).toBe(true);
36
- expect(root.classList.contains("st-collapsible--md")).toBe(false);
37
- });
38
- it("size=\"lg\" toggles st-collapsible--lg", () => {
39
- const { container } = render(Collapsible, { props: { title: "Section", size: "lg" } });
40
- expect(container.querySelector(".st-collapsible").classList.contains("st-collapsible--lg")).toBe(true);
41
- });
42
- });
43
- describe("Collapsible — trailing slot", () => {
44
- it("renders trailing content between the title and the chevron", () => {
45
- const { container } = render(Collapsible, {
46
- props: { title: "Entities", trailing: snippet("128") },
47
- });
48
- const trailing = container.querySelector(".st-collapsible__trailing");
49
- expect(trailing).toBeTruthy();
50
- expect(trailing?.textContent).toContain("128");
51
- // Order inside the trigger: title, trailing, chevron (chevron stays last).
52
- const trigger = container.querySelector(".st-collapsible__trigger");
53
- const order = Array.from(trigger.children).map(structuralClass);
54
- expect(order).toEqual([
55
- "st-collapsible__title",
56
- "st-collapsible__trailing",
57
- "st-collapsible__icon",
58
- ]);
59
- });
60
- });
61
- describe("Collapsible — a11y unchanged", () => {
62
- it("toggles aria-expanded on click with size + trailing set", async () => {
63
- const { container } = render(Collapsible, {
64
- props: { title: "Entities", size: "sm", trailing: snippet("7") },
65
- });
66
- const trigger = container.querySelector(".st-collapsible__trigger");
67
- expect(trigger.getAttribute("aria-expanded")).toBe("false");
68
- await fireEvent.click(trigger);
69
- expect(trigger.getAttribute("aria-expanded")).toBe("true");
70
- });
71
- });
72
- it("scopes open chevron rotation to the direct trigger icon", () => {
73
- const source = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "Collapsible.svelte"), "utf8");
74
- expect(source).toContain(".st-collapsible--open > .st-collapsible__trigger .st-collapsible__icon");
75
- expect(source).not.toContain(".st-collapsible--open .st-collapsible__icon {\n transform");
76
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ContourChart.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContourChart.test.d.ts","sourceRoot":"","sources":["../src/lib/ContourChart.test.ts"],"names":[],"mappings":""}
@@ -1,59 +0,0 @@
1
- import { render } from "@testing-library/svelte";
2
- import { describe, expect, it } from "vitest";
3
- import ContourChart from "./ContourChart.svelte";
4
- // Grille 2×2 régulière, valeurs croissantes.
5
- const grid = [
6
- { x: 0, y: 0, value: 1 },
7
- { x: 1, y: 0, value: 2 },
8
- { x: 0, y: 1, value: 3 },
9
- { x: 1, y: 1, value: 4 }
10
- ];
11
- const cells = (container) => Array.from(container.querySelectorAll(".st-contourChart__cell"));
12
- const listItems = (container) => Array.from(container.querySelectorAll(".st-chartDataList li")).map((n) => n.textContent?.trim());
13
- const structuralClass = (el) => el.className.split(/\s+/)[0];
14
- describe("ContourChart", () => {
15
- it("renders an img role and one cell per datum", () => {
16
- const { container } = render(ContourChart, { props: { data: grid, label: "Relief" } });
17
- expect(container.querySelector('[role="img"]')).toBeTruthy();
18
- expect(cells(container).length).toBe(4);
19
- });
20
- it("colours cells by value band (largest value → category8)", () => {
21
- const { container } = render(ContourChart, { props: { data: grid, label: "C" } });
22
- const last = cells(container).at(-1);
23
- expect(last.classList.contains("st-contourChart__cell--category8")).toBe(true);
24
- });
25
- it("renders graduated X/Y axes with nice ticks", () => {
26
- const { container } = render(ContourChart, { props: { data: grid, label: "C" } });
27
- expect(container.querySelectorAll(".st-contourChart__axis").length).toBe(2);
28
- expect(container.querySelectorAll(".st-contourChart__tick").length).toBeGreaterThan(0);
29
- });
30
- it("renders a level legend ramp", () => {
31
- const { container } = render(ContourChart, { props: { data: grid, levels: 4, label: "C" } });
32
- expect(container.querySelectorAll(".st-contourChart__legendSwatch").length).toBe(4);
33
- });
34
- it("lists every datum in the accessible data list", () => {
35
- const { container } = render(ContourChart, {
36
- props: { data: [{ x: 2, y: 3, value: 5 }], label: "C" }
37
- });
38
- expect(listItems(container)[0]).toBe("x 2, y 3 · 5");
39
- });
40
- it("drops non-finite points before rendering", () => {
41
- const { container } = render(ContourChart, {
42
- props: {
43
- data: [
44
- { x: Number.NaN, y: 0, value: 1 },
45
- { x: 0, y: 0, value: Number.NaN },
46
- { x: 1, y: 1, value: 2 }
47
- ],
48
- label: "C"
49
- }
50
- });
51
- expect(cells(container).length).toBe(1);
52
- });
53
- it("merges a custom class onto the root", () => {
54
- const { container } = render(ContourChart, { props: { data: grid, class: "mine" } });
55
- const root = container.querySelector(".st-contourChart");
56
- expect(structuralClass(root)).toBe("st-contourChart");
57
- expect(root.classList.contains("mine")).toBe(true);
58
- });
59
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=EventFeedPanel.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventFeedPanel.test.d.ts","sourceRoot":"","sources":["../src/lib/EventFeedPanel.test.ts"],"names":[],"mappings":""}
@@ -1,66 +0,0 @@
1
- import { render } from "@testing-library/svelte";
2
- import { describe, expect, it } from "vitest";
3
- import EventFeedPanel from "./EventFeedPanel.svelte";
4
- const events = [
5
- { at: 1_700_000_000_000, type: "deploy", severity: "info", message: "Deployed v1.2.0" },
6
- { at: 1_700_000_300_000, type: "alert", severity: "error", message: "5xx spike" },
7
- { at: 1_700_000_100_000, type: "scale", severity: "success", message: "Scaled up" },
8
- { at: 1_700_000_200_000, type: "warn", severity: "warning", message: "High latency" }
9
- ];
10
- const items = (container) => Array.from(container.querySelectorAll(".st-eventFeedPanel__item"));
11
- const structuralClass = (el) => el.className.split(/\s+/)[0];
12
- describe("EventFeedPanel", () => {
13
- it("renders a feed with one article per event", () => {
14
- const { container } = render(EventFeedPanel, { props: { data: events, label: "Activité" } });
15
- expect(container.querySelector('[role="feed"]')).toBeTruthy();
16
- expect(items(container).length).toBe(4);
17
- expect(container.querySelectorAll('[role="article"]').length).toBe(4);
18
- });
19
- it("sorts events by timestamp descending (newest first)", () => {
20
- const { container } = render(EventFeedPanel, { props: { data: events, label: "A" } });
21
- const messages = items(container).map((li) => li.querySelector(".st-eventFeedPanel__message")?.textContent);
22
- expect(messages).toEqual(["5xx spike", "High latency", "Scaled up", "Deployed v1.2.0"]);
23
- });
24
- it("applies a severity tone class per item", () => {
25
- const { container } = render(EventFeedPanel, { props: { data: events, label: "A" } });
26
- expect(container.querySelector(".st-eventFeedPanel__item--info")).toBeTruthy();
27
- expect(container.querySelector(".st-eventFeedPanel__item--success")).toBeTruthy();
28
- expect(container.querySelector(".st-eventFeedPanel__item--warning")).toBeTruthy();
29
- expect(container.querySelector(".st-eventFeedPanel__item--error")).toBeTruthy();
30
- });
31
- it("falls back to the neutral tone for unknown severities", () => {
32
- const { container } = render(EventFeedPanel, {
33
- props: { data: [{ at: 1, type: "x", severity: "debug", message: "noise" }], label: "A" }
34
- });
35
- expect(container.querySelector(".st-eventFeedPanel__item--neutral")).toBeTruthy();
36
- });
37
- it("drops non-finite timestamps before rendering", () => {
38
- const { container } = render(EventFeedPanel, {
39
- props: {
40
- data: [
41
- { at: Number.NaN, type: "x", severity: "info", message: "bad" },
42
- { at: 2, type: "y", severity: "info", message: "good" }
43
- ],
44
- label: "A"
45
- }
46
- });
47
- expect(items(container).length).toBe(1);
48
- expect(container.querySelector(".st-eventFeedPanel__message")?.textContent).toBe("good");
49
- });
50
- it("constrains the scroll height when maxHeight is set", () => {
51
- const { container } = render(EventFeedPanel, { props: { data: events, maxHeight: 180 } });
52
- const list = container.querySelector(".st-eventFeedPanel__list");
53
- expect(list.getAttribute("style")).toContain("max-height: 180px");
54
- });
55
- it("accepts height as an alias of maxHeight", () => {
56
- const { container } = render(EventFeedPanel, { props: { data: events, height: 120 } });
57
- const list = container.querySelector(".st-eventFeedPanel__list");
58
- expect(list.getAttribute("style")).toContain("max-height: 120px");
59
- });
60
- it("merges a custom class onto the root", () => {
61
- const { container } = render(EventFeedPanel, { props: { data: events, class: "mine" } });
62
- const root = container.querySelector(".st-eventFeedPanel");
63
- expect(structuralClass(root)).toBe("st-eventFeedPanel");
64
- expect(root.classList.contains("mine")).toBe(true);
65
- });
66
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Icon.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Icon.test.d.ts","sourceRoot":"","sources":["../src/lib/Icon.test.ts"],"names":[],"mappings":""}
package/dist/Icon.test.js DELETED
@@ -1,38 +0,0 @@
1
- import { render } from "@testing-library/svelte";
2
- import { describe, expect, it } from "vitest";
3
- import Icon from "./Icon.svelte";
4
- import { ICON_NAMES } from "./icons.js";
5
- describe("Icon — canonical DS icon set", () => {
6
- it("renders an svg for every canonical name", () => {
7
- for (const name of ICON_NAMES) {
8
- const { container, unmount } = render(Icon, { props: { name } });
9
- const svg = container.querySelector("svg");
10
- expect(svg, `expected an <svg> for icon "${name}"`).toBeTruthy();
11
- unmount();
12
- }
13
- });
14
- it("defaults to size 18 and stroke-width 2.25 (DS-standard)", () => {
15
- const { container } = render(Icon, { props: { name: "settings" } });
16
- const svg = container.querySelector("svg");
17
- expect(svg.getAttribute("width")).toBe("18");
18
- expect(svg.getAttribute("height")).toBe("18");
19
- expect(svg.getAttribute("stroke-width")).toBe("2.25");
20
- });
21
- it("is decorative (aria-hidden) with no title", () => {
22
- const { container } = render(Icon, { props: { name: "close" } });
23
- const svg = container.querySelector("svg");
24
- expect(svg.getAttribute("aria-hidden")).toBe("true");
25
- });
26
- it("exposes an accessible name when title is set", () => {
27
- const { container } = render(Icon, { props: { name: "eye", title: "Afficher" } });
28
- const svg = container.querySelector("svg");
29
- expect(svg.getAttribute("aria-hidden")).toBeNull();
30
- expect(svg.getAttribute("role")).toBe("img");
31
- expect(svg.getAttribute("aria-label")).toBe("Afficher");
32
- });
33
- it("honours a custom size", () => {
34
- const { container } = render(Icon, { props: { name: "layers", size: 24 } });
35
- const svg = container.querySelector("svg");
36
- expect(svg.getAttribute("width")).toBe("24");
37
- });
38
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=PointAndFigureChart.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PointAndFigureChart.test.d.ts","sourceRoot":"","sources":["../src/lib/PointAndFigureChart.test.ts"],"names":[],"mappings":""}