@f-ewald/components 1.39.0 → 1.40.1
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 +48 -0
- package/custom-elements.json +1179 -100
- package/dist/address-autocomplete.js +2 -2
- package/dist/address-autocomplete.js.map +1 -1
- package/dist/app-shell.js +4 -4
- package/dist/app-shell.js.map +1 -1
- package/dist/app-sidebar.js +2 -2
- package/dist/app-sidebar.js.map +1 -1
- package/dist/audio-player.js +1 -1
- package/dist/audio-player.js.map +1 -1
- package/dist/autocomplete-input.js +2 -2
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/breadcrumb-nav.d.ts +87 -0
- package/dist/breadcrumb-nav.d.ts.map +1 -0
- package/dist/breadcrumb-nav.js +281 -0
- package/dist/breadcrumb-nav.js.map +1 -0
- package/dist/button-group.js +2 -2
- package/dist/button-group.js.map +1 -1
- package/dist/calendar-day.js +3 -3
- package/dist/calendar-day.js.map +1 -1
- package/dist/calendar-month.d.ts.map +1 -1
- package/dist/calendar-month.js +4 -1
- package/dist/calendar-month.js.map +1 -1
- package/dist/calendar-week.js +4 -4
- package/dist/calendar-week.js.map +1 -1
- package/dist/chat-message.js +1 -1
- package/dist/chat-message.js.map +1 -1
- package/dist/comment-composer.js +1 -1
- package/dist/comment-composer.js.map +1 -1
- package/dist/confirm-dialog.d.ts.map +1 -1
- package/dist/confirm-dialog.js +5 -2
- package/dist/confirm-dialog.js.map +1 -1
- package/dist/content-divider.js +1 -1
- package/dist/content-divider.js.map +1 -1
- package/dist/cron-schedule.d.ts.map +1 -1
- package/dist/cron-schedule.js +6 -5
- package/dist/cron-schedule.js.map +1 -1
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +3 -2
- package/dist/data-table.js.map +1 -1
- package/dist/dropdown-button.d.ts.map +1 -1
- package/dist/dropdown-button.js +4 -2
- package/dist/dropdown-button.js.map +1 -1
- package/dist/editable-text.js +1 -1
- package/dist/editable-text.js.map +1 -1
- package/dist/empty-state.d.ts +58 -0
- package/dist/empty-state.d.ts.map +1 -0
- package/dist/empty-state.js +203 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/form-field.js +1 -1
- package/dist/form-field.js.map +1 -1
- package/dist/form-select.js +3 -3
- package/dist/form-select.js.map +1 -1
- package/dist/frame-box.js +1 -1
- package/dist/frame-box.js.map +1 -1
- package/dist/fullscreen-button.js +1 -1
- package/dist/fullscreen-button.js.map +1 -1
- package/dist/icons.d.ts +2 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +2 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/kanban-card.js +1 -1
- package/dist/kanban-card.js.map +1 -1
- package/dist/kanban-column.js +3 -3
- package/dist/kanban-column.js.map +1 -1
- package/dist/kbd-hint.d.ts.map +1 -1
- package/dist/kbd-hint.js +2 -1
- package/dist/kbd-hint.js.map +1 -1
- package/dist/link-card.js +1 -1
- package/dist/link-card.js.map +1 -1
- package/dist/markdown-view.js +3 -3
- package/dist/markdown-view.js.map +1 -1
- package/dist/modal-dialog.js +1 -1
- package/dist/modal-dialog.js.map +1 -1
- package/dist/multi-select.js +5 -5
- package/dist/multi-select.js.map +1 -1
- package/dist/pagination-nav.d.ts.map +1 -1
- package/dist/pagination-nav.js +5 -1
- package/dist/pagination-nav.js.map +1 -1
- package/dist/photo-gallery.js +1 -1
- package/dist/photo-gallery.js.map +1 -1
- package/dist/popover-panel.d.ts.map +1 -1
- package/dist/popover-panel.js +4 -2
- package/dist/popover-panel.js.map +1 -1
- package/dist/progress-bar.d.ts.map +1 -1
- package/dist/progress-bar.js +1 -0
- package/dist/progress-bar.js.map +1 -1
- package/dist/radio-cards.js +1 -1
- package/dist/radio-cards.js.map +1 -1
- package/dist/radio-pills.js +1 -1
- package/dist/radio-pills.js.map +1 -1
- package/dist/reveal-button.js +1 -1
- package/dist/reveal-button.js.map +1 -1
- package/dist/scroll-to-bottom.js +1 -1
- package/dist/scroll-to-bottom.js.map +1 -1
- package/dist/scroll-to-top.js +1 -1
- package/dist/scroll-to-top.js.map +1 -1
- package/dist/skip-link.d.ts +38 -0
- package/dist/skip-link.d.ts.map +1 -0
- package/dist/skip-link.js +184 -0
- package/dist/skip-link.js.map +1 -0
- package/dist/slide-panel.js +1 -1
- package/dist/slide-panel.js.map +1 -1
- package/dist/spec-list.d.ts +58 -0
- package/dist/spec-list.d.ts.map +1 -0
- package/dist/spec-list.js +226 -0
- package/dist/spec-list.js.map +1 -0
- package/dist/stat-meter.d.ts.map +1 -1
- package/dist/stat-meter.js +1 -0
- package/dist/stat-meter.js.map +1 -1
- package/dist/tab-bar.js +1 -1
- package/dist/tab-bar.js.map +1 -1
- package/dist/text-area.js +1 -1
- package/dist/text-area.js.map +1 -1
- package/dist/tile-grid.js +1 -1
- package/dist/tile-grid.js.map +1 -1
- package/dist/tokens.css +42 -1
- package/dist/tokens.d.ts +50 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +136 -0
- package/dist/tokens.js.map +1 -1
- package/dist/tree-view.js +2 -2
- package/dist/tree-view.js.map +1 -1
- package/dist/ui-admonition.js +1 -1
- package/dist/ui-admonition.js.map +1 -1
- package/dist/ui-button.js +1 -1
- package/dist/ui-button.js.map +1 -1
- package/dist/video-player.js +1 -1
- package/dist/video-player.js.map +1 -1
- package/dist/vote-control.d.ts +40 -0
- package/dist/vote-control.d.ts.map +1 -0
- package/dist/vote-control.js +318 -0
- package/dist/vote-control.js.map +1 -0
- package/docs/address-autocomplete.md +1 -0
- package/docs/app-shell.md +1 -0
- package/docs/app-sidebar.md +1 -0
- package/docs/audio-player.md +1 -0
- package/docs/autocomplete-input.md +1 -0
- package/docs/breadcrumb-nav.md +70 -0
- package/docs/button-group.md +1 -0
- package/docs/calendar-day.md +1 -0
- package/docs/calendar-month.md +1 -0
- package/docs/calendar-week.md +1 -0
- package/docs/chat-message.md +1 -0
- package/docs/comment-composer.md +1 -0
- package/docs/confirm-dialog.md +1 -0
- package/docs/content-divider.md +1 -0
- package/docs/cron-schedule.md +2 -0
- package/docs/data-table.md +2 -0
- package/docs/design-language.md +57 -5
- package/docs/dropdown-button.md +1 -0
- package/docs/editable-text.md +1 -0
- package/docs/empty-state.md +60 -0
- package/docs/form-field.md +1 -0
- package/docs/form-select.md +1 -0
- package/docs/frame-box.md +1 -0
- package/docs/fullscreen-button.md +1 -0
- package/docs/icons.md +1 -0
- package/docs/kanban-card.md +1 -0
- package/docs/kanban-column.md +1 -0
- package/docs/kbd-hint.md +1 -0
- package/docs/link-card.md +1 -0
- package/docs/markdown-view.md +1 -0
- package/docs/modal-dialog.md +1 -0
- package/docs/multi-select.md +1 -0
- package/docs/pagination-nav.md +2 -0
- package/docs/photo-gallery.md +1 -0
- package/docs/popover-panel.md +1 -0
- package/docs/progress-bar.md +1 -0
- package/docs/radio-cards.md +1 -0
- package/docs/radio-pills.md +1 -0
- package/docs/reveal-button.md +1 -0
- package/docs/scroll-to-bottom.md +1 -0
- package/docs/scroll-to-top.md +1 -0
- package/docs/skip-link.md +61 -0
- package/docs/slide-panel.md +1 -0
- package/docs/spec-list.md +79 -0
- package/docs/stat-meter.md +1 -0
- package/docs/tab-bar.md +1 -0
- package/docs/text-area.md +1 -0
- package/docs/tile-grid.md +1 -0
- package/docs/tree-view.md +1 -0
- package/docs/ui-admonition.md +1 -0
- package/docs/ui-button.md +1 -0
- package/docs/video-player.md +1 -0
- package/docs/vote-control.md +73 -0
- package/llms.txt +212 -49
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-to-top.js","sourceRoot":"","sources":["../src/scroll-to-top.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,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AChD,aAAa,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,KAAK;;KAErB,CAAC;IACJ,CAAC;CACF,CAAA;AApEiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CAAmC;AAEtC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAiB;AAEhC;IAAX,QAAQ,EAAE;0CAAyB;AAEnB;IAAhB,KAAK,EAAE;6CAA0B;AAzGvB,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAuKvB","sourcesContent":["import { LitElement, css, html, type PropertyValues } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronUp } from \"./icons.js\";\nimport { distanceFromTop, scrollToEdge } from \"./utils/scroll.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Overlay button that appears once the page (or a given `target` container)\n * has scrolled more than `threshold` pixels away from the top edge, and\n * scrolls back to the top on click.\n *\n * With no `target` (default), the button is `position: fixed` to the\n * viewport. When `target` is set, the button switches to `position:\n * absolute` and expects to be placed as a descendant of a `position:\n * relative` (or otherwise positioned) ancestor that establishes the visual\n * bounds to float within — typically `target` itself, given `overflow-y:\n * auto; position: relative`, so the button stays pinned to that container's\n * own visible corner as its content scrolls, rather than floating over the\n * whole page.\n *\n * The control is styled as a standard secondary button (ui-button's\n * `secondary` variant: 2rem tall, `--ui-radius-sm` corners, the\n * `--ui-button-secondary-*` background/border tokens, so a gradient theme\n * carries over) rather than a pill, layered over an opaque `--ui-surface`\n * base and an elevation shadow, since it floats above scrolled content.\n *\n * @element scroll-to-top\n * @fires scroll-to-top-triggered - The button was clicked, just before\n * scrolling; detail: `{ target }`.\n */\n@customElement(\"scroll-to-top\")\nexport class ScrollToTop extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n bottom: 0.75rem;\n right: 0.75rem;\n z-index: 40;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 150ms ease,\n visibility 0s linear 150ms;\n }\n :host([contained]) {\n position: absolute;\n }\n :host([visible]) {\n opacity: 1;\n visibility: visible;\n transition:\n opacity 150ms ease,\n visibility 0s linear 0s;\n }\n button {\n pointer-events: auto;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0.5rem 1rem;\n color: var(--ui-text, #0f172a);\n /* ui-button's secondary variant, over an opaque --ui-surface base: a\n floating control can't let scrolled content show through the way a\n secondary button's transparent flat background does. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow:\n var(--ui-button-highlight, 0 0 0 0 transparent),\n var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\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 white-space: nowrap;\n }\n button:hover {\n background:\n var(--ui-button-secondary-background-hover, none),\n var(--ui-surface-muted, #f8fafc);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n button:active {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface-muted, #f8fafc);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n button:focus-visible {\n outline: none;\n box-shadow:\n var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)),\n var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n @media (prefers-reduced-motion: reduce) {\n :host {\n transition: none;\n }\n :host([visible]) {\n transition: 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 `,\n ];\n\n /** Scrollable container to control; `null` (default) scrolls `window`. */\n @property({ attribute: false }) target: HTMLElement | null = null;\n /** Pixels scrolled away from the top before the button appears. */\n @property({ type: Number }) threshold = 200;\n /** Visible button text, and its accessible name. */\n @property() label = \"Scroll to top\";\n\n @state() private _visible = false;\n\n #listenedTo: HTMLElement | Window | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#subscribe();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#unsubscribe();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"target\")) {\n this.toggleAttribute(\"contained\", this.target !== null);\n // Resubscribing here (not in `updated()`) lets `#onScroll()`'s\n // `_visible` write fold into the update already in progress instead of\n // scheduling a new one. Guarded against the initial update, where\n // `target` is always in `changed` too, but `connectedCallback` already\n // subscribed to it.\n if (this.#listenedTo !== (this.target ?? window)) this.#subscribe();\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"_visible\")) this.toggleAttribute(\"visible\", this._visible);\n }\n\n #subscribe(): void {\n this.#unsubscribe();\n this.#listenedTo = this.target ?? window;\n this.#listenedTo.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n this.#onScroll();\n }\n\n #unsubscribe(): void {\n this.#listenedTo?.removeEventListener(\"scroll\", this.#onScroll);\n this.#listenedTo = null;\n }\n\n #onScroll = (): void => {\n this._visible = distanceFromTop(this.target ?? window) > this.threshold;\n };\n\n #onClick(): void {\n const target = this.target ?? window;\n this.dispatchEvent(\n new CustomEvent(\"scroll-to-top-triggered\", { detail: { target }, bubbles: true, composed: true }),\n );\n scrollToEdge(target, \"top\");\n }\n\n override render() {\n return html`\n <button type=\"button\" @click=${() => this.#onClick()}>\n ${iconChevronUp(14)}\n <span>${this.label}</span>\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"scroll-to-top\": ScrollToTop;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scroll-to-top.js","sourceRoot":"","sources":["../src/scroll-to-top.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAkGL,0EAA0E;QAC1C,WAAM,GAAuB,IAAI,CAAC;QAClE,mEAAmE;QACvC,cAAS,GAAG,GAAG,CAAC;QAC5C,oDAAoD;QACxC,UAAK,GAAG,eAAe,CAAC;QAEnB,aAAQ,GAAG,KAAK,CAAC;QAElC,gBAAW,GAAgC,IAAI,CAAC;QAwChD,cAAS,GAAG,GAAS,EAAE;YACrB,IAAI,CAAC,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;QAC1E,CAAC,CAAC;IAkBJ,CAAC;aAtKiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4FF;KACF,AA/FqB,CA+FpB;IAWF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AQ;QACN,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC;QACrC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,yBAAyB,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAClG,CAAC;QACF,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;qCACsB,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE;UAChD,aAAa,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,KAAK;;KAErB,CAAC;IACJ,CAAC;CACF,CAAA;AApEiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CAAmC;AAEtC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAiB;AAEhC;IAAX,QAAQ,EAAE;0CAAyB;AAEnB;IAAhB,KAAK,EAAE;6CAA0B;AAzGvB,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAuKvB","sourcesContent":["import { LitElement, css, html, type PropertyValues } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronUp } from \"./icons.js\";\nimport { distanceFromTop, scrollToEdge } from \"./utils/scroll.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Overlay button that appears once the page (or a given `target` container)\n * has scrolled more than `threshold` pixels away from the top edge, and\n * scrolls back to the top on click.\n *\n * With no `target` (default), the button is `position: fixed` to the\n * viewport. When `target` is set, the button switches to `position:\n * absolute` and expects to be placed as a descendant of a `position:\n * relative` (or otherwise positioned) ancestor that establishes the visual\n * bounds to float within — typically `target` itself, given `overflow-y:\n * auto; position: relative`, so the button stays pinned to that container's\n * own visible corner as its content scrolls, rather than floating over the\n * whole page.\n *\n * The control is styled as a standard secondary button (ui-button's\n * `secondary` variant: 2rem tall, `--ui-radius-sm` corners, the\n * `--ui-button-secondary-*` background/border tokens, so a gradient theme\n * carries over) rather than a pill, layered over an opaque `--ui-surface`\n * base and an elevation shadow, since it floats above scrolled content.\n *\n * @element scroll-to-top\n * @fires scroll-to-top-triggered - The button was clicked, just before\n * scrolling; detail: `{ target }`.\n */\n@customElement(\"scroll-to-top\")\nexport class ScrollToTop extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n bottom: 0.75rem;\n right: 0.75rem;\n z-index: 40;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 150ms ease,\n visibility 0s linear 150ms;\n }\n :host([contained]) {\n position: absolute;\n }\n :host([visible]) {\n opacity: 1;\n visibility: visible;\n transition:\n opacity 150ms ease,\n visibility 0s linear 0s;\n }\n button {\n pointer-events: auto;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0.5rem 1rem;\n color: var(--ui-text, #0f172a);\n /* ui-button's secondary variant, over an opaque --ui-surface base: a\n floating control can't let scrolled content show through the way a\n secondary button's transparent flat background does. */\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 box-shadow:\n var(--ui-button-highlight, 0 0 0 0 transparent),\n var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\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 white-space: nowrap;\n }\n button:hover {\n background:\n var(--ui-button-secondary-background-hover, none),\n var(--ui-surface-muted, #f8fafc);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n button:active {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface-muted, #f8fafc);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n button:focus-visible {\n outline: none;\n box-shadow:\n var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)),\n var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n @media (prefers-reduced-motion: reduce) {\n :host {\n transition: none;\n }\n :host([visible]) {\n transition: 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 `,\n ];\n\n /** Scrollable container to control; `null` (default) scrolls `window`. */\n @property({ attribute: false }) target: HTMLElement | null = null;\n /** Pixels scrolled away from the top before the button appears. */\n @property({ type: Number }) threshold = 200;\n /** Visible button text, and its accessible name. */\n @property() label = \"Scroll to top\";\n\n @state() private _visible = false;\n\n #listenedTo: HTMLElement | Window | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#subscribe();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#unsubscribe();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"target\")) {\n this.toggleAttribute(\"contained\", this.target !== null);\n // Resubscribing here (not in `updated()`) lets `#onScroll()`'s\n // `_visible` write fold into the update already in progress instead of\n // scheduling a new one. Guarded against the initial update, where\n // `target` is always in `changed` too, but `connectedCallback` already\n // subscribed to it.\n if (this.#listenedTo !== (this.target ?? window)) this.#subscribe();\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"_visible\")) this.toggleAttribute(\"visible\", this._visible);\n }\n\n #subscribe(): void {\n this.#unsubscribe();\n this.#listenedTo = this.target ?? window;\n this.#listenedTo.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n this.#onScroll();\n }\n\n #unsubscribe(): void {\n this.#listenedTo?.removeEventListener(\"scroll\", this.#onScroll);\n this.#listenedTo = null;\n }\n\n #onScroll = (): void => {\n this._visible = distanceFromTop(this.target ?? window) > this.threshold;\n };\n\n #onClick(): void {\n const target = this.target ?? window;\n this.dispatchEvent(\n new CustomEvent(\"scroll-to-top-triggered\", { detail: { target }, bubbles: true, composed: true }),\n );\n scrollToEdge(target, \"top\");\n }\n\n override render() {\n return html`\n <button type=\"button\" @click=${() => this.#onClick()}>\n ${iconChevronUp(14)}\n <span>${this.label}</span>\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"scroll-to-top\": ScrollToTop;\n }\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* "Skip to main content" bypass link — the package's first pure
|
|
4
|
+
* accessibility-utility component. It renders a real `<a>` that stays
|
|
5
|
+
* visually hidden (but in the focus order) until it receives keyboard focus,
|
|
6
|
+
* then pins itself to the top-left of the viewport as a solid, high-contrast
|
|
7
|
+
* block so a keyboard or screen-reader user can jump straight past repeated
|
|
8
|
+
* page chrome to the main content.
|
|
9
|
+
*
|
|
10
|
+
* Activating it moves focus into the target as well as scrolling to it: a
|
|
11
|
+
* plain fragment link only moves focus when the target is already focusable,
|
|
12
|
+
* so this applies `tabindex="-1"` to the target on demand rather than making
|
|
13
|
+
* every consumer remember to. Native navigation is never prevented, so the
|
|
14
|
+
* hash still updates.
|
|
15
|
+
*
|
|
16
|
+
* Place it as the very first focusable element on the page, before the app
|
|
17
|
+
* chrome, and point `href` at the `id` of the main content region.
|
|
18
|
+
*
|
|
19
|
+
* @element skip-link
|
|
20
|
+
* @slot - Optional custom link wording, overriding `label`.
|
|
21
|
+
*/
|
|
22
|
+
export declare class SkipLink extends LitElement {
|
|
23
|
+
#private;
|
|
24
|
+
static styles: import("lit").CSSResult[];
|
|
25
|
+
/** The in-page target the link jumps to (the `id` of the main content region). */
|
|
26
|
+
href: string;
|
|
27
|
+
/** Fallback link wording used when nothing is slotted. */
|
|
28
|
+
label: string;
|
|
29
|
+
/** Whether the default slot holds real wording, as opposed to the whitespace ordinary formatting leaves behind. */
|
|
30
|
+
private _hasSlotted;
|
|
31
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
"skip-link": SkipLink;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=skip-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip-link.d.ts","sourceRoot":"","sources":["../src/skip-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,QAAS,SAAQ,UAAU;;IACtC,OAAgB,MAAM,4BA+FpB;IAEF,kFAAkF;IACtE,IAAI,SAAW;IAE3B,0DAA0D;IAC9C,KAAK,SAA0B;IAE3C,mHAAmH;IAC1G,OAAO,CAAC,WAAW,CAAS;IA8B5B,MAAM,yCAId;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, css, html, nothing } from "lit";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
|
+
import { tokens } from "./tokens.js";
|
|
10
|
+
/**
|
|
11
|
+
* "Skip to main content" bypass link — the package's first pure
|
|
12
|
+
* accessibility-utility component. It renders a real `<a>` that stays
|
|
13
|
+
* visually hidden (but in the focus order) until it receives keyboard focus,
|
|
14
|
+
* then pins itself to the top-left of the viewport as a solid, high-contrast
|
|
15
|
+
* block so a keyboard or screen-reader user can jump straight past repeated
|
|
16
|
+
* page chrome to the main content.
|
|
17
|
+
*
|
|
18
|
+
* Activating it moves focus into the target as well as scrolling to it: a
|
|
19
|
+
* plain fragment link only moves focus when the target is already focusable,
|
|
20
|
+
* so this applies `tabindex="-1"` to the target on demand rather than making
|
|
21
|
+
* every consumer remember to. Native navigation is never prevented, so the
|
|
22
|
+
* hash still updates.
|
|
23
|
+
*
|
|
24
|
+
* Place it as the very first focusable element on the page, before the app
|
|
25
|
+
* chrome, and point `href` at the `id` of the main content region.
|
|
26
|
+
*
|
|
27
|
+
* @element skip-link
|
|
28
|
+
* @slot - Optional custom link wording, overriding `label`.
|
|
29
|
+
*/
|
|
30
|
+
let SkipLink = class SkipLink extends LitElement {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
/** The in-page target the link jumps to (the `id` of the main content region). */
|
|
34
|
+
this.href = "#main";
|
|
35
|
+
/** Fallback link wording used when nothing is slotted. */
|
|
36
|
+
this.label = "Skip to main content";
|
|
37
|
+
/** Whether the default slot holds real wording, as opposed to the whitespace ordinary formatting leaves behind. */
|
|
38
|
+
this._hasSlotted = false;
|
|
39
|
+
}
|
|
40
|
+
static { this.styles = [
|
|
41
|
+
tokens,
|
|
42
|
+
css `
|
|
43
|
+
:host {
|
|
44
|
+
display: contents;
|
|
45
|
+
}
|
|
46
|
+
/* Hidden at rest with the shared .sr-only clip technique — never
|
|
47
|
+
display:none / visibility:hidden, which would pull the link out of
|
|
48
|
+
the focus order and defeat the entire purpose. Clipped, it stays
|
|
49
|
+
focusable, so Tab reaches it and reveals it.
|
|
50
|
+
|
|
51
|
+
Pinned with position: fixed, not absolute. An absolutely positioned
|
|
52
|
+
link resolves its insets against the nearest positioned ancestor, so
|
|
53
|
+
dropping the component inside any position: relative container — which
|
|
54
|
+
app-shell's own .shell is — would park the revealed link at that
|
|
55
|
+
container's corner instead of the viewport's, and an overflow: hidden
|
|
56
|
+
ancestor would clip it away entirely. */
|
|
57
|
+
.link {
|
|
58
|
+
position: fixed;
|
|
59
|
+
width: 1px;
|
|
60
|
+
height: 1px;
|
|
61
|
+
margin: -1px;
|
|
62
|
+
padding: 0;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
clip: rect(0 0 0 0);
|
|
65
|
+
clip-path: inset(50%);
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
border: 0;
|
|
68
|
+
top: 0.25rem;
|
|
69
|
+
left: 0.25rem;
|
|
70
|
+
/* Above app-shell's own chrome (.sidebar/.detail/.scrim at 40/40/39)
|
|
71
|
+
so it paints over the top bar when revealed — but a deliberate
|
|
72
|
+
literal below the shared layer stack's base of 100, and it does NOT
|
|
73
|
+
call activateLayer/deactivateLayer. A skip link must never float
|
|
74
|
+
above an open modal-dialog/confirm-dialog/popover-panel/slide-panel
|
|
75
|
+
(all >= 100): that would be a focus escape hatch out of a modal's
|
|
76
|
+
trap, a real bug. 50 sits cleanly in the gap between the shell
|
|
77
|
+
chrome and any real overlay. */
|
|
78
|
+
z-index: 50;
|
|
79
|
+
box-sizing: border-box;
|
|
80
|
+
background: var(--ui-text, #0f172a);
|
|
81
|
+
color: var(--ui-on-accent, #ffffff);
|
|
82
|
+
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
83
|
+
font-family: var(
|
|
84
|
+
--ui-font,
|
|
85
|
+
ui-sans-serif,
|
|
86
|
+
system-ui,
|
|
87
|
+
sans-serif,
|
|
88
|
+
"Apple Color Emoji",
|
|
89
|
+
"Segoe UI Emoji",
|
|
90
|
+
"Segoe UI Symbol",
|
|
91
|
+
"Noto Color Emoji"
|
|
92
|
+
);
|
|
93
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
94
|
+
font-weight: var(--ui-font-weight-medium, 500);
|
|
95
|
+
line-height: var(--ui-line-height-tight, 1.25);
|
|
96
|
+
text-decoration: none;
|
|
97
|
+
box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
|
|
98
|
+
}
|
|
99
|
+
/* Both :focus and :focus-visible: the link is only ever reached by
|
|
100
|
+
keyboard, so revealing it on plain focus is correct here. The visible
|
|
101
|
+
padding lives here rather than on .link, because box-sizing:
|
|
102
|
+
border-box would otherwise floor the clipped 1x1 box at the size of
|
|
103
|
+
its own padding box, leaving an invisible 32px hit target parked over
|
|
104
|
+
the page content. */
|
|
105
|
+
.link:focus,
|
|
106
|
+
.link:focus-visible {
|
|
107
|
+
width: auto;
|
|
108
|
+
height: auto;
|
|
109
|
+
margin: 0;
|
|
110
|
+
overflow: visible;
|
|
111
|
+
clip: auto;
|
|
112
|
+
clip-path: none;
|
|
113
|
+
padding-top: 0.5rem;
|
|
114
|
+
padding-right: 1rem;
|
|
115
|
+
padding-bottom: 0.5rem;
|
|
116
|
+
padding-left: 1rem;
|
|
117
|
+
}
|
|
118
|
+
.link:focus-visible {
|
|
119
|
+
outline: none;
|
|
120
|
+
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
121
|
+
}
|
|
122
|
+
@media (forced-colors: active) {
|
|
123
|
+
.link {
|
|
124
|
+
background: Canvas;
|
|
125
|
+
color: CanvasText;
|
|
126
|
+
border: 1px solid CanvasText;
|
|
127
|
+
}
|
|
128
|
+
.link:focus-visible {
|
|
129
|
+
outline: 2px solid CanvasText;
|
|
130
|
+
outline-offset: 2px;
|
|
131
|
+
box-shadow: none;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
`,
|
|
135
|
+
]; }
|
|
136
|
+
/**
|
|
137
|
+
* Moves focus to the fragment target, in addition to the native scroll.
|
|
138
|
+
*
|
|
139
|
+
* A plain in-page anchor only moves focus when its target is already
|
|
140
|
+
* focusable, so pointing a skip link at an ordinary `<main id="main">`
|
|
141
|
+
* scrolls the page but strands the keyboard user's focus back at the top —
|
|
142
|
+
* the classic way a skip link silently does nothing. Rather than requiring
|
|
143
|
+
* every consumer to remember `tabindex="-1"`, this applies it to the target
|
|
144
|
+
* on demand. Navigation is never prevented, so the hash still updates.
|
|
145
|
+
*/
|
|
146
|
+
#focusTarget() {
|
|
147
|
+
const id = this.href.startsWith("#") ? this.href.slice(1) : "";
|
|
148
|
+
if (!id)
|
|
149
|
+
return;
|
|
150
|
+
const root = this.getRootNode();
|
|
151
|
+
const target = root.getElementById?.(id) ?? document.getElementById(id);
|
|
152
|
+
if (!target)
|
|
153
|
+
return;
|
|
154
|
+
if (!target.hasAttribute("tabindex"))
|
|
155
|
+
target.setAttribute("tabindex", "-1");
|
|
156
|
+
target.focus();
|
|
157
|
+
}
|
|
158
|
+
/** Tracks whether the slot holds substantive wording, so whitespace can't strip the link's accessible name. */
|
|
159
|
+
#onSlotChange(event) {
|
|
160
|
+
const slot = event.target;
|
|
161
|
+
this._hasSlotted = slot
|
|
162
|
+
.assignedNodes({ flatten: true })
|
|
163
|
+
.some((node) => node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? "").trim().length > 0);
|
|
164
|
+
}
|
|
165
|
+
render() {
|
|
166
|
+
return html `<a class="link" href=${this.href} @click=${this.#focusTarget}
|
|
167
|
+
><slot @slotchange=${this.#onSlotChange}></slot>${this._hasSlotted ? nothing : this.label}</a
|
|
168
|
+
>`;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
__decorate([
|
|
172
|
+
property()
|
|
173
|
+
], SkipLink.prototype, "href", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
property()
|
|
176
|
+
], SkipLink.prototype, "label", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
state()
|
|
179
|
+
], SkipLink.prototype, "_hasSlotted", void 0);
|
|
180
|
+
SkipLink = __decorate([
|
|
181
|
+
customElement("skip-link")
|
|
182
|
+
], SkipLink);
|
|
183
|
+
export { SkipLink };
|
|
184
|
+
//# sourceMappingURL=skip-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip-link.js","sourceRoot":"","sources":["../src/skip-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QAkGL,kFAAkF;QACtE,SAAI,GAAG,OAAO,CAAC;QAE3B,0DAA0D;QAC9C,UAAK,GAAG,sBAAsB,CAAC;QAE3C,mHAAmH;QAClG,gBAAW,GAAG,KAAK,CAAC;IAmCvC,CAAC;aA3IiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4FF;KACF,AA/FqB,CA+FpB;IAWF;;;;;;;;;OASG;IACH,YAAY;QACV,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAA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B,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA4IpB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * \"Skip to main content\" bypass link — the package's first pure\n * accessibility-utility component. It renders a real `<a>` that stays\n * visually hidden (but in the focus order) until it receives keyboard focus,\n * then pins itself to the top-left of the viewport as a solid, high-contrast\n * block so a keyboard or screen-reader user can jump straight past repeated\n * page chrome to the main content.\n *\n * Activating it moves focus into the target as well as scrolling to it: a\n * plain fragment link only moves focus when the target is already focusable,\n * so this applies `tabindex=\"-1\"` to the target on demand rather than making\n * every consumer remember to. Native navigation is never prevented, so the\n * hash still updates.\n *\n * Place it as the very first focusable element on the page, before the app\n * chrome, and point `href` at the `id` of the main content region.\n *\n * @element skip-link\n * @slot - Optional custom link wording, overriding `label`.\n */\n@customElement(\"skip-link\")\nexport class SkipLink extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: contents;\n }\n /* Hidden at rest with the shared .sr-only clip technique — never\n display:none / visibility:hidden, which would pull the link out of\n the focus order and defeat the entire purpose. Clipped, it stays\n focusable, so Tab reaches it and reveals it.\n\n Pinned with position: fixed, not absolute. An absolutely positioned\n link resolves its insets against the nearest positioned ancestor, so\n dropping the component inside any position: relative container — which\n app-shell's own .shell is — would park the revealed link at that\n container's corner instead of the viewport's, and an overflow: hidden\n ancestor would clip it away entirely. */\n .link {\n position: fixed;\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 top: 0.25rem;\n left: 0.25rem;\n /* Above app-shell's own chrome (.sidebar/.detail/.scrim at 40/40/39)\n so it paints over the top bar when revealed — but a deliberate\n literal below the shared layer stack's base of 100, and it does NOT\n call activateLayer/deactivateLayer. A skip link must never float\n above an open modal-dialog/confirm-dialog/popover-panel/slide-panel\n (all >= 100): that would be a focus escape hatch out of a modal's\n trap, a real bug. 50 sits cleanly in the gap between the shell\n chrome and any real overlay. */\n z-index: 50;\n box-sizing: border-box;\n background: var(--ui-text, #0f172a);\n color: var(--ui-on-accent, #ffffff);\n border-radius: var(--ui-radius-sm, 0.25rem);\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 text-decoration: none;\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n /* Both :focus and :focus-visible: the link is only ever reached by\n keyboard, so revealing it on plain focus is correct here. The visible\n padding lives here rather than on .link, because box-sizing:\n border-box would otherwise floor the clipped 1x1 box at the size of\n its own padding box, leaving an invisible 32px hit target parked over\n the page content. */\n .link:focus,\n .link:focus-visible {\n width: auto;\n height: auto;\n margin: 0;\n overflow: visible;\n clip: auto;\n clip-path: none;\n padding-top: 0.5rem;\n padding-right: 1rem;\n padding-bottom: 0.5rem;\n padding-left: 1rem;\n }\n .link: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 (forced-colors: active) {\n .link {\n background: Canvas;\n color: CanvasText;\n border: 1px solid CanvasText;\n }\n .link:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** The in-page target the link jumps to (the `id` of the main content region). */\n @property() href = \"#main\";\n\n /** Fallback link wording used when nothing is slotted. */\n @property() label = \"Skip to main content\";\n\n /** Whether the default slot holds real wording, as opposed to the whitespace ordinary formatting leaves behind. */\n @state() private _hasSlotted = false;\n\n /**\n * Moves focus to the fragment target, in addition to the native scroll.\n *\n * A plain in-page anchor only moves focus when its target is already\n * focusable, so pointing a skip link at an ordinary `<main id=\"main\">`\n * scrolls the page but strands the keyboard user's focus back at the top —\n * the classic way a skip link silently does nothing. Rather than requiring\n * every consumer to remember `tabindex=\"-1\"`, this applies it to the target\n * on demand. Navigation is never prevented, so the hash still updates.\n */\n #focusTarget(): void {\n const id = this.href.startsWith(\"#\") ? this.href.slice(1) : \"\";\n if (!id) return;\n const root = this.getRootNode() as Document | ShadowRoot;\n const target = root.getElementById?.(id) ?? document.getElementById(id);\n if (!target) return;\n if (!target.hasAttribute(\"tabindex\")) target.setAttribute(\"tabindex\", \"-1\");\n target.focus();\n }\n\n /** Tracks whether the slot holds substantive wording, so whitespace can't strip the link's accessible name. */\n #onSlotChange(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n this._hasSlotted = slot\n .assignedNodes({ flatten: true })\n .some((node) => node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? \"\").trim().length > 0);\n }\n\n override render() {\n return html`<a class=\"link\" href=${this.href} @click=${this.#focusTarget}\n ><slot @slotchange=${this.#onSlotChange}></slot>${this._hasSlotted ? nothing : this.label}</a\n >`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"skip-link\": SkipLink;\n }\n}\n"]}
|
package/dist/slide-panel.js
CHANGED
|
@@ -63,7 +63,7 @@ let SlidePanel = class SlidePanel extends LitElement {
|
|
|
63
63
|
align-items: center;
|
|
64
64
|
justify-content: space-between;
|
|
65
65
|
padding: 0.75rem;
|
|
66
|
-
border-bottom: 1px solid var(--ui-border, #e2e8f0);
|
|
66
|
+
border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
67
67
|
flex: 0 0 auto;
|
|
68
68
|
}
|
|
69
69
|
.panel-title {
|
package/dist/slide-panel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slide-panel.js","sourceRoot":"","sources":["../src/slide-panel.ts"],"names":[],"mappings":";;;;;;AAA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B,CAAC,IAAI,CAAC,IAAI;;;;;iCAKM,IAAI,CAAC,OAAO,IAAI,OAAO;;sEAEc,IAAI,CAAC,MAAM;uCAC1C,KAAK,CAAC,EAAE,CAAC;;;;;KAK3C,CAAC;IACJ,CAAC;CACF,CAAA;AA5L8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAc;AAE9B;IAAX,QAAQ,EAAE;2CAAc;AAJd,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CA8LtB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconX } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport { activateLayer, claimEscape, deactivateLayer } from \"./utils/layer-stack.js\";\n\n/**\n * Generic sliding panel shell. Handles positioning, open/close animation,\n * header chrome, and a close button. Body content is provided via the\n * default slot; the consumer controls its own padding and overflow.\n *\n * Desktop: fixed right-side panel that slides from the right.\n * Mobile (≤48rem): bottom-sheet drawer (60vh) — reserved for future use.\n *\n * @element slide-panel\n * @fires panel-close - User clicked the close (✕) button.\n */\n@customElement(\"slide-panel\")\nexport class SlidePanel extends LitElement {\n /** Whether the panel is currently visible. */\n @property({ type: Boolean }) open = false;\n /** Title text shown in the panel header (overridable via slot=\"title\"). */\n @property() heading = \"\";\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .panel {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n width: 20rem;\n z-index: var(--component-layer-z, 20);\n background: var(--ui-surface, #ffffff);\n box-shadow: var(--ui-shadow-lg, 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1));\n transform: translateX(110%);\n transition: transform 250ms ease;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n .panel.open {\n transform: translateX(0);\n }\n .panel-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0.75rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n flex: 0 0 auto;\n }\n .panel-title {\n font-weight: var(--ui-font-weight-semibold, 600);\n font-size: var(--ui-font-size-lg, 1rem);\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 color: var(--ui-text, #0f172a);\n flex: 1 1 auto;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n padding-right: 0.5rem;\n }\n .close-btn {\n background: none;\n border: none;\n cursor: pointer;\n width: 2rem;\n height: 2rem;\n padding: 0;\n color: var(--ui-text-muted, #64748b);\n border-radius: var(--ui-radius-sm, 0.25rem);\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n .close-btn:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .close-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 .handle {\n display: none;\n }\n @media (prefers-reduced-motion: reduce) {\n .panel {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .close-btn:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n .panel {\n top: auto;\n right: 0;\n bottom: 0;\n left: 0;\n width: auto;\n height: 60vh;\n border-radius: var(--ui-radius, 0.5rem) var(--ui-radius, 0.5rem) 0 0;\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 transform: translateY(110%);\n }\n .panel.open {\n transform: translateY(0);\n }\n .handle {\n display: block;\n width: 2.25rem;\n height: 0.25rem;\n background: var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-pill, 9999px);\n margin: 0.5rem auto 0;\n flex: 0 0 auto;\n }\n .panel-header {\n padding: 0.25rem 0.5rem 0.5rem;\n }\n }\n `,\n ];\n\n private _previousFocus: HTMLElement | null = null;\n\n private _close() {\n this.dispatchEvent(new CustomEvent(\"panel-close\", { bubbles: true, composed: true }));\n }\n\n private _onWindowKeydown = (event: KeyboardEvent): void => {\n if (!this.open || !claimEscape(this, event)) return;\n this._close();\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 window.addEventListener(\"keydown\", this._onWindowKeydown);\n this.shadowRoot?.querySelector<HTMLElement>(\".close-btn\")?.focus();\n return;\n }\n deactivateLayer(this);\n window.removeEventListener(\"keydown\", this._onWindowKeydown);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener(\"keydown\", this._onWindowKeydown);\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 explicitLabel = this.getAttribute(\"aria-label\");\n return html`\n <div\n class=\"panel ${this.open ? \"open\" : \"\"}\"\n role=\"dialog\"\n aria-modal=\"false\"\n aria-label=${explicitLabel ?? nothing}\n aria-labelledby=${explicitLabel ? nothing : \"panel-title\"}\n aria-hidden=${String(!this.open)}\n ?inert=${!this.open}\n >\n <div class=\"handle\" aria-hidden=\"true\"></div>\n <div class=\"panel-header\">\n <span id=\"panel-title\" class=\"panel-title\">\n <slot name=\"title\">${this.heading || \"Panel\"}</slot>\n </span>\n <button class=\"close-btn\" aria-label=\"Close panel\" @click=${this._close}>\n <span aria-hidden=\"true\">${iconX(18)}</span>\n </button>\n </div>\n <slot></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"slide-panel\": SlidePanel;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"slide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aAAa;sBAC3C,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;iBACvB,CAAC,IAAI,CAAC,IAAI;;;;;iCAKM,IAAI,CAAC,OAAO,IAAI,OAAO;;sEAEc,IAAI,CAAC,MAAM;uCAC1C,KAAK,CAAC,EAAE,CAAC;;;;;KAK3C,CAAC;IACJ,CAAC;CACF,CAAA;AA5L8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAc;AAE9B;IAAX,QAAQ,EAAE;2CAAc;AAJd,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CA8LtB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconX } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport { activateLayer, claimEscape, deactivateLayer } from \"./utils/layer-stack.js\";\n\n/**\n * Generic sliding panel shell. Handles positioning, open/close animation,\n * header chrome, and a close button. Body content is provided via the\n * default slot; the consumer controls its own padding and overflow.\n *\n * Desktop: fixed right-side panel that slides from the right.\n * Mobile (≤48rem): bottom-sheet drawer (60vh) — reserved for future use.\n *\n * @element slide-panel\n * @fires panel-close - User clicked the close (✕) button.\n */\n@customElement(\"slide-panel\")\nexport class SlidePanel extends LitElement {\n /** Whether the panel is currently visible. */\n @property({ type: Boolean }) open = false;\n /** Title text shown in the panel header (overridable via slot=\"title\"). */\n @property() heading = \"\";\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .panel {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n width: 20rem;\n z-index: var(--component-layer-z, 20);\n background: var(--ui-surface, #ffffff);\n box-shadow: var(--ui-shadow-lg, 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1));\n transform: translateX(110%);\n transition: transform 250ms ease;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n .panel.open {\n transform: translateX(0);\n }\n .panel-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0.75rem;\n border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n flex: 0 0 auto;\n }\n .panel-title {\n font-weight: var(--ui-font-weight-semibold, 600);\n font-size: var(--ui-font-size-lg, 1rem);\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 color: var(--ui-text, #0f172a);\n flex: 1 1 auto;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n padding-right: 0.5rem;\n }\n .close-btn {\n background: none;\n border: none;\n cursor: pointer;\n width: 2rem;\n height: 2rem;\n padding: 0;\n color: var(--ui-text-muted, #64748b);\n border-radius: var(--ui-radius-sm, 0.25rem);\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n .close-btn:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .close-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 .handle {\n display: none;\n }\n @media (prefers-reduced-motion: reduce) {\n .panel {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .close-btn:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n .panel {\n top: auto;\n right: 0;\n bottom: 0;\n left: 0;\n width: auto;\n height: 60vh;\n border-radius: var(--ui-radius, 0.5rem) var(--ui-radius, 0.5rem) 0 0;\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 transform: translateY(110%);\n }\n .panel.open {\n transform: translateY(0);\n }\n .handle {\n display: block;\n width: 2.25rem;\n height: 0.25rem;\n background: var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-pill, 9999px);\n margin: 0.5rem auto 0;\n flex: 0 0 auto;\n }\n .panel-header {\n padding: 0.25rem 0.5rem 0.5rem;\n }\n }\n `,\n ];\n\n private _previousFocus: HTMLElement | null = null;\n\n private _close() {\n this.dispatchEvent(new CustomEvent(\"panel-close\", { bubbles: true, composed: true }));\n }\n\n private _onWindowKeydown = (event: KeyboardEvent): void => {\n if (!this.open || !claimEscape(this, event)) return;\n this._close();\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 window.addEventListener(\"keydown\", this._onWindowKeydown);\n this.shadowRoot?.querySelector<HTMLElement>(\".close-btn\")?.focus();\n return;\n }\n deactivateLayer(this);\n window.removeEventListener(\"keydown\", this._onWindowKeydown);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener(\"keydown\", this._onWindowKeydown);\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 explicitLabel = this.getAttribute(\"aria-label\");\n return html`\n <div\n class=\"panel ${this.open ? \"open\" : \"\"}\"\n role=\"dialog\"\n aria-modal=\"false\"\n aria-label=${explicitLabel ?? nothing}\n aria-labelledby=${explicitLabel ? nothing : \"panel-title\"}\n aria-hidden=${String(!this.open)}\n ?inert=${!this.open}\n >\n <div class=\"handle\" aria-hidden=\"true\"></div>\n <div class=\"panel-header\">\n <span id=\"panel-title\" class=\"panel-title\">\n <slot name=\"title\">${this.heading || \"Panel\"}</slot>\n </span>\n <button class=\"close-btn\" aria-label=\"Close panel\" @click=${this._close}>\n <span aria-hidden=\"true\">${iconX(18)}</span>\n </button>\n </div>\n <slot></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"slide-panel\": SlidePanel;\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/** One key/value row of a {@link SpecList} in the data-driven `items` path. */
|
|
3
|
+
export interface SpecListItem {
|
|
4
|
+
/** The attribute name, shown as the muted, wide-tracked key. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The attribute value, shown against the key. */
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A key/value specification sheet — the "spec sheet" block on a product page:
|
|
11
|
+
* a muted, wide-tracked key column against a value column, separated by
|
|
12
|
+
* hairline rules (and uppercased under themes that set
|
|
13
|
+
* `--ui-label-transform`). It describes ONE record's attributes, which is
|
|
14
|
+
* what sets it apart from `data-table` (many records, many columns, sorting);
|
|
15
|
+
* `spec-list` is not tabular and renders a real `<dl>`/`<dt>`/`<dd>` structure.
|
|
16
|
+
*
|
|
17
|
+
* Feed it the `items` array for the plain data path, or slot bare `<dt>`/`<dd>`
|
|
18
|
+
* pairs when a value needs a link, a `status-pill`, or other markup — slotted
|
|
19
|
+
* pairs inherit the component's own key/value styling, so no page CSS is
|
|
20
|
+
* needed. A `<div>` wrapping a pair is also accepted as a full-width grouping
|
|
21
|
+
* row, but `::slotted()` cannot reach inside it, so those `dt`/`dd` stay the
|
|
22
|
+
* consumer's to style. Slotted content takes precedence over `items`; with
|
|
23
|
+
* neither, nothing is rendered.
|
|
24
|
+
*
|
|
25
|
+
* @element spec-list
|
|
26
|
+
* @slot - Optional `<dt>`/`<dd>` pairs for values that need custom markup;
|
|
27
|
+
* when present, they replace the `items` path.
|
|
28
|
+
*/
|
|
29
|
+
export declare class SpecList extends LitElement {
|
|
30
|
+
/** The key/value rows for the data-driven path. Ignored when the default slot has content. */
|
|
31
|
+
items: SpecListItem[];
|
|
32
|
+
/**
|
|
33
|
+
* `auto` is the two-column grid that collapses to stacked below `48rem`;
|
|
34
|
+
* `stacked` forces the stacked form at every width.
|
|
35
|
+
*/
|
|
36
|
+
layout: "auto" | "stacked";
|
|
37
|
+
/** Whether to draw a hairline rule between rows; `false` for a dense inline listing. */
|
|
38
|
+
dividers: boolean;
|
|
39
|
+
/** Optional accessible caption rendered above the list; no element or reserved space when empty. */
|
|
40
|
+
caption: string;
|
|
41
|
+
/** Whether the default slot currently has assigned content. */
|
|
42
|
+
private _hasSlotted;
|
|
43
|
+
static styles: import("lit").CSSResult[];
|
|
44
|
+
/** Whether a slot node is real content, ignoring the whitespace ordinary indented markup leaves between children. */
|
|
45
|
+
private static _isContent;
|
|
46
|
+
/** Tracks whether the default slot has content so slotted markup can take precedence over `items`. */
|
|
47
|
+
private _onSlotChange;
|
|
48
|
+
connectedCallback(): void;
|
|
49
|
+
/** The rows, defended against a non-array value assigned at runtime by a JS or HTML consumer. */
|
|
50
|
+
private _rows;
|
|
51
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
52
|
+
}
|
|
53
|
+
declare global {
|
|
54
|
+
interface HTMLElementTagNameMap {
|
|
55
|
+
"spec-list": SpecList;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=spec-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-list.d.ts","sourceRoot":"","sources":["../src/spec-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAIrD,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,8FAA8F;IACnE,KAAK,EAAE,YAAY,EAAE,CAAM;IAEtD;;;OAGG;IAC0B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAU;IAEjE,wFAAwF;IAC5C,QAAQ,UAAQ;IAE5D,oGAAoG;IACxF,OAAO,SAAM;IAEzB,+DAA+D;IACtD,OAAO,CAAC,WAAW,CAAS;IAErC,OAAgB,MAAM,4BAsHpB;IAEF,qHAAqH;IACrH,OAAO,CAAC,MAAM,CAAC,UAAU;IAIzB,sGAAsG;IACtG,OAAO,CAAC,aAAa;IAKZ,iBAAiB,IAAI,IAAI,CAOjC;IAED,iGAAiG;IACjG,OAAO,CAAC,KAAK;IAIJ,MAAM,yCAgBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var SpecList_1;
|
|
8
|
+
import { LitElement, css, html, nothing } from "lit";
|
|
9
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
10
|
+
import { tokens } from "./tokens.js";
|
|
11
|
+
/**
|
|
12
|
+
* A key/value specification sheet — the "spec sheet" block on a product page:
|
|
13
|
+
* a muted, wide-tracked key column against a value column, separated by
|
|
14
|
+
* hairline rules (and uppercased under themes that set
|
|
15
|
+
* `--ui-label-transform`). It describes ONE record's attributes, which is
|
|
16
|
+
* what sets it apart from `data-table` (many records, many columns, sorting);
|
|
17
|
+
* `spec-list` is not tabular and renders a real `<dl>`/`<dt>`/`<dd>` structure.
|
|
18
|
+
*
|
|
19
|
+
* Feed it the `items` array for the plain data path, or slot bare `<dt>`/`<dd>`
|
|
20
|
+
* pairs when a value needs a link, a `status-pill`, or other markup — slotted
|
|
21
|
+
* pairs inherit the component's own key/value styling, so no page CSS is
|
|
22
|
+
* needed. A `<div>` wrapping a pair is also accepted as a full-width grouping
|
|
23
|
+
* row, but `::slotted()` cannot reach inside it, so those `dt`/`dd` stay the
|
|
24
|
+
* consumer's to style. Slotted content takes precedence over `items`; with
|
|
25
|
+
* neither, nothing is rendered.
|
|
26
|
+
*
|
|
27
|
+
* @element spec-list
|
|
28
|
+
* @slot - Optional `<dt>`/`<dd>` pairs for values that need custom markup;
|
|
29
|
+
* when present, they replace the `items` path.
|
|
30
|
+
*/
|
|
31
|
+
let SpecList = class SpecList extends LitElement {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
/** The key/value rows for the data-driven path. Ignored when the default slot has content. */
|
|
35
|
+
this.items = [];
|
|
36
|
+
/**
|
|
37
|
+
* `auto` is the two-column grid that collapses to stacked below `48rem`;
|
|
38
|
+
* `stacked` forces the stacked form at every width.
|
|
39
|
+
*/
|
|
40
|
+
this.layout = "auto";
|
|
41
|
+
/** Whether to draw a hairline rule between rows; `false` for a dense inline listing. */
|
|
42
|
+
this.dividers = true;
|
|
43
|
+
/** Optional accessible caption rendered above the list; no element or reserved space when empty. */
|
|
44
|
+
this.caption = "";
|
|
45
|
+
/** Whether the default slot currently has assigned content. */
|
|
46
|
+
this._hasSlotted = false;
|
|
47
|
+
}
|
|
48
|
+
static { SpecList_1 = this; }
|
|
49
|
+
static { this.styles = [
|
|
50
|
+
tokens,
|
|
51
|
+
css `
|
|
52
|
+
:host {
|
|
53
|
+
display: block;
|
|
54
|
+
font-family: var(
|
|
55
|
+
--ui-font,
|
|
56
|
+
ui-sans-serif,
|
|
57
|
+
system-ui,
|
|
58
|
+
sans-serif,
|
|
59
|
+
"Apple Color Emoji",
|
|
60
|
+
"Segoe UI Emoji",
|
|
61
|
+
"Segoe UI Symbol",
|
|
62
|
+
"Noto Color Emoji"
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
.caption {
|
|
66
|
+
margin: 0 0 0.5rem;
|
|
67
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
68
|
+
font-weight: var(--ui-font-weight-medium, 500);
|
|
69
|
+
letter-spacing: var(--ui-tracking-wide, 0.04em);
|
|
70
|
+
text-transform: var(--ui-label-transform, none);
|
|
71
|
+
color: var(--ui-text-muted, #64748b);
|
|
72
|
+
}
|
|
73
|
+
/* The dl itself is the two-column grid, so a slotted dt/dd pair is a
|
|
74
|
+
direct slottable and can be styled by this stylesheet. Nesting each
|
|
75
|
+
pair in a wrapper element instead would put the dt/dd a level deeper
|
|
76
|
+
than ::slotted() can reach, leaving slotted keys and values entirely
|
|
77
|
+
unstyled — including the dd's 40px UA margin and the min-width: 0 that
|
|
78
|
+
keeps a long value from overflowing the grid column. */
|
|
79
|
+
.list {
|
|
80
|
+
margin: 0;
|
|
81
|
+
display: grid;
|
|
82
|
+
grid-template-columns: 11rem minmax(0, 1fr);
|
|
83
|
+
}
|
|
84
|
+
.list.empty {
|
|
85
|
+
display: none;
|
|
86
|
+
}
|
|
87
|
+
dt,
|
|
88
|
+
::slotted(dt) {
|
|
89
|
+
/* The column gap is padding on the key rather than column-gap, so a
|
|
90
|
+
divider draws as one unbroken rule across both columns. */
|
|
91
|
+
padding: 0.5rem 0.75rem 0.5rem 0;
|
|
92
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
93
|
+
font-weight: var(--ui-font-weight-medium, 500);
|
|
94
|
+
letter-spacing: var(--ui-tracking-wide, 0.04em);
|
|
95
|
+
text-transform: var(--ui-label-transform, none);
|
|
96
|
+
line-height: var(--ui-line-height-normal, 1.5);
|
|
97
|
+
color: var(--ui-text-muted, #64748b);
|
|
98
|
+
}
|
|
99
|
+
dd,
|
|
100
|
+
::slotted(dd) {
|
|
101
|
+
margin: 0;
|
|
102
|
+
min-width: 0;
|
|
103
|
+
padding: 0.5rem 0;
|
|
104
|
+
font-size: var(--ui-font-size, 0.875rem);
|
|
105
|
+
line-height: var(--ui-line-height-normal, 1.5);
|
|
106
|
+
color: var(--ui-text, #0f172a);
|
|
107
|
+
word-break: break-word;
|
|
108
|
+
}
|
|
109
|
+
:host([dividers]) dt,
|
|
110
|
+
:host([dividers]) dd,
|
|
111
|
+
:host([dividers]) ::slotted(dt),
|
|
112
|
+
:host([dividers]) ::slotted(dd) {
|
|
113
|
+
border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
114
|
+
}
|
|
115
|
+
:host([dividers]) dt:last-of-type,
|
|
116
|
+
:host([dividers]) dd:last-of-type,
|
|
117
|
+
:host([dividers]) ::slotted(dt:last-of-type),
|
|
118
|
+
:host([dividers]) ::slotted(dd:last-of-type) {
|
|
119
|
+
border-bottom: none;
|
|
120
|
+
}
|
|
121
|
+
/* A slotted wrapper element still groups a pair, but this stylesheet
|
|
122
|
+
cannot reach the dt/dd inside it — the consumer styles those. */
|
|
123
|
+
::slotted(div) {
|
|
124
|
+
grid-column: 1 / -1;
|
|
125
|
+
display: grid;
|
|
126
|
+
grid-template-columns: 11rem minmax(0, 1fr);
|
|
127
|
+
column-gap: 0.75rem;
|
|
128
|
+
padding: 0.5rem 0;
|
|
129
|
+
}
|
|
130
|
+
:host([dividers]) ::slotted(div) {
|
|
131
|
+
border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
132
|
+
}
|
|
133
|
+
:host([dividers]) ::slotted(div:last-of-type) {
|
|
134
|
+
border-bottom: none;
|
|
135
|
+
}
|
|
136
|
+
/* Stacked: one column, and the rule sits under the value only, since the
|
|
137
|
+
key and value are now two rows of one logical row. */
|
|
138
|
+
:host([layout="stacked"]) .list,
|
|
139
|
+
:host([layout="stacked"]) ::slotted(div) {
|
|
140
|
+
grid-template-columns: minmax(0, 1fr);
|
|
141
|
+
}
|
|
142
|
+
:host([layout="stacked"]) dt,
|
|
143
|
+
:host([layout="stacked"]) ::slotted(dt) {
|
|
144
|
+
padding: 0.5rem 0 0;
|
|
145
|
+
border-bottom: none;
|
|
146
|
+
}
|
|
147
|
+
:host([layout="stacked"]) dd,
|
|
148
|
+
:host([layout="stacked"]) ::slotted(dd) {
|
|
149
|
+
padding: 0.25rem 0 0.5rem;
|
|
150
|
+
}
|
|
151
|
+
@media (max-width: 48rem) {
|
|
152
|
+
:host([layout="auto"]) .list,
|
|
153
|
+
:host([layout="auto"]) ::slotted(div) {
|
|
154
|
+
grid-template-columns: minmax(0, 1fr);
|
|
155
|
+
}
|
|
156
|
+
:host([layout="auto"]) dt,
|
|
157
|
+
:host([layout="auto"]) ::slotted(dt) {
|
|
158
|
+
padding: 0.5rem 0 0;
|
|
159
|
+
border-bottom: none;
|
|
160
|
+
}
|
|
161
|
+
:host([layout="auto"]) dd,
|
|
162
|
+
:host([layout="auto"]) ::slotted(dd) {
|
|
163
|
+
padding: 0.25rem 0 0.5rem;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
`,
|
|
167
|
+
]; }
|
|
168
|
+
/** Whether a slot node is real content, ignoring the whitespace ordinary indented markup leaves between children. */
|
|
169
|
+
static _isContent(node) {
|
|
170
|
+
return node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? "").trim().length > 0;
|
|
171
|
+
}
|
|
172
|
+
/** Tracks whether the default slot has content so slotted markup can take precedence over `items`. */
|
|
173
|
+
_onSlotChange(event) {
|
|
174
|
+
const slot = event.target;
|
|
175
|
+
this._hasSlotted = slot.assignedNodes({ flatten: true }).some(SpecList_1._isContent);
|
|
176
|
+
}
|
|
177
|
+
connectedCallback() {
|
|
178
|
+
super.connectedCallback();
|
|
179
|
+
// slotchange only fires after the first render, so without seeding from the
|
|
180
|
+
// light DOM here an element given both items and slotted markup renders
|
|
181
|
+
// both paths for its first update — visible to anything awaiting
|
|
182
|
+
// updateComplete, and contrary to the documented "slot wins" contract.
|
|
183
|
+
this._hasSlotted = Array.from(this.childNodes).some(SpecList_1._isContent);
|
|
184
|
+
}
|
|
185
|
+
/** The rows, defended against a non-array value assigned at runtime by a JS or HTML consumer. */
|
|
186
|
+
_rows() {
|
|
187
|
+
return Array.isArray(this.items) ? this.items.filter((item) => item != null) : [];
|
|
188
|
+
}
|
|
189
|
+
render() {
|
|
190
|
+
const rows = this._rows();
|
|
191
|
+
const showItems = !this._hasSlotted && rows.length > 0;
|
|
192
|
+
const empty = !this._hasSlotted && rows.length === 0;
|
|
193
|
+
return html `
|
|
194
|
+
${this.caption ? html `<div class="caption" id="caption">${this.caption}</div>` : nothing}
|
|
195
|
+
<dl
|
|
196
|
+
class="list ${empty ? "empty" : ""}"
|
|
197
|
+
aria-labelledby=${this.caption ? "caption" : nothing}
|
|
198
|
+
>
|
|
199
|
+
${showItems
|
|
200
|
+
? rows.map((item) => html `<dt>${item.label}</dt><dd>${item.value}</dd>`)
|
|
201
|
+
: nothing}
|
|
202
|
+
<slot @slotchange=${this._onSlotChange}></slot>
|
|
203
|
+
</dl>
|
|
204
|
+
`;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
__decorate([
|
|
208
|
+
property({ type: Array })
|
|
209
|
+
], SpecList.prototype, "items", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
property({ reflect: true })
|
|
212
|
+
], SpecList.prototype, "layout", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
property({ type: Boolean, reflect: true })
|
|
215
|
+
], SpecList.prototype, "dividers", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
property()
|
|
218
|
+
], SpecList.prototype, "caption", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
state()
|
|
221
|
+
], SpecList.prototype, "_hasSlotted", void 0);
|
|
222
|
+
SpecList = SpecList_1 = __decorate([
|
|
223
|
+
customElement("spec-list")
|
|
224
|
+
], SpecList);
|
|
225
|
+
export { SpecList };
|
|
226
|
+
//# sourceMappingURL=spec-list.js.map
|