import{u as F,_ as $}from"./useFormSelect-DvaFh_iu-BGTVaqMd.js";import{u as y}from"./useDefaults-DESCdb0p-CFLjYrdG.js";import{u as I}from"./useId-t29UARy6-BH5d2231.js";import{l as g,x as f,d as l,o as i,J as p,F as b,r as v,c as D,w as T,L as m,D as B,e as S,t as V,_ as k,b as h,a as w}from"./index-D02r7Zsc.js";import{_ as L}from"./BFormInput.vue_vue_type_script_setup_true_lang-B9E5yJEs-DBdCBfsp.js";import"./object-0ALvRU0O-3BORTTD-.js";import"./useStateClass-BGbSLWFN-BcKQ8Z3i.js";import"./index-C0p9vHHI-DoOEDIMw.js";const C=["id"],N=g({__name:"BFormDatalist",props:{disabledField:{default:"disabled"},id:{default:void 0},options:{default:()=>[]},textField:{default:"text"},valueField:{default:"value"}},setup(t){const e=y(t,"BFormDatalist"),u=I(()=>e.id,"datalist"),{normalizedOptions:c,isComplex:n}=F(()=>e.options,f(()=>({...e,optionsField:"options",labelField:"label"}))),d=f(()=>c.value.filter(a=>!n(a)));return(a,o)=>(i(),l("datalist",{id:B(u)},[p(a.$slots,"first"),(i(!0),l(b,null,v(d.value,(r,x)=>(i(),D($,m({key:x},{ref_for:!0},r),{default:T(()=>[p(a.$slots,"option",m({ref_for:!0},r),()=>[S(V(r.text),1)])]),_:2},1040))),128)),p(a.$slots,"default")],8,C))}}),_={11:"categories",2:"authors",3:"publishers",51:"titres_uniformes",4:"collections",5:"subcollections",12:"indexint",6:"serie"},z={name:"authoritySelector",props:["criteria","value"],watch:{userText:async function(){this.userText.length>2&&this.updateDatalist()}},data:function(){return{authorities:[],userText:""}},computed:{authLabel:function(){return _[this.criteria.id]!==void 0?_[this.criteria.id]:""}},methods:{updateInput:function(t){let s=this.authorities.findIndex(u=>u.label==t.target.value),e=0;s!=-1&&(e=this.authorities[s].id),this.$emit("update",e)},updateDatalist:async function(){let t=await this.get("ws").getSelector(this.authLabel,this.userText);this.authorities=t}}},O={id:"authority-datalist"},A=["data-value","value"];function E(t,s,e,u,c,n){const d=L,a=N;return i(),l("div",null,[h(d,{autocomplete:"off",list:"authority-datalist",modelValue:t.userText,"onUpdate:modelValue":s[0]||(s[0]=o=>t.userText=o),onInput:n.updateInput},null,8,["modelValue","onInput"]),w("datalist",O,[(i(!0),l(b,null,v(t.authorities,(o,r)=>(i(),l("option",{key:r,"data-value":o.id,value:o.label},null,8,A))),128))]),h(a,{id:"authority-datalist",options:t.authorities,"text-field":"label","value-field":"id"},null,8,["options"])])}const K=k(z,[["render",E]]);export{K as default};
