@f-ewald/components 1.40.1 → 1.40.2
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 +6 -0
- package/dist/button-group.d.ts.map +1 -1
- package/dist/button-group.js +9 -2
- package/dist/button-group.js.map +1 -1
- package/dist/confirm-dialog.d.ts.map +1 -1
- package/dist/confirm-dialog.js +11 -3
- package/dist/confirm-dialog.js.map +1 -1
- package/dist/pagination-nav.d.ts.map +1 -1
- package/dist/pagination-nav.js +9 -2
- package/dist/pagination-nav.js.map +1 -1
- package/dist/radio-cards.d.ts.map +1 -1
- package/dist/radio-cards.js +9 -2
- package/dist/radio-cards.js.map +1 -1
- package/dist/ui-button.d.ts.map +1 -1
- package/dist/ui-button.js +15 -3
- package/dist/ui-button.js.map +1 -1
- package/docs/button-group.md +1 -0
- package/docs/design-language.md +21 -0
- package/docs/pagination-nav.md +1 -0
- package/docs/ui-button.md +1 -0
- package/llms.txt +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -311,6 +311,12 @@ Opens a live playground (`index.html`) with a rendered, hand-testable example
|
|
|
311
311
|
of every component, plus a copy-paste usage snippet for each. Component
|
|
312
312
|
sources are imported directly from `src/`, so edits hot-reload.
|
|
313
313
|
|
|
314
|
+
The theme picker writes the chosen theme to the URL as a `?theme=` parameter,
|
|
315
|
+
so the address bar is always shareable — for example
|
|
316
|
+
[`?theme=blueprint#button-group`](https://f-ewald.github.io/components/playground/?theme=blueprint#button-group)
|
|
317
|
+
opens `button-group` under the blueprint theme. A theme in the link takes
|
|
318
|
+
precedence over the reader's own remembered choice.
|
|
319
|
+
|
|
314
320
|
```bash
|
|
315
321
|
npm run build:demo # static build of the playground, into demo-dist/
|
|
316
322
|
npm run build:site # docs + playground Pages artifact, into pages-dist/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-group.d.ts","sourceRoot":"","sources":["../src/button-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAKrD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAID;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,WAAY,SAAQ,UAAU;;IACzC,OAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"button-group.d.ts","sourceRoot":"","sources":["../src/button-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAKrD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAID;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,WAAY,SAAQ,UAAU;;IACzC,OAAgB,MAAM,4BAqIpB;IAEF,2CAA2C;IACX,OAAO,EAAE,iBAAiB,EAAE,CAAM;IAClE,gCAAgC;IACpB,KAAK,SAAM;IACvB,gDAAgD;IACnB,QAAQ,UAAS;IAC9C,oFAAoF;IAChB,QAAQ,UAAS;IACrF,uFAAuF;IAC1D,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAItD,OAAO,CAAC,SAAS;IAQR,MAAM,sBAwBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,WAAW,CAAC;KAC7B;CACF"}
|
package/dist/button-group.js
CHANGED
|
@@ -84,7 +84,12 @@ let ButtonGroup = class ButtonGroup extends LitElement {
|
|
|
84
84
|
line-height: var(--ui-line-height-tight, 1.25);
|
|
85
85
|
color: var(--ui-text, #0f172a);
|
|
86
86
|
white-space: nowrap;
|
|
87
|
-
|
|
87
|
+
/* Opaque base under the transparent-by-default secondary token, so an
|
|
88
|
+
unchecked segment reads as a solid control rather than letting a
|
|
89
|
+
textured or tinted page show through. See ui-button's secondary. */
|
|
90
|
+
background:
|
|
91
|
+
var(--ui-button-secondary-background, none),
|
|
92
|
+
var(--ui-surface, #ffffff);
|
|
88
93
|
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
89
94
|
}
|
|
90
95
|
.segment:first-child {
|
|
@@ -105,7 +110,9 @@ let ButtonGroup = class ButtonGroup extends LitElement {
|
|
|
105
110
|
background: var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));
|
|
106
111
|
}
|
|
107
112
|
.segment:not(:has(input:checked)):active {
|
|
108
|
-
background:
|
|
113
|
+
background:
|
|
114
|
+
var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),
|
|
115
|
+
var(--ui-surface, #ffffff);
|
|
109
116
|
box-shadow: none;
|
|
110
117
|
}
|
|
111
118
|
.segment input {
|
package/dist/button-group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-group.js","sourceRoot":"","sources":["../src/button-group.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAiIL,2CAA2C;QACX,YAAO,GAAwB,EAAE,CAAC;QAClE,gCAAgC;Q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,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;;gBAEzC,GAAG,CAAC,IAAI,IAAI,OAAO;4BACP,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,KAAK;;WAE5D,CACF;;KAEJ,CAAC;IACJ,CAAC;CACF,CAAA;AA7CiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAAmC;AAEtD;IAAX,QAAQ,EAAE;0CAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAkB;AAEsB;IAAnE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;6CAAkB;AAExD;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAA0B;AA1I3C,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA+KvB","sourcesContent":["import type { TemplateResult } from \"lit\";\nimport { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport interface ButtonGroupOption {\n value: string;\n label: string;\n /** Optional pre-rendered icon template displayed before the label. */\n icon?: TemplateResult;\n}\n\nlet instanceCount = 0;\n\n/**\n * Single-select segmented control — a strip of buttons joined into one\n * shared-border shape, for a small, persistent set of mutually exclusive\n * choices (a view switcher, a theme picker) where the *currently selected*\n * option should read as visually \"pressed,\" not just checked. For many\n * short, individually pill-shaped choices, use `radio-pills` instead. Wraps\n * native radio inputs for keyboard/a11y and fires `change` rather than\n * relying on form submission. Set `size=\"sm\"` for a compact strip one step\n * below the default, matching `ui-button`'s `sm` size.\n *\n * The checked segment reads `--ui-button-background`/`-hover`/`-active`,\n * same as `ui-button`'s `primary` variant. Unchecked segments are treated as\n * `ui-button`'s `secondary` variant: they read the shared\n * `--ui-button-secondary-background`/`-active` (rest/pressed) so a gradient\n * theme applies consistently, but use the shared `--ui-button-secondary-surface-muted`\n * (also used by `pagination-nav`) for hover, since — unlike `secondary` — an\n * unchecked segment already paints `--ui-surface-muted` on hover by default.\n *\n * @element button-group\n * @fires change - A segment was selected; detail: { value }.\n */\n@customElement(\"button-group\")\nexport class ButtonGroup extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\n }\n .group {\n display: flex;\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n overflow: hidden;\n }\n .segment {\n position: relative;\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n justify-content: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0.5rem 0.75rem;\n border-left: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n cursor: pointer;\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 color: var(--ui-text, #0f172a);\n white-space: nowrap;\n background: var(--ui-button-secondary-background, none);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .segment:first-child {\n border-left: none;\n border-top-left-radius: var(--ui-radius-sm, 0.25rem);\n border-bottom-left-radius: var(--ui-radius-sm, 0.25rem);\n }\n .segment:last-child {\n border-top-right-radius: var(--ui-radius-sm, 0.25rem);\n border-bottom-right-radius: var(--ui-radius-sm, 0.25rem);\n }\n .segment:has(input:checked) {\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n color: var(--ui-on-accent, #ffffff);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .segment:not(:has(input:checked)):hover {\n background: var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));\n }\n .segment:not(:has(input:checked)):active {\n background: var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none));\n box-shadow: none;\n }\n .segment input {\n /* Fills the whole segment (not visually-hidden-offscreen) so a real\n click anywhere in the segment — including a test driver clicking\n the input by its accessible role — lands on the input itself,\n not just via native <label> click delegation. */\n position: absolute;\n inset: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n /* Clipped by the group's own overflow:hidden unless promoted above its\n neighbors — the focus ring needs a stacking context of its own. */\n .segment:has(input:focus-visible) {\n z-index: 1;\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .segment:has(input: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 .segment:has(input:disabled) {\n cursor: not-allowed;\n opacity: 0.6;\n }\n :host([icon-only]) .segment {\n padding: 0.5rem;\n }\n :host([size=\"sm\"]) .segment {\n height: 1.5rem;\n padding: 0.25rem 0.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n :host([icon-only][size=\"sm\"]) .segment {\n padding: 0.25rem;\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n @media (forced-colors: active) {\n .segment:has(input:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .segment:has(input:checked) {\n background: Highlight;\n color: HighlightText;\n }\n .segment:has(input:disabled) {\n color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n /** Options to render, one segment each. */\n @property({ attribute: false }) options: ButtonGroupOption[] = [];\n /** Currently selected value. */\n @property() value = \"\";\n /** Disables every native radio in the group. */\n @property({ type: Boolean }) disabled = false;\n /** Hides labels visually (icons only) while keeping them as the accessible name. */\n @property({ type: Boolean, reflect: true, attribute: \"icon-only\" }) iconOnly = false;\n /** Size — `sm` reduces segment height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n readonly #name = `button-group-${++instanceCount}`;\n\n private _onChange(value: string) {\n if (this.disabled) return;\n this.value = value;\n this.dispatchEvent(\n new CustomEvent(\"change\", { detail: { value }, bubbles: true, composed: true }),\n );\n }\n\n override render() {\n return html`\n <div class=\"group\">\n ${repeat(\n this.options,\n (opt) => opt.value,\n (opt) => html`\n <label class=\"segment\">\n <input\n type=\"radio\"\n name=${this.#name}\n ?checked=${this.value === opt.value}\n ?disabled=${this.disabled}\n aria-label=${this.iconOnly ? opt.label : nothing}\n title=${this.iconOnly ? opt.label : nothing}\n @change=${() => this._onChange(opt.value)}\n />\n ${opt.icon ?? nothing}\n <span class=${this.iconOnly ? \"sr-only\" : \"\"}>${opt.label}</span>\n </label>\n `,\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"button-group\": ButtonGroup;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"button-group.js","sourceRoot":"","sources":["../src/button-group.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAwIL,2CAA2C;QACX,YAA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,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;0BACjC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;;gBAEzC,GAAG,CAAC,IAAI,IAAI,OAAO;4BACP,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,KAAK;;WAE5D,CACF;;KAEJ,CAAC;IACJ,CAAC;CACF,CAAA;AA7CiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAAmC;AAEtD;IAAX,QAAQ,EAAE;0CAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAkB;AAEsB;IAAnE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;6CAAkB;AAExD;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAA0B;AAjJ3C,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAsLvB","sourcesContent":["import type { TemplateResult } from \"lit\";\nimport { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport interface ButtonGroupOption {\n value: string;\n label: string;\n /** Optional pre-rendered icon template displayed before the label. */\n icon?: TemplateResult;\n}\n\nlet instanceCount = 0;\n\n/**\n * Single-select segmented control — a strip of buttons joined into one\n * shared-border shape, for a small, persistent set of mutually exclusive\n * choices (a view switcher, a theme picker) where the *currently selected*\n * option should read as visually \"pressed,\" not just checked. For many\n * short, individually pill-shaped choices, use `radio-pills` instead. Wraps\n * native radio inputs for keyboard/a11y and fires `change` rather than\n * relying on form submission. Set `size=\"sm\"` for a compact strip one step\n * below the default, matching `ui-button`'s `sm` size.\n *\n * The checked segment reads `--ui-button-background`/`-hover`/`-active`,\n * same as `ui-button`'s `primary` variant. Unchecked segments are treated as\n * `ui-button`'s `secondary` variant: they read the shared\n * `--ui-button-secondary-background`/`-active` (rest/pressed) so a gradient\n * theme applies consistently, but use the shared `--ui-button-secondary-surface-muted`\n * (also used by `pagination-nav`) for hover, since — unlike `secondary` — an\n * unchecked segment already paints `--ui-surface-muted` on hover by default.\n *\n * @element button-group\n * @fires change - A segment was selected; detail: { value }.\n */\n@customElement(\"button-group\")\nexport class ButtonGroup extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\n }\n .group {\n display: flex;\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n overflow: hidden;\n }\n .segment {\n position: relative;\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n justify-content: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0.5rem 0.75rem;\n border-left: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n cursor: pointer;\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 color: var(--ui-text, #0f172a);\n white-space: nowrap;\n /* Opaque base under the transparent-by-default secondary token, so an\n unchecked segment reads as a solid control rather than letting a\n textured or tinted page show through. See ui-button's secondary. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .segment:first-child {\n border-left: none;\n border-top-left-radius: var(--ui-radius-sm, 0.25rem);\n border-bottom-left-radius: var(--ui-radius-sm, 0.25rem);\n }\n .segment:last-child {\n border-top-right-radius: var(--ui-radius-sm, 0.25rem);\n border-bottom-right-radius: var(--ui-radius-sm, 0.25rem);\n }\n .segment:has(input:checked) {\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n color: var(--ui-on-accent, #ffffff);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .segment:not(:has(input:checked)):hover {\n background: var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));\n }\n .segment:not(:has(input:checked)):active {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface, #ffffff);\n box-shadow: none;\n }\n .segment input {\n /* Fills the whole segment (not visually-hidden-offscreen) so a real\n click anywhere in the segment — including a test driver clicking\n the input by its accessible role — lands on the input itself,\n not just via native <label> click delegation. */\n position: absolute;\n inset: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n /* Clipped by the group's own overflow:hidden unless promoted above its\n neighbors — the focus ring needs a stacking context of its own. */\n .segment:has(input:focus-visible) {\n z-index: 1;\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .segment:has(input: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 .segment:has(input:disabled) {\n cursor: not-allowed;\n opacity: 0.6;\n }\n :host([icon-only]) .segment {\n padding: 0.5rem;\n }\n :host([size=\"sm\"]) .segment {\n height: 1.5rem;\n padding: 0.25rem 0.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n :host([icon-only][size=\"sm\"]) .segment {\n padding: 0.25rem;\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n @media (forced-colors: active) {\n .segment:has(input:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .segment:has(input:checked) {\n background: Highlight;\n color: HighlightText;\n }\n .segment:has(input:disabled) {\n color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n /** Options to render, one segment each. */\n @property({ attribute: false }) options: ButtonGroupOption[] = [];\n /** Currently selected value. */\n @property() value = \"\";\n /** Disables every native radio in the group. */\n @property({ type: Boolean }) disabled = false;\n /** Hides labels visually (icons only) while keeping them as the accessible name. */\n @property({ type: Boolean, reflect: true, attribute: \"icon-only\" }) iconOnly = false;\n /** Size — `sm` reduces segment height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n readonly #name = `button-group-${++instanceCount}`;\n\n private _onChange(value: string) {\n if (this.disabled) return;\n this.value = value;\n this.dispatchEvent(\n new CustomEvent(\"change\", { detail: { value }, bubbles: true, composed: true }),\n );\n }\n\n override render() {\n return html`\n <div class=\"group\">\n ${repeat(\n this.options,\n (opt) => opt.value,\n (opt) => html`\n <label class=\"segment\">\n <input\n type=\"radio\"\n name=${this.#name}\n ?checked=${this.value === opt.value}\n ?disabled=${this.disabled}\n aria-label=${this.iconOnly ? opt.label : nothing}\n title=${this.iconOnly ? opt.label : nothing}\n @change=${() => this._onChange(opt.value)}\n />\n ${opt.icon ?? nothing}\n <span class=${this.iconOnly ? \"sr-only\" : \"\"}>${opt.label}</span>\n </label>\n `,\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"button-group\": ButtonGroup;\n }\n}\n"]}
|
|
@@ -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;;;;;;;;;;;GAWG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,OAAgB,MAAM,
|
|
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,4BAkMpB;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
|
@@ -141,7 +141,11 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
141
141
|
line-height: var(--ui-line-height-tight, 1.25);
|
|
142
142
|
}
|
|
143
143
|
.btn-cancel {
|
|
144
|
-
|
|
144
|
+
/* Opaque base under the transparent-by-default secondary token, the
|
|
145
|
+
same as ui-button's secondary variant — see the comment there. */
|
|
146
|
+
background:
|
|
147
|
+
var(--ui-button-secondary-background, none),
|
|
148
|
+
var(--ui-surface, #ffffff);
|
|
145
149
|
border: var(--ui-border-width, 1px) solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));
|
|
146
150
|
color: var(--ui-text, #0f172a);
|
|
147
151
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
@@ -151,11 +155,15 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
151
155
|
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
152
156
|
}
|
|
153
157
|
.btn-cancel:hover:not(:disabled) {
|
|
154
|
-
background:
|
|
158
|
+
background:
|
|
159
|
+
var(--ui-button-secondary-background-hover, none),
|
|
160
|
+
var(--ui-surface, #ffffff);
|
|
155
161
|
border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));
|
|
156
162
|
}
|
|
157
163
|
.btn-cancel:active:not(:disabled) {
|
|
158
|
-
background:
|
|
164
|
+
background:
|
|
165
|
+
var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),
|
|
166
|
+
var(--ui-surface, #ffffff);
|
|
159
167
|
box-shadow: none;
|
|
160
168
|
}
|
|
161
169
|
.btn-danger,
|
|
@@ -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,GACX,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;GAWG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QA6LL,qCAAqC;QACR,SAAI,GAAG,KA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AAC,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;AA/H8B;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;AAEX;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAA0B;AA1M3C,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CA6TzB","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: var(--ui-border-width, 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: var(--ui-border-width, 1px) solid transparent;\n border-radius: var(--ui-radius-sm, 0.25rem);\n /* The border width is themeable, so it has to stay inside the fixed\n height the sm size sets below. */\n box-sizing: border-box;\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}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AEd;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;AAlN3C,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAqUzB","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 /* Opaque base under the transparent-by-default secondary token, the\n same as ui-button's secondary variant — see the comment there. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\n border: var(--ui-border-width, 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:\n var(--ui-button-secondary-background-hover, none),\n var(--ui-surface, #ffffff);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n .btn-cancel:active:not(:disabled) {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface, #ffffff);\n box-shadow: none;\n }\n .btn-danger,\n .btn-primary {\n border: var(--ui-border-width, 1px) solid transparent;\n border-radius: var(--ui-radius-sm, 0.25rem);\n /* The border width is themeable, so it has to stay inside the fixed\n height the sm size sets below. */\n box-sizing: border-box;\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination-nav.d.ts","sourceRoot":"","sources":["../src/pagination-nav.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAK5C,+FAA+F;AAC/F,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,gCAAgC;IACuB,WAAW,SAAK;IACvE,6CAA6C;IACS,UAAU,SAAK;IAErE,OAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"pagination-nav.d.ts","sourceRoot":"","sources":["../src/pagination-nav.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAK5C,+FAA+F;AAC/F,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,gCAAgC;IACuB,WAAW,SAAK;IACvE,6CAA6C;IACS,UAAU,SAAK;IAErE,OAAgB,MAAM,4BAoFpB;IAEF,uFAAuF;IACvF,OAAO,CAAC,GAAG;IAaF,MAAM,yCAsBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
|
package/dist/pagination-nav.js
CHANGED
|
@@ -62,7 +62,12 @@ let PaginationNav = class PaginationNav extends LitElement {
|
|
|
62
62
|
width: 2rem;
|
|
63
63
|
height: 2rem;
|
|
64
64
|
padding: 0;
|
|
65
|
-
|
|
65
|
+
/* Opaque base under the transparent-by-default secondary token — a
|
|
66
|
+
pager button is a solid control, not a window onto the page behind
|
|
67
|
+
it. See ui-button's secondary variant. */
|
|
68
|
+
background:
|
|
69
|
+
var(--ui-button-secondary-background, none),
|
|
70
|
+
var(--ui-surface, #ffffff);
|
|
66
71
|
border: var(--ui-border-width, 1px) solid
|
|
67
72
|
var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));
|
|
68
73
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
@@ -77,7 +82,9 @@ let PaginationNav = class PaginationNav extends LitElement {
|
|
|
77
82
|
border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));
|
|
78
83
|
}
|
|
79
84
|
button:active:not(:disabled) {
|
|
80
|
-
background:
|
|
85
|
+
background:
|
|
86
|
+
var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),
|
|
87
|
+
var(--ui-surface, #ffffff);
|
|
81
88
|
box-shadow: none;
|
|
82
89
|
}
|
|
83
90
|
button:disabled {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination-nav.js","sourceRoot":"","sources":["../src/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EAAE,CAAC;kDAAiB;AAEjB;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;iDAAgB;AAJ1D,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAiIzB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconChevronLeft, iconChevronRight } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** Fired when the user requests a different page. `detail.page` is the 1-based target page. */\nexport interface PageChangeDetail {\n page: number;\n}\n\n/**\n * Minimal, controlled pager for list/table views: a previous/next control pair\n * around a \"Page N of M\" status. It owns no data — the consumer sets\n * `current-page` / `total-pages` and moves the page in response to the\n * `page-change` event (typically alongside its own data fetch), exactly like\n * `data-table` leaves the row data to the caller.\n *\n * Previous is disabled on the first page and next on the last; neither fires an\n * event when there is nowhere to go.\n *\n * The prev/next buttons are treated as `ui-button`'s `secondary` variant:\n * they read the same shared `--ui-button-secondary-*`/`--ui-button-highlight`\n * tokens (and `--ui-button-secondary-surface-muted` for hover, since — like\n * `button-group`'s unchecked segments — they already paint\n * `--ui-surface-muted` on hover by default), so a gradient theme applies\n * consistently here too.\n *\n * @element pagination-nav\n * @fires page-change - The user picked a new page (`detail: { page }`).\n */\n@customElement(\"pagination-nav\")\nexport class PaginationNav extends LitElement {\n /** The 1-based current page. */\n @property({ type: Number, attribute: \"current-page\" }) currentPage = 1;\n /** The total number of pages (minimum 1). */\n @property({ type: Number, attribute: \"total-pages\" }) totalPages = 1;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\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 }\n button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n /* Opaque base under the transparent-by-default secondary token — a\n pager button is a solid control, not a window onto the page behind\n it. See ui-button's secondary variant. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\n border: var(--ui-border-width, 1px) solid\n var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n border-radius: var(--ui-radius-sm, 0.25rem);\n /* The border is themeable, so it has to stay inside the 2rem target. */\n box-sizing: border-box;\n color: var(--ui-text, #0f172a);\n cursor: pointer;\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n button:hover:not(:disabled) {\n background: var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n button:active:not(:disabled) {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface, #ffffff);\n box-shadow: none;\n }\n button:disabled {\n opacity: 0.5;\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 button: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 .status {\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 color: var(--ui-text-muted, #64748b);\n font-variant-numeric: var(--ui-numeric, normal);\n min-width: 6rem;\n text-align: center;\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 button:disabled {\n color: GrayText;\n border-color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n /** Clamps `page` to the valid range and fires `page-change` when it actually moves. */\n private _go(page: number): void {\n const total = Math.max(1, Math.floor(this.totalPages));\n const target = Math.min(total, Math.max(1, Math.floor(page)));\n if (target === this.currentPage) return;\n this.dispatchEvent(\n new CustomEvent<PageChangeDetail>(\"page-change\", {\n detail: { page: target },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n override render() {\n const total = Math.max(1, Math.floor(this.totalPages));\n const current = Math.min(total, Math.max(1, Math.floor(this.currentPage)));\n return html`\n <button\n type=\"button\"\n aria-label=\"Previous page\"\n ?disabled=${current <= 1}\n @click=${() => this._go(current - 1)}\n >\n ${iconChevronLeft(18)}\n </button>\n <span class=\"status\" aria-live=\"polite\">Page ${current} of ${total}</span>\n <button\n type=\"button\"\n aria-label=\"Next page\"\n ?disabled=${current >= total}\n @click=${() => this._go(current + 1)}\n >\n ${iconChevronRight(18)}\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pagination-nav\": PaginationNav;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-cards.d.ts","sourceRoot":"","sources":["../src/radio-cards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAMrD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,UAAW,SAAQ,UAAU;;IACxC,OAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"radio-cards.d.ts","sourceRoot":"","sources":["../src/radio-cards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAMrD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,UAAW,SAAQ,UAAU;;IACxC,OAAgB,MAAM,4BAmJpB;IAEF,wCAAwC;IACR,OAAO,EAAE,eAAe,EAAE,CAAM;IAChE,gCAAgC;IACpB,KAAK,SAAM;IACvB,gDAAgD;IACnB,QAAQ,UAAS;IAC9C;;;;;;OAMG;IACS,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,OAAO,CAAW;IAClE,2FAA2F;IACrC,SAAS,UAAS;IAIxE,OAAO,CAAC,SAAS;IAMR,MAAM,yCAyBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
|
package/dist/radio-cards.js
CHANGED
|
@@ -99,7 +99,12 @@ let RadioCards = class RadioCards extends LitElement {
|
|
|
99
99
|
align-items: flex-start;
|
|
100
100
|
gap: 0.5rem;
|
|
101
101
|
box-sizing: border-box;
|
|
102
|
-
|
|
102
|
+
/* Opaque base under the transparent-by-default secondary token, so an
|
|
103
|
+
unchecked card is a solid card rather than a bordered hole in the
|
|
104
|
+
page. See ui-button's secondary variant. */
|
|
105
|
+
background:
|
|
106
|
+
var(--ui-button-secondary-background, none),
|
|
107
|
+
var(--ui-surface, #ffffff);
|
|
103
108
|
border: var(--ui-border-width, 1px) solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));
|
|
104
109
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
105
110
|
padding: 0.5rem 0.75rem;
|
|
@@ -120,7 +125,9 @@ let RadioCards = class RadioCards extends LitElement {
|
|
|
120
125
|
resting/hover gradient tokens), so a gradient theme applies here the
|
|
121
126
|
same way it does to every button — a card is not a special case. */
|
|
122
127
|
.card:hover:not(:has(input:disabled)):not(:has(input:checked)) {
|
|
123
|
-
background:
|
|
128
|
+
background:
|
|
129
|
+
var(--ui-button-secondary-background-hover, none),
|
|
130
|
+
var(--ui-surface, #ffffff);
|
|
124
131
|
border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));
|
|
125
132
|
}
|
|
126
133
|
/* Same single muted-surface variable as button-group/pagination-nav,
|
package/dist/radio-cards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-cards.js","sourceRoot":"","sources":["../src/radio-cards.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QA+IL,wCAAwC;QACR,YAAO,GAAsB,EAAE,CAAC;QAChE,gCAAgC;QACpB,UAAK,GAAG,EAAE,CAAC;QACvB,gDAAgD;QACnB,aAAQ,GAAG,KAAK,CAAC;QAC9C;;;;;;WAMG;QACS,WAAM,GAAwC,OAAO,CAAC;QAClE,2FAA2F;QACrC,cAAS,GAAG,KAAK,CAAC;QAE/D,UAAK,GAAG,eAAe,EAAE,aAAa,EAAE,CAAC;IAkCpD,CAAC;aAjMiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAkB;AAQlC;IAAX,QAAQ,EAAE;0CAAuD;AAEZ;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;6CAAmB;AA9J7D,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAkMtB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport interface RadioCardOption {\n value: string;\n label: string;\n description?: string;\n /** In `layout=\"mixed\"`, forces this card onto its own full-width row. */\n fullWidth?: boolean;\n}\n\nlet instanceCount = 0;\n\n/**\n * Single-select group of full-width cards, each with a label and optional\n * description — for a handful of meaningfully different choices where the\n * description matters. For many short, same-shaped options (a color swatch,\n * a basemap style), use `radio-pills` instead. Wraps native radio inputs for\n * keyboard/a11y and fires `change` rather than relying on form submission.\n *\n * An unchecked card is treated as `ui-button`'s secondary variant: it reads\n * the same `--ui-button-secondary-background`/`-hover` and\n * `-border`/`-hover` tokens, so a gradient theme applies to a card exactly\n * like it does to any button. The selected card's border/radio dot instead\n * read `--ui-button-accent` (a solid stand-in, since `border-color`/\n * `accent-color` can't render a gradient), and its background reads the\n * shared `--ui-button-secondary-surface-muted` plus `--ui-button-highlight`,\n * so a gradient theme tints it consistently with `button-group`/\n * `pagination-nav`'s equivalents. That shared value is tuned for small\n * controls, so a card — with far more area — blends it 45% toward\n * `--ui-surface` rather than taking a second token: the tint stays the same\n * hue and gradient, just lighter on light themes (and correspondingly\n * deeper on dark ones) than on a button.\n *\n * `layout` controls how cards flow (\"mixed\" wraps with per-option\n * `fullWidth` rows, \"vertical\" stacks one per row, \"horizontal\" stays\n * side-by-side at every width). `hideInput` visually hides the radio dot via\n * the same `sr-only` clip pattern as `ui-checkbox` — the native input stays\n * in the DOM for keyboard/a11y, and the card's own border/tint carries the\n * selected state instead.\n *\n * @element radio-cards\n * @fires change - A card was selected; detail: { value }.\n */\n@customElement(\"radio-cards\")\nexport class RadioCards extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .options {\n display: flex;\n gap: 0.5rem;\n }\n .options.mixed {\n flex-wrap: wrap;\n }\n .options.mixed .card {\n flex: 1 1 11.25rem;\n }\n .options.mixed .card.full {\n flex: 1 0 100%;\n }\n .options.vertical {\n flex-direction: column;\n }\n .options.vertical .card {\n flex: 0 0 auto;\n }\n .options.horizontal {\n flex-wrap: nowrap;\n }\n .options.horizontal .card {\n flex: 1 1 0;\n min-width: 0;\n }\n .card {\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n box-sizing: border-box;\n background: var(--ui-button-secondary-background, none);\n border: var(--ui-border-width, 1px) solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.5rem 0.75rem;\n cursor: pointer;\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 /* Unchecked cards are treated as ui-button's secondary variant (same\n resting/hover gradient tokens), so a gradient theme applies here the\n same way it does to every button — a card is not a special case. */\n .card:hover:not(:has(input:disabled)):not(:has(input:checked)) {\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 /* Same single muted-surface variable as button-group/pagination-nav,\n but blended toward the card's own surface: that value is tuned for a\n small control, and across a card's much larger area it reads too\n heavy. Mixing with --ui-surface (rather than plain white) keeps the\n adjustment theme-correct — it lightens on light themes and deepens\n on dark ones. Written with the background shorthand (not\n background-image) so it stays valid whether the variable resolves to\n a gradient or a flat color. */\n .card:has(input:checked) {\n border-color: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n background:\n linear-gradient(\n color-mix(in srgb, var(--ui-surface, #ffffff) 45%, transparent),\n color-mix(in srgb, var(--ui-surface, #ffffff) 45%, transparent)\n ),\n var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .card input {\n width: 1rem;\n height: 1rem;\n margin-top: 0.25rem;\n accent-color: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n cursor: pointer;\n }\n .card-label {\n font-weight: var(--ui-font-weight-semibold, 600);\n color: var(--ui-text, #0f172a);\n }\n .card-description {\n display: block;\n color: var(--ui-text-muted, #64748b);\n font-weight: var(--ui-font-weight-regular, 400);\n }\n .card:has(input:focus-visible) {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .card:has(input:checked):has(input:focus-visible) {\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 .card:has(input:disabled) {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .card:has(input:disabled) input {\n cursor: not-allowed;\n }\n .card input.sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n @media (forced-colors: active) {\n .card:has(input:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .card:has(input:checked) {\n border-color: Highlight;\n }\n .card:has(input:disabled) {\n color: GrayText;\n opacity: 1;\n }\n .card:has(input:disabled) .card-label,\n .card:has(input:disabled) .card-description {\n color: GrayText;\n }\n }\n `,\n ];\n\n /** Options to render, one card each. */\n @property({ attribute: false }) options: RadioCardOption[] = [];\n /** Currently selected value. */\n @property() value = \"\";\n /** Disables every native radio in the group. */\n @property({ type: Boolean }) disabled = false;\n /**\n * How the cards flow.\n * - \"mixed\" (default): cards wrap onto as many rows as fit; options marked\n * `fullWidth` take a row of their own.\n * - \"vertical\": one full-width card per row, never side by side.\n * - \"horizontal\": every card on one row, equal widths, no wrapping.\n */\n @property() layout: \"vertical\" | \"horizontal\" | \"mixed\" = \"mixed\";\n /** Visually hides the radio dot; the card's own border/tint carries the selected state. */\n @property({ type: Boolean, attribute: \"hide-input\" }) hideInput = false;\n\n readonly #name = `radio-cards-${++instanceCount}`;\n\n private _onChange(value: string) {\n if (this.disabled) return;\n this.value = value;\n this.dispatchEvent(new CustomEvent(\"change\", { detail: { value }, bubbles: true, composed: true }));\n }\n\n override render() {\n return html`\n <div class=\"options ${this.layout}\">\n ${repeat(\n this.options,\n (opt) => opt.value,\n (opt) => html`\n <label class=${classMap({ card: true, full: this.layout === \"mixed\" && !!opt.fullWidth })}>\n <input\n type=\"radio\"\n class=${classMap({ \"sr-only\": this.hideInput })}\n name=${this.#name}\n .checked=${this.value === opt.value}\n ?disabled=${this.disabled}\n @change=${() => this._onChange(opt.value)}\n />\n <span>\n <span class=\"card-label\">${opt.label}</span>\n ${opt.description ? html`<span class=\"card-description\">${opt.description}</span>` : nothing}\n </span>\n </label>\n `,\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"radio-cards\": RadioCards;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"radio-cards.js","sourceRoot":"","sources":["../src/radio-cards.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,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C,IAAI,CAAA;2BACI,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;;;wBAG7E,QAAQ,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;uBACxC,IAAI,CAAC,KAAK;2BACN,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC,KAAK;4BACvB,IAAI,CAAC,QAAQ;0BACf,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;;;2CAGd,GAAG,CAAC,KAAK;kBAClC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA,kCAAkC,GAAG,CAAC,WAAW,SAAS,CAAC,CAAC,CAAC,OAAO;;;WAGjG,CACF;;KAEJ,CAAC;IACJ,CAAC;CACF,CAAA;AAlDiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CAAiC;AAEpD;IAAX,QAAQ,EAAE;yCAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAkB;AAQlC;IAAX,QAAQ,EAAE;0CAAuD;AAEZ;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;6CAAmB;AArK7D,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAyMtB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport interface RadioCardOption {\n value: string;\n label: string;\n description?: string;\n /** In `layout=\"mixed\"`, forces this card onto its own full-width row. */\n fullWidth?: boolean;\n}\n\nlet instanceCount = 0;\n\n/**\n * Single-select group of full-width cards, each with a label and optional\n * description — for a handful of meaningfully different choices where the\n * description matters. For many short, same-shaped options (a color swatch,\n * a basemap style), use `radio-pills` instead. Wraps native radio inputs for\n * keyboard/a11y and fires `change` rather than relying on form submission.\n *\n * An unchecked card is treated as `ui-button`'s secondary variant: it reads\n * the same `--ui-button-secondary-background`/`-hover` and\n * `-border`/`-hover` tokens, so a gradient theme applies to a card exactly\n * like it does to any button. The selected card's border/radio dot instead\n * read `--ui-button-accent` (a solid stand-in, since `border-color`/\n * `accent-color` can't render a gradient), and its background reads the\n * shared `--ui-button-secondary-surface-muted` plus `--ui-button-highlight`,\n * so a gradient theme tints it consistently with `button-group`/\n * `pagination-nav`'s equivalents. That shared value is tuned for small\n * controls, so a card — with far more area — blends it 45% toward\n * `--ui-surface` rather than taking a second token: the tint stays the same\n * hue and gradient, just lighter on light themes (and correspondingly\n * deeper on dark ones) than on a button.\n *\n * `layout` controls how cards flow (\"mixed\" wraps with per-option\n * `fullWidth` rows, \"vertical\" stacks one per row, \"horizontal\" stays\n * side-by-side at every width). `hideInput` visually hides the radio dot via\n * the same `sr-only` clip pattern as `ui-checkbox` — the native input stays\n * in the DOM for keyboard/a11y, and the card's own border/tint carries the\n * selected state instead.\n *\n * @element radio-cards\n * @fires change - A card was selected; detail: { value }.\n */\n@customElement(\"radio-cards\")\nexport class RadioCards extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .options {\n display: flex;\n gap: 0.5rem;\n }\n .options.mixed {\n flex-wrap: wrap;\n }\n .options.mixed .card {\n flex: 1 1 11.25rem;\n }\n .options.mixed .card.full {\n flex: 1 0 100%;\n }\n .options.vertical {\n flex-direction: column;\n }\n .options.vertical .card {\n flex: 0 0 auto;\n }\n .options.horizontal {\n flex-wrap: nowrap;\n }\n .options.horizontal .card {\n flex: 1 1 0;\n min-width: 0;\n }\n .card {\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n box-sizing: border-box;\n /* Opaque base under the transparent-by-default secondary token, so an\n unchecked card is a solid card rather than a bordered hole in the\n page. See ui-button's secondary variant. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\n border: var(--ui-border-width, 1px) solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.5rem 0.75rem;\n cursor: pointer;\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 /* Unchecked cards are treated as ui-button's secondary variant (same\n resting/hover gradient tokens), so a gradient theme applies here the\n same way it does to every button — a card is not a special case. */\n .card:hover:not(:has(input:disabled)):not(:has(input:checked)) {\n background:\n var(--ui-button-secondary-background-hover, none),\n var(--ui-surface, #ffffff);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n /* Same single muted-surface variable as button-group/pagination-nav,\n but blended toward the card's own surface: that value is tuned for a\n small control, and across a card's much larger area it reads too\n heavy. Mixing with --ui-surface (rather than plain white) keeps the\n adjustment theme-correct — it lightens on light themes and deepens\n on dark ones. Written with the background shorthand (not\n background-image) so it stays valid whether the variable resolves to\n a gradient or a flat color. */\n .card:has(input:checked) {\n border-color: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n background:\n linear-gradient(\n color-mix(in srgb, var(--ui-surface, #ffffff) 45%, transparent),\n color-mix(in srgb, var(--ui-surface, #ffffff) 45%, transparent)\n ),\n var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .card input {\n width: 1rem;\n height: 1rem;\n margin-top: 0.25rem;\n accent-color: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n cursor: pointer;\n }\n .card-label {\n font-weight: var(--ui-font-weight-semibold, 600);\n color: var(--ui-text, #0f172a);\n }\n .card-description {\n display: block;\n color: var(--ui-text-muted, #64748b);\n font-weight: var(--ui-font-weight-regular, 400);\n }\n .card:has(input:focus-visible) {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .card:has(input:checked):has(input:focus-visible) {\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 .card:has(input:disabled) {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .card:has(input:disabled) input {\n cursor: not-allowed;\n }\n .card input.sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n @media (forced-colors: active) {\n .card:has(input:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .card:has(input:checked) {\n border-color: Highlight;\n }\n .card:has(input:disabled) {\n color: GrayText;\n opacity: 1;\n }\n .card:has(input:disabled) .card-label,\n .card:has(input:disabled) .card-description {\n color: GrayText;\n }\n }\n `,\n ];\n\n /** Options to render, one card each. */\n @property({ attribute: false }) options: RadioCardOption[] = [];\n /** Currently selected value. */\n @property() value = \"\";\n /** Disables every native radio in the group. */\n @property({ type: Boolean }) disabled = false;\n /**\n * How the cards flow.\n * - \"mixed\" (default): cards wrap onto as many rows as fit; options marked\n * `fullWidth` take a row of their own.\n * - \"vertical\": one full-width card per row, never side by side.\n * - \"horizontal\": every card on one row, equal widths, no wrapping.\n */\n @property() layout: \"vertical\" | \"horizontal\" | \"mixed\" = \"mixed\";\n /** Visually hides the radio dot; the card's own border/tint carries the selected state. */\n @property({ type: Boolean, attribute: \"hide-input\" }) hideInput = false;\n\n readonly #name = `radio-cards-${++instanceCount}`;\n\n private _onChange(value: string) {\n if (this.disabled) return;\n this.value = value;\n this.dispatchEvent(new CustomEvent(\"change\", { detail: { value }, bubbles: true, composed: true }));\n }\n\n override render() {\n return html`\n <div class=\"options ${this.layout}\">\n ${repeat(\n this.options,\n (opt) => opt.value,\n (opt) => html`\n <label class=${classMap({ card: true, full: this.layout === \"mixed\" && !!opt.fullWidth })}>\n <input\n type=\"radio\"\n class=${classMap({ \"sr-only\": this.hideInput })}\n name=${this.#name}\n .checked=${this.value === opt.value}\n ?disabled=${this.disabled}\n @change=${() => this._onChange(opt.value)}\n />\n <span>\n <span class=\"card-label\">${opt.label}</span>\n ${opt.description ? html`<span class=\"card-description\">${opt.description}</span>` : nothing}\n </span>\n </label>\n `,\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"radio-cards\": RadioCards;\n }\n}\n"]}
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,qBACa,QAAS,SAAQ,UAAU;;IACtC,MAAM,CAAC,cAAc,UAAQ;IAG7B,OAAgB,MAAM,
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,qBACa,QAAS,SAAQ,UAAU;;IACtC,MAAM,CAAC,cAAc,UAAQ;IAG7B,OAAgB,MAAM,4BA2OpB;IAEF,qBAAqB;IACT,OAAO,EAAE,aAAa,CAAa;IAC/C,+EAA+E;IACnE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IACrC,2FAA2F;IAC9D,IAAI,UAAS;IAC1C,sKAAsK;IAC1H,EAAE,UAAS;IACvD,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
|
@@ -137,17 +137,29 @@ let UiButton = class UiButton extends LitElement {
|
|
|
137
137
|
box-shadow: none;
|
|
138
138
|
}
|
|
139
139
|
.btn.secondary {
|
|
140
|
-
|
|
140
|
+
/* Layered over an opaque --ui-surface base rather than left flat: the
|
|
141
|
+
secondary background token is transparent by default, and a bordered
|
|
142
|
+
button that lets the page show through reads as broken on any
|
|
143
|
+
surface that isn't plain --ui-surface (a textured or tinted page, an
|
|
144
|
+
image). A themed gradient still paints over the base, so this only
|
|
145
|
+
changes what shows when the token contributes nothing. */
|
|
146
|
+
background:
|
|
147
|
+
var(--ui-button-secondary-background, none),
|
|
148
|
+
var(--ui-surface, #ffffff);
|
|
141
149
|
border-color: var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));
|
|
142
150
|
color: var(--ui-text, #0f172a);
|
|
143
151
|
box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
144
152
|
}
|
|
145
153
|
.btn.secondary:hover:not(:disabled) {
|
|
146
|
-
background:
|
|
154
|
+
background:
|
|
155
|
+
var(--ui-button-secondary-background-hover, none),
|
|
156
|
+
var(--ui-surface, #ffffff);
|
|
147
157
|
border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));
|
|
148
158
|
}
|
|
149
159
|
.btn.secondary:active:not(:disabled) {
|
|
150
|
-
background:
|
|
160
|
+
background:
|
|
161
|
+
var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),
|
|
162
|
+
var(--ui-surface, #ffffff);
|
|
151
163
|
box-shadow: none;
|
|
152
164
|
}
|
|
153
165
|
.btn.danger {
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QAGL,eAAU,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAkOpC,qBAAqB;QACT,YAAO,GAAkB,SAAS,CAAC;QAC/C,+EAA+E;QACnE,SAAI,GAAgB,IAAI,CAAC;QACrC,2FAA2F;QAC9D,SAAI,GAAG,KAAK,CAAC;QAC1C,sKAAsK;QAC1H,OAAE,GAAG,KAAK,CAAC;QACvD,oEAAoE;QACxD,SAAI,GAAkB,IAAI,CAAC;QACvC,wDAAwD;QAC5C,SAAI,GAAkC,QAAQ,CAAC;QAC3D,wCAAwC;QACX,aAA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AC,IAAI,EAAE,CAAC;YACd,OAAO,IAAI,CAAA;;kBAEC,OAAO;iBACR,IAAI,CAAC,IAAI;0BACA,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;sBACjC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;mBAC/B,IAAI,CAAC,YAAY;;0DAEsB,CAAC,IAAI,CAAC,IAAI,IAAI,aAAa,CAAC,EAAE,CAAC;sCACnD,IAAI,CAAC,IAAI;;;OAGxC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAA;;gBAEC,OAAO;;oBAEH,UAAU;oBACV,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;iBAC/B,IAAI,CAAC,QAAQ;;wDAE0B,CAAC,IAAI,CAAC,IAAI,IAAI,aAAa,CAAC,EAAE,CAAC;oCACnD,IAAI,CAAC,IAAI;;;KAGxC,CAAC;IACJ,CAAC;CACF,CAAA;AA5Da;IAAX,QAAQ,EAAE;yCAAoC;AAEnC;IAAX,QAAQ,EAAE;sCAA0B;AAER;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCAAc;AAEE;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCAAY;AAE3C;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;AApP/B,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAkSpB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconArrowPath } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"danger\";\n\n/**\n * Button (or link styled as one) with an optional leading icon, in three\n * visual weights. Set `href` to render an `<a>` instead of a `<button>` —\n * same styling either way — for cross-page navigation that should look like\n * an action button; a disabled/busy link stays a real `<a>` with\n * `aria-disabled` + `pointer-events: none` rather than losing its href.\n * Put the icon in the `icon` slot and the label in the default slot.\n *\n * Form-associated (`type=\"submit\"`/`\"reset\"`): the actual `<button>` lives in\n * this element's shadow root, which native HTML form association does not\n * cross into from an ancestor light-DOM `<form>`. `type=\"submit\"`/`\"reset\"`\n * is instead wired through `ElementInternals.form` — the same mechanism\n * `address-autocomplete` uses to associate with an ancestor form.\n *\n * `primary`/`danger` backgrounds read `--ui-button-background`/\n * `--ui-button-danger-background` (and their `-hover`/`-active`\n * counterparts), which default to the flat `--ui-primary`/`--ui-danger`\n * tokens unchanged — so `--ui-primary`/`--ui-danger` stay the single source\n * of truth for every other component. A consumer can override just these\n * button-specific tokens with a `linear-gradient(...)` to opt every\n * `ui-button` into a gradient look without touching component markup —\n * `gradientTokenValues` in `tokens.ts` ships exactly this, wired up via\n * `data-theme=\"gradient\"` (see `tokens.css`'s \"Gradient theme\" section) —\n * pairing it with `--ui-button-border`/`--ui-button-danger-border` (default\n * `transparent`) for a defining edge a shade darker than the gradient's dark\n * stop, and setting the `-active` variant's stops in reverse for a\n * pressed/\"indented\" look while the button is held down. `secondary`'s\n * background/border read the equivalent `--ui-button-secondary-*` tokens\n * (shared with `confirm-dialog`'s Cancel button), defaulting to today's\n * transparent/bordered look, so it can be themed into a matching (e.g.\n * white-to-gray) gradient too.\n *\n * `ai` is an orthogonal modifier rather than a fourth variant: it leaves the\n * variant's fill (flat or gradient-themed) untouched and only adds an\n * animated multi-hue ring *outside* the button box — a crisp masked edge\n * plus a blurred bloom behind it that fades out to transparent, so the ring\n * melts into the page instead of ending on a hard line. Both layers are\n * masked into a donut, so nothing is ever painted over the background or\n * label. The ring's four stops are the `--ui-ai-1`…`--ui-ai-4` tokens. It\n * sweeps slowly at rest, faster on hover and while `busy`, holds still while\n * disabled or under `prefers-reduced-motion`, and drops the bloom for a\n * solid `CanvasText` ring in forced-colors mode. The bloom reaches about\n * `0.5rem` past the control, so give an AI button that much clearance from\n * its neighbors and avoid `overflow: hidden` ancestors that would clip it.\n *\n * Do not combine `ai` with `pill` under the gradient theme\n * (`data-theme=\"gradient\"`). That theme defines a button through a darker\n * `--ui-button-border` edge plus a glossy top highlight; a pill's\n * fully-rounded silhouette runs flush against the ring around its entire\n * outline, so that border and gloss read as the inner edge of the rainbow\n * rather than as the button's own shape, and the vertical gradient fill\n * stops reading as a gradient at all. Use `ai` with the default\n * `--ui-radius-sm` corners there, and keep `ai` + `pill` for the flat theme.\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 width: 100%;\n align-items: center;\n justify-content: 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: var(--ui-border-width, 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 .btn.pill {\n border-radius: var(--ui-radius-pill, 9999px);\n }\n .btn.ai {\n position: relative;\n --ai-sweep: linear-gradient(\n 90deg,\n var(--ui-ai-1, #38bdf8),\n var(--ui-ai-2, #6366f1),\n var(--ui-ai-3, #d946ef),\n var(--ui-ai-4, #fbbf24),\n var(--ui-ai-1, #38bdf8)\n );\n }\n /* Two layers, both masked into a donut (everything except the content\n box) so the fill underneath — flat, gradient-themed, or transparent\n secondary — is never painted over: ::before is a blurred bloom that\n fades out to transparent, ::after the crisp edge on top of it. The\n gradient tile is 1.5x the box so most of the hue range is visible at\n once, and one cycle shifts it by exactly one tile, for a seamless\n loop. */\n .btn.ai::before,\n .btn.ai::after {\n content: \"\";\n position: absolute;\n background: var(--ai-sweep);\n background-size: 150% 100%;\n -webkit-mask:\n linear-gradient(#000 0 0) content-box,\n linear-gradient(#000 0 0);\n -webkit-mask-composite: xor;\n mask:\n linear-gradient(#000 0 0) content-box,\n linear-gradient(#000 0 0);\n mask-composite: exclude;\n animation: ai-sweep 4s linear infinite;\n pointer-events: none;\n }\n /* The transparent border is headroom: a mask layer is clipped to the\n border box, so without it the blur's outward spread — the fade —\n would be cut off square again. */\n .btn.ai::before {\n inset: -1rem;\n border: 0.75rem solid transparent;\n padding: 0.25rem;\n border-radius: calc(var(--ui-radius-sm, 0.25rem) + 1rem);\n background-clip: padding-box;\n filter: blur(0.3125rem);\n opacity: 0.6;\n }\n .btn.ai::after {\n inset: -0.125rem;\n padding: 0.125rem;\n border-radius: calc(var(--ui-radius-sm, 0.25rem) + 0.125rem);\n }\n .btn.ai.pill::before,\n .btn.ai.pill::after {\n border-radius: var(--ui-radius-pill, 9999px);\n }\n .btn.ai:hover::before,\n .btn.ai:hover::after {\n animation-duration: 1.5s;\n }\n /* A busy AI button keeps sweeping (and speeds up) — the ring reads as\n \"working\"; a plainly disabled one holds still. */\n .btn.ai[aria-busy=\"true\"]::before,\n .btn.ai[aria-busy=\"true\"]::after {\n animation-duration: 1.5s;\n }\n .btn.ai:disabled:not([aria-busy=\"true\"])::before,\n .btn.ai:disabled:not([aria-busy=\"true\"])::after,\n .btn.ai[aria-disabled=\"true\"]:not([aria-busy=\"true\"])::before,\n .btn.ai[aria-disabled=\"true\"]:not([aria-busy=\"true\"])::after {\n animation: none;\n }\n @keyframes ai-sweep {\n to {\n background-position: 300% 0;\n }\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 .btn.ai::before,\n .btn.ai::after,\n .btn.ai:hover::before,\n .btn.ai:hover::after,\n .btn.ai[aria-busy=\"true\"]::before,\n .btn.ai[aria-busy=\"true\"]::after {\n animation: none;\n }\n }\n @media (forced-colors: active) {\n /* Gradients carry no meaning once colors are forced — drop the bloom\n and keep a solid system-colored ring so the AI affordance survives. */\n .btn.ai::before {\n display: none;\n }\n .btn.ai::after {\n background: CanvasText;\n animation: none;\n }\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 fully rounded (pill-shaped) corners instead of the default `--ui-radius-sm`. */\n @property({ type: Boolean }) pill = false;\n /** Draws the animated multi-hue \"AI\" ring (crisp edge plus a bloom fading out to transparent) around the button, on top of whatever variant/theme it already uses. */\n @property({ type: Boolean, reflect: true }) ai = false;\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}${this.pill ? \" pill\" : \"\"}${this.ai ? \" ai\" : \"\"}`;\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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X,QAAQ,EAAE;yCAAoC;AAEnC;IAAX,QAAQ,EAAE;sCAA0B;AAER;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCAAc;AAEE;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCAAY;AAE3C;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;AAhQ/B,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA8SpB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconArrowPath } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"danger\";\n\n/**\n * Button (or link styled as one) with an optional leading icon, in three\n * visual weights. Set `href` to render an `<a>` instead of a `<button>` —\n * same styling either way — for cross-page navigation that should look like\n * an action button; a disabled/busy link stays a real `<a>` with\n * `aria-disabled` + `pointer-events: none` rather than losing its href.\n * Put the icon in the `icon` slot and the label in the default slot.\n *\n * Form-associated (`type=\"submit\"`/`\"reset\"`): the actual `<button>` lives in\n * this element's shadow root, which native HTML form association does not\n * cross into from an ancestor light-DOM `<form>`. `type=\"submit\"`/`\"reset\"`\n * is instead wired through `ElementInternals.form` — the same mechanism\n * `address-autocomplete` uses to associate with an ancestor form.\n *\n * `primary`/`danger` backgrounds read `--ui-button-background`/\n * `--ui-button-danger-background` (and their `-hover`/`-active`\n * counterparts), which default to the flat `--ui-primary`/`--ui-danger`\n * tokens unchanged — so `--ui-primary`/`--ui-danger` stay the single source\n * of truth for every other component. A consumer can override just these\n * button-specific tokens with a `linear-gradient(...)` to opt every\n * `ui-button` into a gradient look without touching component markup —\n * `gradientTokenValues` in `tokens.ts` ships exactly this, wired up via\n * `data-theme=\"gradient\"` (see `tokens.css`'s \"Gradient theme\" section) —\n * pairing it with `--ui-button-border`/`--ui-button-danger-border` (default\n * `transparent`) for a defining edge a shade darker than the gradient's dark\n * stop, and setting the `-active` variant's stops in reverse for a\n * pressed/\"indented\" look while the button is held down. `secondary`'s\n * background/border read the equivalent `--ui-button-secondary-*` tokens\n * (shared with `confirm-dialog`'s Cancel button), defaulting to today's\n * transparent/bordered look, so it can be themed into a matching (e.g.\n * white-to-gray) gradient too.\n *\n * `ai` is an orthogonal modifier rather than a fourth variant: it leaves the\n * variant's fill (flat or gradient-themed) untouched and only adds an\n * animated multi-hue ring *outside* the button box — a crisp masked edge\n * plus a blurred bloom behind it that fades out to transparent, so the ring\n * melts into the page instead of ending on a hard line. Both layers are\n * masked into a donut, so nothing is ever painted over the background or\n * label. The ring's four stops are the `--ui-ai-1`…`--ui-ai-4` tokens. It\n * sweeps slowly at rest, faster on hover and while `busy`, holds still while\n * disabled or under `prefers-reduced-motion`, and drops the bloom for a\n * solid `CanvasText` ring in forced-colors mode. The bloom reaches about\n * `0.5rem` past the control, so give an AI button that much clearance from\n * its neighbors and avoid `overflow: hidden` ancestors that would clip it.\n *\n * Do not combine `ai` with `pill` under the gradient theme\n * (`data-theme=\"gradient\"`). That theme defines a button through a darker\n * `--ui-button-border` edge plus a glossy top highlight; a pill's\n * fully-rounded silhouette runs flush against the ring around its entire\n * outline, so that border and gloss read as the inner edge of the rainbow\n * rather than as the button's own shape, and the vertical gradient fill\n * stops reading as a gradient at all. Use `ai` with the default\n * `--ui-radius-sm` corners there, and keep `ai` + `pill` for the flat theme.\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 width: 100%;\n align-items: center;\n justify-content: 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: var(--ui-border-width, 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 /* Layered over an opaque --ui-surface base rather than left flat: the\n secondary background token is transparent by default, and a bordered\n button that lets the page show through reads as broken on any\n surface that isn't plain --ui-surface (a textured or tinted page, an\n image). A themed gradient still paints over the base, so this only\n changes what shows when the token contributes nothing. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\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:\n var(--ui-button-secondary-background-hover, none),\n var(--ui-surface, #ffffff);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n .btn.secondary:active:not(:disabled) {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface, #ffffff);\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 .btn.pill {\n border-radius: var(--ui-radius-pill, 9999px);\n }\n .btn.ai {\n position: relative;\n --ai-sweep: linear-gradient(\n 90deg,\n var(--ui-ai-1, #38bdf8),\n var(--ui-ai-2, #6366f1),\n var(--ui-ai-3, #d946ef),\n var(--ui-ai-4, #fbbf24),\n var(--ui-ai-1, #38bdf8)\n );\n }\n /* Two layers, both masked into a donut (everything except the content\n box) so the fill underneath — flat, gradient-themed, or transparent\n secondary — is never painted over: ::before is a blurred bloom that\n fades out to transparent, ::after the crisp edge on top of it. The\n gradient tile is 1.5x the box so most of the hue range is visible at\n once, and one cycle shifts it by exactly one tile, for a seamless\n loop. */\n .btn.ai::before,\n .btn.ai::after {\n content: \"\";\n position: absolute;\n background: var(--ai-sweep);\n background-size: 150% 100%;\n -webkit-mask:\n linear-gradient(#000 0 0) content-box,\n linear-gradient(#000 0 0);\n -webkit-mask-composite: xor;\n mask:\n linear-gradient(#000 0 0) content-box,\n linear-gradient(#000 0 0);\n mask-composite: exclude;\n animation: ai-sweep 4s linear infinite;\n pointer-events: none;\n }\n /* The transparent border is headroom: a mask layer is clipped to the\n border box, so without it the blur's outward spread — the fade —\n would be cut off square again. */\n .btn.ai::before {\n inset: -1rem;\n border: 0.75rem solid transparent;\n padding: 0.25rem;\n border-radius: calc(var(--ui-radius-sm, 0.25rem) + 1rem);\n background-clip: padding-box;\n filter: blur(0.3125rem);\n opacity: 0.6;\n }\n .btn.ai::after {\n inset: -0.125rem;\n padding: 0.125rem;\n border-radius: calc(var(--ui-radius-sm, 0.25rem) + 0.125rem);\n }\n .btn.ai.pill::before,\n .btn.ai.pill::after {\n border-radius: var(--ui-radius-pill, 9999px);\n }\n .btn.ai:hover::before,\n .btn.ai:hover::after {\n animation-duration: 1.5s;\n }\n /* A busy AI button keeps sweeping (and speeds up) — the ring reads as\n \"working\"; a plainly disabled one holds still. */\n .btn.ai[aria-busy=\"true\"]::before,\n .btn.ai[aria-busy=\"true\"]::after {\n animation-duration: 1.5s;\n }\n .btn.ai:disabled:not([aria-busy=\"true\"])::before,\n .btn.ai:disabled:not([aria-busy=\"true\"])::after,\n .btn.ai[aria-disabled=\"true\"]:not([aria-busy=\"true\"])::before,\n .btn.ai[aria-disabled=\"true\"]:not([aria-busy=\"true\"])::after {\n animation: none;\n }\n @keyframes ai-sweep {\n to {\n background-position: 300% 0;\n }\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 .btn.ai::before,\n .btn.ai::after,\n .btn.ai:hover::before,\n .btn.ai:hover::after,\n .btn.ai[aria-busy=\"true\"]::before,\n .btn.ai[aria-busy=\"true\"]::after {\n animation: none;\n }\n }\n @media (forced-colors: active) {\n /* Gradients carry no meaning once colors are forced — drop the bloom\n and keep a solid system-colored ring so the AI affordance survives. */\n .btn.ai::before {\n display: none;\n }\n .btn.ai::after {\n background: CanvasText;\n animation: none;\n }\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 fully rounded (pill-shaped) corners instead of the default `--ui-radius-sm`. */\n @property({ type: Boolean }) pill = false;\n /** Draws the animated multi-hue \"AI\" ring (crisp edge plus a bloom fading out to transparent) around the button, on top of whatever variant/theme it already uses. */\n @property({ type: Boolean, reflect: true }) ai = false;\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}${this.pill ? \" pill\" : \"\"}${this.ai ? \" ai\" : \"\"}`;\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/docs/button-group.md
CHANGED
package/docs/design-language.md
CHANGED
|
@@ -66,6 +66,27 @@ defines the details used when creating or reviewing components.
|
|
|
66
66
|
the active tab's `--ui-primary` line drawn on top of it) rather than
|
|
67
67
|
introducing a new token — the same precedent as `ui-button`'s `secondary`
|
|
68
68
|
variant, which is realized via `--ui-border`/`--ui-text-muted`, not a hue.
|
|
69
|
+
- **A bordered control paints an opaque base.** `--ui-button-secondary-*`
|
|
70
|
+
defaults to `none`, so any control that uses it directly would let the page
|
|
71
|
+
behind it show through — invisible on a plain `--ui-surface` page, obviously
|
|
72
|
+
broken on a tinted, textured, or image-backed one, and inconsistent with
|
|
73
|
+
text fields, which are already opaque. Every such control therefore layers
|
|
74
|
+
the token over an opaque base rather than declaring it alone:
|
|
75
|
+
|
|
76
|
+
```css
|
|
77
|
+
background:
|
|
78
|
+
var(--ui-button-secondary-background, none),
|
|
79
|
+
var(--ui-surface, #ffffff);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A themed gradient still paints over that base, so a theme overriding the
|
|
83
|
+
token behaves exactly as before; only the "token contributes nothing" case
|
|
84
|
+
changes. This applies to `ui-button`'s `secondary` variant,
|
|
85
|
+
`confirm-dialog`'s Cancel, `button-group`'s unchecked segments,
|
|
86
|
+
`pagination-nav`'s buttons, `radio-cards`' unchecked cards, and the floating
|
|
87
|
+
`scroll-to-top`/`scroll-to-bottom`/`fullscreen-button` controls. It does not
|
|
88
|
+
apply to states that already resolve to an opaque value
|
|
89
|
+
(`--ui-button-secondary-surface-muted`, `--ui-surface-muted`).
|
|
69
90
|
- `--ui-ai-1`…`--ui-ai-4` are the one multi-hue family: the stops of
|
|
70
91
|
`ui-button[ai]`'s animated ring, where the rainbow itself is the meaning
|
|
71
92
|
("this action is AI-powered") rather than a semantic state. They are only
|
package/docs/pagination-nav.md
CHANGED
package/docs/ui-button.md
CHANGED
package/llms.txt
CHANGED
|
@@ -447,7 +447,7 @@ Import: `import "@f-ewald/components/button-group.js";`
|
|
|
447
447
|
|
|
448
448
|
Properties: `options` (JS property only) : ButtonGroupOption[], default []; `value` (attribute `value`) : string, default ""; `disabled` (attribute `disabled`) : boolean, default false; `iconOnly` (attribute `icon-only`) : boolean, default false; `size` (attribute `size`) : "sm" | "md", default "md"
|
|
449
449
|
Events: `change`
|
|
450
|
-
CSS custom properties: `--ui-border`, `--ui-border-width`, `--ui-button-background`, `--ui-button-highlight`, `--ui-button-secondary-background`, `--ui-button-secondary-background-active`, `--ui-button-secondary-surface-muted`, `--ui-button-text-shadow`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-medium`, `--ui-line-height-tight`, `--ui-on-accent`, `--ui-primary`, `--ui-radius-sm`, `--ui-surface-muted`, `--ui-text`
|
|
450
|
+
CSS custom properties: `--ui-border`, `--ui-border-width`, `--ui-button-background`, `--ui-button-highlight`, `--ui-button-secondary-background`, `--ui-button-secondary-background-active`, `--ui-button-secondary-surface-muted`, `--ui-button-text-shadow`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-medium`, `--ui-line-height-tight`, `--ui-on-accent`, `--ui-primary`, `--ui-radius-sm`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`
|
|
451
451
|
|
|
452
452
|
Example:
|
|
453
453
|
```html
|
|
@@ -1799,7 +1799,7 @@ Import: `import "@f-ewald/components/pagination-nav.js";`
|
|
|
1799
1799
|
|
|
1800
1800
|
Properties: `currentPage` (attribute `current-page`) : number, default 1; `totalPages` (attribute `total-pages`) : number, default 1
|
|
1801
1801
|
Events: `page-change`
|
|
1802
|
-
CSS custom properties: `--ui-border`, `--ui-border-width`, `--ui-button-highlight`, `--ui-button-secondary-`, `--ui-button-secondary-background`, `--ui-button-secondary-background-active`, `--ui-button-secondary-border`, `--ui-button-secondary-border-hover`, `--ui-button-secondary-surface-muted`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-weight-medium`, `--ui-line-height-tight`, `--ui-numeric`, `--ui-radius-sm`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
|
|
1802
|
+
CSS custom properties: `--ui-border`, `--ui-border-width`, `--ui-button-highlight`, `--ui-button-secondary-`, `--ui-button-secondary-background`, `--ui-button-secondary-background-active`, `--ui-button-secondary-border`, `--ui-button-secondary-border-hover`, `--ui-button-secondary-surface-muted`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-weight-medium`, `--ui-line-height-tight`, `--ui-numeric`, `--ui-radius-sm`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
|
|
1803
1803
|
|
|
1804
1804
|
Example:
|
|
1805
1805
|
```html
|
|
@@ -2807,7 +2807,7 @@ Import: `import "@f-ewald/components/ui-button.js";`
|
|
|
2807
2807
|
|
|
2808
2808
|
Properties: `variant` (attribute `variant`) : ButtonVariant, default "primary"; `size` (attribute `size`) : "sm" | "md", default "md"; `pill` (attribute `pill`) : boolean, default false; `ai` (attribute `ai`) : boolean, default false; `href` (attribute `href`) : string | null, default null; `type` (attribute `type`) : "button" | "submit" | "reset", default "button"; `disabled` (attribute `disabled`) : boolean, default false; `busy` (attribute `busy`) : boolean, default false
|
|
2809
2809
|
Events: none
|
|
2810
|
-
CSS custom properties: `--ui-ai-1`, `--ui-ai-2`, `--ui-ai-3`, `--ui-ai-4`, `--ui-border`, `--ui-border-width`, `--ui-button-background`, `--ui-button-background-active`, `--ui-button-background-hover`, `--ui-button-border`, `--ui-button-danger-background`, `--ui-button-danger-background-active`, `--ui-button-danger-background-hover`, `--ui-button-danger-border`, `--ui-button-highlight`, `--ui-button-secondary-`, `--ui-button-secondary-background`, `--ui-button-secondary-background-active`, `--ui-button-secondary-background-hover`, `--ui-button-secondary-border`, `--ui-button-secondary-border-hover`, `--ui-button-text-shadow`, `--ui-danger`, `--ui-danger-hover`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-medium`, `--ui-line-height-tight`, `--ui-on-accent`, `--ui-primary`, `--ui-primary-hover`, `--ui-radius-pill`, `--ui-radius-sm`, `--ui-text`, `--ui-text-muted`
|
|
2810
|
+
CSS custom properties: `--ui-ai-1`, `--ui-ai-2`, `--ui-ai-3`, `--ui-ai-4`, `--ui-border`, `--ui-border-width`, `--ui-button-background`, `--ui-button-background-active`, `--ui-button-background-hover`, `--ui-button-border`, `--ui-button-danger-background`, `--ui-button-danger-background-active`, `--ui-button-danger-background-hover`, `--ui-button-danger-border`, `--ui-button-highlight`, `--ui-button-secondary-`, `--ui-button-secondary-background`, `--ui-button-secondary-background-active`, `--ui-button-secondary-background-hover`, `--ui-button-secondary-border`, `--ui-button-secondary-border-hover`, `--ui-button-text-shadow`, `--ui-danger`, `--ui-danger-hover`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-medium`, `--ui-line-height-tight`, `--ui-on-accent`, `--ui-primary`, `--ui-primary-hover`, `--ui-radius-pill`, `--ui-radius-sm`, `--ui-surface`, `--ui-text`, `--ui-text-muted`
|
|
2811
2811
|
|
|
2812
2812
|
Example:
|
|
2813
2813
|
```html
|