@f-ewald/components 1.34.0 → 1.36.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.
- package/custom-elements.json +339 -3
- package/dist/app-shell.d.ts +8 -0
- package/dist/app-shell.d.ts.map +1 -1
- package/dist/app-shell.js +51 -22
- package/dist/app-shell.js.map +1 -1
- package/dist/copy-link-button.js +2 -2
- package/dist/copy-link-button.js.map +1 -1
- package/dist/icons.d.ts +11 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +11 -1
- package/dist/icons.js.map +1 -1
- package/dist/toast-notification.d.ts +30 -0
- package/dist/toast-notification.d.ts.map +1 -1
- package/dist/toast-notification.js +223 -10
- package/dist/toast-notification.js.map +1 -1
- package/docs/app-shell.md +7 -0
- package/docs/icons.md +6 -1
- package/docs/toast-notification.md +10 -0
- package/llms.txt +23 -3
- package/package.json +1 -1
|
@@ -9,6 +9,9 @@ import { customElement, state } from "lit/decorators.js";
|
|
|
9
9
|
import { iconCheckCircle, iconExclamationCircle, iconExclamationTriangle, iconInfo, iconX, } from "./icons.js";
|
|
10
10
|
import { tokens } from "./tokens.js";
|
|
11
11
|
const DEFAULT_DURATION_MS = 5000;
|
|
12
|
+
/** Radius of the countdown ring's SVG circle — used to derive its circumference. */
|
|
13
|
+
const RING_RADIUS = 9;
|
|
14
|
+
const RING_CIRCUMFERENCE = 2 * Math.PI * RING_RADIUS;
|
|
12
15
|
/**
|
|
13
16
|
* Fixed-position stack of dismissible notifications, anchored top-right
|
|
14
17
|
* (top-full-width on mobile). Every toast shares one fixed width so entries
|
|
@@ -24,6 +27,15 @@ const DEFAULT_DURATION_MS = 5000;
|
|
|
24
27
|
* auto-dismisses after `duration` ms and can also be dismissed via its ✕
|
|
25
28
|
* button. Appears/disappears instantly — no slide/fade transitions.
|
|
26
29
|
*
|
|
30
|
+
* A toast with `duration > 0` replaces its ✕ button with a countdown: a
|
|
31
|
+
* number of seconds remaining inside a ring that fills in clockwise over
|
|
32
|
+
* `duration`. Hovering or keyboard-focusing the toast swaps the countdown
|
|
33
|
+
* back for the ✕ and pauses the countdown (both the visual ring/number and
|
|
34
|
+
* the underlying auto-dismiss timer) — the toast won't disappear while
|
|
35
|
+
* someone's reading it or has tabbed to its close button — resuming from
|
|
36
|
+
* where it left off once the pointer/focus leaves. A `duration: 0` toast has
|
|
37
|
+
* no countdown to show, so its ✕ is always visible, exactly as before.
|
|
38
|
+
*
|
|
27
39
|
* Each variant's background reads a dedicated `--ui-toast-*-background` hook
|
|
28
40
|
* (`success`/`error`/`info`/`warning`), which defaults to the flat
|
|
29
41
|
* `--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
|
|
@@ -46,6 +58,10 @@ let ToastNotification = class ToastNotification extends LitElement {
|
|
|
46
58
|
this._toasts = [];
|
|
47
59
|
this._nextId = 0;
|
|
48
60
|
this._timers = new Map();
|
|
61
|
+
/** Per-toast hover/focus tracking, so leaving one doesn't resume while the other still applies. */
|
|
62
|
+
this._interaction = new Map();
|
|
63
|
+
/** Ticks while any toast has a running countdown, purely to refresh the displayed seconds. */
|
|
64
|
+
this._tickTimer = null;
|
|
49
65
|
}
|
|
50
66
|
static { this.styles = [
|
|
51
67
|
tokens,
|
|
@@ -123,23 +139,97 @@ let ToastNotification = class ToastNotification extends LitElement {
|
|
|
123
139
|
line-height: var(--ui-line-height-normal, 1.5);
|
|
124
140
|
word-break: break-word;
|
|
125
141
|
}
|
|
126
|
-
.close
|
|
142
|
+
/* .countdown and .close are stacked exactly on top of one another (both
|
|
143
|
+
inset:0 inside this fixed-size box) rather than swapped via
|
|
144
|
+
display:none, so toggling between them never shifts layout. */
|
|
145
|
+
.actions {
|
|
146
|
+
position: relative;
|
|
127
147
|
flex: 0 0 auto;
|
|
148
|
+
width: 2rem;
|
|
149
|
+
height: 2rem;
|
|
150
|
+
margin: -0.25rem -0.25rem -0.25rem 0;
|
|
151
|
+
}
|
|
152
|
+
.countdown {
|
|
153
|
+
position: absolute;
|
|
154
|
+
inset: 0;
|
|
128
155
|
display: inline-flex;
|
|
129
156
|
align-items: center;
|
|
130
157
|
justify-content: center;
|
|
158
|
+
pointer-events: none;
|
|
159
|
+
}
|
|
160
|
+
.ring {
|
|
161
|
+
position: absolute;
|
|
162
|
+
inset: 0;
|
|
163
|
+
width: 100%;
|
|
164
|
+
height: 100%;
|
|
165
|
+
}
|
|
166
|
+
.ring-track {
|
|
167
|
+
fill: none;
|
|
168
|
+
stroke: currentColor;
|
|
169
|
+
stroke-width: 2;
|
|
170
|
+
opacity: 0.3;
|
|
171
|
+
}
|
|
172
|
+
.ring-progress {
|
|
173
|
+
fill: none;
|
|
174
|
+
stroke: currentColor;
|
|
175
|
+
stroke-width: 2;
|
|
176
|
+
stroke-linecap: round;
|
|
177
|
+
transform-origin: 50% 50%;
|
|
178
|
+
transform: rotate(-90deg);
|
|
179
|
+
stroke-dasharray: ${RING_CIRCUMFERENCE};
|
|
180
|
+
stroke-dashoffset: ${RING_CIRCUMFERENCE};
|
|
181
|
+
animation-name: toast-ring-fill;
|
|
182
|
+
animation-duration: var(--toast-duration, 5000ms);
|
|
183
|
+
animation-timing-function: linear;
|
|
184
|
+
animation-fill-mode: forwards;
|
|
185
|
+
}
|
|
186
|
+
.toast.has-countdown:hover .ring-progress,
|
|
187
|
+
.toast.has-countdown:focus-within .ring-progress {
|
|
188
|
+
animation-play-state: paused;
|
|
189
|
+
}
|
|
190
|
+
@keyframes toast-ring-fill {
|
|
191
|
+
to {
|
|
192
|
+
stroke-dashoffset: 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
.countdown-number {
|
|
196
|
+
position: relative;
|
|
197
|
+
font-size: var(--ui-font-size-xs, 0.6875rem);
|
|
198
|
+
font-weight: var(--ui-font-weight-semibold, 600);
|
|
199
|
+
font-variant-numeric: tabular-nums;
|
|
200
|
+
line-height: var(--ui-line-height-glyph, 1);
|
|
201
|
+
}
|
|
202
|
+
.close {
|
|
203
|
+
position: absolute;
|
|
204
|
+
inset: 0;
|
|
131
205
|
width: 2rem;
|
|
132
206
|
height: 2rem;
|
|
207
|
+
display: inline-flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
justify-content: center;
|
|
133
210
|
background: none;
|
|
134
211
|
border: none;
|
|
135
212
|
padding: 0;
|
|
136
|
-
margin: -0.25rem -0.25rem -0.25rem 0;
|
|
137
213
|
color: inherit;
|
|
138
214
|
opacity: 0.8;
|
|
139
215
|
cursor: pointer;
|
|
140
216
|
line-height: var(--ui-line-height-glyph, 1);
|
|
141
217
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
142
218
|
}
|
|
219
|
+
/* Only hide the ✕ behind the countdown when there IS a countdown — a
|
|
220
|
+
duration:0 toast has no .countdown sibling and keeps the ✕ always
|
|
221
|
+
visible, unchanged from before this feature existed. */
|
|
222
|
+
.toast.has-countdown .close {
|
|
223
|
+
opacity: 0;
|
|
224
|
+
}
|
|
225
|
+
.toast.has-countdown:hover .close,
|
|
226
|
+
.toast.has-countdown:focus-within .close {
|
|
227
|
+
opacity: 1;
|
|
228
|
+
}
|
|
229
|
+
.toast.has-countdown:hover .countdown,
|
|
230
|
+
.toast.has-countdown:focus-within .countdown {
|
|
231
|
+
visibility: hidden;
|
|
232
|
+
}
|
|
143
233
|
.close:hover {
|
|
144
234
|
opacity: 1;
|
|
145
235
|
background: var(--ui-hover-overlay, rgb(255 255 255 / 0.32));
|
|
@@ -149,6 +239,11 @@ let ToastNotification = class ToastNotification extends LitElement {
|
|
|
149
239
|
opacity: 1;
|
|
150
240
|
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
151
241
|
}
|
|
242
|
+
@media (prefers-reduced-motion: reduce) {
|
|
243
|
+
.ring-progress {
|
|
244
|
+
animation: none;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
152
247
|
@media (forced-colors: active) {
|
|
153
248
|
.toast {
|
|
154
249
|
border: 1px solid CanvasText;
|
|
@@ -180,10 +275,20 @@ let ToastNotification = class ToastNotification extends LitElement {
|
|
|
180
275
|
const id = this._nextId++;
|
|
181
276
|
const variant = options.variant ?? "info";
|
|
182
277
|
const duration = options.duration ?? DEFAULT_DURATION_MS;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
278
|
+
const toast = {
|
|
279
|
+
id,
|
|
280
|
+
message,
|
|
281
|
+
variant,
|
|
282
|
+
description: options.description,
|
|
283
|
+
duration,
|
|
284
|
+
endTime: duration > 0 ? Date.now() + duration : 0,
|
|
285
|
+
remaining: duration,
|
|
286
|
+
paused: false,
|
|
287
|
+
};
|
|
288
|
+
this._toasts = [...this._toasts, toast];
|
|
289
|
+
if (duration > 0)
|
|
290
|
+
this._scheduleTimer(id, duration);
|
|
291
|
+
this._syncTicking();
|
|
187
292
|
return id;
|
|
188
293
|
}
|
|
189
294
|
/**
|
|
@@ -196,13 +301,104 @@ let ToastNotification = class ToastNotification extends LitElement {
|
|
|
196
301
|
clearTimeout(timer);
|
|
197
302
|
this._timers.delete(id);
|
|
198
303
|
}
|
|
304
|
+
this._interaction.delete(id);
|
|
199
305
|
this._toasts = this._toasts.filter((t) => t.id !== id);
|
|
306
|
+
this._syncTicking();
|
|
200
307
|
}
|
|
201
308
|
disconnectedCallback() {
|
|
202
309
|
super.disconnectedCallback();
|
|
203
310
|
for (const timer of this._timers.values())
|
|
204
311
|
clearTimeout(timer);
|
|
205
312
|
this._timers.clear();
|
|
313
|
+
if (this._tickTimer)
|
|
314
|
+
clearInterval(this._tickTimer);
|
|
315
|
+
this._tickTimer = null;
|
|
316
|
+
}
|
|
317
|
+
/** Schedules (or reschedules) the real auto-dismiss timeout for a toast. */
|
|
318
|
+
_scheduleTimer(id, ms) {
|
|
319
|
+
this._timers.set(id, setTimeout(() => this.dismiss(id), ms));
|
|
320
|
+
}
|
|
321
|
+
/** Freezes a toast's countdown at its current remaining time. */
|
|
322
|
+
_pause(id) {
|
|
323
|
+
const index = this._toasts.findIndex((t) => t.id === id);
|
|
324
|
+
if (index === -1)
|
|
325
|
+
return;
|
|
326
|
+
const toast = this._toasts[index];
|
|
327
|
+
if (toast.duration === 0 || toast.paused)
|
|
328
|
+
return;
|
|
329
|
+
const timer = this._timers.get(id);
|
|
330
|
+
if (timer) {
|
|
331
|
+
clearTimeout(timer);
|
|
332
|
+
this._timers.delete(id);
|
|
333
|
+
}
|
|
334
|
+
const remaining = Math.max(0, toast.endTime - Date.now());
|
|
335
|
+
const next = [...this._toasts];
|
|
336
|
+
next[index] = { ...toast, paused: true, remaining };
|
|
337
|
+
this._toasts = next;
|
|
338
|
+
this._syncTicking();
|
|
339
|
+
}
|
|
340
|
+
/** Resumes a paused toast's countdown for whatever time was remaining. */
|
|
341
|
+
_resume(id) {
|
|
342
|
+
const index = this._toasts.findIndex((t) => t.id === id);
|
|
343
|
+
if (index === -1)
|
|
344
|
+
return;
|
|
345
|
+
const toast = this._toasts[index];
|
|
346
|
+
if (toast.duration === 0 || !toast.paused)
|
|
347
|
+
return;
|
|
348
|
+
this._scheduleTimer(id, toast.remaining);
|
|
349
|
+
const next = [...this._toasts];
|
|
350
|
+
next[index] = { ...toast, paused: false, endTime: Date.now() + toast.remaining };
|
|
351
|
+
this._toasts = next;
|
|
352
|
+
this._syncTicking();
|
|
353
|
+
}
|
|
354
|
+
/** Starts or stops the shared display-only tick, matching whether any countdown is actually running. */
|
|
355
|
+
_syncTicking() {
|
|
356
|
+
const needsTicking = this._toasts.some((t) => t.duration > 0 && !t.paused);
|
|
357
|
+
if (needsTicking && !this._tickTimer) {
|
|
358
|
+
this._tickTimer = setInterval(() => this.requestUpdate(), 250);
|
|
359
|
+
}
|
|
360
|
+
else if (!needsTicking && this._tickTimer) {
|
|
361
|
+
clearInterval(this._tickTimer);
|
|
362
|
+
this._tickTimer = null;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/** Reads (creating if absent) a toast's hover/focus tracking record. */
|
|
366
|
+
_interactionState(id) {
|
|
367
|
+
let state = this._interaction.get(id);
|
|
368
|
+
if (!state) {
|
|
369
|
+
state = { hovered: false, focusWithin: false };
|
|
370
|
+
this._interaction.set(id, state);
|
|
371
|
+
}
|
|
372
|
+
return state;
|
|
373
|
+
}
|
|
374
|
+
_onMouseEnter(id) {
|
|
375
|
+
this._interactionState(id).hovered = true;
|
|
376
|
+
this._pause(id);
|
|
377
|
+
}
|
|
378
|
+
_onMouseLeave(id) {
|
|
379
|
+
const state = this._interactionState(id);
|
|
380
|
+
state.hovered = false;
|
|
381
|
+
if (!state.focusWithin)
|
|
382
|
+
this._resume(id);
|
|
383
|
+
}
|
|
384
|
+
_onFocusIn(id) {
|
|
385
|
+
this._interactionState(id).focusWithin = true;
|
|
386
|
+
this._pause(id);
|
|
387
|
+
}
|
|
388
|
+
/** Rechecks focus-within on a microtask, since focusout fires before the new focus target settles. */
|
|
389
|
+
_onFocusOut(id, event) {
|
|
390
|
+
const el = event.currentTarget;
|
|
391
|
+
queueMicrotask(() => {
|
|
392
|
+
const state = this._interactionState(id);
|
|
393
|
+
state.focusWithin = el.matches(":focus-within");
|
|
394
|
+
if (!state.hovered && !state.focusWithin)
|
|
395
|
+
this._resume(id);
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
/** Whole seconds remaining until auto-dismiss, for the countdown number. */
|
|
399
|
+
_secondsLeft(t) {
|
|
400
|
+
const ms = t.paused ? t.remaining : Math.max(0, t.endTime - Date.now());
|
|
401
|
+
return Math.max(0, Math.ceil(ms / 1000));
|
|
206
402
|
}
|
|
207
403
|
/**
|
|
208
404
|
* Returns the decorative status icon for a variant, sized as a standalone
|
|
@@ -227,18 +423,35 @@ let ToastNotification = class ToastNotification extends LitElement {
|
|
|
227
423
|
return html `
|
|
228
424
|
${this._toasts.map((t) => html `
|
|
229
425
|
<div
|
|
230
|
-
class="toast ${t.variant}"
|
|
426
|
+
class="toast ${t.variant} ${t.duration > 0 ? "has-countdown" : ""}"
|
|
231
427
|
role=${t.variant === "error" ? "alert" : "status"}
|
|
232
428
|
aria-atomic="true"
|
|
429
|
+
@mouseenter=${() => this._onMouseEnter(t.id)}
|
|
430
|
+
@mouseleave=${() => this._onMouseLeave(t.id)}
|
|
431
|
+
@focusin=${() => this._onFocusIn(t.id)}
|
|
432
|
+
@focusout=${(e) => this._onFocusOut(t.id, e)}
|
|
233
433
|
>
|
|
234
434
|
<span class="icon" aria-hidden="true">${this._variantIcon(t.variant)}</span>
|
|
235
435
|
<div class="content">
|
|
236
436
|
<span class="message">${t.message}</span>
|
|
237
437
|
${t.description ? html `<span class="description">${t.description}</span>` : nothing}
|
|
238
438
|
</div>
|
|
239
|
-
<
|
|
240
|
-
|
|
241
|
-
|
|
439
|
+
<div class="actions">
|
|
440
|
+
${t.duration > 0
|
|
441
|
+
? html `
|
|
442
|
+
<div class="countdown" aria-hidden="true" style="--toast-duration: ${t.duration}ms">
|
|
443
|
+
<svg class="ring" viewBox="0 0 24 24">
|
|
444
|
+
<circle class="ring-track" cx="12" cy="12" r=${RING_RADIUS}></circle>
|
|
445
|
+
<circle class="ring-progress" cx="12" cy="12" r=${RING_RADIUS}></circle>
|
|
446
|
+
</svg>
|
|
447
|
+
<span class="countdown-number">${this._secondsLeft(t)}</span>
|
|
448
|
+
</div>
|
|
449
|
+
`
|
|
450
|
+
: nothing}
|
|
451
|
+
<button class="close" aria-label="Dismiss notification" @click=${() => this.dismiss(t.id)}>
|
|
452
|
+
<span aria-hidden="true">${iconX(18)}</span>
|
|
453
|
+
</button>
|
|
454
|
+
</div>
|
|
242
455
|
</div>
|
|
243
456
|
`)}
|
|
244
457
|
`;
|
|
@@ -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,mB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AC,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"]}
|
|
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;AA+BrC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,oFAAoF;AACpF,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,WAAW,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;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;QACnE,mGAAmG;QAC3F,iBAAY,GAAG,IAAI,GAAG,EAAsD,CAAC;QACrF,8FAA8F;QACtF,eAAU,GAA0C,IAAI,CAAC;IAoZnE,CAAC;aAlZiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA+GqB,kBAAkB;6BACjB,kBAAkB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,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;2CAC5D,KAAK,CAAC,EAAE,CAAC;;;;SAI3C,CACF;KACF,CAAC;IACJ,CAAC;CACF,CAAA;AA3ZkB;IAAhB,KAAK,EAAE;kDAA+B;AAD5B,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,CA4Z7B;;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 /** Configured auto-dismiss delay in ms; 0 means manual dismiss only (no countdown). */\n duration: number;\n /** Timestamp (`Date.now()`-based) this toast will auto-dismiss at, while the countdown is running. */\n endTime: number;\n /** Milliseconds remaining, frozen at the instant hover/focus paused the countdown. */\n remaining: number;\n /** Whether hover or focus has paused the countdown. */\n paused: boolean;\n}\n\nconst DEFAULT_DURATION_MS = 5000;\n/** Radius of the countdown ring's SVG circle — used to derive its circumference. */\nconst RING_RADIUS = 9;\nconst RING_CIRCUMFERENCE = 2 * Math.PI * RING_RADIUS;\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 * A toast with `duration > 0` replaces its ✕ button with a countdown: a\n * number of seconds remaining inside a ring that fills in clockwise over\n * `duration`. Hovering or keyboard-focusing the toast swaps the countdown\n * back for the ✕ and pauses the countdown (both the visual ring/number and\n * the underlying auto-dismiss timer) — the toast won't disappear while\n * someone's reading it or has tabbed to its close button — resuming from\n * where it left off once the pointer/focus leaves. A `duration: 0` toast has\n * no countdown to show, so its ✕ is always visible, exactly as before.\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 /** Per-toast hover/focus tracking, so leaving one doesn't resume while the other still applies. */\n private _interaction = new Map<number, { hovered: boolean; focusWithin: boolean }>();\n /** Ticks while any toast has a running countdown, purely to refresh the displayed seconds. */\n private _tickTimer: ReturnType<typeof setInterval> | null = null;\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 /* .countdown and .close are stacked exactly on top of one another (both\n inset:0 inside this fixed-size box) rather than swapped via\n display:none, so toggling between them never shifts layout. */\n .actions {\n position: relative;\n flex: 0 0 auto;\n width: 2rem;\n height: 2rem;\n margin: -0.25rem -0.25rem -0.25rem 0;\n }\n .countdown {\n position: absolute;\n inset: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n }\n .ring {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n }\n .ring-track {\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n opacity: 0.3;\n }\n .ring-progress {\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n stroke-linecap: round;\n transform-origin: 50% 50%;\n transform: rotate(-90deg);\n stroke-dasharray: ${RING_CIRCUMFERENCE};\n stroke-dashoffset: ${RING_CIRCUMFERENCE};\n animation-name: toast-ring-fill;\n animation-duration: var(--toast-duration, 5000ms);\n animation-timing-function: linear;\n animation-fill-mode: forwards;\n }\n .toast.has-countdown:hover .ring-progress,\n .toast.has-countdown:focus-within .ring-progress {\n animation-play-state: paused;\n }\n @keyframes toast-ring-fill {\n to {\n stroke-dashoffset: 0;\n }\n }\n .countdown-number {\n position: relative;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n font-variant-numeric: tabular-nums;\n line-height: var(--ui-line-height-glyph, 1);\n }\n .close {\n position: absolute;\n inset: 0;\n width: 2rem;\n height: 2rem;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: none;\n border: none;\n padding: 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 /* Only hide the ✕ behind the countdown when there IS a countdown — a\n duration:0 toast has no .countdown sibling and keeps the ✕ always\n visible, unchanged from before this feature existed. */\n .toast.has-countdown .close {\n opacity: 0;\n }\n .toast.has-countdown:hover .close,\n .toast.has-countdown:focus-within .close {\n opacity: 1;\n }\n .toast.has-countdown:hover .countdown,\n .toast.has-countdown:focus-within .countdown {\n visibility: hidden;\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 (prefers-reduced-motion: reduce) {\n .ring-progress {\n animation: none;\n }\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 const toast: Toast = {\n id,\n message,\n variant,\n description: options.description,\n duration,\n endTime: duration > 0 ? Date.now() + duration : 0,\n remaining: duration,\n paused: false,\n };\n this._toasts = [...this._toasts, toast];\n if (duration > 0) this._scheduleTimer(id, duration);\n this._syncTicking();\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._interaction.delete(id);\n this._toasts = this._toasts.filter((t) => t.id !== id);\n this._syncTicking();\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n for (const timer of this._timers.values()) clearTimeout(timer);\n this._timers.clear();\n if (this._tickTimer) clearInterval(this._tickTimer);\n this._tickTimer = null;\n }\n\n /** Schedules (or reschedules) the real auto-dismiss timeout for a toast. */\n private _scheduleTimer(id: number, ms: number): void {\n this._timers.set(\n id,\n setTimeout(() => this.dismiss(id), ms),\n );\n }\n\n /** Freezes a toast's countdown at its current remaining time. */\n private _pause(id: number): void {\n const index = this._toasts.findIndex((t) => t.id === id);\n if (index === -1) return;\n const toast = this._toasts[index];\n if (toast.duration === 0 || toast.paused) return;\n const timer = this._timers.get(id);\n if (timer) {\n clearTimeout(timer);\n this._timers.delete(id);\n }\n const remaining = Math.max(0, toast.endTime - Date.now());\n const next = [...this._toasts];\n next[index] = { ...toast, paused: true, remaining };\n this._toasts = next;\n this._syncTicking();\n }\n\n /** Resumes a paused toast's countdown for whatever time was remaining. */\n private _resume(id: number): void {\n const index = this._toasts.findIndex((t) => t.id === id);\n if (index === -1) return;\n const toast = this._toasts[index];\n if (toast.duration === 0 || !toast.paused) return;\n this._scheduleTimer(id, toast.remaining);\n const next = [...this._toasts];\n next[index] = { ...toast, paused: false, endTime: Date.now() + toast.remaining };\n this._toasts = next;\n this._syncTicking();\n }\n\n /** Starts or stops the shared display-only tick, matching whether any countdown is actually running. */\n private _syncTicking(): void {\n const needsTicking = this._toasts.some((t) => t.duration > 0 && !t.paused);\n if (needsTicking && !this._tickTimer) {\n this._tickTimer = setInterval(() => this.requestUpdate(), 250);\n } else if (!needsTicking && this._tickTimer) {\n clearInterval(this._tickTimer);\n this._tickTimer = null;\n }\n }\n\n /** Reads (creating if absent) a toast's hover/focus tracking record. */\n private _interactionState(id: number): { hovered: boolean; focusWithin: boolean } {\n let state = this._interaction.get(id);\n if (!state) {\n state = { hovered: false, focusWithin: false };\n this._interaction.set(id, state);\n }\n return state;\n }\n\n private _onMouseEnter(id: number): void {\n this._interactionState(id).hovered = true;\n this._pause(id);\n }\n\n private _onMouseLeave(id: number): void {\n const state = this._interactionState(id);\n state.hovered = false;\n if (!state.focusWithin) this._resume(id);\n }\n\n private _onFocusIn(id: number): void {\n this._interactionState(id).focusWithin = true;\n this._pause(id);\n }\n\n /** Rechecks focus-within on a microtask, since focusout fires before the new focus target settles. */\n private _onFocusOut(id: number, event: FocusEvent): void {\n const el = event.currentTarget as HTMLElement;\n queueMicrotask(() => {\n const state = this._interactionState(id);\n state.focusWithin = el.matches(\":focus-within\");\n if (!state.hovered && !state.focusWithin) this._resume(id);\n });\n }\n\n /** Whole seconds remaining until auto-dismiss, for the countdown number. */\n private _secondsLeft(t: Toast): number {\n const ms = t.paused ? t.remaining : Math.max(0, t.endTime - Date.now());\n return Math.max(0, Math.ceil(ms / 1000));\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} ${t.duration > 0 ? \"has-countdown\" : \"\"}\"\n role=${t.variant === \"error\" ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n @mouseenter=${() => this._onMouseEnter(t.id)}\n @mouseleave=${() => this._onMouseLeave(t.id)}\n @focusin=${() => this._onFocusIn(t.id)}\n @focusout=${(e: FocusEvent) => this._onFocusOut(t.id, e)}\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 <div class=\"actions\">\n ${t.duration > 0\n ? html`\n <div class=\"countdown\" aria-hidden=\"true\" style=\"--toast-duration: ${t.duration}ms\">\n <svg class=\"ring\" viewBox=\"0 0 24 24\">\n <circle class=\"ring-track\" cx=\"12\" cy=\"12\" r=${RING_RADIUS}></circle>\n <circle class=\"ring-progress\" cx=\"12\" cy=\"12\" r=${RING_RADIUS}></circle>\n </svg>\n <span class=\"countdown-number\">${this._secondsLeft(t)}</span>\n </div>\n `\n : nothing}\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 </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/docs/app-shell.md
CHANGED
|
@@ -42,6 +42,12 @@ Hovering or keyboard-focusing the toggle reveals a tooltip naming the
|
|
|
42
42
|
action and its `[` shortcut — the shortcut is not shown as permanent
|
|
43
43
|
chrome.
|
|
44
44
|
|
|
45
|
+
Consumers with their own external top bar can set `no-topbar` to skip
|
|
46
|
+
rendering the built-in topbar row and toggle button entirely (the grid
|
|
47
|
+
drops that row rather than leaving dead space). The `[`/Escape shortcuts
|
|
48
|
+
stay fully active either way — drive `sidebar-open` from your own UI and
|
|
49
|
+
listen for `sidebar-toggle` to stay in sync with keyboard-driven changes.
|
|
50
|
+
|
|
45
51
|
## Install
|
|
46
52
|
|
|
47
53
|
```js
|
|
@@ -77,6 +83,7 @@ import "@f-ewald/components/app-shell.js";
|
|
|
77
83
|
| `sidebarWidth` | `sidebar-width` | `"full" | "icon"` | `"full"` | Sidebar width when open: `"full"` (16rem, icons + labels) or `"icon"` (3.5rem rail, icons only). |
|
|
78
84
|
| `detailOpen` | `detail-open` | `boolean` | `false` | Shows the right-hand detail region (inline column, or overlay on mobile). |
|
|
79
85
|
| `detailWidth` | `detail-width` | `"compact" | "comfortable"` | `"compact"` | Detail width: `compact` (20rem) or `comfortable` (25rem). |
|
|
86
|
+
| `noTopbar` | `no-topbar` | `boolean` | `false` | Skips rendering the built-in topbar row and its nav toggle entirely, for consumers with their own external top bar. The `[`/Escape shortcuts stay active regardless — this only affects what's rendered. |
|
|
80
87
|
|
|
81
88
|
## Events
|
|
82
89
|
|
package/docs/icons.md
CHANGED
|
@@ -31,6 +31,7 @@ const icon = iconPencil(16); // 16px, defaults shown below if omitted
|
|
|
31
31
|
| `iconChevronLeft` | 16px | "Previous" navigation, e.g. pagination or carousel back controls. |
|
|
32
32
|
| `iconChevronRight` | 16px | "Next" navigation, or a collapsed disclosure/submenu indicator. |
|
|
33
33
|
| `iconChevronUp` | 16px | "Scroll to top", or an expanded/upward disclosure control. |
|
|
34
|
+
| `iconClipboard` | 18px | Copy-to-clipboard actions, e.g. copy-link-button. |
|
|
34
35
|
| `iconClipboardDocumentList` | 18px | Task lists, checklists, or clipboard/notes content. |
|
|
35
36
|
| `iconClock` | 16px | Timestamps, durations, or time-related metadata. |
|
|
36
37
|
| `iconCodeBracketSquare` | 16px | Code snippets, developer tools, or technical/API content. |
|
|
@@ -45,12 +46,15 @@ const icon = iconPencil(16); // 16px, defaults shown below if omitted
|
|
|
45
46
|
| `iconEye` | 16px | "Show"/"preview" actions or a visible/reviewed state, e.g. password visibility or a review status. |
|
|
46
47
|
| `iconEyeSlash` | 16px | "Hide" actions or a hidden/masked state; pair with iconEye for the visible state. |
|
|
47
48
|
| `iconFolder` | 18px | Folders, directories, or grouped file content. |
|
|
49
|
+
| `iconGlobeAlt` | 16px | A generic globe/satellite-view toggle, or international/worldwide content. |
|
|
50
|
+
| `iconGlobeAmericas` | 16px | Terrain/outdoors content, or a Americas-centric globe/region selector. |
|
|
48
51
|
| `iconHeart` | 16px | "Like"/"favorite" actions in their unselected state. |
|
|
49
52
|
| `iconHeartSolid` | 16px | "Like"/"favorite" actions in their selected/active state; pair with iconHeart for the unselected state. |
|
|
50
53
|
| `iconHome` | 16px | A primary navigation link to the app's home or dashboard. |
|
|
51
54
|
| `iconInfo` | 20px | Neutral informational messages, e.g. an info toast or status banner. |
|
|
52
|
-
| `iconLink` | 16px |
|
|
55
|
+
| `iconLink` | 16px | Hyperlink-related actions or a linked/associated-item indicator. |
|
|
53
56
|
| `iconListBullet` | 18px | A list-view toggle, or to represent list-type content. |
|
|
57
|
+
| `iconMagnifyingGlass` | 16px | Search inputs or search-triggering actions. |
|
|
54
58
|
| `iconMap` | 16px | A map-view toggle, or to represent map/geographic content. |
|
|
55
59
|
| `iconMapPin` | 16px | A location, address, or map marker. |
|
|
56
60
|
| `iconMoon` | 16px | A dark-theme toggle, or to represent night/dark mode. |
|
|
@@ -63,6 +67,7 @@ const icon = iconPencil(16); // 16px, defaults shown below if omitted
|
|
|
63
67
|
| `iconQueueList` | 16px | Queues, backlogs, or ordered work-item lists. |
|
|
64
68
|
| `iconShieldCheck` | 16px | Verified, secure, or trusted states. |
|
|
65
69
|
| `iconShieldExclamation` | 16px | Security warnings, or at-risk/compromised states. |
|
|
70
|
+
| `iconSignal` | 16px | Live/real-time data, connectivity strength, or a traffic-conditions toggle. |
|
|
66
71
|
| `iconSparkles` | 16px | An AI-powered action (pairs with ui-button's `ai` ring), a gradient-theme toggle, or a decorative/enhanced visual style. |
|
|
67
72
|
| `iconSpeakerWave` | 18px | An unmuted volume control, e.g. audio-player/video-player's mute toggle. |
|
|
68
73
|
| `iconSpeakerXMark` | 18px | A muted volume state; pair with iconSpeakerWave for the unmuted state. |
|
|
@@ -14,6 +14,15 @@ circle, info → information circle, warning → exclamation triangle). Each toa
|
|
|
14
14
|
auto-dismisses after `duration` ms and can also be dismissed via its ✕
|
|
15
15
|
button. Appears/disappears instantly — no slide/fade transitions.
|
|
16
16
|
|
|
17
|
+
A toast with `duration > 0` replaces its ✕ button with a countdown: a
|
|
18
|
+
number of seconds remaining inside a ring that fills in clockwise over
|
|
19
|
+
`duration`. Hovering or keyboard-focusing the toast swaps the countdown
|
|
20
|
+
back for the ✕ and pauses the countdown (both the visual ring/number and
|
|
21
|
+
the underlying auto-dismiss timer) — the toast won't disappear while
|
|
22
|
+
someone's reading it or has tabbed to its close button — resuming from
|
|
23
|
+
where it left off once the pointer/focus leaves. A `duration: 0` toast has
|
|
24
|
+
no countdown to show, so its ✕ is always visible, exactly as before.
|
|
25
|
+
|
|
17
26
|
Each variant's background reads a dedicated `--ui-toast-*-background` hook
|
|
18
27
|
(`success`/`error`/`info`/`warning`), which defaults to the flat
|
|
19
28
|
`--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
|
|
@@ -67,6 +76,7 @@ _None._
|
|
|
67
76
|
| `--ui-font` |
|
|
68
77
|
| `--ui-font-size` |
|
|
69
78
|
| `--ui-font-size-sm` |
|
|
79
|
+
| `--ui-font-size-xs` |
|
|
70
80
|
| `--ui-font-weight-regular` |
|
|
71
81
|
| `--ui-font-weight-semibold` |
|
|
72
82
|
| `--ui-hover-overlay` |
|
package/llms.txt
CHANGED
|
@@ -40,6 +40,7 @@ table to pick the icon matching a use case, for consistency across apps:
|
|
|
40
40
|
| `iconChevronLeft` | 16px | "Previous" navigation, e.g. pagination or carousel back controls. |
|
|
41
41
|
| `iconChevronRight` | 16px | "Next" navigation, or a collapsed disclosure/submenu indicator. |
|
|
42
42
|
| `iconChevronUp` | 16px | "Scroll to top", or an expanded/upward disclosure control. |
|
|
43
|
+
| `iconClipboard` | 18px | Copy-to-clipboard actions, e.g. copy-link-button. |
|
|
43
44
|
| `iconClipboardDocumentList` | 18px | Task lists, checklists, or clipboard/notes content. |
|
|
44
45
|
| `iconClock` | 16px | Timestamps, durations, or time-related metadata. |
|
|
45
46
|
| `iconCodeBracketSquare` | 16px | Code snippets, developer tools, or technical/API content. |
|
|
@@ -54,12 +55,15 @@ table to pick the icon matching a use case, for consistency across apps:
|
|
|
54
55
|
| `iconEye` | 16px | "Show"/"preview" actions or a visible/reviewed state, e.g. password visibility or a review status. |
|
|
55
56
|
| `iconEyeSlash` | 16px | "Hide" actions or a hidden/masked state; pair with iconEye for the visible state. |
|
|
56
57
|
| `iconFolder` | 18px | Folders, directories, or grouped file content. |
|
|
58
|
+
| `iconGlobeAlt` | 16px | A generic globe/satellite-view toggle, or international/worldwide content. |
|
|
59
|
+
| `iconGlobeAmericas` | 16px | Terrain/outdoors content, or a Americas-centric globe/region selector. |
|
|
57
60
|
| `iconHeart` | 16px | "Like"/"favorite" actions in their unselected state. |
|
|
58
61
|
| `iconHeartSolid` | 16px | "Like"/"favorite" actions in their selected/active state; pair with iconHeart for the unselected state. |
|
|
59
62
|
| `iconHome` | 16px | A primary navigation link to the app's home or dashboard. |
|
|
60
63
|
| `iconInfo` | 20px | Neutral informational messages, e.g. an info toast or status banner. |
|
|
61
|
-
| `iconLink` | 16px |
|
|
64
|
+
| `iconLink` | 16px | Hyperlink-related actions or a linked/associated-item indicator. |
|
|
62
65
|
| `iconListBullet` | 18px | A list-view toggle, or to represent list-type content. |
|
|
66
|
+
| `iconMagnifyingGlass` | 16px | Search inputs or search-triggering actions. |
|
|
63
67
|
| `iconMap` | 16px | A map-view toggle, or to represent map/geographic content. |
|
|
64
68
|
| `iconMapPin` | 16px | A location, address, or map marker. |
|
|
65
69
|
| `iconMoon` | 16px | A dark-theme toggle, or to represent night/dark mode. |
|
|
@@ -72,6 +76,7 @@ table to pick the icon matching a use case, for consistency across apps:
|
|
|
72
76
|
| `iconQueueList` | 16px | Queues, backlogs, or ordered work-item lists. |
|
|
73
77
|
| `iconShieldCheck` | 16px | Verified, secure, or trusted states. |
|
|
74
78
|
| `iconShieldExclamation` | 16px | Security warnings, or at-risk/compromised states. |
|
|
79
|
+
| `iconSignal` | 16px | Live/real-time data, connectivity strength, or a traffic-conditions toggle. |
|
|
75
80
|
| `iconSparkles` | 16px | An AI-powered action (pairs with ui-button's `ai` ring), a gradient-theme toggle, or a decorative/enhanced visual style. |
|
|
76
81
|
| `iconSpeakerWave` | 18px | An unmuted volume control, e.g. audio-player/video-player's mute toggle. |
|
|
77
82
|
| `iconSpeakerXMark` | 18px | A muted volume state; pair with iconSpeakerWave for the unmuted state. |
|
|
@@ -202,9 +207,15 @@ Hovering or keyboard-focusing the toggle reveals a tooltip naming the
|
|
|
202
207
|
action and its `[` shortcut — the shortcut is not shown as permanent
|
|
203
208
|
chrome.
|
|
204
209
|
|
|
210
|
+
Consumers with their own external top bar can set `no-topbar` to skip
|
|
211
|
+
rendering the built-in topbar row and toggle button entirely (the grid
|
|
212
|
+
drops that row rather than leaving dead space). The `[`/Escape shortcuts
|
|
213
|
+
stay fully active either way — drive `sidebar-open` from your own UI and
|
|
214
|
+
listen for `sidebar-toggle` to stay in sync with keyboard-driven changes.
|
|
215
|
+
|
|
205
216
|
Import: `import "@f-ewald/components/app-shell.js";`
|
|
206
217
|
|
|
207
|
-
Properties: `sidebarOpen` (attribute `sidebar-open`) : boolean, default false; `sidebarMode` (attribute `sidebar-mode`) : "overlay" | "push", default "overlay"; `sidebarWidth` (attribute `sidebar-width`) : "full" | "icon", default "full"; `detailOpen` (attribute `detail-open`) : boolean, default false; `detailWidth` (attribute `detail-width`) : "compact" | "comfortable", default "compact"
|
|
218
|
+
Properties: `sidebarOpen` (attribute `sidebar-open`) : boolean, default false; `sidebarMode` (attribute `sidebar-mode`) : "overlay" | "push", default "overlay"; `sidebarWidth` (attribute `sidebar-width`) : "full" | "icon", default "full"; `detailOpen` (attribute `detail-open`) : boolean, default false; `detailWidth` (attribute `detail-width`) : "compact" | "comfortable", default "compact"; `noTopbar` (attribute `no-topbar`) : boolean, default false
|
|
208
219
|
Events: `sidebar-toggle`, `detail-close`
|
|
209
220
|
CSS custom properties: `--ui-border`, `--ui-focus-ring`, `--ui-font-size-sm`, `--ui-line-height-tight`, `--ui-on-accent`, `--ui-overlay`, `--ui-radius-sm`, `--ui-shadow`, `--ui-shadow-lg`, `--ui-surface`, `--ui-surface-muted`, `--ui-text-muted`, `--ui-tooltip`
|
|
210
221
|
|
|
@@ -2485,6 +2496,15 @@ circle, info → information circle, warning → exclamation triangle). Each toa
|
|
|
2485
2496
|
auto-dismisses after `duration` ms and can also be dismissed via its ✕
|
|
2486
2497
|
button. Appears/disappears instantly — no slide/fade transitions.
|
|
2487
2498
|
|
|
2499
|
+
A toast with `duration > 0` replaces its ✕ button with a countdown: a
|
|
2500
|
+
number of seconds remaining inside a ring that fills in clockwise over
|
|
2501
|
+
`duration`. Hovering or keyboard-focusing the toast swaps the countdown
|
|
2502
|
+
back for the ✕ and pauses the countdown (both the visual ring/number and
|
|
2503
|
+
the underlying auto-dismiss timer) — the toast won't disappear while
|
|
2504
|
+
someone's reading it or has tabbed to its close button — resuming from
|
|
2505
|
+
where it left off once the pointer/focus leaves. A `duration: 0` toast has
|
|
2506
|
+
no countdown to show, so its ✕ is always visible, exactly as before.
|
|
2507
|
+
|
|
2488
2508
|
Each variant's background reads a dedicated `--ui-toast-*-background` hook
|
|
2489
2509
|
(`success`/`error`/`info`/`warning`), which defaults to the flat
|
|
2490
2510
|
`--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
|
|
@@ -2503,7 +2523,7 @@ Import: `import "@f-ewald/components/toast-notification.js";`
|
|
|
2503
2523
|
|
|
2504
2524
|
Properties: none
|
|
2505
2525
|
Events: none
|
|
2506
|
-
CSS custom properties: `--ui-button-highlight`, `--ui-button-text-shadow`, `--ui-danger`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size`, `--ui-font-size-sm`, `--ui-font-weight-regular`, `--ui-font-weight-semibold`, `--ui-hover-overlay`, `--ui-info`, `--ui-line-height-glyph`, `--ui-line-height-normal`, `--ui-on-accent`, `--ui-radius`, `--ui-radius-sm`, `--ui-shadow-lg`, `--ui-success`, `--ui-text`, `--ui-toast-`, `--ui-toast-error-background`, `--ui-toast-highlight`, `--ui-toast-info-background`, `--ui-toast-success-background`, `--ui-toast-text-shadow`, `--ui-toast-warning-background`, `--ui-warning`
|
|
2526
|
+
CSS custom properties: `--ui-button-highlight`, `--ui-button-text-shadow`, `--ui-danger`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-regular`, `--ui-font-weight-semibold`, `--ui-hover-overlay`, `--ui-info`, `--ui-line-height-glyph`, `--ui-line-height-normal`, `--ui-on-accent`, `--ui-radius`, `--ui-radius-sm`, `--ui-shadow-lg`, `--ui-success`, `--ui-text`, `--ui-toast-`, `--ui-toast-error-background`, `--ui-toast-highlight`, `--ui-toast-info-background`, `--ui-toast-success-background`, `--ui-toast-text-shadow`, `--ui-toast-warning-background`, `--ui-warning`
|
|
2507
2527
|
|
|
2508
2528
|
Example:
|
|
2509
2529
|
```html
|