@momentum-design/components 0.133.23 → 0.133.24

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.
@@ -4374,7 +4374,7 @@
4374
4374
  `,gb=[M0,...Et()];var us=class extends ce(fe){constructor(){super(...arguments);this.size=da.SIZE;this.inline=da.INLINE;this.inverted=da.INVERTED}connectedCallback(){super.connectedCallback(),this.active=void 0,this.role=da.ROLE}update(t){super.update(t),t.has("size")&&this.setSize(this.size)}setSize(t){this.setAttribute("size",Object.values(la).includes(t)?`${t}`:da.SIZE.toString())}render(){return S`
4375
4375
  <slot></slot>
4376
4376
  ${this.iconName?S` <mdc-icon name=${this.iconName} size=${vb(this.size)} length-unit="rem"></mdc-icon> `:W}
4377
- `}};us.styles=[...ni.styles,...gb],h([u({type:Number,reflect:!0})],us.prototype,"size",2),h([u({type:Boolean,reflect:!0})],us.prototype,"inline",2),h([u({type:Boolean,reflect:!0})],us.prototype,"inverted",2);var Tp=us;Tp.register(fb);var L0=Tp;ni.register(wv);var O0=ni;var Jt={CREATED:"created",FIRST_UPDATE_COMPLETED:"first-update-completed",DESTROYED:"destroyed",MODIFIED:"modified"};var yo=a=>{class o extends Lt(Nt(a)){constructor(...i){super(...i);this.loop="true";this.propagateAllKeyEvents=!1;this.initialFocus=0;this.orientation="vertical";this.handleItemCreation=i=>{var f;let{target:l}=i,c=i instanceof CustomEvent&&((f=i.detail)==null?void 0:f.lifecycle);this.navItems.length===0&&l instanceof Z&&c&&l.setAttribute("tabindex","0")};this.handleNavigationClick=i=>{let l=i.target,c=this.getCurrentIndex(l);if(c!==-1){let f=document.activeElement===l,b=document.activeElement&&document.activeElement.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_CONTAINED_BY,A=!(this.navItems.at(c)!==l&&(f||b));this.resetTabIndexAndSetFocus(c,void 0,A,!1)}};this.handleNavBeforeFocus=i=>{let l=eh(i.relatedTarget);if(this!==l&&!this.contains(document.activeElement)&&this.contains(l)){i.preventDefault();let c=this.navItems.find(b=>b.contains(l)),f=this.getCurrentIndex(c);if(f===-1)return;this.resetTabIndexes(f)}};this.addEventListener(Jt.CREATED,this.handleItemCreation),this.addEventListener("keydown",this.handleNavigationKeyDown.bind(this)),this.addEventListener("click",this.handleNavigationClick)}connectedCallback(){super.connectedCallback(),document.addEventListener("navbeforefocus",this.handleNavBeforeFocus)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("navbeforefocus",this.handleNavBeforeFocus)}async firstUpdated(i){super.firstUpdated(i),this.setInitialFocus()}setInitialFocus(){let i=Math.max(Math.min(this.initialFocus,this.navItems.length-1),0);this.resetTabIndexAndSetFocus(i,void 0,!1)}handleNavigationKeyDown(i){let l=this.getActionForKeyEvent(i,!0),c=this.orientation==="vertical",f=new Set(c?[Y.DOWN,Y.UP,Y.HOME,Y.END]:[Y.LEFT,Y.RIGHT,Y.HOME,Y.END]);if(!l||!f.has(l))return;let b=i.target,A=this.getCurrentIndex(b);if(A===-1)return;this.resetTabIndexes(A);let F=!1;switch(l){case Y.HOME:{F=this.resetTabIndexAndSetFocus(0,A);break}case Y.END:{F=this.resetTabIndexAndSetFocus(this.navItems.length-1,A);break}case Y.DOWN:case Y.RIGHT:{let U=this.shouldLoop()?0:A,Q=A+1===this.navItems.length?U:A+1;F=this.resetTabIndexAndSetFocus(Q,A);break}case Y.UP:case Y.LEFT:{let U=this.shouldLoop()?this.navItems.length-1:A,Q=A-1===-1?U:A-1;F=this.resetTabIndexAndSetFocus(Q,A);break}default:break}F&&(this.keyDownEventHandled(),this.propagateAllKeyEvents||(i.stopPropagation(),i.preventDefault()))}getCurrentIndex(i){return i?this.navItems.findIndex(l=>l===i||!!(l.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY)):-1}resetTabIndexes(i,l=!0){var c;if(this.navItems.length>0){this.navItems.forEach(A=>A.setAttribute("tabindex","-1"));let f=this.navItems.at(i)?i:0,b=(c=this.navItems.at(f))!=null?c:this.navItems.find(Boolean);b&&(b.setAttribute("tabindex","0"),l&&b.focus())}}resetTabIndexAndSetFocus(i,l,c=!0,f=!0){var F;let{navItems:b}=this;if(b.length===0)return!1;let A=(F=b.at(i))!=null?F:b.find(Boolean);return i===0&&l===0&&b.length===1?!0:i===l&&A&&A.getAttribute("tabindex")==="0"?!1:(l===void 0?b.forEach(U=>U.setAttribute("tabindex","-1")):b.at(l)&&b.at(l).setAttribute("tabindex","-1"),A.setAttribute("tabindex","0"),c&&(A.focus({preventScroll:!0}),f&&A.scrollIntoView({block:"nearest"})),!0)}shouldLoop(){return this.getKeyboardNavMode()===ee.SPATIAL?!1:this.loop!=="false"}}return o};var Wd=z.constructTagName("listitem"),kn={FULL_WIDTH:"full-width",INSET_PILL:"inset-pill",INSET_RECTANGLE:"inset-rectangle"},bb={VARIANT:kn.FULL_WIDTH};var R0=a=>!!a,Mr=class{constructor(o,t){this.cache=[];this.itemCreationHandler=o=>{o.stopPropagation(),this.addItem(o.target,void 0)};this.itemDestroyHandler=o=>{o.stopPropagation(),this.delete(o.detail.originalTarget)};this.host=o,o.addController(this),this.isValidItem=(t==null?void 0:t.isValidItem)||R0,this.onStoreUpdate=t==null?void 0:t.onStoreUpdate}get items(){return this.cache}hostConnected(){this.host.addEventListener(Jt.CREATED,this.itemCreationHandler),this.host.addEventListener(Jt.DESTROYED,this.itemDestroyHandler)}hostDisconnected(){this.host.removeEventListener(Jt.CREATED,this.itemCreationHandler),this.host.removeEventListener(Jt.DESTROYED,this.itemDestroyHandler),this.reset()}add(o){this.addItem(o,void 0)}addAt(o,t){this.addItem(o,t)}getIndexToInsertInCache(o){if(!this.cache.length||!df(this.cache.at(-1),o))return-1;let t=0,e=this.cache.length-1;for(;t<=e;){let i=Math.floor((t+e)/2);cf(this.cache[i],o)?t=i+1:e=i-1}return t}addItem(o,t=void 0){var i;let e=o;if(this.isValidItem(e)&&!this.cache.includes(e)){let l=t===void 0?this.getIndexToInsertInCache(e):t;this.onStoreUpdate&&((i=this.onStoreUpdate)==null||i.call(this,e,"added",l===-1?this.cache.length:l,this.cache.slice())),l===-1?this.cache.push(e):l>=0&&this.cache.splice(l,0,e)}}delete(o){var e;let t=this.cache.indexOf(o);t!==-1&&(this.onStoreUpdate&&((e=this.onStoreUpdate)==null||e.call(this,o,"removed",t,this.cache.slice())),this.cache.splice(t,1))}reset(o){this.cache.length=0,o&&this.cache.push(...o)}};var ci=a=>{class o extends a{constructor(...i){super(...i);this.handleItemCreation=i=>{let l=i.target;l&&l.addEventListener(Jt.DESTROYED,this.handleItemRemovedEvent)};this.handleItemRemovedEvent=i=>{i.stopImmediatePropagation(),i.target&&i.type===Jt.DESTROYED&&(i.target.removeEventListener(Jt.DESTROYED,this.handleItemRemovedEvent),this.dispatchEvent(new CustomEvent(i.type,{bubbles:i.bubbles,composed:i.composed,detail:{originalTarget:i.target}})))};this.addEventListener(Jt.CREATED,this.handleItemCreation)}}return o};var D0=B`
4377
+ `}};us.styles=[...ni.styles,...gb],h([u({type:Number,reflect:!0})],us.prototype,"size",2),h([u({type:Boolean,reflect:!0})],us.prototype,"inline",2),h([u({type:Boolean,reflect:!0})],us.prototype,"inverted",2);var Tp=us;Tp.register(fb);var L0=Tp;ni.register(wv);var O0=ni;var Jt={CREATED:"created",FIRST_UPDATE_COMPLETED:"first-update-completed",DESTROYED:"destroyed",MODIFIED:"modified"};var yo=a=>{class o extends Lt(Nt(a)){constructor(...i){super(...i);this.loop="true";this.propagateAllKeyEvents=!1;this.initialFocus=0;this.orientation="vertical";this.handleItemCreation=i=>{var f;let{target:l}=i,c=i instanceof CustomEvent&&((f=i.detail)==null?void 0:f.lifecycle);this.navItems.length===0&&l instanceof Z&&c&&l.setAttribute("tabindex","0")};this.handleNavigationClick=i=>{let l=i.target,c=this.getCurrentIndex(l);if(c!==-1){let f=document.activeElement===l,b=document.activeElement&&document.activeElement.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_CONTAINED_BY,A=!(this.navItems.at(c)!==l&&(f||b));this.resetTabIndexAndSetFocus(c,void 0,A,!1)}};this.handleNavBeforeFocus=i=>{let l=eh(i.relatedTarget);if(this!==l&&!this.contains(document.activeElement)&&this.contains(l)){i.preventDefault();let c=this.navItems.find(b=>b.contains(l)),f=this.getCurrentIndex(c);if(f===-1)return;this.resetTabIndexes(f)}};this.addEventListener(Jt.CREATED,this.handleItemCreation),this.addEventListener("keydown",this.handleNavigationKeyDown.bind(this)),this.addEventListener("click",this.handleNavigationClick)}connectedCallback(){super.connectedCallback(),document.addEventListener("navbeforefocus",this.handleNavBeforeFocus)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("navbeforefocus",this.handleNavBeforeFocus)}async firstUpdated(i){super.firstUpdated(i),this.setInitialFocus()}setInitialFocus(){let i=Math.max(Math.min(this.initialFocus,this.navItems.length-1),0);this.resetTabIndexAndSetFocus(i,void 0,!1)}handleNavigationKeyDown(i){let l=this.getActionForKeyEvent(i,!0),c=this.orientation==="vertical",f=new Set(c?[Y.DOWN,Y.UP,Y.HOME,Y.END]:[Y.LEFT,Y.RIGHT,Y.HOME,Y.END]);if(!l||!f.has(l))return;let b=i.target,A=this.getCurrentIndex(b);if(A===-1)return;this.resetTabIndexes(A);let F=!1;switch(l){case Y.HOME:{F=this.resetTabIndexAndSetFocus(0,A);break}case Y.END:{F=this.resetTabIndexAndSetFocus(this.navItems.length-1,A);break}case Y.DOWN:case Y.RIGHT:{let U=this.shouldLoop()?0:A,Q=A+1===this.navItems.length?U:A+1;F=this.resetTabIndexAndSetFocus(Q,A);break}case Y.UP:case Y.LEFT:{let U=this.shouldLoop()?this.navItems.length-1:A,Q=A-1===-1?U:A-1;F=this.resetTabIndexAndSetFocus(Q,A);break}default:break}F&&(this.keyDownEventHandled(),this.propagateAllKeyEvents||(i.stopPropagation(),i.preventDefault()))}getCurrentIndex(i){return i?this.navItems.findIndex(l=>l===i||!!(l.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY)):-1}resetTabIndexes(i,l=!0){var c;if(this.navItems.length>0){this.navItems.forEach(A=>A.setAttribute("tabindex","-1"));let f=this.navItems.at(i)?i:0,b=(c=this.navItems.at(f))!=null?c:this.navItems.find(Boolean);b&&(b.setAttribute("tabindex","0"),l&&b.focus())}}resetTabIndexAndSetFocus(i,l,c=!0,f=!0){var F;let{navItems:b}=this;if(b.length===0)return!1;let A=(F=b.at(i))!=null?F:b.find(Boolean);return i===0&&l===0&&b.length===1||i===l&&A&&A.getAttribute("tabindex")==="0"?!1:(l===void 0?b.forEach(U=>U.setAttribute("tabindex","-1")):b.at(l)&&b.at(l).setAttribute("tabindex","-1"),A.setAttribute("tabindex","0"),c&&(A.focus({preventScroll:!0}),f&&A.scrollIntoView({block:"nearest"})),!0)}shouldLoop(){return this.getKeyboardNavMode()===ee.SPATIAL?!1:this.loop!=="false"}}return o};var Wd=z.constructTagName("listitem"),kn={FULL_WIDTH:"full-width",INSET_PILL:"inset-pill",INSET_RECTANGLE:"inset-rectangle"},bb={VARIANT:kn.FULL_WIDTH};var R0=a=>!!a,Mr=class{constructor(o,t){this.cache=[];this.itemCreationHandler=o=>{o.stopPropagation(),this.addItem(o.target,void 0)};this.itemDestroyHandler=o=>{o.stopPropagation(),this.delete(o.detail.originalTarget)};this.host=o,o.addController(this),this.isValidItem=(t==null?void 0:t.isValidItem)||R0,this.onStoreUpdate=t==null?void 0:t.onStoreUpdate}get items(){return this.cache}hostConnected(){this.host.addEventListener(Jt.CREATED,this.itemCreationHandler),this.host.addEventListener(Jt.DESTROYED,this.itemDestroyHandler)}hostDisconnected(){this.host.removeEventListener(Jt.CREATED,this.itemCreationHandler),this.host.removeEventListener(Jt.DESTROYED,this.itemDestroyHandler),this.reset()}add(o){this.addItem(o,void 0)}addAt(o,t){this.addItem(o,t)}getIndexToInsertInCache(o){if(!this.cache.length||!df(this.cache.at(-1),o))return-1;let t=0,e=this.cache.length-1;for(;t<=e;){let i=Math.floor((t+e)/2);cf(this.cache[i],o)?t=i+1:e=i-1}return t}addItem(o,t=void 0){var i;let e=o;if(this.isValidItem(e)&&!this.cache.includes(e)){let l=t===void 0?this.getIndexToInsertInCache(e):t;this.onStoreUpdate&&((i=this.onStoreUpdate)==null||i.call(this,e,"added",l===-1?this.cache.length:l,this.cache.slice())),l===-1?this.cache.push(e):l>=0&&this.cache.splice(l,0,e)}}delete(o){var e;let t=this.cache.indexOf(o);t!==-1&&(this.onStoreUpdate&&((e=this.onStoreUpdate)==null||e.call(this,o,"removed",t,this.cache.slice())),this.cache.splice(t,1))}reset(o){this.cache.length=0,o&&this.cache.push(...o)}};var ci=a=>{class o extends a{constructor(...i){super(...i);this.handleItemCreation=i=>{let l=i.target;l&&l.addEventListener(Jt.DESTROYED,this.handleItemRemovedEvent)};this.handleItemRemovedEvent=i=>{i.stopImmediatePropagation(),i.target&&i.type===Jt.DESTROYED&&(i.target.removeEventListener(Jt.DESTROYED,this.handleItemRemovedEvent),this.dispatchEvent(new CustomEvent(i.type,{bubbles:i.bubbles,composed:i.composed,detail:{originalTarget:i.target}})))};this.addEventListener(Jt.CREATED,this.handleItemCreation)}}return o};var D0=B`
4378
4378
  :host {
4379
4379
  display: flex;
4380
4380
  flex-direction: column;