@f-ewald/components 1.23.1 → 1.24.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 +3 -0
- package/custom-elements.json +1847 -596
- 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 +10 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +10 -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 +17 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +56 -0
- package/dist/tokens.js.map +1 -1
- package/dist/ui-button.d.ts +16 -0
- package/dist/ui-button.d.ts.map +1 -1
- package/dist/ui-button.js +48 -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 +5 -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 +32 -0
- package/docs/video-player.md +59 -0
- package/llms.txt +162 -23
- package/package.json +1 -1
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;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,22 @@ 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
|
+
* pairing it with `--ui-button-border`/`--ui-button-danger-border` (default
|
|
33
|
+
* `transparent`) for a defining edge a shade darker than the gradient's dark
|
|
34
|
+
* stop, and setting the `-active` variant's stops in reverse for a
|
|
35
|
+
* pressed/"indented" look while the button is held down. `secondary`'s
|
|
36
|
+
* background/border read the equivalent `--ui-button-secondary-*` tokens
|
|
37
|
+
* (shared with `confirm-dialog`'s Cancel button), defaulting to today's
|
|
38
|
+
* transparent/bordered look, so it can be themed into a matching (e.g.
|
|
39
|
+
* white-to-gray) gradient too.
|
|
40
|
+
*
|
|
25
41
|
* @element ui-button
|
|
26
42
|
* @slot icon - Optional leading icon (e.g. an inline SVG).
|
|
27
43
|
* @slot - Button label.
|
|
@@ -77,26 +93,46 @@ let UiButton = class UiButton extends LitElement {
|
|
|
77
93
|
box-sizing: border-box;
|
|
78
94
|
}
|
|
79
95
|
.btn.primary {
|
|
80
|
-
background: var(--ui-primary, #4f46e5);
|
|
96
|
+
background: var(--ui-button-background, var(--ui-primary, #4f46e5));
|
|
97
|
+
border-color: var(--ui-button-border, transparent);
|
|
81
98
|
color: var(--ui-on-accent, #ffffff);
|
|
99
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
100
|
+
text-shadow: var(--ui-button-text-shadow, none);
|
|
82
101
|
}
|
|
83
102
|
.btn.primary:hover:not(:disabled) {
|
|
84
|
-
background: var(--ui-primary-hover, #4338ca);
|
|
103
|
+
background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));
|
|
104
|
+
}
|
|
105
|
+
.btn.primary:active:not(:disabled) {
|
|
106
|
+
background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));
|
|
107
|
+
box-shadow: none;
|
|
85
108
|
}
|
|
86
109
|
.btn.secondary {
|
|
87
|
-
background: none;
|
|
88
|
-
border-color: var(--ui-border, #e2e8f0);
|
|
110
|
+
background: var(--ui-button-secondary-background, none);
|
|
111
|
+
border-color: var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));
|
|
89
112
|
color: var(--ui-text, #0f172a);
|
|
113
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
90
114
|
}
|
|
91
115
|
.btn.secondary:hover:not(:disabled) {
|
|
92
|
-
|
|
116
|
+
background: var(--ui-button-secondary-background-hover, none);
|
|
117
|
+
border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));
|
|
118
|
+
}
|
|
119
|
+
.btn.secondary:active:not(:disabled) {
|
|
120
|
+
background: var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none));
|
|
121
|
+
box-shadow: none;
|
|
93
122
|
}
|
|
94
123
|
.btn.danger {
|
|
95
|
-
background: var(--ui-danger, #dc2626);
|
|
124
|
+
background: var(--ui-button-danger-background, var(--ui-danger, #dc2626));
|
|
125
|
+
border-color: var(--ui-button-danger-border, transparent);
|
|
96
126
|
color: var(--ui-on-accent, #ffffff);
|
|
127
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
128
|
+
text-shadow: var(--ui-button-text-shadow, none);
|
|
97
129
|
}
|
|
98
130
|
.btn.danger:hover:not(:disabled) {
|
|
99
|
-
background: var(--ui-danger-hover, #b91c1c);
|
|
131
|
+
background: var(--ui-button-danger-background-hover, var(--ui-danger-hover, #b91c1c));
|
|
132
|
+
}
|
|
133
|
+
.btn.danger:active:not(:disabled) {
|
|
134
|
+
background: var(--ui-button-danger-background-active, var(--ui-button-danger-background, var(--ui-danger, #dc2626)));
|
|
135
|
+
box-shadow: none;
|
|
100
136
|
}
|
|
101
137
|
.btn:disabled,
|
|
102
138
|
.btn[aria-disabled="true"] {
|
|
@@ -108,6 +144,11 @@ let UiButton = class UiButton extends LitElement {
|
|
|
108
144
|
outline: none;
|
|
109
145
|
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
110
146
|
}
|
|
147
|
+
.btn.primary:focus-visible:not(:active),
|
|
148
|
+
.btn.danger:focus-visible:not(:active),
|
|
149
|
+
.btn.secondary:focus-visible:not(:active) {
|
|
150
|
+
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);
|
|
151
|
+
}
|
|
111
152
|
.btn.sm {
|
|
112
153
|
height: 1.5rem;
|
|
113
154
|
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,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,CA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AC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;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,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,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 * 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":[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M,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
|
+
//# sourceM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