@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
|
@@ -0,0 +1 @@
|
|
|
1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AxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;oDAAwB;AAEvB;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;oDAAwB;AAEnC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAkB;AAE7B;IAAhB,KAAK,EAAE;kDAA2B;AAClB;IAAhB,KAAK,EAAE;+CAAqB;AAEF;IAA1B,KAAK,CAAC,UAAU,CAAC;kDAAyC;AAvFhD,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAyL3B","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\nimport \"./form-actions.js\";\nimport \"./ui-button.js\";\n\n/**\n * GitHub/Slack-style comment composer: a one-line text field that expands\n * into a multi-line textarea with a bottom-right Cancel/Submit footer\n * (`form-actions`) as soon as it's focused or clicked. Submitting fires\n * `submit` with the trimmed value, then clears the field and collapses back\n * to one line — it's meant for posting one comment at a time, not editing a\n * persistent value in place (see `editable-text` for that). Canceling (the\n * Cancel button or `Escape`) discards the draft and collapses without\n * firing `submit`. Clicking away (blur) does neither — the composer stays\n * expanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`\n * submits from the textarea, matching `editable-text`'s multiline shortcut.\n * Purely token-styled (no bespoke colors), so it's themeable via the same\n * `--ui-*` custom properties as every other value-entry field.\n *\n * @element comment-composer\n * @fires submit - User submitted a non-empty comment; detail: `{ value: string }`.\n * @fires cancel - User discarded the draft via the Cancel button or `Escape`.\n */\n@customElement(\"comment-composer\")\nexport class CommentComposer extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .shell {\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n background: var(--ui-surface, #ffffff);\n }\n .shell.expanded {\n border-radius: var(--ui-radius, 0.5rem);\n }\n input,\n textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n border: 0;\n background: none;\n color: var(--ui-text, #0f172a);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n padding: 0.5rem 0.75rem;\n outline: none;\n }\n textarea {\n resize: none;\n }\n input:focus-visible,\n .shell:not(.expanded):focus-within {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n border-radius: var(--ui-radius-sm, 0.25rem);\n }\n textarea:focus-visible {\n outline: none;\n }\n .footer {\n display: flex;\n justify-content: flex-end;\n padding: 0.5rem 0.75rem 0.75rem;\n }\n input:disabled,\n textarea:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n @media (forced-colors: active) {\n .shell:not(.expanded):focus-within {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Committed value shown in the collapsed one-line field. */\n @property() value = \"\";\n /** Placeholder text shown when empty. */\n @property() placeholder = \"Add a comment…\";\n /** Accessible name applied to the input/textarea. */\n @property() label = \"Comment\";\n /** Visible row count once expanded. */\n @property({ type: Number }) rows = 4;\n /** Label for the primary submit button. */\n @property({ attribute: \"submit-label\" }) submitLabel = \"Submit\";\n /** Label for the secondary cancel button. */\n @property({ attribute: \"cancel-label\" }) cancelLabel = \"Cancel\";\n /** Disables the field entirely. */\n @property({ type: Boolean }) disabled = false;\n\n @state() private _expanded = false;\n @state() private _draft = \"\";\n\n @query(\"textarea\") private _textarea?: HTMLTextAreaElement;\n\n private _expand(): void {\n if (this.disabled || this._expanded) return;\n this._draft = this.value;\n this._expanded = true;\n }\n\n private _onInput(e: Event): void {\n this._draft = (e.target as HTMLInputElement | HTMLTextAreaElement).value;\n }\n\n private _cancel(): void {\n this._draft = this.value;\n this._expanded = false;\n this.dispatchEvent(new CustomEvent(\"cancel\", { bubbles: true, composed: true }));\n }\n\n private _submit(): void {\n const trimmed = this._draft.trim();\n if (trimmed === \"\") return;\n this.value = \"\";\n this._draft = \"\";\n this._expanded = false;\n this.dispatchEvent(\n new CustomEvent(\"submit\", { detail: { value: trimmed }, bubbles: true, composed: true }),\n );\n }\n\n private _onKeydown(e: KeyboardEvent): void {\n if (e.key === \"Escape\") {\n e.preventDefault();\n this._cancel();\n } else if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n this._submit();\n }\n }\n\n protected override updated(changed: Map<string, unknown>): void {\n if (changed.has(\"_expanded\") && this._expanded) {\n const field = this._textarea;\n if (!field) return;\n field.focus();\n const end = field.value.length;\n field.setSelectionRange(end, end);\n }\n }\n\n override render() {\n const canSubmit = this._draft.trim() !== \"\";\n return html`\n <div class=\"shell ${this._expanded ? \"expanded\" : \"\"}\">\n ${this._expanded\n ? html`\n <textarea\n rows=${this.rows}\n .value=${this._draft}\n placeholder=${this.placeholder}\n aria-label=${this.label}\n ?disabled=${this.disabled}\n @input=${this._onInput}\n @keydown=${this._onKeydown}\n ></textarea>\n <div class=\"footer\">\n <form-actions>\n <ui-button\n slot=\"secondary\"\n variant=\"secondary\"\n size=\"sm\"\n @click=${this._cancel}\n >${this.cancelLabel}</ui-button\n >\n <ui-button\n slot=\"primary\"\n variant=\"primary\"\n size=\"sm\"\n ?disabled=${!canSubmit}\n @click=${this._submit}\n >${this.submitLabel}</ui-button\n >\n </form-actions>\n </div>\n `\n : html`\n <input\n type=\"text\"\n .value=${this.value}\n placeholder=${this.placeholder}\n aria-label=${this.label}\n ?disabled=${this.disabled}\n @focus=${this._expand}\n @click=${this._expand}\n />\n `}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"comment-composer\": CommentComposer;\n }\n}\n"]}
|
package/dist/confirm-dialog.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { LitElement, type PropertyValues } from "lit";
|
|
|
4
4
|
* an optional error line, and Cancel/Confirm actions. Instant `display:none`
|
|
5
5
|
* → `display:flex` toggle (no transitions). Fires `confirm`/`cancel`
|
|
6
6
|
* (bubbling, composed) instead of owning any deletion logic itself —
|
|
7
|
-
* callers stay in charge of the request.
|
|
7
|
+
* callers stay in charge of the request. Set `size="sm"` for compact
|
|
8
|
+
* actions one step below the default, matching `ui-button`'s `sm` size.
|
|
8
9
|
*
|
|
9
10
|
* @element confirm-dialog
|
|
10
11
|
* @fires confirm - User clicked the confirm button.
|
|
@@ -24,6 +25,8 @@ export declare class ConfirmDialog extends LitElement {
|
|
|
24
25
|
busy: boolean;
|
|
25
26
|
/** Inline error line shown below the body, or null for none. */
|
|
26
27
|
error: string | null;
|
|
28
|
+
/** Size — `sm` reduces both action buttons' height/padding/font-size one step below the default. */
|
|
29
|
+
size: "sm" | "md";
|
|
27
30
|
private _previousFocus;
|
|
28
31
|
private _confirm;
|
|
29
32
|
private _cancel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm-dialog.d.ts","sourceRoot":"","sources":["../src/confirm-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAW1E
|
|
1
|
+
{"version":3,"file":"confirm-dialog.d.ts","sourceRoot":"","sources":["../src/confirm-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAW1E;;;;;;;;;;;GAWG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,OAAgB,MAAM,4BAuLpB;IAEF,qCAAqC;IACR,IAAI,UAAS;IAC1C,oCAAoC;IACM,YAAY,SAAY;IAClE,mCAAmC;IACM,WAAW,SAAY;IAChE,wEAAwE;IAC3C,MAAM,UAAQ;IAC3C,8EAA8E;IACjD,IAAI,UAAS;IAC1C,gEAAgE;IACpD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IACxC,oGAAoG;IACvE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEtD,OAAO,CAAC,cAAc,CAA4B;IAElD,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,kBAAkB,CAGxB;IAEF,OAAO,CAAC,gBAAgB,CAuBtB;IAEF,UAAmB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAexD;IAEQ,oBAAoB,IAAI,IAAI,CAQpC;IAEQ,MAAM,yCA4Bd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
|
package/dist/confirm-dialog.js
CHANGED
|
@@ -14,7 +14,8 @@ import { activateLayer, claimEscape, deactivateLayer, isTopLayer, } from "./util
|
|
|
14
14
|
* an optional error line, and Cancel/Confirm actions. Instant `display:none`
|
|
15
15
|
* → `display:flex` toggle (no transitions). Fires `confirm`/`cancel`
|
|
16
16
|
* (bubbling, composed) instead of owning any deletion logic itself —
|
|
17
|
-
* callers stay in charge of the request.
|
|
17
|
+
* callers stay in charge of the request. Set `size="sm"` for compact
|
|
18
|
+
* actions one step below the default, matching `ui-button`'s `sm` size.
|
|
18
19
|
*
|
|
19
20
|
* @element confirm-dialog
|
|
20
21
|
* @fires confirm - User clicked the confirm button.
|
|
@@ -35,6 +36,8 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
35
36
|
this.busy = false;
|
|
36
37
|
/** Inline error line shown below the body, or null for none. */
|
|
37
38
|
this.error = null;
|
|
39
|
+
/** Size — `sm` reduces both action buttons' height/padding/font-size one step below the default. */
|
|
40
|
+
this.size = "md";
|
|
38
41
|
this._previousFocus = null;
|
|
39
42
|
this._onDocumentFocusIn = (event) => {
|
|
40
43
|
if (!this.open || !isTopLayer(this) || event.composedPath().includes(this))
|
|
@@ -138,20 +141,26 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
138
141
|
line-height: var(--ui-line-height-tight, 1.25);
|
|
139
142
|
}
|
|
140
143
|
.btn-cancel {
|
|
141
|
-
background: none;
|
|
142
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
144
|
+
background: var(--ui-button-secondary-background, none);
|
|
145
|
+
border: 1px solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));
|
|
143
146
|
color: var(--ui-text, #0f172a);
|
|
144
147
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
145
148
|
padding: 0.5rem 1rem;
|
|
146
149
|
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
147
150
|
cursor: pointer;
|
|
151
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
148
152
|
}
|
|
149
153
|
.btn-cancel:hover:not(:disabled) {
|
|
150
|
-
|
|
154
|
+
background: var(--ui-button-secondary-background-hover, none);
|
|
155
|
+
border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));
|
|
156
|
+
}
|
|
157
|
+
.btn-cancel:active:not(:disabled) {
|
|
158
|
+
background: var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none));
|
|
159
|
+
box-shadow: none;
|
|
151
160
|
}
|
|
152
161
|
.btn-danger,
|
|
153
162
|
.btn-primary {
|
|
154
|
-
border:
|
|
163
|
+
border: 1px solid transparent;
|
|
155
164
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
156
165
|
padding: 0.5rem 1rem;
|
|
157
166
|
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
@@ -162,18 +171,32 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
162
171
|
gap: 0.25rem;
|
|
163
172
|
}
|
|
164
173
|
.btn-danger {
|
|
165
|
-
background: var(--ui-danger, #dc2626);
|
|
174
|
+
background: var(--ui-button-danger-background, var(--ui-danger, #dc2626));
|
|
175
|
+
border-color: var(--ui-button-danger-border, transparent);
|
|
166
176
|
color: var(--ui-on-accent, #ffffff);
|
|
177
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
178
|
+
text-shadow: var(--ui-button-text-shadow, none);
|
|
167
179
|
}
|
|
168
180
|
.btn-danger:hover:not(:disabled) {
|
|
169
|
-
background: var(--ui-danger-hover, #b91c1c);
|
|
181
|
+
background: var(--ui-button-danger-background-hover, var(--ui-danger-hover, #b91c1c));
|
|
182
|
+
}
|
|
183
|
+
.btn-danger:active:not(:disabled) {
|
|
184
|
+
background: var(--ui-button-danger-background-active, var(--ui-button-danger-background, var(--ui-danger, #dc2626)));
|
|
185
|
+
box-shadow: none;
|
|
170
186
|
}
|
|
171
187
|
.btn-primary {
|
|
172
|
-
background: var(--ui-primary, #4f46e5);
|
|
188
|
+
background: var(--ui-button-background, var(--ui-primary, #4f46e5));
|
|
189
|
+
border-color: var(--ui-button-border, transparent);
|
|
173
190
|
color: var(--ui-on-accent, #ffffff);
|
|
191
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
192
|
+
text-shadow: var(--ui-button-text-shadow, none);
|
|
174
193
|
}
|
|
175
194
|
.btn-primary:hover:not(:disabled) {
|
|
176
|
-
background: var(--ui-primary-hover, #4338ca);
|
|
195
|
+
background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));
|
|
196
|
+
}
|
|
197
|
+
.btn-primary:active:not(:disabled) {
|
|
198
|
+
background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));
|
|
199
|
+
box-shadow: none;
|
|
177
200
|
}
|
|
178
201
|
button:disabled {
|
|
179
202
|
opacity: 0.6;
|
|
@@ -183,6 +206,18 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
183
206
|
outline: none;
|
|
184
207
|
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
185
208
|
}
|
|
209
|
+
.btn-primary:focus-visible:not(:active),
|
|
210
|
+
.btn-danger:focus-visible:not(:active),
|
|
211
|
+
.btn-cancel:focus-visible:not(:active) {
|
|
212
|
+
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);
|
|
213
|
+
}
|
|
214
|
+
:host([size="sm"]) .btn-cancel,
|
|
215
|
+
:host([size="sm"]) .btn-danger,
|
|
216
|
+
:host([size="sm"]) .btn-primary {
|
|
217
|
+
height: 1.5rem;
|
|
218
|
+
padding: 0.25rem 0.5rem;
|
|
219
|
+
font-size: var(--ui-font-size-xs, 0.6875rem);
|
|
220
|
+
}
|
|
186
221
|
.error-text {
|
|
187
222
|
color: var(--ui-danger, #dc2626);
|
|
188
223
|
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
@@ -314,6 +349,9 @@ __decorate([
|
|
|
314
349
|
__decorate([
|
|
315
350
|
property()
|
|
316
351
|
], ConfirmDialog.prototype, "error", void 0);
|
|
352
|
+
__decorate([
|
|
353
|
+
property({ reflect: true })
|
|
354
|
+
], ConfirmDialog.prototype, "size", void 0);
|
|
317
355
|
ConfirmDialog = __decorate([
|
|
318
356
|
customElement("confirm-dialog")
|
|
319
357
|
], ConfirmDialog);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm-dialog.js","sourceRoot":"","sources":["../src/confirm-dialog.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,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;AACrC,OAAO,EACL,aAAa,EACb,WAAW,EACX,eAAe,EACf,UAAU,G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,CAAA,wDAAwD,IAAI,CAAC,KAAK,MAAM;YAC9E,CAAC,CAAC,OAAO;;mDAE8B,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW;4BAC3E,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,cAAc,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,QAAQ;gBACrG,IAAI,CAAC,IAAI;YACT,CAAC,CAAC,IAAI,CAAA,yCAAyC,aAAa,CAAC,EAAE,CAAC,SAAS;YACzE,CAAC,CAAC,OAAO;gBACT,IAAI,CAAC,YAAY;;;;;KAK5B,CAAC;IACJ,CAAC;CACF,CAAA;AA7H8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CAAc;AAEA;IAAzC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;mDAAyB;AAEzB;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;kDAAwB;AAEnC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAe;AAEd;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CAAc;AAE9B;IAAX,QAAQ,EAAE;4CAA6B;AArK7B,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAwRzB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconArrowPath } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n activateLayer,\n claimEscape,\n deactivateLayer,\n isTopLayer,\n} from \"./utils/layer-stack.js\";\n\n/**\n * Reusable confirmation dialog: overlay + centered card with a slotted body,\n * an optional error line, and Cancel/Confirm actions. Instant `display:none`\n * → `display:flex` toggle (no transitions). Fires `confirm`/`cancel`\n * (bubbling, composed) instead of owning any deletion logic itself —\n * callers stay in charge of the request.\n *\n * @element confirm-dialog\n * @fires confirm - User clicked the confirm button.\n * @fires cancel - User clicked the cancel button.\n */\n@customElement(\"confirm-dialog\")\nexport class ConfirmDialog extends LitElement {\n static override styles = [\n tokens,\n css`\n .overlay {\n position: fixed;\n inset: 0;\n background: var(--ui-overlay, rgb(15 23 42 / 0.45));\n z-index: var(--component-layer-z, 50);\n display: none;\n align-items: flex-start;\n justify-content: center;\n padding: 10vh 1.25rem 1.25rem;\n box-sizing: border-box;\n }\n .overlay.open {\n display: flex;\n }\n .dialog {\n background: var(--ui-surface, #ffffff);\n border-radius: var(--ui-radius, 0.5rem);\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n );\n width: 100%;\n max-width: min(25rem, calc(100vw - 2rem));\n padding: 1rem;\n box-sizing: border-box;\n outline: none;\n }\n .dialog-text {\n margin: 0 0 1rem;\n color: var(--ui-text, #0f172a);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n }\n .dialog-actions {\n display: flex;\n justify-content: flex-end;\n gap: 0.5rem;\n }\n .btn-cancel,\n .btn-danger,\n .btn-primary {\n height: 2rem;\n box-sizing: border-box;\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 line-height: var(--ui-line-height-tight, 1.25);\n }\n .btn-cancel {\n background: none;\n border: 1px solid var(--ui-border, #e2e8f0);\n color: var(--ui-text, #0f172a);\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 cursor: pointer;\n }\n .btn-cancel:hover:not(:disabled) {\n border-color: var(--ui-text-muted, #64748b);\n }\n .btn-danger,\n .btn-primary {\n border: none;\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 cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\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-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 button:disabled {\n opacity: 0.6;\n cursor: default;\n }\n button:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .error-text {\n color: var(--ui-danger, #dc2626);\n font-size: var(--ui-font-size-sm, 0.75rem);\n margin: 0.5rem 0 0.75rem;\n }\n .spin {\n display: inline-flex;\n animation: spin 0.8s linear infinite;\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 button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n .overlay {\n padding: 0.75rem;\n overflow-y: auto;\n }\n .dialog {\n padding: 0.75rem;\n }\n }\n `,\n ];\n\n /** Whether the dialog is visible. */\n @property({ type: Boolean }) open = false;\n /** Label for the confirm button. */\n @property({ attribute: \"confirm-label\" }) confirmLabel = \"Delete\";\n /** Label for the cancel button. */\n @property({ attribute: \"cancel-label\" }) cancelLabel = \"Cancel\";\n /** Danger (red) vs. primary (indigo) styling for the confirm button. */\n @property({ type: Boolean }) danger = true;\n /** Shows a spinner and disables both buttons while a request is in flight. */\n @property({ type: Boolean }) busy = false;\n /** Inline error line shown below the body, or null for none. */\n @property() error: string | null = null;\n\n private _previousFocus: HTMLElement | null = null;\n\n private _confirm() {\n this.dispatchEvent(new CustomEvent(\"confirm\", { bubbles: true, composed: true }));\n }\n\n private _cancel() {\n this.dispatchEvent(new CustomEvent(\"cancel\", { bubbles: true, composed: true }));\n }\n\n private _getFocusableElements(): HTMLElement[] {\n const selector =\n \"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])\";\n const slotted = Array.from(this.querySelectorAll<HTMLElement>(selector));\n const internal = Array.from(\n this.shadowRoot?.querySelectorAll<HTMLElement>(selector) ?? [],\n ).filter((element) => element.closest(\".dialog\") !== null);\n return [...slotted, ...internal].filter((element) => !element.hasAttribute(\"hidden\"));\n }\n\n private _focusInitial(): void {\n const autofocus = this.querySelector<HTMLElement>(\"[autofocus]\");\n const cancel = this.shadowRoot?.querySelector<HTMLElement>(\".btn-cancel:not(:disabled)\");\n const dialog = this.shadowRoot?.querySelector<HTMLElement>(\".dialog\");\n (autofocus ?? cancel ?? this._getFocusableElements()[0] ?? dialog)?.focus();\n }\n\n private _onDocumentFocusIn = (event: FocusEvent): void => {\n if (!this.open || !isTopLayer(this) || event.composedPath().includes(this)) return;\n this._focusInitial();\n };\n\n private _onWindowKeydown = (event: KeyboardEvent): void => {\n if (!this.open || !isTopLayer(this)) return;\n if (claimEscape(this, event) && !this.busy) {\n this._cancel();\n return;\n }\n if (event.key !== \"Tab\") return;\n\n const focusable = this._getFocusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n this._focusInitial();\n return;\n }\n const active = (this.shadowRoot?.activeElement ?? document.activeElement) as HTMLElement | null;\n const index = focusable.indexOf(active as HTMLElement);\n if (event.shiftKey && index <= 0) {\n event.preventDefault();\n focusable.at(-1)?.focus();\n } else if (!event.shiftKey && index === focusable.length - 1) {\n event.preventDefault();\n focusable[0]?.focus();\n }\n };\n\n protected override updated(changed: PropertyValues): void {\n if (!changed.has(\"open\")) return;\n if (this.open) {\n activateLayer(this);\n this._previousFocus = document.activeElement as HTMLElement | null;\n document.addEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.addEventListener(\"keydown\", this._onWindowKeydown, true);\n this._focusInitial();\n return;\n }\n deactivateLayer(this);\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n deactivateLayer(this);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n this.open = false;\n }\n\n override render() {\n const accessibleName = this.getAttribute(\"aria-label\") ?? \"Confirmation\";\n return html`\n <div class=\"overlay ${this.open ? \"open\" : \"\"}\">\n <div\n class=\"dialog\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${accessibleName}\n aria-describedby=${this.error ? \"dialog-text dialog-error\" : \"dialog-text\"}\n tabindex=\"-1\"\n >\n <p id=\"dialog-text\" class=\"dialog-text\"><slot></slot></p>\n ${this.error\n ? html`<p id=\"dialog-error\" class=\"error-text\" role=\"alert\">${this.error}</p>`\n : nothing}\n <div class=\"dialog-actions\">\n <button class=\"btn-cancel\" ?disabled=${this.busy} @click=${this._cancel}>${this.cancelLabel}</button>\n <button class=${this.danger ? \"btn-danger\" : \"btn-primary\"} ?disabled=${this.busy} @click=${this._confirm}>\n ${this.busy\n ? html`<span class=\"spin\" aria-hidden=\"true\">${iconArrowPath(14)}</span>`\n : nothing}\n ${this.confirmLabel}\n </button>\n </div>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n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EAAE,CAAC;6CAAe;AAEd;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CAAc;AAE9B;IAAX,QAAQ,EAAE;4CAA6B;AAEX;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAA0B;AAvM3C,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CA0TzB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconArrowPath } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n activateLayer,\n claimEscape,\n deactivateLayer,\n isTopLayer,\n} from \"./utils/layer-stack.js\";\n\n/**\n * Reusable confirmation dialog: overlay + centered card with a slotted body,\n * an optional error line, and Cancel/Confirm actions. Instant `display:none`\n * → `display:flex` toggle (no transitions). Fires `confirm`/`cancel`\n * (bubbling, composed) instead of owning any deletion logic itself —\n * callers stay in charge of the request. Set `size=\"sm\"` for compact\n * actions one step below the default, matching `ui-button`'s `sm` size.\n *\n * @element confirm-dialog\n * @fires confirm - User clicked the confirm button.\n * @fires cancel - User clicked the cancel button.\n */\n@customElement(\"confirm-dialog\")\nexport class ConfirmDialog extends LitElement {\n static override styles = [\n tokens,\n css`\n .overlay {\n position: fixed;\n inset: 0;\n background: var(--ui-overlay, rgb(15 23 42 / 0.45));\n z-index: var(--component-layer-z, 50);\n display: none;\n align-items: flex-start;\n justify-content: center;\n padding: 10vh 1.25rem 1.25rem;\n box-sizing: border-box;\n }\n .overlay.open {\n display: flex;\n }\n .dialog {\n background: var(--ui-surface, #ffffff);\n border-radius: var(--ui-radius, 0.5rem);\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n );\n width: 100%;\n max-width: min(25rem, calc(100vw - 2rem));\n padding: 1rem;\n box-sizing: border-box;\n outline: none;\n }\n .dialog-text {\n margin: 0 0 1rem;\n color: var(--ui-text, #0f172a);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n }\n .dialog-actions {\n display: flex;\n justify-content: flex-end;\n gap: 0.5rem;\n }\n .btn-cancel,\n .btn-danger,\n .btn-primary {\n height: 2rem;\n box-sizing: border-box;\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 line-height: var(--ui-line-height-tight, 1.25);\n }\n .btn-cancel {\n background: var(--ui-button-secondary-background, none);\n border: 1px solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n color: var(--ui-text, #0f172a);\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 cursor: pointer;\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .btn-cancel: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-cancel: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 .btn-primary {\n border: 1px solid transparent;\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 cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\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-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 button:disabled {\n opacity: 0.6;\n cursor: default;\n }\n button: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-cancel: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 :host([size=\"sm\"]) .btn-cancel,\n :host([size=\"sm\"]) .btn-danger,\n :host([size=\"sm\"]) .btn-primary {\n height: 1.5rem;\n padding: 0.25rem 0.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .error-text {\n color: var(--ui-danger, #dc2626);\n font-size: var(--ui-font-size-sm, 0.75rem);\n margin: 0.5rem 0 0.75rem;\n }\n .spin {\n display: inline-flex;\n animation: spin 0.8s linear infinite;\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 button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n .overlay {\n padding: 0.75rem;\n overflow-y: auto;\n }\n .dialog {\n padding: 0.75rem;\n }\n }\n `,\n ];\n\n /** Whether the dialog is visible. */\n @property({ type: Boolean }) open = false;\n /** Label for the confirm button. */\n @property({ attribute: \"confirm-label\" }) confirmLabel = \"Delete\";\n /** Label for the cancel button. */\n @property({ attribute: \"cancel-label\" }) cancelLabel = \"Cancel\";\n /** Danger (red) vs. primary (indigo) styling for the confirm button. */\n @property({ type: Boolean }) danger = true;\n /** Shows a spinner and disables both buttons while a request is in flight. */\n @property({ type: Boolean }) busy = false;\n /** Inline error line shown below the body, or null for none. */\n @property() error: string | null = null;\n /** Size — `sm` reduces both action buttons' height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n private _previousFocus: HTMLElement | null = null;\n\n private _confirm() {\n this.dispatchEvent(new CustomEvent(\"confirm\", { bubbles: true, composed: true }));\n }\n\n private _cancel() {\n this.dispatchEvent(new CustomEvent(\"cancel\", { bubbles: true, composed: true }));\n }\n\n private _getFocusableElements(): HTMLElement[] {\n const selector =\n \"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])\";\n const slotted = Array.from(this.querySelectorAll<HTMLElement>(selector));\n const internal = Array.from(\n this.shadowRoot?.querySelectorAll<HTMLElement>(selector) ?? [],\n ).filter((element) => element.closest(\".dialog\") !== null);\n return [...slotted, ...internal].filter((element) => !element.hasAttribute(\"hidden\"));\n }\n\n private _focusInitial(): void {\n const autofocus = this.querySelector<HTMLElement>(\"[autofocus]\");\n const cancel = this.shadowRoot?.querySelector<HTMLElement>(\".btn-cancel:not(:disabled)\");\n const dialog = this.shadowRoot?.querySelector<HTMLElement>(\".dialog\");\n (autofocus ?? cancel ?? this._getFocusableElements()[0] ?? dialog)?.focus();\n }\n\n private _onDocumentFocusIn = (event: FocusEvent): void => {\n if (!this.open || !isTopLayer(this) || event.composedPath().includes(this)) return;\n this._focusInitial();\n };\n\n private _onWindowKeydown = (event: KeyboardEvent): void => {\n if (!this.open || !isTopLayer(this)) return;\n if (claimEscape(this, event) && !this.busy) {\n this._cancel();\n return;\n }\n if (event.key !== \"Tab\") return;\n\n const focusable = this._getFocusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n this._focusInitial();\n return;\n }\n const active = (this.shadowRoot?.activeElement ?? document.activeElement) as HTMLElement | null;\n const index = focusable.indexOf(active as HTMLElement);\n if (event.shiftKey && index <= 0) {\n event.preventDefault();\n focusable.at(-1)?.focus();\n } else if (!event.shiftKey && index === focusable.length - 1) {\n event.preventDefault();\n focusable[0]?.focus();\n }\n };\n\n protected override updated(changed: PropertyValues): void {\n if (!changed.has(\"open\")) return;\n if (this.open) {\n activateLayer(this);\n this._previousFocus = document.activeElement as HTMLElement | null;\n document.addEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.addEventListener(\"keydown\", this._onWindowKeydown, true);\n this._focusInitial();\n return;\n }\n deactivateLayer(this);\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n deactivateLayer(this);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n this.open = false;\n }\n\n override render() {\n const accessibleName = this.getAttribute(\"aria-label\") ?? \"Confirmation\";\n return html`\n <div class=\"overlay ${this.open ? \"open\" : \"\"}\">\n <div\n class=\"dialog\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${accessibleName}\n aria-describedby=${this.error ? \"dialog-text dialog-error\" : \"dialog-text\"}\n tabindex=\"-1\"\n >\n <p id=\"dialog-text\" class=\"dialog-text\"><slot></slot></p>\n ${this.error\n ? html`<p id=\"dialog-error\" class=\"error-text\" role=\"alert\">${this.error}</p>`\n : nothing}\n <div class=\"dialog-actions\">\n <button class=\"btn-cancel\" ?disabled=${this.busy} @click=${this._cancel}>${this.cancelLabel}</button>\n <button class=${this.danger ? \"btn-danger\" : \"btn-primary\"} ?disabled=${this.busy} @click=${this._confirm}>\n ${this.busy\n ? html`<span class=\"spin\" aria-hidden=\"true\">${iconArrowPath(14)}</span>`\n : nothing}\n ${this.confirmLabel}\n </button>\n </div>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"confirm-dialog\": ConfirmDialog;\n }\n}\n"]}
|
|
@@ -19,7 +19,8 @@ export type DropdownButtonVariant = "text" | "icon" | "text-icon";
|
|
|
19
19
|
* (the same, with `icon` ahead of the label), and `icon` (a borderless,
|
|
20
20
|
* square, low-emphasis icon target in the style of `icon-button` — the
|
|
21
21
|
* classic "three-dot"/overflow menu, where `label` becomes the accessible
|
|
22
|
-
* name rather than visible text).
|
|
22
|
+
* name rather than visible text). Set `size="sm"` for a compact trigger one
|
|
23
|
+
* step below the default, matching `ui-button`'s `sm` size.
|
|
23
24
|
*
|
|
24
25
|
* @element dropdown-button
|
|
25
26
|
* @fires select - Fired with `{ value: string }` when a menu item is picked.
|
|
@@ -37,6 +38,8 @@ export declare class DropdownButton extends LitElement {
|
|
|
37
38
|
variant: DropdownButtonVariant;
|
|
38
39
|
/** Icon template rendered by the `icon` and `text-icon` variants. */
|
|
39
40
|
icon: TemplateResult | null;
|
|
41
|
+
/** Size — `sm` reduces the trigger's height/padding/font-size one step below the default. */
|
|
42
|
+
size: "sm" | "md";
|
|
40
43
|
private _open;
|
|
41
44
|
private _activeIndex;
|
|
42
45
|
disconnectedCallback(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-button.d.ts","sourceRoot":"","sources":["../src/dropdown-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAO/F,4BAA4B;AAC5B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,+EAA+E;AAC/E,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;AAElE
|
|
1
|
+
{"version":3,"file":"dropdown-button.d.ts","sourceRoot":"","sources":["../src/dropdown-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAO/F,4BAA4B;AAC5B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,+EAA+E;AAC/E,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,cAAe,SAAQ,UAAU;;IAC5C,OAAgB,MAAM,4BAkKpB;IAEF,2GAA2G;IAC/F,KAAK,SAAM;IACvB,0BAA0B;IACM,OAAO,EAAE,cAAc,EAAE,CAAM;IAC/D,8DAA8D;IACjC,QAAQ,UAAS;IAC9C,oEAAoE;IACvC,OAAO,EAAE,qBAAqB,CAAU;IACrE,qEAAqE;IACrC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAQ;IACnE,6FAA6F;IAChE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE7C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,YAAY,CAAM;IAG1B,oBAAoB,IAAI,IAAI,CAKpC;IAED,UAAmB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAYxD;IA6CD,OAAO,CAAC,UAAU;IA0BT,MAAM,sBA8Bd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,cAAc,CAAC;KACnC;CACF"}
|
package/dist/dropdown-button.js
CHANGED
|
@@ -20,7 +20,8 @@ let instanceCount = 0;
|
|
|
20
20
|
* (the same, with `icon` ahead of the label), and `icon` (a borderless,
|
|
21
21
|
* square, low-emphasis icon target in the style of `icon-button` — the
|
|
22
22
|
* classic "three-dot"/overflow menu, where `label` becomes the accessible
|
|
23
|
-
* name rather than visible text).
|
|
23
|
+
* name rather than visible text). Set `size="sm"` for a compact trigger one
|
|
24
|
+
* step below the default, matching `ui-button`'s `sm` size.
|
|
24
25
|
*
|
|
25
26
|
* @element dropdown-button
|
|
26
27
|
* @fires select - Fired with `{ value: string }` when a menu item is picked.
|
|
@@ -38,6 +39,8 @@ let DropdownButton = class DropdownButton extends LitElement {
|
|
|
38
39
|
this.variant = "text";
|
|
39
40
|
/** Icon template rendered by the `icon` and `text-icon` variants. */
|
|
40
41
|
this.icon = null;
|
|
42
|
+
/** Size — `sm` reduces the trigger's height/padding/font-size one step below the default. */
|
|
43
|
+
this.size = "md";
|
|
41
44
|
this._open = false;
|
|
42
45
|
this._activeIndex = -1;
|
|
43
46
|
this.#menuId = `dropdown-button-menu-${++instanceCount}`;
|
|
@@ -102,11 +105,21 @@ let DropdownButton = class DropdownButton extends LitElement {
|
|
|
102
105
|
even before the reflected attribute lands. */
|
|
103
106
|
:host(:not([variant="icon"])) button.trigger {
|
|
104
107
|
color: var(--ui-on-accent, #ffffff);
|
|
105
|
-
background: var(--ui-primary, #4f46e5);
|
|
108
|
+
background: var(--ui-button-background, var(--ui-primary, #4f46e5));
|
|
109
|
+
border-color: var(--ui-button-border, transparent);
|
|
110
|
+
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
111
|
+
text-shadow: var(--ui-button-text-shadow, none);
|
|
106
112
|
padding: 0.5rem 1rem;
|
|
107
113
|
}
|
|
108
114
|
:host(:not([variant="icon"])) button.trigger:hover:not(:disabled) {
|
|
109
|
-
background: var(--ui-primary-hover, #4338ca);
|
|
115
|
+
background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));
|
|
116
|
+
}
|
|
117
|
+
:host(:not([variant="icon"])) button.trigger:active:not(:disabled) {
|
|
118
|
+
background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));
|
|
119
|
+
box-shadow: none;
|
|
120
|
+
}
|
|
121
|
+
:host(:not([variant="icon"])) button.trigger:focus-visible:not(:active) {
|
|
122
|
+
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);
|
|
110
123
|
}
|
|
111
124
|
/* icon: borderless low-emphasis square target, matching icon-button. */
|
|
112
125
|
:host([variant="icon"]) button.trigger {
|
|
@@ -119,6 +132,16 @@ let DropdownButton = class DropdownButton extends LitElement {
|
|
|
119
132
|
background: var(--ui-surface-muted, #f8fafc);
|
|
120
133
|
color: var(--ui-text, #0f172a);
|
|
121
134
|
}
|
|
135
|
+
:host([size="sm"]) button.trigger {
|
|
136
|
+
height: 1.5rem;
|
|
137
|
+
font-size: var(--ui-font-size-xs, 0.6875rem);
|
|
138
|
+
}
|
|
139
|
+
:host(:not([variant="icon"])[size="sm"]) button.trigger {
|
|
140
|
+
padding: 0.25rem 0.5rem;
|
|
141
|
+
}
|
|
142
|
+
:host([variant="icon"][size="sm"]) button.trigger {
|
|
143
|
+
width: 1.5rem;
|
|
144
|
+
}
|
|
122
145
|
.icon {
|
|
123
146
|
display: flex;
|
|
124
147
|
line-height: 0;
|
|
@@ -326,6 +349,9 @@ __decorate([
|
|
|
326
349
|
__decorate([
|
|
327
350
|
property({ attribute: false })
|
|
328
351
|
], DropdownButton.prototype, "icon", void 0);
|
|
352
|
+
__decorate([
|
|
353
|
+
property({ reflect: true })
|
|
354
|
+
], DropdownButton.prototype, "size", void 0);
|
|
329
355
|
__decorate([
|
|
330
356
|
state()
|
|
331
357
|
], DropdownButton.prototype, "_open", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-button.js","sourceRoot":"","sources":["../src/dropdown-button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,IAAI,aAAa,GAAG,CAAC,CAAC;AAatB;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAiJL,2GAA2G;QAC/F,UAAK,GAAG,EAAE,CAAC;QACvB,0BAA0B;QACM,YAAO,GAAqB,EAAE,CAAC;QAC/D,8DAA8D;QACjC,aAAQ,GAAG,KAAK,CAAC;QAC9C,oEAAoE;QACvC,YAAO,GAA0B,MAAM,CAAC;QACrE,qEAAqE;QACrC,SAAI,GAA0B,IAAI,CAAC;QAElD,UAAK,GAAG,KAAK,CAAC;QACd,iBAAY,GAAG,CAAC,CAAC,CAAC;QAC1B,YAAO,GAAG,wBAAwB,EAAE,aAAa,EAAE,CAAC;QAuB7D,uBAAkB,GAAG,CAAC,CAAa,EAAQ,EAAE;YAC3C,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAC3D,CAAC,CAAC;IAkGJ,CAAC;aAxRiB,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CAAC;+CAAyC;AAErC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAAoC;AAElD;IAAhB,KAAK,EAAE;6CAAuB;AACd;IAAhB,KAAK,EAAE;oDAA2B;AA7JxB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAyR1B","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues, type TemplateResult } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronRight } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nlet instanceCount = 0;\n\n/** A single menu action. */\nexport interface DropdownOption {\n value: string;\n label: string;\n /** Renders the item in the danger color, for a destructive action (e.g. Delete). */\n danger?: boolean;\n}\n\n/** How the trigger presents itself: label only, icon only, or icon + label. */\nexport type DropdownButtonVariant = \"text\" | \"icon\" | \"text-icon\";\n\n/**\n * A button that opens an anchored menu of actions — essentially `form-select`\n * minus \"current value\" semantics: a menu, not a select. Use for a set of\n * mutually exclusive next-step actions (e.g. a failed task's Retry / Close /\n * Backlog, or a table row's overflow actions).\n *\n * Three trigger presentations share one base: `text` (the default — a\n * primary-filled button with a label and a rotating chevron), `text-icon`\n * (the same, with `icon` ahead of the label), and `icon` (a borderless,\n * square, low-emphasis icon target in the style of `icon-button` — the\n * classic \"three-dot\"/overflow menu, where `label` becomes the accessible\n * name rather than visible text).\n *\n * @element dropdown-button\n * @fires select - Fired with `{ value: string }` when a menu item is picked.\n */\n@customElement(\"dropdown-button\")\nexport class DropdownButton extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\n position: relative;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n /* Shared trigger base — layout, type, shape, and interaction states every\n variant has in common. Variant blocks below only add fill/padding. */\n button.trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0.25rem;\n height: 2rem;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n border: 1px solid transparent;\n border-radius: var(--ui-radius-sm, 0.25rem);\n cursor: pointer;\n }\n button.trigger:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n button.trigger:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n /* text + text-icon: the primary-filled trigger. Written as :not([variant=\"icon\"])\n rather than two positive selectors so the default presentation is correct\n even before the reflected attribute lands. */\n :host(:not([variant=\"icon\"])) button.trigger {\n color: var(--ui-on-accent, #ffffff);\n background: var(--ui-primary, #4f46e5);\n padding: 0.5rem 1rem;\n }\n :host(:not([variant=\"icon\"])) button.trigger:hover:not(:disabled) {\n background: var(--ui-primary-hover, #4338ca);\n }\n /* icon: borderless low-emphasis square target, matching icon-button. */\n :host([variant=\"icon\"]) button.trigger {\n width: 2rem;\n padding: 0;\n color: var(--ui-text-muted, #64748b);\n background: none;\n }\n :host([variant=\"icon\"]) button.trigger:hover:not(:disabled) {\n background: var(--ui-surface-muted, #f8fafc);\n color: var(--ui-text, #0f172a);\n }\n .icon {\n display: flex;\n line-height: 0;\n }\n .chevron {\n display: flex;\n transform: rotate(90deg);\n transition: transform 150ms ease;\n }\n :host([open]) .chevron {\n transform: rotate(-90deg);\n }\n ul.options {\n position: absolute;\n top: 100%;\n right: 0;\n z-index: 10;\n min-width: 100%;\n max-height: 40vh;\n overflow-y: auto;\n margin: 0.25rem 0 0;\n padding: 0.25rem 0;\n list-style: none;\n white-space: nowrap;\n background: var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n li {\n padding: 0.5rem 0.75rem;\n cursor: pointer;\n color: var(--ui-text, #0f172a);\n }\n li.danger {\n color: var(--ui-danger, #dc2626);\n }\n li.active,\n li:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n li.danger.active,\n li.danger:hover {\n color: var(--ui-danger-hover, #b91c1c);\n }\n @media (prefers-reduced-motion: reduce) {\n .chevron {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n button.trigger:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n button.trigger:disabled {\n color: GrayText;\n opacity: 1;\n }\n li.active,\n li:hover,\n li.danger.active,\n li.danger:hover {\n color: HighlightText;\n background: Highlight;\n }\n }\n `,\n ];\n\n /** The trigger button's label. In the `icon` variant it is the accessible name instead of visible text. */\n @property() label = \"\";\n /** The menu's actions. */\n @property({ attribute: false }) options: DropdownOption[] = [];\n /** Disables the trigger, preventing the menu from opening. */\n @property({ type: Boolean }) disabled = false;\n /** Trigger presentation: label only, icon only, or icon + label. */\n @property({ reflect: true }) variant: DropdownButtonVariant = \"text\";\n /** Icon template rendered by the `icon` and `text-icon` variants. */\n @property({ attribute: false }) icon: TemplateResult | null = null;\n\n @state() private _open = false;\n @state() private _activeIndex = -1;\n readonly #menuId = `dropdown-button-menu-${++instanceCount}`;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener(\"mousedown\", this.#onWindowMousedown, true);\n this._open = false;\n this._activeIndex = -1;\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"disabled\") && this.disabled) {\n this._open = false;\n this._activeIndex = -1;\n }\n if (!changed.has(\"_open\")) return;\n this.toggleAttribute(\"open\", this._open);\n if (this._open) {\n window.addEventListener(\"mousedown\", this.#onWindowMousedown, true);\n } else {\n window.removeEventListener(\"mousedown\", this.#onWindowMousedown, true);\n }\n }\n\n #onWindowMousedown = (e: MouseEvent): void => {\n if (!e.composedPath().includes(this)) this._open = false;\n };\n\n #toggle(): void {\n if (this.disabled) return;\n this._open = !this._open;\n if (this._open) this._activeIndex = 0;\n }\n\n #select(option: DropdownOption): void {\n if (this.disabled) return;\n this._open = false;\n this.dispatchEvent(new CustomEvent(\"select\", { detail: { value: option.value } }));\n }\n\n #onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\" || e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n if (!this._open) {\n this.#toggle();\n return;\n }\n if (e.key === \"ArrowDown\") this.#moveActive(1);\n else if (e.key === \"ArrowUp\") this.#moveActive(-1);\n else this.#confirmActive();\n } else if (e.key === \"Escape\" && this._open) {\n e.preventDefault();\n this._open = false;\n }\n }\n\n #moveActive(delta: number): void {\n if (this.options.length === 0) return;\n const n = this.options.length;\n this._activeIndex = (this._activeIndex + delta + n) % n;\n }\n\n #confirmActive(): void {\n const option = this.options[this._activeIndex];\n if (option) this.#select(option);\n }\n\n private renderMenu() {\n if (!this._open) return nothing;\n return html`\n <ul id=${this.#menuId} class=\"options\" role=\"menu\" aria-label=${this.label}>\n ${this.options.map(\n (o, i) => html`\n <li\n id=${`${this.#menuId}-item-${i}`}\n role=\"menuitem\"\n class=${[i === this._activeIndex ? \"active\" : \"\", o.danger ? \"danger\" : \"\"]\n .filter(Boolean)\n .join(\" \")}\n @mousedown=${(e: MouseEvent) => {\n if (e.button !== 0) return;\n e.preventDefault();\n this.#select(o);\n }}\n >\n ${o.label}\n </li>\n `,\n )}\n </ul>\n `;\n }\n\n override render() {\n const activeDescendant =\n this._open && this._activeIndex >= 0\n ? `${this.#menuId}-item-${this._activeIndex}`\n : nothing;\n const iconOnly = this.variant === \"icon\";\n return html`\n <button\n type=\"button\"\n class=\"trigger\"\n aria-haspopup=\"menu\"\n aria-expanded=${this._open}\n aria-controls=${this.#menuId}\n aria-activedescendant=${activeDescendant}\n aria-label=${iconOnly && this.label ? this.label : nothing}\n title=${iconOnly && this.label ? this.label : nothing}\n ?disabled=${this.disabled}\n @click=${() => this.#toggle()}\n @keydown=${(e: KeyboardEvent) => this.#onTriggerKeydown(e)}\n >\n ${this.variant !== \"text\" && this.icon\n ? html`<span class=\"icon\" aria-hidden=\"true\">${this.icon}</span>`\n : nothing}\n ${iconOnly ? nothing : html`<span>${this.label}</span>`}\n ${iconOnly\n ? nothing\n : html`<span class=\"chevron\" aria-hidden=\"true\">${iconChevronRight(14)}</span>`}\n </button>\n ${this.renderMenu()}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dropdown-button\": DropdownButton;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dropdown-button.js","sourceRoot":"","sources":["../src/dropdown-button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,IAAI,aAAa,GAAG,CAAC,CAAC;AAatB;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAqKL,2GAA2G;QAC/F,UAAK,GAAG,EAAE,CAAC;QACvB,0BAA0B;QACM,YAAO,GAAqB,EAAE,CAAC;QAC/D,8DAA8D;QACjC,aAAQ,GAAG,KAAK,CAAC;QAC9C,oEAAoE;QACvC,YAAO,GAA0B,MAAM,CAAC;QACrE,qEAAqE;QACrC,SAAI,GAA0B,IAAI,CAAC;QACnE,6FAA6F;QACh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AC,OAAO;YACT,CAAC,CAAC,IAAI,CAAA,4CAA4C,gBAAgB,CAAC,EAAE,CAAC,SAAS;;QAEjF,IAAI,CAAC,UAAU,EAAE;KACpB,CAAC;IACJ,CAAC;CACF,CAAA;AAzIa;IAAX,QAAQ,EAAE;6CAAY;AAES;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+CAAgC;AAElC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CAAyC;AAErC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAAoC;AAEtC;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAA0B;AAErC;IAAhB,KAAK,EAAE;6CAAuB;AACd;IAAhB,KAAK,EAAE;oDAA2B;AAnLxB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CA+S1B","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues, type TemplateResult } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronRight } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nlet instanceCount = 0;\n\n/** A single menu action. */\nexport interface DropdownOption {\n value: string;\n label: string;\n /** Renders the item in the danger color, for a destructive action (e.g. Delete). */\n danger?: boolean;\n}\n\n/** How the trigger presents itself: label only, icon only, or icon + label. */\nexport type DropdownButtonVariant = \"text\" | \"icon\" | \"text-icon\";\n\n/**\n * A button that opens an anchored menu of actions — essentially `form-select`\n * minus \"current value\" semantics: a menu, not a select. Use for a set of\n * mutually exclusive next-step actions (e.g. a failed task's Retry / Close /\n * Backlog, or a table row's overflow actions).\n *\n * Three trigger presentations share one base: `text` (the default — a\n * primary-filled button with a label and a rotating chevron), `text-icon`\n * (the same, with `icon` ahead of the label), and `icon` (a borderless,\n * square, low-emphasis icon target in the style of `icon-button` — the\n * classic \"three-dot\"/overflow menu, where `label` becomes the accessible\n * name rather than visible text). Set `size=\"sm\"` for a compact trigger one\n * step below the default, matching `ui-button`'s `sm` size.\n *\n * @element dropdown-button\n * @fires select - Fired with `{ value: string }` when a menu item is picked.\n */\n@customElement(\"dropdown-button\")\nexport class DropdownButton extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\n position: relative;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n /* Shared trigger base — layout, type, shape, and interaction states every\n variant has in common. Variant blocks below only add fill/padding. */\n button.trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0.25rem;\n height: 2rem;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n border: 1px solid transparent;\n border-radius: var(--ui-radius-sm, 0.25rem);\n cursor: pointer;\n }\n button.trigger:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n button.trigger:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n /* text + text-icon: the primary-filled trigger. Written as :not([variant=\"icon\"])\n rather than two positive selectors so the default presentation is correct\n even before the reflected attribute lands. */\n :host(:not([variant=\"icon\"])) button.trigger {\n color: var(--ui-on-accent, #ffffff);\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border-color: var(--ui-button-border, transparent);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n text-shadow: var(--ui-button-text-shadow, none);\n padding: 0.5rem 1rem;\n }\n :host(:not([variant=\"icon\"])) button.trigger:hover:not(:disabled) {\n background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));\n }\n :host(:not([variant=\"icon\"])) button.trigger:active:not(:disabled) {\n background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));\n box-shadow: none;\n }\n :host(:not([variant=\"icon\"])) button.trigger: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 /* icon: borderless low-emphasis square target, matching icon-button. */\n :host([variant=\"icon\"]) button.trigger {\n width: 2rem;\n padding: 0;\n color: var(--ui-text-muted, #64748b);\n background: none;\n }\n :host([variant=\"icon\"]) button.trigger:hover:not(:disabled) {\n background: var(--ui-surface-muted, #f8fafc);\n color: var(--ui-text, #0f172a);\n }\n :host([size=\"sm\"]) button.trigger {\n height: 1.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n :host(:not([variant=\"icon\"])[size=\"sm\"]) button.trigger {\n padding: 0.25rem 0.5rem;\n }\n :host([variant=\"icon\"][size=\"sm\"]) button.trigger {\n width: 1.5rem;\n }\n .icon {\n display: flex;\n line-height: 0;\n }\n .chevron {\n display: flex;\n transform: rotate(90deg);\n transition: transform 150ms ease;\n }\n :host([open]) .chevron {\n transform: rotate(-90deg);\n }\n ul.options {\n position: absolute;\n top: 100%;\n right: 0;\n z-index: 10;\n min-width: 100%;\n max-height: 40vh;\n overflow-y: auto;\n margin: 0.25rem 0 0;\n padding: 0.25rem 0;\n list-style: none;\n white-space: nowrap;\n background: var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n li {\n padding: 0.5rem 0.75rem;\n cursor: pointer;\n color: var(--ui-text, #0f172a);\n }\n li.danger {\n color: var(--ui-danger, #dc2626);\n }\n li.active,\n li:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n li.danger.active,\n li.danger:hover {\n color: var(--ui-danger-hover, #b91c1c);\n }\n @media (prefers-reduced-motion: reduce) {\n .chevron {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n button.trigger:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n button.trigger:disabled {\n color: GrayText;\n opacity: 1;\n }\n li.active,\n li:hover,\n li.danger.active,\n li.danger:hover {\n color: HighlightText;\n background: Highlight;\n }\n }\n `,\n ];\n\n /** The trigger button's label. In the `icon` variant it is the accessible name instead of visible text. */\n @property() label = \"\";\n /** The menu's actions. */\n @property({ attribute: false }) options: DropdownOption[] = [];\n /** Disables the trigger, preventing the menu from opening. */\n @property({ type: Boolean }) disabled = false;\n /** Trigger presentation: label only, icon only, or icon + label. */\n @property({ reflect: true }) variant: DropdownButtonVariant = \"text\";\n /** Icon template rendered by the `icon` and `text-icon` variants. */\n @property({ attribute: false }) icon: TemplateResult | null = null;\n /** Size — `sm` reduces the trigger's height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n @state() private _open = false;\n @state() private _activeIndex = -1;\n readonly #menuId = `dropdown-button-menu-${++instanceCount}`;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener(\"mousedown\", this.#onWindowMousedown, true);\n this._open = false;\n this._activeIndex = -1;\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"disabled\") && this.disabled) {\n this._open = false;\n this._activeIndex = -1;\n }\n if (!changed.has(\"_open\")) return;\n this.toggleAttribute(\"open\", this._open);\n if (this._open) {\n window.addEventListener(\"mousedown\", this.#onWindowMousedown, true);\n } else {\n window.removeEventListener(\"mousedown\", this.#onWindowMousedown, true);\n }\n }\n\n #onWindowMousedown = (e: MouseEvent): void => {\n if (!e.composedPath().includes(this)) this._open = false;\n };\n\n #toggle(): void {\n if (this.disabled) return;\n this._open = !this._open;\n if (this._open) this._activeIndex = 0;\n }\n\n #select(option: DropdownOption): void {\n if (this.disabled) return;\n this._open = false;\n this.dispatchEvent(new CustomEvent(\"select\", { detail: { value: option.value } }));\n }\n\n #onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\" || e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n if (!this._open) {\n this.#toggle();\n return;\n }\n if (e.key === \"ArrowDown\") this.#moveActive(1);\n else if (e.key === \"ArrowUp\") this.#moveActive(-1);\n else this.#confirmActive();\n } else if (e.key === \"Escape\" && this._open) {\n e.preventDefault();\n this._open = false;\n }\n }\n\n #moveActive(delta: number): void {\n if (this.options.length === 0) return;\n const n = this.options.length;\n this._activeIndex = (this._activeIndex + delta + n) % n;\n }\n\n #confirmActive(): void {\n const option = this.options[this._activeIndex];\n if (option) this.#select(option);\n }\n\n private renderMenu() {\n if (!this._open) return nothing;\n return html`\n <ul id=${this.#menuId} class=\"options\" role=\"menu\" aria-label=${this.label}>\n ${this.options.map(\n (o, i) => html`\n <li\n id=${`${this.#menuId}-item-${i}`}\n role=\"menuitem\"\n class=${[i === this._activeIndex ? \"active\" : \"\", o.danger ? \"danger\" : \"\"]\n .filter(Boolean)\n .join(\" \")}\n @mousedown=${(e: MouseEvent) => {\n if (e.button !== 0) return;\n e.preventDefault();\n this.#select(o);\n }}\n >\n ${o.label}\n </li>\n `,\n )}\n </ul>\n `;\n }\n\n override render() {\n const activeDescendant =\n this._open && this._activeIndex >= 0\n ? `${this.#menuId}-item-${this._activeIndex}`\n : nothing;\n const iconOnly = this.variant === \"icon\";\n return html`\n <button\n type=\"button\"\n class=\"trigger\"\n aria-haspopup=\"menu\"\n aria-expanded=${this._open}\n aria-controls=${this.#menuId}\n aria-activedescendant=${activeDescendant}\n aria-label=${iconOnly && this.label ? this.label : nothing}\n title=${iconOnly && this.label ? this.label : nothing}\n ?disabled=${this.disabled}\n @click=${() => this.#toggle()}\n @keydown=${(e: KeyboardEvent) => this.#onTriggerKeydown(e)}\n >\n ${this.variant !== \"text\" && this.icon\n ? html`<span class=\"icon\" aria-hidden=\"true\">${this.icon}</span>`\n : nothing}\n ${iconOnly ? nothing : html`<span>${this.label}</span>`}\n ${iconOnly\n ? nothing\n : html`<span class=\"chevron\" aria-hidden=\"true\">${iconChevronRight(14)}</span>`}\n </button>\n ${this.renderMenu()}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dropdown-button\": DropdownButton;\n }\n}\n"]}
|
package/dist/icons.d.ts
CHANGED
|
@@ -106,4 +106,14 @@ export declare const iconUsers: (size?: number) => import("lit-html").TemplateRe
|
|
|
106
106
|
export declare const iconArrowRightOnRectangle: (size?: number) => import("lit-html").TemplateResult<2>;
|
|
107
107
|
/** Tools, maintenance, or build/configuration actions. */
|
|
108
108
|
export declare const iconWrenchScrewdriver: (size?: number) => import("lit-html").TemplateResult<2>;
|
|
109
|
+
/** "Play" transport actions, e.g. audio-player/video-player's paused state. */
|
|
110
|
+
export declare const iconPlay: (size?: number) => import("lit-html").TemplateResult<2>;
|
|
111
|
+
/** "Pause" transport actions, e.g. audio-player/video-player's playing state. */
|
|
112
|
+
export declare const iconPause: (size?: number) => import("lit-html").TemplateResult<2>;
|
|
113
|
+
/** An unmuted volume control, e.g. audio-player/video-player's mute toggle. */
|
|
114
|
+
export declare const iconSpeakerWave: (size?: number) => import("lit-html").TemplateResult<2>;
|
|
115
|
+
/** A muted volume state; pair with iconSpeakerWave for the unmuted state. */
|
|
116
|
+
export declare const iconSpeakerXMark: (size?: number) => import("lit-html").TemplateResult<2>;
|
|
117
|
+
/** "Exit fullscreen" actions; pair with iconArrowsPointingOut for entering fullscreen. */
|
|
118
|
+
export declare const iconArrowsPointingIn: (size?: number) => import("lit-html").TemplateResult<2>;
|
|
109
119
|
//#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0DAA0D;AAC1D,eAAO,MAAM,qBAAqB,yDACgtB,CAAC;AAEnvB,+EAA+E;AAC/E,eAAO,MAAM,QAAQ,yDACkV,CAAC;AAExW,iFAAiF;AACjF,eAAO,MAAM,SAAS,yDACkP,CAAC;AAEzQ,+EAA+E;AAC/E,eAAO,MAAM,eAAe,yDAC8d,CAAC;AAE3f,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,yDAC4d,CAAC;AAE1f,0FAA0F;AAC1F,eAAO,MAAM,oBAAoB,yDAC6U,CAAC"}
|
package/dist/icons.js
CHANGED
|
@@ -109,4 +109,14 @@ export const iconUsers = (size = 18) => svg `<svg xmlns="http://www.w3.org/2000/
|
|
|
109
109
|
export const iconArrowRightOnRectangle = (size = 16) => svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke="currentColor" width=${size} height=${size} aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 9V5.25A2.25 2.25 0 0 0 13.5 3h-6a2.25 2.25 0 0 0-2.25 2.25v13.5A2.25 2.25 0 0 0 7.5 21h6a2.25 2.25 0 0 0 2.25-2.25V15m3 0 3-3m0 0-3-3m3 3H9"/></svg>`;
|
|
110
110
|
/** Tools, maintenance, or build/configuration actions. */
|
|
111
111
|
export const iconWrenchScrewdriver = (size = 18) => svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke="currentColor" width=${size} height=${size} aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M11.42 15.17 17.25 21A2.652 2.652 0 0 0 21 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 1 1-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 0 0 4.486-6.336l-3.276 3.277a3.004 3.004 0 0 1-2.25-2.25l3.276-3.276a4.5 4.5 0 0 0-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437 1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008Z"/></svg>`;
|
|
112
|
+
/** "Play" transport actions, e.g. audio-player/video-player's paused state. */
|
|
113
|
+
export const iconPlay = (size = 18) => svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke="currentColor" width=${size} height=${size} aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z"/></svg>`;
|
|
114
|
+
/** "Pause" transport actions, e.g. audio-player/video-player's playing state. */
|
|
115
|
+
export const iconPause = (size = 18) => svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke="currentColor" width=${size} height=${size} aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25v13.5m-7.5-13.5v13.5"/></svg>`;
|
|
116
|
+
/** An unmuted volume control, e.g. audio-player/video-player's mute toggle. */
|
|
117
|
+
export const iconSpeakerWave = (size = 18) => svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke="currentColor" width=${size} height=${size} aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M19.114 5.636a9 9 0 0 1 0 12.728M16.463 8.288a5.25 5.25 0 0 1 0 7.424M6.75 8.25l4.72-4.72a.75.75 0 0 1 1.28.53v15.88a.75.75 0 0 1-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.009 9.009 0 0 1 2.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75Z"/></svg>`;
|
|
118
|
+
/** A muted volume state; pair with iconSpeakerWave for the unmuted state. */
|
|
119
|
+
export const iconSpeakerXMark = (size = 18) => svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke="currentColor" width=${size} height=${size} aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M17.25 9.75 19.5 12m0 0 2.25 2.25M19.5 12l2.25-2.25M19.5 12l-2.25 2.25m-10.5-6 4.72-4.72a.75.75 0 0 1 1.28.53v15.88a.75.75 0 0 1-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.009 9.009 0 0 1 2.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75Z"/></svg>`;
|
|
120
|
+
/** "Exit fullscreen" actions; pair with iconArrowsPointingOut for entering fullscreen. */
|
|
121
|
+
export const iconArrowsPointingIn = (size = 16) => svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.5" stroke="currentColor" width=${size} height=${size} aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M9 9V4.5M9 9H4.5M9 9 3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5 5.25 5.25"/></svg>`;
|
|
112
122
|
//# sourceMappingURL=icons.js.map
|