@adobe/spectrum-wc-core 2.0.0-beta.2 → 2.0.0-next.20260728161641

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.
Files changed (58) hide show
  1. package/dist/components/accordion/AccordionItem.base.d.ts +16 -6
  2. package/dist/components/accordion/AccordionItem.base.js +6 -3
  3. package/dist/components/accordion/AccordionItem.base.js.map +1 -1
  4. package/dist/components/badge/Badge.base.d.ts +24 -8
  5. package/dist/components/badge/Badge.base.js +8 -5
  6. package/dist/components/badge/Badge.base.js.map +1 -1
  7. package/dist/components/button/Button.base.d.ts +16 -9
  8. package/dist/components/button/Button.base.js +7 -5
  9. package/dist/components/button/Button.base.js.map +1 -1
  10. package/dist/components/card/Card.base.d.ts +94 -46
  11. package/dist/components/card/Card.base.js +58 -19
  12. package/dist/components/card/Card.base.js.map +1 -1
  13. package/dist/components/card/Card.types.d.ts +1 -0
  14. package/dist/components/card/Card.types.js +2 -2
  15. package/dist/components/card/Card.types.js.map +1 -1
  16. package/dist/components/card/index.js +3 -3
  17. package/dist/controllers/index.d.ts +2 -0
  18. package/dist/controllers/index.js +13 -11
  19. package/dist/controllers/slot-presence-controller/index.d.ts +12 -0
  20. package/dist/controllers/slot-presence-controller/index.js +2 -0
  21. package/dist/controllers/slot-presence-controller/src/slot-presence-controller.d.ts +57 -0
  22. package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js +44 -0
  23. package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js.map +1 -0
  24. package/dist/controllers/slot-text-controller/index.d.ts +12 -0
  25. package/dist/controllers/slot-text-controller/index.js +2 -0
  26. package/dist/controllers/slot-text-controller/src/slot-text-controller.d.ts +92 -0
  27. package/dist/controllers/slot-text-controller/src/slot-text-controller.js +53 -0
  28. package/dist/controllers/slot-text-controller/src/slot-text-controller.js.map +1 -0
  29. package/dist/element/index.d.ts +1 -1
  30. package/dist/element/index.js +2 -2
  31. package/dist/element/spectrum-element.d.ts +2 -17
  32. package/dist/element/spectrum-element.js +9 -26
  33. package/dist/element/spectrum-element.js.map +1 -1
  34. package/dist/element/version.d.ts +2 -2
  35. package/dist/element/version.js +1 -1
  36. package/dist/element/version.js.map +1 -1
  37. package/dist/mixins/index.d.ts +0 -2
  38. package/dist/mixins/index.js +4 -6
  39. package/dist/mixins/linear-progress-mixin.d.ts +1 -2
  40. package/dist/mixins/linear-progress-mixin.js +5 -5
  41. package/dist/mixins/linear-progress-mixin.js.map +1 -1
  42. package/dist/utils/index.d.ts +1 -0
  43. package/dist/utils/index.js +10 -9
  44. package/dist/utils/is-focus-visible-in-tree.d.ts +33 -0
  45. package/dist/utils/is-focus-visible-in-tree.js +11 -0
  46. package/dist/utils/is-focus-visible-in-tree.js.map +1 -0
  47. package/package.json +30 -16
  48. package/CHANGELOG.md +0 -125
  49. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/defineProperty.js +0 -12
  50. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/toPrimitive.js +0 -14
  51. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/toPropertyKey.js +0 -9
  52. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/typeof.js +0 -11
  53. package/dist/mixins/observe-slot-presence.d.ts +0 -12
  54. package/dist/mixins/observe-slot-presence.js +0 -40
  55. package/dist/mixins/observe-slot-presence.js.map +0 -1
  56. package/dist/mixins/observe-slot-text.d.ts +0 -11
  57. package/dist/mixins/observe-slot-text.js +0 -60
  58. package/dist/mixins/observe-slot-text.js.map +0 -1
@@ -1,21 +1,29 @@
1
1
  import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js";
2
- import { CARD_DENSITIES as t, CARD_VALID_SIZES as n, CARD_VARIANTS as r } from "./Card.types.js";
3
- import { property as i } from "lit/decorators.js";
4
- import { SpectrumElement as a } from "@adobe/spectrum-wc-core/element/index.js";
5
- import { SizedMixin as o } from "@adobe/spectrum-wc-core/mixins/index.js";
2
+ import { SlotAttributePropagationController as t } from "../../controllers/slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.js";
3
+ import { SlotTextController as n } from "../../controllers/slot-text-controller/src/slot-text-controller.js";
4
+ import { CARD_DENSITIES as r, CARD_VALID_SIZES as i, CARD_VARIANTS as a, SWC_CARD_CLICK_EVENT as o } from "./Card.types.js";
5
+ import { property as s } from "lit/decorators.js";
6
+ import { SpectrumElement as c } from "@adobe/spectrum-wc-core/element/index.js";
7
+ import { SizedMixin as l } from "@adobe/spectrum-wc-core/mixins/index.js";
6
8
  //#region components/card/Card.base.ts
7
- var s, c = class e extends o(a, { validSizes: n }) {
8
- constructor(...t) {
9
- super(...t), this.variant = "primary", this.density = "regular", this.titleAsLink = !1, this.selectable = !1, this.handleSurfaceClick = (t) => {
9
+ var u, d = class e extends l(c, { validSizes: i }) {
10
+ constructor(...r) {
11
+ super(...r), this.variant = "primary", this.density = "regular", this.titleAsLink = !1, this.selectable = !1, this._sizePropagation = new t(this, {
12
+ attribute: "size",
13
+ getValue: () => e.getSmallerSize(this.size),
14
+ slotName: "actions"
15
+ }), this.slotText = new n(this), this.handleActionsSlotChange = () => {
16
+ this._sizePropagation.propagate(), this.checkActionsSupport();
17
+ }, this.handleSurfaceClick = (t) => {
10
18
  var n;
11
- if (!this.titleAsLink && !this.selectable) return;
12
- let r = t.composedPath(), i = r.slice(0, r.indexOf(this)), a = (n = this.renderRoot) == null ? void 0 : n.querySelector("slot[name=\"actions\"]");
19
+ if (!this.titleAsLink && !this.selectable || t instanceof MouseEvent && ((n = document.getSelection()) == null ? void 0 : n.isCollapsed) === !1) return;
20
+ let r = t.composedPath(), i = r.slice(0, r.indexOf(this)), a = this.getActionsSlotElement();
13
21
  if (!(a && i.includes(a) || i.some(e.isFocusable))) {
14
22
  if (this.titleAsLink) {
15
- var o;
16
- (o = this.getTitleLinkElement()) == null || o.click();
23
+ var s;
24
+ (s = this.getTitleLinkElement()) == null || s.click();
17
25
  }
18
- this.selectable && this.dispatchEvent(new Event("swc-card-click", {
26
+ this.selectable && this.dispatchEvent(new Event(o, {
19
27
  bubbles: !0,
20
28
  composed: !0
21
29
  }));
@@ -24,23 +32,50 @@ var s, c = class e extends o(a, { validSizes: n }) {
24
32
  (e.code === "Enter" || e.code === "Space") && (e.preventDefault(), this.handleSurfaceClick(e));
25
33
  };
26
34
  }
35
+ get slotHasContent() {
36
+ return this.slotText.hasContent;
37
+ }
27
38
  connectedCallback() {
28
39
  super.connectedCallback(), this.addEventListener("click", this.handleSurfaceClick);
29
40
  }
30
41
  disconnectedCallback() {
31
42
  this.removeEventListener("click", this.handleSurfaceClick), this.removeEventListener("keydown", this.handleSelectableKeydown), super.disconnectedCallback();
32
43
  }
44
+ firstUpdated(e) {
45
+ var t;
46
+ super.firstUpdated(e), (t = this.renderRoot) == null || (t = t.querySelector("slot[name=\"actions\"]")) == null || t.addEventListener("slotchange", this.handleActionsSlotChange);
47
+ }
33
48
  updated(e) {
34
49
  var t;
35
50
  if (super.updated(e), e.has("selectable") && (this.selectable ? (this.setAttribute("tabindex", "0"), this.addEventListener("keydown", this.handleSelectableKeydown)) : (this.removeAttribute("tabindex"), this.removeEventListener("keydown", this.handleSelectableKeydown))), (t = window.__swc) != null && t.DEBUG) {
36
51
  let { VARIANTS: t, DENSITIES: n } = this.constructor;
37
- e.has("variant") && !t.includes(this.variant) && window.__swc.warn(this, `<${this.localName}> received an invalid "variant" value of "${this.variant}". Valid values are ${t.join(", ")}.`, "https://opensource.adobe.com/spectrum-web-components/components/card/", { issues: [`variant="${this.variant}"`] }), e.has("density") && !n.includes(this.density) && window.__swc.warn(this, `<${this.localName}> received an invalid "density" value of "${this.density}". Valid values are ${n.join(", ")}.`, "https://opensource.adobe.com/spectrum-web-components/components/card/", { issues: [`density="${this.density}"`] }), e.has("titleAsLink") && this.titleAsLink && !this.getTitleLinkElement() && window.__swc.warn(this, `<${this.localName}> has "title-as-link" set but no link element was found in the "title" slot.`, "https://opensource.adobe.com/spectrum-web-components/components/card/", { issues: ["title-as-link"] });
52
+ e.has("variant") && !t.includes(this.variant) && window.__swc.warn(this, `<${this.localName}> received an invalid "variant" value of "${this.variant}". Valid values are ${t.join(", ")}.`, "https://opensource.adobe.com/spectrum-web-components/components/card/", { issues: [`variant="${this.variant}"`] }), e.has("density") && !n.includes(this.density) && window.__swc.warn(this, `<${this.localName}> received an invalid "density" value of "${this.density}". Valid values are ${n.join(", ")}.`, "https://opensource.adobe.com/spectrum-web-components/components/card/", {
53
+ level: "low",
54
+ issues: [`density="${this.density}"`]
55
+ }), e.has("titleAsLink") && this.titleAsLink && !this.getTitleLinkElement() && window.__swc.warn(this, `<${this.localName}> has "title-as-link" set but no link element was found in the "title" slot.`, "https://opensource.adobe.com/spectrum-web-components/components/card/", {
56
+ level: "high",
57
+ issues: ["title-as-link"]
58
+ }), e.has("size") && this.checkActionsSupport();
38
59
  }
39
60
  }
40
61
  getTitleSlotElement() {
41
62
  var e, t;
42
63
  return (e = (t = this.renderRoot) == null ? void 0 : t.querySelector("slot[name=\"title\"]")) == null ? null : e;
43
64
  }
65
+ getActionsSlotElement() {
66
+ var e, t;
67
+ return (e = (t = this.renderRoot) == null ? void 0 : t.querySelector("slot[name=\"actions\"]")) == null ? null : e;
68
+ }
69
+ get actionsSupported() {
70
+ return this.size !== "xs";
71
+ }
72
+ checkActionsSupport() {
73
+ var e, t, n;
74
+ (e = window.__swc) != null && e.DEBUG && !this.actionsSupported && ((t = (n = this.getActionsSlotElement()) == null ? void 0 : n.assignedElements({ flatten: !0 }).length) == null ? 0 : t) > 0 && window.__swc.warn(this, `<${this.localName}> has content in the "actions" slot, but actions are not supported for this card (size="${this.size}").`, "https://opensource.adobe.com/spectrum-web-components/components/card/", {
75
+ level: "medium",
76
+ issues: ["actions"]
77
+ });
78
+ }
44
79
  getTitleLinkElement() {
45
80
  var e;
46
81
  let t = (e = this.getTitleSlotElement()) == null ? void 0 : e.assignedElements({ flatten: !0 });
@@ -54,22 +89,26 @@ var s, c = class e extends o(a, { validSizes: n }) {
54
89
  static isFocusable(e) {
55
90
  return e instanceof HTMLElement && e.tabIndex >= 0;
56
91
  }
92
+ static getSmallerSize(e) {
93
+ let t = i.indexOf(e);
94
+ return i[Math.max(t - 1, 0)];
95
+ }
57
96
  };
58
- s = c, s.VARIANTS = r, s.DENSITIES = t, e([i({
97
+ u = d, u.VARIANTS = a, u.DENSITIES = r, e([s({
59
98
  type: String,
60
99
  reflect: !0
61
- })], c.prototype, "variant", void 0), e([i({
100
+ })], d.prototype, "variant", void 0), e([s({
62
101
  type: String,
63
102
  reflect: !0
64
- })], c.prototype, "density", void 0), e([i({
103
+ })], d.prototype, "density", void 0), e([s({
65
104
  type: Boolean,
66
105
  reflect: !0,
67
106
  attribute: "title-as-link"
68
- })], c.prototype, "titleAsLink", void 0), e([i({
107
+ })], d.prototype, "titleAsLink", void 0), e([s({
69
108
  type: Boolean,
70
109
  reflect: !0
71
- })], c.prototype, "selectable", void 0);
110
+ })], d.prototype, "selectable", void 0);
72
111
  //#endregion
73
- export { c as CardBase };
112
+ export { d as CardBase };
74
113
 
75
114
  //# sourceMappingURL=Card.base.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Card.base.js","names":[],"sources":["../../../components/card/Card.base.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { SpectrumElement } from '@adobe/spectrum-wc-core/element/index.js';\nimport { SizedMixin } from '@adobe/spectrum-wc-core/mixins/index.js';\n\nimport {\n CARD_DENSITIES,\n CARD_VALID_SIZES,\n CARD_VARIANTS,\n type CardDensity,\n type CardVariant,\n} from './Card.types.js';\n\n/**\n * Abstract base class for all card-family components. Owns the semantics\n * shared across every card type: sizing, visual variant, and density.\n *\n * `swc-card`, `swc-user-card`, and `swc-product-card` each extend this base\n * directly and render the shared anatomy via `renderCardTemplate()` in\n * `swc/components/card/card-template.ts`. That template also carries a\n * collection placeholder and an avatar/thumbnail glyph, each supplied\n * per-component via `renderCollection`/`renderGlyph`.\n *\n * @attribute {ElementSize} size - The size of the card.\n *\n * @slot preview - Primary preview content\n * @slot title - Card title\n * @slot actions - Optional action controls\n * @slot description - Supporting description text\n * @slot footer - Optional footer content\n * @slot - Additional body content\n */\nexport abstract class CardBase extends SizedMixin(SpectrumElement, {\n validSizes: CARD_VALID_SIZES,\n}) {\n // ─────────────────────────\n // API TO OVERRIDE\n // ─────────────────────────\n\n /**\n * @internal\n */\n static readonly VARIANTS: readonly CardVariant[] = CARD_VARIANTS;\n\n /**\n * @internal\n */\n static readonly DENSITIES: readonly CardDensity[] = CARD_DENSITIES;\n\n // ──────────────────\n // SHARED API\n // ──────────────────\n\n /**\n * The visual variant of the card.\n *\n * @default primary\n */\n @property({ type: String, reflect: true })\n public variant: CardVariant = 'primary';\n\n /**\n * The density of the card, controlling internal spacing and gaps.\n *\n * @default regular\n */\n @property({ type: String, reflect: true })\n public density: CardDensity = 'regular';\n\n /**\n * Indicates the consumer has wrapped their `title` slot content in a real\n * link. Extends that link's hit area to cover the card surface while\n * leaving navigation entirely consumer-owned — Card accepts no `href`.\n *\n * @todo Naming, and the `::slotted(a)::after` vs. click-proxy mechanism,\n * are still open. See the card family plan, A11y-3 / Q2.\n */\n @property({ type: Boolean, reflect: true, attribute: 'title-as-link' })\n public titleAsLink = false;\n\n /**\n * Makes the card focusable and captures surface clicks (excluding nested\n * interactive targets) to dispatch a `swc-card-click` event, independent\n * of `titleAsLink`. Lays groundwork for a future `CardView` selection\n * model without Card owning selected-state UI itself.\n *\n * @todo Event name and `tabindex` management details are still open. See\n * the card family plan, A11y-3 / Q3.\n * @todo No `role` is set when `selectable` is true — deferred rather than\n * defaulting to `role=\"button\"`, since the eventual `CardView` selection\n * model may call for a different role (e.g. `option`/`gridcell`) that\n * `role=\"button\"` would be wrong to have committed to today. See the card\n * family plan, A11y-3 / Q8.\n */\n @property({ type: Boolean, reflect: true })\n public selectable = false;\n\n // ──────────────────────\n // IMPLEMENTATION\n // ──────────────────────\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('click', this.handleSurfaceClick);\n }\n\n public override disconnectedCallback(): void {\n this.removeEventListener('click', this.handleSurfaceClick);\n this.removeEventListener('keydown', this.handleSelectableKeydown);\n super.disconnectedCallback();\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('selectable')) {\n if (this.selectable) {\n this.setAttribute('tabindex', '0');\n this.addEventListener('keydown', this.handleSelectableKeydown);\n } else {\n this.removeAttribute('tabindex');\n this.removeEventListener('keydown', this.handleSelectableKeydown);\n }\n }\n\n if (window.__swc?.DEBUG) {\n const { VARIANTS, DENSITIES } = this.constructor as typeof CardBase;\n\n if (\n changedProperties.has('variant') &&\n !VARIANTS.includes(this.variant)\n ) {\n window.__swc.warn(\n this,\n `<${this.localName}> received an invalid \"variant\" value of \"${this.variant}\". Valid values are ${VARIANTS.join(', ')}.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/card/',\n { issues: [`variant=\"${this.variant}\"`] }\n );\n }\n\n if (\n changedProperties.has('density') &&\n !DENSITIES.includes(this.density)\n ) {\n window.__swc.warn(\n this,\n `<${this.localName}> received an invalid \"density\" value of \"${this.density}\". Valid values are ${DENSITIES.join(', ')}.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/card/',\n { issues: [`density=\"${this.density}\"`] }\n );\n }\n\n if (\n changedProperties.has('titleAsLink') &&\n this.titleAsLink &&\n !this.getTitleLinkElement()\n ) {\n window.__swc.warn(\n this,\n `<${this.localName}> has \"title-as-link\" set but no link element was found in the \"title\" slot.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/card/',\n { issues: ['title-as-link'] }\n );\n }\n }\n }\n\n /**\n * @internal\n * The card's own `title` slot element, or `null` before the concrete\n * class's `renderCardTemplate()` call has rendered.\n */\n protected getTitleSlotElement(): HTMLSlotElement | null {\n return this.renderRoot?.querySelector('slot[name=\"title\"]') ?? null;\n }\n\n /**\n * @internal\n * The `title` slot's link, supporting both forms consumers reasonably\n * use: the assigned element itself is the anchor (`<a slot=\"title\"\n * href=\"...\">`), or the anchor is nested inside a wrapper (`<span\n * slot=\"title\"><a href=\"...\">`). Requires `href` — a link with no\n * destination can't usefully be clicked-through.\n */\n protected getTitleLinkElement(): HTMLAnchorElement | null {\n const assigned = this.getTitleSlotElement()?.assignedElements({\n flatten: true,\n });\n for (const element of assigned ?? []) {\n if (element instanceof HTMLAnchorElement && element.href) {\n return element;\n }\n const nested = element.querySelector<HTMLAnchorElement>('a[href]');\n if (nested) {\n return nested;\n }\n }\n return null;\n }\n\n /**\n * @internal\n * Whether `node` provides its own interaction/focus semantics. Checking\n * the `tabIndex` IDL property (rather than the `tabindex` attribute or a\n * tag-name list) correctly covers natively-interactive elements\n * (`button`, `input`, `select`, `textarea`, `a[href]`) with no explicit\n * attribute, excludes `tabindex=\"-1\"` (focusable for scripting, not a\n * click target) and disabled controls, and works for a custom element's\n * internal shadow-DOM control too — `composedPath()` already traverses\n * into other elements' shadow roots for composed events like `click`, so\n * an internal `<button>` inside e.g. `<swc-button>` is inspected directly\n * regardless of which shadow tree it belongs to.\n */\n private static isFocusable(node: EventTarget): boolean {\n return node instanceof HTMLElement && node.tabIndex >= 0;\n }\n\n /**\n * Proxies a qualifying surface click to `titleAsLink`'s link and/or\n * dispatches `swc-card-click` for `selectable`, after filtering out\n * clicks that landed on a nested interactive target (see `isFocusable()`\n * and the `actions`-slot exclusion above).\n */\n protected readonly handleSurfaceClick = (event: Event): void => {\n if (!this.titleAsLink && !this.selectable) {\n return;\n }\n const path = event.composedPath();\n const precedingPath = path.slice(0, path.indexOf(this));\n const actionsSlot = this.renderRoot?.querySelector('slot[name=\"actions\"]');\n const hitInteractiveTarget =\n // The `actions` slot is unconditionally excluded, defense-in-depth,\n // since it's contractually for interactive content regardless of\n // whether a given control correctly reflects focusability.\n (actionsSlot && precedingPath.includes(actionsSlot)) ||\n precedingPath.some(CardBase.isFocusable);\n if (hitInteractiveTarget) {\n return;\n }\n if (this.titleAsLink) {\n this.getTitleLinkElement()?.click();\n }\n if (this.selectable) {\n this.dispatchEvent(\n new Event('swc-card-click', { bubbles: true, composed: true })\n );\n }\n };\n\n /**\n * `tabindex` is only ever added alongside this listener (see `updated()`)\n * and removed alongside its removal — a focusable card is never left\n * without keyboard activation. Enter and Space are treated identically\n * and both proxy to `titleAsLink`'s link when set, even though a bare\n * link conventionally responds to Enter only: the card's own activation\n * contract (Enter+Space, more button-like) is authoritative once\n * `selectable` makes the card itself the focused target, regardless of\n * what that activation happens to proxy to.\n */\n protected readonly handleSelectableKeydown = (event: KeyboardEvent): void => {\n if (event.code === 'Enter' || event.code === 'Space') {\n event.preventDefault();\n this.handleSurfaceClick(event);\n }\n };\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"Card.base.js","names":[],"sources":["../../../components/card/Card.base.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { SpectrumElement } from '@adobe/spectrum-wc-core/element/index.js';\nimport {\n type ElementSize,\n SizedMixin,\n} from '@adobe/spectrum-wc-core/mixins/index.js';\n\nimport { SlotAttributePropagationController } from '../../controllers/slot-attribute-propagation-controller/index.js';\nimport { SlotTextController } from '../../controllers/slot-text-controller/index.js';\nimport {\n CARD_DENSITIES,\n CARD_VALID_SIZES,\n CARD_VARIANTS,\n type CardDensity,\n type CardSize,\n type CardVariant,\n SWC_CARD_CLICK_EVENT,\n} from './Card.types.js';\n\n/**\n * Abstract base class for all card-family components. Owns the semantics\n * shared across every card type: sizing, visual variant, and density.\n *\n * @attribute {ElementSize} size - The size of the card.\n *\n * @fires swc-card-click - Dispatched when a `selectable` card is activated (click, Enter, or Space).\n *\n * @slot preview - Primary preview content\n * @slot title - Card title\n * @slot actions - Optional action controls\n * @slot description - Supporting description text\n * @slot footer - Optional footer content\n * @slot - Additional body content\n *\n * @cssprop --swc-card-base-max-inline-size - Maximum inline size of the card. Defaults to 280px, overridden per size.\n * @cssprop --swc-card-base-border-radius - Corner radius of the card. Defaults to the extra-large corner-radius token, overridden per size.\n * @cssprop --swc-card-base-box-shadow - Box shadow (elevation) of the card. Defaults to the emphasized drop-shadow token; overridden by the tertiary variant, selectable focus, and title-as-link/selectable hover.\n * @cssprop --swc-card-base-background-color - Background color of the card. Defaults to the layer-2 background token; overridden by the secondary, tertiary, and quiet variants.\n * @cssprop --swc-card-base-preview-aspect-ratio - Aspect ratio of the preview slot. Defaults to 3/2.\n * @cssprop --swc-card-base-title-font-size - Font size of the title slot. Defaults to the medium font-size token, overridden per size.\n * @cssprop --swc-card-base-title-line-height - Line height of the title slot. Defaults to the medium line-height token, overridden per size.\n * @cssprop --swc-card-base-description-font-size - Font size of the description slot and default slot content. Defaults to a smaller font-size token, overridden per size.\n * @cssprop --swc-card-base-action-component-height - Height used to vertically balance slotted actions content. Defaults to the smallest component-height token, overridden per size.\n * @cssprop --swc-card-base-content-header-gap - Column gap between the title and actions slots. Defaults to the medium base-gap token, overridden per size.\n * @cssprop --swc-card-base-content-padding - Padding of the content region. Defaults to the medium container-padding token; overridden by density.\n * @cssprop --swc-card-base-content-padding-regular - Content padding used at the default (regular) density, per size.\n * @cssprop --swc-card-base-content-padding-compact - Content padding used at compact density, per size.\n * @cssprop --swc-card-base-content-padding-spacious - Content padding used at spacious density, per size.\n */\nexport abstract class CardBase extends SizedMixin(SpectrumElement, {\n validSizes: CARD_VALID_SIZES,\n}) {\n // ─────────────────────────\n // API TO OVERRIDE\n // ─────────────────────────\n\n /**\n * @internal\n */\n static readonly VARIANTS: readonly CardVariant[] = CARD_VARIANTS;\n\n /**\n * @internal\n */\n static readonly DENSITIES: readonly CardDensity[] = CARD_DENSITIES;\n\n // ──────────────────\n // SHARED API\n // ──────────────────\n\n /**\n * The visual variant of the card.\n *\n * @default primary\n */\n @property({ type: String, reflect: true })\n public variant: CardVariant = 'primary';\n\n /**\n * The density of the card, controlling internal spacing and gaps.\n *\n * @default regular\n */\n @property({ type: String, reflect: true })\n public density: CardDensity = 'regular';\n\n /**\n * Indicates the consumer has wrapped their `title` slot content in a real\n * link. Extends that link's hit area to cover the card surface while\n * leaving navigation entirely consumer-owned; Card accepts no `href`.\n */\n @property({ type: Boolean, reflect: true, attribute: 'title-as-link' })\n public titleAsLink = false;\n\n /**\n * Makes the card focusable and captures surface clicks (excluding nested\n * interactive targets) to dispatch a `swc-card-click` event, independent\n * of `titleAsLink`.\n *\n * @todo No ARIA role is set yet; deferred until a future `CardView`\n * selection model determines the appropriate role.\n */\n @property({ type: Boolean, reflect: true })\n public selectable = false;\n\n // ──────────────────────\n // IMPLEMENTATION\n // ──────────────────────\n\n /**\n * Keeps a slotted action control's `size` one step smaller than the\n * card's own `size`.\n */\n private readonly _sizePropagation = new SlotAttributePropagationController(\n this,\n {\n attribute: 'size',\n getValue: () => CardBase.getSmallerSize(this.size),\n slotName: 'actions',\n }\n );\n\n /**\n * Observes whether the default slot has meaningful content. Each concrete\n * card's `render()` must bind `@slotchange=${this.slotText.handleSlotChange}`\n * on the default slot (via `renderCardTemplate`'s `onDefaultSlotChange`) for\n * changes after the first render to be tracked.\n *\n * @internal\n */\n protected slotText = new SlotTextController(this);\n\n /**\n * Whether the default slot has meaningful content. Consumed by each concrete\n * card's `render()` (through `renderCardTemplate`'s `hasDefaultSlotContent`)\n * to toggle the `--hasDefault` class.\n *\n * @internal\n */\n protected get slotHasContent(): boolean {\n return this.slotText.hasContent;\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('click', this.handleSurfaceClick);\n }\n\n public override disconnectedCallback(): void {\n this.removeEventListener('click', this.handleSurfaceClick);\n this.removeEventListener('keydown', this.handleSelectableKeydown);\n super.disconnectedCallback();\n }\n\n protected override firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n // renderCardTemplate() doesn't take a slotchange callback, so the\n // listener is attached imperatively rather than declaratively in the\n // template; the slot node itself persists across re-renders.\n this.renderRoot\n ?.querySelector('slot[name=\"actions\"]')\n ?.addEventListener('slotchange', this.handleActionsSlotChange);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('selectable')) {\n if (this.selectable) {\n this.setAttribute('tabindex', '0');\n this.addEventListener('keydown', this.handleSelectableKeydown);\n } else {\n this.removeAttribute('tabindex');\n this.removeEventListener('keydown', this.handleSelectableKeydown);\n }\n }\n\n if (window.__swc?.DEBUG) {\n const { VARIANTS, DENSITIES } = this.constructor as typeof CardBase;\n\n if (\n changedProperties.has('variant') &&\n !VARIANTS.includes(this.variant)\n ) {\n window.__swc.warn(\n this,\n `<${this.localName}> received an invalid \"variant\" value of \"${this.variant}\". Valid values are ${VARIANTS.join(', ')}.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/card/',\n { issues: [`variant=\"${this.variant}\"`] }\n );\n }\n\n if (\n changedProperties.has('density') &&\n !DENSITIES.includes(this.density)\n ) {\n window.__swc.warn(\n this,\n `<${this.localName}> received an invalid \"density\" value of \"${this.density}\". Valid values are ${DENSITIES.join(', ')}.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/card/',\n { level: 'low', issues: [`density=\"${this.density}\"`] }\n );\n }\n\n if (\n changedProperties.has('titleAsLink') &&\n this.titleAsLink &&\n !this.getTitleLinkElement()\n ) {\n window.__swc.warn(\n this,\n `<${this.localName}> has \"title-as-link\" set but no link element was found in the \"title\" slot.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/card/',\n { level: 'high', issues: ['title-as-link'] }\n );\n }\n\n if (changedProperties.has('size')) {\n this.checkActionsSupport();\n }\n }\n }\n\n /**\n * @internal\n *\n * The card's own `title` slot element.\n */\n protected getTitleSlotElement(): HTMLSlotElement | null {\n return this.renderRoot?.querySelector('slot[name=\"title\"]') ?? null;\n }\n\n /**\n * @internal\n *\n * The card's own `actions` slot element.\n */\n protected getActionsSlotElement(): HTMLSlotElement | null {\n return this.renderRoot?.querySelector('slot[name=\"actions\"]') ?? null;\n }\n\n /**\n * Whether the `actions` slot is supported for this card's current state.\n * `xs` cards don't have room for it. Concrete classes may override this\n * to exclude the slot for other reasons, independent of size.\n */\n protected get actionsSupported(): boolean {\n return this.size !== 'xs';\n }\n\n /**\n * @internal\n *\n * Warns in dev mode when the `actions` slot has content but isn't\n * supported for the current state. Visual suppression is handled in\n * CSS, not here.\n */\n private checkActionsSupport(): void {\n if (\n window.__swc?.DEBUG &&\n !this.actionsSupported &&\n (this.getActionsSlotElement()?.assignedElements({ flatten: true })\n .length ?? 0) > 0\n ) {\n window.__swc.warn(\n this,\n `<${this.localName}> has content in the \"actions\" slot, but actions are not supported for this card (size=\"${this.size}\").`,\n 'https://opensource.adobe.com/spectrum-web-components/components/card/',\n { level: 'medium', issues: ['actions'] }\n );\n }\n }\n\n /**\n * @internal\n *\n * The `title` slot's link: either the assigned element itself\n * (`<a slot=\"title\" href=\"...\">`) or an anchor nested inside a wrapper\n * (`<span slot=\"title\"><a href=\"...\">`). Requires `href`.\n */\n protected getTitleLinkElement(): HTMLAnchorElement | null {\n const assigned = this.getTitleSlotElement()?.assignedElements({\n flatten: true,\n });\n for (const element of assigned ?? []) {\n if (element instanceof HTMLAnchorElement && element.href) {\n return element;\n }\n const nested = element.querySelector<HTMLAnchorElement>('a[href]');\n if (nested) {\n return nested;\n }\n }\n return null;\n }\n\n /**\n * @internal\n *\n * Whether `node` has its own interaction/focus semantics, via the\n * `tabIndex` IDL property rather than the `tabindex` attribute; this\n * also correctly excludes `tabindex=\"-1\"` and disabled controls.\n */\n private static isFocusable(node: EventTarget): boolean {\n return node instanceof HTMLElement && node.tabIndex >= 0;\n }\n\n /**\n * @internal\n *\n * The size one step below `size` in `CARD_VALID_SIZES`, clamped at the\n * smallest size.\n */\n private static getSmallerSize(size: ElementSize): CardSize {\n const index = CARD_VALID_SIZES.indexOf(size as CardSize);\n return CARD_VALID_SIZES[Math.max(index - 1, 0)];\n }\n\n /**\n * Re-propagates the `actions` slot's `size` for elements assigned after\n * the initial render, wired to the slot's `slotchange` in\n * `firstUpdated()`.\n */\n protected readonly handleActionsSlotChange = (): void => {\n this._sizePropagation.propagate();\n this.checkActionsSupport();\n };\n\n /**\n * Proxies a qualifying surface click to `titleAsLink`'s link and/or\n * dispatches `swc-card-click` for `selectable`, after filtering out\n * clicks that landed on a nested interactive target or followed a\n * text-selection drag.\n */\n protected readonly handleSurfaceClick = (event: Event): void => {\n if (!this.titleAsLink && !this.selectable) {\n return;\n }\n // A text-selection drag still fires `click` on mouseup; a non-collapsed\n // selection at that point means the user was selecting text, not\n // clicking through the card.\n if (\n event instanceof MouseEvent &&\n document.getSelection()?.isCollapsed === false\n ) {\n return;\n }\n const path = event.composedPath();\n const precedingPath = path.slice(0, path.indexOf(this));\n const actionsSlot = this.getActionsSlotElement();\n const hitInteractiveTarget =\n // The actions slot is always excluded, since it's contractually\n // for interactive content regardless of whether a control reflects\n // focusability correctly.\n (actionsSlot && precedingPath.includes(actionsSlot)) ||\n precedingPath.some(CardBase.isFocusable);\n if (hitInteractiveTarget) {\n return;\n }\n if (this.titleAsLink) {\n this.getTitleLinkElement()?.click();\n }\n if (this.selectable) {\n this.dispatchEvent(\n new Event(SWC_CARD_CLICK_EVENT, { bubbles: true, composed: true })\n );\n }\n };\n\n /**\n * Enter and Space both activate the card, even though a bare link\n * conventionally responds to Enter only; the card's own activation\n * contract takes precedence once `selectable` makes it the focused\n * target.\n */\n protected readonly handleSelectableKeydown = (event: KeyboardEvent): void => {\n if (event.code === 'Enter' || event.code === 'Space') {\n event.preventDefault();\n this.handleSurfaceClick(event);\n }\n };\n}\n"],"mappings":"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"}
@@ -12,6 +12,7 @@
12
12
  export declare const CARD_VALID_SIZES: readonly ["xs", "s", "m", "l", "xl"];
13
13
  export declare const CARD_VARIANTS: readonly ["primary", "secondary", "tertiary", "quiet"];
14
14
  export declare const CARD_DENSITIES: readonly ["compact", "regular", "spacious"];
15
+ export declare const SWC_CARD_CLICK_EVENT: "swc-card-click";
15
16
  export type CardSize = (typeof CARD_VALID_SIZES)[number];
16
17
  export type CardVariant = (typeof CARD_VARIANTS)[number];
17
18
  export type CardDensity = (typeof CARD_DENSITIES)[number];
@@ -14,8 +14,8 @@ var e = [
14
14
  "compact",
15
15
  "regular",
16
16
  "spacious"
17
- ];
17
+ ], r = "swc-card-click";
18
18
  //#endregion
19
- export { n as CARD_DENSITIES, e as CARD_VALID_SIZES, t as CARD_VARIANTS };
19
+ export { n as CARD_DENSITIES, e as CARD_VALID_SIZES, t as CARD_VARIANTS, r as SWC_CARD_CLICK_EVENT };
20
20
 
21
21
  //# sourceMappingURL=Card.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Card.types.js","names":[],"sources":["../../../components/card/Card.types.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { ElementSize } from '@adobe/spectrum-wc-core/mixins/index.js';\n\n// ──────────────────\n// SHARED\n// ──────────────────\n\nexport const CARD_VALID_SIZES = [\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n] as const satisfies readonly ElementSize[];\n\nexport const CARD_VARIANTS = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'quiet',\n] as const;\n\nexport const CARD_DENSITIES = ['compact', 'regular', 'spacious'] as const;\n\n// ──────────────────\n// TYPES\n// ──────────────────\n\nexport type CardSize = (typeof CARD_VALID_SIZES)[number];\nexport type CardVariant = (typeof CARD_VARIANTS)[number];\nexport type CardDensity = (typeof CARD_DENSITIES)[number];\n"],"mappings":";AAkBA,IAAa,IAAmB;CAC9B;CACA;CACA;CACA;CACA;CACD,EAEY,IAAgB;CAC3B;CACA;CACA;CACA;CACD,EAEY,IAAiB;CAAC;CAAW;CAAW;CAAW"}
1
+ {"version":3,"file":"Card.types.js","names":[],"sources":["../../../components/card/Card.types.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { ElementSize } from '@adobe/spectrum-wc-core/mixins/index.js';\n\n// ──────────────────\n// SHARED\n// ──────────────────\n\nexport const CARD_VALID_SIZES = [\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n] as const satisfies readonly ElementSize[];\n\nexport const CARD_VARIANTS = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'quiet',\n] as const;\n\nexport const CARD_DENSITIES = ['compact', 'regular', 'spacious'] as const;\n\nexport const SWC_CARD_CLICK_EVENT = 'swc-card-click' as const;\n\n// ──────────────────\n// TYPES\n// ──────────────────\n\nexport type CardSize = (typeof CARD_VALID_SIZES)[number];\nexport type CardVariant = (typeof CARD_VARIANTS)[number];\nexport type CardDensity = (typeof CARD_DENSITIES)[number];\n"],"mappings":";AAkBA,IAAa,IAAmB;CAC9B;CACA;CACA;CACA;CACA;CACD,EAEY,IAAgB;CAC3B;CACA;CACA;CACA;CACD,EAEY,IAAiB;CAAC;CAAW;CAAW;CAAW,EAEnD,IAAuB"}
@@ -1,3 +1,3 @@
1
- import { CARD_DENSITIES as e, CARD_VALID_SIZES as t, CARD_VARIANTS as n } from "./Card.types.js";
2
- import { CardBase as r } from "./Card.base.js";
3
- export { e as CARD_DENSITIES, t as CARD_VALID_SIZES, n as CARD_VARIANTS, r as CardBase };
1
+ import { CARD_DENSITIES as e, CARD_VALID_SIZES as t, CARD_VARIANTS as n, SWC_CARD_CLICK_EVENT as r } from "./Card.types.js";
2
+ import { CardBase as i } from "./Card.base.js";
3
+ export { e as CARD_DENSITIES, t as CARD_VALID_SIZES, n as CARD_VARIANTS, i as CardBase, r as SWC_CARD_CLICK_EVENT };
@@ -21,3 +21,5 @@ export { PageScrollLockController } from './page-scroll-lock.js';
21
21
  export { PendingController, type PendingControllerHost, type PendingControllerOptions, } from './pending-controller/index.js';
22
22
  export { ALL_PLACEMENTS, fromFloatingPlacement, PlacementController, toFloatingPlacement, type Placement, type PlacementOptions, type VirtualTrigger, } from './placement-controller/index.js';
23
23
  export { SlotAttributePropagationController, type SlotAttributePropagationControllerOptions, } from './slot-attribute-propagation-controller/index.js';
24
+ export { SlotPresenceController } from './slot-presence-controller/index.js';
25
+ export { SlotTextController, type SlotTextConfig, } from './slot-text-controller/index.js';
@@ -1,15 +1,17 @@
1
1
  import { SlotAttributePropagationController as e } from "./slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.js";
2
- import { HoverController as t } from "./hover-controller/src/hover-controller.js";
3
- import { fromFloatingPlacement as n, toFloatingPlacement as r } from "./placement-controller/src/placement-conversion.js";
4
- import { ALL_PLACEMENTS as i } from "./placement-controller/src/types.js";
5
- import { PlacementController as a } from "./placement-controller/src/placement-controller.js";
2
+ import { SlotTextController as t } from "./slot-text-controller/src/slot-text-controller.js";
3
+ import { HoverController as n } from "./hover-controller/src/hover-controller.js";
4
+ import { fromFloatingPlacement as r, toFloatingPlacement as i } from "./placement-controller/src/placement-conversion.js";
5
+ import { ALL_PLACEMENTS as a } from "./placement-controller/src/types.js";
6
+ import { PlacementController as o } from "./placement-controller/src/placement-controller.js";
6
7
  import "./placement-controller/index.js";
7
- import { LanguageResolutionController as o, languageResolverUpdatedSymbol as s } from "./language-resolution.js";
8
- import { PendingController as c } from "./pending-controller/src/pending-controller.js";
8
+ import { LanguageResolutionController as s, languageResolverUpdatedSymbol as c } from "./language-resolution.js";
9
+ import { SlotPresenceController as l } from "./slot-presence-controller/src/slot-presence-controller.js";
10
+ import { PendingController as u } from "./pending-controller/src/pending-controller.js";
9
11
  import "./pending-controller/index.js";
10
- import { ColorController as l } from "./color-controller/src/color-controller.js";
12
+ import { ColorController as d } from "./color-controller/src/color-controller.js";
11
13
  import "./color-controller/index.js";
12
- import { FocusgroupNavigationController as u, focusgroupNavigationActiveChange as d } from "./focusgroup-navigation-controller/src/focusgroup-navigation-controller.js";
13
- import { LiveSelectionController as f } from "./live-selection-controller/src/live-selection-controller.js";
14
- import { PageScrollLockController as p } from "./page-scroll-lock.js";
15
- export { i as ALL_PLACEMENTS, l as ColorController, u as FocusgroupNavigationController, t as HoverController, o as LanguageResolutionController, f as LiveSelectionController, p as PageScrollLockController, c as PendingController, a as PlacementController, e as SlotAttributePropagationController, d as focusgroupNavigationActiveChange, n as fromFloatingPlacement, s as languageResolverUpdatedSymbol, r as toFloatingPlacement };
14
+ import { FocusgroupNavigationController as f, focusgroupNavigationActiveChange as p } from "./focusgroup-navigation-controller/src/focusgroup-navigation-controller.js";
15
+ import { LiveSelectionController as m } from "./live-selection-controller/src/live-selection-controller.js";
16
+ import { PageScrollLockController as h } from "./page-scroll-lock.js";
17
+ export { a as ALL_PLACEMENTS, d as ColorController, f as FocusgroupNavigationController, n as HoverController, s as LanguageResolutionController, m as LiveSelectionController, h as PageScrollLockController, u as PendingController, o as PlacementController, e as SlotAttributePropagationController, l as SlotPresenceController, t as SlotTextController, p as focusgroupNavigationActiveChange, r as fromFloatingPlacement, c as languageResolverUpdatedSymbol, i as toFloatingPlacement };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ export { SlotPresenceController } from './src/slot-presence-controller.js';
@@ -0,0 +1,2 @@
1
+ import { SlotPresenceController as e } from "./src/slot-presence-controller.js";
2
+ export { e as SlotPresenceController };
@@ -0,0 +1,57 @@
1
+ import { ReactiveController, ReactiveElement } from 'lit';
2
+ /**
3
+ * A reactive controller that observes whether slotted content matching
4
+ * given CSS selectors is present in the host's light DOM.
5
+ *
6
+ * Replaces the `ObserveSlotPresence` mixin with a composition-based approach.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * class MyComponent extends SpectrumElement {
11
+ * private slotPresence = new SlotPresenceController(this, '[slot="icon"]');
12
+ *
13
+ * get hasIcon(): boolean {
14
+ * return this.slotPresence.isPresent;
15
+ * }
16
+ * }
17
+ * ```
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // Observing multiple selectors
22
+ * class MyComponent extends SpectrumElement {
23
+ * private slotPresence = new SlotPresenceController(this, [
24
+ * '[slot="icon"]',
25
+ * '[slot="description"]',
26
+ * ]);
27
+ *
28
+ * get hasIcon(): boolean {
29
+ * return this.slotPresence.getPresence('[slot="icon"]');
30
+ * }
31
+ *
32
+ * get hasDescription(): boolean {
33
+ * return this.slotPresence.getPresence('[slot="description"]');
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ export declare class SlotPresenceController implements ReactiveController {
39
+ private host;
40
+ private selectors;
41
+ private presenceMap;
42
+ private observer;
43
+ constructor(host: ReactiveElement, selectors: string | string[]);
44
+ /**
45
+ * Whether slotted content is present. Use this when observing a single
46
+ * selector. Throws if multiple selectors were provided — use
47
+ * `getPresence(selector)` instead.
48
+ */
49
+ get isPresent(): boolean;
50
+ /**
51
+ * Returns whether content matching the given selector is present.
52
+ */
53
+ getPresence(selector: string): boolean;
54
+ private checkPresence;
55
+ hostConnected(): void;
56
+ hostDisconnected(): void;
57
+ }
@@ -0,0 +1,44 @@
1
+ //#region controllers/slot-presence-controller/src/slot-presence-controller.ts
2
+ var e = class {
3
+ constructor(e, t) {
4
+ this.presenceMap = /* @__PURE__ */ new Map(), this.host = e, this.selectors = Array.isArray(t) ? t : [t], this.host.addController(this), this.observer = new MutationObserver(() => {
5
+ this.checkPresence();
6
+ }), this.checkPresence();
7
+ }
8
+ get isPresent() {
9
+ if (this.selectors.length === 1) {
10
+ var e;
11
+ return (e = this.presenceMap.get(this.selectors[0])) == null ? !1 : e;
12
+ }
13
+ throw Error("Multiple selectors provided to SlotPresenceController — use getPresence(selector) instead.");
14
+ }
15
+ getPresence(e) {
16
+ if (this.presenceMap.has(e)) {
17
+ var t;
18
+ return (t = this.presenceMap.get(e)) == null ? !1 : t;
19
+ }
20
+ throw Error(`The provided selector \`${e}\` is not being observed.`);
21
+ }
22
+ checkPresence() {
23
+ let e = !1;
24
+ for (let n of this.selectors) {
25
+ var t;
26
+ let r = !!this.host.querySelector(`:scope > ${n}`);
27
+ ((t = this.presenceMap.get(n)) == null ? !1 : t) !== r && (e = !0), this.presenceMap.set(n, r);
28
+ }
29
+ e && this.host.requestUpdate();
30
+ }
31
+ hostConnected() {
32
+ this.observer.observe(this.host, {
33
+ childList: !0,
34
+ subtree: !0
35
+ }), this.checkPresence();
36
+ }
37
+ hostDisconnected() {
38
+ this.observer.disconnect();
39
+ }
40
+ };
41
+ //#endregion
42
+ export { e as SlotPresenceController };
43
+
44
+ //# sourceMappingURL=slot-presence-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-presence-controller.js","names":[],"sources":["../../../../controllers/slot-presence-controller/src/slot-presence-controller.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\n\n/**\n * A reactive controller that observes whether slotted content matching\n * given CSS selectors is present in the host's light DOM.\n *\n * Replaces the `ObserveSlotPresence` mixin with a composition-based approach.\n *\n * @example\n * ```typescript\n * class MyComponent extends SpectrumElement {\n * private slotPresence = new SlotPresenceController(this, '[slot=\"icon\"]');\n *\n * get hasIcon(): boolean {\n * return this.slotPresence.isPresent;\n * }\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Observing multiple selectors\n * class MyComponent extends SpectrumElement {\n * private slotPresence = new SlotPresenceController(this, [\n * '[slot=\"icon\"]',\n * '[slot=\"description\"]',\n * ]);\n *\n * get hasIcon(): boolean {\n * return this.slotPresence.getPresence('[slot=\"icon\"]');\n * }\n *\n * get hasDescription(): boolean {\n * return this.slotPresence.getPresence('[slot=\"description\"]');\n * }\n * }\n * ```\n */\nexport class SlotPresenceController implements ReactiveController {\n private host: ReactiveElement;\n private selectors: string[];\n private presenceMap = new Map<string, boolean>();\n private observer: MutationObserver;\n\n constructor(host: ReactiveElement, selectors: string | string[]) {\n this.host = host;\n this.selectors = Array.isArray(selectors) ? selectors : [selectors];\n this.host.addController(this);\n\n this.observer = new MutationObserver(() => {\n this.checkPresence();\n });\n\n // Check initial state synchronously\n this.checkPresence();\n }\n\n /**\n * Whether slotted content is present. Use this when observing a single\n * selector. Throws if multiple selectors were provided — use\n * `getPresence(selector)` instead.\n */\n get isPresent(): boolean {\n if (this.selectors.length === 1) {\n return this.presenceMap.get(this.selectors[0]) ?? false;\n }\n throw new Error(\n 'Multiple selectors provided to SlotPresenceController — use getPresence(selector) instead.'\n );\n }\n\n /**\n * Returns whether content matching the given selector is present.\n */\n getPresence(selector: string): boolean {\n if (this.presenceMap.has(selector)) {\n return this.presenceMap.get(selector) ?? false;\n }\n throw new Error(\n `The provided selector \\`${selector}\\` is not being observed.`\n );\n }\n\n private checkPresence(): void {\n let changed = false;\n for (const selector of this.selectors) {\n const nextValue = !!this.host.querySelector(`:scope > ${selector}`);\n const previousValue = this.presenceMap.get(selector) ?? false;\n if (previousValue !== nextValue) {\n changed = true;\n }\n this.presenceMap.set(selector, nextValue);\n }\n if (changed) {\n // The `ObserveSlotPresence` mixin this controller replaces deferred the\n // re-render with `this.updateComplete.then(() => this.requestUpdate())`.\n // The controller requests the update synchronously instead. This is\n // safe because `checkPresence` only runs from the constructor, the\n // `MutationObserver` callback, and `hostConnected` — never from inside\n // the host's own `update()`/`render()` — so there is no re-entrant\n // update. Lit batches `requestUpdate()` calls into the next microtask,\n // so multiple presence changes in one tick still coalesce into a single\n // render. See the controller stories for the behavioral test.\n this.host.requestUpdate();\n }\n }\n\n hostConnected(): void {\n this.observer.observe(this.host, {\n childList: true,\n subtree: true,\n });\n this.checkPresence();\n }\n\n hostDisconnected(): void {\n this.observer.disconnect();\n }\n}\n"],"mappings":";AAkDA,IAAa,IAAb,MAAkE;CAMhE,YAAY,GAAuB,GAA8B;AAU/D,qCAboB,IAAI,KAAsB,EAI9C,KAAK,OAAO,GACZ,KAAK,YAAY,MAAM,QAAQ,EAAU,GAAG,IAAY,CAAC,EAAU,EACnE,KAAK,KAAK,cAAc,KAAK,EAE7B,KAAK,WAAW,IAAI,uBAAuB;AACzC,QAAK,eAAe;IACpB,EAGF,KAAK,eAAe;;CAQtB,IAAI,YAAqB;AACvB,MAAI,KAAK,UAAU,WAAW,GAAG;;AAC/B,WAAA,IAAO,KAAK,YAAY,IAAI,KAAK,UAAU,GAAG,KAAA,OAAI,KAAJ;;AAEhD,QAAU,MACR,6FACD;;CAMH,YAAY,GAA2B;AACrC,MAAI,KAAK,YAAY,IAAI,EAAS,EAAE;;AAClC,WAAA,IAAO,KAAK,YAAY,IAAI,EAAS,KAAA,OAAI,KAAJ;;AAEvC,QAAU,MACR,2BAA2B,EAAS,2BACrC;;CAGH,gBAA8B;EAC5B,IAAI,IAAU;AACd,OAAK,IAAM,KAAY,KAAK,WAAW;;GACrC,IAAM,IAAY,CAAC,CAAC,KAAK,KAAK,cAAc,YAAY,IAAW;AAKnE,KAHA,IADsB,KAAK,YAAY,IAAI,EAAS,KAAA,OAAI,KAAJ,OAC9B,MACpB,IAAU,KAEZ,KAAK,YAAY,IAAI,GAAU,EAAU;;AAE3C,EAAI,KAUF,KAAK,KAAK,eAAe;;CAI7B,gBAAsB;AAKpB,EAJA,KAAK,SAAS,QAAQ,KAAK,MAAM;GAC/B,WAAW;GACX,SAAS;GACV,CAAC,EACF,KAAK,eAAe;;CAGtB,mBAAyB;AACvB,OAAK,SAAS,YAAY"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ export { SlotTextController, type SlotTextConfig, } from './src/slot-text-controller.js';
@@ -0,0 +1,2 @@
1
+ import { SlotTextController as e } from "./src/slot-text-controller.js";
2
+ export { e as SlotTextController };
@@ -0,0 +1,92 @@
1
+ import { ReactiveController, ReactiveElement } from 'lit';
2
+ export interface SlotTextConfig {
3
+ /**
4
+ * The slot name to observe. Use `''` (empty string) for the default slot.
5
+ *
6
+ * @default '' (default slot)
7
+ */
8
+ slotName?: string;
9
+ /**
10
+ * CSS selectors for elements to exclude when checking for content.
11
+ * Matched elements are ignored — only non-excluded elements and
12
+ * non-empty text nodes count as "content."
13
+ */
14
+ excludeSelectors?: string[];
15
+ }
16
+ /**
17
+ * A reactive controller that observes whether a slot contains meaningful
18
+ * text or element content.
19
+ *
20
+ * Replaces the `ObserveSlotText` mixin with a composition-based approach.
21
+ *
22
+ * Monitors for `characterData` mutations (text changes) and re-evaluates
23
+ * on slot change events. The host is requested to update whenever the
24
+ * content state changes.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * class MyButton extends SpectrumElement {
29
+ * private slotText = new SlotTextController(this);
30
+ *
31
+ * get hasLabel(): boolean {
32
+ * return this.slotText.hasContent;
33
+ * }
34
+ *
35
+ * override render() {
36
+ * return html`<slot @slotchange=${this.slotText.handleSlotChange}></slot>`;
37
+ * }
38
+ * }
39
+ * ```
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Named slot with exclusions
44
+ * class MyComponent extends SpectrumElement {
45
+ * private slotText = new SlotTextController(this, {
46
+ * slotName: 'description',
47
+ * excludeSelectors: ['.visually-hidden'],
48
+ * });
49
+ * }
50
+ * ```
51
+ */
52
+ export declare class SlotTextController implements ReactiveController {
53
+ private host;
54
+ private slotName;
55
+ private excludeSelectors;
56
+ private observer;
57
+ private _hasContent;
58
+ constructor(host: ReactiveElement, config?: SlotTextConfig);
59
+ /**
60
+ * Whether the observed slot has meaningful content (text nodes or
61
+ * non-excluded elements).
62
+ */
63
+ get hasContent(): boolean;
64
+ /**
65
+ * Bind this to the slot's `@slotchange` event in the template.
66
+ *
67
+ * @example
68
+ * ```html
69
+ * <slot @slotchange=${this.slotText.handleSlotChange}></slot>
70
+ * ```
71
+ */
72
+ handleSlotChange: (event: Event) => void;
73
+ private evaluateNodes;
74
+ /**
75
+ * Checks initial content from light DOM children before the first render,
76
+ * before slots are assigned.
77
+ *
78
+ * This runs from `hostConnected`, which Lit invokes during the host's
79
+ * `connectedCallback` — before the first `update()`. It sets `_hasContent`
80
+ * directly and intentionally does not call `requestUpdate()`: the first
81
+ * render has not happened yet, so it will read the correct value when it
82
+ * runs. This differs from the `ObserveSlotText` mixin, where `slotHasContent`
83
+ * was a reactive `@property` assigned in `update()`. After the first render,
84
+ * `handleSlotChange` (bound via `@slotchange`) and the `characterData`
85
+ * observer take over and do call `requestUpdate()` on change. The
86
+ * controller stories cover initial content being reflected on first paint.
87
+ */
88
+ private checkInitialContent;
89
+ private checkContent;
90
+ hostConnected(): void;
91
+ hostDisconnected(): void;
92
+ }
@@ -0,0 +1,53 @@
1
+ //#region controllers/slot-text-controller/src/slot-text-controller.ts
2
+ var e = class {
3
+ constructor(e, t = {}) {
4
+ var n, r;
5
+ this._hasContent = !1, this.handleSlotChange = (e) => {
6
+ let t = e.target.assignedNodes({ flatten: !0 });
7
+ this.evaluateNodes(t);
8
+ }, this.host = e, this.slotName = (n = t.slotName) == null ? "" : n, this.excludeSelectors = (r = t.excludeSelectors) == null ? [] : r, this.host.addController(this), this.observer = new MutationObserver((e) => {
9
+ for (let t of e) if (t.type === "characterData") {
10
+ this.checkContent();
11
+ return;
12
+ }
13
+ });
14
+ }
15
+ get hasContent() {
16
+ return this._hasContent;
17
+ }
18
+ evaluateNodes(e) {
19
+ let t = [...e].some((e) => {
20
+ let t = e;
21
+ return t.tagName ? !this.excludeSelectors.some((e) => t.matches(e)) : this.slotName ? !1 : e.textContent ? e.textContent.trim().length > 0 : !1;
22
+ });
23
+ t !== this._hasContent && (this._hasContent = t, this.host.requestUpdate());
24
+ }
25
+ checkInitialContent() {
26
+ let { childNodes: e } = this.host;
27
+ this._hasContent = [...e].filter((e) => {
28
+ let t = e;
29
+ return t.tagName ? this.excludeSelectors.some((e) => t.matches(e)) ? !1 : this.slotName ? t.getAttribute("slot") === this.slotName : !t.hasAttribute("slot") : this.slotName ? !1 : e.textContent ? e.textContent.trim().length > 0 : !1;
30
+ }).length > 0;
31
+ }
32
+ checkContent() {
33
+ var e;
34
+ let t = (e = this.host.shadowRoot) == null ? void 0 : e.querySelector(this.slotName ? `slot[name="${this.slotName}"]` : "slot:not([name])");
35
+ if (t) {
36
+ let e = t.assignedNodes({ flatten: !0 });
37
+ this.evaluateNodes(e);
38
+ }
39
+ }
40
+ hostConnected() {
41
+ this.observer.observe(this.host, {
42
+ characterData: !0,
43
+ subtree: !0
44
+ }), this.checkInitialContent();
45
+ }
46
+ hostDisconnected() {
47
+ this.observer.disconnect();
48
+ }
49
+ };
50
+ //#endregion
51
+ export { e as SlotTextController };
52
+
53
+ //# sourceMappingURL=slot-text-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-text-controller.js","names":[],"sources":["../../../../controllers/slot-text-controller/src/slot-text-controller.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\n\nexport interface SlotTextConfig {\n /**\n * The slot name to observe. Use `''` (empty string) for the default slot.\n *\n * @default '' (default slot)\n */\n slotName?: string;\n\n /**\n * CSS selectors for elements to exclude when checking for content.\n * Matched elements are ignored — only non-excluded elements and\n * non-empty text nodes count as \"content.\"\n */\n excludeSelectors?: string[];\n}\n\n/**\n * A reactive controller that observes whether a slot contains meaningful\n * text or element content.\n *\n * Replaces the `ObserveSlotText` mixin with a composition-based approach.\n *\n * Monitors for `characterData` mutations (text changes) and re-evaluates\n * on slot change events. The host is requested to update whenever the\n * content state changes.\n *\n * @example\n * ```typescript\n * class MyButton extends SpectrumElement {\n * private slotText = new SlotTextController(this);\n *\n * get hasLabel(): boolean {\n * return this.slotText.hasContent;\n * }\n *\n * override render() {\n * return html`<slot @slotchange=${this.slotText.handleSlotChange}></slot>`;\n * }\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Named slot with exclusions\n * class MyComponent extends SpectrumElement {\n * private slotText = new SlotTextController(this, {\n * slotName: 'description',\n * excludeSelectors: ['.visually-hidden'],\n * });\n * }\n * ```\n */\nexport class SlotTextController implements ReactiveController {\n private host: ReactiveElement;\n private slotName: string;\n private excludeSelectors: string[];\n private observer: MutationObserver;\n private _hasContent = false;\n\n constructor(host: ReactiveElement, config: SlotTextConfig = {}) {\n this.host = host;\n this.slotName = config.slotName ?? '';\n this.excludeSelectors = config.excludeSelectors ?? [];\n this.host.addController(this);\n\n this.observer = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n if (mutation.type === 'characterData') {\n this.checkContent();\n return;\n }\n }\n });\n }\n\n /**\n * Whether the observed slot has meaningful content (text nodes or\n * non-excluded elements).\n */\n get hasContent(): boolean {\n return this._hasContent;\n }\n\n /**\n * Bind this to the slot's `@slotchange` event in the template.\n *\n * @example\n * ```html\n * <slot @slotchange=${this.slotText.handleSlotChange}></slot>\n * ```\n */\n handleSlotChange = (event: Event): void => {\n const slot = event.target as HTMLSlotElement;\n const nodes = slot.assignedNodes({ flatten: true });\n this.evaluateNodes(nodes);\n };\n\n private evaluateNodes(nodes: Iterable<Node>): void {\n const hasContent = [...nodes].some((node) => {\n const el = node as HTMLElement;\n if (el.tagName) {\n return !this.excludeSelectors.some((sel) => el.matches(sel));\n }\n // A bare text node can never carry a `slot` attribute, so it is only\n // ever assigned to the default slot. When observing a named slot it must\n // not count as content.\n if (this.slotName) {\n return false;\n }\n return node.textContent ? node.textContent.trim().length > 0 : false;\n });\n\n if (hasContent !== this._hasContent) {\n this._hasContent = hasContent;\n this.host.requestUpdate();\n }\n }\n\n /**\n * Checks initial content from light DOM children before the first render,\n * before slots are assigned.\n *\n * This runs from `hostConnected`, which Lit invokes during the host's\n * `connectedCallback` — before the first `update()`. It sets `_hasContent`\n * directly and intentionally does not call `requestUpdate()`: the first\n * render has not happened yet, so it will read the correct value when it\n * runs. This differs from the `ObserveSlotText` mixin, where `slotHasContent`\n * was a reactive `@property` assigned in `update()`. After the first render,\n * `handleSlotChange` (bound via `@slotchange`) and the `characterData`\n * observer take over and do call `requestUpdate()` on change. The\n * controller stories cover initial content being reflected on first paint.\n */\n private checkInitialContent(): void {\n const { childNodes } = this.host;\n const relevant = [...childNodes].filter((node) => {\n const el = node as HTMLElement;\n if (el.tagName) {\n const excluded = this.excludeSelectors.some((sel) => el.matches(sel));\n if (excluded) {\n return false;\n }\n // Match slot assignment: named slot checks slot attribute,\n // default slot checks for no slot attribute\n return this.slotName\n ? el.getAttribute('slot') === this.slotName\n : !el.hasAttribute('slot');\n }\n // A bare text node has no `slot` attribute, so it is only assigned to\n // the default slot; it never counts as content for a named slot.\n if (this.slotName) {\n return false;\n }\n return node.textContent ? node.textContent.trim().length > 0 : false;\n });\n this._hasContent = relevant.length > 0;\n }\n\n private checkContent(): void {\n // Re-query assigned nodes from the slot element in the shadow root\n const slot = this.host.shadowRoot?.querySelector(\n this.slotName ? `slot[name=\"${this.slotName}\"]` : 'slot:not([name])'\n ) as HTMLSlotElement | null;\n if (slot) {\n const nodes = slot.assignedNodes({ flatten: true });\n this.evaluateNodes(nodes);\n }\n }\n\n hostConnected(): void {\n this.observer.observe(this.host, {\n characterData: true,\n subtree: true,\n });\n this.checkInitialContent();\n }\n\n hostDisconnected(): void {\n this.observer.disconnect();\n }\n}\n"],"mappings":";AAkEA,IAAa,IAAb,MAA8D;CAO5D,YAAY,GAAuB,IAAyB,EAAE,EAAE;;AAM9D,qBARoB,6BAkCF,MAAuB;GAEzC,IAAM,IADO,EAAM,OACA,cAAc,EAAE,SAAS,IAAM,CAAC;AACnD,QAAK,cAAc,EAAM;KAlCzB,KAAK,OAAO,GACZ,KAAK,YAAA,IAAW,EAAO,aAAA,OAAY,KAAZ,GACvB,KAAK,oBAAA,IAAmB,EAAO,qBAAA,OAAoB,EAAE,GAAtB,GAC/B,KAAK,KAAK,cAAc,KAAK,EAE7B,KAAK,WAAW,IAAI,kBAAkB,MAAc;AAClD,QAAK,IAAM,KAAY,EACrB,KAAI,EAAS,SAAS,iBAAiB;AACrC,SAAK,cAAc;AACnB;;IAGJ;;CAOJ,IAAI,aAAsB;AACxB,SAAO,KAAK;;CAiBd,cAAsB,GAA6B;EACjD,IAAM,IAAa,CAAC,GAAG,EAAM,CAAC,MAAM,MAAS;GAC3C,IAAM,IAAK;AAUX,UATI,EAAG,UACE,CAAC,KAAK,iBAAiB,MAAM,MAAQ,EAAG,QAAQ,EAAI,CAAC,GAK1D,KAAK,WACA,KAEF,EAAK,cAAc,EAAK,YAAY,MAAM,CAAC,SAAS,IAAI;IAC/D;AAEF,EAAI,MAAe,KAAK,gBACtB,KAAK,cAAc,GACnB,KAAK,KAAK,eAAe;;CAkB7B,sBAAoC;EAClC,IAAM,EAAE,kBAAe,KAAK;AAqB5B,OAAK,cApBY,CAAC,GAAG,EAAW,CAAC,QAAQ,MAAS;GAChD,IAAM,IAAK;AAiBX,UAhBI,EAAG,UACY,KAAK,iBAAiB,MAAM,MAAQ,EAAG,QAAQ,EAAI,CAAC,GAE5D,KAIF,KAAK,WACR,EAAG,aAAa,OAAO,KAAK,KAAK,WACjC,CAAC,EAAG,aAAa,OAAO,GAI1B,KAAK,WACA,KAEF,EAAK,cAAc,EAAK,YAAY,MAAM,CAAC,SAAS,IAAI;IAC/D,CAC0B,SAAS;;CAGvC,eAA6B;;EAE3B,IAAM,KAAA,IAAO,KAAK,KAAK,eAAA,OAAA,KAAA,IAAA,EAAY,cACjC,KAAK,WAAW,cAAc,KAAK,SAAS,MAAM,mBACnD;AACD,MAAI,GAAM;GACR,IAAM,IAAQ,EAAK,cAAc,EAAE,SAAS,IAAM,CAAC;AACnD,QAAK,cAAc,EAAM;;;CAI7B,gBAAsB;AAKpB,EAJA,KAAK,SAAS,QAAQ,KAAK,MAAM;GAC/B,eAAe;GACf,SAAS;GACV,CAAC,EACF,KAAK,qBAAqB;;CAG5B,mBAAyB;AACvB,OAAK,SAAS,YAAY"}
@@ -10,5 +10,5 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  export { defineElement } from './define-element.js';
13
- export { SpectrumElement, SpectrumMixin, type SpectrumInterface, } from './spectrum-element.js';
13
+ export { SpectrumElement } from './spectrum-element.js';
14
14
  export { coreVersion, version } from './version.js';