@momentum-design/components 0.142.6 → 0.142.7
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
|
@@ -1116,7 +1116,7 @@
|
|
|
1116
1116
|
:host svg {
|
|
1117
1117
|
display: block;
|
|
1118
1118
|
}
|
|
1119
|
-
`],Av=fA;var Sv=$.constructTagName("animation"),Wh={AUTO_PLAY:!0,LOOP:"true"};var pi=class extends Q{constructor(){super(...arguments);this.loop=Wh.LOOP;this.autoplay=Wh.AUTO_PLAY;this.ariaLabel=null;this.ariaLabelledby=null;this.containerRef=Ev();this.onCompleteHandler=()=>{let t=new CustomEvent("complete",{detail:{name:this.name},bubbles:!0});this.dispatchEvent(t)}}get animation(){return this.lottieInstance}getLoopValue(){return this.loop==="true"?!0:this.loop==="false"?!1:this.loop?Number(this.loop):!0}onLoadSuccessHandler(t){this.cachedAnimationData=t,this.createLottieInstance(t),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,cancelable:!0,detail:{name:this.name}}))}createLottieInstance(t){this.lottieInstance&&(this.lottieInstance.removeEventListener("complete",this.onCompleteHandler),this.lottieInstance.destroy()),this.containerRef.value&&(this.lottieInstance=Iv.default.loadAnimation({container:this.containerRef.value,renderer:"svg",loop:this.getLoopValue(),autoplay:this.autoplay,animationData:t,name:this.name}),this.lottieInstance.addEventListener("complete",this.onCompleteHandler))}onLoadFailHandler(t){let e=new CustomEvent("error",{bubbles:!0,cancelable:!0,detail:{error:t}});this.dispatchEvent(e)}getAnimationData(){this.src?this.fetchAnimationFromUrl(this.src):this.name&&Kh[this.name]?import(`@momentum-design/animations/dist/lottie${Kh[this.name].replace(/^\.\/lottie/,"")}`).then(e=>this.onLoadSuccessHandler(e.default)).catch(e=>this.onLoadFailHandler(e)):this.onLoadFailHandler(new Error(`Invalid animation name: ${this.name}`))}fetchAnimationFromUrl(t){fetch(t).then(e=>{if(!e.ok)throw new Error(`Failed to fetch animation from URL: ${t} (${e.status})`);return e.json()}).then(e=>this.onLoadSuccessHandler(e)).catch(e=>this.onLoadFailHandler(e))}updated(t){super.updated(t),t.has("name")||t.has("src")?(this.cachedAnimationData=void 0,this.getAnimationData()):(t.has("loop")||t.has("autoplay"))&&this.cachedAnimationData&&this.createLottieInstance(this.cachedAnimationData),(t.has("ariaLabel")||t.has("ariaLabelledby"))&&(this.role=this.ariaLabel||this.ariaLabelledby?et.IMG:null)}disconnectedCallback(){super.disconnectedCallback(),this.lottieInstance&&(this.lottieInstance.removeEventListener("complete",this.onCompleteHandler),this.lottieInstance.destroy(),this.lottieInstance=void 0)}render(){return A`<div aria-hidden="true" ${Tv(this.containerRef)}></div>`}};pi.styles=[...Q.styles,...Av],h([u({type:String,reflect:!0})],pi.prototype,"name",2),h([u({type:String,reflect:!0})],pi.prototype,"src",2),h([u({type:String,reflect:!0})],pi.prototype,"loop",2),h([u({type:Boolean,reflect:!0})],pi.prototype,"autoplay",2),h([u({type:String,attribute:"aria-label"})],pi.prototype,"ariaLabel",2),h([u({type:String,attribute:"aria-labelledby"})],pi.prototype,"ariaLabelledby",2);var Yh=pi;Yh.register(Sv);var vA=Yh;var Qs=n=>{class o extends n{constructor(){super(...arguments);this.shouldFocusTrapWrap=!0;this.focusTrapIndex=-1;this.focusableElements=[];this.isFocusTrapActivated=!1}setIsFocusTrapActivated(i){this.isFocusTrapActivated=i}activateFocusTrap(){this.setIsFocusTrapActivated(!0),Vi.activate(this)}deactivateFocusTrap(){this.setIsFocusTrapActivated(!1),Vi.deactivate(this),this.focusTrapIndex=-1}setFocusableElements(){this.shadowRoot&&(this.focusableElements=ts(this.shadowRoot,{stopAtNonTabbable:!0}))}setInitialFocus(i=0){this.setFocusableElements(),!(this.focusableElements.length===0||!this.focusTrap)&&this.focusableElements[i]&&(this.focusTrapIndex=i,this.focusableElements[i].focus({preventScroll:!0}))}calculateNextIndex(i,a){let{length:d}=this.focusableElements;if(i===-1)return a>0?0:d-1;let f=i+a;return this.shouldFocusTrapWrap?(f<0&&(f=d-1),f>=d&&(f=0)):(f<0&&(f=0),f>=d&&(f=d-1)),f}getDeepActiveElement(){var a;let i=document.activeElement||document.body;for(;i instanceof HTMLElement&&((a=i.shadowRoot)!=null&&a.activeElement);)i=i.shadowRoot.activeElement;return i||document.body}findElement(i){return this.focusableElements.findIndex(a=>this.isEqualFocusNode(i,a))}isEqualFocusNode(i,a){return i.nodeType>=0?a.isEqualNode(i)&&a===i:!1}trapFocus(i){if(this.setFocusableElements(),this.focusableElements.length===0)return;let a=this.getDeepActiveElement(),d=this.findElement(a);if(d===-1)return;i.shiftKey?this.focusTrapIndex=this.calculateNextIndex(d,-1):this.focusTrapIndex=this.calculateNextIndex(d,1);let v=this.focusableElements[this.focusTrapIndex];v.tagName!=="IFRAME"&&v
|
|
1119
|
+
`],Av=fA;var Sv=$.constructTagName("animation"),Wh={AUTO_PLAY:!0,LOOP:"true"};var pi=class extends Q{constructor(){super(...arguments);this.loop=Wh.LOOP;this.autoplay=Wh.AUTO_PLAY;this.ariaLabel=null;this.ariaLabelledby=null;this.containerRef=Ev();this.onCompleteHandler=()=>{let t=new CustomEvent("complete",{detail:{name:this.name},bubbles:!0});this.dispatchEvent(t)}}get animation(){return this.lottieInstance}getLoopValue(){return this.loop==="true"?!0:this.loop==="false"?!1:this.loop?Number(this.loop):!0}onLoadSuccessHandler(t){this.cachedAnimationData=t,this.createLottieInstance(t),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,cancelable:!0,detail:{name:this.name}}))}createLottieInstance(t){this.lottieInstance&&(this.lottieInstance.removeEventListener("complete",this.onCompleteHandler),this.lottieInstance.destroy()),this.containerRef.value&&(this.lottieInstance=Iv.default.loadAnimation({container:this.containerRef.value,renderer:"svg",loop:this.getLoopValue(),autoplay:this.autoplay,animationData:t,name:this.name}),this.lottieInstance.addEventListener("complete",this.onCompleteHandler))}onLoadFailHandler(t){let e=new CustomEvent("error",{bubbles:!0,cancelable:!0,detail:{error:t}});this.dispatchEvent(e)}getAnimationData(){this.src?this.fetchAnimationFromUrl(this.src):this.name&&Kh[this.name]?import(`@momentum-design/animations/dist/lottie${Kh[this.name].replace(/^\.\/lottie/,"")}`).then(e=>this.onLoadSuccessHandler(e.default)).catch(e=>this.onLoadFailHandler(e)):this.onLoadFailHandler(new Error(`Invalid animation name: ${this.name}`))}fetchAnimationFromUrl(t){fetch(t).then(e=>{if(!e.ok)throw new Error(`Failed to fetch animation from URL: ${t} (${e.status})`);return e.json()}).then(e=>this.onLoadSuccessHandler(e)).catch(e=>this.onLoadFailHandler(e))}updated(t){super.updated(t),t.has("name")||t.has("src")?(this.cachedAnimationData=void 0,this.getAnimationData()):(t.has("loop")||t.has("autoplay"))&&this.cachedAnimationData&&this.createLottieInstance(this.cachedAnimationData),(t.has("ariaLabel")||t.has("ariaLabelledby"))&&(this.role=this.ariaLabel||this.ariaLabelledby?et.IMG:null)}disconnectedCallback(){super.disconnectedCallback(),this.lottieInstance&&(this.lottieInstance.removeEventListener("complete",this.onCompleteHandler),this.lottieInstance.destroy(),this.lottieInstance=void 0)}render(){return A`<div aria-hidden="true" ${Tv(this.containerRef)}></div>`}};pi.styles=[...Q.styles,...Av],h([u({type:String,reflect:!0})],pi.prototype,"name",2),h([u({type:String,reflect:!0})],pi.prototype,"src",2),h([u({type:String,reflect:!0})],pi.prototype,"loop",2),h([u({type:Boolean,reflect:!0})],pi.prototype,"autoplay",2),h([u({type:String,attribute:"aria-label"})],pi.prototype,"ariaLabel",2),h([u({type:String,attribute:"aria-labelledby"})],pi.prototype,"ariaLabelledby",2);var Yh=pi;Yh.register(Sv);var vA=Yh;var Qs=n=>{class o extends n{constructor(){super(...arguments);this.shouldFocusTrapWrap=!0;this.focusTrapIndex=-1;this.focusableElements=[];this.isFocusTrapActivated=!1}setIsFocusTrapActivated(i){this.isFocusTrapActivated=i}activateFocusTrap(){this.setIsFocusTrapActivated(!0),Vi.activate(this)}deactivateFocusTrap(){this.setIsFocusTrapActivated(!1),Vi.deactivate(this),this.focusTrapIndex=-1}setFocusableElements(){this.shadowRoot&&(this.focusableElements=ts(this.shadowRoot,{stopAtNonTabbable:!0}))}setInitialFocus(i=0){this.setFocusableElements(),!(this.focusableElements.length===0||!this.focusTrap)&&this.focusableElements[i]&&(this.focusTrapIndex=i,this.focusableElements[i].focus({preventScroll:!0}))}calculateNextIndex(i,a){let{length:d}=this.focusableElements;if(i===-1)return a>0?0:d-1;let f=i+a;return this.shouldFocusTrapWrap?(f<0&&(f=d-1),f>=d&&(f=0)):(f<0&&(f=0),f>=d&&(f=d-1)),f}getDeepActiveElement(){var a;let i=document.activeElement||document.body;for(;i instanceof HTMLElement&&((a=i.shadowRoot)!=null&&a.activeElement);)i=i.shadowRoot.activeElement;return i||document.body}findElement(i){return this.focusableElements.findIndex(a=>this.isEqualFocusNode(i,a))}isEqualFocusNode(i,a){return i.nodeType>=0?a.isEqualNode(i)&&a===i:!1}trapFocus(i){if(this.setFocusableElements(),this.focusableElements.length===0)return;let a=this.getDeepActiveElement(),d=this.findElement(a);if(d===-1)return;i.shiftKey?this.focusTrapIndex=this.calculateNextIndex(d,-1):this.focusTrapIndex=this.calculateNextIndex(d,1);let v=this.focusableElements[this.focusTrapIndex];if(v.tagName!=="IFRAME"&&v){i.preventDefault();let S={focusVisible:!0};v.focus(S)}}handleTabKeydown(i){this.isFocusTrapActivated&&i.key==="Tab"&&this.trapFocus(i)}}return h([u({type:Boolean,reflect:!0,attribute:"should-focus-trap-wrap"})],o.prototype,"shouldFocusTrapWrap",2),o};var dd=n=>{class o extends n{constructor(){super(...arguments);this.isPreventScrollActive=!1;this.previousDocumentBodyStyleOverflow=""}activatePreventScroll(){this.preventScroll&&!this.isPreventScrollActive&&(this.isPreventScrollActive=!0,this.previousDocumentBodyStyleOverflow=document.body.style.overflow,document.body.style.overflow="hidden")}deactivatePreventScroll(){this.isPreventScrollActive&&(this.isPreventScrollActive=!1,document.body.style.overflow=this.previousDocumentBodyStyleOverflow)}}return o};var cd=$.constructTagName("link"),hd={LARGE:"large",MIDSIZE:"midsize",SMALL:"small"},pd={LARGE:1,MIDSIZE:.875,SMALL:.75},Cv={LINK_SIZE:hd.LARGE};var _v=$.constructTagName("card"),jh={BORDER:"border",GHOST:"ghost",PROMOTIONAL:"promotional"},gA={HORIZONTAL:"horizontal",VERTICAL:"vertical"},Ce={VARIANT:jh.BORDER,ORIENTATION:gA.VERTICAL,TITLE_TYPE:at.HEADING_SMALL_BOLD,SUBTITLE_TYPE:at.BODY_MIDSIZE_MEDIUM,TAGNAME:pt.SPAN,ICON_SIZE:1.5,ICON_LENGTH_UNIT:"rem",LINK:cd,BUTTON:Fi};var Js=n=>{class o extends n{updateFooterButtonColors(e){let i=[...this.footerButtonPrimary||[],...this.footerButtonSecondary||[]];i==null||i.forEach(a=>{e===jh.PROMOTIONAL?a.setAttribute("color",Ye.PROMOTIONAL):a.setAttribute("color",Ye.DEFAULT)})}handleFooterSlot(e,i){var d,f,v;let a=[];e===Ce.LINK&&((d=this.footerLink)!=null&&d.length)?a=this.footerLink:e===Ce.BUTTON&&i===Ft.PRIMARY&&((f=this.footerButtonPrimary)!=null&&f.length)?a=this.footerButtonPrimary:e===Ce.BUTTON&&i===Ft.SECONDARY&&((v=this.footerButtonSecondary)!=null&&v.length)&&(a=this.footerButtonSecondary);for(let S=1;S<a.length;S+=1)a[S].remove();a.forEach(S=>{S.matches(e)||S.remove(),i&&S.setAttribute("variant",i)})}renderFooter(){return A` <slot name="footer">
|
|
1120
1120
|
<div part="footer">
|
|
1121
1121
|
<slot name="footer-link" @slotchange=${()=>this.handleFooterSlot(Ce.LINK)}></slot>
|
|
1122
1122
|
<slot
|