@momentum-design/components 0.10.2 → 0.10.3
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/dist/browser/index.js
CHANGED
@@ -69,12 +69,12 @@
|
|
69
69
|
:host {
|
70
70
|
--mdc-icon-fill-color: currentColor;
|
71
71
|
}
|
72
|
-
|
72
|
+
:host::part(icon) {
|
73
73
|
height: 100%;
|
74
74
|
width: 100%;
|
75
75
|
fill: var(--mdc-icon-fill-color);
|
76
76
|
}
|
77
|
-
`],Ht=Lo;var $o=s=>{let{host:e,context:t,subscribe:o}=s;return new Z(e,{context:t,subscribe:o!=null?o:!0})},wo={consume:$o},Gt=wo;var Re=v.constructTagName("iconprovider"),Bt=["svg"],Vt=["em","rem","px"],Oo={px:16,em:1,rem:1},P={FILE_EXTENSION:"svg",LENGTH_UNIT:"em",SIZE:Oo.em};var ze=class{};ze.context=Re;var Le=ze;var Y=class extends K{constructor(){super({context:Le.context,initialValue:new Le});this.fileExtension=P.FILE_EXTENSION;this.lengthUnit=P.LENGTH_UNIT;this.size=P.SIZE}static get Context(){return Le.context}updateValuesInContext(){this.fileExtension&&Bt.includes(this.fileExtension)?this.context.value.fileExtension=this.fileExtension:(this.fileExtension=P.FILE_EXTENSION,this.context.value.fileExtension=P.FILE_EXTENSION),this.context.value.url=this.url,this.context.value.size=this.size,this.lengthUnit&&Vt.includes(this.lengthUnit)?this.context.value.lengthUnit=this.lengthUnit:(this.lengthUnit=P.LENGTH_UNIT,this.context.value.lengthUnit=P.LENGTH_UNIT)}updateContext(){(this.context.value.fileExtension!==this.fileExtension||this.context.value.url!==this.url||this.context.value.lengthUnit!==this.lengthUnit||this.context.value.size!==this.size)&&(this.updateValuesInContext(),this.context.updateObservers())}};a([l({type:String})],Y.prototype,"url",2),a([l({type:String,attribute:"file-extension",reflect:!0})],Y.prototype,"fileExtension",2),a([l({type:String,attribute:"length-unit",reflect:!0})],Y.prototype,"lengthUnit",2),a([l({type:Number,reflect:!0})],Y.prototype,"size",2);var le=Y;var Yt=async(s,e,t)=>{let o=await fetch(`${s}/${e}.${t}`);if(!o.ok)throw new Error("There was a problem while fetching the icon!");let r=await o.text(),n=new DOMParser().parseFromString(r,"text/html").body.children[0];return n.setAttribute("data-name",e),n};var qt=v.constructTagName("icon"),et={NAME:void 0,SIZE:1};var A=class extends p{constructor(){super(...arguments);this.name=et.NAME;this.ariaLabel=null;this.iconProviderContext=Gt.consume({host:this,context:le.Context})}async getIconData(){if(this.iconProviderContext.value){let{fileExtension:t,url:o}=this.iconProviderContext.value;if(o&&t&&this.name){let r=await Yt(o,this.name,t);this.iconData=r,this.setRoleOnIcon(),this.setAriaLabelOnIcon(),this.setAriaHiddenOnIcon()}}}updateSize(){var t;if(this.computedIconSize&&(this.lengthUnit||this.lengthUnitFromContext)){let o=`${this.computedIconSize}${(t=this.lengthUnit)!=null?t:this.lengthUnitFromContext}`;this.style.width=o,this.style.height=o}}setRoleOnIcon(){this.role=this.ariaLabel?"img":null}setAriaHiddenOnIcon(){var t;(t=this.iconData)==null||t.setAttribute("aria-hidden","true")}setAriaLabelOnIcon(){var t,o;this.ariaLabel?(t=this.iconData)==null||t.setAttribute("aria-label",this.ariaLabel):(o=this.iconData)==null||o.removeAttribute("aria-label")}get computedIconSize(){var t,o;return(o=(t=this.size)!=null?t:this.sizeFromContext)!=null?o:et.SIZE}updated(t){var o,r,n,i;super.updated(t),t.has("name")&&this.getIconData().catch(d=>{console.error(d)}),t.has("ariaLabel")&&(this.setRoleOnIcon(),this.setAriaLabelOnIcon()),(t.has("size")||t.has("lengthUnit"))&&this.updateSize(),this.lengthUnitFromContext!==((o=this.iconProviderContext.value)==null?void 0:o.lengthUnit)&&(this.lengthUnitFromContext=(r=this.iconProviderContext.value)==null?void 0:r.lengthUnit,this.updateSize()),this.sizeFromContext!==((n=this.iconProviderContext.value)==null?void 0:n.size)&&(this.sizeFromContext=(i=this.iconProviderContext.value)==null?void 0:i.size,this.updateSize())}render(){return m` ${this.iconData} `}};A.styles=[...p.styles,...Ht],a([I()],A.prototype,"iconData",2),a([I()],A.prototype,"lengthUnitFromContext",2),a([I()],A.prototype,"sizeFromContext",2),a([l({type:String,reflect:!0})],A.prototype,"name",2),a([l({type:Number})],A.prototype,"size",2),a([l({type:String,attribute:"length-unit"})],A.prototype,"lengthUnit",2),a([l({type:String,attribute:"aria-label"})],A.prototype,"ariaLabel",2);var tt=A;tt.register(qt);var Mo=tt;le.register(Re);var ko=le;var me=s=>s!=null?s:b;var Uo=h`
|
77
|
+
`],Ht=Lo;var $o=s=>{let{host:e,context:t,subscribe:o}=s;return new Z(e,{context:t,subscribe:o!=null?o:!0})},wo={consume:$o},Gt=wo;var Re=v.constructTagName("iconprovider"),Bt=["svg"],Vt=["em","rem","px"],Oo={px:16,em:1,rem:1},P={FILE_EXTENSION:"svg",LENGTH_UNIT:"em",SIZE:Oo.em};var ze=class{};ze.context=Re;var Le=ze;var Y=class extends K{constructor(){super({context:Le.context,initialValue:new Le});this.fileExtension=P.FILE_EXTENSION;this.lengthUnit=P.LENGTH_UNIT;this.size=P.SIZE}static get Context(){return Le.context}updateValuesInContext(){this.fileExtension&&Bt.includes(this.fileExtension)?this.context.value.fileExtension=this.fileExtension:(this.fileExtension=P.FILE_EXTENSION,this.context.value.fileExtension=P.FILE_EXTENSION),this.context.value.url=this.url,this.context.value.size=this.size,this.lengthUnit&&Vt.includes(this.lengthUnit)?this.context.value.lengthUnit=this.lengthUnit:(this.lengthUnit=P.LENGTH_UNIT,this.context.value.lengthUnit=P.LENGTH_UNIT)}updateContext(){(this.context.value.fileExtension!==this.fileExtension||this.context.value.url!==this.url||this.context.value.lengthUnit!==this.lengthUnit||this.context.value.size!==this.size)&&(this.updateValuesInContext(),this.context.updateObservers())}};a([l({type:String})],Y.prototype,"url",2),a([l({type:String,attribute:"file-extension",reflect:!0})],Y.prototype,"fileExtension",2),a([l({type:String,attribute:"length-unit",reflect:!0})],Y.prototype,"lengthUnit",2),a([l({type:Number,reflect:!0})],Y.prototype,"size",2);var le=Y;var Yt=async(s,e,t)=>{let o=await fetch(`${s}/${e}.${t}`);if(!o.ok)throw new Error("There was a problem while fetching the icon!");let r=await o.text(),n=new DOMParser().parseFromString(r,"text/html").body.children[0];return n.setAttribute("data-name",e),n.setAttribute("part","icon"),n};var qt=v.constructTagName("icon"),et={NAME:void 0,SIZE:1};var A=class extends p{constructor(){super(...arguments);this.name=et.NAME;this.ariaLabel=null;this.iconProviderContext=Gt.consume({host:this,context:le.Context})}async getIconData(){if(this.iconProviderContext.value){let{fileExtension:t,url:o}=this.iconProviderContext.value;if(o&&t&&this.name){let r=await Yt(o,this.name,t);this.iconData=r,this.setRoleOnIcon(),this.setAriaLabelOnIcon(),this.setAriaHiddenOnIcon()}}}updateSize(){var t;if(this.computedIconSize&&(this.lengthUnit||this.lengthUnitFromContext)){let o=`${this.computedIconSize}${(t=this.lengthUnit)!=null?t:this.lengthUnitFromContext}`;this.style.width=o,this.style.height=o}}setRoleOnIcon(){this.role=this.ariaLabel?"img":null}setAriaHiddenOnIcon(){var t;(t=this.iconData)==null||t.setAttribute("aria-hidden","true")}setAriaLabelOnIcon(){var t,o;this.ariaLabel?(t=this.iconData)==null||t.setAttribute("aria-label",this.ariaLabel):(o=this.iconData)==null||o.removeAttribute("aria-label")}get computedIconSize(){var t,o;return(o=(t=this.size)!=null?t:this.sizeFromContext)!=null?o:et.SIZE}updated(t){var o,r,n,i;super.updated(t),t.has("name")&&this.getIconData().catch(d=>{console.error(d)}),t.has("ariaLabel")&&(this.setRoleOnIcon(),this.setAriaLabelOnIcon()),(t.has("size")||t.has("lengthUnit"))&&this.updateSize(),this.lengthUnitFromContext!==((o=this.iconProviderContext.value)==null?void 0:o.lengthUnit)&&(this.lengthUnitFromContext=(r=this.iconProviderContext.value)==null?void 0:r.lengthUnit,this.updateSize()),this.sizeFromContext!==((n=this.iconProviderContext.value)==null?void 0:n.size)&&(this.sizeFromContext=(i=this.iconProviderContext.value)==null?void 0:i.size,this.updateSize())}render(){return m` ${this.iconData} `}};A.styles=[...p.styles,...Ht],a([I()],A.prototype,"iconData",2),a([I()],A.prototype,"lengthUnitFromContext",2),a([I()],A.prototype,"sizeFromContext",2),a([l({type:String,reflect:!0})],A.prototype,"name",2),a([l({type:Number})],A.prototype,"size",2),a([l({type:String,attribute:"length-unit"})],A.prototype,"lengthUnit",2),a([l({type:String,attribute:"aria-label"})],A.prototype,"ariaLabel",2);var tt=A;tt.register(qt);var Mo=tt;le.register(Re);var ko=le;var me=s=>s!=null?s:b;var Uo=h`
|
78
78
|
:host {
|
79
79
|
display: flex;
|
80
80
|
justify-content: center;
|