import{e as O,f as m,B as f,A as p,v as d,n as S,g as b,c as s,o as g,q as v,F as $,u as A,y as V,C as P,t as _,r as D,J as I}from"./iframe-Bl-fVlm8.js";import{u as L}from"./index-pk-yyh3_.js";import{k as T}from"./floating-vue-C5xzxu-B.js";import{l as q}from"./lodash-CdDiHlzQ.js";import{_ as W}from"./PzIcon-cRuuou9i.js";import{P as R}from"./PzLabel-avnfC9tn.js";import{_ as j}from"./_plugin-vue_export-helper-DlAUqK2U.js";const J=6,M=["id"],Z=["id","disabled","aria-controls","aria-expanded","aria-label"],G={class:"pz-select-trigger-text"},H=["id","aria-labelledby"],K=["id","aria-selected","disabled","onClick"],o=O({name:"PzSelect",__name:"PzSelect",props:{name:{},options:{},modelValue:{type:[String,Number,Boolean],default:void 0},label:{default:""},placeholder:{default:""},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1},variant:{default:"field"},width:{default:void 0}},emits:["update:modelValue"],setup(l,{emit:x}){const a=l,N=x,y=D(null),{width:k}=L(y),i=s(()=>a.options.find(e=>q.isEqual(e.value,a.modelValue))),u=s(()=>a.variant==="field"),B=s(()=>{var e;return((e=i.value)==null?void 0:e.label)??a.placeholder}),C=s(()=>{var e;return a.label||((e=i.value)==null?void 0:e.label)||a.placeholder||a.name}),E=s(()=>{const e=Math.round(k.value);return!e||!u.value?{}:{inlineSize:`${String(e)}px`}}),c=e=>q.isEqual(e,a.modelValue),h=(e,r)=>e.id??`${a.name}-trigger-option-${String(r+1)}`,w=e=>({option:e,selected:c(e.value),disabled:!!e.disabled}),F=(e,r)=>{N("update:modelValue",e),r()};return(e,r)=>(g(),m("div",{id:l.name,class:b(["pz-select",{"is-field":u.value,"is-inline":!u.value}]),style:S({width:l.width})},[f(d(R),{label:a.label,for:l.name+"-trigger",required:a.required,disabled:a.disabled},{default:p(()=>[f(d(T),{class:"pz-select-dropdown",theme:"dropdown",placement:"bottom-start",container:"#"+l.name,distance:d(J),disabled:a.disabled},{default:p(({shown:n})=>[v("button",{id:l.name+"-trigger",ref_key:"triggerRef",ref:y,type:"button",class:b(["pz-select-trigger",{"is-open":n,"is-placeholder":!i.value}]),disabled:a.disabled,"aria-controls":l.name+"-menu","aria-expanded":n?"true":"false","aria-haspopup":"listbox","aria-label":a.label?void 0:C.value},[v("span",G,[V(e.$slots,"selected",{option:i.value,placeholder:a.placeholder},()=>[P(_(B.value),1)],!0)]),f(d(W),{name:"expand_more",size:"20",class:"pz-select-trigger-icon"})],10,Z)]),popper:p(({hide:n})=>[v("div",{id:l.name+"-menu",class:"pz-select-menu",style:S(E.value),role:"listbox","aria-labelledby":l.name+"-trigger"},[(g(!0),m($,null,A(a.options,(t,z)=>(g(),m("button",{id:h(t,z),key:h(t,z),type:"button",role:"option",class:b(["pz-select-option",{"is-active":c(t.value),"is-disabled":t.disabled}]),"aria-selected":c(t.value)?"true":"false",disabled:t.disabled,onClick:Q=>F(t.value,n)},[V(e.$slots,"default",I({ref_for:!0},w(t)),()=>[P(_(t.label),1)],!0)],10,K))),128))],12,H)]),_:3},8,["container","distance","disabled"])]),_:3},8,["label","for","required","disabled"])],14,M))}}),se=j(o,[["__scopeId","data-v-c794c950"]]);o.__docgenInfo=Object.assign({displayName:o.name??o.__name},{name:"PzSelect",exportName:"default",displayName:"PzSelect",description:"",tags:{},props:[{name:"name",required:!0,type:{name:"string"}},{name:"options",required:!0,type:{name:"Array",elements:[{name:"PzFormSelectOption"}]}},{name:"modelValue",required:!1,type:{name:"PzFormSelectValue"},defaultValue:{func:!1,value:"undefined"}},{name:"label",required:!1,type:{name:"string"},defaultValue:{func:!1,value:'""'}},{name:"placeholder",required:!1,type:{name:"string"},defaultValue:{func:!1,value:'""'}},{name:"disabled",required:!1,type:{name:"boolean"},defaultValue:{func:!1,value:"false"}},{name:"required",required:!1,type:{name:"boolean"},defaultValue:{func:!1,value:"false"}},{name:"variant",required:!1,type:{name:"PzSelectVariant"},defaultValue:{func:!1,value:'"field"'}},{name:"width",required:!1,type:{name:"string"},defaultValue:{func:!1,value:"undefined"}}],slots:[{name:"selected",scoped:!0,bindings:[{name:"option",title:"binding"},{name:"placeholder",title:"binding"}]},{name:"default",scoped:!0,bindings:[]}],sourceFiles:["/builds/Web-Projects/client-services/prozorro-ui/src/components/Form/PzSelect/PzSelect.vue"]});export{se as P};
