"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=require("../../common/utils/index.cjs"),i=require("./toggle-constants.cjs"),d=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),o={compatConfig:{MODE:3},name:"DtToggle",inheritAttrs:!1,props:{id:{type:String,default(){return s.getUniqueString()}},disabled:{type:Boolean,default:!1},modelValue:{type:[Boolean,String],default:!1,validator:t=>i.TOGGLE_CHECKED_VALUES.includes(t)},toggleOnClick:{type:Boolean,default:!0},size:{type:String,default:"md",validator:t=>Object.keys(i.TOGGLE_SIZE_MODIFIERS).includes(t)},showIcon:{type:Boolean,default:!0},labelClass:{type:[String,Array,Object],default:""},wrapperClass:{type:[String,Array,Object],default:void 0},labelChildProps:{type:Object,default:()=>({})}},emits:["change","update:modelValue"],data(){return{internalChecked:this.modelValue,hasSlotContent:s.hasSlotContent}},computed:{inputListeners(){return{...s.removeClassStyleAttrs(this.$attrs),onClick:()=>this.toggleCheckedValue()}},isIndeterminate(){return this.internalChecked==="mixed"},toggleRole(){return this.isIndeterminate?"checkbox":"switch"},toggleClasses(){return["d-toggle",i.TOGGLE_SIZE_MODIFIERS[this.size],{"d-toggle--checked":this.internalChecked===!0,"d-toggle--disabled":this.disabled,"d-toggle--indeterminate":this.isIndeterminate}]}},watch:{modelValue(t){this.internalChecked=t}},mounted(){this.runValidations()},methods:{addClassStyleAttrs:s.addClassStyleAttrs,toggleCheckedValue(){this.$emit("update:modelValue",!this.internalChecked),this.$emit("change",!this.internalChecked),this.toggleOnClick&&(this.internalChecked=!this.internalChecked)},hasSlotLabel(){return!!this.$slots.default},runValidations(){this.validateInputLabels(this.hasSlotLabel(),this.$attrs["aria-label"])},validateInputLabels(t,n){!t&&!n&&e.warn("You must provide an aria-label when there is no label passed",this)}}},c=["for"],u=["id","role","aria-checked","disabled","aria-disabled"],h={key:0,class:"d-toggle__inner"};function g(t,n,l,C,r,a){return e.openBlock(),e.createElementBlock("div",e.mergeProps({class:["d-toggle-wrapper",l.wrapperClass]},a.addClassStyleAttrs(t.$attrs)),[r.hasSlotContent(t.$slots.default)?(e.openBlock(),e.createElementBlock("label",e.mergeProps({key:0,class:l.labelClass,for:l.id},l.labelChildProps,{"data-qa":"toggle-label"}),[e.renderSlot(t.$slots,"default")],16,c)):e.createCommentVNode("",!0),e.createElementVNode("button",e.mergeProps({id:l.id,role:a.toggleRole,type:"button","aria-checked":r.internalChecked.toString(),disabled:l.disabled,"aria-disabled":l.disabled.toString(),class:a.toggleClasses},a.inputListeners),[l.showIcon?(e.openBlock(),e.createElementBlock("span",h)):e.createCommentVNode("",!0)],16,u)],16)}const m=d._(o,[["render",g]]);exports.default=m;
//# sourceMappingURL=toggle.cjs.map
