@f-ewald/components 1.40.0 → 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/custom-elements.json +170 -6
- package/dist/breadcrumb-nav.d.ts +20 -2
- package/dist/breadcrumb-nav.d.ts.map +1 -1
- package/dist/breadcrumb-nav.js +53 -7
- package/dist/breadcrumb-nav.js.map +1 -1
- 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/empty-state.d.ts +16 -0
- package/dist/empty-state.d.ts.map +1 -1
- package/dist/empty-state.js +39 -8
- package/dist/empty-state.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/skip-link.d.ts +10 -2
- package/dist/skip-link.d.ts.map +1 -1
- package/dist/skip-link.js +55 -7
- package/dist/skip-link.js.map +1 -1
- package/dist/spec-list.d.ts +17 -8
- package/dist/spec-list.d.ts.map +1 -1
- package/dist/spec-list.js +103 -45
- package/dist/spec-list.js.map +1 -1
- package/dist/tokens.css +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +8 -4
- package/dist/tokens.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/dist/vote-control.d.ts.map +1 -1
- package/dist/vote-control.js +9 -2
- package/dist/vote-control.js.map +1 -1
- package/docs/breadcrumb-nav.md +1 -1
- package/docs/button-group.md +1 -0
- package/docs/design-language.md +21 -0
- package/docs/empty-state.md +6 -1
- package/docs/pagination-nav.md +1 -0
- package/docs/skip-link.md +10 -3
- package/docs/spec-list.md +18 -10
- package/docs/ui-button.md +1 -0
- package/llms.txt +26 -15
- 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/
|
package/custom-elements.json
CHANGED
|
@@ -2580,7 +2580,7 @@
|
|
|
2580
2580
|
"text": "number"
|
|
2581
2581
|
},
|
|
2582
2582
|
"default": "0",
|
|
2583
|
-
"description": "When greater than zero and the trail has more items than this, collapse the\nmiddle of the trail behind an overflow button (the first and current crumbs\nalways stay visible). `0` (the default) never collapses.",
|
|
2583
|
+
"description": "When greater than zero and the trail has more items than this, collapse the\nmiddle of the trail behind an overflow button (the first and current crumbs\nalways stay visible). `0` (the default) never collapses.\n\nA collapsed trail always occupies three positions — first crumb, overflow\nbutton, current page — so values below `3` are raised to `3`. Collapsing a\nshorter trail would spend a button to hide one crumb, or none at all.",
|
|
2584
2584
|
"attribute": "max-visible"
|
|
2585
2585
|
},
|
|
2586
2586
|
{
|
|
@@ -2605,6 +2605,49 @@
|
|
|
2605
2605
|
},
|
|
2606
2606
|
"description": "Toggles a collapsed trail between collapsed and expanded."
|
|
2607
2607
|
},
|
|
2608
|
+
{
|
|
2609
|
+
"kind": "method",
|
|
2610
|
+
"name": "_crumbs",
|
|
2611
|
+
"privacy": "private",
|
|
2612
|
+
"return": {
|
|
2613
|
+
"type": {
|
|
2614
|
+
"text": "BreadcrumbItem[]"
|
|
2615
|
+
}
|
|
2616
|
+
},
|
|
2617
|
+
"description": "The crumbs, defended against a non-array value assigned at runtime by a JS or HTML consumer."
|
|
2618
|
+
},
|
|
2619
|
+
{
|
|
2620
|
+
"kind": "method",
|
|
2621
|
+
"name": "_limit",
|
|
2622
|
+
"privacy": "private",
|
|
2623
|
+
"return": {
|
|
2624
|
+
"type": {
|
|
2625
|
+
"text": "number"
|
|
2626
|
+
}
|
|
2627
|
+
},
|
|
2628
|
+
"description": "How many crumbs may show before the middle collapses, or `0` for never.\nFloored at 3, since a collapsed trail always renders first + overflow +\ncurrent."
|
|
2629
|
+
},
|
|
2630
|
+
{
|
|
2631
|
+
"kind": "method",
|
|
2632
|
+
"name": "_collapsible",
|
|
2633
|
+
"privacy": "private",
|
|
2634
|
+
"return": {
|
|
2635
|
+
"type": {
|
|
2636
|
+
"text": "boolean"
|
|
2637
|
+
}
|
|
2638
|
+
},
|
|
2639
|
+
"description": "Whether the trail is long enough for the overflow button to earn its place."
|
|
2640
|
+
},
|
|
2641
|
+
{
|
|
2642
|
+
"kind": "field",
|
|
2643
|
+
"name": "_overflowHadFocus",
|
|
2644
|
+
"type": {
|
|
2645
|
+
"text": "boolean"
|
|
2646
|
+
},
|
|
2647
|
+
"privacy": "private",
|
|
2648
|
+
"default": "false",
|
|
2649
|
+
"description": "Whether the overflow button held focus when the current update began."
|
|
2650
|
+
},
|
|
2608
2651
|
{
|
|
2609
2652
|
"kind": "method",
|
|
2610
2653
|
"name": "_onNavigate",
|
|
@@ -2704,7 +2747,7 @@
|
|
|
2704
2747
|
"text": "number"
|
|
2705
2748
|
},
|
|
2706
2749
|
"default": "0",
|
|
2707
|
-
"description": "When greater than zero and the trail has more items than this, collapse the\nmiddle of the trail behind an overflow button (the first and current crumbs\nalways stay visible). `0` (the default) never collapses.",
|
|
2750
|
+
"description": "When greater than zero and the trail has more items than this, collapse the\nmiddle of the trail behind an overflow button (the first and current crumbs\nalways stay visible). `0` (the default) never collapses.\n\nA collapsed trail always occupies three positions — first crumb, overflow\nbutton, current page — so values below `3` are raised to `3`. Collapsing a\nshorter trail would spend a button to hide one crumb, or none at all.",
|
|
2708
2751
|
"fieldName": "maxVisible"
|
|
2709
2752
|
},
|
|
2710
2753
|
{
|
|
@@ -7266,6 +7309,16 @@
|
|
|
7266
7309
|
"attribute": "size",
|
|
7267
7310
|
"reflects": true
|
|
7268
7311
|
},
|
|
7312
|
+
{
|
|
7313
|
+
"kind": "field",
|
|
7314
|
+
"name": "headingLevel",
|
|
7315
|
+
"type": {
|
|
7316
|
+
"text": "number"
|
|
7317
|
+
},
|
|
7318
|
+
"default": "2",
|
|
7319
|
+
"description": "Heading rank the `heading` is exposed as, 1-6. An `empty-state` fills a\npage, a panel, or a sidebar, so no single rank is right everywhere; set\nthis to whatever the surrounding outline needs. Applied via `aria-level`\non the rendered `h2`, which overrides the element's native rank for\nassistive technology.",
|
|
7320
|
+
"attribute": "heading-level"
|
|
7321
|
+
},
|
|
7269
7322
|
{
|
|
7270
7323
|
"kind": "field",
|
|
7271
7324
|
"name": "_hasIcon",
|
|
@@ -7296,6 +7349,26 @@
|
|
|
7296
7349
|
"default": "false",
|
|
7297
7350
|
"description": "Whether the actions slot currently has assigned content."
|
|
7298
7351
|
},
|
|
7352
|
+
{
|
|
7353
|
+
"kind": "method",
|
|
7354
|
+
"name": "_slotHasContent",
|
|
7355
|
+
"privacy": "private",
|
|
7356
|
+
"static": true,
|
|
7357
|
+
"return": {
|
|
7358
|
+
"type": {
|
|
7359
|
+
"text": "boolean"
|
|
7360
|
+
}
|
|
7361
|
+
},
|
|
7362
|
+
"parameters": [
|
|
7363
|
+
{
|
|
7364
|
+
"name": "event",
|
|
7365
|
+
"type": {
|
|
7366
|
+
"text": "Event"
|
|
7367
|
+
}
|
|
7368
|
+
}
|
|
7369
|
+
],
|
|
7370
|
+
"description": "Whether a slot holds real content. Whitespace-only text nodes don't count:\nordinary indented markup puts a newline between every child, which would\notherwise mark every slot as filled and reserve space for rows that are\nvisually empty."
|
|
7371
|
+
},
|
|
7299
7372
|
{
|
|
7300
7373
|
"kind": "method",
|
|
7301
7374
|
"name": "_onIconSlotChange",
|
|
@@ -7352,6 +7425,17 @@
|
|
|
7352
7425
|
}
|
|
7353
7426
|
],
|
|
7354
7427
|
"description": "Tracks whether the actions slot has content so its row can collapse when empty."
|
|
7428
|
+
},
|
|
7429
|
+
{
|
|
7430
|
+
"kind": "method",
|
|
7431
|
+
"name": "#level",
|
|
7432
|
+
"privacy": "private",
|
|
7433
|
+
"return": {
|
|
7434
|
+
"type": {
|
|
7435
|
+
"text": "number"
|
|
7436
|
+
}
|
|
7437
|
+
},
|
|
7438
|
+
"description": "Clamps `headingLevel` into the valid 1-6 heading range, falling back to 2 for a non-numeric value."
|
|
7355
7439
|
}
|
|
7356
7440
|
],
|
|
7357
7441
|
"attributes": [
|
|
@@ -7381,6 +7465,15 @@
|
|
|
7381
7465
|
"default": "\"md\"",
|
|
7382
7466
|
"description": "`sm` for a small panel/sidebar, `md` (default) for a full page region. `md` matches the pre-`size` look exactly.",
|
|
7383
7467
|
"fieldName": "size"
|
|
7468
|
+
},
|
|
7469
|
+
{
|
|
7470
|
+
"name": "heading-level",
|
|
7471
|
+
"type": {
|
|
7472
|
+
"text": "number"
|
|
7473
|
+
},
|
|
7474
|
+
"default": "2",
|
|
7475
|
+
"description": "Heading rank the `heading` is exposed as, 1-6. An `empty-state` fills a\npage, a panel, or a sidebar, so no single rank is right everywhere; set\nthis to whatever the surrounding outline needs. Applied via `aria-level`\non the rendered `h2`, which overrides the element's native rank for\nassistive technology.",
|
|
7476
|
+
"fieldName": "headingLevel"
|
|
7384
7477
|
}
|
|
7385
7478
|
],
|
|
7386
7479
|
"superclass": {
|
|
@@ -18000,7 +18093,7 @@
|
|
|
18000
18093
|
"declarations": [
|
|
18001
18094
|
{
|
|
18002
18095
|
"kind": "class",
|
|
18003
|
-
"description": "\"Skip to main content\" bypass link — the package's first pure\naccessibility-utility component. It renders a real `<a>` that stays\nvisually hidden (but in the focus order) until it receives keyboard focus,\nthen pins itself to the top-left of the viewport as a solid, high-contrast\nblock so a keyboard or screen-reader user can jump straight past repeated\npage chrome to the main content
|
|
18096
|
+
"description": "\"Skip to main content\" bypass link — the package's first pure\naccessibility-utility component. It renders a real `<a>` that stays\nvisually hidden (but in the focus order) until it receives keyboard focus,\nthen pins itself to the top-left of the viewport as a solid, high-contrast\nblock so a keyboard or screen-reader user can jump straight past repeated\npage chrome to the main content.\n\nActivating it moves focus into the target as well as scrolling to it: a\nplain fragment link only moves focus when the target is already focusable,\nso this applies `tabindex=\"-1\"` to the target on demand rather than making\nevery consumer remember to. Native navigation is never prevented, so the\nhash still updates.\n\nPlace it as the very first focusable element on the page, before the app\nchrome, and point `href` at the `id` of the main content region.",
|
|
18004
18097
|
"name": "SkipLink",
|
|
18005
18098
|
"slots": [
|
|
18006
18099
|
{
|
|
@@ -18028,6 +18121,46 @@
|
|
|
18028
18121
|
"default": "\"Skip to main content\"",
|
|
18029
18122
|
"description": "Fallback link wording used when nothing is slotted.",
|
|
18030
18123
|
"attribute": "label"
|
|
18124
|
+
},
|
|
18125
|
+
{
|
|
18126
|
+
"kind": "field",
|
|
18127
|
+
"name": "_hasSlotted",
|
|
18128
|
+
"type": {
|
|
18129
|
+
"text": "boolean"
|
|
18130
|
+
},
|
|
18131
|
+
"privacy": "private",
|
|
18132
|
+
"default": "false",
|
|
18133
|
+
"description": "Whether the default slot holds real wording, as opposed to the whitespace ordinary formatting leaves behind."
|
|
18134
|
+
},
|
|
18135
|
+
{
|
|
18136
|
+
"kind": "method",
|
|
18137
|
+
"name": "#focusTarget",
|
|
18138
|
+
"privacy": "private",
|
|
18139
|
+
"return": {
|
|
18140
|
+
"type": {
|
|
18141
|
+
"text": "void"
|
|
18142
|
+
}
|
|
18143
|
+
},
|
|
18144
|
+
"description": "Moves focus to the fragment target, in addition to the native scroll.\n\nA plain in-page anchor only moves focus when its target is already\nfocusable, so pointing a skip link at an ordinary `<main id=\"main\">`\nscrolls the page but strands the keyboard user's focus back at the top —\nthe classic way a skip link silently does nothing. Rather than requiring\nevery consumer to remember `tabindex=\"-1\"`, this applies it to the target\non demand. Navigation is never prevented, so the hash still updates."
|
|
18145
|
+
},
|
|
18146
|
+
{
|
|
18147
|
+
"kind": "method",
|
|
18148
|
+
"name": "#onSlotChange",
|
|
18149
|
+
"privacy": "private",
|
|
18150
|
+
"return": {
|
|
18151
|
+
"type": {
|
|
18152
|
+
"text": "void"
|
|
18153
|
+
}
|
|
18154
|
+
},
|
|
18155
|
+
"parameters": [
|
|
18156
|
+
{
|
|
18157
|
+
"name": "event",
|
|
18158
|
+
"type": {
|
|
18159
|
+
"text": "Event"
|
|
18160
|
+
}
|
|
18161
|
+
}
|
|
18162
|
+
],
|
|
18163
|
+
"description": "Tracks whether the slot holds substantive wording, so whitespace can't strip the link's accessible name."
|
|
18031
18164
|
}
|
|
18032
18165
|
],
|
|
18033
18166
|
"attributes": [
|
|
@@ -18188,11 +18321,11 @@
|
|
|
18188
18321
|
"declarations": [
|
|
18189
18322
|
{
|
|
18190
18323
|
"kind": "class",
|
|
18191
|
-
"description": "A key/value specification sheet — the \"spec sheet\" block on a product page:\
|
|
18324
|
+
"description": "A key/value specification sheet — the \"spec sheet\" block on a product page:\na muted, wide-tracked key column against a value column, separated by\nhairline rules (and uppercased under themes that set\n`--ui-label-transform`). It describes ONE record's attributes, which is\nwhat sets it apart from `data-table` (many records, many columns, sorting);\n`spec-list` is not tabular and renders a real `<dl>`/`<dt>`/`<dd>` structure.\n\nFeed it the `items` array for the plain data path, or slot bare `<dt>`/`<dd>`\npairs when a value needs a link, a `status-pill`, or other markup — slotted\npairs inherit the component's own key/value styling, so no page CSS is\nneeded. A `<div>` wrapping a pair is also accepted as a full-width grouping\nrow, but `::slotted()` cannot reach inside it, so those `dt`/`dd` stay the\nconsumer's to style. Slotted content takes precedence over `items`; with\nneither, nothing is rendered.",
|
|
18192
18325
|
"name": "SpecList",
|
|
18193
18326
|
"slots": [
|
|
18194
18327
|
{
|
|
18195
|
-
"description": "Optional `<
|
|
18328
|
+
"description": "Optional `<dt>`/`<dd>` pairs for values that need custom markup; when present, they replace the `items` path.",
|
|
18196
18329
|
"name": ""
|
|
18197
18330
|
}
|
|
18198
18331
|
],
|
|
@@ -18249,6 +18382,26 @@
|
|
|
18249
18382
|
"default": "false",
|
|
18250
18383
|
"description": "Whether the default slot currently has assigned content."
|
|
18251
18384
|
},
|
|
18385
|
+
{
|
|
18386
|
+
"kind": "method",
|
|
18387
|
+
"name": "_isContent",
|
|
18388
|
+
"privacy": "private",
|
|
18389
|
+
"static": true,
|
|
18390
|
+
"return": {
|
|
18391
|
+
"type": {
|
|
18392
|
+
"text": "boolean"
|
|
18393
|
+
}
|
|
18394
|
+
},
|
|
18395
|
+
"parameters": [
|
|
18396
|
+
{
|
|
18397
|
+
"name": "node",
|
|
18398
|
+
"type": {
|
|
18399
|
+
"text": "Node"
|
|
18400
|
+
}
|
|
18401
|
+
}
|
|
18402
|
+
],
|
|
18403
|
+
"description": "Whether a slot node is real content, ignoring the whitespace ordinary indented markup leaves between children."
|
|
18404
|
+
},
|
|
18252
18405
|
{
|
|
18253
18406
|
"kind": "method",
|
|
18254
18407
|
"name": "_onSlotChange",
|
|
@@ -18267,6 +18420,17 @@
|
|
|
18267
18420
|
}
|
|
18268
18421
|
],
|
|
18269
18422
|
"description": "Tracks whether the default slot has content so slotted markup can take precedence over `items`."
|
|
18423
|
+
},
|
|
18424
|
+
{
|
|
18425
|
+
"kind": "method",
|
|
18426
|
+
"name": "_rows",
|
|
18427
|
+
"privacy": "private",
|
|
18428
|
+
"return": {
|
|
18429
|
+
"type": {
|
|
18430
|
+
"text": "SpecListItem[]"
|
|
18431
|
+
}
|
|
18432
|
+
},
|
|
18433
|
+
"description": "The rows, defended against a non-array value assigned at runtime by a JS or HTML consumer."
|
|
18270
18434
|
}
|
|
18271
18435
|
],
|
|
18272
18436
|
"attributes": [
|
|
@@ -20217,7 +20381,7 @@
|
|
|
20217
20381
|
"type": {
|
|
20218
20382
|
"text": "Record<string, string>"
|
|
20219
20383
|
},
|
|
20220
|
-
"default": "{ // Ink over paper. --ui-text-muted is the same ink at ~65% over white rather // than a neutral gray, so the quiet text stays in the same warm family // instead of turning blue-gray beside the accent. \"--ui-text\": \"#17160f\", \"--ui-text-muted\": \"#686763\", \"--ui-surface\": \"#ffffff\", \"--ui-surface-muted\": \"#f0f0f0\", // ~
|
|
20384
|
+
"default": "{ // Ink over paper. --ui-text-muted is the same ink at ~65% over white rather // than a neutral gray, so the quiet text stays in the same warm family // instead of turning blue-gray beside the accent. \"--ui-text\": \"#17160f\", \"--ui-text-muted\": \"#686763\", \"--ui-surface\": \"#ffffff\", \"--ui-surface-muted\": \"#f0f0f0\", // ~55% ink over white. Darker than it looks like it needs to be, because a // border is often the only thing bounding a white-on-white control, and // WCAG 1.4.11 wants 3:1 against both adjacent surfaces for that: this is // 3.55:1 on white and 3.12:1 on the muted surface. The lighter ~40% ink // (#a2a29f) reads better but only reaches 2.56:1, and 1.5px of extra weight // does not buy an exemption. Still short of fully black, which at this width // would turn every bordered surface into a hard box. \"--ui-border\": \"#898883\", \"--ui-tooltip\": \"#17160f\", \"--ui-overlay\": \"rgb(23 22 15 / 0.45)\", // The \"just changed\" flash tints toward the accent instead of amber, which // is the one warm hue this palette has no room for. \"--ui-highlight\": \"#dcdcff\", \"--ui-primary\": \"#0000ff\", \"--ui-primary-hover\": \"#0000cc\", \"--ui-info\": \"#0000ff\", \"--ui-info-hover\": \"#0000cc\", \"--ui-on-accent\": \"#ffffff\", // Solid and crisp at the reference's own 2px, not the default translucent // 3px halo — a blurred ring is the one soft edge this theme has nowhere to // put. \"--ui-focus-ring\": \"0 0 0 2px #0000ff\", // Ink CTA that lights up blue on hover, and inverts its two stops while // pressed. The border is ink at every state so the button keeps a defining // edge even once the fill goes blue. \"--ui-button-background\": \"#17160f\", \"--ui-button-background-hover\": \"#0000ff\", \"--ui-button-background-active\": \"#0000cc\", \"--ui-button-border\": \"#17160f\", \"--ui-button-danger-border\": \"#b91c1c\", // Secondary is the reference's ghost button: no fill, ink border, a paper // wash on hover and an accent border to echo the primary's hover. \"--ui-button-secondary-border\": \"#17160f\", \"--ui-button-secondary-border-hover\": \"#0000ff\", \"--ui-button-secondary-background-hover\": \"#f0f0f0\", \"--ui-button-secondary-surface-muted\": \"#f0f0f0\", // Non-button accents that can only take a plain color (a native input's // accent-color, range-slider's track/thumb) follow --ui-primary, not the // ink button fill — those are selection marks, not calls to action. \"--ui-button-accent\": \"#0000ff\", \"--ui-radius\": \"0\", \"--ui-radius-sm\": \"0\", \"--ui-radius-pill\": \"0\", \"--ui-radius-circle\": \"0\", \"--ui-shadow\": \"0 0 0 1.5px rgb(23 22 15 / 0.24)\", \"--ui-shadow-lg\": \"0 0 0 1.5px #17160f\", \"--ui-border-width\": \"1.5px\", \"--ui-label-transform\": \"uppercase\", \"--ui-numeric\": \"tabular-nums\", \"--ui-font\": '\"Space Mono\", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace', }",
|
|
20221
20385
|
"description": "\"Blueprint\" theme overrides, applied via `data-theme=\"blueprint\"` on `<html>`\n(see `generate-tokens-css.mjs`) — forces `color-scheme: light` like every\nother non-dark theme, and restyles the light palette as a technical catalog\n/ spec sheet: warm near-black ink on white paper, one pure-blue accent,\nsquare corners, and structure carried entirely by hairline rules instead of\nshadows.\n\nIt is the widest theme in the system, and the reason three token axes exist\nthat no earlier theme needed:\n\n- `--ui-font` is retargeted to a monospace stack. `darkTokenValues` notes\n that shape and type tokens are theme-independent; `metro` already broke\n that for shape, and this breaks it for the type *family* only. Type\n *metrics* (size, weight, line height) remain unthemed in every theme —\n they encode hierarchy, which is not a stylistic choice. \"Space Mono\"\n leads the stack purely so a consumer who loads that webfont gets the\n reference face automatically; with no external CSS at all it falls\n straight through to the same system mono stack `--ui-font-mono` uses, so\n the theme still renders correctly on its own.\n- `--ui-border-width` goes to `1.5px`. Every border in this theme is doing\n the work a shadow does elsewhere, and at 1px those rules read as a faint\n table rather than as drawn structure.\n- `--ui-label-transform` goes to `uppercase`, which is what makes chrome\n micro-labels read as signage/spec-sheet keys. Only labels that name a\n region or column carry this — never user content.\n- `--ui-numeric` goes to `tabular-nums`, so figures line up in a column and\n do not jitter as they change.\n\nButtons are deliberately NOT the accent color. `--ui-primary` stays pure\nblue because it drives accents everywhere else (active tab underlines,\nselected states, links, the certification-style tints), but the primary\nbutton fill is overridden to ink through the `--ui-button-*` hooks and only\nturns blue on hover — a black-on-white CTA that lights up is the\ncatalog-print look, and a large pure-blue fill next to blue accents would\nflatten the two roles into one. That split is exactly what those hooks\nexist for (see `gradientTokenValues` above for the same technique).\n\nSemantic `danger`/`success`/`warning` keep their default hues: they encode\nmeaning rather than style, and the reference's blue-only restraint is an\neditorial choice a component library cannot make on a consumer's behalf.\n`--ui-info` is the exception — it is \"neutral notice\", which in this theme\nis precisely the accent, and the default sky blue would otherwise sit a few\ndegrees off the pure blue beside it and read as a mistake.\n\nShadows flatten to a hard ink ring rather than to `none`, for the same\nreason `metro` does it: `slide-panel` has no border of its own and would\notherwise lose its edge entirely."
|
|
20222
20386
|
},
|
|
20223
20387
|
{
|
package/dist/breadcrumb-nav.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement, type TemplateResult } from "lit";
|
|
1
|
+
import { LitElement, nothing, type TemplateResult } from "lit";
|
|
2
2
|
/** A single crumb in the trail. */
|
|
3
3
|
export interface BreadcrumbItem {
|
|
4
4
|
/** Visible text for the crumb. */
|
|
@@ -48,6 +48,10 @@ export declare class BreadcrumbNav extends LitElement {
|
|
|
48
48
|
* When greater than zero and the trail has more items than this, collapse the
|
|
49
49
|
* middle of the trail behind an overflow button (the first and current crumbs
|
|
50
50
|
* always stay visible). `0` (the default) never collapses.
|
|
51
|
+
*
|
|
52
|
+
* A collapsed trail always occupies three positions — first crumb, overflow
|
|
53
|
+
* button, current page — so values below `3` are raised to `3`. Collapsing a
|
|
54
|
+
* shorter trail would spend a button to hide one crumb, or none at all.
|
|
51
55
|
*/
|
|
52
56
|
maxVisible: number;
|
|
53
57
|
/** Whether a collapsed trail is currently expanded to show its hidden crumbs. */
|
|
@@ -55,11 +59,25 @@ export declare class BreadcrumbNav extends LitElement {
|
|
|
55
59
|
static styles: import("lit").CSSResult[];
|
|
56
60
|
/** Toggles a collapsed trail between collapsed and expanded. */
|
|
57
61
|
private _toggle;
|
|
62
|
+
/** The crumbs, defended against a non-array value assigned at runtime by a JS or HTML consumer. */
|
|
63
|
+
private _crumbs;
|
|
64
|
+
/**
|
|
65
|
+
* How many crumbs may show before the middle collapses, or `0` for never.
|
|
66
|
+
* Floored at 3, since a collapsed trail always renders first + overflow +
|
|
67
|
+
* current.
|
|
68
|
+
*/
|
|
69
|
+
private _limit;
|
|
70
|
+
/** Whether the trail is long enough for the overflow button to earn its place. */
|
|
71
|
+
private _collapsible;
|
|
72
|
+
willUpdate(): void;
|
|
73
|
+
updated(): void;
|
|
74
|
+
/** Whether the overflow button held focus when the current update began. */
|
|
75
|
+
private _overflowHadFocus;
|
|
58
76
|
/** Dispatches `breadcrumb-navigate` without preventing native navigation. */
|
|
59
77
|
private _onNavigate;
|
|
60
78
|
private _crumbNode;
|
|
61
79
|
private _overflowNode;
|
|
62
|
-
render(): TemplateResult<1>;
|
|
80
|
+
render(): typeof nothing | TemplateResult<1>;
|
|
63
81
|
}
|
|
64
82
|
declare global {
|
|
65
83
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumb-nav.d.ts","sourceRoot":"","sources":["../src/breadcrumb-nav.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"breadcrumb-nav.d.ts","sourceRoot":"","sources":["../src/breadcrumb-nav.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAK1E,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,kDAAkD;AAClD,MAAM,WAAW,wBAAwB;IACvC,2BAA2B;IAC3B,IAAI,EAAE,cAAc,CAAC;IACrB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C;;;OAGG;IACwB,KAAK,EAAE,cAAc,EAAE,CAAM;IAExD;;;;;;;;OAQG;IACmD,UAAU,SAAK;IAErE,iFAAiF;IACrC,QAAQ,UAAS;IAE7D,OAAgB,MAAM,4BAgGpB;IAEF,gEAAgE;IAChE,OAAO,CAAC,OAAO;IAIf,mGAAmG;IACnG,OAAO,CAAC,OAAO;IAIf;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAKd,kFAAkF;IAClF,OAAO,CAAC,YAAY;IAKX,UAAU,IAAI,IAAI,CAO1B;IAEQ,OAAO,IAAI,IAAI,CAQvB;IAED,4EAA4E;IAC5E,OAAO,CAAC,iBAAiB,CAAS;IAElC,6EAA6E;IAC7E,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,aAAa;IAcZ,MAAM,uCAsCd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
|
package/dist/breadcrumb-nav.js
CHANGED
|
@@ -42,10 +42,16 @@ let BreadcrumbNav = class BreadcrumbNav extends LitElement {
|
|
|
42
42
|
* When greater than zero and the trail has more items than this, collapse the
|
|
43
43
|
* middle of the trail behind an overflow button (the first and current crumbs
|
|
44
44
|
* always stay visible). `0` (the default) never collapses.
|
|
45
|
+
*
|
|
46
|
+
* A collapsed trail always occupies three positions — first crumb, overflow
|
|
47
|
+
* button, current page — so values below `3` are raised to `3`. Collapsing a
|
|
48
|
+
* shorter trail would spend a button to hide one crumb, or none at all.
|
|
45
49
|
*/
|
|
46
50
|
this.maxVisible = 0;
|
|
47
51
|
/** Whether a collapsed trail is currently expanded to show its hidden crumbs. */
|
|
48
52
|
this.expanded = false;
|
|
53
|
+
/** Whether the overflow button held focus when the current update began. */
|
|
54
|
+
this._overflowHadFocus = false;
|
|
49
55
|
}
|
|
50
56
|
static { this.styles = [
|
|
51
57
|
tokens,
|
|
@@ -148,6 +154,44 @@ let BreadcrumbNav = class BreadcrumbNav extends LitElement {
|
|
|
148
154
|
_toggle() {
|
|
149
155
|
this.expanded = !this.expanded;
|
|
150
156
|
}
|
|
157
|
+
/** The crumbs, defended against a non-array value assigned at runtime by a JS or HTML consumer. */
|
|
158
|
+
_crumbs() {
|
|
159
|
+
return Array.isArray(this.items) ? this.items : [];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* How many crumbs may show before the middle collapses, or `0` for never.
|
|
163
|
+
* Floored at 3, since a collapsed trail always renders first + overflow +
|
|
164
|
+
* current.
|
|
165
|
+
*/
|
|
166
|
+
_limit() {
|
|
167
|
+
const limit = Math.trunc(this.maxVisible);
|
|
168
|
+
return limit > 0 ? Math.max(3, limit) : 0;
|
|
169
|
+
}
|
|
170
|
+
/** Whether the trail is long enough for the overflow button to earn its place. */
|
|
171
|
+
_collapsible() {
|
|
172
|
+
const limit = this._limit();
|
|
173
|
+
return limit > 0 && this._crumbs().length > limit;
|
|
174
|
+
}
|
|
175
|
+
willUpdate() {
|
|
176
|
+
const root = this.renderRoot;
|
|
177
|
+
this._overflowHadFocus = root?.activeElement?.classList.contains("overflow") ?? false;
|
|
178
|
+
// A trail that stops being collapsible (its items shrank, or max-visible
|
|
179
|
+
// grew) must not keep a reflected expanded attribute describing a
|
|
180
|
+
// disclosure that no longer exists.
|
|
181
|
+
if (this.expanded && !this._collapsible())
|
|
182
|
+
this.expanded = false;
|
|
183
|
+
}
|
|
184
|
+
updated() {
|
|
185
|
+
// The overflow button is the only focusable node that can vanish mid-update.
|
|
186
|
+
// Without this, replacing items while it holds focus drops focus to
|
|
187
|
+
// document.body and strands a keyboard user at the top of the page.
|
|
188
|
+
if (!this._overflowHadFocus)
|
|
189
|
+
return;
|
|
190
|
+
this._overflowHadFocus = false;
|
|
191
|
+
if (this.renderRoot.querySelector(".overflow"))
|
|
192
|
+
return;
|
|
193
|
+
this.renderRoot.querySelector("nav")?.focus();
|
|
194
|
+
}
|
|
151
195
|
/** Dispatches `breadcrumb-navigate` without preventing native navigation. */
|
|
152
196
|
_onNavigate(item, index) {
|
|
153
197
|
this.dispatchEvent(new CustomEvent("breadcrumb-navigate", {
|
|
@@ -176,6 +220,7 @@ let BreadcrumbNav = class BreadcrumbNav extends LitElement {
|
|
|
176
220
|
type="button"
|
|
177
221
|
class="overflow"
|
|
178
222
|
aria-expanded=${this.expanded ? "true" : "false"}
|
|
223
|
+
aria-controls="trail"
|
|
179
224
|
aria-label=${label}
|
|
180
225
|
@click=${this._toggle}
|
|
181
226
|
>
|
|
@@ -183,12 +228,13 @@ let BreadcrumbNav = class BreadcrumbNav extends LitElement {
|
|
|
183
228
|
</button>`;
|
|
184
229
|
}
|
|
185
230
|
render() {
|
|
186
|
-
const items = this.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
231
|
+
const items = this._crumbs();
|
|
232
|
+
// An empty trail renders nothing at all rather than an empty landmark: a
|
|
233
|
+
// named but contentless nav is pure noise in the accessibility tree.
|
|
234
|
+
if (items.length === 0)
|
|
235
|
+
return nothing;
|
|
190
236
|
const lastIndex = items.length - 1;
|
|
191
|
-
const collapsible = this.
|
|
237
|
+
const collapsible = this._collapsible();
|
|
192
238
|
const nodes = [];
|
|
193
239
|
if (collapsible) {
|
|
194
240
|
nodes.push(this._crumbNode(items[0], 0, lastIndex));
|
|
@@ -204,8 +250,8 @@ let BreadcrumbNav = class BreadcrumbNav extends LitElement {
|
|
|
204
250
|
items.forEach((item, i) => nodes.push(this._crumbNode(item, i, lastIndex)));
|
|
205
251
|
}
|
|
206
252
|
return html `
|
|
207
|
-
<nav aria-label="Breadcrumb">
|
|
208
|
-
<ol class="trail">
|
|
253
|
+
<nav aria-label="Breadcrumb" tabindex="-1">
|
|
254
|
+
<ol class="trail" id="trail">
|
|
209
255
|
${nodes.map((node, i) => html `
|
|
210
256
|
<li class="crumb-item">
|
|
211
257
|
${i > 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumb-nav.js","sourceRoot":"","sources":["../src/breadcrumb-nav.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,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAqBrC;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QACL;;;WAGG;QACwB,UAAK,GAAqB,EAAE,CAAC;QAExD;;;;WAIG;QACmD,eAAU,GAAG,CAAC,CAAC;QAErE,iFAAiF;QACrC,aAAQ,GAAG,KAAK,CAAC;IAuL/D,CAAC;aArLiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6FF;KACF,AAhGqB,CAgGpB;IAEF,gEAAgE;IACxD,OAAO;QACb,IAA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,GAAG,CAAC;YACL,CAAC,CAAC,IAAI,CAAA,wCAAwC,gBAAgB,CAAC,EAAE,CAAC,SAAS;YAC3E,CAAC,CAAC,OAAO;kBACT,IAAI;;aAET,CACF;;;KAGN,CAAC;IACJ,CAAC;CACF,CAAA;AAjM4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CAA8B;AAOF;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;iDAAgB;AAGzB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CAAkB;AAflD,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAsMzB","sourcesContent":["import { LitElement, css, html, nothing, type TemplateResult } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconChevronRight, iconEllipsisHorizontal } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** A single crumb in the trail. */\nexport interface BreadcrumbItem {\n /** Visible text for the crumb. */\n label: string;\n /**\n * Destination the crumb links to. Omit for a non-interactive crumb rendered\n * as plain text. Ignored on the last item, which is always the current page.\n */\n href?: string;\n}\n\n/** Detail for the `breadcrumb-navigate` event. */\nexport interface BreadcrumbNavigateDetail {\n /** The activated crumb. */\n item: BreadcrumbItem;\n /** Its index within `items`. */\n index: number;\n}\n\n/**\n * A breadcrumb trail: a `<nav aria-label=\"Breadcrumb\">` wrapping an ordered\n * list, with chevron separators and the current page rendered as plain,\n * non-interactive text. Designed to drop into `page-header`'s `breadcrumb`\n * slot, but usable on its own anywhere a trail is needed.\n *\n * The last `items` entry is always treated as the current page: it renders as\n * text with `aria-current=\"page\"` even if it carries an `href`. Middle entries\n * without an `href` render as plain text too; only middle entries with an\n * `href` are real anchors.\n *\n * When `max-visible` is greater than zero and the trail is longer than that,\n * the middle collapses behind an overflow button that always keeps the first\n * and current crumbs visible; activating it toggles `expanded` to reveal the\n * hidden crumbs in place.\n *\n * @element breadcrumb-nav\n * @fires breadcrumb-navigate - A crumb link was activated; `detail` is\n * `{ item: BreadcrumbItem; index: number }`. This is an additional\n * notification hook only — the anchor's native navigation is never\n * prevented, so crumbs stay real, middle-clickable, right-clickable links.\n */\n@customElement(\"breadcrumb-nav\")\nexport class BreadcrumbNav extends LitElement {\n /**\n * The crumbs, root first. The last entry is the current page and is rendered\n * as non-interactive text with `aria-current=\"page\"`.\n */\n @property({ type: Array }) items: BreadcrumbItem[] = [];\n\n /**\n * When greater than zero and the trail has more items than this, collapse the\n * middle of the trail behind an overflow button (the first and current crumbs\n * always stay visible). `0` (the default) never collapses.\n */\n @property({ type: Number, attribute: \"max-visible\" }) maxVisible = 0;\n\n /** Whether a collapsed trail is currently expanded to show its hidden crumbs. */\n @property({ type: Boolean, reflect: true }) expanded = false;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\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 .trail {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.25rem;\n margin: 0;\n padding: 0;\n list-style: none;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-tight, 1.25);\n }\n .crumb-item {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n }\n .sep {\n display: inline-flex;\n line-height: var(--ui-line-height-glyph, 1);\n color: var(--ui-text-muted, #64748b);\n }\n .crumb {\n color: var(--ui-text-muted, #64748b);\n text-decoration: none;\n border-radius: var(--ui-radius-sm, 0.25rem);\n transition: color 150ms ease;\n }\n .crumb:hover,\n .crumb:focus-visible {\n color: var(--ui-text, #0f172a);\n }\n .crumb:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .static {\n color: var(--ui-text-muted, #64748b);\n }\n .current {\n color: var(--ui-text, #0f172a);\n font-weight: var(--ui-font-weight-medium, 500);\n }\n .overflow {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n appearance: none;\n background: none;\n border: none;\n border-radius: var(--ui-radius-sm, 0.25rem);\n color: var(--ui-text-muted, #64748b);\n cursor: pointer;\n transition: color 150ms ease;\n }\n .overflow:hover {\n color: var(--ui-text, #0f172a);\n }\n .overflow:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (prefers-reduced-motion: reduce) {\n .crumb,\n .overflow {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .crumb:focus-visible,\n .overflow:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Toggles a collapsed trail between collapsed and expanded. */\n private _toggle(): void {\n this.expanded = !this.expanded;\n }\n\n /** Dispatches `breadcrumb-navigate` without preventing native navigation. */\n private _onNavigate(item: BreadcrumbItem, index: number): void {\n this.dispatchEvent(\n new CustomEvent<BreadcrumbNavigateDetail>(\"breadcrumb-navigate\", {\n detail: { item, index },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _crumbNode(item: BreadcrumbItem, index: number, lastIndex: number): TemplateResult {\n if (index === lastIndex) {\n return html`<span class=\"current\" aria-current=\"page\">${item.label}</span>`;\n }\n if (item.href) {\n return html`<a\n class=\"crumb\"\n href=${item.href}\n @click=${() => this._onNavigate(item, index)}\n >${item.label}</a\n >`;\n }\n return html`<span class=\"static\">${item.label}</span>`;\n }\n\n private _overflowNode(hiddenCount: number): TemplateResult {\n const label = this.expanded ? \"Hide breadcrumbs\" : `Show ${hiddenCount} hidden breadcrumbs`;\n return html`<button\n type=\"button\"\n class=\"overflow\"\n aria-expanded=${this.expanded ? \"true\" : \"false\"}\n aria-label=${label}\n @click=${this._toggle}\n >\n ${iconEllipsisHorizontal(18)}\n </button>`;\n }\n\n override render() {\n const items = this.items ?? [];\n if (items.length === 0) {\n return html`<nav aria-label=\"Breadcrumb\"></nav>`;\n }\n const lastIndex = items.length - 1;\n const collapsible = this.maxVisible > 0 && items.length > this.maxVisible;\n\n const nodes: TemplateResult[] = [];\n if (collapsible) {\n nodes.push(this._crumbNode(items[0], 0, lastIndex));\n nodes.push(this._overflowNode(items.length - 2));\n if (this.expanded) {\n for (let i = 1; i < lastIndex; i++) {\n nodes.push(this._crumbNode(items[i], i, lastIndex));\n }\n }\n nodes.push(this._crumbNode(items[lastIndex], lastIndex, lastIndex));\n } else {\n items.forEach((item, i) => nodes.push(this._crumbNode(item, i, lastIndex)));\n }\n\n return html`\n <nav aria-label=\"Breadcrumb\">\n <ol class=\"trail\">\n ${nodes.map(\n (node, i) => html`\n <li class=\"crumb-item\">\n ${i > 0\n ? html`<span class=\"sep\" aria-hidden=\"true\">${iconChevronRight(14)}</span>`\n : nothing}\n ${node}\n </li>\n `,\n )}\n </ol>\n </nav>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"breadcrumb-nav\": BreadcrumbNav;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"breadcrumb-nav.js","sourceRoot":"","sources":["../src/breadcrumb-nav.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,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAqBrC;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;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,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;QACtE,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,IAAI,CAAA;;;YAGH,KAAK,CAAC,GAAG,CACT,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAA;;kBAEX,CAAC,GAAG,CAAC;YACL,CAAC,CAAC,IAAI,CAAA,wCAAwC,gBAAgB,CAAC,EAAE,CAAC,SAAS;YAC3E,CAAC,CAAC,OAAO;kBACT,IAAI;;aAET,CACF;;;KAGN,CAAC;IACJ,CAAC;CACF,CAAA;AAjP4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CAA8B;AAWF;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;iDAAgB;AAGzB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CAAkB;AAnBlD,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAsPzB","sourcesContent":["import { LitElement, css, html, nothing, type TemplateResult } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconChevronRight, iconEllipsisHorizontal } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** A single crumb in the trail. */\nexport interface BreadcrumbItem {\n /** Visible text for the crumb. */\n label: string;\n /**\n * Destination the crumb links to. Omit for a non-interactive crumb rendered\n * as plain text. Ignored on the last item, which is always the current page.\n */\n href?: string;\n}\n\n/** Detail for the `breadcrumb-navigate` event. */\nexport interface BreadcrumbNavigateDetail {\n /** The activated crumb. */\n item: BreadcrumbItem;\n /** Its index within `items`. */\n index: number;\n}\n\n/**\n * A breadcrumb trail: a `<nav aria-label=\"Breadcrumb\">` wrapping an ordered\n * list, with chevron separators and the current page rendered as plain,\n * non-interactive text. Designed to drop into `page-header`'s `breadcrumb`\n * slot, but usable on its own anywhere a trail is needed.\n *\n * The last `items` entry is always treated as the current page: it renders as\n * text with `aria-current=\"page\"` even if it carries an `href`. Middle entries\n * without an `href` render as plain text too; only middle entries with an\n * `href` are real anchors.\n *\n * When `max-visible` is greater than zero and the trail is longer than that,\n * the middle collapses behind an overflow button that always keeps the first\n * and current crumbs visible; activating it toggles `expanded` to reveal the\n * hidden crumbs in place.\n *\n * @element breadcrumb-nav\n * @fires breadcrumb-navigate - A crumb link was activated; `detail` is\n * `{ item: BreadcrumbItem; index: number }`. This is an additional\n * notification hook only — the anchor's native navigation is never\n * prevented, so crumbs stay real, middle-clickable, right-clickable links.\n */\n@customElement(\"breadcrumb-nav\")\nexport class BreadcrumbNav extends LitElement {\n /**\n * The crumbs, root first. The last entry is the current page and is rendered\n * as non-interactive text with `aria-current=\"page\"`.\n */\n @property({ type: Array }) items: BreadcrumbItem[] = [];\n\n /**\n * When greater than zero and the trail has more items than this, collapse the\n * middle of the trail behind an overflow button (the first and current crumbs\n * always stay visible). `0` (the default) never collapses.\n *\n * A collapsed trail always occupies three positions — first crumb, overflow\n * button, current page — so values below `3` are raised to `3`. Collapsing a\n * shorter trail would spend a button to hide one crumb, or none at all.\n */\n @property({ type: Number, attribute: \"max-visible\" }) maxVisible = 0;\n\n /** Whether a collapsed trail is currently expanded to show its hidden crumbs. */\n @property({ type: Boolean, reflect: true }) expanded = false;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\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 .trail {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.25rem;\n margin: 0;\n padding: 0;\n list-style: none;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-tight, 1.25);\n }\n .crumb-item {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n }\n .sep {\n display: inline-flex;\n line-height: var(--ui-line-height-glyph, 1);\n color: var(--ui-text-muted, #64748b);\n }\n .crumb {\n color: var(--ui-text-muted, #64748b);\n text-decoration: none;\n border-radius: var(--ui-radius-sm, 0.25rem);\n transition: color 150ms ease;\n }\n .crumb:hover,\n .crumb:focus-visible {\n color: var(--ui-text, #0f172a);\n }\n .crumb:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .static {\n color: var(--ui-text-muted, #64748b);\n }\n .current {\n color: var(--ui-text, #0f172a);\n font-weight: var(--ui-font-weight-medium, 500);\n }\n .overflow {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n appearance: none;\n background: none;\n border: none;\n border-radius: var(--ui-radius-sm, 0.25rem);\n color: var(--ui-text-muted, #64748b);\n cursor: pointer;\n transition: color 150ms ease;\n }\n .overflow:hover {\n color: var(--ui-text, #0f172a);\n }\n .overflow:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (prefers-reduced-motion: reduce) {\n .crumb,\n .overflow {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .crumb:focus-visible,\n .overflow:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Toggles a collapsed trail between collapsed and expanded. */\n private _toggle(): void {\n this.expanded = !this.expanded;\n }\n\n /** The crumbs, defended against a non-array value assigned at runtime by a JS or HTML consumer. */\n private _crumbs(): BreadcrumbItem[] {\n return Array.isArray(this.items) ? this.items : [];\n }\n\n /**\n * How many crumbs may show before the middle collapses, or `0` for never.\n * Floored at 3, since a collapsed trail always renders first + overflow +\n * current.\n */\n private _limit(): number {\n const limit = Math.trunc(this.maxVisible);\n return limit > 0 ? Math.max(3, limit) : 0;\n }\n\n /** Whether the trail is long enough for the overflow button to earn its place. */\n private _collapsible(): boolean {\n const limit = this._limit();\n return limit > 0 && this._crumbs().length > limit;\n }\n\n override willUpdate(): void {\n const root = this.renderRoot as ShadowRoot | null;\n this._overflowHadFocus = root?.activeElement?.classList.contains(\"overflow\") ?? false;\n // A trail that stops being collapsible (its items shrank, or max-visible\n // grew) must not keep a reflected expanded attribute describing a\n // disclosure that no longer exists.\n if (this.expanded && !this._collapsible()) this.expanded = false;\n }\n\n override updated(): void {\n // The overflow button is the only focusable node that can vanish mid-update.\n // Without this, replacing items while it holds focus drops focus to\n // document.body and strands a keyboard user at the top of the page.\n if (!this._overflowHadFocus) return;\n this._overflowHadFocus = false;\n if (this.renderRoot.querySelector(\".overflow\")) return;\n this.renderRoot.querySelector<HTMLElement>(\"nav\")?.focus();\n }\n\n /** Whether the overflow button held focus when the current update began. */\n private _overflowHadFocus = false;\n\n /** Dispatches `breadcrumb-navigate` without preventing native navigation. */\n private _onNavigate(item: BreadcrumbItem, index: number): void {\n this.dispatchEvent(\n new CustomEvent<BreadcrumbNavigateDetail>(\"breadcrumb-navigate\", {\n detail: { item, index },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _crumbNode(item: BreadcrumbItem, index: number, lastIndex: number): TemplateResult {\n if (index === lastIndex) {\n return html`<span class=\"current\" aria-current=\"page\">${item.label}</span>`;\n }\n if (item.href) {\n return html`<a\n class=\"crumb\"\n href=${item.href}\n @click=${() => this._onNavigate(item, index)}\n >${item.label}</a\n >`;\n }\n return html`<span class=\"static\">${item.label}</span>`;\n }\n\n private _overflowNode(hiddenCount: number): TemplateResult {\n const label = this.expanded ? \"Hide breadcrumbs\" : `Show ${hiddenCount} hidden breadcrumbs`;\n return html`<button\n type=\"button\"\n class=\"overflow\"\n aria-expanded=${this.expanded ? \"true\" : \"false\"}\n aria-controls=\"trail\"\n aria-label=${label}\n @click=${this._toggle}\n >\n ${iconEllipsisHorizontal(18)}\n </button>`;\n }\n\n override render() {\n const items = this._crumbs();\n // An empty trail renders nothing at all rather than an empty landmark: a\n // named but contentless nav is pure noise in the accessibility tree.\n if (items.length === 0) return nothing;\n const lastIndex = items.length - 1;\n const collapsible = this._collapsible();\n\n const nodes: TemplateResult[] = [];\n if (collapsible) {\n nodes.push(this._crumbNode(items[0], 0, lastIndex));\n nodes.push(this._overflowNode(items.length - 2));\n if (this.expanded) {\n for (let i = 1; i < lastIndex; i++) {\n nodes.push(this._crumbNode(items[i], i, lastIndex));\n }\n }\n nodes.push(this._crumbNode(items[lastIndex], lastIndex, lastIndex));\n } else {\n items.forEach((item, i) => nodes.push(this._crumbNode(item, i, lastIndex)));\n }\n\n return html`\n <nav aria-label=\"Breadcrumb\" tabindex=\"-1\">\n <ol class=\"trail\" id=\"trail\">\n ${nodes.map(\n (node, i) => html`\n <li class=\"crumb-item\">\n ${i > 0\n ? html`<span class=\"sep\" aria-hidden=\"true\">${iconChevronRight(14)}</span>`\n : nothing}\n ${node}\n </li>\n `,\n )}\n </ol>\n </nav>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"breadcrumb-nav\": BreadcrumbNav;\n }\n}\n"]}
|
|
@@ -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;QACpB,UAAK,GAAG,EAAE,CAAC;QACvB,gDAAgD;QACnB,aAAQ,GAAG,KAAK,CAAC;QAC9C,oFAAoF;QAChB,aAAQ,GAAG,KAAK,CAAC;QACrF,uFAAuF;QAC1D,SAAI,GAAgB,IAAI,CAAC;QAE7C,UAAK,GAAG,gBAAgB,EAAE,aAAa,EAAE,CAAC;IAmCrD,CAAC;a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,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,YAAO,GAAwB,EAAE,CAAC;QAClE,gCAAgC;QACpB,UAAK,GAAG,EAAE,CAAC;QACvB,gDAAgD;QACnB,aAAQ,GAAG,KAAK,CAAC;QAC9C,oFAAoF;QAChB,aAAQ,GAAG,KAAK,CAAC;QACrF,uFAAuF;QAC1D,SAAI,GAAgB,IAAI,CAAC;QAE7C,UAAK,GAAG,gBAAgB,EA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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"}
|