"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("../../common/constants/index.cjs"),o=require("./select-menu-constants.cjs"),i=require("../../common/utils/index.cjs"),u=require("../../common/mixins/input.cjs"),m=require("./select-menu-validators.cjs"),S=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),E=require("../validation-messages/validation-messages.cjs"),_={compatConfig:{MODE:3},name:"DtSelectMenu",components:{DtValidationMessages:E.default},mixins:[u.MessagesMixin],inheritAttrs:!1,props:{label:{type:String,default:""},description:{type:String,default:""},options:{type:Array,default:()=>[],validator:t=>m.optionsValidator(t)},size:{type:String,default:"md",validator:t=>Object.keys(o.SELECT_SIZE_MODIFIERS).includes(t)},labelClass:{type:[String,Array,Object],default:""},descriptionClass:{type:[String,Array,Object],default:""},selectClass:{type:[String,Array,Object],default:""},optionClass:{type:[String,Array,Object],default:""},labelChildProps:{type:Object,default:()=>({})},descriptionChildProps:{type:Object,default:()=>({})},optionChildProps:{type:Object,default:()=>({})},disabled:{type:Boolean,default:!1},rootClass:{type:[String,Object,Array],default:""},modelValue:{type:[String,Number],default:""}},emits:["input","update:modelValue","change"],data(){return{LABEL_SIZE_MODIFIERS:d.LABEL_SIZE_MODIFIERS,DESCRIPTION_SIZE_MODIFIERS:d.DESCRIPTION_SIZE_MODIFIERS,SELECT_SIZE_MODIFIERS:o.SELECT_SIZE_MODIFIERS,SELECT_STATE_MODIFIERS:o.SELECT_STATE_MODIFIERS,hasSlotContent:i.hasSlotContent}},computed:{selectListeners(){return{input:()=>{},change:t=>this.emitValue(t.target.value,t)}},state(){return i.getValidationState(this.formattedMessages)},selectKey(){return i.getUniqueString()},descriptionKey(){return`select-${this.selectKey}-description`},labelAriaDetails(){return this.$slots.description||this.description?this.descriptionKey:this.$attrs["aria-details"]}},mounted(){this.validateOptionsPresence()},beforeUpdate(){this.validateOptionsPresence()},methods:{removeClassStyleAttrs:i.removeClassStyleAttrs,addClassStyleAttrs:i.addClassStyleAttrs,emitValue(t,r){this.$emit("update:modelValue",t,r),this.$emit("input",t,r),this.$emit("change",t,r)},getOptionKey(t){return`select-${this.selectKey}-option-${t}`},validateOptionsPresence(){var t;((t=this.options)==null?void 0:t.length)<1&&!this.$slots.default&&e.warn("Options are expected to be provided via prop or slot",this)}}},p=["aria-details"],g=["id"],C=["disabled","value"],y=["value"];function I(t,r,s,b,a,l){const c=e.resolveComponent("dt-validation-messages");return e.openBlock(),e.createElementBlock("div",e.mergeProps({class:s.rootClass},l.addClassStyleAttrs(t.$attrs)),[e.createElementVNode("label",null,[a.hasSlotContent(t.$slots.label)||s.label?(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:0,"aria-details":l.labelAriaDetails,class:["d-label",a.LABEL_SIZE_MODIFIERS[s.size],s.labelClass]},s.labelChildProps,{"data-qa":"dt-select-label"}),[e.renderSlot(t.$slots,"label",{},()=>[e.createTextVNode(e.toDisplayString(s.label),1)])],16,p)):e.createCommentVNode("",!0),a.hasSlotContent(t.$slots.description)||s.description?(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:1,id:l.descriptionKey,class:["d-description",a.DESCRIPTION_SIZE_MODIFIERS[s.size],s.descriptionClass]},s.descriptionChildProps,{"data-qa":"dt-select-description"}),[e.renderSlot(t.$slots,"description",{},()=>[e.createTextVNode(e.toDisplayString(s.description),1)])],16,g)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["d-select",a.SELECT_SIZE_MODIFIERS[s.size],s.selectClass,{"d-select--disabled":s.disabled}]),"data-qa":"dt-select-wrapper"},[e.createElementVNode("select",e.mergeProps({ref:"selectElement",class:["d-select__input",a.SELECT_STATE_MODIFIERS[l.state]]},l.removeClassStyleAttrs(t.$attrs),{"data-qa":"dt-select",disabled:s.disabled,value:s.modelValue},e.toHandlers(l.selectListeners,!0)),[e.renderSlot(t.$slots,"default",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.options,n=>(e.openBlock(),e.createElementBlock("option",e.mergeProps({key:l.getOptionKey(n.value),value:n.value,class:s.optionClass},{ref_for:!0},s.optionChildProps),e.toDisplayString(n.label),17,y))),128))])],16,C)],2)]),e.createVNode(c,e.mergeProps({"validation-messages":t.formattedMessages,"show-messages":t.showMessages,class:t.messagesClass},t.messagesChildProps,{"data-qa":"dt-select-messages"}),null,16,["validation-messages","show-messages","class"])],16)}const h=S._(_,[["render",I]]);exports.default=h;
//# sourceMappingURL=select-menu.cjs.map
