"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),i=require("./button-constants.cjs"),o=require("../../localization/index.cjs"),r=require("../../_plugin-vue2_normalizer-e_CkxkSV.cjs"),a=require("../link/link-constants.cjs"),u={name:"DtButton",props:{circle:{type:Boolean,default:!1},iconPosition:{type:String,default:"left",validator:e=>Object.keys(i.ICON_POSITION_MODIFIERS).includes(e)},importance:{type:String,default:"primary",validator:e=>Object.keys(i.BUTTON_IMPORTANCE_MODIFIERS).includes(e)},link:{type:Boolean,default:!1},linkKind:{type:String,default:"default",validator:e=>Object.keys(a.LINK_KIND_MODIFIERS).includes(e)},linkInverted:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},type:{type:String,default:"button",validator:e=>i.BUTTON_TYPES.includes(e)},width:{type:String,default:null},size:{type:String,default:"md",validator:e=>Object.keys(i.BUTTON_SIZE_MODIFIERS).includes(e)},labelClass:{type:[String,Array,Object],default:""},loading:{type:Boolean,default:!1},kind:{type:String,default:"default",validator:e=>Object.keys(i.BUTTON_KIND_MODIFIERS).includes(e)},assertiveOnFocus:{type:Boolean,default:!1},active:{type:Boolean,default:!1}},emits:["click","focusin","focusout"],data(){return{ICON_POSITION_MODIFIERS:i.ICON_POSITION_MODIFIERS,isInFocus:!1,i18n:new o.DialtoneLocalization}},computed:{buttonListeners(){return this.assertiveOnFocus?{...this.$listeners,focusin:()=>{this.isInFocus=!0},focusout:()=>{this.isInFocus=!1}}:this.$listeners},computedAriaLive(){return this.assertiveOnFocus&&this.isInFocus?"assertive":this.$attrs.ariaLive},iconSize(){return i.BUTTON_ICON_SIZES[this.size]}},watch:{$props:{deep:!0,immediate:!0,handler(){process.env.NODE_ENV!=="production"&&(this.circle&&this.link&&l.util.warn("You cannot enable circle and link at the same time",this),this.isInvalidPropCombination(this.circle,this.kind,this.importance))}}},methods:{buttonClasses(){return this.link?["d-link",a.getLinkKindModifier(this.linkKind,this.linkInverted),i.BUTTON_SIZE_MODIFIERS[this.size]]:this.kind==="unstyled"?["d-btn--unstyled"]:["d-btn",i.BUTTON_IMPORTANCE_MODIFIERS[this.importance],i.BUTTON_KIND_MODIFIERS[this.kind],i.BUTTON_SIZE_MODIFIERS[this.size],{"d-btn--circle":this.circle,"d-btn--loading":this.loading,"d-btn--icon-only":this.isIconOnly(),"d-btn--vertical":this.isVerticalIconLayout(),"d-btn--active":this.active}]},isInvalidPropCombination(e,t,n){if(this.kind==="unstyled")return!0;for(const s of i.INVALID_COMBINATION)if(e===s.circle&&t===s.kind&&n===s.importance)return console.warn(s.message),!1;return!0},shouldRenderIcon(){return this.$scopedSlots.icon&&this.$scopedSlots.icon()&&!this.link},isIconOnly(){return this.shouldRenderIcon()&&!this.$slots.default},isVerticalIconLayout(){return!this.isIconOnly()&&["top","bottom"].includes(this.iconPosition)}}};var d=function(){var t=this,n=t._self._c;return n("button",t._g({class:["base-button__button",t.buttonClasses()],style:{width:t.width},attrs:{"data-qa":"dt-button",type:t.type,disabled:t.disabled,"aria-live":t.computedAriaLive,"aria-label":t.loading?t.i18n.$t("DIALTONE_LOADING"):t.$attrs["aria-label"]}},t.buttonListeners),[t.shouldRenderIcon()?n("span",{class:["base-button__icon",{"d-btn__icon":t.kind!=="unstyled",[t.ICON_POSITION_MODIFIERS[t.iconPosition]]:t.kind!=="unstyled"}],attrs:{"data-qa":"dt-button-icon"}},[t._t("icon",null,{iconSize:t.iconSize})],2):t._e(),t.$slots.default?n("span",{class:["base-button__label",{"d-btn__label":t.kind!=="unstyled"},t.labelClass],attrs:{"data-qa":"dt-button-label"}},[t._t("default")],2):t._e()])},c=[],I=r.n(u,d,c);const _=I.exports;exports.default=_;
//# sourceMappingURL=button.cjs.map
