@spectrum-web-components/shared 0.31.1-react.1 → 0.31.1-react.21

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/shared",
3
- "version": "0.31.1-react.1+86ddafa4c",
3
+ "version": "0.31.1-react.21+44f0b1df9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -89,7 +89,7 @@
89
89
  ],
90
90
  "dependencies": {
91
91
  "@lit-labs/observers": "^2.0.0",
92
- "@spectrum-web-components/base": "^0.31.1-react.1+86ddafa4c",
92
+ "@spectrum-web-components/base": "^0.31.1-react.21+44f0b1df9",
93
93
  "focus-visible": "^5.1.0"
94
94
  },
95
95
  "types": "./src/index.d.ts",
@@ -97,5 +97,5 @@
97
97
  "sideEffects": [
98
98
  "./**/*.dev.js"
99
99
  ],
100
- "gitHead": "86ddafa4c44636bbe277444050f67b549af35ad8"
100
+ "gitHead": "44f0b1df9e1ea77d9e931629a63918ceee2744c2"
101
101
  }
@@ -88,7 +88,10 @@ export function ObserveSlotText(constructor, slotName, excludedSelectors = []) {
88
88
  property({ type: Boolean, attribute: false })
89
89
  ], SlotTextObservingElement.prototype, "slotHasContent", 2);
90
90
  __decorateClass([
91
- queryAssignedNodes(slotName, true)
91
+ queryAssignedNodes({
92
+ slot: slotName,
93
+ flatten: true
94
+ })
92
95
  ], SlotTextObservingElement.prototype, _a, 2);
93
96
  return SlotTextObservingElement;
94
97
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["observe-slot-text.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { PropertyValues, ReactiveElement } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/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(slotName, true)\n private [assignedNodesList]!: NodeListOf<HTMLElement>;\n\n public manageTextObservedSlot(): void {\n if (!this[assignedNodesList]) return;\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"],
5
- "mappings": ";;;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,0BAA0B;AAEnC,MAAM,oBAAoB,OAAO,eAAe;AAazC,gBAAS,gBACZ,aACA,UACA,oBAA8B,CAAC,GACY;AAnC/C;AAoCI,QAAM,cAAc,CAAC,OAAoB,CAAC,aAAqB;AAC3D,WAAO,GAAG,QAAQ,QAAQ;AAAA,EAC9B;AAEA,QAAM,iCACM,YAEZ;AAAA;AAAA,IAEI,eAAe,MAAa;AACxB,YAAM,IAAI;AAmBd,WAAO,iBAAiB;AAjBpB,UAAI,mBAAmB,MAAM;AAAA,QACzB,QAAQ;AAAA,UACJ,eAAe;AAAA,UACf,SAAS;AAAA,QACb;AAAA,QACA,UAAU,CAAC,kBAAyC;AAChD,qBAAW,YAAY,eAAe;AAClC,gBAAI,SAAS,SAAS,iBAAiB;AACnC,mBAAK,uBAAuB;AAC5B;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IAQO,yBAA+B;AAClC,UAAI,CAAC,KAAK,iBAAiB;AAAG;AAC9B,YAAM,gBAAgB,CAAC,GAAG,KAAK,iBAAiB,CAAC,EAAE;AAAA,QAC/C,CAAC,gBAAgB;AACb,gBAAM,OAAO;AACb,cAAI,KAAK,SAAS;AACd,mBAAO,CAAC,kBAAkB,KAAK,YAAY,IAAI,CAAC;AAAA,UACpD;AACA,iBAAO,KAAK,cAAc,KAAK,YAAY,KAAK,IAAI;AAAA,QACxD;AAAA,MACJ;AACA,WAAK,iBAAiB,cAAc,SAAS;AAAA,IACjD;AAAA,IAEmB,OAAO,mBAAyC;AAC/D,UAAI,CAAC,KAAK,YAAY;AAClB,cAAM,EAAE,WAAW,IAAI;AACvB,cAAM,YAAY,CAAC,GAAG,UAAU,EAAE,OAAO,CAAC,gBAAgB;AACtD,gBAAM,OAAO;AACb,cAAI,KAAK,SAAS;AACd,kBAAM,WAAW,kBAAkB;AAAA,cAC/B,YAAY,IAAI;AAAA,YACpB;AACA,mBAAO,CAAC;AAAA;AAAA;AAAA,cAGF,WACI,KAAK,aAAa,MAAM,MAAM,WAC9B,CAAC,KAAK,aAAa,MAAM;AAAA,gBAC7B;AAAA,UACV;AACA,iBAAO,KAAK,cAAc,KAAK,YAAY,KAAK,IAAI;AAAA,QACxD,CAAC;AACD,aAAK,iBAAiB,UAAU,SAAS;AAAA,MAC7C;AACA,YAAM,OAAO,iBAAiB;AAAA,IAClC;AAAA,IAEmB,aACf,mBACI;AACJ,YAAM,aAAa,iBAAiB;AACpC,WAAK,eAAe,KAAK,MAAM;AAC3B,aAAK,uBAAuB;AAAA,MAChC,CAAC;AAAA,IACL;AAAA,EACJ;AApHJ,EAoEiB;AAHF;AAAA,IADN,SAAS,EAAE,MAAM,SAAS,WAAW,MAAM,CAAC;AAAA,KAxB3C,yBAyBK;AAGE;AAAA,IADR,mBAAmB,UAAU,IAAI;AAAA,KA3BhC,yBA4BO;AAiDb,SAAO;AACX;",
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { PropertyValues, ReactiveElement } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/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]) return;\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"],
5
+ "mappings": ";;;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,0BAA0B;AAEnC,MAAM,oBAAoB,OAAO,eAAe;AAazC,gBAAS,gBACZ,aACA,UACA,oBAA8B,CAAC,GACY;AAnC/C;AAoCI,QAAM,cAAc,CAAC,OAAoB,CAAC,aAAqB;AAC3D,WAAO,GAAG,QAAQ,QAAQ;AAAA,EAC9B;AAEA,QAAM,iCACM,YAEZ;AAAA;AAAA,IAEI,eAAe,MAAa;AACxB,YAAM,IAAI;AAmBd,WAAO,iBAAiB;AAjBpB,UAAI,mBAAmB,MAAM;AAAA,QACzB,QAAQ;AAAA,UACJ,eAAe;AAAA,UACf,SAAS;AAAA,QACb;AAAA,QACA,UAAU,CAAC,kBAAyC;AAChD,qBAAW,YAAY,eAAe;AAClC,gBAAI,SAAS,SAAS,iBAAiB;AACnC,mBAAK,uBAAuB;AAC5B;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IAWO,yBAA+B;AAClC,UAAI,CAAC,KAAK,iBAAiB;AAAG;AAC9B,YAAM,gBAAgB,CAAC,GAAG,KAAK,iBAAiB,CAAC,EAAE;AAAA,QAC/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>{for(var t=o>1?void 0:o?h(e,s):e,d=c.length-1,a;d>=0;d--)(a=c[d])&&(t=(o?a(e,s,t):a(t))||t);return o&&t&&g(e,s,t),t};import{property as x,queryAssignedNodes as T}from"@spectrum-web-components/base/src/decorators.js";import{MutationController as b}from"@lit-labs/observers/mutation-controller.js";const p=Symbol("assignedNodes");export function ObserveSlotText(c,e,s=[]){var d;const o=a=>f=>a.matches(f);class t extends c{constructor(...n){super(n);this.slotHasContent=!1;new b(this,{config:{characterData:!0,subtree:!0},callback:l=>{for(const r of l)if(r.type==="characterData"){this.manageTextObservedSlot();return}}})}manageTextObservedSlot(){if(!this[p])return;const n=[...this[p]].filter(l=>{const r=l;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:l}=this,r=[...l].filter(m=>{const i=m;return i.tagName?s.some(o(i))?!1:e?i.getAttribute("slot")===e:!i.hasAttribute("slot"):i.textContent?i.textContent.trim():!1});this.slotHasContent=r.length>0}super.update(n)}firstUpdated(n){super.firstUpdated(n),this.updateComplete.then(()=>{this.manageTextObservedSlot()})}}return d=p,u([x({type:Boolean,attribute:!1})],t.prototype,"slotHasContent",2),u([T(e,!0)],t.prototype,d,2),t}
1
+ "use strict";var g=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var u=(c,e,s,o)=>{for(var t=o>1?void 0:o?h(e,s):e,l=c.length-1,a;l>=0;l--)(a=c[l])&&(t=(o?a(e,s,t):a(t))||t);return o&&t&&g(e,s,t),t};import{property as x,queryAssignedNodes as T}from"@spectrum-web-components/base/src/decorators.js";import{MutationController as b}from"@lit-labs/observers/mutation-controller.js";const p=Symbol("assignedNodes");export function ObserveSlotText(c,e,s=[]){var l;const o=a=>f=>a.matches(f);class t extends c{constructor(...n){super(n);this.slotHasContent=!1;new b(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(m=>{const i=m;return i.tagName?s.some(o(i))?!1:e?i.getAttribute("slot")===e:!i.hasAttribute("slot"):i.textContent?i.textContent.trim():!1});this.slotHasContent=r.length>0}super.update(n)}firstUpdated(n){super.firstUpdated(n),this.updateComplete.then(()=>{this.manageTextObservedSlot()})}}return l=p,u([x({type:Boolean,attribute:!1})],t.prototype,"slotHasContent",2),u([T({slot:e,flatten:!0})],t.prototype,l,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": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { PropertyValues, ReactiveElement } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/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(slotName, true)\n private [assignedNodesList]!: NodeListOf<HTMLElement>;\n\n public manageTextObservedSlot(): void {\n if (!this[assignedNodesList]) return;\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"],
5
- "mappings": "qNAYA,OACI,YAAAA,EACA,sBAAAC,MACG,kDACP,OAAS,sBAAAC,MAA0B,6CAEnC,MAAMC,EAAoB,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,KAAK,uBAAuB,CAChC,CAAC,CACL,CACJ,CApHJ,OAoEiBX,EAAAJ,EAHFkB,EAAA,CADNrB,EAAS,CAAE,KAAM,QAAS,UAAW,EAAM,CAAC,GAxB3CW,EAyBK,8BAGEU,EAAA,CADRpB,EAAmBI,EAAU,EAAI,GA3BhCM,EA4BO,UAAAJ,EAAA,GAiDNI,CACX",
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { PropertyValues, ReactiveElement } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/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]) return;\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"],
5
+ "mappings": "qNAYA,OACI,YAAAA,EACA,sBAAAC,MACG,kDACP,OAAS,sBAAAC,MAA0B,6CAEnC,MAAMC,EAAoB,OAAO,eAAe,EAazC,gBAAS,gBACZC,EACAC,EACAC,EAA8B,CAAC,EACY,CAnC/C,IAAAC,EAoCI,MAAMC,EAAeC,GAAqBC,GAC/BD,EAAG,QAAQC,CAAQ,EAG9B,MAAMC,UACMP,CAEZ,CAEI,eAAeQ,EAAa,CACxB,MAAMA,CAAI,EAmBd,KAAO,eAAiB,GAjBpB,IAAIV,EAAmB,KAAM,CACzB,O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names": ["property", "queryAssignedNodes", "MutationController", "assignedNodesList", "constructor", "slotName", "excludedSelectors", "_a", "notExcluded", "el", "selector", "SlotTextObservingElement", "args", "mutationsList", "mutation", "assignedNodes", "currentNode", "node", "changedProperties", "childNodes", "textNodes", "__decorateClass"]
7
7
  }