import{c as r,o as i,f as o,b as c,t as a,p as h,B as u,d,F as p,j as b,n as y}from"./app-BLo7SiiE.js";import{_ as V}from"./FlashMessages-DImpr6PL.js";import{v}from"./v4-SoommWqA.js";const w={inheritAttrs:!1,props:{placeholder:{type:String,default:""},onInput:{type:Function},items:{type:Array},id:{type:String,default(){return`select-input-filter-${v()}`}},error:String,label:String,modelValue:[String,Number,Boolean]},emits:["update:modelValue"],data(){return{selectedValue:"",selected:this.modelValue,isListVisible:!1}},watch:{selected(e){this.$emit("update:modelValue",e)}},created(){},mounted(){document.addEventListener("click",this.close)},methods:{close(e){this.$el.contains(e.target)||(this.isListVisible=!1)},onFocus(){this.isListVisible=!0},selectItem(e){this.$refs.input.value=e.name,this.selected=e.id,this.selectedValue=e.name,this.isListVisible=!1},focus(){this.$refs.input.focus()},select(){this.$refs.input.select()}}},g=["for"],S=["id","placeholder"],k={key:1,class:"form-error"},_={key:2,class:"i__filter__list"},F=["onClick"];function I(e,l,t,L,f,n){return i(),r("div",{class:y(["sel__filter",e.$attrs.class]),ref:"sel__filter"},[t.label?(i(),r("label",{key:0,class:"form-label",for:t.id},a(t.label)+":",9,g)):o("",!0),c("input",h({id:t.id,ref:"input",class:["form-select",{error:t.error}],type:"text"},{...e.$attrs,class:null},{placeholder:t.placeholder,onInput:l[0]||(l[0]=(...s)=>t.onInput&&t.onInput(...s)),onFocus:l[1]||(l[1]=(...s)=>n.onFocus&&n.onFocus(...s)),onKeydown:[l[2]||(l[2]=u(d((...s)=>e.onArrowDown&&e.onArrowDown(...s),["prevent"]),["down"])),l[3]||(l[3]=u(d((...s)=>e.onArrowUp&&e.onArrowUp(...s),["prevent"]),["up"])),l[4]||(l[4]=u(d((...s)=>e.selectCurrentSelection&&e.selectCurrentSelection(...s),["prevent"]),["enter","tab"]))],autocomplete:"off"}),null,16,S),t.error?(i(),r("div",k,a(t.error),1)):o("",!0),f.isListVisible&&t.items.length?(i(),r("div",_,[c("ul",null,[(i(!0),r(p,null,b(t.items,(s,m)=>(i(),r("li",{key:m,onClick:A=>n.selectItem(s)},a(s.name),9,F))),128))])])):o("",!0)],2)}const N=V(w,[["render",I]]);export{N as S};
