@supersoniks/concorde 5.0.3 → 5.0.5

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 (151) hide show
  1. package/.agents/skills/concorde-component-docs/SKILL.md +194 -0
  2. package/.agents/skills/concorde-component-docs/template.md +45 -0
  3. package/ai/cursor/rules/concorde-theme.mdc +1 -1
  4. package/ai/cursor/rules/concorde.mdc +1 -1
  5. package/ai/skills/concorde/SKILL.md +1 -1
  6. package/ai/skills/concorde-theme/SKILL.md +21 -10
  7. package/build-infos.json +1 -1
  8. package/concorde-core.bundle.js +515 -521
  9. package/concorde-core.es.js +5151 -5056
  10. package/dist/concorde-core.bundle.js +515 -521
  11. package/dist/concorde-core.es.js +5151 -5056
  12. package/dist/docs-mock-api-sw.js +2 -0
  13. package/dist/docs-mock-api-sw.js.map +2 -2
  14. package/docs/assets/index-CD4WyL6o.css +1 -0
  15. package/docs/assets/{index-BnK6OS7w.js → index-wVZpLVYW.js} +815 -808
  16. package/docs/crawl/core/components/ui/alert/alert.html +76 -5
  17. package/docs/crawl/core/components/ui/alert-messages/alert-messages.html +113 -5
  18. package/docs/crawl/core/components/ui/badge/badge.html +57 -8
  19. package/docs/crawl/core/components/ui/captcha/captcha.html +90 -8
  20. package/docs/crawl/core/components/ui/card/card.html +122 -12
  21. package/docs/crawl/core/components/ui/divider/divider.html +117 -31
  22. package/docs/crawl/core/components/ui/form/fieldset/fieldset.html +232 -101
  23. package/docs/crawl/core/components/ui/form/form-actions/form-actions.html +95 -52
  24. package/docs/crawl/core/components/ui/form/form-layout/form-layout.html +97 -38
  25. package/docs/crawl/core/components/ui/group/group.html +60 -38
  26. package/docs/crawl/core/components/ui/icon/icon.html +136 -47
  27. package/docs/crawl/core/components/ui/image/image.html +118 -6
  28. package/docs/crawl/core/components/ui/link/link.html +65 -7
  29. package/docs/crawl/core/components/ui/loader/loader.html +97 -23
  30. package/docs/crawl/core/components/ui/menu/menu.html +162 -90
  31. package/docs/crawl/core/components/ui/modal/modal.html +275 -50
  32. package/docs/crawl/core/components/ui/pop/pop.html +242 -124
  33. package/docs/crawl/core/components/ui/progress/progress.html +103 -30
  34. package/docs/crawl/core/components/ui/table/table.html +303 -171
  35. package/docs/crawl/core/components/ui/theme/theme.html +131 -0
  36. package/docs/crawl/core/components/ui/toast/toast.html +170 -59
  37. package/docs/crawl/core/components/ui/tooltip/tooltip.html +90 -29
  38. package/docs/crawl/docs/_decorators/ancestor-attribute.html +3 -2
  39. package/docs/crawl/docs/_getting-started/start.html +1 -1
  40. package/docs/crawl/docs/_getting-started/theming.html +311 -63
  41. package/docs/crawl/hubs/form-components.html +71 -49
  42. package/docs/crawl/index.html +7 -6
  43. package/docs/docs-mock-api-sw.js +2 -0
  44. package/docs/docs-mock-api-sw.js.map +2 -2
  45. package/docs/index.html +6 -4
  46. package/docs/llms-full.txt +1468 -405
  47. package/docs/llms.txt +23 -30
  48. package/docs/sitemap.xml +3 -0
  49. package/docs/src/core/components/ui/alert/alert.md +21 -2
  50. package/docs/src/core/components/ui/alert-messages/alert-messages.md +85 -0
  51. package/docs/src/core/components/ui/badge/badge.md +19 -6
  52. package/docs/src/core/components/ui/captcha/captcha.md +65 -6
  53. package/docs/src/core/components/ui/card/card.md +73 -10
  54. package/docs/src/core/components/ui/divider/divider.md +107 -13
  55. package/docs/src/core/components/ui/form/fieldset/fieldset.md +175 -99
  56. package/docs/src/core/components/ui/form/form-actions/form-actions.md +75 -52
  57. package/docs/src/core/components/ui/form/form-layout/form-layout.md +109 -34
  58. package/docs/src/core/components/ui/group/group.md +36 -36
  59. package/docs/src/core/components/ui/icon/icon.md +132 -43
  60. package/docs/src/core/components/ui/image/image.md +35 -3
  61. package/docs/src/core/components/ui/link/link.md +43 -5
  62. package/docs/src/core/components/ui/loader/loader.md +79 -22
  63. package/docs/src/core/components/ui/menu/menu.md +133 -92
  64. package/docs/src/core/components/ui/modal/modal.md +163 -47
  65. package/docs/src/core/components/ui/pop/pop.md +217 -123
  66. package/docs/src/core/components/ui/progress/progress.md +76 -30
  67. package/docs/src/core/components/ui/table/table.md +147 -171
  68. package/docs/src/core/components/ui/theme/theme.md +122 -0
  69. package/docs/src/core/components/ui/toast/toast.md +108 -58
  70. package/docs/src/core/components/ui/tooltip/tooltip.md +68 -26
  71. package/docs/src/docs/_decorators/ancestor-attribute.md +3 -2
  72. package/docs/src/docs/_getting-started/start.md +1 -1
  73. package/docs/src/docs/_getting-started/theming.md +223 -61
  74. package/docs/src/docs/search/docs-search.json +2504 -399
  75. package/docs/src/tsconfig.json +18 -0
  76. package/index.html +4 -2
  77. package/package.json +7 -1
  78. package/public/docs-mock-api-sw.js +2 -0
  79. package/public/docs-mock-api-sw.js.map +2 -2
  80. package/src/core/components/ui/_css/align.ts +1 -0
  81. package/src/core/components/ui/_css/type.ts +86 -8
  82. package/src/core/components/ui/_i18n/ui-aria-labels.ts +8 -0
  83. package/src/core/components/ui/alert/alert.md +21 -2
  84. package/src/core/components/ui/alert-messages/alert-messages.md +85 -0
  85. package/src/core/components/ui/badge/badge.md +19 -6
  86. package/src/core/components/ui/badge/badge.ts +8 -9
  87. package/src/core/components/ui/button/button.ts +5 -15
  88. package/src/core/components/ui/captcha/captcha.md +65 -6
  89. package/src/core/components/ui/card/card.md +73 -10
  90. package/src/core/components/ui/card/card.ts +24 -22
  91. package/src/core/components/ui/divider/divider.md +107 -13
  92. package/src/core/components/ui/divider/divider.ts +40 -33
  93. package/src/core/components/ui/form/fieldset/fieldset.md +175 -99
  94. package/src/core/components/ui/form/fieldset/fieldset.ts +15 -28
  95. package/src/core/components/ui/form/fieldset/legend.ts +13 -13
  96. package/src/core/components/ui/form/form-actions/form-actions.md +75 -52
  97. package/src/core/components/ui/form/form-actions/form-actions.ts +7 -5
  98. package/src/core/components/ui/form/form-layout/form-layout.md +109 -34
  99. package/src/core/components/ui/form/form-layout/form-layout.ts +27 -24
  100. package/src/core/components/ui/form/textarea/textarea.ts +4 -3
  101. package/src/core/components/ui/group/group.md +36 -36
  102. package/src/core/components/ui/group/group.ts +5 -10
  103. package/src/core/components/ui/icon/icon.md +132 -43
  104. package/src/core/components/ui/image/image.md +35 -3
  105. package/src/core/components/ui/link/link.md +43 -5
  106. package/src/core/components/ui/loader/loader.md +79 -22
  107. package/src/core/components/ui/loader/loader.ts +67 -27
  108. package/src/core/components/ui/loader/styles/fixed.ts +6 -11
  109. package/src/core/components/ui/menu/menu.md +133 -92
  110. package/src/core/components/ui/menu/menu.ts +53 -58
  111. package/src/core/components/ui/modal/modal.md +163 -47
  112. package/src/core/components/ui/modal/modal.ts +2 -4
  113. package/src/core/components/ui/pop/pop.md +217 -123
  114. package/src/core/components/ui/pop/pop.ts +0 -1
  115. package/src/core/components/ui/progress/progress.md +76 -30
  116. package/src/core/components/ui/progress/progress.ts +25 -56
  117. package/src/core/components/ui/table/table-caption.ts +2 -2
  118. package/src/core/components/ui/table/table-tbody.ts +3 -3
  119. package/src/core/components/ui/table/table-td.ts +23 -18
  120. package/src/core/components/ui/table/table-th.ts +8 -8
  121. package/src/core/components/ui/table/table-tr.ts +4 -4
  122. package/src/core/components/ui/table/table.md +147 -171
  123. package/src/core/components/ui/table/table.ts +20 -19
  124. package/src/core/components/ui/theme/theme-collection/auto.ts +15 -0
  125. package/src/core/components/ui/theme/theme-collection/core-variables.ts +8 -31
  126. package/src/core/components/ui/theme/theme-collection/dark.ts +1 -7
  127. package/src/core/components/ui/theme/theme-collection/light.ts +30 -26
  128. package/src/core/components/ui/theme/theme.md +122 -0
  129. package/src/core/components/ui/theme/theme.ts +30 -7
  130. package/src/core/components/ui/toast/toast-item.ts +6 -9
  131. package/src/core/components/ui/toast/toast.md +108 -58
  132. package/src/core/components/ui/toast/types.ts +1 -1
  133. package/src/core/components/ui/tooltip/tooltip.md +68 -26
  134. package/src/core/decorators/subscriber/ancestorAttribute.spec.ts +26 -0
  135. package/src/core/decorators/subscriber/ancestorAttribute.ts +3 -4
  136. package/src/core/utils/AncestorAttributeObserver.ts +183 -70
  137. package/src/docs/_decorators/ancestor-attribute.md +3 -2
  138. package/src/docs/_getting-started/start.md +1 -1
  139. package/src/docs/_getting-started/theming.md +223 -61
  140. package/src/docs/code.ts +125 -58
  141. package/src/docs/header/header.ts +62 -54
  142. package/src/docs/mock-api/router.ts +2 -0
  143. package/src/docs/navigation/navigation.ts +6 -3
  144. package/src/docs/search/docs-search.json +2504 -399
  145. package/src/docs/search/markdown-renderer.ts +6 -6
  146. package/src/docs/search/search.ts +4 -4
  147. package/src/docs/tailwind/css/tailwind.css +6 -5
  148. package/src/tsconfig.json +18 -0
  149. package/src/tsconfig.tsbuildinfo +1 -1
  150. package/tailwind.config.js +19 -0
  151. package/docs/assets/index--GpD7R7a.css +0 -1
@@ -1,32 +1,36 @@
1
1
  import { css } from "lit";
2
2
 
3
- export const light = css`
4
- :host([theme="light"]) {
5
- /*Boutons*/
6
- --sc-primary: var(--sc-base-800);
7
- --sc-info: #2563eb;
8
- --sc-danger: #f43f5e;
9
- --sc-warning: #f97316;
10
- --sc-success: #14b8a6;
3
+ export const lightCss = css`
4
+ /*Boutons*/
5
+ --sc-primary: var(--sc-base-800);
6
+ --sc-info: #2563eb;
7
+ --sc-danger: #f43f5e;
8
+ --sc-warning: #f97316;
9
+ --sc-success: #14b8a6;
10
+
11
+ --sc-primary-content: var(--sc-base, #fff);
12
+ --sc-info-content: var(--sc-base, #fff);
13
+ --sc-danger-content: var(--sc-base, #fff);
14
+ --sc-warning-content: var(--sc-base, #fff);
15
+ --sc-success-content: var(--sc-base, #fff);
11
16
 
12
- --sc-primary-content: var(--sc-base, #fff);
13
- --sc-info-content: var(--sc-base, #fff);
14
- --sc-danger-content: var(--sc-base, #fff);
15
- --sc-warning-content: var(--sc-base, #fff);
16
- --sc-success-content: var(--sc-base, #fff);
17
+ /*Bases*/
18
+ --sc-base: #fff;
19
+ --sc-base-50: #f8fafc;
20
+ --sc-base-100: #f1f5f9;
21
+ --sc-base-200: #e2e8f0;
22
+ --sc-base-300: #cbd5e1;
23
+ --sc-base-400: #94a3b8;
24
+ --sc-base-500: #64748b;
25
+ --sc-base-600: #475569;
26
+ --sc-base-700: #334155;
27
+ --sc-base-800: #1e293b;
28
+ --sc-base-900: #0f172a;
29
+ --sc-base-content: var(--sc-base-700);
30
+ `;
17
31
 
18
- /*Bases*/
19
- --sc-base: #fff;
20
- --sc-base-50: #f8fafc;
21
- --sc-base-100: #f1f5f9;
22
- --sc-base-200: #e2e8f0;
23
- --sc-base-300: #cbd5e1;
24
- --sc-base-400: #94a3b8;
25
- --sc-base-500: #64748b;
26
- --sc-base-600: #475569;
27
- --sc-base-700: #334155;
28
- --sc-base-800: #1e293b;
29
- --sc-base-900: #0f172a;
30
- --sc-base-content: var(--sc-base-700);
32
+ export const light = css`
33
+ :host([theme="light"]) {
34
+ ${lightCss}
31
35
  }
32
36
  `;
@@ -0,0 +1,122 @@
1
+ # Theme
2
+
3
+ **`sonic-theme`** wraps a Concorde UI: it registers **`--sc-*`** design tokens and provides the default slot for your app. With no **`theme`** attribute (or **`theme="custom"`**), only shared primitives and your overrides apply—built-in **`light`** / **`dark`** / **`auto`** palettes are opt-in. Set **`color`** and **`font`** when the host should carry base text and typography; add Tailwind **`bg-base`** and **`block`** (or **`min-h-screen`**) on the tag for a full surface fill. **Popovers**, **modals**, and **toasts** mount under the nearest connected theme (see [Pop container](#pop-container)). Import **`@supersoniks/concorde/theme`** once at the app entry. For the full public token list and brand overrides, see [Customization](#docs/_getting-started/theming.md/theming).
4
+
5
+ ## Basic example
6
+
7
+ Wrap interactive components so tokens and overlays resolve from one root.
8
+
9
+ <sonic-code>
10
+ <template>
11
+ <sonic-theme color font class="block bg-base p-6 rounded-lg">
12
+ <sonic-button type="primary">Save changes</sonic-button>
13
+ </sonic-theme>
14
+ </template>
15
+ </sonic-code>
16
+
17
+ ## Theme mode
18
+
19
+ **Default:** omit **`theme`** or set **`theme="custom"`**. The host loads core tokens (`--sc-rounded`, shadows, form defaults, …) and any **`--sc-*`** you set; it does **not** apply the built-in light or dark palette.
20
+
21
+ Set **`theme`** to **`light`** or **`dark`** for Concorde’s preset palettes. Set **`theme="auto"`** to follow **`prefers-color-scheme`** (light palette until the OS prefers dark).
22
+
23
+ <sonic-code>
24
+ <template>
25
+ <div class="grid gap-4 md:grid-cols-2">
26
+ <sonic-theme theme="light" color font class="block bg-base p-4 rounded-md border border-neutral-200">
27
+ <p class="text-sm mb-3 opacity-80">theme="light"</p>
28
+ <div class="flex flex-wrap gap-2">
29
+ <sonic-badge type="primary">Primary</sonic-badge>
30
+ <sonic-badge type="success">Success</sonic-badge>
31
+ <sonic-badge type="danger">Danger</sonic-badge>
32
+ </div>
33
+ </sonic-theme>
34
+ <sonic-theme theme="dark" color font class="block bg-base p-4 rounded-md">
35
+ <p class="text-sm mb-3 opacity-80">theme="dark"</p>
36
+ <div class="flex flex-wrap gap-2">
37
+ <sonic-badge type="primary">Primary</sonic-badge>
38
+ <sonic-badge type="success">Success</sonic-badge>
39
+ <sonic-badge type="danger">Danger</sonic-badge>
40
+ </div>
41
+ </sonic-theme>
42
+ </div>
43
+ </template>
44
+ </sonic-code>
45
+
46
+ ## Presentation
47
+
48
+ **`color`** sets text from **`--sc-base-content`**. **`font`** applies **`--sc-font-family-base`**, **`--sc-font-weight-base`**, and **`--sc-font-style-base`**. For the page or shell background, use **`bg-base`** on **`sonic-theme`** (maps to **`--sc-base`** in Tailwind) with **`block`** so the host paints the surface. Components keep their own fallbacks when **`color`** / **`font`** are omitted.
49
+
50
+ <sonic-code>
51
+ <template>
52
+ <sonic-theme theme="light" color font class="block bg-base p-6 min-h-[8rem] rounded-lg">
53
+ <p>Body copy inherits base content color and font from the theme host.</p>
54
+ </sonic-theme>
55
+ </template>
56
+ </sonic-code>
57
+
58
+ ## Custom tokens
59
+
60
+ Override **primitives** on **`sonic-theme`** (or **`:root`** / a project stylesheet). Derived radii, shadows, and control rounding are computed from tokens such as **`--sc-rounded`**—avoid copying long lists of internal variables unless you have a specific need.
61
+
62
+ <sonic-code>
63
+ <template>
64
+ <sonic-theme
65
+ theme="custom"
66
+ color
67
+ font
68
+ class="block bg-base p-6 rounded-lg"
69
+ style="--sc-primary: #353429; --sc-rounded: 0.25rem;"
70
+ >
71
+ <sonic-button type="primary">Brand primary</sonic-button>
72
+ </sonic-theme>
73
+ </template>
74
+ </sonic-code>
75
+
76
+ ## Pop container
77
+
78
+ **`Theme.getPopContainer()`** returns the last connected **`sonic-theme`**, or **`document.body`** if none is connected. When a theme disconnects, the previous connected instance is adopted. Imperative **`Modal.create()`** and declarative **`sonic-modal`** use the same container.
79
+
80
+ <sonic-code>
81
+ <template>
82
+ <sonic-theme theme="light" color font class="block bg-base p-4 rounded-lg">
83
+ <sonic-button onclick="document.getElementById('themePopModal').show()">
84
+ Open modal
85
+ </sonic-button>
86
+ <sonic-modal id="themePopModal">
87
+ <sonic-modal-title>Mounted on theme</sonic-modal-title>
88
+ <sonic-modal-content>
89
+ This dialog is appended under the nearest sonic-theme pop container.
90
+ </sonic-modal-content>
91
+ <sonic-modal-actions>
92
+ <sonic-button hideModal>Close</sonic-button>
93
+ </sonic-modal-actions>
94
+ </sonic-modal>
95
+ </sonic-theme>
96
+ </template>
97
+ </sonic-code>
98
+
99
+ ## Embedded iframes
100
+
101
+ On connect, the theme publishes resolved **`--sc-*`** values and linked font stylesheet URLs (Google Fonts / Adobe Fonts) to the **`sonic-theme`** data channel and **`postMessage`**s them to same-page iframes. Iframes can request a refresh by posting **`{ type: "GetSonicTheme" }`**.
102
+
103
+ <sonic-code language="javascript">
104
+ <template>
105
+ // Inside the iframe — ask the parent theme to rebroadcast tokens
106
+ window.parent.postMessage({ type: "GetSonicTheme" }, "*");
107
+ </template>
108
+ </sonic-code>
109
+
110
+ ## API reference
111
+
112
+ | Attribute | Values | Description |
113
+ |----------|---------|-------------|
114
+ | `theme` | omitted · `custom` (default) · `light` · `dark` · `auto` | Omitted or `custom`: core tokens and your `--sc-*` only. `light` / `dark`: fixed presets. `auto`: presets follow `prefers-color-scheme` |
115
+ | `color` | boolean | Host text color uses `--sc-base-content` |
116
+ | `font` | boolean | Host font uses `--sc-font-family-base` and related base weight/style tokens |
117
+
118
+ | Slot | Description |
119
+ |------|-------------|
120
+ | *(default)* | Application markup and Concorde components |
121
+
122
+ Surface background: Tailwind **`bg-base`** on **`sonic-theme`** (requires Concorde Tailwind color **`base`** → **`--sc-base`**).
@@ -1,6 +1,7 @@
1
1
  import { html, LitElement, css } from "lit";
2
2
  import { customElement, property } from "lit/decorators.js";
3
3
  import { coreVariables } from "@supersoniks/concorde/core/components/ui/theme/theme-collection/core-variables";
4
+ import { auto } from "@supersoniks/concorde/core/components/ui/theme/theme-collection/auto";
4
5
  import { light } from "@supersoniks/concorde/core/components/ui/theme/theme-collection/light";
5
6
  import { dark } from "@supersoniks/concorde/core/components/ui/theme/theme-collection/dark";
6
7
  import { PublisherManager } from "@supersoniks/concorde/utils";
@@ -12,6 +13,7 @@ export class Theme extends LitElement {
12
13
  static styles = [
13
14
  light,
14
15
  dark,
16
+ auto,
15
17
  coreVariables,
16
18
  css`
17
19
  :host([color]) {
@@ -50,32 +52,53 @@ export class Theme extends LitElement {
50
52
 
51
53
  static instance: Theme | undefined;
52
54
 
53
- constructor() {
54
- super();
55
- Theme.instance = this;
55
+ private readonly onWindowMessage = (event: MessageEvent) =>
56
+ this.receiveMessage(event);
57
+
58
+ /** Last connected `<sonic-theme>`; used as the portal root for overlays. */
59
+ private static adoptPopContainerInstance(exclude?: Theme) {
60
+ Theme.instance = undefined;
61
+ const themes = document.querySelectorAll(tagName);
62
+ for (let i = themes.length - 1; i >= 0; i--) {
63
+ const elt = themes[i];
64
+ if (elt !== exclude && elt instanceof Theme && elt.isConnected) {
65
+ Theme.instance = elt;
66
+ return;
67
+ }
68
+ }
56
69
  }
57
70
 
58
71
  /**
59
72
  * retourne le conteneur de tout ce qui pop : popups / modale / tooltip? / dropdown / ...
60
73
  */
61
74
  public static getPopContainer() {
62
- return Theme.instance || document.body;
75
+ if (Theme.instance?.isConnected) return Theme.instance;
76
+ Theme.adoptPopContainerInstance();
77
+ return Theme.instance ?? document.body;
63
78
  }
64
79
 
65
80
  @property({ type: String, reflect: true })
66
- theme?: "light" | "dark";
81
+ theme?: "light" | "dark" | "auto" | "custom";
67
82
 
68
- @property({ type: Boolean, reflect: true }) background = false;
69
83
  @property({ type: Boolean, reflect: true }) color = false;
70
84
  @property({ type: Boolean, reflect: true }) font = false;
71
85
 
72
86
  connectedCallback(): void {
73
87
  super.connectedCallback();
74
- window.addEventListener("message", (e) => this.receiveMessage(e), false);
88
+ Theme.instance = this;
89
+ window.addEventListener("message", this.onWindowMessage, false);
75
90
  window.dispatchEvent(new CustomEvent("SonicThemeReady"));
76
91
  this.postCSSVars();
77
92
  }
78
93
 
94
+ disconnectedCallback(): void {
95
+ window.removeEventListener("message", this.onWindowMessage, false);
96
+ if (Theme.instance === this) {
97
+ Theme.adoptPopContainerInstance(this);
98
+ }
99
+ super.disconnectedCallback();
100
+ }
101
+
79
102
  postCSSVars() {
80
103
  const stylesheets = document.styleSheets;
81
104
  const ssLength = stylesheets.length;
@@ -148,19 +148,16 @@ export class SonicToastItem extends LitElement {
148
148
  }
149
149
 
150
150
  /*STATUS — accent via statusColor (--sc-_color) */
151
- :host([status]) .sonic-toast {
151
+ :host([status="success"]) .sonic-toast,
152
+ :host([status="error"]) .sonic-toast,
153
+ :host([status="info"]) .sonic-toast,
154
+ :host([status="warning"]) .sonic-toast {
152
155
  border-top: 3px solid var(--sc-_color);
153
156
  }
154
157
 
155
- :host([status="success"]) .sonic-toast:before,
156
- :host([status="error"]) .sonic-toast:before,
157
- :host([status="info"]) .sonic-toast:before,
158
- :host([status="warning"]) .sonic-toast:before {
159
- background-color: var(--sc-_color);
160
- }
161
-
162
158
  .sonic-toast:before {
163
159
  content: "";
160
+ background-color: var(--sc-_color);
164
161
  display: block;
165
162
  position: absolute;
166
163
  left: 0;
@@ -192,7 +189,7 @@ export class SonicToastItem extends LitElement {
192
189
  @property() label: ToastContent = "";
193
190
  @property({ type: String }) id = "";
194
191
  @property() text: ToastContent = "";
195
- @property({ type: String, reflect: true }) status: ToastStatus = "";
192
+ @property({ type: String, reflect: true }) status?: ToastStatus;
196
193
  @property({ type: Boolean }) ghost = false;
197
194
  @property({ type: Boolean }) preserve = false;
198
195
  @property({ type: Boolean }) dismissForever = false;
@@ -1,166 +1,216 @@
1
1
  # Toast
2
2
 
3
- ## Utilisation de base
3
+ Toasts surface **short-lived feedback** in a fixed stack (bottom-right in the main window). Queue messages with **`SonicToast.add()`** on the global **`SonicToast`** class—the host **`sonic-toast`** is created automatically. Prefer **`label`** for a heading; use **`preserve`** or interactive **`text`** when the user must read or act before dismiss.
4
+
5
+ ## Basic example
6
+
7
+ Click the button to show a toast.
4
8
 
5
9
  <sonic-code>
6
10
  <template>
7
- <sonic-button onclick="window.SonicToast.add({ text: 'Message de notification simple' })">
8
- Afficher un toast
11
+ <sonic-button onclick="SonicToast.add({ text: 'Simple notification' })">
12
+ Show toast
9
13
  </sonic-button>
10
14
  </template>
11
15
  </sonic-code>
12
16
 
13
- ## Statut
17
+ ## Status
14
18
 
15
- Les statuts disponibles sont : `success`, `error`, `warning`, `info` ou vide (par défaut).
19
+ **`status`** drives color, icon, and live-region behavior. Omit **`status`** or pass an empty string for a neutral toast.
16
20
 
17
21
  <sonic-code>
18
22
  <template>
19
23
  <div class="flex flex-wrap gap-2">
20
- <sonic-button onclick="window.SonicToast.add({ text: 'Message par défaut', status: '' })">
24
+ <sonic-button onclick="SonicToast.add({ text: 'Default message', status: '' })">
21
25
  Default
22
26
  </sonic-button>
23
- <sonic-button onclick="window.SonicToast.add({ text: 'Opération réussie !', status: 'success' })">
27
+ <sonic-button onclick="SonicToast.add({ text: 'Operation succeeded', status: 'success' })">
24
28
  Success
25
29
  </sonic-button>
26
- <sonic-button onclick="window.SonicToast.add({ text: 'Une erreur est survenue', status: 'error' })">
30
+ <sonic-button onclick="SonicToast.add({ text: 'Something went wrong', status: 'error' })">
27
31
  Error
28
32
  </sonic-button>
29
- <sonic-button onclick="window.SonicToast.add({ text: 'Attention à ce point', status: 'warning' })">
33
+ <sonic-button onclick="SonicToast.add({ text: 'Check this detail', status: 'warning' })">
30
34
  Warning
31
35
  </sonic-button>
32
- <sonic-button onclick="window.SonicToast.add({ text: 'Information importante', status: 'info' })">
36
+ <sonic-button onclick="SonicToast.add({ text: 'Helpful context', status: 'info' })">
33
37
  Info
34
38
  </sonic-button>
35
39
  </div>
36
40
  </template>
37
41
  </sonic-code>
38
42
 
39
- ## Avec titre
43
+ ## Label
44
+
45
+ Set **`label`** for a bold title above **`text`**. **`title`** still works but is deprecated—use **`label`** in new code.
40
46
 
41
47
  <sonic-code>
42
48
  <template>
43
49
  <div class="flex flex-wrap gap-2">
44
- <sonic-button onclick="window.SonicToast.add({ title: 'Succès', text: 'Votre demande a été traitée avec succès.', status: 'success' })">
45
- Toast avec titre
50
+ <sonic-button
51
+ onclick="SonicToast.add({ label: 'Success', text: 'Your request was processed.', status: 'success' })"
52
+ >
53
+ Toast with label
46
54
  </sonic-button>
47
- <sonic-button onclick="window.SonicToast.add({ title: 'Test', text: 'Une erreur est survenue lors du traitement.', status: 'error' })">
48
- Toast d'erreur avec titre
55
+ <sonic-button
56
+ onclick="SonicToast.add({ label: 'Error', text: 'Processing failed. Try again.', status: 'error' })"
57
+ >
58
+ Error with label
49
59
  </sonic-button>
50
60
  </div>
51
61
  </template>
52
62
  </sonic-code>
53
63
 
54
- ## Avec contenu HTML
64
+ ## HTML in text
55
65
 
56
- Le contenu du toast peut contenir du HTML.
66
+ **`text`** (and **`label`**) can include HTML strings. Links and controls in **`text`** automatically enable **`preserve`** so the toast does not auto-hide while the user interacts.
57
67
 
58
68
  <sonic-code>
59
69
  <template>
60
- <sonic-button onclick="window.SonicToast.add({ text: 'Message avec <strong>HTML</strong> et un <a href=&quot;#&quot;>lien cliquable</a>', status: 'info' })">
61
- Toast avec HTML
70
+ <sonic-button
71
+ onclick="SonicToast.add({ text: 'Message with <strong>HTML</strong> and an <a href=&quot;#&quot;>action link</a>', status: 'info' })"
72
+ >
73
+ Toast with HTML
62
74
  </sonic-button>
63
75
  </template>
64
76
  </sonic-code>
65
77
 
78
+ ## Preserve
66
79
 
67
- ## Persistance
68
-
69
- Par défaut, les toasts disparaissent automatiquement. Avec `preserve: true`, le toast reste affiché jusqu'à ce qu'il soit fermé manuellement.
80
+ Without **`preserve`**, toasts auto-hide after about six seconds (timer pauses on hover or focus). Set **`preserve`** to keep the toast until the user closes it.
70
81
 
71
82
  <sonic-code>
72
83
  <template>
73
- <sonic-button onclick="window.SonicToast.add({ text: 'Ce toast ne disparaîtra pas automatiquement', status: 'info', preserve: true })">
74
- Toast persistant
84
+ <sonic-button
85
+ onclick="SonicToast.add({ text: 'This toast stays until you dismiss it', status: 'info', preserve: true })"
86
+ >
87
+ Persistent toast
75
88
  </sonic-button>
76
89
  </template>
77
90
  </sonic-code>
78
91
 
79
- ## Masquer définitivement
92
+ ## Dismiss forever
80
93
 
81
- Avec `dismissForever: true` et un `id`, le toast peut être masqué définitivement. Une fois fermé, il ne réapparaîtra plus même après rechargement de la page.
94
+ With **`dismissForever`** and a stable **`id`**, closing the toast stores dismissal in **`localStorage`**—**`SonicToast.add`** skips it on later visits. Duplicate payloads (same fields, ignoring **`id`**) are not queued twice.
82
95
 
83
96
  <sonic-code>
84
97
  <template>
85
- <sonic-button onclick="window.SonicToast.add({ id: 'unique-toast-id', text: 'Ce toast peut être masqué définitivement', status: 'info', dismissForever: true })">
86
- Toast avec dismiss forever
98
+ <sonic-button
99
+ onclick="SonicToast.add({ id: 'unique-toast-id', text: 'Dismiss forever hides this across reloads', status: 'info', dismissForever: true })"
100
+ >
101
+ Dismiss forever
87
102
  </sonic-button>
88
103
  </template>
89
104
  </sonic-code>
90
105
 
91
- ## Fantôme
106
+ ## Ghost
92
107
 
93
- Avec `ghost: true`, le toast devient semi-transparent et non-interactif.
108
+ **`ghost`** renders a semi-transparent, non-interactive toast—useful for loading or background states. **`SonicToast.removeAll`** leaves ghost toasts in place.
94
109
 
95
110
  <sonic-code>
96
111
  <template>
97
- <sonic-button onclick="window.SonicToast.add({ text: 'Toast fantôme (semi-transparent)', status: 'info', ghost: true })">
98
- Toast ghost
112
+ <sonic-button
113
+ onclick="SonicToast.add({ text: 'Ghost toast (non-interactive)', status: 'info', ghost: true })"
114
+ >
115
+ Ghost toast
99
116
  </sonic-button>
100
117
  </template>
101
118
  </sonic-code>
102
119
 
120
+ ## Dismissal
103
121
 
104
- ## Méthodes de suppression
122
+ Use static helpers to clear the stack from app logic (for example after navigation).
105
123
 
106
- ### Tout supprimer
124
+ ### Remove all
107
125
 
108
- Supprime tous les toasts sauf ceux marqués comme `ghost`.
126
+ Removes every toast except **`ghost`** items.
109
127
 
110
128
  <sonic-code>
111
129
  <template>
112
130
  <div class="flex flex-wrap gap-2">
113
- <sonic-button onclick="window.SonicToast.add({ text: 'Toast 1', status: 'info' })">Ajouter toast 1</sonic-button>
114
- <sonic-button onclick="window.SonicToast.add({ text: 'Toast 2', status: 'success' })">Ajouter toast 2</sonic-button>
115
- <sonic-button onclick="window.SonicToast.add({ text: 'Toast 3', status: 'warning' })">Ajouter toast 3</sonic-button>
116
- <sonic-button onclick="window.SonicToast.removeAll()">Supprimer tous</sonic-button>
131
+ <sonic-button onclick="SonicToast.add({ text: 'Toast 1', status: 'info' })">Add toast 1</sonic-button>
132
+ <sonic-button onclick="SonicToast.add({ text: 'Toast 2', status: 'success' })">Add toast 2</sonic-button>
133
+ <sonic-button onclick="SonicToast.add({ text: 'Toast 3', status: 'warning' })">Add toast 3</sonic-button>
134
+ <sonic-button onclick="SonicToast.removeAll()">Remove all</sonic-button>
117
135
  </div>
118
136
  </template>
119
137
  </sonic-code>
120
138
 
121
- ### Supprimer par statut
122
-
123
- Supprime tous les toasts d'un statut spécifique.
139
+ ### Remove by status
124
140
 
125
141
  <sonic-code>
126
142
  <template>
127
143
  <div class="flex flex-wrap gap-2">
128
- <sonic-button onclick="window.SonicToast.add({ text: 'Toast success', status: 'success' })">Success</sonic-button>
129
- <sonic-button onclick="window.SonicToast.add({ text: 'Toast error', status: 'error' })">Error</sonic-button>
130
- <sonic-button onclick="window.SonicToast.add({ text: 'Toast warning', status: 'warning' })">Warning</sonic-button>
131
- <sonic-button onclick="window.SonicToast.removeItemsByStatus('success')">Supprimer success</sonic-button>
132
- <sonic-button onclick="window.SonicToast.removeItemsByStatus('error')">Supprimer error</sonic-button>
144
+ <sonic-button onclick="SonicToast.add({ text: 'Success toast', status: 'success' })">Success</sonic-button>
145
+ <sonic-button onclick="SonicToast.add({ text: 'Error toast', status: 'error' })">Error</sonic-button>
146
+ <sonic-button onclick="SonicToast.add({ text: 'Warning toast', status: 'warning' })">Warning</sonic-button>
147
+ <sonic-button onclick="SonicToast.removeItemsByStatus('success')">Remove success</sonic-button>
148
+ <sonic-button onclick="SonicToast.removeItemsByStatus('error')">Remove error</sonic-button>
133
149
  </div>
134
150
  </template>
135
151
  </sonic-code>
136
152
 
137
- ### Supprimer les éléments temporaires
153
+ ### Remove temporary items
138
154
 
139
- Supprime tous les toasts qui ne sont pas marqués comme `preserve`.
155
+ Removes toasts that are not **`preserve`**.
140
156
 
141
157
  <sonic-code>
142
158
  <template>
143
159
  <div class="flex flex-wrap gap-2">
144
- <sonic-button onclick="window.SonicToast.add({ text: 'Toast temporaire', status: 'info' })">Temporaire</sonic-button>
145
- <sonic-button onclick="window.SonicToast.add({ text: 'Toast persistant', status: 'success', preserve: true })">Persistant</sonic-button>
146
- <sonic-button onclick="window.SonicToast.removeTemporaryItems()">Supprimer temporaires</sonic-button>
160
+ <sonic-button onclick="SonicToast.add({ text: 'Temporary toast', status: 'info' })">Temporary</sonic-button>
161
+ <sonic-button onclick="SonicToast.add({ text: 'Persistent toast', status: 'success', preserve: true })">
162
+ Persistent
163
+ </sonic-button>
164
+ <sonic-button onclick="SonicToast.removeTemporaryItems()">Remove temporary</sonic-button>
147
165
  </div>
148
166
  </template>
149
167
  </sonic-code>
150
168
 
151
- ## Exemple complet
169
+ ## Combined options
152
170
 
153
171
  <sonic-code>
154
172
  <template>
155
- <sonic-button onclick="window.SonicToast.add({
173
+ <sonic-button
174
+ onclick="SonicToast.add({
156
175
  id: 'welcome-toast',
157
- title: 'Bienvenue',
158
- text: 'Bienvenue sur notre plateforme ! Vous pouvez commencer à explorer les fonctionnalités.',
176
+ label: 'Welcome',
177
+ text: 'Welcome to the platform. Explore the docs to get started.',
159
178
  status: 'success',
160
179
  dismissForever: true
161
- })">
162
- Toast complet
180
+ })"
181
+ >
182
+ Full example
163
183
  </sonic-button>
164
184
  </template>
165
185
  </sonic-code>
166
186
 
187
+ ## Accessibility
188
+
189
+ Each toast uses **`role="alert"`** for **`error`** and **`role="status"`** otherwise (with **`aria-live="polite"`** when applicable). Status icons are decorative (**`aria-hidden`**). The close control has an i18n **`aria-label`**. When there is no **`label`**, a truncated string **`aria-label`** may be derived from plain **`text`**.
190
+
191
+ ## API reference
192
+
193
+ Options passed to **`SonicToast.add(conf)`**:
194
+
195
+ | Option | Values | Description |
196
+ |----------|---------|-------------|
197
+ | `text` | string · Lit template | Main body; HTML strings are supported |
198
+ | `label` | string · Lit template | Optional heading above **`text`** |
199
+ | `title` | string · Lit template | Deprecated alias for **`label`** |
200
+ | `status` | `success` · `error` · `warning` · `info` · `` (empty) | Semantic styling and live region behavior |
201
+ | `id` | string · number | Stable id for deduplication and **`dismissForever`** (defaults to timestamp) |
202
+ | `preserve` | boolean | Skip auto-hide; forced when **`text`** contains interactive markup |
203
+ | `ghost` | boolean | Semi-transparent and non-interactive; kept by **`removeAll`** |
204
+ | `dismissForever` | boolean | Persist dismissal in **`localStorage`** when closed (requires stable **`id`**) |
205
+ | `styleSheet` | modal style input | Extra adopted styles on the toast item shadow root |
206
+ | `useSlot` | boolean | Legacy: project **`text`** into the light DOM slot |
207
+
208
+ | Method | Description |
209
+ |--------|-------------|
210
+ | `SonicToast.add(conf)` | Append a toast; returns the config or **`null`** if skipped (dismissed forever or duplicate) |
211
+ | `SonicToast.removeAll()` | Remove all non-**`ghost`** toasts |
212
+ | `SonicToast.removeItemsByStatus(status)` | Remove toasts matching **`status`** |
213
+ | `SonicToast.removeItemById(id)` | Remove a single toast by **`id`** |
214
+ | `SonicToast.removeTemporaryItems()` | Remove toasts without **`preserve`** |
215
+
216
+ **`sonic-toast`** is mounted automatically; **`sonic-toast-item`** is internal. In iframes, toasts can delegate to the parent window via **`postMessage`**.
@@ -3,7 +3,7 @@ import { TemplateResult } from "lit";
3
3
  import { DirectiveResult } from "lit/directive.js";
4
4
  import { ModalStyleSheetInput } from "@supersoniks/concorde/core/components/ui/modal/modal-utils";
5
5
 
6
- export type ToastStatus = Message["status"] | "" | "success";
6
+ export type ToastStatus = Message["status"] | "" | "default";
7
7
 
8
8
  export type ToastContent = string | TemplateResult | DirectiveResult;
9
9