@f-ewald/components 1.25.0 → 1.27.0

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 (51) hide show
  1. package/README.md +7 -3
  2. package/custom-elements.json +1390 -181
  3. package/dist/calendar-day.d.ts +33 -0
  4. package/dist/calendar-day.d.ts.map +1 -0
  5. package/dist/calendar-day.js +280 -0
  6. package/dist/calendar-day.js.map +1 -0
  7. package/dist/calendar-timeline-base.d.ts +43 -0
  8. package/dist/calendar-timeline-base.d.ts.map +1 -0
  9. package/dist/calendar-timeline-base.js +113 -0
  10. package/dist/calendar-timeline-base.js.map +1 -0
  11. package/dist/calendar-week.d.ts +37 -0
  12. package/dist/calendar-week.d.ts.map +1 -0
  13. package/dist/calendar-week.js +315 -0
  14. package/dist/calendar-week.js.map +1 -0
  15. package/dist/comment-composer.d.ts +15 -1
  16. package/dist/comment-composer.d.ts.map +1 -1
  17. package/dist/comment-composer.js +25 -3
  18. package/dist/comment-composer.js.map +1 -1
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +3 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/modal-dialog.d.ts +49 -0
  24. package/dist/modal-dialog.d.ts.map +1 -0
  25. package/dist/modal-dialog.js +287 -0
  26. package/dist/modal-dialog.js.map +1 -0
  27. package/dist/toast-notification.d.ts +14 -0
  28. package/dist/toast-notification.d.ts.map +1 -1
  29. package/dist/toast-notification.js +23 -8
  30. package/dist/toast-notification.js.map +1 -1
  31. package/dist/tokens.css +15 -3
  32. package/dist/tokens.d.ts +9 -8
  33. package/dist/tokens.d.ts.map +1 -1
  34. package/dist/tokens.js +43 -15
  35. package/dist/tokens.js.map +1 -1
  36. package/dist/ui-button.d.ts +2 -0
  37. package/dist/ui-button.d.ts.map +1 -1
  38. package/dist/ui-button.js +9 -1
  39. package/dist/ui-button.js.map +1 -1
  40. package/dist/utils/calendar.d.ts +41 -0
  41. package/dist/utils/calendar.d.ts.map +1 -1
  42. package/dist/utils/calendar.js +74 -0
  43. package/dist/utils/calendar.js.map +1 -1
  44. package/docs/calendar-day.md +70 -0
  45. package/docs/calendar-week.md +69 -0
  46. package/docs/comment-composer.md +5 -1
  47. package/docs/modal-dialog.md +66 -0
  48. package/docs/toast-notification.md +23 -0
  49. package/docs/ui-button.md +1 -0
  50. package/llms.txt +108 -3
  51. package/package.json +1 -1
@@ -0,0 +1,49 @@
1
+ import { LitElement, type PropertyValues } from "lit";
2
+ export type ModalDialogSize = "default" | "lg" | "fullscreen";
3
+ /**
4
+ * Generic centered modal-dialog shell: overlay + card with header chrome, a
5
+ * close button, and an arbitrary slotted body — the modal sibling to
6
+ * `slide-panel` (fixed-edge) and `popover-panel` (anchored). Unlike
7
+ * `confirm-dialog`, it has no baked-in actions; the consumer supplies the
8
+ * body content (a form, a read-only viewer, a table) and any footer buttons
9
+ * itself. Instant `display:none` → `display:flex` toggle, no transition.
10
+ * Traps focus, closes on Escape, and restores focus to the trigger on
11
+ * close, stacking correctly against other open `confirm-dialog`/
12
+ * `slide-panel`/`popover-panel`/`modal-dialog` layers.
13
+ *
14
+ * @element modal-dialog
15
+ * @fires panel-close - User clicked the close (✕) button, pressed Escape, or (when `dismissible`) clicked the backdrop.
16
+ * @slot - Dialog body content.
17
+ * @slot title - Overrides the header title text (falls back to the `heading` property).
18
+ */
19
+ export declare class ModalDialog extends LitElement {
20
+ static styles: import("lit").CSSResult[];
21
+ /** Whether the dialog is visible. */
22
+ open: boolean;
23
+ /** Title text shown in the dialog header (overridable via slot="title"). */
24
+ heading: string;
25
+ /**
26
+ * `"lg"` widens the dialog to 60rem for content like tables; `"default"`
27
+ * is 25rem; `"fullscreen"` covers the entire viewport edge-to-edge with
28
+ * no border-radius or overlay padding.
29
+ */
30
+ size: ModalDialogSize;
31
+ /** When true, clicking the backdrop also closes the dialog (off by default — safe for forms with unsaved input). */
32
+ dismissible: boolean;
33
+ private _previousFocus;
34
+ private _close;
35
+ private _getFocusableElements;
36
+ private _focusInitial;
37
+ private _onDocumentFocusIn;
38
+ private _onWindowKeydown;
39
+ private _onOverlayClick;
40
+ protected updated(changed: PropertyValues): void;
41
+ disconnectedCallback(): void;
42
+ render(): import("lit-html").TemplateResult<1>;
43
+ }
44
+ declare global {
45
+ interface HTMLElementTagNameMap {
46
+ "modal-dialog": ModalDialog;
47
+ }
48
+ }
49
+ //# sourceMappingURL=modal-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-dialog.d.ts","sourceRoot":"","sources":["../src/modal-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAM1E,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,IAAI,GAAG,YAAY,CAAC;AAE9D;;;;;;;;;;;;;;;GAeG;AACH,qBACa,WAAY,SAAQ,UAAU;IACzC,OAAgB,MAAM,4BAoHpB;IAEF,qCAAqC;IACR,IAAI,UAAS;IAC1C,4EAA4E;IAChE,OAAO,SAAM;IACzB;;;;OAIG;IACS,IAAI,EAAE,eAAe,CAAa;IAC9C,oHAAoH;IACvF,WAAW,UAAS;IAEjD,OAAO,CAAC,cAAc,CAA4B;IAElD,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,kBAAkB,CAGxB;IAEF,OAAO,CAAC,gBAAgB,CAuBtB;IAEF,OAAO,CAAC,eAAe,CAErB;IAEF,UAAmB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAexD;IAEQ,oBAAoB,IAAI,IAAI,CAQpC;IAEQ,MAAM,yCA6Bd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,WAAW,CAAC;KAC7B;CACF"}
@@ -0,0 +1,287 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LitElement, css, html, nothing } from "lit";
8
+ import { customElement, property } from "lit/decorators.js";
9
+ import { iconX } from "./icons.js";
10
+ import { tokens } from "./tokens.js";
11
+ import { activateLayer, claimEscape, deactivateLayer, isTopLayer } from "./utils/layer-stack.js";
12
+ /**
13
+ * Generic centered modal-dialog shell: overlay + card with header chrome, a
14
+ * close button, and an arbitrary slotted body — the modal sibling to
15
+ * `slide-panel` (fixed-edge) and `popover-panel` (anchored). Unlike
16
+ * `confirm-dialog`, it has no baked-in actions; the consumer supplies the
17
+ * body content (a form, a read-only viewer, a table) and any footer buttons
18
+ * itself. Instant `display:none` → `display:flex` toggle, no transition.
19
+ * Traps focus, closes on Escape, and restores focus to the trigger on
20
+ * close, stacking correctly against other open `confirm-dialog`/
21
+ * `slide-panel`/`popover-panel`/`modal-dialog` layers.
22
+ *
23
+ * @element modal-dialog
24
+ * @fires panel-close - User clicked the close (✕) button, pressed Escape, or (when `dismissible`) clicked the backdrop.
25
+ * @slot - Dialog body content.
26
+ * @slot title - Overrides the header title text (falls back to the `heading` property).
27
+ */
28
+ let ModalDialog = class ModalDialog extends LitElement {
29
+ constructor() {
30
+ super(...arguments);
31
+ /** Whether the dialog is visible. */
32
+ this.open = false;
33
+ /** Title text shown in the dialog header (overridable via slot="title"). */
34
+ this.heading = "";
35
+ /**
36
+ * `"lg"` widens the dialog to 60rem for content like tables; `"default"`
37
+ * is 25rem; `"fullscreen"` covers the entire viewport edge-to-edge with
38
+ * no border-radius or overlay padding.
39
+ */
40
+ this.size = "default";
41
+ /** When true, clicking the backdrop also closes the dialog (off by default — safe for forms with unsaved input). */
42
+ this.dismissible = false;
43
+ this._previousFocus = null;
44
+ this._onDocumentFocusIn = (event) => {
45
+ if (!this.open || !isTopLayer(this) || event.composedPath().includes(this))
46
+ return;
47
+ this._focusInitial();
48
+ };
49
+ this._onWindowKeydown = (event) => {
50
+ if (!this.open || !isTopLayer(this))
51
+ return;
52
+ if (claimEscape(this, event)) {
53
+ this._close();
54
+ return;
55
+ }
56
+ if (event.key !== "Tab")
57
+ return;
58
+ const focusable = this._getFocusableElements();
59
+ if (focusable.length === 0) {
60
+ event.preventDefault();
61
+ this._focusInitial();
62
+ return;
63
+ }
64
+ const active = (this.shadowRoot?.activeElement ?? document.activeElement);
65
+ const index = focusable.indexOf(active);
66
+ if (event.shiftKey && index <= 0) {
67
+ event.preventDefault();
68
+ focusable.at(-1)?.focus();
69
+ }
70
+ else if (!event.shiftKey && index === focusable.length - 1) {
71
+ event.preventDefault();
72
+ focusable[0]?.focus();
73
+ }
74
+ };
75
+ this._onOverlayClick = (event) => {
76
+ if (this.dismissible && event.target === event.currentTarget)
77
+ this._close();
78
+ };
79
+ }
80
+ static { this.styles = [
81
+ tokens,
82
+ css `
83
+ .overlay {
84
+ position: fixed;
85
+ inset: 0;
86
+ background: var(--ui-overlay, rgb(15 23 42 / 0.45));
87
+ z-index: var(--component-layer-z, 50);
88
+ display: none;
89
+ align-items: flex-start;
90
+ justify-content: center;
91
+ padding: 10vh 1.25rem 1.25rem;
92
+ box-sizing: border-box;
93
+ }
94
+ .overlay.open {
95
+ display: flex;
96
+ }
97
+ .overlay.fullscreen {
98
+ padding: 0;
99
+ align-items: stretch;
100
+ }
101
+ .dialog {
102
+ background: var(--ui-surface, #ffffff);
103
+ border-radius: var(--ui-radius, 0.5rem);
104
+ box-shadow: var(
105
+ --ui-shadow-lg,
106
+ 0 20px 25px -5px rgb(0 0 0 / 0.1),
107
+ 0 8px 10px -6px rgb(0 0 0 / 0.1)
108
+ );
109
+ width: 100%;
110
+ max-width: min(25rem, calc(100vw - 2rem));
111
+ max-height: calc(100vh - 10vh - 1.25rem);
112
+ display: flex;
113
+ flex-direction: column;
114
+ overflow: hidden;
115
+ box-sizing: border-box;
116
+ outline: none;
117
+ }
118
+ .dialog.lg {
119
+ max-width: min(60rem, calc(100vw - 2rem));
120
+ }
121
+ .dialog.fullscreen {
122
+ width: 100vw;
123
+ height: 100vh;
124
+ max-width: 100vw;
125
+ max-height: 100vh;
126
+ border-radius: 0;
127
+ }
128
+ .dialog-header {
129
+ display: flex;
130
+ align-items: center;
131
+ justify-content: space-between;
132
+ padding: 0.75rem;
133
+ border-bottom: 1px solid var(--ui-border, #e2e8f0);
134
+ flex: 0 0 auto;
135
+ }
136
+ .dialog-title {
137
+ font-weight: var(--ui-font-weight-semibold, 600);
138
+ font-size: var(--ui-font-size-lg, 1rem);
139
+ line-height: var(--ui-line-height-tight, 1.25);
140
+ font-family: var(
141
+ --ui-font,
142
+ ui-sans-serif,
143
+ system-ui,
144
+ sans-serif,
145
+ "Apple Color Emoji",
146
+ "Segoe UI Emoji",
147
+ "Segoe UI Symbol",
148
+ "Noto Color Emoji"
149
+ );
150
+ color: var(--ui-text, #0f172a);
151
+ flex: 1 1 auto;
152
+ overflow: hidden;
153
+ white-space: nowrap;
154
+ text-overflow: ellipsis;
155
+ padding-right: 0.5rem;
156
+ }
157
+ .close-btn {
158
+ background: none;
159
+ border: none;
160
+ cursor: pointer;
161
+ width: 2rem;
162
+ height: 2rem;
163
+ padding: 0;
164
+ color: var(--ui-text-muted, #64748b);
165
+ border-radius: var(--ui-radius-sm, 0.25rem);
166
+ flex: 0 0 auto;
167
+ display: inline-flex;
168
+ align-items: center;
169
+ justify-content: center;
170
+ }
171
+ .close-btn:hover {
172
+ background: var(--ui-surface-muted, #f8fafc);
173
+ }
174
+ .close-btn:focus-visible {
175
+ outline: none;
176
+ box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
177
+ }
178
+ .body {
179
+ overflow-y: auto;
180
+ flex: 1 1 auto;
181
+ }
182
+ @media (forced-colors: active) {
183
+ .close-btn:focus-visible {
184
+ outline: 2px solid CanvasText;
185
+ outline-offset: 2px;
186
+ box-shadow: none;
187
+ }
188
+ }
189
+ @media (max-width: 48rem) {
190
+ .overlay {
191
+ padding: 0.75rem;
192
+ overflow-y: auto;
193
+ }
194
+ }
195
+ `,
196
+ ]; }
197
+ _close() {
198
+ this.dispatchEvent(new CustomEvent("panel-close", { bubbles: true, composed: true }));
199
+ }
200
+ _getFocusableElements() {
201
+ const selector = "a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])";
202
+ const slotted = Array.from(this.querySelectorAll(selector));
203
+ const internal = Array.from(this.shadowRoot?.querySelectorAll(selector) ?? []).filter((element) => element.closest(".dialog") !== null);
204
+ return [...slotted, ...internal].filter((element) => !element.hasAttribute("hidden"));
205
+ }
206
+ _focusInitial() {
207
+ const autofocus = this.querySelector("[autofocus]");
208
+ const close = this.shadowRoot?.querySelector(".close-btn");
209
+ const dialog = this.shadowRoot?.querySelector(".dialog");
210
+ (autofocus ?? close ?? this._getFocusableElements()[0] ?? dialog)?.focus();
211
+ }
212
+ updated(changed) {
213
+ if (!changed.has("open"))
214
+ return;
215
+ if (this.open) {
216
+ activateLayer(this);
217
+ this._previousFocus = document.activeElement;
218
+ document.addEventListener("focusin", this._onDocumentFocusIn, true);
219
+ window.addEventListener("keydown", this._onWindowKeydown, true);
220
+ this._focusInitial();
221
+ return;
222
+ }
223
+ deactivateLayer(this);
224
+ document.removeEventListener("focusin", this._onDocumentFocusIn, true);
225
+ window.removeEventListener("keydown", this._onWindowKeydown, true);
226
+ if (this._previousFocus?.isConnected)
227
+ this._previousFocus.focus();
228
+ this._previousFocus = null;
229
+ }
230
+ disconnectedCallback() {
231
+ super.disconnectedCallback();
232
+ document.removeEventListener("focusin", this._onDocumentFocusIn, true);
233
+ window.removeEventListener("keydown", this._onWindowKeydown, true);
234
+ deactivateLayer(this);
235
+ if (this._previousFocus?.isConnected)
236
+ this._previousFocus.focus();
237
+ this._previousFocus = null;
238
+ this.open = false;
239
+ }
240
+ render() {
241
+ const explicitLabel = this.getAttribute("aria-label");
242
+ return html `
243
+ <div
244
+ class="overlay ${this.open ? "open" : ""} ${this.size === "fullscreen" ? "fullscreen" : ""}"
245
+ @click=${this._onOverlayClick}
246
+ >
247
+ <div
248
+ class="dialog ${this.size === "lg" ? "lg" : this.size === "fullscreen" ? "fullscreen" : ""}"
249
+ role="dialog"
250
+ aria-modal="true"
251
+ aria-label=${explicitLabel ?? nothing}
252
+ aria-labelledby=${explicitLabel ? nothing : "dialog-title"}
253
+ tabindex="-1"
254
+ >
255
+ <div class="dialog-header">
256
+ <span id="dialog-title" class="dialog-title">
257
+ <slot name="title">${this.heading}</slot>
258
+ </span>
259
+ <button class="close-btn" aria-label="Close" @click=${this._close}>
260
+ <span aria-hidden="true">${iconX(18)}</span>
261
+ </button>
262
+ </div>
263
+ <div class="body">
264
+ <slot></slot>
265
+ </div>
266
+ </div>
267
+ </div>
268
+ `;
269
+ }
270
+ };
271
+ __decorate([
272
+ property({ type: Boolean })
273
+ ], ModalDialog.prototype, "open", void 0);
274
+ __decorate([
275
+ property()
276
+ ], ModalDialog.prototype, "heading", void 0);
277
+ __decorate([
278
+ property()
279
+ ], ModalDialog.prototype, "size", void 0);
280
+ __decorate([
281
+ property({ type: Boolean })
282
+ ], ModalDialog.prototype, "dismissible", void 0);
283
+ ModalDialog = __decorate([
284
+ customElement("modal-dialog")
285
+ ], ModalDialog);
286
+ export { ModalDialog };
287
+ //# sourceMappingURL=modal-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-dialog.js","sourceRoot":"","sources":["../src/modal-dialog.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E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,EAAE;iBACjF,IAAI,CAAC,eAAe;;;0BAGX,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;;;uBAG7E,aAAa,IAAI,OAAO;4BACnB,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc;;;;;mCAKjC,IAAI,CAAC,OAAO;;kEAEmB,IAAI,CAAC,MAAM;yCACpC,KAAK,CAAC,EAAE,CAAC;;;;;;;;KAQ7C,CAAC;IACJ,CAAC;CACF,CAAA;AA9H8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAc;AAE9B;IAAX,QAAQ,EAAE;4CAAc;AAMb;IAAX,QAAQ,EAAE;yCAAmC;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAqB;AAlItC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAsPvB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconX } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport { activateLayer, claimEscape, deactivateLayer, isTopLayer } from \"./utils/layer-stack.js\";\n\nexport type ModalDialogSize = \"default\" | \"lg\" | \"fullscreen\";\n\n/**\n * Generic centered modal-dialog shell: overlay + card with header chrome, a\n * close button, and an arbitrary slotted body — the modal sibling to\n * `slide-panel` (fixed-edge) and `popover-panel` (anchored). Unlike\n * `confirm-dialog`, it has no baked-in actions; the consumer supplies the\n * body content (a form, a read-only viewer, a table) and any footer buttons\n * itself. Instant `display:none` → `display:flex` toggle, no transition.\n * Traps focus, closes on Escape, and restores focus to the trigger on\n * close, stacking correctly against other open `confirm-dialog`/\n * `slide-panel`/`popover-panel`/`modal-dialog` layers.\n *\n * @element modal-dialog\n * @fires panel-close - User clicked the close (✕) button, pressed Escape, or (when `dismissible`) clicked the backdrop.\n * @slot - Dialog body content.\n * @slot title - Overrides the header title text (falls back to the `heading` property).\n */\n@customElement(\"modal-dialog\")\nexport class ModalDialog extends LitElement {\n static override styles = [\n tokens,\n css`\n .overlay {\n position: fixed;\n inset: 0;\n background: var(--ui-overlay, rgb(15 23 42 / 0.45));\n z-index: var(--component-layer-z, 50);\n display: none;\n align-items: flex-start;\n justify-content: center;\n padding: 10vh 1.25rem 1.25rem;\n box-sizing: border-box;\n }\n .overlay.open {\n display: flex;\n }\n .overlay.fullscreen {\n padding: 0;\n align-items: stretch;\n }\n .dialog {\n background: var(--ui-surface, #ffffff);\n border-radius: var(--ui-radius, 0.5rem);\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n );\n width: 100%;\n max-width: min(25rem, calc(100vw - 2rem));\n max-height: calc(100vh - 10vh - 1.25rem);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n box-sizing: border-box;\n outline: none;\n }\n .dialog.lg {\n max-width: min(60rem, calc(100vw - 2rem));\n }\n .dialog.fullscreen {\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n border-radius: 0;\n }\n .dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0.75rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n flex: 0 0 auto;\n }\n .dialog-title {\n font-weight: var(--ui-font-weight-semibold, 600);\n font-size: var(--ui-font-size-lg, 1rem);\n line-height: var(--ui-line-height-tight, 1.25);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n color: var(--ui-text, #0f172a);\n flex: 1 1 auto;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n padding-right: 0.5rem;\n }\n .close-btn {\n background: none;\n border: none;\n cursor: pointer;\n width: 2rem;\n height: 2rem;\n padding: 0;\n color: var(--ui-text-muted, #64748b);\n border-radius: var(--ui-radius-sm, 0.25rem);\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n .close-btn:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .close-btn:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .body {\n overflow-y: auto;\n flex: 1 1 auto;\n }\n @media (forced-colors: active) {\n .close-btn:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n .overlay {\n padding: 0.75rem;\n overflow-y: auto;\n }\n }\n `,\n ];\n\n /** Whether the dialog is visible. */\n @property({ type: Boolean }) open = false;\n /** Title text shown in the dialog header (overridable via slot=\"title\"). */\n @property() heading = \"\";\n /**\n * `\"lg\"` widens the dialog to 60rem for content like tables; `\"default\"`\n * is 25rem; `\"fullscreen\"` covers the entire viewport edge-to-edge with\n * no border-radius or overlay padding.\n */\n @property() size: ModalDialogSize = \"default\";\n /** When true, clicking the backdrop also closes the dialog (off by default — safe for forms with unsaved input). */\n @property({ type: Boolean }) dismissible = false;\n\n private _previousFocus: HTMLElement | null = null;\n\n private _close() {\n this.dispatchEvent(new CustomEvent(\"panel-close\", { bubbles: true, composed: true }));\n }\n\n private _getFocusableElements(): HTMLElement[] {\n const selector =\n \"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])\";\n const slotted = Array.from(this.querySelectorAll<HTMLElement>(selector));\n const internal = Array.from(\n this.shadowRoot?.querySelectorAll<HTMLElement>(selector) ?? [],\n ).filter((element) => element.closest(\".dialog\") !== null);\n return [...slotted, ...internal].filter((element) => !element.hasAttribute(\"hidden\"));\n }\n\n private _focusInitial(): void {\n const autofocus = this.querySelector<HTMLElement>(\"[autofocus]\");\n const close = this.shadowRoot?.querySelector<HTMLElement>(\".close-btn\");\n const dialog = this.shadowRoot?.querySelector<HTMLElement>(\".dialog\");\n (autofocus ?? close ?? this._getFocusableElements()[0] ?? dialog)?.focus();\n }\n\n private _onDocumentFocusIn = (event: FocusEvent): void => {\n if (!this.open || !isTopLayer(this) || event.composedPath().includes(this)) return;\n this._focusInitial();\n };\n\n private _onWindowKeydown = (event: KeyboardEvent): void => {\n if (!this.open || !isTopLayer(this)) return;\n if (claimEscape(this, event)) {\n this._close();\n return;\n }\n if (event.key !== \"Tab\") return;\n\n const focusable = this._getFocusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n this._focusInitial();\n return;\n }\n const active = (this.shadowRoot?.activeElement ?? document.activeElement) as HTMLElement | null;\n const index = focusable.indexOf(active as HTMLElement);\n if (event.shiftKey && index <= 0) {\n event.preventDefault();\n focusable.at(-1)?.focus();\n } else if (!event.shiftKey && index === focusable.length - 1) {\n event.preventDefault();\n focusable[0]?.focus();\n }\n };\n\n private _onOverlayClick = (event: MouseEvent): void => {\n if (this.dismissible && event.target === event.currentTarget) this._close();\n };\n\n protected override updated(changed: PropertyValues): void {\n if (!changed.has(\"open\")) return;\n if (this.open) {\n activateLayer(this);\n this._previousFocus = document.activeElement as HTMLElement | null;\n document.addEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.addEventListener(\"keydown\", this._onWindowKeydown, true);\n this._focusInitial();\n return;\n }\n deactivateLayer(this);\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n deactivateLayer(this);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n this.open = false;\n }\n\n override render() {\n const explicitLabel = this.getAttribute(\"aria-label\");\n return html`\n <div\n class=\"overlay ${this.open ? \"open\" : \"\"} ${this.size === \"fullscreen\" ? \"fullscreen\" : \"\"}\"\n @click=${this._onOverlayClick}\n >\n <div\n class=\"dialog ${this.size === \"lg\" ? \"lg\" : this.size === \"fullscreen\" ? \"fullscreen\" : \"\"}\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${explicitLabel ?? nothing}\n aria-labelledby=${explicitLabel ? nothing : \"dialog-title\"}\n tabindex=\"-1\"\n >\n <div class=\"dialog-header\">\n <span id=\"dialog-title\" class=\"dialog-title\">\n <slot name=\"title\">${this.heading}</slot>\n </span>\n <button class=\"close-btn\" aria-label=\"Close\" @click=${this._close}>\n <span aria-hidden=\"true\">${iconX(18)}</span>\n </button>\n </div>\n <div class=\"body\">\n <slot></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"modal-dialog\": ModalDialog;\n }\n}\n"]}
@@ -26,6 +26,20 @@ interface ToastOptions {
26
26
  * auto-dismisses after `duration` ms and can also be dismissed via its ✕
27
27
  * button. Appears/disappears instantly — no slide/fade transitions.
28
28
  *
29
+ * Each variant's background reads a dedicated `--ui-toast-*-background` hook
30
+ * (`success`/`error`/`info`/`warning`), which defaults to the flat
31
+ * `--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
32
+ * so those stay the single source of truth for every other component. A
33
+ * consumer can override just these toast-specific tokens with a
34
+ * `linear-gradient(...)` to opt every toast into a gradient look without
35
+ * touching component markup — `gradientTokenValues` in `tokens.ts` ships
36
+ * exactly this, wired up via `data-theme="gradient"` (see `tokens.css`'s
37
+ * "Gradient theme" section), the same mechanism `ui-button` uses.
38
+ * `--ui-toast-highlight` (a glossy top-edge box-shadow, layered onto the
39
+ * existing elevation shadow) and `--ui-toast-text-shadow` (legibility
40
+ * against the gradient's lighter stop) round out the effect, mirroring
41
+ * `ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.
42
+ *
29
43
  * @element toast-notification
30
44
  */
31
45
  export declare class ToastNotification extends LitElement {
@@ -1 +1 @@
1
- {"version":3,"file":"toast-notification.d.ts","sourceRoot":"","sources":["../src/toast-notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,OAAO,EAAE,MAAM,KAAK,CAAC;AAWrD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpE,UAAU,YAAY;IACpB,uEAAuE;IACvE,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAWD;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,iBAAkB,SAAQ,UAAU;IACtC,OAAO,CAAC,OAAO,CAAe;IAEvC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAoD;IAEnE,OAAgB,MAAM,4BAyHpB;IAEF;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CAYxD;IAED;;;OAGG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,QAOjB;IAEQ,oBAAoB,SAI5B;IAED;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAaX,MAAM,0DAsBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,iBAAiB,CAAC;KACzC;CACF;AAMD,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,QAEhE;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,E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;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,QAElE;AAED,2BAA2B;AAC3B,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,QAE/D;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,QAElE"}
@@ -24,6 +24,20 @@ const DEFAULT_DURATION_MS = 5000;
24
24
  * auto-dismisses after `duration` ms and can also be dismissed via its ✕
25
25
  * button. Appears/disappears instantly — no slide/fade transitions.
26
26
  *
27
+ * Each variant's background reads a dedicated `--ui-toast-*-background` hook
28
+ * (`success`/`error`/`info`/`warning`), which defaults to the flat
29
+ * `--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
30
+ * so those stay the single source of truth for every other component. A
31
+ * consumer can override just these toast-specific tokens with a
32
+ * `linear-gradient(...)` to opt every toast into a gradient look without
33
+ * touching component markup — `gradientTokenValues` in `tokens.ts` ships
34
+ * exactly this, wired up via `data-theme="gradient"` (see `tokens.css`'s
35
+ * "Gradient theme" section), the same mechanism `ui-button` uses.
36
+ * `--ui-toast-highlight` (a glossy top-edge box-shadow, layered onto the
37
+ * existing elevation shadow) and `--ui-toast-text-shadow` (legibility
38
+ * against the gradient's lighter stop) round out the effect, mirroring
39
+ * `ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.
40
+ *
27
41
  * @element toast-notification
28
42
  */
29
43
  let ToastNotification = class ToastNotification extends LitElement {
@@ -55,10 +69,10 @@ let ToastNotification = class ToastNotification extends LitElement {
55
69
  border-radius: var(--ui-radius, 0.5rem);
56
70
  padding: 0.75rem;
57
71
  box-shadow: var(
58
- --ui-shadow-lg,
59
- 0 20px 25px -5px rgb(0 0 0 / 0.1),
60
- 0 8px 10px -6px rgb(0 0 0 / 0.1)
61
- );
72
+ --ui-shadow-lg,
73
+ 0 20px 25px -5px rgb(0 0 0 / 0.1),
74
+ 0 8px 10px -6px rgb(0 0 0 / 0.1)
75
+ ), var(--ui-toast-highlight, 0 0 0 0 transparent);
62
76
  font-family: var(
63
77
  --ui-font,
64
78
  ui-sans-serif,
@@ -73,18 +87,19 @@ let ToastNotification = class ToastNotification extends LitElement {
73
87
  line-height: var(--ui-line-height-normal, 1.5);
74
88
  color: var(--ui-on-accent, #ffffff);
75
89
  background: var(--ui-text, #0f172a);
90
+ text-shadow: var(--ui-toast-text-shadow, none);
76
91
  }
77
92
  .toast.error {
78
- background: var(--ui-danger, #dc2626);
93
+ background: var(--ui-toast-error-background, var(--ui-danger, #dc2626));
79
94
  }
80
95
  .toast.success {
81
- background: var(--ui-success, #16a34a);
96
+ background: var(--ui-toast-success-background, var(--ui-success, #16a34a));
82
97
  }
83
98
  .toast.info {
84
- background: var(--ui-info, #0ea5e9);
99
+ background: var(--ui-toast-info-background, var(--ui-info, #0ea5e9));
85
100
  }
86
101
  .toast.warning {
87
- background: var(--ui-warning, #d97706);
102
+ background: var(--ui-toast-warning-background, var(--ui-warning, #d97706));
88
103
  }
89
104
  .icon {
90
105
  flex: 0 0 auto;
@@ -1 +1 @@
1
- {"version":3,"file":"toast-notification.js","sourceRoot":"","sources":["../src/toast-notification.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,QAAQ,EACR,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAuBrC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBA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AC,OAAO;;6EAEpB,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;yCAC5D,KAAK,CAAC,EAAE,CAAC;;;SAGzC,CACF;KACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhNkB;IAAhB,KAAK,EAAE;kDAA+B;AAD5B,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,CAiN7B;;AAQD,SAAS,QAAQ;IACf,OAAO,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,WAAoB;IAC/D,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,WAAoB;IACjE,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,2BAA2B;AAC3B,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,WAAoB;IAC9D,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,WAAoB;IACjE,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, state } from \"lit/decorators.js\";\nimport {\n iconCheckCircle,\n iconExclamationCircle,\n iconExclamationTriangle,\n iconInfo,\n iconX,\n} from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport type ToastVariant = \"error\" | \"info\" | \"success\" | \"warning\";\n\ninterface ToastOptions {\n /** Visual style; also selects the accent color. Defaults to \"info\". */\n variant?: ToastVariant;\n /** Auto-dismiss delay in ms. Pass 0 to require a manual close. Defaults to 5000. */\n duration?: number;\n /**\n * Optional secondary line shown beneath the headline in smaller, non-bold\n * type. Omit for a single-line toast.\n */\n description?: string;\n}\n\ninterface Toast {\n id: number;\n message: string;\n variant: ToastVariant;\n description?: string;\n}\n\nconst DEFAULT_DURATION_MS = 5000;\n\n/**\n * Fixed-position stack of dismissible notifications, anchored top-right\n * (top-full-width on mobile). Every toast shares one fixed width so entries\n * never appear narrower or wider than one another. Not wired to any app state\n * yet — callers add toasts imperatively via the `show()` method on a live\n * element reference,\n * e.g. `document.querySelector('toast-notification')?.show('Offline', { variant: 'error' })`,\n * or via the `notifySuccess`/`notifyError`/`notifyInfo` module-level helpers\n * exported from this file. The first argument is the required bold headline; an\n * optional `description` renders a smaller, non-bold second line. Each variant\n * leads with a matching status icon (success → check, error → exclamation\n * circle, info → information circle, warning → exclamation triangle). Each toast\n * auto-dismisses after `duration` ms and can also be dismissed via its ✕\n * button. Appears/disappears instantly — no slide/fade transitions.\n *\n * @element toast-notification\n */\n@customElement(\"toast-notification\")\nexport class ToastNotification extends LitElement {\n @state() private _toasts: Toast[] = [];\n\n private _nextId = 0;\n private _timers = new Map<number, ReturnType<typeof setTimeout>>();\n\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n top: 1rem;\n right: 1rem;\n z-index: 200;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n width: 22.5rem;\n pointer-events: none;\n }\n .toast {\n pointer-events: auto;\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n border-radius: var(--ui-radius, 0.5rem);\n padding: 0.75rem;\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n );\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-on-accent, #ffffff);\n background: var(--ui-text, #0f172a);\n }\n .toast.error {\n background: var(--ui-danger, #dc2626);\n }\n .toast.success {\n background: var(--ui-success, #16a34a);\n }\n .toast.info {\n background: var(--ui-info, #0ea5e9);\n }\n .toast.warning {\n background: var(--ui-warning, #d97706);\n }\n .icon {\n flex: 0 0 auto;\n margin-top: 0.125rem;\n line-height: var(--ui-line-height-glyph, 1);\n }\n .content {\n flex: 1 1 auto;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n .message {\n font-weight: var(--ui-font-weight-semibold, 600);\n word-break: break-word;\n }\n .description {\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-normal, 1.5);\n word-break: break-word;\n }\n .close {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n background: none;\n border: none;\n padding: 0;\n margin: -0.25rem -0.25rem -0.25rem 0;\n color: inherit;\n opacity: 0.8;\n cursor: pointer;\n line-height: var(--ui-line-height-glyph, 1);\n border-radius: var(--ui-radius-sm, 0.25rem);\n }\n .close:hover {\n opacity: 1;\n background: var(--ui-hover-overlay, rgb(255 255 255 / 0.32));\n }\n .close:focus-visible {\n outline: none;\n opacity: 1;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (forced-colors: active) {\n .toast {\n border: 1px solid CanvasText;\n forced-color-adjust: auto;\n }\n .close:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n :host {\n top: 0.75rem;\n right: 0.75rem;\n left: 0.75rem;\n width: auto;\n }\n }\n `,\n ];\n\n /**\n * Queues a toast for display.\n * @param message Text to show.\n * @param options Variant + auto-dismiss duration (see {@link ToastOptions}).\n * @returns The toast's id — pass to `dismiss()` to remove it early.\n */\n show(message: string, options: ToastOptions = {}): number {\n const id = this._nextId++;\n const variant = options.variant ?? \"info\";\n const duration = options.duration ?? DEFAULT_DURATION_MS;\n this._toasts = [...this._toasts, { id, message, variant, description: options.description }];\n if (duration > 0) {\n this._timers.set(\n id,\n setTimeout(() => this.dismiss(id), duration),\n );\n }\n return id;\n }\n\n /**\n * Removes a toast immediately, cancelling its pending auto-dismiss timer if any.\n * @param id The id returned by `show()`.\n */\n dismiss(id: number) {\n const timer = this._timers.get(id);\n if (timer) {\n clearTimeout(timer);\n this._timers.delete(id);\n }\n this._toasts = this._toasts.filter((t) => t.id !== id);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n for (const timer of this._timers.values()) clearTimeout(timer);\n this._timers.clear();\n }\n\n /**\n * Returns the decorative status icon for a variant, sized as a standalone\n * 18px glyph to match the dismiss button.\n * @param variant The toast variant.\n */\n private _variantIcon(variant: ToastVariant) {\n switch (variant) {\n case \"success\":\n return iconCheckCircle(18);\n case \"error\":\n return iconExclamationCircle(18);\n case \"warning\":\n return iconExclamationTriangle(18);\n default:\n return iconInfo(18);\n }\n }\n\n override render() {\n if (this._toasts.length === 0) return nothing;\n return html`\n ${this._toasts.map(\n (t) => html`\n <div\n class=\"toast ${t.variant}\"\n role=${t.variant === \"error\" ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n >\n <span class=\"icon\" aria-hidden=\"true\">${this._variantIcon(t.variant)}</span>\n <div class=\"content\">\n <span class=\"message\">${t.message}</span>\n ${t.description ? html`<span class=\"description\">${t.description}</span>` : nothing}\n </div>\n <button class=\"close\" aria-label=\"Dismiss notification\" @click=${() => this.dismiss(t.id)}>\n <span aria-hidden=\"true\">${iconX(18)}</span>\n </button>\n </div>\n `,\n )}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"toast-notification\": ToastNotification;\n }\n}\n\nfunction getToast(): ToastNotification | null {\n return document.querySelector(\"toast-notification\");\n}\n\n/** Shows an error toast. Use for connection/network failures, not validation errors. */\nexport function notifyError(message: string, description?: string) {\n getToast()?.show(message, { variant: \"error\", description });\n}\n\n/** Shows a success toast. */\nexport function notifySuccess(message: string, description?: string) {\n getToast()?.show(message, { variant: \"success\", description });\n}\n\n/** Shows an info toast. */\nexport function notifyInfo(message: string, description?: string) {\n getToast()?.show(message, { variant: \"info\", description });\n}\n\n/** Shows a warning toast. */\nexport function notifyWarning(message: string, description?: string) {\n getToast()?.show(message, { variant: \"warning\", description });\n}\n"]}
1
+ {"version":3,"file":"toast-notification.js","sourceRoot":"","sources":["../src/toast-notification.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,QAAQ,EACR,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAuBrC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QACY,YAAO,GAAY,EAAE,CAAC;QAE/B,YAAO,GAAG,CAAC,CAAC;QACZ,YAAO,GAAG,IAAI,GAAG,EAAyC,CAAC;IA8MrE,CAAC;aA5MiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,CAkN7B;;AAQD,SAAS,QAAQ;IACf,OAAO,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,WAAoB;IAC/D,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,WAAoB;IACjE,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,2BAA2B;AAC3B,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,WAAoB;IAC9D,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,WAAoB;IACjE,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, state } from \"lit/decorators.js\";\nimport {\n iconCheckCircle,\n iconExclamationCircle,\n iconExclamationTriangle,\n iconInfo,\n iconX,\n} from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport type ToastVariant = \"error\" | \"info\" | \"success\" | \"warning\";\n\ninterface ToastOptions {\n /** Visual style; also selects the accent color. Defaults to \"info\". */\n variant?: ToastVariant;\n /** Auto-dismiss delay in ms. Pass 0 to require a manual close. Defaults to 5000. */\n duration?: number;\n /**\n * Optional secondary line shown beneath the headline in smaller, non-bold\n * type. Omit for a single-line toast.\n */\n description?: string;\n}\n\ninterface Toast {\n id: number;\n message: string;\n variant: ToastVariant;\n description?: string;\n}\n\nconst DEFAULT_DURATION_MS = 5000;\n\n/**\n * Fixed-position stack of dismissible notifications, anchored top-right\n * (top-full-width on mobile). Every toast shares one fixed width so entries\n * never appear narrower or wider than one another. Not wired to any app state\n * yet — callers add toasts imperatively via the `show()` method on a live\n * element reference,\n * e.g. `document.querySelector('toast-notification')?.show('Offline', { variant: 'error' })`,\n * or via the `notifySuccess`/`notifyError`/`notifyInfo` module-level helpers\n * exported from this file. The first argument is the required bold headline; an\n * optional `description` renders a smaller, non-bold second line. Each variant\n * leads with a matching status icon (success → check, error → exclamation\n * circle, info → information circle, warning → exclamation triangle). Each toast\n * auto-dismisses after `duration` ms and can also be dismissed via its ✕\n * button. Appears/disappears instantly — no slide/fade transitions.\n *\n * Each variant's background reads a dedicated `--ui-toast-*-background` hook\n * (`success`/`error`/`info`/`warning`), which defaults to the flat\n * `--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —\n * so those stay the single source of truth for every other component. A\n * consumer can override just these toast-specific tokens with a\n * `linear-gradient(...)` to opt every toast into a gradient look without\n * touching component markup — `gradientTokenValues` in `tokens.ts` ships\n * exactly this, wired up via `data-theme=\"gradient\"` (see `tokens.css`'s\n * \"Gradient theme\" section), the same mechanism `ui-button` uses.\n * `--ui-toast-highlight` (a glossy top-edge box-shadow, layered onto the\n * existing elevation shadow) and `--ui-toast-text-shadow` (legibility\n * against the gradient's lighter stop) round out the effect, mirroring\n * `ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.\n *\n * @element toast-notification\n */\n@customElement(\"toast-notification\")\nexport class ToastNotification extends LitElement {\n @state() private _toasts: Toast[] = [];\n\n private _nextId = 0;\n private _timers = new Map<number, ReturnType<typeof setTimeout>>();\n\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n top: 1rem;\n right: 1rem;\n z-index: 200;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n width: 22.5rem;\n pointer-events: none;\n }\n .toast {\n pointer-events: auto;\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n border-radius: var(--ui-radius, 0.5rem);\n padding: 0.75rem;\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n ), var(--ui-toast-highlight, 0 0 0 0 transparent);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-on-accent, #ffffff);\n background: var(--ui-text, #0f172a);\n text-shadow: var(--ui-toast-text-shadow, none);\n }\n .toast.error {\n background: var(--ui-toast-error-background, var(--ui-danger, #dc2626));\n }\n .toast.success {\n background: var(--ui-toast-success-background, var(--ui-success, #16a34a));\n }\n .toast.info {\n background: var(--ui-toast-info-background, var(--ui-info, #0ea5e9));\n }\n .toast.warning {\n background: var(--ui-toast-warning-background, var(--ui-warning, #d97706));\n }\n .icon {\n flex: 0 0 auto;\n margin-top: 0.125rem;\n line-height: var(--ui-line-height-glyph, 1);\n }\n .content {\n flex: 1 1 auto;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n .message {\n font-weight: var(--ui-font-weight-semibold, 600);\n word-break: break-word;\n }\n .description {\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-normal, 1.5);\n word-break: break-word;\n }\n .close {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n background: none;\n border: none;\n padding: 0;\n margin: -0.25rem -0.25rem -0.25rem 0;\n color: inherit;\n opacity: 0.8;\n cursor: pointer;\n line-height: var(--ui-line-height-glyph, 1);\n border-radius: var(--ui-radius-sm, 0.25rem);\n }\n .close:hover {\n opacity: 1;\n background: var(--ui-hover-overlay, rgb(255 255 255 / 0.32));\n }\n .close:focus-visible {\n outline: none;\n opacity: 1;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (forced-colors: active) {\n .toast {\n border: 1px solid CanvasText;\n forced-color-adjust: auto;\n }\n .close:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n :host {\n top: 0.75rem;\n right: 0.75rem;\n left: 0.75rem;\n width: auto;\n }\n }\n `,\n ];\n\n /**\n * Queues a toast for display.\n * @param message Text to show.\n * @param options Variant + auto-dismiss duration (see {@link ToastOptions}).\n * @returns The toast's id — pass to `dismiss()` to remove it early.\n */\n show(message: string, options: ToastOptions = {}): number {\n const id = this._nextId++;\n const variant = options.variant ?? \"info\";\n const duration = options.duration ?? DEFAULT_DURATION_MS;\n this._toasts = [...this._toasts, { id, message, variant, description: options.description }];\n if (duration > 0) {\n this._timers.set(\n id,\n setTimeout(() => this.dismiss(id), duration),\n );\n }\n return id;\n }\n\n /**\n * Removes a toast immediately, cancelling its pending auto-dismiss timer if any.\n * @param id The id returned by `show()`.\n */\n dismiss(id: number) {\n const timer = this._timers.get(id);\n if (timer) {\n clearTimeout(timer);\n this._timers.delete(id);\n }\n this._toasts = this._toasts.filter((t) => t.id !== id);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n for (const timer of this._timers.values()) clearTimeout(timer);\n this._timers.clear();\n }\n\n /**\n * Returns the decorative status icon for a variant, sized as a standalone\n * 18px glyph to match the dismiss button.\n * @param variant The toast variant.\n */\n private _variantIcon(variant: ToastVariant) {\n switch (variant) {\n case \"success\":\n return iconCheckCircle(18);\n case \"error\":\n return iconExclamationCircle(18);\n case \"warning\":\n return iconExclamationTriangle(18);\n default:\n return iconInfo(18);\n }\n }\n\n override render() {\n if (this._toasts.length === 0) return nothing;\n return html`\n ${this._toasts.map(\n (t) => html`\n <div\n class=\"toast ${t.variant}\"\n role=${t.variant === \"error\" ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n >\n <span class=\"icon\" aria-hidden=\"true\">${this._variantIcon(t.variant)}</span>\n <div class=\"content\">\n <span class=\"message\">${t.message}</span>\n ${t.description ? html`<span class=\"description\">${t.description}</span>` : nothing}\n </div>\n <button class=\"close\" aria-label=\"Dismiss notification\" @click=${() => this.dismiss(t.id)}>\n <span aria-hidden=\"true\">${iconX(18)}</span>\n </button>\n </div>\n `,\n )}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"toast-notification\": ToastNotification;\n }\n}\n\nfunction getToast(): ToastNotification | null {\n return document.querySelector(\"toast-notification\");\n}\n\n/** Shows an error toast. Use for connection/network failures, not validation errors. */\nexport function notifyError(message: string, description?: string) {\n getToast()?.show(message, { variant: \"error\", description });\n}\n\n/** Shows a success toast. */\nexport function notifySuccess(message: string, description?: string) {\n getToast()?.show(message, { variant: \"success\", description });\n}\n\n/** Shows an info toast. */\nexport function notifyInfo(message: string, description?: string) {\n getToast()?.show(message, { variant: \"info\", description });\n}\n\n/** Shows a warning toast. */\nexport function notifyWarning(message: string, description?: string) {\n getToast()?.show(message, { variant: \"warning\", description });\n}\n"]}
package/dist/tokens.css CHANGED
@@ -26,6 +26,12 @@
26
26
  --ui-success: #16a34a;
27
27
  --ui-warning: #d97706;
28
28
  --ui-warning-hover: #b45309;
29
+ --ui-toast-success-background: var(--ui-success, #16a34a);
30
+ --ui-toast-error-background: var(--ui-danger, #dc2626);
31
+ --ui-toast-info-background: var(--ui-info, #0ea5e9);
32
+ --ui-toast-warning-background: var(--ui-warning, #d97706);
33
+ --ui-toast-highlight: 0 0 0 0 transparent;
34
+ --ui-toast-text-shadow: none;
29
35
  --ui-on-accent: #ffffff;
30
36
  --ui-text: #0f172a;
31
37
  --ui-text-muted: #64748b;
@@ -122,12 +128,18 @@
122
128
  --ui-button-danger-background-hover: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
123
129
  --ui-button-danger-background-active: linear-gradient(180deg, #dc2626 0%, #ef4444 100%);
124
130
  --ui-button-danger-border: #b91c1c;
125
- --ui-button-secondary-background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
126
- --ui-button-secondary-background-hover: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
127
- --ui-button-secondary-background-active: linear-gradient(180deg, #f1f5f9 0%, #ffffff 100%);
131
+ --ui-button-secondary-background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
132
+ --ui-button-secondary-background-hover: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
133
+ --ui-button-secondary-background-active: linear-gradient(180deg, #f1f5f9 0%, #f8fafc 100%);
128
134
  --ui-button-secondary-border: #cbd5e1;
129
135
  --ui-button-secondary-border-hover: #94a3b8;
130
136
  --ui-button-highlight: inset 0 1px 0 rgb(255 255 255 / 0.35);
131
137
  --ui-button-text-shadow: 0 1px 1px rgb(0 0 0 / 0.25);
132
138
  --ui-button-accent: #4338ca;
139
+ --ui-toast-success-background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
140
+ --ui-toast-error-background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
141
+ --ui-toast-info-background: linear-gradient(180deg, #38bdf8 0%, #0ea5e9 100%);
142
+ --ui-toast-warning-background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
143
+ --ui-toast-highlight: inset 0 1px 0 rgb(255 255 255 / 0.35);
144
+ --ui-toast-text-shadow: 0 1px 1px rgb(0 0 0 / 0.25);
133
145
  }
package/dist/tokens.d.ts CHANGED
@@ -22,14 +22,15 @@ export declare const darkTokenValues: Record<string, string>;
22
22
  * `"light"` override and layers a glossy gradient look on top of the flat
23
23
  * light palette, using exactly the `--ui-button-*`/`--ui-button-danger-*`/
24
24
  * `--ui-button-secondary-*` hooks `ui-button.ts` already reads (see that
25
- * file's doc comment). Every other token (`--ui-text`, `--ui-surface`, …)
26
- * is left at its light-mode default — this theme is button-only by design.
27
- * Each variant's gradient runs light-to-dark top-to-bottom (`180deg`)
28
- * across one Tailwind shade step lighter/darker than the flat token so it
29
- * still reads as "the same color, glossy" rather than a different hue;
30
- * `-hover` shifts the whole pair one shade lighter, `-active` reverses the
31
- * two stops for a pressed/"indented" look, and `-border` is a shade darker
32
- * than the gradient's dark stop for a defining edge.
25
+ * file's doc comment), plus the `--ui-toast-*` hooks `toast-notification.ts`
26
+ * reads (see its doc comment). Every other token (`--ui-text`, `--ui-surface`,
27
+ * …) is left at its light-mode default — this theme only glosses buttons and
28
+ * toasts by design. Each variant's gradient runs light-to-dark top-to-bottom
29
+ * (`180deg`) across one Tailwind shade step lighter/darker than the flat
30
+ * token so it still reads as "the same color, glossy" rather than a
31
+ * different hue; `-hover` shifts the whole pair one shade lighter, `-active`
32
+ * reverses the two stops for a pressed/"indented" look, and `-border` is a
33
+ * shade darker than the gradient's dark stop for a defining edge.
33
34
  */
34
35
  export declare const gradientTokenValues: Record<string, string>;
35
36
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAgH9C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBlD,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,MAAM,yBAAQ,CAAC"}
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8H9C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBlD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkCtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,MAAM,yBAAQ,CAAC"}