@f-ewald/components 1.34.0 → 1.35.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 +222 -1
- package/dist/app-shell.js +1 -1
- package/dist/app-shell.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/toast-notification.md +10 -0
- package/llms.txt +10 -1
- package/package.json +1 -1
package/custom-elements.json
CHANGED
|
@@ -18862,7 +18862,7 @@
|
|
|
18862
18862
|
"declarations": [
|
|
18863
18863
|
{
|
|
18864
18864
|
"kind": "class",
|
|
18865
|
-
"description": "Fixed-position stack of dismissible notifications, anchored top-right\n(top-full-width on mobile). Every toast shares one fixed width so entries\nnever appear narrower or wider than one another. Not wired to any app state\nyet — callers add toasts imperatively via the `show()` method on a live\nelement reference,\ne.g. `document.querySelector('toast-notification')?.show('Offline', { variant: 'error' })`,\nor via the `notifySuccess`/`notifyError`/`notifyInfo` module-level helpers\nexported from this file. The first argument is the required bold headline; an\noptional `description` renders a smaller, non-bold second line. Each variant\nleads with a matching status icon (success → check, error → exclamation\ncircle, info → information circle, warning → exclamation triangle). Each toast\nauto-dismisses after `duration` ms and can also be dismissed via its ✕\nbutton. Appears/disappears instantly — no slide/fade transitions.\n\nEach 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 —\nso those stay the single source of truth for every other component. A\nconsumer can override just these toast-specific tokens with a\n`linear-gradient(...)` to opt every toast into a gradient look without\ntouching component markup — `gradientTokenValues` in `tokens.ts` ships\nexactly 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\nexisting elevation shadow) and `--ui-toast-text-shadow` (legibility\nagainst the gradient's lighter stop) round out the effect, mirroring\n`ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.",
|
|
18865
|
+
"description": "Fixed-position stack of dismissible notifications, anchored top-right\n(top-full-width on mobile). Every toast shares one fixed width so entries\nnever appear narrower or wider than one another. Not wired to any app state\nyet — callers add toasts imperatively via the `show()` method on a live\nelement reference,\ne.g. `document.querySelector('toast-notification')?.show('Offline', { variant: 'error' })`,\nor via the `notifySuccess`/`notifyError`/`notifyInfo` module-level helpers\nexported from this file. The first argument is the required bold headline; an\noptional `description` renders a smaller, non-bold second line. Each variant\nleads with a matching status icon (success → check, error → exclamation\ncircle, info → information circle, warning → exclamation triangle). Each toast\nauto-dismisses after `duration` ms and can also be dismissed via its ✕\nbutton. Appears/disappears instantly — no slide/fade transitions.\n\nA toast with `duration > 0` replaces its ✕ button with a countdown: a\nnumber of seconds remaining inside a ring that fills in clockwise over\n`duration`. Hovering or keyboard-focusing the toast swaps the countdown\nback for the ✕ and pauses the countdown (both the visual ring/number and\nthe underlying auto-dismiss timer) — the toast won't disappear while\nsomeone's reading it or has tabbed to its close button — resuming from\nwhere it left off once the pointer/focus leaves. A `duration: 0` toast has\nno countdown to show, so its ✕ is always visible, exactly as before.\n\nEach 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 —\nso those stay the single source of truth for every other component. A\nconsumer can override just these toast-specific tokens with a\n`linear-gradient(...)` to opt every toast into a gradient look without\ntouching component markup — `gradientTokenValues` in `tokens.ts` ships\nexactly 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\nexisting elevation shadow) and `--ui-toast-text-shadow` (legibility\nagainst the gradient's lighter stop) round out the effect, mirroring\n`ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.",
|
|
18866
18866
|
"name": "ToastNotification",
|
|
18867
18867
|
"members": [
|
|
18868
18868
|
{
|
|
@@ -18889,6 +18889,23 @@
|
|
|
18889
18889
|
"privacy": "private",
|
|
18890
18890
|
"default": "new Map<number, ReturnType<typeof setTimeout>>()"
|
|
18891
18891
|
},
|
|
18892
|
+
{
|
|
18893
|
+
"kind": "field",
|
|
18894
|
+
"name": "_interaction",
|
|
18895
|
+
"privacy": "private",
|
|
18896
|
+
"default": "new Map<number, { hovered: boolean; focusWithin: boolean }>()",
|
|
18897
|
+
"description": "Per-toast hover/focus tracking, so leaving one doesn't resume while the other still applies."
|
|
18898
|
+
},
|
|
18899
|
+
{
|
|
18900
|
+
"kind": "field",
|
|
18901
|
+
"name": "_tickTimer",
|
|
18902
|
+
"type": {
|
|
18903
|
+
"text": "ReturnType<typeof setInterval> | null"
|
|
18904
|
+
},
|
|
18905
|
+
"privacy": "private",
|
|
18906
|
+
"default": "null",
|
|
18907
|
+
"description": "Ticks while any toast has a running countdown, purely to refresh the displayed seconds."
|
|
18908
|
+
},
|
|
18892
18909
|
{
|
|
18893
18910
|
"kind": "method",
|
|
18894
18911
|
"name": "show",
|
|
@@ -18930,6 +18947,197 @@
|
|
|
18930
18947
|
],
|
|
18931
18948
|
"description": "Removes a toast immediately, cancelling its pending auto-dismiss timer if any."
|
|
18932
18949
|
},
|
|
18950
|
+
{
|
|
18951
|
+
"kind": "method",
|
|
18952
|
+
"name": "_scheduleTimer",
|
|
18953
|
+
"privacy": "private",
|
|
18954
|
+
"return": {
|
|
18955
|
+
"type": {
|
|
18956
|
+
"text": "void"
|
|
18957
|
+
}
|
|
18958
|
+
},
|
|
18959
|
+
"parameters": [
|
|
18960
|
+
{
|
|
18961
|
+
"name": "id",
|
|
18962
|
+
"type": {
|
|
18963
|
+
"text": "number"
|
|
18964
|
+
}
|
|
18965
|
+
},
|
|
18966
|
+
{
|
|
18967
|
+
"name": "ms",
|
|
18968
|
+
"type": {
|
|
18969
|
+
"text": "number"
|
|
18970
|
+
}
|
|
18971
|
+
}
|
|
18972
|
+
],
|
|
18973
|
+
"description": "Schedules (or reschedules) the real auto-dismiss timeout for a toast."
|
|
18974
|
+
},
|
|
18975
|
+
{
|
|
18976
|
+
"kind": "method",
|
|
18977
|
+
"name": "_pause",
|
|
18978
|
+
"privacy": "private",
|
|
18979
|
+
"return": {
|
|
18980
|
+
"type": {
|
|
18981
|
+
"text": "void"
|
|
18982
|
+
}
|
|
18983
|
+
},
|
|
18984
|
+
"parameters": [
|
|
18985
|
+
{
|
|
18986
|
+
"name": "id",
|
|
18987
|
+
"type": {
|
|
18988
|
+
"text": "number"
|
|
18989
|
+
}
|
|
18990
|
+
}
|
|
18991
|
+
],
|
|
18992
|
+
"description": "Freezes a toast's countdown at its current remaining time."
|
|
18993
|
+
},
|
|
18994
|
+
{
|
|
18995
|
+
"kind": "method",
|
|
18996
|
+
"name": "_resume",
|
|
18997
|
+
"privacy": "private",
|
|
18998
|
+
"return": {
|
|
18999
|
+
"type": {
|
|
19000
|
+
"text": "void"
|
|
19001
|
+
}
|
|
19002
|
+
},
|
|
19003
|
+
"parameters": [
|
|
19004
|
+
{
|
|
19005
|
+
"name": "id",
|
|
19006
|
+
"type": {
|
|
19007
|
+
"text": "number"
|
|
19008
|
+
}
|
|
19009
|
+
}
|
|
19010
|
+
],
|
|
19011
|
+
"description": "Resumes a paused toast's countdown for whatever time was remaining."
|
|
19012
|
+
},
|
|
19013
|
+
{
|
|
19014
|
+
"kind": "method",
|
|
19015
|
+
"name": "_syncTicking",
|
|
19016
|
+
"privacy": "private",
|
|
19017
|
+
"return": {
|
|
19018
|
+
"type": {
|
|
19019
|
+
"text": "void"
|
|
19020
|
+
}
|
|
19021
|
+
},
|
|
19022
|
+
"description": "Starts or stops the shared display-only tick, matching whether any countdown is actually running."
|
|
19023
|
+
},
|
|
19024
|
+
{
|
|
19025
|
+
"kind": "method",
|
|
19026
|
+
"name": "_interactionState",
|
|
19027
|
+
"privacy": "private",
|
|
19028
|
+
"return": {
|
|
19029
|
+
"type": {
|
|
19030
|
+
"text": "{ hovered: boolean; focusWithin: boolean }"
|
|
19031
|
+
}
|
|
19032
|
+
},
|
|
19033
|
+
"parameters": [
|
|
19034
|
+
{
|
|
19035
|
+
"name": "id",
|
|
19036
|
+
"type": {
|
|
19037
|
+
"text": "number"
|
|
19038
|
+
}
|
|
19039
|
+
}
|
|
19040
|
+
],
|
|
19041
|
+
"description": "Reads (creating if absent) a toast's hover/focus tracking record."
|
|
19042
|
+
},
|
|
19043
|
+
{
|
|
19044
|
+
"kind": "method",
|
|
19045
|
+
"name": "_onMouseEnter",
|
|
19046
|
+
"privacy": "private",
|
|
19047
|
+
"return": {
|
|
19048
|
+
"type": {
|
|
19049
|
+
"text": "void"
|
|
19050
|
+
}
|
|
19051
|
+
},
|
|
19052
|
+
"parameters": [
|
|
19053
|
+
{
|
|
19054
|
+
"name": "id",
|
|
19055
|
+
"type": {
|
|
19056
|
+
"text": "number"
|
|
19057
|
+
}
|
|
19058
|
+
}
|
|
19059
|
+
]
|
|
19060
|
+
},
|
|
19061
|
+
{
|
|
19062
|
+
"kind": "method",
|
|
19063
|
+
"name": "_onMouseLeave",
|
|
19064
|
+
"privacy": "private",
|
|
19065
|
+
"return": {
|
|
19066
|
+
"type": {
|
|
19067
|
+
"text": "void"
|
|
19068
|
+
}
|
|
19069
|
+
},
|
|
19070
|
+
"parameters": [
|
|
19071
|
+
{
|
|
19072
|
+
"name": "id",
|
|
19073
|
+
"type": {
|
|
19074
|
+
"text": "number"
|
|
19075
|
+
}
|
|
19076
|
+
}
|
|
19077
|
+
]
|
|
19078
|
+
},
|
|
19079
|
+
{
|
|
19080
|
+
"kind": "method",
|
|
19081
|
+
"name": "_onFocusIn",
|
|
19082
|
+
"privacy": "private",
|
|
19083
|
+
"return": {
|
|
19084
|
+
"type": {
|
|
19085
|
+
"text": "void"
|
|
19086
|
+
}
|
|
19087
|
+
},
|
|
19088
|
+
"parameters": [
|
|
19089
|
+
{
|
|
19090
|
+
"name": "id",
|
|
19091
|
+
"type": {
|
|
19092
|
+
"text": "number"
|
|
19093
|
+
}
|
|
19094
|
+
}
|
|
19095
|
+
]
|
|
19096
|
+
},
|
|
19097
|
+
{
|
|
19098
|
+
"kind": "method",
|
|
19099
|
+
"name": "_onFocusOut",
|
|
19100
|
+
"privacy": "private",
|
|
19101
|
+
"return": {
|
|
19102
|
+
"type": {
|
|
19103
|
+
"text": "void"
|
|
19104
|
+
}
|
|
19105
|
+
},
|
|
19106
|
+
"parameters": [
|
|
19107
|
+
{
|
|
19108
|
+
"name": "id",
|
|
19109
|
+
"type": {
|
|
19110
|
+
"text": "number"
|
|
19111
|
+
}
|
|
19112
|
+
},
|
|
19113
|
+
{
|
|
19114
|
+
"name": "event",
|
|
19115
|
+
"type": {
|
|
19116
|
+
"text": "FocusEvent"
|
|
19117
|
+
}
|
|
19118
|
+
}
|
|
19119
|
+
],
|
|
19120
|
+
"description": "Rechecks focus-within on a microtask, since focusout fires before the new focus target settles."
|
|
19121
|
+
},
|
|
19122
|
+
{
|
|
19123
|
+
"kind": "method",
|
|
19124
|
+
"name": "_secondsLeft",
|
|
19125
|
+
"privacy": "private",
|
|
19126
|
+
"return": {
|
|
19127
|
+
"type": {
|
|
19128
|
+
"text": "number"
|
|
19129
|
+
}
|
|
19130
|
+
},
|
|
19131
|
+
"parameters": [
|
|
19132
|
+
{
|
|
19133
|
+
"name": "t",
|
|
19134
|
+
"type": {
|
|
19135
|
+
"text": "Toast"
|
|
19136
|
+
}
|
|
19137
|
+
}
|
|
19138
|
+
],
|
|
19139
|
+
"description": "Whole seconds remaining until auto-dismiss, for the countdown number."
|
|
19140
|
+
},
|
|
18933
19141
|
{
|
|
18934
19142
|
"kind": "method",
|
|
18935
19143
|
"name": "_variantIcon",
|
|
@@ -18953,6 +19161,19 @@
|
|
|
18953
19161
|
"tagName": "toast-notification",
|
|
18954
19162
|
"customElement": true
|
|
18955
19163
|
},
|
|
19164
|
+
{
|
|
19165
|
+
"kind": "variable",
|
|
19166
|
+
"name": "id",
|
|
19167
|
+
"default": "this._nextId++"
|
|
19168
|
+
},
|
|
19169
|
+
{
|
|
19170
|
+
"kind": "variable",
|
|
19171
|
+
"name": "variant"
|
|
19172
|
+
},
|
|
19173
|
+
{
|
|
19174
|
+
"kind": "variable",
|
|
19175
|
+
"name": "duration"
|
|
19176
|
+
},
|
|
18956
19177
|
{
|
|
18957
19178
|
"kind": "function",
|
|
18958
19179
|
"name": "notifyError",
|
package/dist/app-shell.js
CHANGED
|
@@ -166,7 +166,7 @@ let AppShell = class AppShell extends LitElement {
|
|
|
166
166
|
border-right: 1px solid var(--ui-border, #e2e8f0);
|
|
167
167
|
background: var(--ui-surface, #ffffff);
|
|
168
168
|
transform: translateX(-100%);
|
|
169
|
-
transition: transform
|
|
169
|
+
transition: transform 150ms ease;
|
|
170
170
|
}
|
|
171
171
|
:host([sidebar-open]) .sidebar {
|
|
172
172
|
transform: translateX(0);
|
package/dist/app-shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-shell.js","sourceRoot":"","sources":["../src/app-shell.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAQrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QACL,0EAA0E;QACH,gBAAW,GAAG,KAAK,CAAC;QAC3F,uGAAuG;QAC/C,gBAAW,GAAuB,SAAS,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3C,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;;;;mBAI/B,IAAI,CAAC,QAAQ;oBACZ,CAAC,WAAW;;;KAG3B,CAAC;IACJ,CAAC;IAED,gEAAgE;IACxD,mBAAmB,CAAC,KAAY;QACtC,IAAI,CAAC,UAAU,GAAI,KAAK,CAAC,MAA0B,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAClG,CAAC;CACF,CAAA;AA3awE;IAAtE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAAqB;AAEnC;IAAvD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAA6C;AAE3C;IAAxD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;8CAAwC;AAE1B;IAArE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;4CAAoB;AAEhD;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAAoD;AAG3E;IAAhB,KAAK,EAAE;yCAAyB;AAEhB;IAAhB,KAAK,EAAE;4CAA4B;AAfzB,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA6apB","sourcesContent":["import { LitElement, css, html, type PropertyValues } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconBars3 } from \"./icons.js\";\nimport \"./kbd-hint.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** Fired when the built-in toggle changes the sidebar state. */\nexport interface SidebarToggleDetail {\n /** Whether the sidebar is now open. */\n open: boolean;\n}\n\n/**\n * The dashboard page shell: a slot-based CSS-grid backbone that arranges a\n * top bar, the main content, an optional right-hand detail column, an\n * optional footer, and a sidebar. The top bar always spans the shell's full\n * width, in every sidebar state.\n *\n * The sidebar's visibility, width, and layout mode are three independent\n * properties:\n * - `sidebar-open` (default closed) — whether it's shown at all.\n * - `sidebar-width`: `\"full\"` (16rem, icons + labels, the default) or\n * `\"icon\"` (3.5rem rail, icons only — drives the slotted `app-sidebar`'s\n * own `collapsed` attribute).\n * - `sidebar-mode`: `\"overlay\"` (the default) floats the sidebar above the\n * shell's own content with a higher z-index, covering part of the top\n * bar's corner and whatever content sits beneath it, without ever\n * resizing or reflowing `main`/`footer`. `\"push\"` instead reserves a real\n * grid column beside `main`/`footer` (which resize to make room) — the\n * top bar still spans full width above it either way.\n *\n * Below the shared 48rem breakpoint the sidebar always behaves as a\n * full-width, modal, scrim/Escape-dismissible drawer regardless of\n * `sidebar-mode`/`sidebar-width` — those two properties only affect the\n * desktop presentation. Above 48rem, an `overlay`-mode sidebar is a\n * non-modal panel (no dimming scrim, no Escape-dismiss, since it reads as\n * an ordinary always-interactive panel rather than a blocking dialog); a\n * `push`-mode sidebar is even more clearly non-modal, since it never\n * covers anything.\n *\n * The right-hand detail column is unaffected by any of the above: it still\n * reserves an inline grid column on desktop and becomes a dismissible\n * overlay (scrim/Escape) on mobile.\n *\n * Widths are tunable per instance via `--component-sidebar-width` (16rem),\n * `--component-sidebar-rail-width` (3.5rem), and `--component-topbar-height`\n * (3rem); the detail column reuses the 20rem/25rem panel widths. The main\n * content area is white by default — override it with\n * `--component-main-background`. Give the shell a height (e.g. `height:\n * 100vh`) so the sidebar and main can size and scroll.\n *\n * Hovering or keyboard-focusing the toggle reveals a tooltip naming the\n * action and its `[` shortcut — the shortcut is not shown as permanent\n * chrome.\n *\n * @element app-shell\n * @slot - Main content area.\n * @slot sidebar - Sidebar navigation (typically `app-sidebar`).\n * @slot topbar - Top bar content, right of the built-in toggle.\n * @slot detail - Optional right-hand detail; shown when `detail-open` is set.\n * @slot footer - Optional footer beneath the main content.\n * @fires sidebar-toggle - The built-in toggle changed the sidebar state.\n * @fires detail-close - The scrim or Escape dismissed the mobile detail overlay.\n */\n@customElement(\"app-shell\")\nexport class AppShell extends LitElement {\n /** Whether the sidebar is open. Closed by default at every breakpoint. */\n @property({ type: Boolean, reflect: true, attribute: \"sidebar-open\" }) sidebarOpen = false;\n /** `\"overlay\"` (default) floats the sidebar above content; `\"push\"` reserves a grid column instead. */\n @property({ reflect: true, attribute: \"sidebar-mode\" }) sidebarMode: \"overlay\" | \"push\" = \"overlay\";\n /** Sidebar width when open: `\"full\"` (16rem, icons + labels) or `\"icon\"` (3.5rem rail, icons only). */\n @property({ reflect: true, attribute: \"sidebar-width\" }) sidebarWidth: \"full\" | \"icon\" = \"full\";\n /** Shows the right-hand detail region (inline column, or overlay on mobile). */\n @property({ type: Boolean, reflect: true, attribute: \"detail-open\" }) detailOpen = false;\n /** Detail width: `compact` (20rem) or `comfortable` (25rem). */\n @property({ attribute: \"detail-width\" }) detailWidth: \"compact\" | \"comfortable\" = \"compact\";\n\n /** Whether the viewport is at/below the 48rem breakpoint. */\n @state() private _mobile = false;\n /** Whether the footer slot has assigned content. */\n @state() private _hasFooter = false;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n block-size: 100%;\n }\n .shell {\n --_sidebar-w: 0px;\n --_detail-w: 0px;\n display: grid;\n grid-template-columns: var(--_sidebar-w) minmax(0, 1fr) var(--_detail-w);\n grid-template-rows: auto minmax(0, 1fr) auto;\n grid-template-areas:\n \"topbar topbar topbar\"\n \"sidebar main detail\"\n \"sidebar footer footer\";\n position: relative;\n block-size: 100%;\n min-height: 0;\n background: var(--ui-surface, #ffffff);\n }\n :host([detail-open]) .shell {\n --_detail-w: 20rem;\n }\n :host([detail-open][detail-width=\"comfortable\"]) .shell {\n --_detail-w: 25rem;\n }\n /* Push mode reserves a real grid column, sized only while open — the\n column width doesn't animate (custom properties feeding a grid\n track don't transition smoothly without @property registration),\n so push mode's open/close is an instant snap, unlike overlay\n mode's sliding transform. */\n :host([sidebar-mode=\"push\"][sidebar-open]) .shell {\n --_sidebar-w: var(--component-sidebar-width, 16rem);\n }\n :host([sidebar-mode=\"push\"][sidebar-open][sidebar-width=\"icon\"]) .shell {\n --_sidebar-w: var(--component-sidebar-rail-width, 3.5rem);\n }\n .sidebar {\n /* No grid-area here: an absolutely-positioned grid item's inset\n properties resolve against its OWN grid area's box, not the\n whole grid container, once grid-area is set — even with\n explicit (non-auto) insets. Overlay mode must stay anchored to\n the whole .shell (to overlap the topbar row), so grid-area is\n assigned only in push mode below, where the sidebar is a real,\n in-flow grid item instead of an absolutely-positioned one. */\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n width: var(--component-sidebar-width, 16rem);\n z-index: 40;\n overflow: hidden;\n border-right: 1px solid var(--ui-border, #e2e8f0);\n background: var(--ui-surface, #ffffff);\n transform: translateX(-100%);\n transition: transform 250ms ease;\n }\n :host([sidebar-open]) .sidebar {\n transform: translateX(0);\n }\n :host([sidebar-open]:not([sidebar-mode=\"push\"])) .sidebar {\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 }\n :host([sidebar-width=\"icon\"]) .sidebar {\n width: var(--component-sidebar-rail-width, 3.5rem);\n }\n :host([sidebar-mode=\"push\"]) .sidebar {\n grid-area: sidebar;\n position: static;\n width: 100%;\n transform: none;\n }\n .topbar {\n grid-area: topbar;\n display: flex;\n align-items: center;\n gap: 0.5rem;\n min-height: var(--component-topbar-height, 3rem);\n padding: 0.5rem 0.75rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n background: var(--ui-surface, #ffffff);\n /* Deliberately no z-index here: an explicit z-index on a CSS grid\n item creates a stacking context, which would trap .nav-toggle\n below .sidebar once an overlay-mode sidebar opens and covers this\n corner. See CLAUDE.md before adding one. */\n }\n .nav-toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n width: 2rem;\n height: 2rem;\n padding: 0;\n background: none;\n border: none;\n cursor: pointer;\n color: var(--ui-text-muted, #64748b);\n border-radius: var(--ui-radius-sm, 0.25rem);\n }\n .nav-group {\n position: relative;\n z-index: 41;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n flex: 0 0 auto;\n }\n .nav-tip {\n position: absolute;\n top: 100%;\n left: 0;\n margin-top: 0.25rem;\n z-index: 10;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n white-space: nowrap;\n padding: 0.25rem 0.5rem;\n border-radius: var(--ui-radius-sm, 0.25rem);\n background: var(--ui-tooltip, #0f172a);\n color: var(--ui-on-accent, #ffffff);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n font-size: var(--ui-font-size-sm, 0.75rem);\n line-height: var(--ui-line-height-tight, 1.25);\n opacity: 0;\n visibility: hidden;\n pointer-events: none;\n transition: opacity 120ms ease;\n }\n .nav-toggle:hover + .nav-tip,\n .nav-toggle:focus-visible + .nav-tip {\n opacity: 1;\n visibility: visible;\n }\n .nav-toggle:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .nav-toggle:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .topbar-content {\n flex: 1 1 auto;\n min-width: 0;\n }\n .main {\n grid-area: main;\n min-height: 0;\n min-width: 0;\n overflow: auto;\n padding: 1rem;\n background: var(--component-main-background, var(--ui-surface, #ffffff));\n }\n .detail {\n grid-area: detail;\n display: none;\n min-height: 0;\n overflow: auto;\n border-left: 1px solid var(--ui-border, #e2e8f0);\n background: var(--ui-surface, #ffffff);\n }\n :host([detail-open]) .detail {\n display: block;\n }\n .footer {\n grid-area: footer;\n padding: 0.5rem 0.75rem;\n border-top: 1px solid var(--ui-border, #e2e8f0);\n background: var(--ui-surface, #ffffff);\n }\n .footer.empty {\n display: none;\n }\n .scrim {\n display: none;\n }\n @media (max-width: 48rem) {\n .shell {\n grid-template-columns: minmax(0, 1fr) var(--_detail-w);\n grid-template-areas:\n \"topbar topbar\"\n \"main detail\"\n \"footer footer\";\n }\n /* Mobile is always a full-screen, position:absolute overlay drawer,\n regardless of sidebar-mode/sidebar-width — those two properties\n only affect the desktop presentation. */\n .sidebar,\n :host([sidebar-mode=\"push\"]) .sidebar {\n position: absolute;\n width: 100%;\n }\n .detail {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n width: var(--_detail-w, 20rem);\n max-width: calc(100vw - 3rem);\n z-index: 40;\n transform: translateX(110%);\n transition: transform 250ms ease;\n }\n :host([detail-open]) .detail {\n transform: translateX(0);\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 }\n .scrim.show {\n display: block;\n position: absolute;\n inset: 0;\n z-index: 39;\n background: var(--ui-overlay, rgb(15 23 42 / 0.45));\n border: none;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .sidebar,\n .detail,\n .nav-tip {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .nav-toggle:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .nav-tip {\n border: 1px solid CanvasText;\n }\n }\n `,\n ];\n\n private _mediaQuery: MediaQueryList | null = null;\n private _previousFocus: HTMLElement | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this._mediaQuery = window.matchMedia(\"(max-width: 48rem)\");\n this._mobile = this._mediaQuery.matches;\n this._mediaQuery.addEventListener(\"change\", this._onMediaChange);\n window.addEventListener(\"keydown\", this._onKeydown);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._mediaQuery?.removeEventListener(\"change\", this._onMediaChange);\n this._mediaQuery = null;\n window.removeEventListener(\"keydown\", this._onKeydown);\n }\n\n /** Tracks the breakpoint the sidebar's width and modality depend on. */\n private _onMediaChange = (event: MediaQueryListEvent): void => {\n this._mobile = event.matches;\n };\n\n /** Handles the `[` sidebar shortcut and Escape dismissal of mobile overlays. */\n private _onKeydown = (event: KeyboardEvent): void => {\n if (event.defaultPrevented) return;\n if (event.key === \"Escape\" && this._mobile) {\n if (this.detailOpen) {\n event.preventDefault();\n this._closeDetail();\n } else if (this.sidebarOpen) {\n event.preventDefault();\n this.sidebarOpen = false;\n }\n return;\n }\n if (\n event.key === \"[\" &&\n !event.ctrlKey &&\n !event.metaKey &&\n !event.altKey &&\n !this._isEditableTarget(event)\n ) {\n event.preventDefault();\n this._toggleSidebar();\n }\n };\n\n /** Whether the keydown originated in a text field, so the shortcut defers to typing. */\n private _isEditableTarget(event: KeyboardEvent): boolean {\n const target = event.composedPath()[0] as HTMLElement | undefined;\n if (!target) return false;\n if (target.isContentEditable) return true;\n const tag = target.tagName;\n return tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\";\n }\n\n /** Toggles the sidebar and announces it. */\n private _toggleSidebar(): void {\n this.sidebarOpen = !this.sidebarOpen;\n if (this._mobile && this.sidebarOpen) {\n this._previousFocus = document.activeElement as HTMLElement | null;\n }\n this.dispatchEvent(\n new CustomEvent<SidebarToggleDetail>(\"sidebar-toggle\", {\n detail: { open: this.sidebarOpen },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n /** Closes the detail overlay and notifies the consumer that owns `detail-open`. */\n private _closeDetail(): void {\n this.detailOpen = false;\n this.dispatchEvent(new CustomEvent(\"detail-close\", { bubbles: true, composed: true }));\n }\n\n /** Scrim click dismisses whichever overlay is open. */\n private _onScrim(): void {\n if (this.detailOpen) this._closeDetail();\n if (this.sidebarOpen) this.sidebarOpen = false;\n }\n\n /** Mirrors `sidebar-width` onto the slotted sidebar's `collapsed` (icon rail) attribute. */\n private _syncSidebarWidth(): void {\n const icon = this.sidebarWidth === \"icon\";\n const slot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"sidebar\"]');\n for (const element of slot?.assignedElements() ?? []) {\n element.toggleAttribute(\"collapsed\", icon);\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"sidebarWidth\")) this._syncSidebarWidth();\n if (!changed.has(\"sidebarOpen\") || !this._mobile) return;\n if (this.sidebarOpen) {\n this.shadowRoot?.querySelector<HTMLElement>(\".sidebar\")?.focus();\n return;\n }\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override render() {\n const scrimActive = this._mobile && (this.sidebarOpen || this.detailOpen);\n return html`\n <div class=\"shell\">\n <aside\n class=\"sidebar\"\n tabindex=\"-1\"\n aria-label=\"Primary\"\n ?inert=${!this.sidebarOpen}\n aria-hidden=${String(!this.sidebarOpen)}\n >\n <slot name=\"sidebar\" @slotchange=${this._syncSidebarWidth}></slot>\n </aside>\n <header class=\"topbar\">\n <div class=\"nav-group\">\n <button\n class=\"nav-toggle\"\n type=\"button\"\n aria-label=\"Toggle navigation\"\n aria-keyshortcuts=\"[\"\n aria-describedby=\"nav-tip\"\n aria-expanded=${String(this.sidebarOpen)}\n @click=${this._toggleSidebar}\n >\n ${iconBars3(18)}\n </button>\n <span class=\"nav-tip\" id=\"nav-tip\" role=\"tooltip\">\n <span>${this.sidebarOpen ? \"Hide navigation\" : \"Show navigation\"}</span>\n <kbd-hint keys=\"[\"></kbd-hint>\n </span>\n </div>\n <div class=\"topbar-content\"><slot name=\"topbar\"></slot></div>\n </header>\n <main class=\"main\"><slot></slot></main>\n <aside\n class=\"detail\"\n aria-label=\"Detail\"\n ?inert=${!this.detailOpen}\n aria-hidden=${String(!this.detailOpen)}\n >\n <slot name=\"detail\"></slot>\n </aside>\n <footer class=\"footer ${this._hasFooter ? \"\" : \"empty\"}\">\n <slot name=\"footer\" @slotchange=${this._onFooterSlotChange}></slot>\n </footer>\n <button\n class=\"scrim ${scrimActive ? \"show\" : \"\"}\"\n type=\"button\"\n tabindex=\"-1\"\n aria-label=\"Close\"\n @click=${this._onScrim}\n ?hidden=${!scrimActive}\n ></button>\n </div>\n `;\n }\n\n /** Collapses the footer row when nothing is slotted into it. */\n private _onFooterSlotChange(event: Event): void {\n this._hasFooter = (event.target as HTMLSlotElement).assignedNodes({ flatten: true }).length > 0;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"app-shell\": AppShell;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"app-shell.js","sourceRoot":"","sources":["../src/app-shell.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAQrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QACL,0EAA0E;QACH,gBAAW,GAAG,KAAK,CAAC;QAC3F,uGAAuG;QAC/C,gBAAW,GAAuB,SAAS,CAAC;QACpG,uGAAuG;QAC9C,iBAAY,GAAoB,MAAM,CAAC;QAChG,gFAAgF;QACV,eAAU,GAAG,KAAK,CAAC;QACzF,gEAAgE;QACvB,gBAAW,GAA8B,SAAS,CAAC;QAE5F,6DAA6D;QAC5C,YAAO,GAAG,KAAK,CAAC;QACjC,oDAAoD;QACnC,eAAU,GAAG,KAAK,CAAC;QAyP5B,gBAAW,GAA0B,IAAI,CAAC;QAC1C,mBAAc,GAAuB,IAAI,CAAC;QAiBlD,wEAAwE;QAChE,mBAAc,GAAG,CAAC,KAA0B,EAAQ,EAAE;YAC5D,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC/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AAc,EAAE,CAAC;6CAAqB;AAEnC;IAAvD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAA6C;AAE3C;IAAxD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;8CAAwC;AAE1B;IAArE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;4CAAoB;AAEhD;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAAoD;AAG3E;IAAhB,KAAK,EAAE;yCAAyB;AAEhB;IAAhB,KAAK,EAAE;4CAA4B;AAfzB,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA6apB","sourcesContent":["import { LitElement, css, html, type PropertyValues } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconBars3 } from \"./icons.js\";\nimport \"./kbd-hint.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** Fired when the built-in toggle changes the sidebar state. */\nexport interface SidebarToggleDetail {\n /** Whether the sidebar is now open. */\n open: boolean;\n}\n\n/**\n * The dashboard page shell: a slot-based CSS-grid backbone that arranges a\n * top bar, the main content, an optional right-hand detail column, an\n * optional footer, and a sidebar. The top bar always spans the shell's full\n * width, in every sidebar state.\n *\n * The sidebar's visibility, width, and layout mode are three independent\n * properties:\n * - `sidebar-open` (default closed) — whether it's shown at all.\n * - `sidebar-width`: `\"full\"` (16rem, icons + labels, the default) or\n * `\"icon\"` (3.5rem rail, icons only — drives the slotted `app-sidebar`'s\n * own `collapsed` attribute).\n * - `sidebar-mode`: `\"overlay\"` (the default) floats the sidebar above the\n * shell's own content with a higher z-index, covering part of the top\n * bar's corner and whatever content sits beneath it, without ever\n * resizing or reflowing `main`/`footer`. `\"push\"` instead reserves a real\n * grid column beside `main`/`footer` (which resize to make room) — the\n * top bar still spans full width above it either way.\n *\n * Below the shared 48rem breakpoint the sidebar always behaves as a\n * full-width, modal, scrim/Escape-dismissible drawer regardless of\n * `sidebar-mode`/`sidebar-width` — those two properties only affect the\n * desktop presentation. Above 48rem, an `overlay`-mode sidebar is a\n * non-modal panel (no dimming scrim, no Escape-dismiss, since it reads as\n * an ordinary always-interactive panel rather than a blocking dialog); a\n * `push`-mode sidebar is even more clearly non-modal, since it never\n * covers anything.\n *\n * The right-hand detail column is unaffected by any of the above: it still\n * reserves an inline grid column on desktop and becomes a dismissible\n * overlay (scrim/Escape) on mobile.\n *\n * Widths are tunable per instance via `--component-sidebar-width` (16rem),\n * `--component-sidebar-rail-width` (3.5rem), and `--component-topbar-height`\n * (3rem); the detail column reuses the 20rem/25rem panel widths. The main\n * content area is white by default — override it with\n * `--component-main-background`. Give the shell a height (e.g. `height:\n * 100vh`) so the sidebar and main can size and scroll.\n *\n * Hovering or keyboard-focusing the toggle reveals a tooltip naming the\n * action and its `[` shortcut — the shortcut is not shown as permanent\n * chrome.\n *\n * @element app-shell\n * @slot - Main content area.\n * @slot sidebar - Sidebar navigation (typically `app-sidebar`).\n * @slot topbar - Top bar content, right of the built-in toggle.\n * @slot detail - Optional right-hand detail; shown when `detail-open` is set.\n * @slot footer - Optional footer beneath the main content.\n * @fires sidebar-toggle - The built-in toggle changed the sidebar state.\n * @fires detail-close - The scrim or Escape dismissed the mobile detail overlay.\n */\n@customElement(\"app-shell\")\nexport class AppShell extends LitElement {\n /** Whether the sidebar is open. Closed by default at every breakpoint. */\n @property({ type: Boolean, reflect: true, attribute: \"sidebar-open\" }) sidebarOpen = false;\n /** `\"overlay\"` (default) floats the sidebar above content; `\"push\"` reserves a grid column instead. */\n @property({ reflect: true, attribute: \"sidebar-mode\" }) sidebarMode: \"overlay\" | \"push\" = \"overlay\";\n /** Sidebar width when open: `\"full\"` (16rem, icons + labels) or `\"icon\"` (3.5rem rail, icons only). */\n @property({ reflect: true, attribute: \"sidebar-width\" }) sidebarWidth: \"full\" | \"icon\" = \"full\";\n /** Shows the right-hand detail region (inline column, or overlay on mobile). */\n @property({ type: Boolean, reflect: true, attribute: \"detail-open\" }) detailOpen = false;\n /** Detail width: `compact` (20rem) or `comfortable` (25rem). */\n @property({ attribute: \"detail-width\" }) detailWidth: \"compact\" | \"comfortable\" = \"compact\";\n\n /** Whether the viewport is at/below the 48rem breakpoint. */\n @state() private _mobile = false;\n /** Whether the footer slot has assigned content. */\n @state() private _hasFooter = false;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n block-size: 100%;\n }\n .shell {\n --_sidebar-w: 0px;\n --_detail-w: 0px;\n display: grid;\n grid-template-columns: var(--_sidebar-w) minmax(0, 1fr) var(--_detail-w);\n grid-template-rows: auto minmax(0, 1fr) auto;\n grid-template-areas:\n \"topbar topbar topbar\"\n \"sidebar main detail\"\n \"sidebar footer footer\";\n position: relative;\n block-size: 100%;\n min-height: 0;\n background: var(--ui-surface, #ffffff);\n }\n :host([detail-open]) .shell {\n --_detail-w: 20rem;\n }\n :host([detail-open][detail-width=\"comfortable\"]) .shell {\n --_detail-w: 25rem;\n }\n /* Push mode reserves a real grid column, sized only while open — the\n column width doesn't animate (custom properties feeding a grid\n track don't transition smoothly without @property registration),\n so push mode's open/close is an instant snap, unlike overlay\n mode's sliding transform. */\n :host([sidebar-mode=\"push\"][sidebar-open]) .shell {\n --_sidebar-w: var(--component-sidebar-width, 16rem);\n }\n :host([sidebar-mode=\"push\"][sidebar-open][sidebar-width=\"icon\"]) .shell {\n --_sidebar-w: var(--component-sidebar-rail-width, 3.5rem);\n }\n .sidebar {\n /* No grid-area here: an absolutely-positioned grid item's inset\n properties resolve against its OWN grid area's box, not the\n whole grid container, once grid-area is set — even with\n explicit (non-auto) insets. Overlay mode must stay anchored to\n the whole .shell (to overlap the topbar row), so grid-area is\n assigned only in push mode below, where the sidebar is a real,\n in-flow grid item instead of an absolutely-positioned one. */\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n width: var(--component-sidebar-width, 16rem);\n z-index: 40;\n overflow: hidden;\n border-right: 1px solid var(--ui-border, #e2e8f0);\n background: var(--ui-surface, #ffffff);\n transform: translateX(-100%);\n transition: transform 150ms ease;\n }\n :host([sidebar-open]) .sidebar {\n transform: translateX(0);\n }\n :host([sidebar-open]:not([sidebar-mode=\"push\"])) .sidebar {\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 }\n :host([sidebar-width=\"icon\"]) .sidebar {\n width: var(--component-sidebar-rail-width, 3.5rem);\n }\n :host([sidebar-mode=\"push\"]) .sidebar {\n grid-area: sidebar;\n position: static;\n width: 100%;\n transform: none;\n }\n .topbar {\n grid-area: topbar;\n display: flex;\n align-items: center;\n gap: 0.5rem;\n min-height: var(--component-topbar-height, 3rem);\n padding: 0.5rem 0.75rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n background: var(--ui-surface, #ffffff);\n /* Deliberately no z-index here: an explicit z-index on a CSS grid\n item creates a stacking context, which would trap .nav-toggle\n below .sidebar once an overlay-mode sidebar opens and covers this\n corner. See CLAUDE.md before adding one. */\n }\n .nav-toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n width: 2rem;\n height: 2rem;\n padding: 0;\n background: none;\n border: none;\n cursor: pointer;\n color: var(--ui-text-muted, #64748b);\n border-radius: var(--ui-radius-sm, 0.25rem);\n }\n .nav-group {\n position: relative;\n z-index: 41;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n flex: 0 0 auto;\n }\n .nav-tip {\n position: absolute;\n top: 100%;\n left: 0;\n margin-top: 0.25rem;\n z-index: 10;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n white-space: nowrap;\n padding: 0.25rem 0.5rem;\n border-radius: var(--ui-radius-sm, 0.25rem);\n background: var(--ui-tooltip, #0f172a);\n color: var(--ui-on-accent, #ffffff);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n font-size: var(--ui-font-size-sm, 0.75rem);\n line-height: var(--ui-line-height-tight, 1.25);\n opacity: 0;\n visibility: hidden;\n pointer-events: none;\n transition: opacity 120ms ease;\n }\n .nav-toggle:hover + .nav-tip,\n .nav-toggle:focus-visible + .nav-tip {\n opacity: 1;\n visibility: visible;\n }\n .nav-toggle:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .nav-toggle:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .topbar-content {\n flex: 1 1 auto;\n min-width: 0;\n }\n .main {\n grid-area: main;\n min-height: 0;\n min-width: 0;\n overflow: auto;\n padding: 1rem;\n background: var(--component-main-background, var(--ui-surface, #ffffff));\n }\n .detail {\n grid-area: detail;\n display: none;\n min-height: 0;\n overflow: auto;\n border-left: 1px solid var(--ui-border, #e2e8f0);\n background: var(--ui-surface, #ffffff);\n }\n :host([detail-open]) .detail {\n display: block;\n }\n .footer {\n grid-area: footer;\n padding: 0.5rem 0.75rem;\n border-top: 1px solid var(--ui-border, #e2e8f0);\n background: var(--ui-surface, #ffffff);\n }\n .footer.empty {\n display: none;\n }\n .scrim {\n display: none;\n }\n @media (max-width: 48rem) {\n .shell {\n grid-template-columns: minmax(0, 1fr) var(--_detail-w);\n grid-template-areas:\n \"topbar topbar\"\n \"main detail\"\n \"footer footer\";\n }\n /* Mobile is always a full-screen, position:absolute overlay drawer,\n regardless of sidebar-mode/sidebar-width — those two properties\n only affect the desktop presentation. */\n .sidebar,\n :host([sidebar-mode=\"push\"]) .sidebar {\n position: absolute;\n width: 100%;\n }\n .detail {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n width: var(--_detail-w, 20rem);\n max-width: calc(100vw - 3rem);\n z-index: 40;\n transform: translateX(110%);\n transition: transform 250ms ease;\n }\n :host([detail-open]) .detail {\n transform: translateX(0);\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 }\n .scrim.show {\n display: block;\n position: absolute;\n inset: 0;\n z-index: 39;\n background: var(--ui-overlay, rgb(15 23 42 / 0.45));\n border: none;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .sidebar,\n .detail,\n .nav-tip {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .nav-toggle:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .nav-tip {\n border: 1px solid CanvasText;\n }\n }\n `,\n ];\n\n private _mediaQuery: MediaQueryList | null = null;\n private _previousFocus: HTMLElement | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this._mediaQuery = window.matchMedia(\"(max-width: 48rem)\");\n this._mobile = this._mediaQuery.matches;\n this._mediaQuery.addEventListener(\"change\", this._onMediaChange);\n window.addEventListener(\"keydown\", this._onKeydown);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._mediaQuery?.removeEventListener(\"change\", this._onMediaChange);\n this._mediaQuery = null;\n window.removeEventListener(\"keydown\", this._onKeydown);\n }\n\n /** Tracks the breakpoint the sidebar's width and modality depend on. */\n private _onMediaChange = (event: MediaQueryListEvent): void => {\n this._mobile = event.matches;\n };\n\n /** Handles the `[` sidebar shortcut and Escape dismissal of mobile overlays. */\n private _onKeydown = (event: KeyboardEvent): void => {\n if (event.defaultPrevented) return;\n if (event.key === \"Escape\" && this._mobile) {\n if (this.detailOpen) {\n event.preventDefault();\n this._closeDetail();\n } else if (this.sidebarOpen) {\n event.preventDefault();\n this.sidebarOpen = false;\n }\n return;\n }\n if (\n event.key === \"[\" &&\n !event.ctrlKey &&\n !event.metaKey &&\n !event.altKey &&\n !this._isEditableTarget(event)\n ) {\n event.preventDefault();\n this._toggleSidebar();\n }\n };\n\n /** Whether the keydown originated in a text field, so the shortcut defers to typing. */\n private _isEditableTarget(event: KeyboardEvent): boolean {\n const target = event.composedPath()[0] as HTMLElement | undefined;\n if (!target) return false;\n if (target.isContentEditable) return true;\n const tag = target.tagName;\n return tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\";\n }\n\n /** Toggles the sidebar and announces it. */\n private _toggleSidebar(): void {\n this.sidebarOpen = !this.sidebarOpen;\n if (this._mobile && this.sidebarOpen) {\n this._previousFocus = document.activeElement as HTMLElement | null;\n }\n this.dispatchEvent(\n new CustomEvent<SidebarToggleDetail>(\"sidebar-toggle\", {\n detail: { open: this.sidebarOpen },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n /** Closes the detail overlay and notifies the consumer that owns `detail-open`. */\n private _closeDetail(): void {\n this.detailOpen = false;\n this.dispatchEvent(new CustomEvent(\"detail-close\", { bubbles: true, composed: true }));\n }\n\n /** Scrim click dismisses whichever overlay is open. */\n private _onScrim(): void {\n if (this.detailOpen) this._closeDetail();\n if (this.sidebarOpen) this.sidebarOpen = false;\n }\n\n /** Mirrors `sidebar-width` onto the slotted sidebar's `collapsed` (icon rail) attribute. */\n private _syncSidebarWidth(): void {\n const icon = this.sidebarWidth === \"icon\";\n const slot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"sidebar\"]');\n for (const element of slot?.assignedElements() ?? []) {\n element.toggleAttribute(\"collapsed\", icon);\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"sidebarWidth\")) this._syncSidebarWidth();\n if (!changed.has(\"sidebarOpen\") || !this._mobile) return;\n if (this.sidebarOpen) {\n this.shadowRoot?.querySelector<HTMLElement>(\".sidebar\")?.focus();\n return;\n }\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override render() {\n const scrimActive = this._mobile && (this.sidebarOpen || this.detailOpen);\n return html`\n <div class=\"shell\">\n <aside\n class=\"sidebar\"\n tabindex=\"-1\"\n aria-label=\"Primary\"\n ?inert=${!this.sidebarOpen}\n aria-hidden=${String(!this.sidebarOpen)}\n >\n <slot name=\"sidebar\" @slotchange=${this._syncSidebarWidth}></slot>\n </aside>\n <header class=\"topbar\">\n <div class=\"nav-group\">\n <button\n class=\"nav-toggle\"\n type=\"button\"\n aria-label=\"Toggle navigation\"\n aria-keyshortcuts=\"[\"\n aria-describedby=\"nav-tip\"\n aria-expanded=${String(this.sidebarOpen)}\n @click=${this._toggleSidebar}\n >\n ${iconBars3(18)}\n </button>\n <span class=\"nav-tip\" id=\"nav-tip\" role=\"tooltip\">\n <span>${this.sidebarOpen ? \"Hide navigation\" : \"Show navigation\"}</span>\n <kbd-hint keys=\"[\"></kbd-hint>\n </span>\n </div>\n <div class=\"topbar-content\"><slot name=\"topbar\"></slot></div>\n </header>\n <main class=\"main\"><slot></slot></main>\n <aside\n class=\"detail\"\n aria-label=\"Detail\"\n ?inert=${!this.detailOpen}\n aria-hidden=${String(!this.detailOpen)}\n >\n <slot name=\"detail\"></slot>\n </aside>\n <footer class=\"footer ${this._hasFooter ? \"\" : \"empty\"}\">\n <slot name=\"footer\" @slotchange=${this._onFooterSlotChange}></slot>\n </footer>\n <button\n class=\"scrim ${scrimActive ? \"show\" : \"\"}\"\n type=\"button\"\n tabindex=\"-1\"\n aria-label=\"Close\"\n @click=${this._onScrim}\n ?hidden=${!scrimActive}\n ></button>\n </div>\n `;\n }\n\n /** Collapses the footer row when nothing is slotted into it. */\n private _onFooterSlotChange(event: Event): void {\n this._hasFooter = (event.target as HTMLSlotElement).assignedNodes({ flatten: true }).length > 0;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"app-shell\": AppShell;\n }\n}\n"]}
|
|
@@ -26,6 +26,15 @@ 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
|
+
* A toast with `duration > 0` replaces its ✕ button with a countdown: a
|
|
30
|
+
* number of seconds remaining inside a ring that fills in clockwise over
|
|
31
|
+
* `duration`. Hovering or keyboard-focusing the toast swaps the countdown
|
|
32
|
+
* back for the ✕ and pauses the countdown (both the visual ring/number and
|
|
33
|
+
* the underlying auto-dismiss timer) — the toast won't disappear while
|
|
34
|
+
* someone's reading it or has tabbed to its close button — resuming from
|
|
35
|
+
* where it left off once the pointer/focus leaves. A `duration: 0` toast has
|
|
36
|
+
* no countdown to show, so its ✕ is always visible, exactly as before.
|
|
37
|
+
*
|
|
29
38
|
* Each variant's background reads a dedicated `--ui-toast-*-background` hook
|
|
30
39
|
* (`success`/`error`/`info`/`warning`), which defaults to the flat
|
|
31
40
|
* `--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
|
|
@@ -46,6 +55,10 @@ export declare class ToastNotification extends LitElement {
|
|
|
46
55
|
private _toasts;
|
|
47
56
|
private _nextId;
|
|
48
57
|
private _timers;
|
|
58
|
+
/** Per-toast hover/focus tracking, so leaving one doesn't resume while the other still applies. */
|
|
59
|
+
private _interaction;
|
|
60
|
+
/** Ticks while any toast has a running countdown, purely to refresh the displayed seconds. */
|
|
61
|
+
private _tickTimer;
|
|
49
62
|
static styles: import("lit").CSSResult[];
|
|
50
63
|
/**
|
|
51
64
|
* Queues a toast for display.
|
|
@@ -60,6 +73,23 @@ export declare class ToastNotification extends LitElement {
|
|
|
60
73
|
*/
|
|
61
74
|
dismiss(id: number): void;
|
|
62
75
|
disconnectedCallback(): void;
|
|
76
|
+
/** Schedules (or reschedules) the real auto-dismiss timeout for a toast. */
|
|
77
|
+
private _scheduleTimer;
|
|
78
|
+
/** Freezes a toast's countdown at its current remaining time. */
|
|
79
|
+
private _pause;
|
|
80
|
+
/** Resumes a paused toast's countdown for whatever time was remaining. */
|
|
81
|
+
private _resume;
|
|
82
|
+
/** Starts or stops the shared display-only tick, matching whether any countdown is actually running. */
|
|
83
|
+
private _syncTicking;
|
|
84
|
+
/** Reads (creating if absent) a toast's hover/focus tracking record. */
|
|
85
|
+
private _interactionState;
|
|
86
|
+
private _onMouseEnter;
|
|
87
|
+
private _onMouseLeave;
|
|
88
|
+
private _onFocusIn;
|
|
89
|
+
/** Rechecks focus-within on a microtask, since focusout fires before the new focus target settles. */
|
|
90
|
+
private _onFocusOut;
|
|
91
|
+
/** Whole seconds remaining until auto-dismiss, for the countdown number. */
|
|
92
|
+
private _secondsLeft;
|
|
63
93
|
/**
|
|
64
94
|
* Returns the decorative status icon for a variant, sized as a standalone
|
|
65
95
|
* 18px glyph to match the dismiss button.
|
|
@@ -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;
|
|
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;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBACa,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,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,QAElE"}
|
|
@@ -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,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;AAD5B,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,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"]}
|
|
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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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"]}
|
|
@@ -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
|
@@ -2485,6 +2485,15 @@ circle, info → information circle, warning → exclamation triangle). Each toa
|
|
|
2485
2485
|
auto-dismisses after `duration` ms and can also be dismissed via its ✕
|
|
2486
2486
|
button. Appears/disappears instantly — no slide/fade transitions.
|
|
2487
2487
|
|
|
2488
|
+
A toast with `duration > 0` replaces its ✕ button with a countdown: a
|
|
2489
|
+
number of seconds remaining inside a ring that fills in clockwise over
|
|
2490
|
+
`duration`. Hovering or keyboard-focusing the toast swaps the countdown
|
|
2491
|
+
back for the ✕ and pauses the countdown (both the visual ring/number and
|
|
2492
|
+
the underlying auto-dismiss timer) — the toast won't disappear while
|
|
2493
|
+
someone's reading it or has tabbed to its close button — resuming from
|
|
2494
|
+
where it left off once the pointer/focus leaves. A `duration: 0` toast has
|
|
2495
|
+
no countdown to show, so its ✕ is always visible, exactly as before.
|
|
2496
|
+
|
|
2488
2497
|
Each variant's background reads a dedicated `--ui-toast-*-background` hook
|
|
2489
2498
|
(`success`/`error`/`info`/`warning`), which defaults to the flat
|
|
2490
2499
|
`--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
|
|
@@ -2503,7 +2512,7 @@ Import: `import "@f-ewald/components/toast-notification.js";`
|
|
|
2503
2512
|
|
|
2504
2513
|
Properties: none
|
|
2505
2514
|
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`
|
|
2515
|
+
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
2516
|
|
|
2508
2517
|
Example:
|
|
2509
2518
|
```html
|