@f-ewald/components 1.23.1 → 1.25.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/README.md +13 -0
- package/custom-elements.json +1882 -595
- package/dist/address-autocomplete.d.ts.map +1 -1
- package/dist/address-autocomplete.js +7 -3
- package/dist/address-autocomplete.js.map +1 -1
- package/dist/audio-player.d.ts +53 -0
- package/dist/audio-player.d.ts.map +1 -0
- package/dist/audio-player.js +267 -0
- package/dist/audio-player.js.map +1 -0
- package/dist/autocomplete-input.d.ts.map +1 -1
- package/dist/autocomplete-input.js +7 -3
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/button-group.d.ts +12 -1
- package/dist/button-group.d.ts.map +1 -1
- package/dist/button-group.js +35 -3
- package/dist/button-group.js.map +1 -1
- package/dist/comment-composer.d.ts +54 -0
- package/dist/comment-composer.d.ts.map +1 -0
- package/dist/comment-composer.js +244 -0
- package/dist/comment-composer.js.map +1 -0
- package/dist/confirm-dialog.d.ts +4 -1
- package/dist/confirm-dialog.d.ts.map +1 -1
- package/dist/confirm-dialog.js +47 -9
- package/dist/confirm-dialog.js.map +1 -1
- package/dist/dropdown-button.d.ts +4 -1
- package/dist/dropdown-button.d.ts.map +1 -1
- package/dist/dropdown-button.js +29 -3
- package/dist/dropdown-button.js.map +1 -1
- package/dist/icons.d.ts +12 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +12 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/page-header.d.ts +8 -3
- package/dist/page-header.d.ts.map +1 -1
- package/dist/page-header.js +33 -12
- package/dist/page-header.js.map +1 -1
- package/dist/pagination-nav.d.ts +7 -0
- package/dist/pagination-nav.d.ts.map +1 -1
- package/dist/pagination-nav.js +19 -4
- package/dist/pagination-nav.js.map +1 -1
- package/dist/radio-cards.d.ts +6 -0
- package/dist/radio-cards.d.ts.map +1 -1
- package/dist/radio-cards.js +13 -3
- package/dist/radio-cards.js.map +1 -1
- package/dist/radio-pills.d.ts +6 -0
- package/dist/radio-pills.d.ts.map +1 -1
- package/dist/radio-pills.js +13 -3
- package/dist/radio-pills.js.map +1 -1
- package/dist/range-slider.d.ts.map +1 -1
- package/dist/range-slider.js +11 -7
- package/dist/range-slider.js.map +1 -1
- package/dist/reveal-button.d.ts +5 -1
- package/dist/reveal-button.d.ts.map +1 -1
- package/dist/reveal-button.js +26 -4
- package/dist/reveal-button.js.map +1 -1
- package/dist/tokens.css +38 -1
- package/dist/tokens.d.ts +16 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +93 -0
- package/dist/tokens.js.map +1 -1
- package/dist/ui-button.d.ts +18 -0
- package/dist/ui-button.d.ts.map +1 -1
- package/dist/ui-button.js +50 -7
- package/dist/ui-button.js.map +1 -1
- package/dist/utils/duration.d.ts +8 -0
- package/dist/utils/duration.d.ts.map +1 -1
- package/dist/utils/duration.js +18 -0
- package/dist/utils/duration.js.map +1 -1
- package/dist/utils/transport-controls.d.ts +11 -0
- package/dist/utils/transport-controls.d.ts.map +1 -0
- package/dist/utils/transport-controls.js +113 -0
- package/dist/utils/transport-controls.js.map +1 -0
- package/dist/video-player.d.ts +60 -0
- package/dist/video-player.d.ts.map +1 -0
- package/dist/video-player.js +324 -0
- package/dist/video-player.js.map +1 -0
- package/docs/audio-player.md +60 -0
- package/docs/button-group.md +18 -1
- package/docs/comment-composer.md +68 -0
- package/docs/confirm-dialog.md +19 -1
- package/docs/dropdown-button.md +10 -1
- package/docs/icons.md +6 -0
- package/docs/page-header.md +11 -4
- package/docs/pagination-nav.md +14 -0
- package/docs/radio-cards.md +9 -0
- package/docs/radio-pills.md +9 -0
- package/docs/range-slider.md +3 -0
- package/docs/reveal-button.md +11 -1
- package/docs/ui-button.md +34 -0
- package/docs/video-player.md +59 -0
- package/llms.txt +165 -23
- package/package.json +1 -1
package/dist/tokens.js
CHANGED
|
@@ -11,10 +11,66 @@ export const tokenValues = {
|
|
|
11
11
|
// Colors
|
|
12
12
|
"--ui-primary": "#4f46e5", // indigo-600
|
|
13
13
|
"--ui-primary-hover": "#4338ca", // indigo-700
|
|
14
|
+
// Button-specific background/border hooks: default to the flat --ui-primary
|
|
15
|
+
// / --ui-danger tokens above unchanged, so those stay the single source of
|
|
16
|
+
// truth for every other component. Overriding just these lets a theme opt
|
|
17
|
+
// ui-button into a gradient (or any other) background without touching
|
|
18
|
+
// component markup; --ui-button-border/--ui-button-danger-border default
|
|
19
|
+
// to transparent (today's look) and are meant to be paired with a shade
|
|
20
|
+
// darker than the gradient's dark stop when one is set. The `-active`
|
|
21
|
+
// variants default to whatever `-background` already resolved to (so a
|
|
22
|
+
// solid override still applies while pressed) — a gradient theme should
|
|
23
|
+
// set them to the same stops in reverse, for a pressed/"indented" look.
|
|
24
|
+
"--ui-button-background": "var(--ui-primary, #4f46e5)",
|
|
25
|
+
"--ui-button-background-hover": "var(--ui-primary-hover, #4338ca)",
|
|
26
|
+
"--ui-button-background-active": "var(--ui-button-background, var(--ui-primary, #4f46e5))",
|
|
27
|
+
"--ui-button-border": "transparent",
|
|
28
|
+
// The bordered, transparent-background secondary variant's equivalents —
|
|
29
|
+
// shared with confirm-dialog's Cancel button, which is the same visual
|
|
30
|
+
// pattern. Defaults reproduce today's literal secondary styling exactly
|
|
31
|
+
// (no background at any state, border colors matching --ui-border /
|
|
32
|
+
// --ui-text-muted), so a theme only needs to override these to make
|
|
33
|
+
// secondary/Cancel buttons match a primary/danger gradient theme.
|
|
34
|
+
"--ui-button-secondary-background": "none",
|
|
35
|
+
"--ui-button-secondary-background-hover": "none",
|
|
36
|
+
"--ui-button-secondary-background-active": "var(--ui-button-secondary-background, none)",
|
|
37
|
+
"--ui-button-secondary-border": "var(--ui-border, #e2e8f0)",
|
|
38
|
+
"--ui-button-secondary-border-hover": "var(--ui-text-muted, #64748b)",
|
|
39
|
+
// A muted-gray surface used wherever something already paints
|
|
40
|
+
// --ui-surface-muted as a state indicator in flat mode — button-group's
|
|
41
|
+
// unchecked-segment hover, pagination-nav's button hover, and
|
|
42
|
+
// radio-cards/radio-pills' checked background — which is a genuinely
|
|
43
|
+
// different default than secondary's borderless flat hover, so it can't
|
|
44
|
+
// reuse --ui-button-secondary-background-hover's "none" default.
|
|
45
|
+
"--ui-button-secondary-surface-muted": "var(--ui-surface-muted, #f8fafc)",
|
|
46
|
+
// Shared by both primary/danger — a purely cosmetic gloss/legibility pair,
|
|
47
|
+
// not color-specific, so one token covers both variants. `-highlight` is a
|
|
48
|
+
// full box-shadow value (e.g. `inset 0 1px 0 rgb(255 255 255 / 0.35)`) for
|
|
49
|
+
// a glossy top edge, defaulting to a fully transparent (so invisible)
|
|
50
|
+
// shadow rather than the keyword `none` — some usages combine it with
|
|
51
|
+
// another literal shadow in a comma-separated list, where a bare `none`
|
|
52
|
+
// item is invalid CSS and would zero out the *whole* declaration.
|
|
53
|
+
// `-text-shadow` is a full text-shadow value for label legibility against
|
|
54
|
+
// a gradient's lighter stop, always used standalone, so it keeps `none`.
|
|
55
|
+
"--ui-button-highlight": "0 0 0 0 transparent",
|
|
56
|
+
"--ui-button-text-shadow": "none",
|
|
57
|
+
// A solid stand-in for the same accent, for spots that can't render a
|
|
58
|
+
// background gradient at all — a native <input>'s accent-color only
|
|
59
|
+
// accepts a plain color, and a hard-stop background gradient (e.g.
|
|
60
|
+
// range-slider's filled track) can't nest another gradient inside its own
|
|
61
|
+
// color-stop list. Consumers that theme the buttons into a gradient should
|
|
62
|
+
// set this to the gradient's dark stop, so these non-button accents (radio
|
|
63
|
+
// selection indicators, the range-slider track/thumb) stay visually
|
|
64
|
+
// coordinated with it even though they can't literally paint a gradient.
|
|
65
|
+
"--ui-button-accent": "var(--ui-primary, #4f46e5)",
|
|
14
66
|
"--ui-info": "#0ea5e9", // sky-500
|
|
15
67
|
"--ui-info-hover": "#0284c7", // sky-600
|
|
16
68
|
"--ui-danger": "#dc2626", // red-600
|
|
17
69
|
"--ui-danger-hover": "#b91c1c", // red-700
|
|
70
|
+
"--ui-button-danger-background": "var(--ui-danger, #dc2626)",
|
|
71
|
+
"--ui-button-danger-background-hover": "var(--ui-danger-hover, #b91c1c)",
|
|
72
|
+
"--ui-button-danger-background-active": "var(--ui-button-danger-background, var(--ui-danger, #dc2626))",
|
|
73
|
+
"--ui-button-danger-border": "transparent",
|
|
18
74
|
"--ui-success": "#16a34a", // green-600
|
|
19
75
|
"--ui-warning": "#d97706", // amber-600
|
|
20
76
|
"--ui-warning-hover": "#b45309", // amber-700
|
|
@@ -84,6 +140,43 @@ export const darkTokenValues = {
|
|
|
84
140
|
"--ui-overlay": "rgb(2 6 23 / 0.6)", // slate-950 / 60%
|
|
85
141
|
"--ui-focus-ring": "0 0 0 3px rgb(99 102 241 / 0.45)",
|
|
86
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* "Gradient" theme overrides, applied via `data-theme="gradient"` on `<html>`
|
|
145
|
+
* (see `generate-tokens-css.mjs`) — forces `color-scheme: light` like the
|
|
146
|
+
* `"light"` override and layers a glossy gradient look on top of the flat
|
|
147
|
+
* light palette, using exactly the `--ui-button-*`/`--ui-button-danger-*`/
|
|
148
|
+
* `--ui-button-secondary-*` hooks `ui-button.ts` already reads (see that
|
|
149
|
+
* file's doc comment). Every other token (`--ui-text`, `--ui-surface`, …)
|
|
150
|
+
* is left at its light-mode default — this theme is button-only by design.
|
|
151
|
+
* Each variant's gradient runs light-to-dark top-to-bottom (`180deg`)
|
|
152
|
+
* across one Tailwind shade step lighter/darker than the flat token so it
|
|
153
|
+
* still reads as "the same color, glossy" rather than a different hue;
|
|
154
|
+
* `-hover` shifts the whole pair one shade lighter, `-active` reverses the
|
|
155
|
+
* two stops for a pressed/"indented" look, and `-border` is a shade darker
|
|
156
|
+
* than the gradient's dark stop for a defining edge.
|
|
157
|
+
*/
|
|
158
|
+
export const gradientTokenValues = {
|
|
159
|
+
"--ui-button-background": "linear-gradient(180deg, #6366f1 0%, #4f46e5 100%)", // indigo-500 -> 600
|
|
160
|
+
"--ui-button-background-hover": "linear-gradient(180deg, #818cf8 0%, #6366f1 100%)", // indigo-400 -> 500
|
|
161
|
+
"--ui-button-background-active": "linear-gradient(180deg, #4f46e5 0%, #6366f1 100%)", // reversed 600 -> 500
|
|
162
|
+
"--ui-button-border": "#4338ca", // indigo-700
|
|
163
|
+
"--ui-button-danger-background": "linear-gradient(180deg, #ef4444 0%, #dc2626 100%)", // red-500 -> 600
|
|
164
|
+
"--ui-button-danger-background-hover": "linear-gradient(180deg, #f87171 0%, #ef4444 100%)", // red-400 -> 500
|
|
165
|
+
"--ui-button-danger-background-active": "linear-gradient(180deg, #dc2626 0%, #ef4444 100%)", // reversed 600 -> 500
|
|
166
|
+
"--ui-button-danger-border": "#b91c1c", // red-700
|
|
167
|
+
// Secondary stays subtle (white -> slate-50) rather than a saturated hue,
|
|
168
|
+
// matching its flat "not the primary action" role, with a slightly
|
|
169
|
+
// stronger border (slate-300 instead of the flat slate-200) so its edge
|
|
170
|
+
// still reads against the near-white gradient fill.
|
|
171
|
+
"--ui-button-secondary-background": "linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)", // white -> slate-50
|
|
172
|
+
"--ui-button-secondary-background-hover": "linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%)", // slate-50 -> 100
|
|
173
|
+
"--ui-button-secondary-background-active": "linear-gradient(180deg, #f1f5f9 0%, #ffffff 100%)", // reversed 100 -> white
|
|
174
|
+
"--ui-button-secondary-border": "#cbd5e1", // slate-300
|
|
175
|
+
"--ui-button-secondary-border-hover": "#94a3b8", // slate-400
|
|
176
|
+
"--ui-button-highlight": "inset 0 1px 0 rgb(255 255 255 / 0.35)", // glossy top edge
|
|
177
|
+
"--ui-button-text-shadow": "0 1px 1px rgb(0 0 0 / 0.25)", // legibility on primary/danger
|
|
178
|
+
"--ui-button-accent": "#4338ca", // indigo-700, matches --ui-button-border
|
|
179
|
+
};
|
|
87
180
|
/**
|
|
88
181
|
* Historically a shared `:host { --ui-x: var(--ui-x, fallback); } ` block,
|
|
89
182
|
* re-declaring every token on each component's own host element as a
|
package/dist/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAA2B;IACjD,SAAS;IACT,cAAc,EAAE,SAAS,EAAE,aAAa;IACxC,oBAAoB,EAAE,SAAS,EAAE,aAAa;IAC9C,WAAW,EAAE,SAAS,EAAE,UAAU;IAClC,iBAAiB,EAAE,SAAS,EAAE,UAAU;IACxC,aAAa,EAAE,SAAS,EAAE,UAAU;IACpC,mBAAmB,EAAE,SAAS,EAAE,UAAU;IAC1C,cAAc,EAAE,SAAS,EAAE,YAAY;IACvC,cAAc,EAAE,SAAS,EAAE,YAAY;IACvC,oBAAoB,EAAE,SAAS,EAAE,YAAY;IAC7C,gBAAgB,EAAE,SAAS;IAC3B,WAAW,EAAE,SAAS,EAAE,YAAY;IACpC,iBAAiB,EAAE,SAAS,EAAE,YAAY;IAC1C,aAAa,EAAE,SAAS,EAAE,YAAY;IACtC,cAAc,EAAE,SAAS,EAAE,QAAQ;IACnC,oBAAoB,EAAE,SAAS,EAAE,WAAW;IAC5C,gBAAgB,EAAE,SAAS,EAAE,6CAA6C;IAC1E,cAAc,EAAE,SAAS,EAAE,YAAY;IACvC,oBAAoB,EAAE,yBAAyB;IAC/C,cAAc,EAAE,sBAAsB,EAAE,kBAAkB;IAE1D,gBAAgB;IAChB,aAAa,EAAE,QAAQ,EAAE,aAAa;IACtC,gBAAgB,EAAE,SAAS,EAAE,UAAU;IACvC,aAAa,EACX,kEAAkE,EAAE,YAAY;IAClF,gBAAgB,EACd,qEAAqE,EAAE,YAAY;IACrF,iBAAiB,EAAE,iCAAi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/C,cAAc,EAAE,mBAAmB,EAAE,kBAAkB;IACvD,iBAAiB,EAAE,kCAAkC;CACtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,EAAE,CAAC","sourcesContent":["import { css } from \"lit\";\n\n/**\n * Design token values, sourced from Tailwind v4's default theme palette.\n * Each entry maps a `--ui-*` custom property name to its default value.\n * These are the same values baked in as `var(--ui-*, <fallback>)` fallbacks\n * throughout component styles, so components render correctly with zero\n * external CSS. Consumers may override any of these by setting the custom\n * property on `:root` or an ancestor element (see `tokens.css`).\n */\nexport const tokenValues: Record<string, string> = {\n // Colors\n \"--ui-primary\": \"#4f46e5\", // indigo-600\n \"--ui-primary-hover\": \"#4338ca\", // indigo-700\n \"--ui-info\": \"#0ea5e9\", // sky-500\n \"--ui-info-hover\": \"#0284c7\", // sky-600\n \"--ui-danger\": \"#dc2626\", // red-600\n \"--ui-danger-hover\": \"#b91c1c\", // red-700\n \"--ui-success\": \"#16a34a\", // green-600\n \"--ui-warning\": \"#d97706\", // amber-600\n \"--ui-warning-hover\": \"#b45309\", // amber-700\n \"--ui-on-accent\": \"#ffffff\",\n \"--ui-text\": \"#0f172a\", // slate-900\n \"--ui-text-muted\": \"#64748b\", // slate-500\n \"--ui-border\": \"#e2e8f0\", // slate-200\n \"--ui-surface\": \"#ffffff\", // white\n \"--ui-surface-muted\": \"#f8fafc\", // slate-50\n \"--ui-highlight\": \"#fde68a\", // amber-200 — transient \"just changed\" flash\n \"--ui-tooltip\": \"#0f172a\", // slate-900\n \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.32)\",\n \"--ui-overlay\": \"rgb(15 23 42 / 0.45)\", // slate-900 / 45%\n\n // Shape / depth\n \"--ui-radius\": \"0.5rem\", // rounded-lg\n \"--ui-radius-sm\": \"0.25rem\", // rounded\n \"--ui-shadow\":\n \"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)\", // shadow-md\n \"--ui-shadow-lg\":\n \"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)\", // shadow-xl\n \"--ui-focus-ring\": \"0 0 0 3px rgb(79 70 229 / 0.35)\",\n\n // Type\n \"--ui-font\":\n 'ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"',\n \"--ui-font-mono\":\n \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\",\n \"--ui-font-size-lg\": \"1rem\", // text-base\n \"--ui-font-size\": \"0.875rem\", // text-sm\n \"--ui-font-size-sm\": \"0.75rem\", // text-xs\n \"--ui-font-size-xs\": \"0.6875rem\",\n\n // Font weights — the only four weights the system uses.\n \"--ui-font-weight-regular\": \"400\",\n \"--ui-font-weight-medium\": \"500\",\n \"--ui-font-weight-semibold\": \"600\",\n \"--ui-font-weight-bold\": \"700\",\n\n // Line heights — glyph (icon/marker box), tight (headings), normal (body).\n \"--ui-line-height-glyph\": \"1\",\n \"--ui-line-height-tight\": \"1.25\",\n \"--ui-line-height-normal\": \"1.5\",\n\n // Letter spacing / tracking — default and the single widened step.\n \"--ui-tracking-normal\": \"0\",\n \"--ui-tracking-wide\": \"0.04em\",\n};\n\n/**\n * Dark-mode overrides for the same `--ui-*` custom properties, applied by\n * `tokens.css` via `@media (prefers-color-scheme: dark)` and `[data-theme]`\n * (see generate-tokens-css.mjs). Same Tailwind slate scale as the light\n * palette, inverted, with primary/danger/success lightened one step (500\n * instead of 600) for sufficient contrast against dark surfaces. Shape/type\n * tokens are theme-independent and not repeated here.\n */\nexport const darkTokenValues: Record<string, string> = {\n \"--ui-primary\": \"#6366f1\", // indigo-500\n \"--ui-primary-hover\": \"#818cf8\", // indigo-400\n \"--ui-info\": \"#38bdf8\", // sky-400\n \"--ui-info-hover\": \"#7dd3fc\", // sky-300\n \"--ui-danger\": \"#ef4444\", // red-500\n \"--ui-danger-hover\": \"#f87171\", // red-400\n \"--ui-success\": \"#22c55e\", // green-500\n \"--ui-warning\": \"#f59e0b\", // amber-500\n \"--ui-warning-hover\": \"#fbbf24\", // amber-400\n \"--ui-on-accent\": \"#ffffff\",\n \"--ui-text\": \"#f1f5f9\", // slate-100\n \"--ui-text-muted\": \"#94a3b8\", // slate-400\n \"--ui-border\": \"#334155\", // slate-700\n \"--ui-surface\": \"#0f172a\", // slate-900\n \"--ui-surface-muted\": \"#1e293b\", // slate-800\n \"--ui-highlight\": \"#854d0e\", // amber-800 — transient \"just changed\" flash on dark\n \"--ui-tooltip\": \"#020617\", // slate-950\n \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.12)\",\n \"--ui-overlay\": \"rgb(2 6 23 / 0.6)\", // slate-950 / 60%\n \"--ui-focus-ring\": \"0 0 0 3px rgb(99 102 241 / 0.45)\",\n};\n\n/**\n * Historically a shared `:host { --ui-x: var(--ui-x, fallback); } ` block,\n * re-declaring every token on each component's own host element as a\n * \"materialize the inherited value, or this fallback\" trick. That pattern\n * turned out to be a genuine bug, not a working default: browsers treat\n * `--ui-x: var(--ui-x, ...)` on `:host` as a self-referencing declaration\n * that computes to the guaranteed-invalid value REGARDLESS of what an\n * ancestor (e.g. `:root`) set — the host's own `:host` rule wins the cascade\n * over the ancestor's, so this dropped whatever the app actually set and\n * silently substituted the component's own fallback everywhere. It went\n * unnoticed because every component's fallback happened to equal the\n * intended light-mode value — dark mode (a real, different value at\n * `:root`) exposed it immediately (colors rendering as if no theme were\n * applied at all). Fix: don't redeclare tokens on `:host` — plain\n * inheritance already carries `:root`'s values into every shadow root\n * correctly, and every component already has its own `var(--ui-x, fallback)`\n * at each point of use, so nothing here is needed for the \"zero external\n * CSS\" default to keep working. Kept as an empty export so the existing\n * `static override styles = [tokens, css\\`...\\`]` import in every component\n * keeps compiling.\n */\nexport const tokens = css``;\n"]}
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../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ACvG,qCAAqC,EAAE,mDAAmD,EAAE,iBAAiB;IAC7G,sCAAsC,EAAE,mDAAmD,EAAE,sBAAsB;IACnH,2BAA2B,EAAE,SAAS,EAAE,UAAU;IAClD,0EAA0E;IAC1E,mEAAmE;IACnE,wEAAwE;IACxE,oDAAoD;IACpD,kCAAkC,EAAE,mDAAmD,EAAE,oBAAoB;IAC7G,wCAAwC,EAAE,mDAAmD,EAAE,kBAAkB;IACjH,yCAAyC,EAAE,mDAAmD,EAAE,wBAAwB;IACxH,8BAA8B,EAAE,SAAS,EAAE,YAAY;IACvD,oCAAoC,EAAE,SAAS,EAAE,YAAY;IAC7D,uBAAuB,EAAE,uCAAuC,EAAE,kBAAkB;IACpF,yBAAyB,EAAE,6BAA6B,EAAE,+BAA+B;IACzF,oBAAoB,EAAE,SAAS,EAAE,yCAAyC;CAC3E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,EAAE,CAAC","sourcesContent":["import { css } from \"lit\";\n\n/**\n * Design token values, sourced from Tailwind v4's default theme palette.\n * Each entry maps a `--ui-*` custom property name to its default value.\n * These are the same values baked in as `var(--ui-*, <fallback>)` fallbacks\n * throughout component styles, so components render correctly with zero\n * external CSS. Consumers may override any of these by setting the custom\n * property on `:root` or an ancestor element (see `tokens.css`).\n */\nexport const tokenValues: Record<string, string> = {\n // Colors\n \"--ui-primary\": \"#4f46e5\", // indigo-600\n \"--ui-primary-hover\": \"#4338ca\", // indigo-700\n // Button-specific background/border hooks: default to the flat --ui-primary\n // / --ui-danger tokens above unchanged, so those stay the single source of\n // truth for every other component. Overriding just these lets a theme opt\n // ui-button into a gradient (or any other) background without touching\n // component markup; --ui-button-border/--ui-button-danger-border default\n // to transparent (today's look) and are meant to be paired with a shade\n // darker than the gradient's dark stop when one is set. The `-active`\n // variants default to whatever `-background` already resolved to (so a\n // solid override still applies while pressed) — a gradient theme should\n // set them to the same stops in reverse, for a pressed/\"indented\" look.\n \"--ui-button-background\": \"var(--ui-primary, #4f46e5)\",\n \"--ui-button-background-hover\": \"var(--ui-primary-hover, #4338ca)\",\n \"--ui-button-background-active\": \"var(--ui-button-background, var(--ui-primary, #4f46e5))\",\n \"--ui-button-border\": \"transparent\",\n // The bordered, transparent-background secondary variant's equivalents —\n // shared with confirm-dialog's Cancel button, which is the same visual\n // pattern. Defaults reproduce today's literal secondary styling exactly\n // (no background at any state, border colors matching --ui-border /\n // --ui-text-muted), so a theme only needs to override these to make\n // secondary/Cancel buttons match a primary/danger gradient theme.\n \"--ui-button-secondary-background\": \"none\",\n \"--ui-button-secondary-background-hover\": \"none\",\n \"--ui-button-secondary-background-active\": \"var(--ui-button-secondary-background, none)\",\n \"--ui-button-secondary-border\": \"var(--ui-border, #e2e8f0)\",\n \"--ui-button-secondary-border-hover\": \"var(--ui-text-muted, #64748b)\",\n // A muted-gray surface used wherever something already paints\n // --ui-surface-muted as a state indicator in flat mode — button-group's\n // unchecked-segment hover, pagination-nav's button hover, and\n // radio-cards/radio-pills' checked background — which is a genuinely\n // different default than secondary's borderless flat hover, so it can't\n // reuse --ui-button-secondary-background-hover's \"none\" default.\n \"--ui-button-secondary-surface-muted\": \"var(--ui-surface-muted, #f8fafc)\",\n // Shared by both primary/danger — a purely cosmetic gloss/legibility pair,\n // not color-specific, so one token covers both variants. `-highlight` is a\n // full box-shadow value (e.g. `inset 0 1px 0 rgb(255 255 255 / 0.35)`) for\n // a glossy top edge, defaulting to a fully transparent (so invisible)\n // shadow rather than the keyword `none` — some usages combine it with\n // another literal shadow in a comma-separated list, where a bare `none`\n // item is invalid CSS and would zero out the *whole* declaration.\n // `-text-shadow` is a full text-shadow value for label legibility against\n // a gradient's lighter stop, always used standalone, so it keeps `none`.\n \"--ui-button-highlight\": \"0 0 0 0 transparent\",\n \"--ui-button-text-shadow\": \"none\",\n // A solid stand-in for the same accent, for spots that can't render a\n // background gradient at all — a native <input>'s accent-color only\n // accepts a plain color, and a hard-stop background gradient (e.g.\n // range-slider's filled track) can't nest another gradient inside its own\n // color-stop list. Consumers that theme the buttons into a gradient should\n // set this to the gradient's dark stop, so these non-button accents (radio\n // selection indicators, the range-slider track/thumb) stay visually\n // coordinated with it even though they can't literally paint a gradient.\n \"--ui-button-accent\": \"var(--ui-primary, #4f46e5)\",\n \"--ui-info\": \"#0ea5e9\", // sky-500\n \"--ui-info-hover\": \"#0284c7\", // sky-600\n \"--ui-danger\": \"#dc2626\", // red-600\n \"--ui-danger-hover\": \"#b91c1c\", // red-700\n \"--ui-button-danger-background\": \"var(--ui-danger, #dc2626)\",\n \"--ui-button-danger-background-hover\": \"var(--ui-danger-hover, #b91c1c)\",\n \"--ui-button-danger-background-active\":\n \"var(--ui-button-danger-background, var(--ui-danger, #dc2626))\",\n \"--ui-button-danger-border\": \"transparent\",\n \"--ui-success\": \"#16a34a\", // green-600\n \"--ui-warning\": \"#d97706\", // amber-600\n \"--ui-warning-hover\": \"#b45309\", // amber-700\n \"--ui-on-accent\": \"#ffffff\",\n \"--ui-text\": \"#0f172a\", // slate-900\n \"--ui-text-muted\": \"#64748b\", // slate-500\n \"--ui-border\": \"#e2e8f0\", // slate-200\n \"--ui-surface\": \"#ffffff\", // white\n \"--ui-surface-muted\": \"#f8fafc\", // slate-50\n \"--ui-highlight\": \"#fde68a\", // amber-200 — transient \"just changed\" flash\n \"--ui-tooltip\": \"#0f172a\", // slate-900\n \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.32)\",\n \"--ui-overlay\": \"rgb(15 23 42 / 0.45)\", // slate-900 / 45%\n\n // Shape / depth\n \"--ui-radius\": \"0.5rem\", // rounded-lg\n \"--ui-radius-sm\": \"0.25rem\", // rounded\n \"--ui-shadow\":\n \"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)\", // shadow-md\n \"--ui-shadow-lg\":\n \"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)\", // shadow-xl\n \"--ui-focus-ring\": \"0 0 0 3px rgb(79 70 229 / 0.35)\",\n\n // Type\n \"--ui-font\":\n 'ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"',\n \"--ui-font-mono\":\n \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\",\n \"--ui-font-size-lg\": \"1rem\", // text-base\n \"--ui-font-size\": \"0.875rem\", // text-sm\n \"--ui-font-size-sm\": \"0.75rem\", // text-xs\n \"--ui-font-size-xs\": \"0.6875rem\",\n\n // Font weights — the only four weights the system uses.\n \"--ui-font-weight-regular\": \"400\",\n \"--ui-font-weight-medium\": \"500\",\n \"--ui-font-weight-semibold\": \"600\",\n \"--ui-font-weight-bold\": \"700\",\n\n // Line heights — glyph (icon/marker box), tight (headings), normal (body).\n \"--ui-line-height-glyph\": \"1\",\n \"--ui-line-height-tight\": \"1.25\",\n \"--ui-line-height-normal\": \"1.5\",\n\n // Letter spacing / tracking — default and the single widened step.\n \"--ui-tracking-normal\": \"0\",\n \"--ui-tracking-wide\": \"0.04em\",\n};\n\n/**\n * Dark-mode overrides for the same `--ui-*` custom properties, applied by\n * `tokens.css` via `@media (prefers-color-scheme: dark)` and `[data-theme]`\n * (see generate-tokens-css.mjs). Same Tailwind slate scale as the light\n * palette, inverted, with primary/danger/success lightened one step (500\n * instead of 600) for sufficient contrast against dark surfaces. Shape/type\n * tokens are theme-independent and not repeated here.\n */\nexport const darkTokenValues: Record<string, string> = {\n \"--ui-primary\": \"#6366f1\", // indigo-500\n \"--ui-primary-hover\": \"#818cf8\", // indigo-400\n \"--ui-info\": \"#38bdf8\", // sky-400\n \"--ui-info-hover\": \"#7dd3fc\", // sky-300\n \"--ui-danger\": \"#ef4444\", // red-500\n \"--ui-danger-hover\": \"#f87171\", // red-400\n \"--ui-success\": \"#22c55e\", // green-500\n \"--ui-warning\": \"#f59e0b\", // amber-500\n \"--ui-warning-hover\": \"#fbbf24\", // amber-400\n \"--ui-on-accent\": \"#ffffff\",\n \"--ui-text\": \"#f1f5f9\", // slate-100\n \"--ui-text-muted\": \"#94a3b8\", // slate-400\n \"--ui-border\": \"#334155\", // slate-700\n \"--ui-surface\": \"#0f172a\", // slate-900\n \"--ui-surface-muted\": \"#1e293b\", // slate-800\n \"--ui-highlight\": \"#854d0e\", // amber-800 — transient \"just changed\" flash on dark\n \"--ui-tooltip\": \"#020617\", // slate-950\n \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.12)\",\n \"--ui-overlay\": \"rgb(2 6 23 / 0.6)\", // slate-950 / 60%\n \"--ui-focus-ring\": \"0 0 0 3px rgb(99 102 241 / 0.45)\",\n};\n\n/**\n * \"Gradient\" theme overrides, applied via `data-theme=\"gradient\"` on `<html>`\n * (see `generate-tokens-css.mjs`) — forces `color-scheme: light` like the\n * `\"light\"` override and layers a glossy gradient look on top of the flat\n * light palette, using exactly the `--ui-button-*`/`--ui-button-danger-*`/\n * `--ui-button-secondary-*` hooks `ui-button.ts` already reads (see that\n * file's doc comment). Every other token (`--ui-text`, `--ui-surface`, …)\n * is left at its light-mode default — this theme is button-only by design.\n * Each variant's gradient runs light-to-dark top-to-bottom (`180deg`)\n * across one Tailwind shade step lighter/darker than the flat token so it\n * still reads as \"the same color, glossy\" rather than a different hue;\n * `-hover` shifts the whole pair one shade lighter, `-active` reverses the\n * two stops for a pressed/\"indented\" look, and `-border` is a shade darker\n * than the gradient's dark stop for a defining edge.\n */\nexport const gradientTokenValues: Record<string, string> = {\n \"--ui-button-background\": \"linear-gradient(180deg, #6366f1 0%, #4f46e5 100%)\", // indigo-500 -> 600\n \"--ui-button-background-hover\": \"linear-gradient(180deg, #818cf8 0%, #6366f1 100%)\", // indigo-400 -> 500\n \"--ui-button-background-active\": \"linear-gradient(180deg, #4f46e5 0%, #6366f1 100%)\", // reversed 600 -> 500\n \"--ui-button-border\": \"#4338ca\", // indigo-700\n \"--ui-button-danger-background\": \"linear-gradient(180deg, #ef4444 0%, #dc2626 100%)\", // red-500 -> 600\n \"--ui-button-danger-background-hover\": \"linear-gradient(180deg, #f87171 0%, #ef4444 100%)\", // red-400 -> 500\n \"--ui-button-danger-background-active\": \"linear-gradient(180deg, #dc2626 0%, #ef4444 100%)\", // reversed 600 -> 500\n \"--ui-button-danger-border\": \"#b91c1c\", // red-700\n // Secondary stays subtle (white -> slate-50) rather than a saturated hue,\n // matching its flat \"not the primary action\" role, with a slightly\n // stronger border (slate-300 instead of the flat slate-200) so its edge\n // still reads against the near-white gradient fill.\n \"--ui-button-secondary-background\": \"linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)\", // white -> slate-50\n \"--ui-button-secondary-background-hover\": \"linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%)\", // slate-50 -> 100\n \"--ui-button-secondary-background-active\": \"linear-gradient(180deg, #f1f5f9 0%, #ffffff 100%)\", // reversed 100 -> white\n \"--ui-button-secondary-border\": \"#cbd5e1\", // slate-300\n \"--ui-button-secondary-border-hover\": \"#94a3b8\", // slate-400\n \"--ui-button-highlight\": \"inset 0 1px 0 rgb(255 255 255 / 0.35)\", // glossy top edge\n \"--ui-button-text-shadow\": \"0 1px 1px rgb(0 0 0 / 0.25)\", // legibility on primary/danger\n \"--ui-button-accent\": \"#4338ca\", // indigo-700, matches --ui-button-border\n};\n\n/**\n * Historically a shared `:host { --ui-x: var(--ui-x, fallback); } ` block,\n * re-declaring every token on each component's own host element as a\n * \"materialize the inherited value, or this fallback\" trick. That pattern\n * turned out to be a genuine bug, not a working default: browsers treat\n * `--ui-x: var(--ui-x, ...)` on `:host` as a self-referencing declaration\n * that computes to the guaranteed-invalid value REGARDLESS of what an\n * ancestor (e.g. `:root`) set — the host's own `:host` rule wins the cascade\n * over the ancestor's, so this dropped whatever the app actually set and\n * silently substituted the component's own fallback everywhere. It went\n * unnoticed because every component's fallback happened to equal the\n * intended light-mode value — dark mode (a real, different value at\n * `:root`) exposed it immediately (colors rendering as if no theme were\n * applied at all). Fix: don't redeclare tokens on `:host` — plain\n * inheritance already carries `:root`'s values into every shadow root\n * correctly, and every component already has its own `var(--ui-x, fallback)`\n * at each point of use, so nothing here is needed for the \"zero external\n * CSS\" default to keep working. Kept as an empty export so the existing\n * `static override styles = [tokens, css\\`...\\`]` import in every component\n * keeps compiling.\n */\nexport const tokens = css``;\n"]}
|
package/dist/ui-button.d.ts
CHANGED
|
@@ -14,6 +14,24 @@ export type ButtonVariant = "primary" | "secondary" | "danger";
|
|
|
14
14
|
* is instead wired through `ElementInternals.form` — the same mechanism
|
|
15
15
|
* `address-autocomplete` uses to associate with an ancestor form.
|
|
16
16
|
*
|
|
17
|
+
* `primary`/`danger` backgrounds read `--ui-button-background`/
|
|
18
|
+
* `--ui-button-danger-background` (and their `-hover`/`-active`
|
|
19
|
+
* counterparts), which default to the flat `--ui-primary`/`--ui-danger`
|
|
20
|
+
* tokens unchanged — so `--ui-primary`/`--ui-danger` stay the single source
|
|
21
|
+
* of truth for every other component. A consumer can override just these
|
|
22
|
+
* button-specific tokens with a `linear-gradient(...)` to opt every
|
|
23
|
+
* `ui-button` into a gradient look without touching component markup —
|
|
24
|
+
* `gradientTokenValues` in `tokens.ts` ships exactly this, wired up via
|
|
25
|
+
* `data-theme="gradient"` (see `tokens.css`'s "Gradient theme" section) —
|
|
26
|
+
* pairing it with `--ui-button-border`/`--ui-button-danger-border` (default
|
|
27
|
+
* `transparent`) for a defining edge a shade darker than the gradient's dark
|
|
28
|
+
* stop, and setting the `-active` variant's stops in reverse for a
|
|
29
|
+
* pressed/"indented" look while the button is held down. `secondary`'s
|
|
30
|
+
* background/border read the equivalent `--ui-button-secondary-*` tokens
|
|
31
|
+
* (shared with `confirm-dialog`'s Cancel button), defaulting to today's
|
|
32
|
+
* transparent/bordered look, so it can be themed into a matching (e.g.
|
|
33
|
+
* white-to-gray) gradient too.
|
|
34
|
+
*
|
|
17
35
|
* @element ui-button
|
|
18
36
|
* @slot icon - Optional leading icon (e.g. an inline SVG).
|
|
19
37
|
* @slot - Button label.
|
package/dist/ui-button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-button.d.ts","sourceRoot":"","sources":["../src/ui-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAK5C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE/D
|
|
1
|
+
{"version":3,"file":"ui-button.d.ts","sourceRoot":"","sources":["../src/ui-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAK5C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBACa,QAAS,SAAQ,UAAU;;IACtC,MAAM,CAAC,cAAc,UAAQ;IAG7B,OAAgB,MAAM,4BA4HpB;IAEF,qBAAqB;IACT,OAAO,EAAE,aAAa,CAAa;IAC/C,+EAA+E;IACnE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IACrC,oEAAoE;IACxD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAQ;IACvC,wDAAwD;IAC5C,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAY;IAC3D,wCAAwC;IACX,QAAQ,UAAS;IAC9C,0EAA0E;IAC7C,IAAI,UAAS;IAE1C,qHAAqH;IACrH,OAAO,CAAC,QAAQ;IAKhB,4EAA4E;IAC5E,OAAO,CAAC,YAAY;IAKX,MAAM,yCA+Bd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|
package/dist/ui-button.js
CHANGED
|
@@ -22,6 +22,24 @@ import { tokens } from "./tokens.js";
|
|
|
22
22
|
* is instead wired through `ElementInternals.form` — the same mechanism
|
|
23
23
|
* `address-autocomplete` uses to associate with an ancestor form.
|
|
24
24
|
*
|
|
25
|
+
* `primary`/`danger` backgrounds read `--ui-button-background`/
|
|
26
|
+
* `--ui-button-danger-background` (and their `-hover`/`-active`
|
|
27
|
+
* counterparts), which default to the flat `--ui-primary`/`--ui-danger`
|
|
28
|
+
* tokens unchanged — so `--ui-primary`/`--ui-danger` stay the single source
|
|
29
|
+
* of truth for every other component. A consumer can override just these
|
|
30
|
+
* button-specific tokens with a `linear-gradient(...)` to opt every
|
|
31
|
+
* `ui-button` into a gradient look without touching component markup —
|
|
32
|
+
* `gradientTokenValues` in `tokens.ts` ships exactly this, wired up via
|
|
33
|
+
* `data-theme="gradient"` (see `tokens.css`'s "Gradient theme" section) —
|
|
34
|
+
* pairing it with `--ui-button-border`/`--ui-button-danger-border` (default
|
|
35
|
+
* `transparent`) for a defining edge a shade darker than the gradient's dark
|
|
36
|
+
* stop, and setting the `-active` variant's stops in reverse for a
|
|
37
|
+
* pressed/"indented" look while the button is held down. `secondary`'s
|
|
38
|
+
* background/border read the equivalent `--ui-button-secondary-*` tokens
|
|
39
|
+
* (shared with `confirm-dialog`'s Cancel button), defaulting to today's
|
|
40
|
+
* transparent/bordered look, so it can be themed into a matching (e.g.
|
|
41
|
+
* white-to-gray) gradient too.
|
|
42
|
+
*
|
|
25
43
|
* @element ui-button
|
|
26
44
|
* @slot icon - Optional leading icon (e.g. an inline SVG).
|
|
27
45
|
* @slot - Button label.
|
|
@@ -77,26 +95,46 @@ let UiButton = class UiButton extends LitElement {
|
|
|
77
95
|
box-sizing: border-box;
|
|
78
96
|
}
|
|
79
97
|
.btn.primary {
|
|
80
|
-
background: var(--ui-primary, #4f46e5);
|
|
98
|
+
background: var(--ui-button-background, var(--ui-primary, #4f46e5));
|
|
99
|
+
border-color: var(--ui-button-border, transparent);
|
|
81
100
|
color: var(--ui-on-accent, #ffffff);
|
|
101
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
102
|
+
text-shadow: var(--ui-button-text-shadow, none);
|
|
82
103
|
}
|
|
83
104
|
.btn.primary:hover:not(:disabled) {
|
|
84
|
-
background: var(--ui-primary-hover, #4338ca);
|
|
105
|
+
background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));
|
|
106
|
+
}
|
|
107
|
+
.btn.primary:active:not(:disabled) {
|
|
108
|
+
background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));
|
|
109
|
+
box-shadow: none;
|
|
85
110
|
}
|
|
86
111
|
.btn.secondary {
|
|
87
|
-
background: none;
|
|
88
|
-
border-color: var(--ui-border, #e2e8f0);
|
|
112
|
+
background: var(--ui-button-secondary-background, none);
|
|
113
|
+
border-color: var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));
|
|
89
114
|
color: var(--ui-text, #0f172a);
|
|
115
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
90
116
|
}
|
|
91
117
|
.btn.secondary:hover:not(:disabled) {
|
|
92
|
-
|
|
118
|
+
background: var(--ui-button-secondary-background-hover, none);
|
|
119
|
+
border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));
|
|
120
|
+
}
|
|
121
|
+
.btn.secondary:active:not(:disabled) {
|
|
122
|
+
background: var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none));
|
|
123
|
+
box-shadow: none;
|
|
93
124
|
}
|
|
94
125
|
.btn.danger {
|
|
95
|
-
background: var(--ui-danger, #dc2626);
|
|
126
|
+
background: var(--ui-button-danger-background, var(--ui-danger, #dc2626));
|
|
127
|
+
border-color: var(--ui-button-danger-border, transparent);
|
|
96
128
|
color: var(--ui-on-accent, #ffffff);
|
|
129
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
130
|
+
text-shadow: var(--ui-button-text-shadow, none);
|
|
97
131
|
}
|
|
98
132
|
.btn.danger:hover:not(:disabled) {
|
|
99
|
-
background: var(--ui-danger-hover, #b91c1c);
|
|
133
|
+
background: var(--ui-button-danger-background-hover, var(--ui-danger-hover, #b91c1c));
|
|
134
|
+
}
|
|
135
|
+
.btn.danger:active:not(:disabled) {
|
|
136
|
+
background: var(--ui-button-danger-background-active, var(--ui-button-danger-background, var(--ui-danger, #dc2626)));
|
|
137
|
+
box-shadow: none;
|
|
100
138
|
}
|
|
101
139
|
.btn:disabled,
|
|
102
140
|
.btn[aria-disabled="true"] {
|
|
@@ -108,6 +146,11 @@ let UiButton = class UiButton extends LitElement {
|
|
|
108
146
|
outline: none;
|
|
109
147
|
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
110
148
|
}
|
|
149
|
+
.btn.primary:focus-visible:not(:active),
|
|
150
|
+
.btn.danger:focus-visible:not(:active),
|
|
151
|
+
.btn.secondary:focus-visible:not(:active) {
|
|
152
|
+
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)), var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
153
|
+
}
|
|
111
154
|
.btn.sm {
|
|
112
155
|
height: 1.5rem;
|
|
113
156
|
padding: 0.25rem 0.5rem;
|
package/dist/ui-button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-button.js","sourceRoot":"","sources":["../src/ui-button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QAGL,eAAU,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAsGpC,qBA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CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;sBACjC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;mBAC/B,IAAI,CAAC,YAAY;;0DAEsB,CAAC,IAAI,CAAC,IAAI,IAAI,aAAa,CAAC,EAAE,CAAC;sCACnD,IAAI,CAAC,IAAI;;;OAGxC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAA;;gBAEC,OAAO;;oBAEH,UAAU;oBACV,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;iBAC/B,IAAI,CAAC,QAAQ;;wDAE0B,CAAC,IAAI,CAAC,IAAI,IAAI,aAAa,CAAC,EAAE,CAAC;oCACnD,IAAI,CAAC,IAAI;;;KAGxC,CAAC;IACJ,CAAC;CACF,CAAA;AAxDa;IAAX,QAAQ,EAAE;yCAAoC;AAEnC;IAAX,QAAQ,EAAE;sCAA0B;AAEzB;IAAX,QAAQ,EAAE;sCAA4B;AAE3B;IAAX,QAAQ,EAAE;sCAAgD;AAE9B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCAAc;AApH/B,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAkKpB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconArrowPath } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"danger\";\n\n/**\n * Button (or link styled as one) with an optional leading icon, in three\n * visual weights. Set `href` to render an `<a>` instead of a `<button>` —\n * same styling either way — for cross-page navigation that should look like\n * an action button; a disabled/busy link stays a real `<a>` with\n * `aria-disabled` + `pointer-events: none` rather than losing its href.\n * Put the icon in the `icon` slot and the label in the default slot.\n *\n * Form-associated (`type=\"submit\"`/`\"reset\"`): the actual `<button>` lives in\n * this element's shadow root, which native HTML form association does not\n * cross into from an ancestor light-DOM `<form>`. `type=\"submit\"`/`\"reset\"`\n * is instead wired through `ElementInternals.form` — the same mechanism\n * `address-autocomplete` uses to associate with an ancestor form.\n *\n * @element ui-button\n * @slot icon - Optional leading icon (e.g. an inline SVG).\n * @slot - Button label.\n */\n@customElement(\"ui-button\")\nexport class UiButton extends LitElement {\n static formAssociated = true;\n\n #internals = this.attachInternals();\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-flex;\n }\n .btn {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n height: 2rem;\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.5rem 1rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n cursor: pointer;\n border: 1px solid transparent;\n text-decoration: none;\n box-sizing: border-box;\n }\n .btn.primary {\n background: var(--ui-primary, #4f46e5);\n color: var(--ui-on-accent, #ffffff);\n }\n .btn.primary:hover:not(:disabled) {\n background: var(--ui-primary-hover, #4338ca);\n }\n .btn.secondary {\n background: none;\n border-color: var(--ui-border, #e2e8f0);\n color: var(--ui-text, #0f172a);\n }\n .btn.secondary:hover:not(:disabled) {\n border-color: var(--ui-text-muted, #64748b);\n }\n .btn.danger {\n background: var(--ui-danger, #dc2626);\n color: var(--ui-on-accent, #ffffff);\n }\n .btn.danger:hover:not(:disabled) {\n background: var(--ui-danger-hover, #b91c1c);\n }\n .btn:disabled,\n .btn[aria-disabled=\"true\"] {\n opacity: 0.6;\n cursor: default;\n pointer-events: none;\n }\n .btn:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .btn.sm {\n height: 1.5rem;\n padding: 0.25rem 0.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .spin {\n display: inline-flex;\n animation: spin 0.8s linear infinite;\n }\n .spin[hidden] {\n display: none;\n }\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .spin {\n animation: none;\n }\n }\n @media (forced-colors: active) {\n .btn:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .btn:disabled,\n .btn[aria-disabled=\"true\"] {\n color: GrayText;\n border-color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n /** Visual weight. */\n @property() variant: ButtonVariant = \"primary\";\n /** Size — `sm` reduces height/padding/font-size one step below the default. */\n @property() size: \"sm\" | \"md\" = \"md\";\n /** Renders an `<a href=\"...\">` instead of a `<button>` when set. */\n @property() href: string | null = null;\n /** Native button `type`. Ignored when `href` is set. */\n @property() type: \"button\" | \"submit\" | \"reset\" = \"button\";\n /** Disables the control and dims it. */\n @property({ type: Boolean }) disabled = false;\n /** Shows a spinner in place of the icon slot and disables the control. */\n @property({ type: Boolean }) busy = false;\n\n /** Drives submit/reset on the ancestor form via ElementInternals, since a shadow-DOM button can't do it natively. */\n private _onClick() {\n if (this.type === \"submit\") this.#internals.form?.requestSubmit();\n else if (this.type === \"reset\") this.#internals.form?.reset();\n }\n\n /** Suppresses navigation while a link-styled button is disabled or busy. */\n private _onLinkClick(e: MouseEvent) {\n if (!this.disabled && !this.busy) return;\n e.preventDefault();\n }\n\n override render() {\n const classes = `btn ${this.variant} ${this.size}`;\n const isDisabled = this.disabled || this.busy;\n if (this.href) {\n return html`\n <a\n class=${classes}\n href=${this.href}\n aria-disabled=${isDisabled ? \"true\" : \"false\"}\n aria-busy=${this.busy ? \"true\" : \"false\"}\n @click=${this._onLinkClick}\n >\n <span class=\"spin\" aria-hidden=\"true\" ?hidden=${!this.busy}>${iconArrowPath(14)}</span>\n <slot name=\"icon\" ?hidden=${this.busy}></slot>\n <slot></slot>\n </a>\n `;\n }\n return html`\n <button\n class=${classes}\n type=\"button\"\n ?disabled=${isDisabled}\n aria-busy=${this.busy ? \"true\" : \"false\"}\n @click=${this._onClick}\n >\n <span class=\"spin\" aria-hidden=\"true\" ?hidden=${!this.busy}>${iconArrowPath(14)}</span>\n <slot name=\"icon\" ?hidden=${this.busy}></slot>\n <slot></slot>\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"ui-button\": UiButton;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ui-button.js","sourceRoot":"","sources":["../src/ui-button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QAGL,eAAU,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QA+HpC,qBAAqB;QACT,YAAO,GAAkB,SAAS,CAAC;QAC/C,+EAA+E;QACnE,SAAI,GAAgB,IAAI,CAAC;QACrC,oEAAoE;QACxD,SAAI,GAAkB,IAAI,CAAC;QACvC,wDAAwD;QAC5C,SAAI,GAAkC,QAAQ,CAAC;QAC3D,wCAAwC;QACX,aAAQ,GAAG,KAAK,CAAC;QAC9C,0EAA0E;QAC7C,SAAI,GAAG,KAAK,CAAC;IA8C5C,CAAC;aA1LQ,mBAAc,GAAG,IAAI,AAAP,CAAQ;IAE7B,UAAU,CAA0B;aACpB,WA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IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;iBAC/B,IAAI,CAAC,QAAQ;;wDAE0B,CAAC,IAAI,CAAC,IAAI,IAAI,aAAa,CAAC,EAAE,CAAC;oCACnD,IAAI,CAAC,IAAI;;;KAGxC,CAAC;IACJ,CAAC;CACF,CAAA;AAxDa;IAAX,QAAQ,EAAE;yCAAoC;AAEnC;IAAX,QAAQ,EAAE;sCAA0B;AAEzB;IAAX,QAAQ,EAAE;sCAA4B;AAE3B;IAAX,QAAQ,EAAE;sCAAgD;AAE9B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCAAc;AA7I/B,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA2LpB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconArrowPath } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"danger\";\n\n/**\n * Button (or link styled as one) with an optional leading icon, in three\n * visual weights. Set `href` to render an `<a>` instead of a `<button>` —\n * same styling either way — for cross-page navigation that should look like\n * an action button; a disabled/busy link stays a real `<a>` with\n * `aria-disabled` + `pointer-events: none` rather than losing its href.\n * Put the icon in the `icon` slot and the label in the default slot.\n *\n * Form-associated (`type=\"submit\"`/`\"reset\"`): the actual `<button>` lives in\n * this element's shadow root, which native HTML form association does not\n * cross into from an ancestor light-DOM `<form>`. `type=\"submit\"`/`\"reset\"`\n * is instead wired through `ElementInternals.form` — the same mechanism\n * `address-autocomplete` uses to associate with an ancestor form.\n *\n * `primary`/`danger` backgrounds read `--ui-button-background`/\n * `--ui-button-danger-background` (and their `-hover`/`-active`\n * counterparts), which default to the flat `--ui-primary`/`--ui-danger`\n * tokens unchanged — so `--ui-primary`/`--ui-danger` stay the single source\n * of truth for every other component. A consumer can override just these\n * button-specific tokens with a `linear-gradient(...)` to opt every\n * `ui-button` into a gradient look without touching component markup —\n * `gradientTokenValues` in `tokens.ts` ships exactly this, wired up via\n * `data-theme=\"gradient\"` (see `tokens.css`'s \"Gradient theme\" section) —\n * pairing it with `--ui-button-border`/`--ui-button-danger-border` (default\n * `transparent`) for a defining edge a shade darker than the gradient's dark\n * stop, and setting the `-active` variant's stops in reverse for a\n * pressed/\"indented\" look while the button is held down. `secondary`'s\n * background/border read the equivalent `--ui-button-secondary-*` tokens\n * (shared with `confirm-dialog`'s Cancel button), defaulting to today's\n * transparent/bordered look, so it can be themed into a matching (e.g.\n * white-to-gray) gradient too.\n *\n * @element ui-button\n * @slot icon - Optional leading icon (e.g. an inline SVG).\n * @slot - Button label.\n */\n@customElement(\"ui-button\")\nexport class UiButton extends LitElement {\n static formAssociated = true;\n\n #internals = this.attachInternals();\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-flex;\n }\n .btn {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n height: 2rem;\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.5rem 1rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n cursor: pointer;\n border: 1px solid transparent;\n text-decoration: none;\n box-sizing: border-box;\n }\n .btn.primary {\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border-color: var(--ui-button-border, transparent);\n color: var(--ui-on-accent, #ffffff);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .btn.primary:hover:not(:disabled) {\n background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));\n }\n .btn.primary:active:not(:disabled) {\n background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));\n box-shadow: none;\n }\n .btn.secondary {\n background: var(--ui-button-secondary-background, none);\n border-color: var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n color: var(--ui-text, #0f172a);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .btn.secondary:hover:not(:disabled) {\n background: var(--ui-button-secondary-background-hover, none);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n .btn.secondary:active:not(:disabled) {\n background: var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none));\n box-shadow: none;\n }\n .btn.danger {\n background: var(--ui-button-danger-background, var(--ui-danger, #dc2626));\n border-color: var(--ui-button-danger-border, transparent);\n color: var(--ui-on-accent, #ffffff);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .btn.danger:hover:not(:disabled) {\n background: var(--ui-button-danger-background-hover, var(--ui-danger-hover, #b91c1c));\n }\n .btn.danger:active:not(:disabled) {\n background: var(--ui-button-danger-background-active, var(--ui-button-danger-background, var(--ui-danger, #dc2626)));\n box-shadow: none;\n }\n .btn:disabled,\n .btn[aria-disabled=\"true\"] {\n opacity: 0.6;\n cursor: default;\n pointer-events: none;\n }\n .btn:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .btn.primary:focus-visible:not(:active),\n .btn.danger:focus-visible:not(:active),\n .btn.secondary:focus-visible:not(:active) {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .btn.sm {\n height: 1.5rem;\n padding: 0.25rem 0.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .spin {\n display: inline-flex;\n animation: spin 0.8s linear infinite;\n }\n .spin[hidden] {\n display: none;\n }\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .spin {\n animation: none;\n }\n }\n @media (forced-colors: active) {\n .btn:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .btn:disabled,\n .btn[aria-disabled=\"true\"] {\n color: GrayText;\n border-color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n /** Visual weight. */\n @property() variant: ButtonVariant = \"primary\";\n /** Size — `sm` reduces height/padding/font-size one step below the default. */\n @property() size: \"sm\" | \"md\" = \"md\";\n /** Renders an `<a href=\"...\">` instead of a `<button>` when set. */\n @property() href: string | null = null;\n /** Native button `type`. Ignored when `href` is set. */\n @property() type: \"button\" | \"submit\" | \"reset\" = \"button\";\n /** Disables the control and dims it. */\n @property({ type: Boolean }) disabled = false;\n /** Shows a spinner in place of the icon slot and disables the control. */\n @property({ type: Boolean }) busy = false;\n\n /** Drives submit/reset on the ancestor form via ElementInternals, since a shadow-DOM button can't do it natively. */\n private _onClick() {\n if (this.type === \"submit\") this.#internals.form?.requestSubmit();\n else if (this.type === \"reset\") this.#internals.form?.reset();\n }\n\n /** Suppresses navigation while a link-styled button is disabled or busy. */\n private _onLinkClick(e: MouseEvent) {\n if (!this.disabled && !this.busy) return;\n e.preventDefault();\n }\n\n override render() {\n const classes = `btn ${this.variant} ${this.size}`;\n const isDisabled = this.disabled || this.busy;\n if (this.href) {\n return html`\n <a\n class=${classes}\n href=${this.href}\n aria-disabled=${isDisabled ? \"true\" : \"false\"}\n aria-busy=${this.busy ? \"true\" : \"false\"}\n @click=${this._onLinkClick}\n >\n <span class=\"spin\" aria-hidden=\"true\" ?hidden=${!this.busy}>${iconArrowPath(14)}</span>\n <slot name=\"icon\" ?hidden=${this.busy}></slot>\n <slot></slot>\n </a>\n `;\n }\n return html`\n <button\n class=${classes}\n type=\"button\"\n ?disabled=${isDisabled}\n aria-busy=${this.busy ? \"true\" : \"false\"}\n @click=${this._onClick}\n >\n <span class=\"spin\" aria-hidden=\"true\" ?hidden=${!this.busy}>${iconArrowPath(14)}</span>\n <slot name=\"icon\" ?hidden=${this.busy}></slot>\n <slot></slot>\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"ui-button\": UiButton;\n }\n}\n"]}
|
package/dist/utils/duration.d.ts
CHANGED
|
@@ -9,4 +9,12 @@ export type DurationFormat = "seconds" | "compact";
|
|
|
9
9
|
* is present.
|
|
10
10
|
*/
|
|
11
11
|
export declare function formatDuration(ms: number, format: DurationFormat): string;
|
|
12
|
+
/**
|
|
13
|
+
* Formats a duration in seconds as a transport-bar clock label:
|
|
14
|
+
* `M:SS` (e.g. `"3:45"`), or `H:MM:SS` once an hour is reached (e.g.
|
|
15
|
+
* `"1:02:03"`). `NaN`/negative/non-finite input (e.g. a not-yet-loaded
|
|
16
|
+
* media duration) renders as `"-:--"` rather than `"0:00"`, so a player can
|
|
17
|
+
* distinguish "no reading yet" from an actual zero-length duration.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatClockDuration(totalSeconds: number): string;
|
|
12
20
|
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/utils/duration.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;AAMnD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,CAWzE"}
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/utils/duration.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;AAMnD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,CAWzE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAQhE"}
|
package/dist/utils/duration.js
CHANGED
|
@@ -24,4 +24,22 @@ export function formatDuration(ms, format) {
|
|
|
24
24
|
return `${minutes}m ${pad2(seconds)}s`;
|
|
25
25
|
return `${seconds}s`;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Formats a duration in seconds as a transport-bar clock label:
|
|
29
|
+
* `M:SS` (e.g. `"3:45"`), or `H:MM:SS` once an hour is reached (e.g.
|
|
30
|
+
* `"1:02:03"`). `NaN`/negative/non-finite input (e.g. a not-yet-loaded
|
|
31
|
+
* media duration) renders as `"-:--"` rather than `"0:00"`, so a player can
|
|
32
|
+
* distinguish "no reading yet" from an actual zero-length duration.
|
|
33
|
+
*/
|
|
34
|
+
export function formatClockDuration(totalSeconds) {
|
|
35
|
+
if (!Number.isFinite(totalSeconds) || totalSeconds < 0)
|
|
36
|
+
return "-:--";
|
|
37
|
+
const whole = Math.floor(totalSeconds);
|
|
38
|
+
const hours = Math.floor(whole / 3600);
|
|
39
|
+
const minutes = Math.floor((whole % 3600) / 60);
|
|
40
|
+
const seconds = whole % 60;
|
|
41
|
+
if (hours > 0)
|
|
42
|
+
return `${hours}:${pad2(minutes)}:${pad2(seconds)}`;
|
|
43
|
+
return `${minutes}:${pad2(seconds)}`;
|
|
44
|
+
}
|
|
27
45
|
//# sourceMappingURL=duration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/utils/duration.ts"],"names":[],"mappings":"AAEA,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,MAAsB;IAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IACxD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,YAAY,UAAU,CAAC;IACrE,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,YAAY,GAAG,EAAE,CAAC;IAClC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,GAAG,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IACtE,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,GAAG,OAAO,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IACxD,OAAO,GAAG,OAAO,GAAG,CAAC;AACvB,CAAC","sourcesContent":["export type DurationFormat = \"seconds\" | \"compact\";\n\nfunction pad2(n: number): string {\n return n < 10 ? `0${n}` : `${n}`;\n}\n\n/**\n * Formats a millisecond duration for display.\n *\n * `\"seconds\"` renders a whole-second count with a pluralized unit word (e.g.\n * \"1 second\", \"12 seconds\"). `\"compact\"` renders the shortest sensible\n * `Xh Ym Zs` form, dropping leading-zero units (`\"12s\"`, `\"3m 12s\"`,\n * `\"1h 03m 12s\"`) — minutes/seconds are zero-padded only once a larger unit\n * is present.\n */\nexport function formatDuration(ms: number, format: DurationFormat): string {\n const totalSeconds = Math.max(0, Math.floor(ms / 1000));\n if (format === \"seconds\") {\n return totalSeconds === 1 ? \"1 second\" : `${totalSeconds} seconds`;\n }\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n if (hours > 0) return `${hours}h ${pad2(minutes)}m ${pad2(seconds)}s`;\n if (minutes > 0) return `${minutes}m ${pad2(seconds)}s`;\n return `${seconds}s`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/utils/duration.ts"],"names":[],"mappings":"AAEA,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,MAAsB;IAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IACxD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,YAAY,UAAU,CAAC;IACrE,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,YAAY,GAAG,EAAE,CAAC;IAClC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,GAAG,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IACtE,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,GAAG,OAAO,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IACxD,OAAO,GAAG,OAAO,GAAG,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAAoB;IACtD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,YAAY,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IACtE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,KAAK,GAAG,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IACnE,OAAO,GAAG,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;AACvC,CAAC","sourcesContent":["export type DurationFormat = \"seconds\" | \"compact\";\n\nfunction pad2(n: number): string {\n return n < 10 ? `0${n}` : `${n}`;\n}\n\n/**\n * Formats a millisecond duration for display.\n *\n * `\"seconds\"` renders a whole-second count with a pluralized unit word (e.g.\n * \"1 second\", \"12 seconds\"). `\"compact\"` renders the shortest sensible\n * `Xh Ym Zs` form, dropping leading-zero units (`\"12s\"`, `\"3m 12s\"`,\n * `\"1h 03m 12s\"`) — minutes/seconds are zero-padded only once a larger unit\n * is present.\n */\nexport function formatDuration(ms: number, format: DurationFormat): string {\n const totalSeconds = Math.max(0, Math.floor(ms / 1000));\n if (format === \"seconds\") {\n return totalSeconds === 1 ? \"1 second\" : `${totalSeconds} seconds`;\n }\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n if (hours > 0) return `${hours}h ${pad2(minutes)}m ${pad2(seconds)}s`;\n if (minutes > 0) return `${minutes}m ${pad2(seconds)}s`;\n return `${seconds}s`;\n}\n\n/**\n * Formats a duration in seconds as a transport-bar clock label:\n * `M:SS` (e.g. `\"3:45\"`), or `H:MM:SS` once an hour is reached (e.g.\n * `\"1:02:03\"`). `NaN`/negative/non-finite input (e.g. a not-yet-loaded\n * media duration) renders as `\"-:--\"` rather than `\"0:00\"`, so a player can\n * distinguish \"no reading yet\" from an actual zero-length duration.\n */\nexport function formatClockDuration(totalSeconds: number): string {\n if (!Number.isFinite(totalSeconds) || totalSeconds < 0) return \"-:--\";\n const whole = Math.floor(totalSeconds);\n const hours = Math.floor(whole / 3600);\n const minutes = Math.floor((whole % 3600) / 60);\n const seconds = whole % 60;\n if (hours > 0) return `${hours}:${pad2(minutes)}:${pad2(seconds)}`;\n return `${minutes}:${pad2(seconds)}`;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared `<input type="range">` track/thumb styling for media transport
|
|
3
|
+
* controls (the seek bar and volume slider in `audio-player`/`video-player`).
|
|
4
|
+
* Reuses `range-slider.ts`'s track/fill visual language (a filled portion up
|
|
5
|
+
* to `--range-percent`) so both players get free native keyboard/pointer
|
|
6
|
+
* seeking instead of a custom-built draggable control, matching the "native
|
|
7
|
+
* semantics before custom ARIA" rule. Extracted here rather than duplicated
|
|
8
|
+
* because both components need the identical rule set.
|
|
9
|
+
*/
|
|
10
|
+
export declare const transportRangeStyles: import("lit").CSSResult;
|
|
11
|
+
//# sourceMappingURL=transport-controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-controls.d.ts","sourceRoot":"","sources":["../../src/utils/transport-controls.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,yBAqGhC,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* Shared `<input type="range">` track/thumb styling for media transport
|
|
4
|
+
* controls (the seek bar and volume slider in `audio-player`/`video-player`).
|
|
5
|
+
* Reuses `range-slider.ts`'s track/fill visual language (a filled portion up
|
|
6
|
+
* to `--range-percent`) so both players get free native keyboard/pointer
|
|
7
|
+
* seeking instead of a custom-built draggable control, matching the "native
|
|
8
|
+
* semantics before custom ARIA" rule. Extracted here rather than duplicated
|
|
9
|
+
* because both components need the identical rule set.
|
|
10
|
+
*/
|
|
11
|
+
export const transportRangeStyles = css `
|
|
12
|
+
input[type="range"] {
|
|
13
|
+
-webkit-appearance: none;
|
|
14
|
+
appearance: none;
|
|
15
|
+
/* Width is intentionally left to the consumer (e.g. .seek/.volume in
|
|
16
|
+
audio-player/video-player) — this element+attribute selector has
|
|
17
|
+
higher specificity than a single class rule, so setting a width
|
|
18
|
+
here would win over a component's own narrower class and silently
|
|
19
|
+
stretch every range input (including a fixed-width volume slider)
|
|
20
|
+
to 100%. */
|
|
21
|
+
height: 1rem;
|
|
22
|
+
margin: 0;
|
|
23
|
+
background: transparent;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
}
|
|
26
|
+
input[type="range"]:disabled {
|
|
27
|
+
cursor: not-allowed;
|
|
28
|
+
opacity: 0.6;
|
|
29
|
+
}
|
|
30
|
+
input[type="range"]::-webkit-slider-runnable-track {
|
|
31
|
+
height: 0.25rem;
|
|
32
|
+
border-radius: 9999px;
|
|
33
|
+
/* A hard-stop gradient two-tone fill trick — see range-slider.ts for why
|
|
34
|
+
this reads --ui-button-accent rather than --ui-button-background. */
|
|
35
|
+
background: linear-gradient(
|
|
36
|
+
to right,
|
|
37
|
+
var(--ui-button-accent, var(--ui-primary, #4f46e5)) 0%,
|
|
38
|
+
var(--ui-button-accent, var(--ui-primary, #4f46e5)) var(--range-percent, 0%),
|
|
39
|
+
var(--ui-surface-muted, #f8fafc) var(--range-percent, 0%),
|
|
40
|
+
var(--ui-surface-muted, #f8fafc) 100%
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
input[type="range"]::-moz-range-track {
|
|
44
|
+
height: 0.25rem;
|
|
45
|
+
border-radius: 9999px;
|
|
46
|
+
background: var(--ui-surface-muted, #f8fafc);
|
|
47
|
+
}
|
|
48
|
+
input[type="range"]::-moz-range-progress {
|
|
49
|
+
height: 0.25rem;
|
|
50
|
+
border-radius: 9999px;
|
|
51
|
+
background: var(--ui-button-accent, var(--ui-primary, #4f46e5));
|
|
52
|
+
}
|
|
53
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
54
|
+
-webkit-appearance: none;
|
|
55
|
+
appearance: none;
|
|
56
|
+
width: 0.75rem;
|
|
57
|
+
height: 0.75rem;
|
|
58
|
+
/* WebKit centers the thumb on the input's full 1rem box, not the
|
|
59
|
+
thinner custom track — nudge it up to align, as in range-slider.ts. */
|
|
60
|
+
transform: translateY(-0.25rem);
|
|
61
|
+
border-radius: 50%;
|
|
62
|
+
background: var(--ui-button-background, var(--ui-primary, #4f46e5));
|
|
63
|
+
border: 2px solid var(--ui-surface, #ffffff);
|
|
64
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
65
|
+
}
|
|
66
|
+
input[type="range"]::-moz-range-thumb {
|
|
67
|
+
width: 0.75rem;
|
|
68
|
+
height: 0.75rem;
|
|
69
|
+
border-radius: 50%;
|
|
70
|
+
background: var(--ui-button-background, var(--ui-primary, #4f46e5));
|
|
71
|
+
border: 2px solid var(--ui-surface, #ffffff);
|
|
72
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
73
|
+
}
|
|
74
|
+
input[type="range"]:disabled::-webkit-slider-thumb {
|
|
75
|
+
background: var(--ui-text-muted, #64748b);
|
|
76
|
+
}
|
|
77
|
+
input[type="range"]:disabled::-moz-range-thumb {
|
|
78
|
+
background: var(--ui-text-muted, #64748b);
|
|
79
|
+
}
|
|
80
|
+
input[type="range"]:focus-visible {
|
|
81
|
+
outline: none;
|
|
82
|
+
}
|
|
83
|
+
input[type="range"]:focus-visible::-webkit-slider-thumb {
|
|
84
|
+
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
85
|
+
}
|
|
86
|
+
input[type="range"]:focus-visible::-moz-range-thumb {
|
|
87
|
+
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
88
|
+
}
|
|
89
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
90
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
91
|
+
transition: box-shadow 120ms ease;
|
|
92
|
+
}
|
|
93
|
+
input[type="range"]::-moz-range-thumb {
|
|
94
|
+
transition: box-shadow 120ms ease;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
@media (forced-colors: active) {
|
|
98
|
+
input[type="range"]::-webkit-slider-runnable-track {
|
|
99
|
+
background: Canvas;
|
|
100
|
+
border: 1px solid CanvasText;
|
|
101
|
+
}
|
|
102
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
103
|
+
background: Highlight;
|
|
104
|
+
border-color: Canvas;
|
|
105
|
+
}
|
|
106
|
+
input[type="range"]:focus-visible::-webkit-slider-thumb {
|
|
107
|
+
outline: 2px solid CanvasText;
|
|
108
|
+
outline-offset: 2px;
|
|
109
|
+
box-shadow: none;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
//# sourceMappingURL=transport-controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-controls.js","sourceRoot":"","sources":["../../src/utils/transport-controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqGtC,CAAC","sourcesContent":["import { css } from \"lit\";\n\n/**\n * Shared `<input type=\"range\">` track/thumb styling for media transport\n * controls (the seek bar and volume slider in `audio-player`/`video-player`).\n * Reuses `range-slider.ts`'s track/fill visual language (a filled portion up\n * to `--range-percent`) so both players get free native keyboard/pointer\n * seeking instead of a custom-built draggable control, matching the \"native\n * semantics before custom ARIA\" rule. Extracted here rather than duplicated\n * because both components need the identical rule set.\n */\nexport const transportRangeStyles = css`\n input[type=\"range\"] {\n -webkit-appearance: none;\n appearance: none;\n /* Width is intentionally left to the consumer (e.g. .seek/.volume in\n audio-player/video-player) — this element+attribute selector has\n higher specificity than a single class rule, so setting a width\n here would win over a component's own narrower class and silently\n stretch every range input (including a fixed-width volume slider)\n to 100%. */\n height: 1rem;\n margin: 0;\n background: transparent;\n cursor: pointer;\n }\n input[type=\"range\"]:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n input[type=\"range\"]::-webkit-slider-runnable-track {\n height: 0.25rem;\n border-radius: 9999px;\n /* A hard-stop gradient two-tone fill trick — see range-slider.ts for why\n this reads --ui-button-accent rather than --ui-button-background. */\n background: linear-gradient(\n to right,\n var(--ui-button-accent, var(--ui-primary, #4f46e5)) 0%,\n var(--ui-button-accent, var(--ui-primary, #4f46e5)) var(--range-percent, 0%),\n var(--ui-surface-muted, #f8fafc) var(--range-percent, 0%),\n var(--ui-surface-muted, #f8fafc) 100%\n );\n }\n input[type=\"range\"]::-moz-range-track {\n height: 0.25rem;\n border-radius: 9999px;\n background: var(--ui-surface-muted, #f8fafc);\n }\n input[type=\"range\"]::-moz-range-progress {\n height: 0.25rem;\n border-radius: 9999px;\n background: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n }\n input[type=\"range\"]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 0.75rem;\n height: 0.75rem;\n /* WebKit centers the thumb on the input's full 1rem box, not the\n thinner custom track — nudge it up to align, as in range-slider.ts. */\n transform: translateY(-0.25rem);\n border-radius: 50%;\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border: 2px solid var(--ui-surface, #ffffff);\n box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n input[type=\"range\"]::-moz-range-thumb {\n width: 0.75rem;\n height: 0.75rem;\n border-radius: 50%;\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border: 2px solid var(--ui-surface, #ffffff);\n box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n input[type=\"range\"]:disabled::-webkit-slider-thumb {\n background: var(--ui-text-muted, #64748b);\n }\n input[type=\"range\"]:disabled::-moz-range-thumb {\n background: var(--ui-text-muted, #64748b);\n }\n input[type=\"range\"]:focus-visible {\n outline: none;\n }\n input[type=\"range\"]:focus-visible::-webkit-slider-thumb {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n input[type=\"range\"]:focus-visible::-moz-range-thumb {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (prefers-reduced-motion: no-preference) {\n input[type=\"range\"]::-webkit-slider-thumb {\n transition: box-shadow 120ms ease;\n }\n input[type=\"range\"]::-moz-range-thumb {\n transition: box-shadow 120ms ease;\n }\n }\n @media (forced-colors: active) {\n input[type=\"range\"]::-webkit-slider-runnable-track {\n background: Canvas;\n border: 1px solid CanvasText;\n }\n input[type=\"range\"]::-webkit-slider-thumb {\n background: Highlight;\n border-color: Canvas;\n }\n input[type=\"range\"]:focus-visible::-webkit-slider-thumb {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n`;\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import "./icon-button.js";
|
|
3
|
+
/**
|
|
4
|
+
* Video player wrapping a native `<video>` element (native `controls`
|
|
5
|
+
* disabled) with the same tokenized transport bar as `audio-player` — a
|
|
6
|
+
* play/pause `icon-button`, elapsed/total time, a seekable progress bar, a
|
|
7
|
+
* mute toggle + volume slider — plus a fullscreen toggle. The control bar
|
|
8
|
+
* sits in a persistent strip under the video frame rather than a
|
|
9
|
+
* hover-reveal overlay, so it stays usable for keyboard/touch input without
|
|
10
|
+
* a pointer hover state.
|
|
11
|
+
*
|
|
12
|
+
* @element video-player
|
|
13
|
+
* @fires play - The video started playing.
|
|
14
|
+
* @fires pause - The video was paused.
|
|
15
|
+
* @fires ended - Playback reached the end.
|
|
16
|
+
*/
|
|
17
|
+
export declare class VideoPlayer extends LitElement {
|
|
18
|
+
#private;
|
|
19
|
+
static styles: import("lit").CSSResult[];
|
|
20
|
+
/** URL of the video file to play. */
|
|
21
|
+
src: string;
|
|
22
|
+
/** Poster image shown before playback starts. */
|
|
23
|
+
poster: string;
|
|
24
|
+
/** Accessible name for the player, e.g. a video title. */
|
|
25
|
+
label: string;
|
|
26
|
+
/** Loops playback once it reaches the end. */
|
|
27
|
+
loop: boolean;
|
|
28
|
+
/** Native `<video preload>` hint. */
|
|
29
|
+
preload: "none" | "metadata" | "auto";
|
|
30
|
+
private _playing;
|
|
31
|
+
private _currentTime;
|
|
32
|
+
private _duration;
|
|
33
|
+
private _volume;
|
|
34
|
+
private _muted;
|
|
35
|
+
private _errored;
|
|
36
|
+
private _fullscreen;
|
|
37
|
+
private _video?;
|
|
38
|
+
private _frame?;
|
|
39
|
+
connectedCallback(): void;
|
|
40
|
+
disconnectedCallback(): void;
|
|
41
|
+
private _togglePlay;
|
|
42
|
+
private _toggleMute;
|
|
43
|
+
private _toggleFullscreen;
|
|
44
|
+
private _onSeekInput;
|
|
45
|
+
private _onVolumeInput;
|
|
46
|
+
private _onLoadedMetadata;
|
|
47
|
+
private _onTimeUpdate;
|
|
48
|
+
private _onPlay;
|
|
49
|
+
private _onPause;
|
|
50
|
+
private _onEnded;
|
|
51
|
+
private _onVolumeChange;
|
|
52
|
+
private _onError;
|
|
53
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
54
|
+
}
|
|
55
|
+
declare global {
|
|
56
|
+
interface HTMLElementTagNameMap {
|
|
57
|
+
"video-player": VideoPlayer;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=video-player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-player.d.ts","sourceRoot":"","sources":["../src/video-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAa5C,OAAO,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AACH,qBACa,WAAY,SAAQ,UAAU;;IACzC,OAAgB,MAAM,4BA2EpB;IAEF,qCAAqC;IACzB,GAAG,SAAM;IACrB,iDAAiD;IACrC,MAAM,SAAM;IACxB,0DAA0D;IAC9C,KAAK,SAAkB;IACnC,8CAA8C;IACjB,IAAI,UAAS;IAC1C,qCAAqC;IACzB,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAc;IAEtD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAS;IAErB,OAAO,CAAC,MAAM,CAAC,CAAmB;IACjC,OAAO,CAAC,MAAM,CAAC,CAAiB;IAMxC,iBAAiB,IAAI,IAAI,CAGjC;IAEQ,oBAAoB,IAAI,IAAI,CAGpC;IAED,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,cAA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