@sentropic/design-system-svelte 0.34.73 → 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.
- package/README.md +31 -1
- package/package.json +7 -2
- package/dist/AppChrome.test.d.ts +0 -2
- package/dist/AppChrome.test.d.ts.map +0 -1
- package/dist/AppChrome.test.js +0 -146
- package/dist/AppShell.panelCollapse.test.d.ts +0 -2
- package/dist/AppShell.panelCollapse.test.d.ts.map +0 -1
- package/dist/AppShell.panelCollapse.test.js +0 -129
- package/dist/AppShell.panelResize.test.d.ts +0 -2
- package/dist/AppShell.panelResize.test.d.ts.map +0 -1
- package/dist/AppShell.panelResize.test.js +0 -338
- package/dist/Collapsible.test.d.ts +0 -2
- package/dist/Collapsible.test.d.ts.map +0 -1
- package/dist/Collapsible.test.js +0 -76
- package/dist/ContourChart.test.d.ts +0 -2
- package/dist/ContourChart.test.d.ts.map +0 -1
- package/dist/ContourChart.test.js +0 -59
- package/dist/EventFeedPanel.test.d.ts +0 -2
- package/dist/EventFeedPanel.test.d.ts.map +0 -1
- package/dist/EventFeedPanel.test.js +0 -66
- package/dist/Icon.test.d.ts +0 -2
- package/dist/Icon.test.d.ts.map +0 -1
- package/dist/Icon.test.js +0 -38
- package/dist/PanelStack.test.d.ts +0 -2
- package/dist/PanelStack.test.d.ts.map +0 -1
- package/dist/PanelStack.test.js +0 -679
- package/dist/PanelStackFixture.svelte +0 -53
- package/dist/PointAndFigureChart.test.d.ts +0 -2
- package/dist/PointAndFigureChart.test.d.ts.map +0 -1
- package/dist/PointAndFigureChart.test.js +0 -73
- package/dist/RenkoChart.test.d.ts +0 -2
- package/dist/RenkoChart.test.d.ts.map +0 -1
- package/dist/RenkoChart.test.js +0 -66
- package/dist/TimeRangePicker.test.d.ts +0 -2
- package/dist/TimeRangePicker.test.d.ts.map +0 -1
- package/dist/TimeRangePicker.test.js +0 -482
- package/dist/VectorFieldChart.test.d.ts +0 -2
- package/dist/VectorFieldChart.test.d.ts.map +0 -1
- package/dist/VectorFieldChart.test.js +0 -59
- package/dist/WindBarbChart.test.d.ts +0 -2
- package/dist/WindBarbChart.test.d.ts.map +0 -1
- 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
|
|
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
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentropic/design-system-svelte",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.75",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,7 +23,12 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
|
-
"dist"
|
|
26
|
+
"dist",
|
|
27
|
+
"!dist/**/*.test.js",
|
|
28
|
+
"!dist/**/*.test.d.ts",
|
|
29
|
+
"!dist/**/*.test.d.ts.map",
|
|
30
|
+
"!dist/**/*Fixture.svelte",
|
|
31
|
+
"!dist/**/*Fixture.d.ts"
|
|
27
32
|
],
|
|
28
33
|
"dependencies": {
|
|
29
34
|
"@lucide/svelte": "^0.562.0",
|
package/dist/AppChrome.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppChrome.test.d.ts","sourceRoot":"","sources":["../src/lib/AppChrome.test.ts"],"names":[],"mappings":""}
|
package/dist/AppChrome.test.js
DELETED
|
@@ -1,146 +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 AppChrome from "./AppChrome.svelte";
|
|
5
|
-
const snippet = (html) => createRawSnippet(() => ({ render: () => `<span>${html}</span>` }));
|
|
6
|
-
const themes = [
|
|
7
|
-
{ id: "sent-tech", label: "Sentropic" },
|
|
8
|
-
{ id: "forge", label: "Forge" },
|
|
9
|
-
{ id: "entropic", label: "Entropic" },
|
|
10
|
-
{ id: "carbon", label: "Carbon" },
|
|
11
|
-
{ id: "dsfr", label: "DSFR" },
|
|
12
|
-
{ id: "airbus", label: "Airbus" },
|
|
13
|
-
];
|
|
14
|
-
const nav = [
|
|
15
|
-
{ label: "Vues", href: "/views", active: true },
|
|
16
|
-
{ label: "Données", href: "/data" },
|
|
17
|
-
{ label: "Réglages", href: "/settings" },
|
|
18
|
-
];
|
|
19
|
-
describe("AppChrome — marque", () => {
|
|
20
|
-
it("renders the canonical brand block (logo + name + product)", () => {
|
|
21
|
-
const { container } = render(AppChrome, {
|
|
22
|
-
props: { brandName: "Sentropic", productName: "dataviz", logoSrc: "/SENT-logo-squared.svg", brandHref: "/home" },
|
|
23
|
-
});
|
|
24
|
-
const brand = container.querySelector("a.st-appChrome__brand");
|
|
25
|
-
expect(brand).toBeTruthy();
|
|
26
|
-
expect(brand.getAttribute("href")).toBe("/home");
|
|
27
|
-
expect(brand.getAttribute("aria-label")).toBe("Sentropic dataviz");
|
|
28
|
-
expect(container.querySelector("img.st-appChrome__brandMark").getAttribute("src")).toBe("/SENT-logo-squared.svg");
|
|
29
|
-
expect(container.querySelector(".st-appChrome__brandName")?.textContent).toBe("Sentropic");
|
|
30
|
-
expect(container.querySelector(".st-appChrome__brandProduct")?.textContent).toBe("dataviz");
|
|
31
|
-
});
|
|
32
|
-
it("defaults brandName to Sentropic", () => {
|
|
33
|
-
const { container } = render(AppChrome, { props: { productName: "dataviz" } });
|
|
34
|
-
expect(container.querySelector(".st-appChrome__brandName")?.textContent).toBe("Sentropic");
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe("AppChrome — navigation", () => {
|
|
38
|
-
it("renders nav links and marks the active one with aria-current", () => {
|
|
39
|
-
const { container } = render(AppChrome, { props: { nav } });
|
|
40
|
-
const links = Array.from(container.querySelectorAll(".st-appChrome__navLink"));
|
|
41
|
-
expect(links.map((a) => a.textContent?.trim())).toEqual(["Vues", "Données", "Réglages"]);
|
|
42
|
-
expect(links[0].getAttribute("aria-current")).toBe("page");
|
|
43
|
-
expect(links[1].getAttribute("aria-current")).toBeNull();
|
|
44
|
-
expect(links[0].classList.contains("st-appHeader__navLink")).toBe(true);
|
|
45
|
-
});
|
|
46
|
-
it("forwards navAlign=center to AppHeader", () => {
|
|
47
|
-
const { container } = render(AppChrome, { props: { nav, navAlign: "center" } });
|
|
48
|
-
expect(container.querySelector(".st-appHeader__bar")?.classList.contains("st-appHeader__bar--navCenter")).toBe(true);
|
|
49
|
-
expect(container.querySelector(".st-appHeader__nav")?.classList.contains("st-appHeader__nav--center")).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
it("filters role-gated items and renders disabled nav without href", () => {
|
|
52
|
-
const { container } = render(AppChrome, {
|
|
53
|
-
props: { nav: [...nav, { label: "Admin", href: "/admin", role: "admin" }, { label: "Soon", href: "/soon", disabled: true }], userRoles: ["member"] },
|
|
54
|
-
});
|
|
55
|
-
const links = Array.from(container.querySelectorAll(".st-appChrome__navLink"));
|
|
56
|
-
expect(links.map((a) => a.textContent?.trim())).toEqual(["Vues", "Données", "Réglages", "Soon"]);
|
|
57
|
-
expect(links.at(-1)?.hasAttribute("href")).toBe(false);
|
|
58
|
-
expect(links.at(-1)?.getAttribute("aria-disabled")).toBe("true");
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe("AppChrome — contrôle thème", () => {
|
|
62
|
-
it("shows the active theme label and fires onThemeChange on selection", async () => {
|
|
63
|
-
const onThemeChange = vi.fn();
|
|
64
|
-
const { container } = render(AppChrome, { props: { themes, theme: "sent-tech", onThemeChange } });
|
|
65
|
-
const trigger = container.querySelector(".st-appChrome__themeWrap button");
|
|
66
|
-
expect(trigger.textContent).toContain("Sentropic");
|
|
67
|
-
await fireEvent.click(trigger);
|
|
68
|
-
expect(container.querySelector('[role="menu"]')).toBeTruthy();
|
|
69
|
-
const carbon = Array.from(container.querySelectorAll(".st-appChrome__menuItem")).find((b) => b.textContent?.includes("Carbon"));
|
|
70
|
-
await fireEvent.click(carbon);
|
|
71
|
-
expect(onThemeChange).toHaveBeenCalledWith("carbon");
|
|
72
|
-
});
|
|
73
|
-
it("hides the theme selector when themes is empty", () => {
|
|
74
|
-
const { container } = render(AppChrome);
|
|
75
|
-
expect(container.querySelector(".st-appChrome__themeWrap")).toBeNull();
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
describe("AppChrome — mode couleur", () => {
|
|
79
|
-
it("cycles light -> dark -> auto via onColorModeChange", async () => {
|
|
80
|
-
const onColorModeChange = vi.fn();
|
|
81
|
-
const { container, rerender } = render(AppChrome, { props: { colorMode: "light", onColorModeChange } });
|
|
82
|
-
await fireEvent.click(container.querySelector(".st-appChrome__iconControl"));
|
|
83
|
-
expect(onColorModeChange).toHaveBeenCalledWith("dark");
|
|
84
|
-
await rerender({ colorMode: "dark", onColorModeChange });
|
|
85
|
-
await fireEvent.click(container.querySelector(".st-appChrome__iconControl"));
|
|
86
|
-
expect(onColorModeChange).toHaveBeenLastCalledWith("auto");
|
|
87
|
-
await rerender({ colorMode: "auto", onColorModeChange });
|
|
88
|
-
await fireEvent.click(container.querySelector(".st-appChrome__iconControl"));
|
|
89
|
-
expect(onColorModeChange).toHaveBeenLastCalledWith("light");
|
|
90
|
-
});
|
|
91
|
-
it("hides the color-mode toggle when colorMode is undefined", () => {
|
|
92
|
-
const { container } = render(AppChrome, { props: { nav } });
|
|
93
|
-
expect(container.querySelector(".st-appChrome__iconControl")).toBeNull();
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
describe("AppChrome — langue", () => {
|
|
97
|
-
it("shows the active locale and fires onLocaleChange on selection", async () => {
|
|
98
|
-
const onLocaleChange = vi.fn();
|
|
99
|
-
const { container } = render(AppChrome, { props: { locale: "fr", onLocaleChange } });
|
|
100
|
-
const trigger = container.querySelector(".st-appChrome__localeWrap button");
|
|
101
|
-
expect(trigger.textContent).toContain("FR");
|
|
102
|
-
await fireEvent.click(trigger);
|
|
103
|
-
const en = Array.from(container.querySelectorAll(".st-appChrome__menuItem")).find((b) => b.textContent?.includes("English"));
|
|
104
|
-
await fireEvent.click(en);
|
|
105
|
-
expect(onLocaleChange).toHaveBeenCalledWith("en");
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
describe("AppChrome — github + identité", () => {
|
|
109
|
-
it("renders the github link with the provided href", () => {
|
|
110
|
-
const { container } = render(AppChrome, { props: { githubHref: "https://github.com/x/y" } });
|
|
111
|
-
const link = container.querySelector('.st-appChrome__utilityNav a[target="_blank"]');
|
|
112
|
-
expect(link.getAttribute("href")).toBe("https://github.com/x/y");
|
|
113
|
-
});
|
|
114
|
-
it("renders the identity snippet content", () => {
|
|
115
|
-
const { container } = render(AppChrome, { props: { identity: snippet("account-zone") } });
|
|
116
|
-
expect(container.querySelector(".st-appChrome__identity")?.textContent).toContain("account-zone");
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
describe("AppChrome — mobile burger + tiroir", () => {
|
|
120
|
-
it("wires the burger aria-controls to the drawer id and renders the drawer when open", () => {
|
|
121
|
-
const { container } = render(AppChrome, { props: { nav, mobileMenuOpen: true } });
|
|
122
|
-
const burger = container.querySelector(".st-appChrome__burgerTrigger");
|
|
123
|
-
const drawer = container.querySelector(".st-appChrome__drawer");
|
|
124
|
-
expect(drawer).toBeTruthy();
|
|
125
|
-
expect(burger.getAttribute("aria-expanded")).toBe("true");
|
|
126
|
-
expect(burger.getAttribute("aria-controls")).toBe(drawer.id);
|
|
127
|
-
expect(drawer.querySelectorAll(".st-appChrome__drawerLink").length).toBeGreaterThanOrEqual(3);
|
|
128
|
-
});
|
|
129
|
-
it("does not render the drawer when closed and toggles via callback", async () => {
|
|
130
|
-
const onMobileMenuToggle = vi.fn();
|
|
131
|
-
const { container } = render(AppChrome, { props: { nav, onMobileMenuToggle } });
|
|
132
|
-
expect(container.querySelector(".st-appChrome__drawer")).toBeNull();
|
|
133
|
-
await fireEvent.click(container.querySelector(".st-appChrome__burgerTrigger"));
|
|
134
|
-
expect(onMobileMenuToggle).toHaveBeenCalledTimes(1);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
describe("AppChrome — extraSelectors", () => {
|
|
138
|
-
it("renders extraSelectors snippet content in the utility nav", () => {
|
|
139
|
-
const { container } = render(AppChrome, { props: { extraSelectors: snippet("extra-ctrl") } });
|
|
140
|
-
expect(container.querySelector(".st-appChrome__extraSelectors")?.textContent).toContain("extra-ctrl");
|
|
141
|
-
});
|
|
142
|
-
it("does not render extraSelectors div when not provided", () => {
|
|
143
|
-
const { container } = render(AppChrome);
|
|
144
|
-
expect(container.querySelector(".st-appChrome__extraSelectors")).toBeNull();
|
|
145
|
-
});
|
|
146
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppShell.panelCollapse.test.d.ts","sourceRoot":"","sources":["../src/lib/AppShell.panelCollapse.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { fireEvent, render } from "@testing-library/svelte";
|
|
2
|
-
import { createRawSnippet } from "svelte";
|
|
3
|
-
import { describe, expect, it } 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 — panelCollapse default (stack)", () => {
|
|
14
|
-
it("renders no disclosure buttons and no panel-region wrappers when panelCollapse is omitted", () => {
|
|
15
|
-
const { container } = render(AppShell, { props: { variant: "workspace", ...panelProps } });
|
|
16
|
-
expect(container.querySelectorAll(".st-appShell__panelDisclosure").length).toBe(0);
|
|
17
|
-
expect(container.querySelectorAll(".st-appShell__panelRegion").length).toBe(0);
|
|
18
|
-
});
|
|
19
|
-
it("renders no disclosure buttons when panelCollapse is explicitly 'stack'", () => {
|
|
20
|
-
const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "stack", ...panelProps } });
|
|
21
|
-
expect(container.querySelectorAll(".st-appShell__panelDisclosure").length).toBe(0);
|
|
22
|
-
});
|
|
23
|
-
it("still renders every panel's content directly inside its aside (unchanged desktop/stack markup)", () => {
|
|
24
|
-
const { container } = render(AppShell, { props: { variant: "workspace", ...panelProps } });
|
|
25
|
-
expect(container.querySelector(".st-appShell__primaryRail")?.textContent).toContain("rail-content");
|
|
26
|
-
expect(container.querySelector(".st-appShell__navigationPanel")?.textContent).toContain("nav-content");
|
|
27
|
-
expect(container.querySelector(".st-appShell__main")?.textContent).toContain("main-content");
|
|
28
|
-
expect(container.querySelector(".st-appShell__contextPanel")?.textContent).toContain("context-content");
|
|
29
|
-
expect(container.querySelector(".st-appShell__utilityPanel")?.textContent).toContain("utility-content");
|
|
30
|
-
});
|
|
31
|
-
it('sets data-panel-collapse="stack" on the root by default', () => {
|
|
32
|
-
const { container } = render(AppShell, { props: { variant: "workspace", ...panelProps } });
|
|
33
|
-
expect(container.querySelector(".st-appShell")?.getAttribute("data-panel-collapse")).toBe("stack");
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe("AppShell — panelCollapse='accordion'", () => {
|
|
37
|
-
it("renders a disclosure button for each present panel, all initially collapsed", () => {
|
|
38
|
-
const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
|
|
39
|
-
const buttons = container.querySelectorAll(".st-appShell__panelDisclosure");
|
|
40
|
-
expect(buttons.length).toBe(4);
|
|
41
|
-
buttons.forEach((btn) => {
|
|
42
|
-
expect(btn.getAttribute("aria-expanded")).toBe("false");
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
it("wires aria-controls on each trigger to the id of its region, and the region is labelled by the trigger", () => {
|
|
46
|
-
const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
|
|
47
|
-
const buttons = Array.from(container.querySelectorAll(".st-appShell__panelDisclosure"));
|
|
48
|
-
expect(buttons.length).toBeGreaterThan(0);
|
|
49
|
-
for (const button of buttons) {
|
|
50
|
-
const controlsId = button.getAttribute("aria-controls");
|
|
51
|
-
expect(controlsId).toBeTruthy();
|
|
52
|
-
const region = container.querySelector(`#${controlsId}`);
|
|
53
|
-
expect(region).toBeTruthy();
|
|
54
|
-
expect(region?.getAttribute("role")).toBe("region");
|
|
55
|
-
expect(region?.getAttribute("aria-labelledby")).toBe(button.id);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
it("toggles aria-expanded on click and reflects the collapsed state on the region", async () => {
|
|
59
|
-
const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
|
|
60
|
-
const trigger = container.querySelector("#st-appShell-navigationPanel-trigger");
|
|
61
|
-
const region = container.querySelector("#st-appShell-navigationPanel-region");
|
|
62
|
-
expect(trigger.getAttribute("aria-expanded")).toBe("false");
|
|
63
|
-
expect(region.classList.contains("st-appShell__panelRegion--collapsed")).toBe(true);
|
|
64
|
-
await fireEvent.click(trigger);
|
|
65
|
-
expect(trigger.getAttribute("aria-expanded")).toBe("true");
|
|
66
|
-
expect(region.classList.contains("st-appShell__panelRegion--collapsed")).toBe(false);
|
|
67
|
-
await fireEvent.click(trigger);
|
|
68
|
-
expect(trigger.getAttribute("aria-expanded")).toBe("false");
|
|
69
|
-
expect(region.classList.contains("st-appShell__panelRegion--collapsed")).toBe(true);
|
|
70
|
-
});
|
|
71
|
-
it("toggles via the keyboard (Enter/Space activate a native button)", async () => {
|
|
72
|
-
const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
|
|
73
|
-
const trigger = container.querySelector("#st-appShell-contextPanel-trigger");
|
|
74
|
-
expect(trigger.getAttribute("aria-expanded")).toBe("false");
|
|
75
|
-
trigger.focus();
|
|
76
|
-
expect(document.activeElement).toBe(trigger);
|
|
77
|
-
// Native <button> activates on Enter/Space via its click event; assert the
|
|
78
|
-
// handler is reachable through a synthesized click (jsdom does not
|
|
79
|
-
// synthesize the keydown->click default action for us).
|
|
80
|
-
await fireEvent.click(trigger);
|
|
81
|
-
expect(trigger.getAttribute("aria-expanded")).toBe("true");
|
|
82
|
-
});
|
|
83
|
-
it("renders no disclosure for a panel that is not provided", () => {
|
|
84
|
-
const { container } = render(AppShell, {
|
|
85
|
-
props: { variant: "workspace", panelCollapse: "accordion", navigationPanel: snippet("nav-only"), main: panelProps.main },
|
|
86
|
-
});
|
|
87
|
-
const buttons = container.querySelectorAll(".st-appShell__panelDisclosure");
|
|
88
|
-
expect(buttons.length).toBe(1);
|
|
89
|
-
expect(container.querySelector(".st-appShell__primaryRail")).toBeNull();
|
|
90
|
-
expect(container.querySelector(".st-appShell__contextPanel")).toBeNull();
|
|
91
|
-
expect(container.querySelector(".st-appShell__utilityPanel")).toBeNull();
|
|
92
|
-
});
|
|
93
|
-
it("keeps the panel content mounted in the DOM even while collapsed (no destroy/remount)", () => {
|
|
94
|
-
const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
|
|
95
|
-
// Collapsed by default, yet content is present — collapse is a CSS
|
|
96
|
-
// concern (sizing/hiding the region), never a conditional {#if}.
|
|
97
|
-
expect(container.querySelector("#st-appShell-utilityPanel-region")?.textContent).toContain("utility-content");
|
|
98
|
-
});
|
|
99
|
-
it("desktop markup still contains the panel content (accordion mode never removes it)", () => {
|
|
100
|
-
const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
|
|
101
|
-
// jsdom does not evaluate @media queries for layout, but the component
|
|
102
|
-
// must not conditionally destroy content based on breakpoint — assert
|
|
103
|
-
// every panel's content is present regardless.
|
|
104
|
-
expect(container.querySelector(".st-appShell__primaryRail")?.textContent).toContain("rail-content");
|
|
105
|
-
expect(container.querySelector(".st-appShell__navigationPanel")?.textContent).toContain("nav-content");
|
|
106
|
-
expect(container.querySelector(".st-appShell__contextPanel")?.textContent).toContain("context-content");
|
|
107
|
-
expect(container.querySelector(".st-appShell__utilityPanel")?.textContent).toContain("utility-content");
|
|
108
|
-
});
|
|
109
|
-
it("uses custom *Label props as the disclosure text, falling back to the existing aria-label props", async () => {
|
|
110
|
-
const { container } = render(AppShell, {
|
|
111
|
-
props: {
|
|
112
|
-
variant: "workspace",
|
|
113
|
-
panelCollapse: "accordion",
|
|
114
|
-
...panelProps,
|
|
115
|
-
primaryRailLabel: "Rail perso",
|
|
116
|
-
contextLabel: "Contexte",
|
|
117
|
-
utilityPanelLabel: "Outils",
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
expect(container.querySelector("#st-appShell-primaryRail-trigger")?.textContent).toContain("Rail perso");
|
|
121
|
-
// contextPanelLabel not set -> falls back to contextLabel.
|
|
122
|
-
expect(container.querySelector("#st-appShell-contextPanel-trigger")?.textContent).toContain("Contexte");
|
|
123
|
-
expect(container.querySelector("#st-appShell-utilityPanel-trigger")?.textContent).toContain("Outils");
|
|
124
|
-
});
|
|
125
|
-
it('sets data-panel-collapse="accordion" on the root', () => {
|
|
126
|
-
const { container } = render(AppShell, { props: { variant: "workspace", panelCollapse: "accordion", ...panelProps } });
|
|
127
|
-
expect(container.querySelector(".st-appShell")?.getAttribute("data-panel-collapse")).toBe("accordion");
|
|
128
|
-
});
|
|
129
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppShell.panelResize.test.d.ts","sourceRoot":"","sources":["../src/lib/AppShell.panelResize.test.ts"],"names":[],"mappings":""}
|