@spectrum-web-components/shared
Advanced tools
Comparing version 0.30.1-overlay.30 to 0.30.1-overlay.31
{ | ||
"name": "@spectrum-web-components/shared", | ||
"version": "0.30.1-overlay.30+1df211c75", | ||
"version": "0.30.1-overlay.31+0d83bbe39", | ||
"publishConfig": { | ||
@@ -92,3 +92,3 @@ "access": "public" | ||
"@lit-labs/observers": "^2.0.0", | ||
"@spectrum-web-components/base": "^0.30.1-overlay.30+1df211c75", | ||
"@spectrum-web-components/base": "^0.30.1-overlay.31+0d83bbe39", | ||
"focus-visible": "^5.1.0" | ||
@@ -101,3 +101,3 @@ }, | ||
], | ||
"gitHead": "1df211c7581b6fd6ec624cf2b09bc81aeec29c26" | ||
"gitHead": "0d83bbe39df1adf5e475c05e71ab221b66354a60" | ||
} |
@@ -10,3 +10,3 @@ import { ReactiveElement } from '@spectrum-web-components/base'; | ||
} | ||
export declare function ObserveSlotText<T extends Constructor<ReactiveElement>>(constructor: T, slotName?: string): T & Constructor<SlotTextObservingInterface>; | ||
export declare function ObserveSlotText<T extends Constructor<ReactiveElement>>(constructor: T, slotName?: string, exclude?: string[]): T & Constructor<SlotTextObservingInterface>; | ||
export {}; |
@@ -19,3 +19,3 @@ "use strict"; | ||
const assignedNodesList = Symbol("assignedNodes"); | ||
export function ObserveSlotText(constructor, slotName) { | ||
export function ObserveSlotText(constructor, slotName, exclude) { | ||
var _a; | ||
@@ -48,2 +48,8 @@ class SlotTextObservingElement extends constructor { | ||
if (node.tagName) { | ||
if (exclude == null ? void 0 : exclude.length) { | ||
const shouldExclude = exclude.some( | ||
(selector) => node.matches(selector) | ||
); | ||
return !shouldExclude; | ||
} | ||
return true; | ||
@@ -61,2 +67,8 @@ } | ||
if (node.tagName) { | ||
if (exclude == null ? void 0 : exclude.length) { | ||
const shouldExclude = exclude.some( | ||
(selector) => node.matches(selector) | ||
); | ||
return !shouldExclude; | ||
} | ||
return slotName ? node.getAttribute("slot") === slotName : !node.hasAttribute("slot"); | ||
@@ -63,0 +75,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var c=(i,e,s,n)=>{for(var r=n>1?void 0:n?f(e,s):e,l=i.length-1,t;l>=0;l--)(t=i[l])&&(r=(n?t(e,s,r):t(r))||r);return n&&r&&p(e,s,r),r};import{property as m,queryAssignedNodes as g}from"@spectrum-web-components/base/src/decorators.js";import{MutationController as h}from"@lit-labs/observers/mutation-controller.js";const d=Symbol("assignedNodes");export function ObserveSlotText(i,e){var n;class s extends i{constructor(...t){super(t);this.slotHasContent=!1;new h(this,{config:{characterData:!0,subtree:!0},callback:o=>{for(const u of o)if(u.type==="characterData"){this.manageTextObservedSlot();return}}})}manageTextObservedSlot(){if(!this[d])return;const t=[...this[d]].filter(o=>o.tagName?!0:o.textContent?o.textContent.trim():!1);this.slotHasContent=t.length>0}update(t){if(!this.hasUpdated){const{childNodes:o}=this,u=[...o].filter(a=>a.tagName?e?a.getAttribute("slot")===e:!a.hasAttribute("slot"):a.textContent?a.textContent.trim():!1);this.slotHasContent=u.length>0}super.update(t)}firstUpdated(t){super.firstUpdated(t),this.updateComplete.then(()=>{this.manageTextObservedSlot()})}}return n=d,c([m({type:Boolean,attribute:!1})],s.prototype,"slotHasContent",2),c([g(e,!0)],s.prototype,n,2),s} | ||
"use strict";var d=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var c=(i,r,t,s)=>{for(var e=s>1?void 0:s?h(r,t):r,l=i.length-1,u;l>=0;l--)(u=i[l])&&(e=(s?u(r,t,e):u(e))||e);return s&&e&&d(r,t,e),e};import{property as g,queryAssignedNodes as T}from"@spectrum-web-components/base/src/decorators.js";import{MutationController as b}from"@lit-labs/observers/mutation-controller.js";const m=Symbol("assignedNodes");export function ObserveSlotText(i,r,t){var e;class s extends i{constructor(...a){super(a);this.slotHasContent=!1;new b(this,{config:{characterData:!0,subtree:!0},callback:o=>{for(const p of o)if(p.type==="characterData"){this.manageTextObservedSlot();return}}})}manageTextObservedSlot(){if(!this[m])return;const a=[...this[m]].filter(o=>o.tagName?t!=null&&t.length?!t.some(n=>o.matches(n)):!0:o.textContent?o.textContent.trim():!1);this.slotHasContent=a.length>0}update(a){if(!this.hasUpdated){const{childNodes:o}=this,p=[...o].filter(n=>n.tagName?t!=null&&t.length?!t.some(f=>n.matches(f)):r?n.getAttribute("slot")===r:!n.hasAttribute("slot"):n.textContent?n.textContent.trim():!1);this.slotHasContent=p.length>0}super.update(a)}firstUpdated(a){super.firstUpdated(a),this.updateComplete.then(()=>{this.manageTextObservedSlot()})}}return e=m,c([g({type:Boolean,attribute:!1})],s.prototype,"slotHasContent",2),c([T(r,!0)],s.prototype,e,2),s} | ||
//# sourceMappingURL=observe-slot-text.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
196113
1213