@f-ewald/components 1.40.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/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/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/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/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/empty-state.md +6 -1
- package/docs/skip-link.md +10 -3
- package/docs/spec-list.md +18 -10
- package/llms.txt +23 -12
- package/package.json +1 -1
package/dist/empty-state.js
CHANGED
|
@@ -4,6 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
var EmptyState_1;
|
|
7
8
|
import { LitElement, css, html, nothing } from "lit";
|
|
8
9
|
import { customElement, property, state } from "lit/decorators.js";
|
|
9
10
|
import { tokens } from "./tokens.js";
|
|
@@ -29,6 +30,14 @@ let EmptyState = class EmptyState extends LitElement {
|
|
|
29
30
|
this.description = "";
|
|
30
31
|
/** `sm` for a small panel/sidebar, `md` (default) for a full page region. `md` matches the pre-`size` look exactly. */
|
|
31
32
|
this.size = "md";
|
|
33
|
+
/**
|
|
34
|
+
* Heading rank the `heading` is exposed as, 1-6. An `empty-state` fills a
|
|
35
|
+
* page, a panel, or a sidebar, so no single rank is right everywhere; set
|
|
36
|
+
* this to whatever the surrounding outline needs. Applied via `aria-level`
|
|
37
|
+
* on the rendered `h2`, which overrides the element's native rank for
|
|
38
|
+
* assistive technology.
|
|
39
|
+
*/
|
|
40
|
+
this.headingLevel = 2;
|
|
32
41
|
/** Whether the icon slot currently has assigned content. */
|
|
33
42
|
this._hasIcon = false;
|
|
34
43
|
/** Whether the default (body) slot currently has assigned content. */
|
|
@@ -36,6 +45,7 @@ let EmptyState = class EmptyState extends LitElement {
|
|
|
36
45
|
/** Whether the actions slot currently has assigned content. */
|
|
37
46
|
this._hasActions = false;
|
|
38
47
|
}
|
|
48
|
+
static { EmptyState_1 = this; }
|
|
39
49
|
static { this.styles = [
|
|
40
50
|
tokens,
|
|
41
51
|
css `
|
|
@@ -114,20 +124,36 @@ let EmptyState = class EmptyState extends LitElement {
|
|
|
114
124
|
}
|
|
115
125
|
`,
|
|
116
126
|
]; }
|
|
127
|
+
/**
|
|
128
|
+
* Whether a slot holds real content. Whitespace-only text nodes don't count:
|
|
129
|
+
* ordinary indented markup puts a newline between every child, which would
|
|
130
|
+
* otherwise mark every slot as filled and reserve space for rows that are
|
|
131
|
+
* visually empty.
|
|
132
|
+
*/
|
|
133
|
+
static _slotHasContent(event) {
|
|
134
|
+
const slot = event.target;
|
|
135
|
+
return slot
|
|
136
|
+
.assignedNodes({ flatten: true })
|
|
137
|
+
.some((node) => node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? "").trim().length > 0);
|
|
138
|
+
}
|
|
117
139
|
/** Tracks whether the icon slot has content so its row can collapse when empty. */
|
|
118
140
|
_onIconSlotChange(event) {
|
|
119
|
-
|
|
120
|
-
this._hasIcon = slot.assignedNodes({ flatten: true }).length > 0;
|
|
141
|
+
this._hasIcon = EmptyState_1._slotHasContent(event);
|
|
121
142
|
}
|
|
122
143
|
/** Tracks whether the default body slot has content so its row can collapse when empty. */
|
|
123
144
|
_onBodySlotChange(event) {
|
|
124
|
-
|
|
125
|
-
this._hasBody = slot.assignedNodes({ flatten: true }).length > 0;
|
|
145
|
+
this._hasBody = EmptyState_1._slotHasContent(event);
|
|
126
146
|
}
|
|
127
147
|
/** Tracks whether the actions slot has content so its row can collapse when empty. */
|
|
128
148
|
_onActionsSlotChange(event) {
|
|
129
|
-
|
|
130
|
-
|
|
149
|
+
this._hasActions = EmptyState_1._slotHasContent(event);
|
|
150
|
+
}
|
|
151
|
+
/** Clamps `headingLevel` into the valid 1-6 heading range, falling back to 2 for a non-numeric value. */
|
|
152
|
+
#level() {
|
|
153
|
+
const level = Math.trunc(Number(this.headingLevel));
|
|
154
|
+
if (!Number.isFinite(level))
|
|
155
|
+
return 2;
|
|
156
|
+
return Math.min(6, Math.max(1, level));
|
|
131
157
|
}
|
|
132
158
|
render() {
|
|
133
159
|
return html `
|
|
@@ -135,7 +161,9 @@ let EmptyState = class EmptyState extends LitElement {
|
|
|
135
161
|
<span class="icon ${this._hasIcon ? "" : "empty"}">
|
|
136
162
|
<slot name="icon" @slotchange=${this._onIconSlotChange}></slot>
|
|
137
163
|
</span>
|
|
138
|
-
${this.heading
|
|
164
|
+
${this.heading
|
|
165
|
+
? html `<h2 class="heading" aria-level=${this.#level()}>${this.heading}</h2>`
|
|
166
|
+
: nothing}
|
|
139
167
|
${this.description ? html `<p class="description">${this.description}</p>` : nothing}
|
|
140
168
|
<div class="body ${this._hasBody ? "" : "empty"}">
|
|
141
169
|
<slot @slotchange=${this._onBodySlotChange}></slot>
|
|
@@ -156,6 +184,9 @@ __decorate([
|
|
|
156
184
|
__decorate([
|
|
157
185
|
property({ reflect: true })
|
|
158
186
|
], EmptyState.prototype, "size", void 0);
|
|
187
|
+
__decorate([
|
|
188
|
+
property({ type: Number, attribute: "heading-level" })
|
|
189
|
+
], EmptyState.prototype, "headingLevel", void 0);
|
|
159
190
|
__decorate([
|
|
160
191
|
state()
|
|
161
192
|
], EmptyState.prototype, "_hasIcon", void 0);
|
|
@@ -165,7 +196,7 @@ __decorate([
|
|
|
165
196
|
__decorate([
|
|
166
197
|
state()
|
|
167
198
|
], EmptyState.prototype, "_hasActions", void 0);
|
|
168
|
-
EmptyState = __decorate([
|
|
199
|
+
EmptyState = EmptyState_1 = __decorate([
|
|
169
200
|
customElement("empty-state")
|
|
170
201
|
], EmptyState);
|
|
171
202
|
export { EmptyState };
|
package/dist/empty-state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empty-state.js","sourceRoot":"","sources":["../src/empty-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"empty-state.js","sourceRoot":"","sources":["../src/empty-state.ts"],"names":[],"mappings":"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","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * A centered placeholder for an empty list, an empty panel, or a zero-result\n * search: an optional leading glyph, a heading, a supporting line (or richer\n * slotted body), and an optional call-to-action row. Purely presentational —\n * it carries no interactive state of its own and no ARIA `role`; it is a\n * region of content, not a live status. Every optional part collapses\n * completely when absent, reserving no layout space.\n *\n * @element empty-state\n * @slot icon - Optional leading glyph. The consumer supplies it (e.g. an inline SVG icon).\n * @slot - Optional rich body content, an alternative to `description`.\n * @slot actions - Optional call to action, e.g. a `ui-button`.\n */\n@customElement(\"empty-state\")\nexport class EmptyState extends LitElement {\n /** The primary line. */\n @property() heading = \"\";\n\n /** The supporting line under the heading. Omitted entirely when empty. */\n @property() description = \"\";\n\n /** `sm` for a small panel/sidebar, `md` (default) for a full page region. `md` matches the pre-`size` look exactly. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n /**\n * Heading rank the `heading` is exposed as, 1-6. An `empty-state` fills a\n * page, a panel, or a sidebar, so no single rank is right everywhere; set\n * this to whatever the surrounding outline needs. Applied via `aria-level`\n * on the rendered `h2`, which overrides the element's native rank for\n * assistive technology.\n */\n @property({ type: Number, attribute: \"heading-level\" }) headingLevel = 2;\n\n /** Whether the icon slot currently has assigned content. */\n @state() private _hasIcon = false;\n\n /** Whether the default (body) slot currently has assigned content. */\n @state() private _hasBody = false;\n\n /** Whether the actions slot currently has assigned content. */\n @state() private _hasActions = 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 .state {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n padding: 2rem 1rem;\n }\n :host([size=\"sm\"]) .state {\n padding: 1rem 0.75rem;\n }\n .icon {\n display: inline-flex;\n margin-bottom: 0.75rem;\n color: var(--ui-text-muted, #64748b);\n }\n :host([size=\"sm\"]) .icon {\n margin-bottom: 0.5rem;\n }\n .heading {\n margin: 0;\n font-size: var(--ui-font-size-lg, 1rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n }\n :host([size=\"sm\"]) .heading {\n font-size: var(--ui-font-size, 0.875rem);\n }\n .description {\n margin: 0.5rem 0 0;\n max-width: 32rem;\n font-size: var(--ui-font-size, 0.875rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text-muted, #64748b);\n }\n :host([size=\"sm\"]) .description {\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n .body {\n margin-top: 0.5rem;\n color: var(--ui-text-muted, #64748b);\n }\n .body.empty {\n display: none;\n }\n .actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n margin-top: 1rem;\n }\n .actions.empty {\n display: none;\n }\n .icon.empty {\n display: none;\n }\n `,\n ];\n\n /**\n * Whether a slot holds real content. Whitespace-only text nodes don't count:\n * ordinary indented markup puts a newline between every child, which would\n * otherwise mark every slot as filled and reserve space for rows that are\n * visually empty.\n */\n private static _slotHasContent(event: Event): boolean {\n const slot = event.target as HTMLSlotElement;\n return slot\n .assignedNodes({ flatten: true })\n .some((node) => node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? \"\").trim().length > 0);\n }\n\n /** Tracks whether the icon slot has content so its row can collapse when empty. */\n private _onIconSlotChange(event: Event): void {\n this._hasIcon = EmptyState._slotHasContent(event);\n }\n\n /** Tracks whether the default body slot has content so its row can collapse when empty. */\n private _onBodySlotChange(event: Event): void {\n this._hasBody = EmptyState._slotHasContent(event);\n }\n\n /** Tracks whether the actions slot has content so its row can collapse when empty. */\n private _onActionsSlotChange(event: Event): void {\n this._hasActions = EmptyState._slotHasContent(event);\n }\n\n /** Clamps `headingLevel` into the valid 1-6 heading range, falling back to 2 for a non-numeric value. */\n #level(): number {\n const level = Math.trunc(Number(this.headingLevel));\n if (!Number.isFinite(level)) return 2;\n return Math.min(6, Math.max(1, level));\n }\n\n override render() {\n return html`\n <div class=\"state\">\n <span class=\"icon ${this._hasIcon ? \"\" : \"empty\"}\">\n <slot name=\"icon\" @slotchange=${this._onIconSlotChange}></slot>\n </span>\n ${this.heading\n ? html`<h2 class=\"heading\" aria-level=${this.#level()}>${this.heading}</h2>`\n : nothing}\n ${this.description ? html`<p class=\"description\">${this.description}</p>` : nothing}\n <div class=\"body ${this._hasBody ? \"\" : \"empty\"}\">\n <slot @slotchange=${this._onBodySlotChange}></slot>\n </div>\n <div class=\"actions ${this._hasActions ? \"\" : \"empty\"}\">\n <slot name=\"actions\" @slotchange=${this._onActionsSlotChange}></slot>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"empty-state\": EmptyState;\n }\n}\n"]}
|
package/dist/skip-link.d.ts
CHANGED
|
@@ -5,8 +5,13 @@ import { LitElement } from "lit";
|
|
|
5
5
|
* visually hidden (but in the focus order) until it receives keyboard focus,
|
|
6
6
|
* then pins itself to the top-left of the viewport as a solid, high-contrast
|
|
7
7
|
* block so a keyboard or screen-reader user can jump straight past repeated
|
|
8
|
-
* page chrome to the main content.
|
|
9
|
-
*
|
|
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.
|
|
10
15
|
*
|
|
11
16
|
* Place it as the very first focusable element on the page, before the app
|
|
12
17
|
* chrome, and point `href` at the `id` of the main content region.
|
|
@@ -15,11 +20,14 @@ import { LitElement } from "lit";
|
|
|
15
20
|
* @slot - Optional custom link wording, overriding `label`.
|
|
16
21
|
*/
|
|
17
22
|
export declare class SkipLink extends LitElement {
|
|
23
|
+
#private;
|
|
18
24
|
static styles: import("lit").CSSResult[];
|
|
19
25
|
/** The in-page target the link jumps to (the `id` of the main content region). */
|
|
20
26
|
href: string;
|
|
21
27
|
/** Fallback link wording used when nothing is slotted. */
|
|
22
28
|
label: string;
|
|
29
|
+
/** Whether the default slot holds real wording, as opposed to the whitespace ordinary formatting leaves behind. */
|
|
30
|
+
private _hasSlotted;
|
|
23
31
|
render(): import("lit-html").TemplateResult<1>;
|
|
24
32
|
}
|
|
25
33
|
declare global {
|
package/dist/skip-link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-link.d.ts","sourceRoot":"","sources":["../src/skip-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
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"}
|
package/dist/skip-link.js
CHANGED
|
@@ -4,8 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { LitElement, css, html } from "lit";
|
|
8
|
-
import { customElement, property } from "lit/decorators.js";
|
|
7
|
+
import { LitElement, css, html, nothing } from "lit";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
9
|
import { tokens } from "./tokens.js";
|
|
10
10
|
/**
|
|
11
11
|
* "Skip to main content" bypass link — the package's first pure
|
|
@@ -13,8 +13,13 @@ import { tokens } from "./tokens.js";
|
|
|
13
13
|
* visually hidden (but in the focus order) until it receives keyboard focus,
|
|
14
14
|
* then pins itself to the top-left of the viewport as a solid, high-contrast
|
|
15
15
|
* block so a keyboard or screen-reader user can jump straight past repeated
|
|
16
|
-
* page chrome to the main content.
|
|
17
|
-
*
|
|
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.
|
|
18
23
|
*
|
|
19
24
|
* Place it as the very first focusable element on the page, before the app
|
|
20
25
|
* chrome, and point `href` at the `id` of the main content region.
|
|
@@ -29,6 +34,8 @@ let SkipLink = class SkipLink extends LitElement {
|
|
|
29
34
|
this.href = "#main";
|
|
30
35
|
/** Fallback link wording used when nothing is slotted. */
|
|
31
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;
|
|
32
39
|
}
|
|
33
40
|
static { this.styles = [
|
|
34
41
|
tokens,
|
|
@@ -39,9 +46,16 @@ let SkipLink = class SkipLink extends LitElement {
|
|
|
39
46
|
/* Hidden at rest with the shared .sr-only clip technique — never
|
|
40
47
|
display:none / visibility:hidden, which would pull the link out of
|
|
41
48
|
the focus order and defeat the entire purpose. Clipped, it stays
|
|
42
|
-
focusable, so Tab reaches it and reveals it.
|
|
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. */
|
|
43
57
|
.link {
|
|
44
|
-
position:
|
|
58
|
+
position: fixed;
|
|
45
59
|
width: 1px;
|
|
46
60
|
height: 1px;
|
|
47
61
|
margin: -1px;
|
|
@@ -119,8 +133,39 @@ let SkipLink = class SkipLink extends LitElement {
|
|
|
119
133
|
}
|
|
120
134
|
`,
|
|
121
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
|
+
}
|
|
122
165
|
render() {
|
|
123
|
-
return html `<a class="link" href=${this.href}
|
|
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
|
+
>`;
|
|
124
169
|
}
|
|
125
170
|
};
|
|
126
171
|
__decorate([
|
|
@@ -129,6 +174,9 @@ __decorate([
|
|
|
129
174
|
__decorate([
|
|
130
175
|
property()
|
|
131
176
|
], SkipLink.prototype, "label", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
state()
|
|
179
|
+
], SkipLink.prototype, "_hasSlotted", void 0);
|
|
132
180
|
SkipLink = __decorate([
|
|
133
181
|
customElement("skip-link")
|
|
134
182
|
], SkipLink);
|
package/dist/skip-link.js.map
CHANGED
|
@@ -1 +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,MAAM,KAAK,CAAC;
|
|
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,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,IAAI,CAAC,EAAE;YAAE,OAAO;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAA2B,CAAC;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC;YAAE,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC5E,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAED,+GAA+G;IAC/G,aAAa,CAAC,KAAY;QACxB,MAAM,IAAI,GAAG,KAAK,CAAC,MAAyB,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,IAAI;aACpB,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;aAChC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvG,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,wBAAwB,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,YAAY;2BACjD,IAAI,CAAC,aAAa,WAAW,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;MACzF,CAAC;IACL,CAAC;CACF,CAAA;AAzCa;IAAX,QAAQ,EAAE;sCAAgB;AAGf;IAAX,QAAQ,EAAE;uCAAgC;AAG1B;IAAhB,KAAK,EAAE;6CAA6B;AAzG1B,QAAQ;IADpB,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/spec-list.d.ts
CHANGED
|
@@ -8,19 +8,23 @@ export interface SpecListItem {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* A key/value specification sheet — the "spec sheet" block on a product page:
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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
|
|
13
14
|
* what sets it apart from `data-table` (many records, many columns, sorting);
|
|
14
15
|
* `spec-list` is not tabular and renders a real `<dl>`/`<dt>`/`<dd>` structure.
|
|
15
16
|
*
|
|
16
|
-
* Feed it the `items` array for the plain data path, or slot
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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.
|
|
20
24
|
*
|
|
21
25
|
* @element spec-list
|
|
22
|
-
* @slot - Optional `<
|
|
23
|
-
*
|
|
26
|
+
* @slot - Optional `<dt>`/`<dd>` pairs for values that need custom markup;
|
|
27
|
+
* when present, they replace the `items` path.
|
|
24
28
|
*/
|
|
25
29
|
export declare class SpecList extends LitElement {
|
|
26
30
|
/** The key/value rows for the data-driven path. Ignored when the default slot has content. */
|
|
@@ -37,8 +41,13 @@ export declare class SpecList extends LitElement {
|
|
|
37
41
|
/** Whether the default slot currently has assigned content. */
|
|
38
42
|
private _hasSlotted;
|
|
39
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;
|
|
40
46
|
/** Tracks whether the default slot has content so slotted markup can take precedence over `items`. */
|
|
41
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;
|
|
42
51
|
render(): import("lit-html").TemplateResult<1>;
|
|
43
52
|
}
|
|
44
53
|
declare global {
|
package/dist/spec-list.d.ts.map
CHANGED
|
@@ -1 +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
|
|
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"}
|
package/dist/spec-list.js
CHANGED
|
@@ -4,24 +4,29 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
var SpecList_1;
|
|
7
8
|
import { LitElement, css, html, nothing } from "lit";
|
|
8
9
|
import { customElement, property, state } from "lit/decorators.js";
|
|
9
10
|
import { tokens } from "./tokens.js";
|
|
10
11
|
/**
|
|
11
12
|
* A key/value specification sheet — the "spec sheet" block on a product page:
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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
|
|
14
16
|
* what sets it apart from `data-table` (many records, many columns, sorting);
|
|
15
17
|
* `spec-list` is not tabular and renders a real `<dl>`/`<dt>`/`<dd>` structure.
|
|
16
18
|
*
|
|
17
|
-
* Feed it the `items` array for the plain data path, or slot
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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.
|
|
21
26
|
*
|
|
22
27
|
* @element spec-list
|
|
23
|
-
* @slot - Optional `<
|
|
24
|
-
*
|
|
28
|
+
* @slot - Optional `<dt>`/`<dd>` pairs for values that need custom markup;
|
|
29
|
+
* when present, they replace the `items` path.
|
|
25
30
|
*/
|
|
26
31
|
let SpecList = class SpecList extends LitElement {
|
|
27
32
|
constructor() {
|
|
@@ -40,6 +45,7 @@ let SpecList = class SpecList extends LitElement {
|
|
|
40
45
|
/** Whether the default slot currently has assigned content. */
|
|
41
46
|
this._hasSlotted = false;
|
|
42
47
|
}
|
|
48
|
+
static { SpecList_1 = this; }
|
|
43
49
|
static { this.styles = [
|
|
44
50
|
tokens,
|
|
45
51
|
css `
|
|
@@ -64,30 +70,25 @@ let SpecList = class SpecList extends LitElement {
|
|
|
64
70
|
text-transform: var(--ui-label-transform, none);
|
|
65
71
|
color: var(--ui-text-muted, #64748b);
|
|
66
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. */
|
|
67
79
|
.list {
|
|
68
80
|
margin: 0;
|
|
69
|
-
}
|
|
70
|
-
.list.empty {
|
|
71
|
-
display: none;
|
|
72
|
-
}
|
|
73
|
-
/* Both the data-driven rows and the slotted div groups are laid out as
|
|
74
|
-
the same two-column grid so the two paths line up identically. */
|
|
75
|
-
.row,
|
|
76
|
-
::slotted(*) {
|
|
77
81
|
display: grid;
|
|
78
82
|
grid-template-columns: 11rem minmax(0, 1fr);
|
|
79
|
-
column-gap: 0.75rem;
|
|
80
|
-
padding: 0.5rem 0;
|
|
81
|
-
}
|
|
82
|
-
:host([dividers]) .row,
|
|
83
|
-
:host([dividers]) ::slotted(*) {
|
|
84
|
-
border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
85
83
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
border-bottom: none;
|
|
84
|
+
.list.empty {
|
|
85
|
+
display: none;
|
|
89
86
|
}
|
|
90
|
-
|
|
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;
|
|
91
92
|
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
92
93
|
font-weight: var(--ui-font-weight-medium, 500);
|
|
93
94
|
letter-spacing: var(--ui-tracking-wide, 0.04em);
|
|
@@ -95,38 +96,100 @@ let SpecList = class SpecList extends LitElement {
|
|
|
95
96
|
line-height: var(--ui-line-height-normal, 1.5);
|
|
96
97
|
color: var(--ui-text-muted, #64748b);
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
+
dd,
|
|
100
|
+
::slotted(dd) {
|
|
99
101
|
margin: 0;
|
|
100
102
|
min-width: 0;
|
|
103
|
+
padding: 0.5rem 0;
|
|
101
104
|
font-size: var(--ui-font-size, 0.875rem);
|
|
102
105
|
line-height: var(--ui-line-height-normal, 1.5);
|
|
103
106
|
color: var(--ui-text, #0f172a);
|
|
104
107
|
word-break: break-word;
|
|
105
108
|
}
|
|
106
|
-
:host([
|
|
107
|
-
:host([
|
|
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) {
|
|
108
140
|
grid-template-columns: minmax(0, 1fr);
|
|
109
|
-
|
|
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;
|
|
110
150
|
}
|
|
111
151
|
@media (max-width: 48rem) {
|
|
112
|
-
:host([layout="auto"]) .
|
|
113
|
-
:host([layout="auto"]) ::slotted(
|
|
152
|
+
:host([layout="auto"]) .list,
|
|
153
|
+
:host([layout="auto"]) ::slotted(div) {
|
|
114
154
|
grid-template-columns: minmax(0, 1fr);
|
|
115
|
-
|
|
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;
|
|
116
164
|
}
|
|
117
165
|
}
|
|
118
166
|
`,
|
|
119
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
|
+
}
|
|
120
172
|
/** Tracks whether the default slot has content so slotted markup can take precedence over `items`. */
|
|
121
173
|
_onSlotChange(event) {
|
|
122
174
|
const slot = event.target;
|
|
123
|
-
this._hasSlotted = slot.assignedNodes({ flatten: true }).some(
|
|
124
|
-
|
|
125
|
-
|
|
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) : [];
|
|
126
188
|
}
|
|
127
189
|
render() {
|
|
128
|
-
const
|
|
129
|
-
const
|
|
190
|
+
const rows = this._rows();
|
|
191
|
+
const showItems = !this._hasSlotted && rows.length > 0;
|
|
192
|
+
const empty = !this._hasSlotted && rows.length === 0;
|
|
130
193
|
return html `
|
|
131
194
|
${this.caption ? html `<div class="caption" id="caption">${this.caption}</div>` : nothing}
|
|
132
195
|
<dl
|
|
@@ -134,12 +197,7 @@ let SpecList = class SpecList extends LitElement {
|
|
|
134
197
|
aria-labelledby=${this.caption ? "caption" : nothing}
|
|
135
198
|
>
|
|
136
199
|
${showItems
|
|
137
|
-
?
|
|
138
|
-
<div class="row">
|
|
139
|
-
<dt>${item.label}</dt>
|
|
140
|
-
<dd>${item.value}</dd>
|
|
141
|
-
</div>
|
|
142
|
-
`)
|
|
200
|
+
? rows.map((item) => html `<dt>${item.label}</dt><dd>${item.value}</dd>`)
|
|
143
201
|
: nothing}
|
|
144
202
|
<slot @slotchange=${this._onSlotChange}></slot>
|
|
145
203
|
</dl>
|
|
@@ -161,7 +219,7 @@ __decorate([
|
|
|
161
219
|
__decorate([
|
|
162
220
|
state()
|
|
163
221
|
], SpecList.prototype, "_hasSlotted", void 0);
|
|
164
|
-
SpecList = __decorate([
|
|
222
|
+
SpecList = SpecList_1 = __decorate([
|
|
165
223
|
customElement("spec-list")
|
|
166
224
|
], SpecList);
|
|
167
225
|
export { SpecList };
|