@spectrum-web-components/shared 1.12.0-testing.20260223092154 → 2.0.0-next.20260512072922
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/package.json +2 -3
- package/src/get-label-from-slot.d.ts +1 -1
- package/src/get-label-from-slot.dev.js +17 -1
- package/src/get-label-from-slot.dev.js.map +2 -2
- package/src/get-label-from-slot.js +1 -1
- package/src/get-label-from-slot.js.map +3 -3
- package/src/observe-slot-presence.d.ts +12 -2
- package/src/observe-slot-presence.dev.js +67 -1
- package/src/observe-slot-presence.dev.js.map +2 -2
- package/src/observe-slot-presence.js +1 -1
- package/src/observe-slot-presence.js.map +3 -3
- package/src/observe-slot-text.d.ts +11 -2
- package/src/observe-slot-text.dev.js +93 -1
- package/src/observe-slot-text.dev.js.map +2 -2
- package/src/observe-slot-text.js +1 -1
- package/src/observe-slot-text.js.map +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.20260512072922",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Adobe",
|
|
@@ -96,8 +96,7 @@
|
|
|
96
96
|
"types": "./src/index.d.ts",
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@lit-labs/observers": "2.0.2",
|
|
99
|
-
"@spectrum-web-components/base": "
|
|
100
|
-
"@spectrum-web-components/core": "0.0.5-testing.20260223092154",
|
|
99
|
+
"@spectrum-web-components/base": "2.0.0-next.20260512072922",
|
|
101
100
|
"focus-visible": "5.2.1"
|
|
102
101
|
},
|
|
103
102
|
"keywords": [
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export declare const getLabelFromSlot: (label: string, slotEl: HTMLSlotElement) => string | null;
|
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
export
|
|
2
|
+
export const getLabelFromSlot = (label, slotEl) => {
|
|
3
|
+
if (label) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
const textContent = slotEl.assignedNodes().reduce((accumulator, node) => {
|
|
7
|
+
if (node.textContent) {
|
|
8
|
+
return accumulator + node.textContent;
|
|
9
|
+
} else {
|
|
10
|
+
return accumulator;
|
|
11
|
+
}
|
|
12
|
+
}, "");
|
|
13
|
+
if (textContent) {
|
|
14
|
+
return textContent.trim();
|
|
15
|
+
} else {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
3
19
|
//# sourceMappingURL=get-label-from-slot.dev.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["get-label-from-slot.ts"],
|
|
4
|
-
"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 */\nexport
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"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\nexport const getLabelFromSlot = (\n label: string,\n slotEl: HTMLSlotElement\n): string | null => {\n if (label) {\n return null;\n }\n const textContent = slotEl\n .assignedNodes()\n .reduce((accumulator: string, node: Node) => {\n if (node.textContent) {\n return accumulator + node.textContent;\n } else {\n return accumulator;\n }\n }, '');\n if (textContent) {\n return textContent.trim();\n } else {\n return null;\n }\n};\n"],
|
|
5
|
+
"mappings": ";AAYO,aAAM,mBAAmB,CAC9B,OACA,WACkB;AAClB,MAAI,OAAO;AACT,WAAO;AAAA,EACT;AACA,QAAM,cAAc,OACjB,cAAc,EACd,OAAO,CAAC,aAAqB,SAAe;AAC3C,QAAI,KAAK,aAAa;AACpB,aAAO,cAAc,KAAK;AAAA,IAC5B,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF,GAAG,EAAE;AACP,MAAI,aAAa;AACf,WAAO,YAAY,KAAK;AAAA,EAC1B,OAAO;AACL,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";export{
|
|
1
|
+
"use strict";export const getLabelFromSlot=(r,l)=>{if(r)return null;const t=l.assignedNodes().reduce((e,n)=>n.textContent?e+n.textContent:e,"");return t?t.trim():null};
|
|
2
2
|
//# sourceMappingURL=get-label-from-slot.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["get-label-from-slot.ts"],
|
|
4
|
-
"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 */\nexport
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"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\nexport const getLabelFromSlot = (\n label: string,\n slotEl: HTMLSlotElement\n): string | null => {\n if (label) {\n return null;\n }\n const textContent = slotEl\n .assignedNodes()\n .reduce((accumulator: string, node: Node) => {\n if (node.textContent) {\n return accumulator + node.textContent;\n } else {\n return accumulator;\n }\n }, '');\n if (textContent) {\n return textContent.trim();\n } else {\n return null;\n }\n};\n"],
|
|
5
|
+
"mappings": "aAYO,aAAM,iBAAmB,CAC9BA,EACAC,IACkB,CAClB,GAAID,EACF,OAAO,KAET,MAAME,EAAcD,EACjB,cAAc,EACd,OAAO,CAACE,EAAqBC,IACxBA,EAAK,YACAD,EAAcC,EAAK,YAEnBD,EAER,EAAE,EACP,OAAID,EACKA,EAAY,KAAK,EAEjB,IAEX",
|
|
6
|
+
"names": ["label", "slotEl", "textContent", "accumulator", "node"]
|
|
7
7
|
}
|
|
@@ -9,5 +9,15 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import { ReactiveElement } from 'lit';
|
|
13
|
+
type Constructor<T = Record<string, unknown>> = {
|
|
14
|
+
new (...args: any[]): T;
|
|
15
|
+
prototype: T;
|
|
16
|
+
};
|
|
17
|
+
export interface SlotPresenceObservingInterface {
|
|
18
|
+
slotContentIsPresent: boolean;
|
|
19
|
+
getSlotContentPresence(selector: string): boolean;
|
|
20
|
+
managePresenceObservedSlot(): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(constructor: T, lightDomSelector: string | string[]): T & Constructor<SlotPresenceObservingInterface>;
|
|
23
|
+
export {};
|
|
@@ -1,3 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
import { MutationController } from "@lit-labs/observers/mutation-controller.js";
|
|
3
|
+
const slotContentIsPresent = Symbol("slotContentIsPresent");
|
|
4
|
+
export function ObserveSlotPresence(constructor, lightDomSelector) {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const lightDomSelectors = Array.isArray(lightDomSelector) ? lightDomSelector : [lightDomSelector];
|
|
7
|
+
class SlotPresenceObservingElement extends (_b = constructor, _a = slotContentIsPresent, _b) {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
constructor(...args) {
|
|
10
|
+
super(...args);
|
|
11
|
+
this[_a] = /* @__PURE__ */ new Map();
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
this.managePresenceObservedSlot = () => {
|
|
16
|
+
let changes = false;
|
|
17
|
+
lightDomSelectors.forEach((selector) => {
|
|
18
|
+
const nextValue = !!this.querySelector(`:scope > ${selector}`);
|
|
19
|
+
const previousValue = this[slotContentIsPresent].get(selector) || false;
|
|
20
|
+
changes = changes || previousValue !== nextValue;
|
|
21
|
+
this[slotContentIsPresent].set(
|
|
22
|
+
selector,
|
|
23
|
+
!!this.querySelector(`:scope > ${selector}`)
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
if (changes) {
|
|
27
|
+
this.updateComplete.then(() => {
|
|
28
|
+
this.requestUpdate();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
new MutationController(this, {
|
|
33
|
+
config: {
|
|
34
|
+
childList: true,
|
|
35
|
+
subtree: true
|
|
36
|
+
},
|
|
37
|
+
callback: () => {
|
|
38
|
+
this.managePresenceObservedSlot();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
this.managePresenceObservedSlot();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
get slotContentIsPresent() {
|
|
47
|
+
if (lightDomSelectors.length === 1) {
|
|
48
|
+
return this[slotContentIsPresent].get(lightDomSelectors[0]) || false;
|
|
49
|
+
} else {
|
|
50
|
+
throw new Error(
|
|
51
|
+
"Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
getSlotContentPresence(selector) {
|
|
59
|
+
if (this[slotContentIsPresent].has(selector)) {
|
|
60
|
+
return this[slotContentIsPresent].get(selector) || false;
|
|
61
|
+
}
|
|
62
|
+
throw new Error(
|
|
63
|
+
`The provided selector \`${selector}\` is not being observed.`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return SlotPresenceObservingElement;
|
|
68
|
+
}
|
|
3
69
|
//# sourceMappingURL=observe-slot-presence.dev.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["observe-slot-presence.ts"],
|
|
4
|
-
"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 */\
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"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 */\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 * @internal\n */\n public get slotContentIsPresent(): boolean {\n if (lightDomSelectors.length === 1) {\n return this[slotContentIsPresent].get(lightDomSelectors[0]) || false;\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 /**\n * @internal\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 /**\n * @internal\n */\n public managePresenceObservedSlot = (): void => {\n let changes = false;\n lightDomSelectors.forEach((selector) => {\n const nextValue = !!this.querySelector(`:scope > ${selector}`);\n const previousValue = 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"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,0BAA0B;AAEnC,MAAM,uBAAuB,OAAO,sBAAsB;AAcnD,gBAAS,oBACd,aACA,kBACiD;AA/BnD;AAgCE,QAAM,oBAAoB,MAAM,QAAQ,gBAAgB,IACpD,mBACA,CAAC,gBAAgB;AAAA,EACrB,MAAM,sCACI,kBAgCC,2BAhCD,IAEV;AAAA;AAAA,IAEE,eAAe,MAAa;AAC1B,YAAM,GAAG,IAAI;AA2Bf,WAAS,MAA8C,oBAAI,IAAI;AAiB/D;AAAA;AAAA;AAAA,WAAO,6BAA6B,MAAY;AAC9C,YAAI,UAAU;AACd,0BAAkB,QAAQ,CAAC,aAAa;AACtC,gBAAM,YAAY,CAAC,CAAC,KAAK,cAAc,YAAY,QAAQ,EAAE;AAC7D,gBAAM,gBAAgB,KAAK,oBAAoB,EAAE,IAAI,QAAQ,KAAK;AAClE,oBAAU,WAAW,kBAAkB;AACvC,eAAK,oBAAoB,EAAE;AAAA,YACzB;AAAA,YACA,CAAC,CAAC,KAAK,cAAc,YAAY,QAAQ,EAAE;AAAA,UAC7C;AAAA,QACF,CAAC;AACD,YAAI,SAAS;AACX,eAAK,eAAe,KAAK,MAAM;AAC7B,iBAAK,cAAc;AAAA,UACrB,CAAC;AAAA,QACH;AAAA,MACF;AA1DE,UAAI,mBAAmB,MAAM;AAAA,QAC3B,QAAQ;AAAA,UACN,WAAW;AAAA,UACX,SAAS;AAAA,QACX;AAAA,QACA,UAAU,MAAM;AACd,eAAK,2BAA2B;AAAA,QAClC;AAAA,MACF,CAAC;AAED,WAAK,2BAA2B;AAAA,IAClC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAW,uBAAgC;AACzC,UAAI,kBAAkB,WAAW,GAAG;AAClC,eAAO,KAAK,oBAAoB,EAAE,IAAI,kBAAkB,CAAC,CAAC,KAAK;AAAA,MACjE,OAAO;AACL,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAMO,uBAAuB,UAA2B;AACvD,UAAI,KAAK,oBAAoB,EAAE,IAAI,QAAQ,GAAG;AAC5C,eAAO,KAAK,oBAAoB,EAAE,IAAI,QAAQ,KAAK;AAAA,MACrD;AACA,YAAM,IAAI;AAAA,QACR,2BAA2B,QAAQ;AAAA,MACrC;AAAA,IACF;AAAA,EAsBF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";import{MutationController as u}from"@lit-labs/observers/mutation-controller.js";const t=Symbol("slotContentIsPresent");export function ObserveSlotPresence(l,s){var o,i;const r=Array.isArray(s)?s:[s];class a extends(i=l,o=t,i){constructor(...e){super(...e);this[o]=new Map;this.managePresenceObservedSlot=()=>{let e=!1;r.forEach(n=>{const c=!!this.querySelector(`:scope > ${n}`),g=this[t].get(n)||!1;e=e||g!==c,this[t].set(n,!!this.querySelector(`:scope > ${n}`))}),e&&this.updateComplete.then(()=>{this.requestUpdate()})};new u(this,{config:{childList:!0,subtree:!0},callback:()=>{this.managePresenceObservedSlot()}}),this.managePresenceObservedSlot()}get slotContentIsPresent(){if(r.length===1)return this[t].get(r[0])||!1;throw new Error("Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.")}getSlotContentPresence(e){if(this[t].has(e))return this[t].get(e)||!1;throw new Error(`The provided selector \`${e}\` is not being observed.`)}}return a}
|
|
2
2
|
//# sourceMappingURL=observe-slot-presence.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["observe-slot-presence.ts"],
|
|
4
|
-
"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 */\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"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 */\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 * @internal\n */\n public get slotContentIsPresent(): boolean {\n if (lightDomSelectors.length === 1) {\n return this[slotContentIsPresent].get(lightDomSelectors[0]) || false;\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 /**\n * @internal\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 /**\n * @internal\n */\n public managePresenceObservedSlot = (): void => {\n let changes = false;\n lightDomSelectors.forEach((selector) => {\n const nextValue = !!this.querySelector(`:scope > ${selector}`);\n const previousValue = 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"],
|
|
5
|
+
"mappings": "aAYA,OAAS,sBAAAA,MAA0B,6CAEnC,MAAMC,EAAuB,OAAO,sBAAsB,EAcnD,gBAAS,oBACdC,EACAC,EACiD,CA/BnD,IAAAC,EAAAC,EAgCE,MAAMC,EAAoB,MAAM,QAAQH,CAAgB,EACpDA,EACA,CAACA,CAAgB,EACrB,MAAMI,UACIF,EAAAH,EAgCCE,EAAAH,EAhCDI,EAEV,CAEE,eAAeG,EAAa,CAC1B,MAAM,GAAGA,CAAI,EA2Bf,KAASJ,GAA8C,IAAI,IAiB3D,KAAO,2BAA6B,IAAY,CAC9C,IAAIK,EAAU,GACdH,EAAkB,QAASI,GAAa,CACtC,MAAMC,EAAY,CAAC,CAAC,KAAK,cAAc,YAAYD,CAAQ,EAAE,EACvDE,EAAgB,KAAKX,CAAoB,EAAE,IAAIS,CAAQ,GAAK,GAClED,EAAUA,GAAWG,IAAkBD,EACvC,KAAKV,CAAoB,EAAE,IACzBS,EACA,CAAC,CAAC,KAAK,cAAc,YAAYA,CAAQ,EAAE,CAC7C,CACF,CAAC,EACGD,GACF,KAAK,eAAe,KAAK,IAAM,CAC7B,KAAK,cAAc,CACrB,CAAC,CAEL,EA1DE,IAAIT,EAAmB,KAAM,CAC3B,OAAQ,CACN,UAAW,GACX,QAAS,EACX,EACA,SAAU,IAAM,CACd,KAAK,2BAA2B,CAClC,CACF,CAAC,EAED,KAAK,2BAA2B,CAClC,CAKA,IAAW,sBAAgC,CACzC,GAAIM,EAAkB,SAAW,EAC/B,OAAO,KAAKL,CAAoB,EAAE,IAAIK,EAAkB,CAAC,CAAC,GAAK,GAE/D,MAAM,IAAI,MACR,8GACF,CAEJ,CAMO,uBAAuBI,EAA2B,CACvD,GAAI,KAAKT,CAAoB,EAAE,IAAIS,CAAQ,EACzC,OAAO,KAAKT,CAAoB,EAAE,IAAIS,CAAQ,GAAK,GAErD,MAAM,IAAI,MACR,2BAA2BA,CAAQ,2BACrC,CACF,CAsBF,CACA,OAAOH,CACT",
|
|
6
|
+
"names": ["MutationController", "slotContentIsPresent", "constructor", "lightDomSelector", "_a", "_b", "lightDomSelectors", "SlotPresenceObservingElement", "args", "changes", "selector", "nextValue", "previousValue"]
|
|
7
7
|
}
|
|
@@ -9,5 +9,14 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import { ReactiveElement } from 'lit';
|
|
13
|
+
type Constructor<T = Record<string, unknown>> = {
|
|
14
|
+
new (...args: any[]): T;
|
|
15
|
+
prototype: T;
|
|
16
|
+
};
|
|
17
|
+
export interface SlotTextObservingInterface {
|
|
18
|
+
slotHasContent: boolean;
|
|
19
|
+
manageTextObservedSlot(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare function ObserveSlotText<T extends Constructor<ReactiveElement>>(constructor: T, slotName?: string, excludedSelectors?: string[]): T & Constructor<SlotTextObservingInterface>;
|
|
22
|
+
export {};
|
|
@@ -1,3 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
+
if (decorator = decorators[i])
|
|
8
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
+
if (kind && result) __defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import { property, queryAssignedNodes } from "lit/decorators.js";
|
|
13
|
+
import { MutationController } from "@lit-labs/observers/mutation-controller.js";
|
|
14
|
+
const assignedNodesList = Symbol("assignedNodes");
|
|
15
|
+
export function ObserveSlotText(constructor, slotName, excludedSelectors = []) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const notExcluded = (el) => (selector) => {
|
|
18
|
+
return el.matches(selector);
|
|
19
|
+
};
|
|
20
|
+
class SlotTextObservingElement extends (_b = constructor, _a = assignedNodesList, _b) {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
constructor(...args) {
|
|
23
|
+
super(...args);
|
|
24
|
+
this.slotHasContent = false;
|
|
25
|
+
new MutationController(this, {
|
|
26
|
+
config: {
|
|
27
|
+
characterData: true,
|
|
28
|
+
subtree: true
|
|
29
|
+
},
|
|
30
|
+
callback: (mutationsList) => {
|
|
31
|
+
for (const mutation of mutationsList) {
|
|
32
|
+
if (mutation.type === "characterData") {
|
|
33
|
+
this.manageTextObservedSlot();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
manageTextObservedSlot() {
|
|
44
|
+
if (!this[assignedNodesList]) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const assignedNodes = [...this[assignedNodesList]].filter(
|
|
48
|
+
(currentNode) => {
|
|
49
|
+
const node = currentNode;
|
|
50
|
+
if (node.tagName) {
|
|
51
|
+
return !excludedSelectors.some(notExcluded(node));
|
|
52
|
+
}
|
|
53
|
+
return node.textContent ? node.textContent.trim() : false;
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
this.slotHasContent = assignedNodes.length > 0;
|
|
57
|
+
}
|
|
58
|
+
update(changedProperties) {
|
|
59
|
+
if (!this.hasUpdated) {
|
|
60
|
+
const { childNodes } = this;
|
|
61
|
+
const textNodes = [...childNodes].filter((currentNode) => {
|
|
62
|
+
const node = currentNode;
|
|
63
|
+
if (node.tagName) {
|
|
64
|
+
const excluded = excludedSelectors.some(notExcluded(node));
|
|
65
|
+
return !excluded ? (
|
|
66
|
+
// This pass happens at element upgrade and before slot rendering.
|
|
67
|
+
// Confirm it would exist in a targeted slot if there was one supplied.
|
|
68
|
+
slotName ? node.getAttribute("slot") === slotName : !node.hasAttribute("slot")
|
|
69
|
+
) : false;
|
|
70
|
+
}
|
|
71
|
+
return node.textContent ? node.textContent.trim() : false;
|
|
72
|
+
});
|
|
73
|
+
this.slotHasContent = textNodes.length > 0;
|
|
74
|
+
}
|
|
75
|
+
super.update(changedProperties);
|
|
76
|
+
}
|
|
77
|
+
firstUpdated(changedProperties) {
|
|
78
|
+
super.firstUpdated(changedProperties);
|
|
79
|
+
this.updateComplete.then(() => {
|
|
80
|
+
this.manageTextObservedSlot();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
__decorateClass([
|
|
85
|
+
property({ type: Boolean, attribute: false })
|
|
86
|
+
], SlotTextObservingElement.prototype, "slotHasContent", 2);
|
|
87
|
+
__decorateClass([
|
|
88
|
+
queryAssignedNodes({
|
|
89
|
+
slot: slotName,
|
|
90
|
+
flatten: true
|
|
91
|
+
})
|
|
92
|
+
], SlotTextObservingElement.prototype, _a, 2);
|
|
93
|
+
return SlotTextObservingElement;
|
|
94
|
+
}
|
|
3
95
|
//# sourceMappingURL=observe-slot-text.dev.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["observe-slot-text.ts"],
|
|
4
|
-
"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 */\
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"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 */\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 /**\n * @internal\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 /**\n * @internal\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(notExcluded(node));\n return !excluded\n ? // This pass happens at element upgrade and before slot rendering.\n // Confirm it would exist 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(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.updateComplete.then(() => {\n this.manageTextObservedSlot();\n });\n }\n }\n return SlotTextObservingElement;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA,SAAS,UAAU,0BAA0B;AAC7C,SAAS,0BAA0B;AAEnC,MAAM,oBAAoB,OAAO,eAAe;AAazC,gBAAS,gBACd,aACA,UACA,oBAA8B,CAAC,GACc;AAhC/C;AAiCE,QAAM,cAAc,CAAC,OAAoB,CAAC,aAAqB;AAC7D,WAAO,GAAG,QAAQ,QAAQ;AAAA,EAC5B;AAAA,EAEA,MAAM,kCACI,kBAiCC,wBAjCD,IAEV;AAAA;AAAA,IAEE,eAAe,MAAa;AAC1B,YAAM,GAAG,IAAI;AAsBf,WAAO,iBAAiB;AApBtB,UAAI,mBAAmB,MAAM;AAAA,QAC3B,QAAQ;AAAA,UACN,eAAe;AAAA,UACf,SAAS;AAAA,QACX;AAAA,QACA,UAAU,CAAC,kBAAyC;AAClD,qBAAW,YAAY,eAAe;AACpC,gBAAI,SAAS,SAAS,iBAAiB;AACrC,mBAAK,uBAAuB;AAC5B;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA;AAAA;AAAA;AAAA,IAiBO,yBAA+B;AACpC,UAAI,CAAC,KAAK,iBAAiB,GAAG;AAC5B;AAAA,MACF;AACA,YAAM,gBAAgB,CAAC,GAAG,KAAK,iBAAiB,CAAC,EAAE;AAAA,QACjD,CAAC,gBAAgB;AACf,gBAAM,OAAO;AACb,cAAI,KAAK,SAAS;AAChB,mBAAO,CAAC,kBAAkB,KAAK,YAAY,IAAI,CAAC;AAAA,UAClD;AACA,iBAAO,KAAK,cAAc,KAAK,YAAY,KAAK,IAAI;AAAA,QACtD;AAAA,MACF;AACA,WAAK,iBAAiB,cAAc,SAAS;AAAA,IAC/C;AAAA,IAEmB,OAAO,mBAAyC;AACjE,UAAI,CAAC,KAAK,YAAY;AACpB,cAAM,EAAE,WAAW,IAAI;AACvB,cAAM,YAAY,CAAC,GAAG,UAAU,EAAE,OAAO,CAAC,gBAAgB;AACxD,gBAAM,OAAO;AACb,cAAI,KAAK,SAAS;AAChB,kBAAM,WAAW,kBAAkB,KAAK,YAAY,IAAI,CAAC;AACzD,mBAAO,CAAC;AAAA;AAAA;AAAA,cAGJ,WACE,KAAK,aAAa,MAAM,MAAM,WAC9B,CAAC,KAAK,aAAa,MAAM;AAAA,gBAC3B;AAAA,UACN;AACA,iBAAO,KAAK,cAAc,KAAK,YAAY,KAAK,IAAI;AAAA,QACtD,CAAC;AACD,aAAK,iBAAiB,UAAU,SAAS;AAAA,MAC3C;AACA,YAAM,OAAO,iBAAiB;AAAA,IAChC;AAAA,IAEmB,aAAa,mBAAyC;AACvE,YAAM,aAAa,iBAAiB;AACpC,WAAK,eAAe,KAAK,MAAM;AAC7B,aAAK,uBAAuB;AAAA,MAC9B,CAAC;AAAA,IACH;AAAA,EACF;AAvDS;AAAA,IADN,SAAS,EAAE,MAAM,SAAS,WAAW,MAAM,CAAC;AAAA,KA3BzC,yBA4BG;AAME;AAAA,IAJR,mBAAmB;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,KAjCG,yBAkCK;AAkDX,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/observe-slot-text.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";var h=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var u=(c,e,s,o)=>{for(var t=o>1?void 0:o?x(e,s):e,a=c.length-1,i;a>=0;a--)(i=c[a])&&(t=(o?i(e,s,t):i(t))||t);return o&&t&&h(e,s,t),t};import{property as T,queryAssignedNodes as b}from"lit/decorators.js";import{MutationController as v}from"@lit-labs/observers/mutation-controller.js";const p=Symbol("assignedNodes");export function ObserveSlotText(c,e,s=[]){var a,i;const o=f=>m=>f.matches(m);class t extends(i=c,a=p,i){constructor(...n){super(...n);this.slotHasContent=!1;new v(this,{config:{characterData:!0,subtree:!0},callback:d=>{for(const r of d)if(r.type==="characterData"){this.manageTextObservedSlot();return}}})}manageTextObservedSlot(){if(!this[p])return;const n=[...this[p]].filter(d=>{const r=d;return r.tagName?!s.some(o(r)):r.textContent?r.textContent.trim():!1});this.slotHasContent=n.length>0}update(n){if(!this.hasUpdated){const{childNodes:d}=this,r=[...d].filter(g=>{const l=g;return l.tagName?s.some(o(l))?!1:e?l.getAttribute("slot")===e:!l.hasAttribute("slot"):l.textContent?l.textContent.trim():!1});this.slotHasContent=r.length>0}super.update(n)}firstUpdated(n){super.firstUpdated(n),this.updateComplete.then(()=>{this.manageTextObservedSlot()})}}return u([T({type:Boolean,attribute:!1})],t.prototype,"slotHasContent",2),u([b({slot:e,flatten:!0})],t.prototype,a,2),t}
|
|
2
2
|
//# sourceMappingURL=observe-slot-text.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["observe-slot-text.ts"],
|
|
4
|
-
"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 */\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"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 */\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 /**\n * @internal\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 /**\n * @internal\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(notExcluded(node));\n return !excluded\n ? // This pass happens at element upgrade and before slot rendering.\n // Confirm it would exist 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(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.updateComplete.then(() => {\n this.manageTextObservedSlot();\n });\n }\n }\n return SlotTextObservingElement;\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OAAS,YAAAA,EAAU,sBAAAC,MAA0B,oBAC7C,OAAS,sBAAAC,MAA0B,6CAEnC,MAAMC,EAAoB,OAAO,eAAe,EAazC,gBAAS,gBACdC,EACAC,EACAC,EAA8B,CAAC,EACc,CAhC/C,IAAAC,EAAAC,EAiCE,MAAMC,EAAeC,GAAqBC,GACjCD,EAAG,QAAQC,CAAQ,EAG5B,MAAMC,UACIJ,EAAAJ,EAiCCG,EAAAJ,EAjCDK,EAEV,CAEE,eAAeK,EAAa,CAC1B,MAAM,GAAGA,CAAI,EAsBf,KAAO,eAAiB,GApBtB,IAAIX,EAAmB,KAAM,CAC3B,OAAQ,CACN,cAAe,GACf,QAAS,EACX,EACA,SAAWY,GAAyC,CAClD,UAAWC,KAAYD,EACrB,GAAIC,EAAS,OAAS,gBAAiB,CACrC,KAAK,uBAAuB,EAC5B,MACF,CAEJ,CACF,CAAC,CACH,CAiBO,wBAA+B,CACpC,GAAI,CAAC,KAAKZ,CAAiB,EACzB,OAEF,MAAMa,EAAgB,CAAC,GAAG,KAAKb,CAAiB,CAAC,EAAE,OAChDc,GAAgB,CACf,MAAMC,EAAOD,EACb,OAAIC,EAAK,QACA,CAACZ,EAAkB,KAAKG,EAAYS,CAAI,CAAC,EAE3CA,EAAK,YAAcA,EAAK,YAAY,KAAK,EAAI,EACtD,CACF,EACA,KAAK,eAAiBF,EAAc,OAAS,CAC/C,CAEmB,OAAOG,EAAyC,CACjE,GAAI,CAAC,KAAK,WAAY,CACpB,KAAM,CAAE,WAAAC,CAAW,EAAI,KACjBC,EAAY,CAAC,GAAGD,CAAU,EAAE,OAAQH,GAAgB,CACxD,MAAMC,EAAOD,EACb,OAAIC,EAAK,QACUZ,EAAkB,KAAKG,EAAYS,CAAI,CAAC,EAOrD,GAHAb,EACEa,EAAK,aAAa,MAAM,IAAMb,EAC9B,CAACa,EAAK,aAAa,MAAM,EAG1BA,EAAK,YAAcA,EAAK,YAAY,KAAK,EAAI,EACtD,CAAC,EACD,KAAK,eAAiBG,EAAU,OAAS,CAC3C,CACA,MAAM,OAAOF,CAAiB,CAChC,CAEmB,aAAaA,EAAyC,CACvE,MAAM,aAAaA,CAAiB,EACpC,KAAK,eAAe,KAAK,IAAM,CAC7B,KAAK,uBAAuB,CAC9B,CAAC,CACH,CACF,CAvDS,OAAAG,EAAA,CADNtB,EAAS,CAAE,KAAM,QAAS,UAAW,EAAM,CAAC,GA3BzCY,EA4BG,8BAMEU,EAAA,CAJRrB,EAAmB,CAClB,KAAMI,EACN,QAAS,EACX,CAAC,GAjCGO,EAkCK,UAAAL,EAAA,GAkDJK,CACT",
|
|
6
|
+
"names": ["property", "queryAssignedNodes", "MutationController", "assignedNodesList", "constructor", "slotName", "excludedSelectors", "_a", "_b", "notExcluded", "el", "selector", "SlotTextObservingElement", "args", "mutationsList", "mutation", "assignedNodes", "currentNode", "node", "changedProperties", "childNodes", "textNodes", "__decorateClass"]
|
|
7
7
|
}
|