import{w as S,g as v,A,J as _,D as L,_ as k,P as D,j as b,t as h,a8 as O,i as R,a6 as T,ab as V,B as C,G as E,Y as I,r as a,n as N,c as w}from"./index-DOFLUERq.js";import j from"./Autocomplete-SEbcHX6m.js";import{u as P,b as Y,A as $,a as z,L as U}from"./utils-DMBE_oxT.js";import{c as G}from"./index-CRx3oDcD.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./iconify-p99pbjf9.js";import"./index-DuPUrsw1.js";const M={class:"add-field-wrapper"},W=["title"],q={__name:"AddFieldButton",props:{column:{type:Object,default:null},field:{type:Object,default:null},tooltip:{type:String,default:"Add field"}},emits:["update:modelValue"],setup(n,{expose:x,emit:H}){const d=P(),o=n,y=w(()=>{let e=o.field?o.field.df.name:o.column.df.name;return d.selected(e)}),l=a(!1),u=a(""),r=a({}),F=w(()=>[...$.filter(t=>!z(U,t)).map(t=>({label:t,value:t}))]),s=a(null),f=a(null);G(s,()=>l.value=!1,{ignore:[f]});function B(){if(!s.value||!l.value)return;const e=s.value.getBoundingClientRect();r.value={position:"fixed",top:`${e.bottom+4}px`,left:`${e.left}px`,minWidth:"200px",zIndex:1e3}}function c(){l.value=!l.value,u.value="",N(()=>B())}function g(e){const t=e?.value;if(!t)return;let i={df:d.getDf(t),table_columns:[]},p=Y(i),m=0;o.field&&(m=o.column.fields.indexOf(o.field)),o.column.fields.splice(m+1,0,p),d.form.selected_field=p.df,l.value=!1}return S(y,e=>{e||(l.value=!1)}),x({open:c}),(e,t)=>(v(),A("div",M,[_("button",{ref_key:"addFieldBtnRef",ref:s,class:"add-field-btn btn btn-xs btn-icon",title:n.tooltip,onClick:O(c,["stop"])},[L(e.$slots,"default",{},()=>[k(D(b(h)("Add field")),1)],!0)],8,W),(v(),R(I,{to:"body"},[T(_("div",{ref_key:"autocompleteRef",ref:f,class:"autocomplete-dropdown",style:E(r.value)},[C(j,{show:l.value,"onUpdate:show":t[0]||(t[0]=i=>l.value=i),value:u.value,options:F.value,onChange:g,placeholder:b(h)("Search fieldtypes...")},null,8,["show","value","options","placeholder"])],4),[[V,l.value]])]))]))}},oe=J(q,[["__scopeId","data-v-b6bd3c60"]]);export{oe as default};
