@momentum-design/components 0.17.2 → 0.17.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -931,7 +931,7 @@
931
931
  :host([size="20"]){
932
932
  height: var(--mdc-button-height-size-20);
933
933
  }
934
- `,...at()],kr=Oo;var oe=i=>{class e extends i{constructor(){super(...arguments);this.disabled=!1}}return a([d({reflect:!0,type:Boolean})],e.prototype,"disabled",2),e};var $r=i=>{class e extends i{constructor(){super(...arguments);this.tabIndex=0}}return a([d({reflect:!0,type:Number})],e.prototype,"tabIndex",2),e};var O=class extends $r(oe(h)){constructor(){super();this.active=!1;this.softDisabled=!1;this.size=ee.SIZE;this.role=ee.ROLE;this.type=ee.TYPE;this.prevTabindex=0;this.addEventListener("click",this.executeAction.bind(this)),this.addEventListener("keydown",this.handleKeyDown.bind(this)),this.addEventListener("keyup",this.handleKeyUp.bind(this)),this.internals=this.attachInternals()}get form(){return this.internals.form}update(t){super.update(t),t.has("disabled")&&this.setDisabled(this,this.disabled),t.has("softDisabled")&&this.setSoftDisabled(this,this.softDisabled),t.has("active")&&this.setAriaPressed(this,this.active)}executeAction(){this.type===mt.SUBMIT&&this.internals.form&&this.internals.form.requestSubmit(),this.type===mt.RESET&&this.internals.form&&this.internals.form.reset()}setAriaPressed(t,r){r?t.setAttribute("aria-pressed","true"):t.setAttribute("aria-pressed","false")}setSoftDisabled(t,r){r?t.setAttribute("aria-disabled","true"):t.setAttribute("aria-disabled","false")}setDisabled(t,r){r?(t.setAttribute("aria-disabled","true"),this.prevTabindex=this.tabIndex,this.tabIndex=-1):(this.tabIndex=this.prevTabindex,t.removeAttribute("aria-disabled"))}triggerClickEvent(){let t=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});this.dispatchEvent(t),this.executeAction()}handleKeyDown(t){["Enter"," "].includes(t.key)&&(this.classList.add("pressed"),t.key==="Enter"&&this.triggerClickEvent())}handleKeyUp(t){["Enter"," "].includes(t.key)&&(this.classList.remove("pressed"),t.key===" "&&this.triggerClickEvent())}render(){return p`
934
+ `,...at()],kr=Oo;var oe=i=>{class e extends i{constructor(){super(...arguments);this.disabled=!1}}return a([d({reflect:!0,type:Boolean})],e.prototype,"disabled",2),e};var $r=i=>{class e extends i{constructor(){super(...arguments);this.tabIndex=0}}return a([d({reflect:!0,type:Number})],e.prototype,"tabIndex",2),e};var O=class extends $r(oe(h)){constructor(){super();this.active=!1;this.softDisabled=!1;this.size=ee.SIZE;this.role=ee.ROLE;this.type=ee.TYPE;this.prevTabindex=0;this.addEventListener("click",this.executeAction.bind(this)),this.addEventListener("keydown",this.handleKeyDown.bind(this)),this.addEventListener("keyup",this.handleKeyUp.bind(this)),this.internals=this.attachInternals()}get form(){return this.internals.form}update(t){super.update(t),t.has("disabled")&&this.setDisabled(this,this.disabled),t.has("softDisabled")&&this.setSoftDisabled(this,this.softDisabled),t.has("active")&&this.setAriaPressed(this,this.active)}executeAction(){this.type===mt.SUBMIT&&this.internals.form&&this.internals.form.requestSubmit(),this.type===mt.RESET&&this.internals.form&&this.internals.form.reset()}setAriaPressed(t,r){r?t.setAttribute("aria-pressed","true"):t.removeAttribute("aria-pressed")}setSoftDisabled(t,r){r?t.setAttribute("aria-disabled","true"):t.removeAttribute("aria-disabled")}setDisabled(t,r){r?(t.setAttribute("aria-disabled","true"),this.prevTabindex=this.tabIndex,this.tabIndex=-1):(this.tabIndex=this.prevTabindex,t.removeAttribute("aria-disabled"))}triggerClickEvent(){let t=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});this.dispatchEvent(t),this.executeAction()}handleKeyDown(t){["Enter"," "].includes(t.key)&&(this.classList.add("pressed"),t.key==="Enter"&&this.triggerClickEvent())}handleKeyUp(t){["Enter"," "].includes(t.key)&&(this.classList.remove("pressed"),t.key===" "&&this.triggerClickEvent())}render(){return p`
935
935
  <slot></slot>
936
936
  `}};O.formAssociated=!0,O.styles=[...h.styles,...kr],a([d({type:Boolean})],O.prototype,"active",2),a([d({type:Boolean,attribute:"soft-disabled"})],O.prototype,"softDisabled",2),a([d({type:Number,reflect:!0})],O.prototype,"size",2),a([d({type:String,reflect:!0})],O.prototype,"role",2),a([d({reflect:!0})],O.prototype,"type",2);var zt=O;var R=class extends zt{constructor(){super(...arguments);this.variant=w.VARIANT;this.size=w.SIZE;this.color=w.COLOR;this.role="button";this.typeInternal=w.TYPE_INTERNAL;this.iconSize=1}update(t){super.update(t),t.has("active")&&this.modifyIconName(this.active),t.has("size")&&this.setSize(this.size),t.has("variant")&&(this.setVariant(this.variant),this.setSize(this.size)),t.has("color")&&this.setColor(this.color),t.has("typeInternal")&&this.setSize(this.size),(t.has("prefixIcon")||t.has("postfixIcon"))&&this.inferButtonType()}modifyIconName(t){t?(this.prefixIcon&&(this.prevPrefixIcon=this.prefixIcon,this.prefixIcon=`${we(this.prefixIcon)}-filled`),this.postfixIcon&&(this.prevPostfixIcon=this.postfixIcon,this.postfixIcon=`${we(this.postfixIcon)}-filled`)):(this.prevPrefixIcon&&(this.prefixIcon=this.prevPrefixIcon),this.prevPostfixIcon&&(this.postfixIcon=this.prevPostfixIcon))}setVariant(t){this.setAttribute("variant",Object.values(Nt).includes(t)?t:w.VARIANT)}setSize(t){let o=this.typeInternal===pt.ICON?Object.values(J).includes(t)&&!(t===J[20]&&this.variant!==Nt.TERTIARY):Object.values(re).includes(t);this.setAttribute("size",o?`${t}`:`${w.SIZE}`),this.iconSize=Mr(t)}setColor(t){!Object.values(Le).includes(t)||this.variant===Nt.TERTIARY?this.setAttribute("color",`${w.COLOR}`):this.setAttribute("color",t)}inferButtonType(){var r,o;let t=(o=(r=this.shadowRoot)==null?void 0:r.querySelector("slot"))==null?void 0:o.assignedNodes().length;t&&(this.prefixIcon||this.postfixIcon)?(this.typeInternal=pt.PILL_WITH_ICON,this.setAttribute("data-btn-type","pill-with-icon")):!t&&(this.prefixIcon||this.postfixIcon)?(this.typeInternal=pt.ICON,this.setAttribute("data-btn-type","icon")):(this.typeInternal=pt.PILL,this.setAttribute("data-btn-type","pill"))}render(){return p`
937
937
  ${this.prefixIcon?p`