@spectrum-web-components/core 0.0.2-snapshot.20260119201148 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export declare const version = "1.11.0-snapshot.20260119201148";
1
+ export declare const version = "1.11.0";
@@ -1,4 +1,4 @@
1
- const o = "1.11.0-snapshot.20260119201148";
1
+ const o = "1.11.0";
2
2
  export {
3
3
  o as version
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../shared/base/version.ts"],"sourcesContent":["// Generated by genversion.\nexport const version = '1.11.0-snapshot.20260119201148';\n"],"names":["version"],"mappings":"AACO,MAAMA,IAAU;"}
1
+ {"version":3,"file":"version.js","sources":["../../../shared/base/version.ts"],"sourcesContent":["// Generated by genversion.\nexport const version = '1.11.0';\n"],"names":["version"],"mappings":"AACO,MAAMA,IAAU;"}
@@ -1,23 +1,12 @@
1
- import { MutationController as g } from "../node_modules/@lit-labs/observers/mutation-controller.js";
2
- const e = Symbol("slotContentIsPresent");
3
- function b(a, r) {
4
- var i, l;
1
+ import { MutationController as u } from "../node_modules/@lit-labs/observers/mutation-controller.js";
2
+ const t = Symbol("slotContentIsPresent");
3
+ function p(l, r) {
4
+ var o, i;
5
5
  const n = Array.isArray(r) ? r : [r];
6
- class c extends (l = a, i = e, l) {
6
+ class a extends (i = l, o = t, i) {
7
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- constructor(...t) {
9
- super(t), this[i] = /* @__PURE__ */ new Map(), this.managePresenceObservedSlot = () => {
10
- let o = !1;
11
- n.forEach((s) => {
12
- const h = !!this.querySelector(`:scope > ${s}`), u = this[e].get(s) || !1;
13
- o = o || u !== h, this[e].set(
14
- s,
15
- !!this.querySelector(`:scope > ${s}`)
16
- );
17
- }), o && this.updateComplete.then(() => {
18
- this.requestUpdate();
19
- });
20
- }, new g(this, {
8
+ constructor(...e) {
9
+ super(...e), this[o] = /* @__PURE__ */ new Map(), new u(this, {
21
10
  config: {
22
11
  childList: !0,
23
12
  subtree: !0
@@ -32,22 +21,34 @@ function b(a, r) {
32
21
  */
33
22
  get slotContentIsPresent() {
34
23
  if (n.length === 1)
35
- return this[e].get(n[0]) || !1;
24
+ return this[t].get(n[0]) || !1;
36
25
  throw new Error(
37
26
  "Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead."
38
27
  );
39
28
  }
40
- getSlotContentPresence(t) {
41
- if (this[e].has(t))
42
- return this[e].get(t) || !1;
29
+ getSlotContentPresence(e) {
30
+ if (this[t].has(e))
31
+ return this[t].get(e) || !1;
43
32
  throw new Error(
44
- `The provided selector \`${t}\` is not being observed.`
33
+ `The provided selector \`${e}\` is not being observed.`
45
34
  );
46
35
  }
36
+ managePresenceObservedSlot() {
37
+ let e = !1;
38
+ n.forEach((s) => {
39
+ const c = !!this.querySelector(`:scope > ${s}`), h = this[t].get(s) || !1;
40
+ e = e || h !== c, this[t].set(
41
+ s,
42
+ !!this.querySelector(`:scope > ${s}`)
43
+ );
44
+ }), e && this.updateComplete.then(() => {
45
+ this.requestUpdate();
46
+ });
47
+ }
47
48
  }
48
- return c;
49
+ return a;
49
50
  }
50
51
  export {
51
- b as ObserveSlotPresence
52
+ p as ObserveSlotPresence
52
53
  };
53
54
  //# sourceMappingURL=observe-slot-presence.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"observe-slot-presence.js","sources":["../../shared/observe-slot-presence.ts"],"sourcesContent":["/**\n * Copyright 2025 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 */\nimport { ReactiveElement } from 'lit';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst slotContentIsPresent = Symbol('slotContentIsPresent');\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport interface SlotPresenceObservingInterface {\n slotContentIsPresent: boolean;\n getSlotContentPresence(selector: string): boolean;\n managePresenceObservedSlot(): void;\n}\n\nexport function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(\n constructor: T,\n lightDomSelector: string | string[]\n): T & Constructor<SlotPresenceObservingInterface> {\n const lightDomSelectors = Array.isArray(lightDomSelector)\n ? lightDomSelector\n : [lightDomSelector];\n class SlotPresenceObservingElement\n extends constructor\n implements SlotPresenceObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(args);\n\n new MutationController(this, {\n config: {\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.managePresenceObservedSlot();\n },\n });\n\n this.managePresenceObservedSlot();\n }\n\n /**\n * @private\n */\n public get slotContentIsPresent(): boolean {\n if (lightDomSelectors.length === 1) {\n return (\n this[slotContentIsPresent].get(lightDomSelectors[0]) ||\n false\n );\n } else {\n throw new Error(\n 'Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.'\n );\n }\n }\n private [slotContentIsPresent]: Map<string, boolean> = new Map();\n\n public getSlotContentPresence(selector: string): boolean {\n if (this[slotContentIsPresent].has(selector)) {\n return this[slotContentIsPresent].get(selector) || false;\n }\n throw new Error(\n `The provided selector \\`${selector}\\` is not being observed.`\n );\n }\n\n public managePresenceObservedSlot = (): void => {\n let changes = false;\n lightDomSelectors.forEach((selector) => {\n const nextValue = !!this.querySelector(`:scope > ${selector}`);\n const previousValue =\n this[slotContentIsPresent].get(selector) || false;\n changes = changes || previousValue !== nextValue;\n this[slotContentIsPresent].set(\n selector,\n !!this.querySelector(`:scope > ${selector}`)\n );\n });\n if (changes) {\n this.updateComplete.then(() => {\n this.requestUpdate();\n });\n }\n };\n }\n return SlotPresenceObservingElement;\n}\n"],"names":["slotContentIsPresent","ObserveSlotPresence","constructor","lightDomSelector","_a","_b","lightDomSelectors","SlotPresenceObservingElement","args","changes","selector","nextValue","previousValue","MutationController"],"mappings":";AAcA,MAAMA,IAAuB,OAAO,sBAAsB;AAcnD,SAASC,EACZC,GACAC,GAC+C;AA/BnD,MAAAC,GAAAC;AAgCI,QAAMC,IAAoB,MAAM,QAAQH,CAAgB,IAClDA,IACA,CAACA,CAAgB;AAAA,EACvB,MAAMI,WACMF,IAAAH,GAmCCE,IAAAJ,GAnCDK,GAEZ;AAAA;AAAA,IAEI,eAAeG,GAAa;AACxB,YAAMA,CAAI,GA8Bd,KAASJ,CAAA,wBAAkD,IAAA,GAW3D,KAAO,6BAA6B,MAAY;AAC5C,YAAIK,IAAU;AACd,QAAAH,EAAkB,QAAQ,CAACI,MAAa;AACpC,gBAAMC,IAAY,CAAC,CAAC,KAAK,cAAc,YAAYD,CAAQ,EAAE,GACvDE,IACF,KAAKZ,CAAoB,EAAE,IAAIU,CAAQ,KAAK;AAChD,UAAAD,IAAUA,KAAWG,MAAkBD,GACvC,KAAKX,CAAoB,EAAE;AAAA,YACvBU;AAAA,YACA,CAAC,CAAC,KAAK,cAAc,YAAYA,CAAQ,EAAE;AAAA,UAAA;AAAA,QAEnD,CAAC,GACGD,KACA,KAAK,eAAe,KAAK,MAAM;AAC3B,eAAK,cAAA;AAAA,QACT,CAAC;AAAA,MAET,GAxDI,IAAII,EAAmB,MAAM;AAAA,QACzB,QAAQ;AAAA,UACJ,WAAW;AAAA,UACX,SAAS;AAAA,QAAA;AAAA,QAEb,UAAU,MAAM;AACZ,eAAK,2BAAA;AAAA,QACT;AAAA,MAAA,CACH,GAED,KAAK,2BAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAW,uBAAgC;AACvC,UAAIP,EAAkB,WAAW;AAC7B,eACI,KAAKN,CAAoB,EAAE,IAAIM,EAAkB,CAAC,CAAC,KACnD;AAGJ,YAAM,IAAI;AAAA,QACN;AAAA,MAAA;AAAA,IAGZ;AAAA,IAGO,uBAAuBI,GAA2B;AACrD,UAAI,KAAKV,CAAoB,EAAE,IAAIU,CAAQ;AACvC,eAAO,KAAKV,CAAoB,EAAE,IAAIU,CAAQ,KAAK;AAEvD,YAAM,IAAI;AAAA,QACN,2BAA2BA,CAAQ;AAAA,MAAA;AAAA,IAE3C;AAAA,EAAA;AAqBJ,SAAOH;AACX;"}
1
+ {"version":3,"file":"observe-slot-presence.js","sources":["../../shared/observe-slot-presence.ts"],"sourcesContent":["/**\n * Copyright 2025 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 */\nimport { ReactiveElement } from 'lit';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst slotContentIsPresent = Symbol('slotContentIsPresent');\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport interface SlotPresenceObservingInterface {\n slotContentIsPresent: boolean;\n getSlotContentPresence(selector: string): boolean;\n managePresenceObservedSlot(): void;\n}\n\nexport function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(\n constructor: T,\n lightDomSelector: string | string[]\n): T & Constructor<SlotPresenceObservingInterface> {\n const lightDomSelectors = Array.isArray(lightDomSelector)\n ? lightDomSelector\n : [lightDomSelector];\n class SlotPresenceObservingElement\n extends constructor\n implements SlotPresenceObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(...args);\n\n new MutationController(this, {\n config: {\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.managePresenceObservedSlot();\n },\n });\n\n this.managePresenceObservedSlot();\n }\n\n /**\n * @private\n */\n public get slotContentIsPresent(): boolean {\n if (lightDomSelectors.length === 1) {\n return (\n this[slotContentIsPresent].get(lightDomSelectors[0]) ||\n false\n );\n } else {\n throw new Error(\n 'Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.'\n );\n }\n }\n private [slotContentIsPresent]: Map<string, boolean> = new Map();\n\n public getSlotContentPresence(selector: string): boolean {\n if (this[slotContentIsPresent].has(selector)) {\n return this[slotContentIsPresent].get(selector) || false;\n }\n throw new Error(\n `The provided selector \\`${selector}\\` is not being observed.`\n );\n }\n\n public managePresenceObservedSlot(): void {\n let changes = false;\n lightDomSelectors.forEach((selector) => {\n const nextValue = !!this.querySelector(`:scope > ${selector}`);\n const previousValue =\n this[slotContentIsPresent].get(selector) || false;\n changes = changes || previousValue !== nextValue;\n this[slotContentIsPresent].set(\n selector,\n !!this.querySelector(`:scope > ${selector}`)\n );\n });\n if (changes) {\n this.updateComplete.then(() => {\n this.requestUpdate();\n });\n }\n }\n }\n return SlotPresenceObservingElement;\n}\n"],"names":["slotContentIsPresent","ObserveSlotPresence","constructor","lightDomSelector","_a","_b","lightDomSelectors","SlotPresenceObservingElement","args","MutationController","selector","changes","nextValue","previousValue"],"mappings":";AAcA,MAAMA,IAAuB,OAAO,sBAAsB;AAcnD,SAASC,EACZC,GACAC,GAC+C;AA/BnD,MAAAC,GAAAC;AAgCI,QAAMC,IAAoB,MAAM,QAAQH,CAAgB,IAClDA,IACA,CAACA,CAAgB;AAAA,EACvB,MAAMI,WACMF,IAAAH,GAmCCE,IAAAJ,GAnCDK,GAEZ;AAAA;AAAA,IAEI,eAAeG,GAAa;AACxB,YAAM,GAAGA,CAAI,GA8BjB,KAASJ,CAAA,wBAAkD,IAAA,GA5BvD,IAAIK,EAAmB,MAAM;AAAA,QACzB,QAAQ;AAAA,UACJ,WAAW;AAAA,UACX,SAAS;AAAA,QAAA;AAAA,QAEb,UAAU,MAAM;AACZ,eAAK,2BAAA;AAAA,QACT;AAAA,MAAA,CACH,GAED,KAAK,2BAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAW,uBAAgC;AACvC,UAAIH,EAAkB,WAAW;AAC7B,eACI,KAAKN,CAAoB,EAAE,IAAIM,EAAkB,CAAC,CAAC,KACnD;AAGJ,YAAM,IAAI;AAAA,QACN;AAAA,MAAA;AAAA,IAGZ;AAAA,IAGO,uBAAuBI,GAA2B;AACrD,UAAI,KAAKV,CAAoB,EAAE,IAAIU,CAAQ;AACvC,eAAO,KAAKV,CAAoB,EAAE,IAAIU,CAAQ,KAAK;AAEvD,YAAM,IAAI;AAAA,QACN,2BAA2BA,CAAQ;AAAA,MAAA;AAAA,IAE3C;AAAA,IAEO,6BAAmC;AACtC,UAAIC,IAAU;AACd,MAAAL,EAAkB,QAAQ,CAACI,MAAa;AACpC,cAAME,IAAY,CAAC,CAAC,KAAK,cAAc,YAAYF,CAAQ,EAAE,GACvDG,IACF,KAAKb,CAAoB,EAAE,IAAIU,CAAQ,KAAK;AAChD,QAAAC,IAAUA,KAAWE,MAAkBD,GACvC,KAAKZ,CAAoB,EAAE;AAAA,UACvBU;AAAA,UACA,CAAC,CAAC,KAAK,cAAc,YAAYA,CAAQ,EAAE;AAAA,QAAA;AAAA,MAEnD,CAAC,GACGC,KACA,KAAK,eAAe,KAAK,MAAM;AAC3B,aAAK,cAAA;AAAA,MACT,CAAC;AAAA,IAET;AAAA,EAAA;AAEJ,SAAOJ;AACX;"}
@@ -12,7 +12,7 @@ function N(d, n, i = []) {
12
12
  class o extends (t = d, u = f, t) {
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
14
  constructor(...e) {
15
- super(e), this.slotHasContent = !1, new x(this, {
15
+ super(...e), this.slotHasContent = !1, new x(this, {
16
16
  config: {
17
17
  characterData: !0,
18
18
  subtree: !0
@@ -1 +1 @@
1
- {"version":3,"file":"observe-slot-text.js","sources":["../../shared/observe-slot-text.ts"],"sourcesContent":["/**\n * Copyright 2025 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 */\nimport { PropertyValues, ReactiveElement } from 'lit';\nimport { property, queryAssignedNodes } from 'lit/decorators.js';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst assignedNodesList = Symbol('assignedNodes');\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport interface SlotTextObservingInterface {\n slotHasContent: boolean;\n manageTextObservedSlot(): void;\n}\n\nexport function ObserveSlotText<T extends Constructor<ReactiveElement>>(\n constructor: T,\n slotName?: string,\n excludedSelectors: string[] = []\n): T & Constructor<SlotTextObservingInterface> {\n const notExcluded = (el: HTMLElement) => (selector: string) => {\n return el.matches(selector);\n };\n\n class SlotTextObservingElement\n extends constructor\n implements SlotTextObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(args);\n\n new MutationController(this, {\n config: {\n characterData: true,\n subtree: true,\n },\n callback: (mutationsList: Array<MutationRecord>) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'characterData') {\n this.manageTextObservedSlot();\n return;\n }\n }\n },\n });\n }\n\n @property({ type: Boolean, attribute: false })\n public slotHasContent = false;\n\n @queryAssignedNodes({\n slot: slotName,\n flatten: true,\n })\n private [assignedNodesList]!: NodeListOf<HTMLElement>;\n\n public manageTextObservedSlot(): void {\n if (!this[assignedNodesList]) {\n return;\n }\n const assignedNodes = [...this[assignedNodesList]].filter(\n (currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n return !excludedSelectors.some(notExcluded(node));\n }\n return node.textContent ? node.textContent.trim() : false;\n }\n );\n this.slotHasContent = assignedNodes.length > 0;\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (!this.hasUpdated) {\n const { childNodes } = this;\n const textNodes = [...childNodes].filter((currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n const excluded = excludedSelectors.some(\n notExcluded(node)\n );\n return !excluded\n ? // This pass happens at element upgrade and before slot rendering.\n // Confirm it would exisit in a targeted slot if there was one supplied.\n slotName\n ? node.getAttribute('slot') === slotName\n : !node.hasAttribute('slot')\n : false;\n }\n return node.textContent ? node.textContent.trim() : false;\n });\n this.slotHasContent = textNodes.length > 0;\n }\n super.update(changedProperties);\n }\n\n protected override firstUpdated(\n changedProperties: PropertyValues\n ): void {\n super.firstUpdated(changedProperties);\n this.updateComplete.then(() => {\n this.manageTextObservedSlot();\n });\n }\n }\n return SlotTextObservingElement;\n}\n"],"names":["assignedNodesList","ObserveSlotText","constructor","slotName","excludedSelectors","_a","_b","notExcluded","el","selector","SlotTextObservingElement","args","MutationController","mutationsList","mutation","assignedNodes","currentNode","node","changedProperties","childNodes","textNodes","__decorateClass","property","queryAssignedNodes"],"mappings":";;;;;;;AAeA,MAAMA,IAAoB,OAAO,eAAe;AAazC,SAASC,EACZC,GACAC,GACAC,IAA8B,CAAA,GACa;AAhC/C,MAAAC,GAAAC;AAiCI,QAAMC,IAAc,CAACC,MAAoB,CAACC,MAC/BD,EAAG,QAAQC,CAAQ;AAAA,EAG9B,MAAMC,WACMJ,IAAAJ,GA8BCG,IAAAL,GA9BDM,GAEZ;AAAA;AAAA,IAEI,eAAeK,GAAa;AACxB,YAAMA,CAAI,GAmBd,KAAO,iBAAiB,IAjBpB,IAAIC,EAAmB,MAAM;AAAA,QACzB,QAAQ;AA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AW,IAAO;AAAA,EAAA,GAxB3CZ,EAyBK,WAAA,gBAAA,GAMEW,EAAA;AAAA,IAJRE,EAAmB;AAAA,MAChB,MAAMpB;AAAA,MACN,SAAS;AAAA,IAAA,CACZ;AAAA,EAAA,GA9BCO,EA+BO,WAAAL,CAAA,GAmDNK;AACX;"}
1
+ {"version":3,"file":"observe-slot-text.js","sources":["../../shared/observe-slot-text.ts"],"sourcesContent":["/**\n * Copyright 2025 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 */\nimport { PropertyValues, ReactiveElement } from 'lit';\nimport { property, queryAssignedNodes } from 'lit/decorators.js';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nconst assignedNodesList = Symbol('assignedNodes');\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport interface SlotTextObservingInterface {\n slotHasContent: boolean;\n manageTextObservedSlot(): void;\n}\n\nexport function ObserveSlotText<T extends Constructor<ReactiveElement>>(\n constructor: T,\n slotName?: string,\n excludedSelectors: string[] = []\n): T & Constructor<SlotTextObservingInterface> {\n const notExcluded = (el: HTMLElement) => (selector: string) => {\n return el.matches(selector);\n };\n\n class SlotTextObservingElement\n extends constructor\n implements SlotTextObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(...args);\n\n new MutationController(this, {\n config: {\n characterData: true,\n subtree: true,\n },\n callback: (mutationsList: Array<MutationRecord>) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'characterData') {\n this.manageTextObservedSlot();\n return;\n }\n }\n },\n });\n }\n\n @property({ type: Boolean, attribute: false })\n public slotHasContent = false;\n\n @queryAssignedNodes({\n slot: slotName,\n flatten: true,\n })\n private [assignedNodesList]!: NodeListOf<HTMLElement>;\n\n public manageTextObservedSlot(): void {\n if (!this[assignedNodesList]) {\n return;\n }\n const assignedNodes = [...this[assignedNodesList]].filter(\n (currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n return !excludedSelectors.some(notExcluded(node));\n }\n return node.textContent ? node.textContent.trim() : false;\n }\n );\n this.slotHasContent = assignedNodes.length > 0;\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (!this.hasUpdated) {\n const { childNodes } = this;\n const textNodes = [...childNodes].filter((currentNode) => {\n const node = currentNode as HTMLElement;\n if (node.tagName) {\n const excluded = excludedSelectors.some(\n notExcluded(node)\n );\n return !excluded\n ? // This pass happens at element upgrade and before slot rendering.\n // Confirm it would exisit in a targeted slot if there was one supplied.\n slotName\n ? node.getAttribute('slot') === slotName\n : !node.hasAttribute('slot')\n : false;\n }\n return node.textContent ? node.textContent.trim() : false;\n });\n this.slotHasContent = textNodes.length > 0;\n }\n super.update(changedProperties);\n }\n\n protected override firstUpdated(\n changedProperties: PropertyValues\n ): void {\n super.firstUpdated(changedProperties);\n this.updateComplete.then(() => {\n this.manageTextObservedSlot();\n });\n }\n }\n return SlotTextObservingElement;\n}\n"],"names":["assignedNodesList","ObserveSlotText","constructor","slotName","excludedSelectors","_a","_b","notExcluded","el","selector","SlotTextObservingElement","args","MutationController","mutationsList","mutation","assignedNodes","currentNode","node","changedProperties","childNodes","textNodes","__decorateClass","property","queryAssignedNodes"],"mappings":";;;;;;;AAeA,MAAMA,IAAoB,OAAO,eAAe;AAazC,SAASC,EACZC,GACAC,GACAC,IAA8B,CAAA,GACa;AAhC/C,MAAAC,GAAAC;AAiCI,QAAMC,IAAc,CAACC,MAAoB,CAACC,MAC/BD,EAAG,QAAQC,CAAQ;AAAA,EAG9B,MAAMC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I;AACJ,YAAM,aAAaA,CAAiB,GACpC,KAAK,eAAe,KAAK,MAAM;AAC3B,aAAK,uBAAA;AAAA,MACT,CAAC;AAAA,IACL;AAAA,EAAA;AAvDO,SAAAG,EAAA;AAAA,IADNC,EAAS,EAAE,MAAM,SAAS,WAAW,IAAO;AAAA,EAAA,GAxB3CZ,EAyBK,WAAA,gBAAA,GAMEW,EAAA;AAAA,IAJRE,EAAmB;AAAA,MAChB,MAAMpB;AAAA,MACN,SAAS;AAAA,IAAA,CACZ;AAAA,EAAA,GA9BCO,EA+BO,WAAAL,CAAA,GAmDNK;AACX;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/core",
3
- "version": "0.0.2-snapshot.20260119201148",
3
+ "version": "0.0.2",
4
4
  "description": "Abstract base classes for Spectrum Web Components",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Adobe",