import{c as F,t as f,o as O,g as a,A as r,i as V,C as p,J as b,j as i,B as n,O as h,a8 as c,Z as L,H as $,r as y}from"./index-DOFLUERq.js";import N from"./EditableInput-DhGmkLrc.js";import{u as z,m as A,b as D}from"./utils-DMBE_oxT.js";import R from"./AddFieldButton-DEq3S2HV.js";import{u as T}from"./index-CRx3oDcD.js";import{I as u}from"./iconify-p99pbjf9.js";import{_ as q}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{h as w}from"./index-DuPUrsw1.js";import"./Autocomplete-SEbcHX6m.js";const E=["title"],S={class:"field-label"},U={key:0,class:"reqd-asterisk"},j={key:1,class:"help-icon"},H=["hidden"],J=["title"],K=["title"],P=["title"],Y={__name:"Field",props:["column","field"],setup(l){const t=l,o=z(),C=y(null),{ctrl_shift_n:B,Backspace:_}=T();w(B,e=>{e&&m.value&&C.value?.open()}),w(_,e=>{e&&m.value&&o.notUsingInput&&k()});const x=y(null),v=y(!1),m=F(()=>o.selected(t.field.df.name)),I=F(()=>t.field.df.fieldtype.replaceAll(" ","")+"Control");function k(){if(o.isCustomizeForm&&t.field.df.is_custom_field===0)throw alert(f("Cannot delete standard field. You can hide it if you want")),"cannot delete standard field";let e=t.column.fields.indexOf(t.field);t.column.fields.splice(e,1),o.form.selected_field=null}function g(){let e=o.currentTab?.sections?.find(d=>d.columns.find(s=>s===t.column));e&&A(t,"column","field",e,o.getDf)}function M(){let e=D(t.field);o.isCustomizeForm&&(e.df.is_custom_field=1),e.df.label&&(e.df.label=e.df.label+" Copy"),e.df.fieldname="",e.df.__islocal=1,e.df.__unsaved=1,delete e.df.creation,delete e.df.modified,delete e.df.modified_by;let d=t.column.fields.indexOf(t.field);t.column.fields.splice(d+1,0,e),o.form.selected_field=e.df}return O(()=>m.value&&x.value?.focusOnLabel?.()),(e,d)=>(a(),r("div",{class:$(["field",m.value?"selected":v.value?"hovered":""]),title:l.field.df.fieldname,onClick:d[1]||(d[1]=c(s=>i(o).form.selected_field=l.field.df,["stop"])),onMouseover:d[2]||(d[2]=c(s=>v.value=!0,["stop"])),onMouseout:d[3]||(d[3]=c(s=>v.value=!1,["stop"]))},[(a(),V(L(I.value),{df:l.field.df,"data-fieldname":l.field.df.fieldname,"data-fieldtype":l.field.df.fieldtype},{label:p(()=>[b("div",S,[n(N,{ref_key:"labelInput",ref:x,text:l.field.df.label,placeholder:i(f)("Label"),emptyLabel:`${i(f)("No Label")} (${l.field.df.fieldtype})`,modelValue:l.field.df.label,"onUpdate:modelValue":d[0]||(d[0]=s=>l.field.df.label=s)},null,8,["text","placeholder","emptyLabel","modelValue"]),l.field.df.reqd?(a(),r("div",U,"*")):h("",!0),l.field.df.documentation_url?(a(),r("div",j,[n(i(u),{icon:"mdi:help-circle-outline",class:"icon-sm"})])):h("",!0)])]),actions:p(()=>[b("div",{class:"field-actions",hidden:i(o).readOnly},[n(R,{ref_key:"addFieldRef",ref:C,column:l.column,field:l.field},{default:p(()=>[n(i(u),{icon:"mdi:plus",class:"icon-sm"})]),_:1},8,["column","field"]),l.column.fields.indexOf(l.field)?(a(),r("button",{key:0,class:"btn btn-xs btn-icon",title:i(f)("Move the current field and the following fields to a new column"),onClick:g},[n(i(u),{icon:"mdi:arrow-right-box",class:"icon-sm"})],8,J)):h("",!0),b("button",{class:"btn btn-xs btn-icon",title:i(f)("Duplicate field"),onClick:c(M,["stop"])},[n(i(u),{icon:"mdi:content-copy",class:"icon-sm"})],8,K),b("button",{class:"btn btn-xs btn-icon",title:i(f)("Remove field"),onClick:c(k,["stop"])},[n(i(u),{icon:"mdi:close",class:"icon-sm"})],8,P)],8,H)]),_:1},8,["df","data-fieldname","data-fieldtype"]))],42,E))}},ie=q(Y,[["__scopeId","data-v-c286b6bd"]]);export{ie as default};
