"use strict";var f=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var m=(e,n)=>{var r={};for(var u in e)B.call(e,u)&&n.indexOf(u)<0&&(r[u]=e[u]);if(e!=null&&f)for(var u of f(e))n.indexOf(u)<0&&V.call(e,u)&&(r[u]=e[u]);return r};const t=require("vue"),I=require("./Icon.js"),l=require("./constants.js"),w=require("./useModelWrapper.cjs"),S=require("./useSplitAttributes.cjs"),T=require("./useFieldData.cjs"),h=require("./_plugin-vue_export-helper.js"),M=l.makeStringTypeValidator(l.TextInputTypes),K=l.makeStringTypeValidator(l.ValidationStatusTypes),q=t.defineComponent({name:"CdxTextInput",components:{CdxIcon:I.CdxIcon},inheritAttrs:!1,expose:["focus","blur"],props:{modelValue:{type:[String,Number],default:""},inputType:{type:String,default:"text",validator:M},status:{type:String,default:"default",validator:K},disabled:{type:Boolean,default:!1},startIcon:{type:[String,Object],default:void 0},endIcon:{type:[String,Object],default:void 0},clearable:{type:Boolean,default:!1}},emits:["update:modelValue","keydown","input","change","focus","blur","clear"],setup(e,{emit:n,attrs:r}){const u=r.id,{computedDisabled:a,computedStatus:c,computedInputId:i}=T(t.toRef(e,"disabled"),t.toRef(e,"status"),u),s=t.inject(l.FieldDescriptionIdKey,void 0),d=w(t.toRef(e,"modelValue"),n),p=t.computed(()=>e.clearable&&!!d.value&&!a.value),C=t.computed(()=>({"cdx-text-input--has-start-icon":!!e.startIcon,"cdx-text-input--has-end-icon":!!e.endIcon,"cdx-text-input--clearable":p.value,["cdx-text-input--status-".concat(c.value)]:!0})),{rootClasses:b,rootStyle:v,otherAttrs:k}=S(r,C),g=t.computed(()=>{const y=k.value,{id:o}=y;return m(y,["id"])}),x=t.computed(()=>({"cdx-text-input__input--has-value":!!d.value}));return{computedInputId:i,descriptionId:s,wrappedModel:d,isClearable:p,rootClasses:b,rootStyle:v,otherAttrsMinusId:g,inputClasses:x,computedDisabled:a,onClear:o=>{d.value="",n("clear",o)},onInput:o=>{n("input",o)},onChange:o=>{n("change",o)},onKeydown:o=>{(o.key==="Home"||o.key==="End")&&!o.ctrlKey&&!o.metaKey||n("keydown",o)},onFocus:o=>{n("focus",o)},onBlur:o=>{n("blur",o)},cdxIconClear:I.Y3}},methods:{focus(){this.$refs.input.focus()},blur(){this.$refs.input.blur()}}}),F=["id","type","aria-describedby","disabled"];function $(e,n,r,u,a,c){const i=t.resolveComponent("cdx-icon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["cdx-text-input",e.rootClasses]),style:t.normalizeStyle(e.rootStyle)},[t.withDirectives(t.createElementVNode("input",t.mergeProps({id:e.computedInputId,ref:"input","onUpdate:modelValue":n[0]||(n[0]=s=>e.wrappedModel=s),class:["cdx-text-input__input",e.inputClasses]},e.otherAttrsMinusId,{type:e.inputType,"aria-describedby":e.descriptionId,disabled:e.computedDisabled,size:"1",onInput:n[1]||(n[1]=(...s)=>e.onInput&&e.onInput(...s)),onChange:n[2]||(n[2]=(...s)=>e.onChange&&e.onChange(...s)),onFocus:n[3]||(n[3]=(...s)=>e.onFocus&&e.onFocus(...s)),onBlur:n[4]||(n[4]=(...s)=>e.onBlur&&e.onBlur(...s)),onKeydown:n[5]||(n[5]=(...s)=>e.onKeydown&&e.onKeydown(...s))}),null,16,F),[[t.vModelDynamic,e.wrappedModel]]),e.startIcon?(t.openBlock(),t.createBlock(i,{key:0,icon:e.startIcon,class:"cdx-text-input__icon-vue cdx-text-input__start-icon"},null,8,["icon"])):t.createCommentVNode("v-if",!0),e.endIcon?(t.openBlock(),t.createBlock(i,{key:1,icon:e.endIcon,class:"cdx-text-input__icon-vue cdx-text-input__end-icon"},null,8,["icon"])):t.createCommentVNode("v-if",!0),e.isClearable?(t.openBlock(),t.createBlock(i,{key:2,icon:e.cdxIconClear,class:"cdx-text-input__icon-vue cdx-text-input__clear-icon",onMousedown:n[6]||(n[6]=t.withModifiers(()=>{},["prevent"])),onClick:e.onClear},null,8,["icon","onClick"])):t.createCommentVNode("v-if",!0)],6)}const A=h._export_sfc(q,[["render",$]]);module.exports=A;
