import{g as n,A as a,j as s,a8 as k,R as x,ad as L,G as T,P as m,J as h,t as g,n as B,r as i,c as M}from"./index-DOFLUERq.js";import{u as S}from"./utils-DMBE_oxT.js";import{_ as w}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-CRx3oDcD.js";import"./index-DuPUrsw1.js";const H=["title"],I=["disabled","placeholder","value"],D=["innerHTML"],E={key:2,class:"text-muted"},N=["innerHTML"],O={__name:"EditableInput",props:{text:{type:String},placeholder:{default:"No Label"},emptyLabel:{default:"No Label"}},setup(e,{expose:y}){let r=S();const u=e;let t=i(!1),f=i(null),d=i(null),p=i(null),v=M(()=>d.value&&u.text?d.value.offsetWidth+15+"px":u.text?"40px":p.value?.offsetWidth+15+"px"||"100px");function c(){r.readOnly||(t.value=!0,B(()=>f.value?.focus()))}return y({focusOnLabel:c}),(b,l)=>(n(),a("div",{onDblclick:c,title:s(g)("Double click to edit label")},[s(t)?(n(),a("input",{key:0,class:"input-text",ref_key:"inputText",ref:f,disabled:s(r).readOnly,type:"text",placeholder:e.placeholder,value:e.text,style:T({width:s(v)}),onInput:l[0]||(l[0]=o=>b.$emit("update:modelValue",o.target.value)),onKeydown:l[1]||(l[1]=L(o=>x(t)?t.value=!1:t=!1,["enter"])),onBlur:l[2]||(l[2]=o=>x(t)?t.value=!1:t=!1),onClick:l[3]||(l[3]=k(()=>{},["stop"]))},null,44,I)):e.text?(n(),a("span",{key:1,innerHTML:e.text},null,8,D)):(n(),a("i",E,m(e.emptyLabel),1)),h("span",{class:"hidden-span",ref_key:"hiddenText",ref:d,innerHTML:e.text},null,8,N),h("span",{class:"hidden-span",ref_key:"hiddenPlaceholder",ref:p},m(e.placeholder),513)],40,H))}},V=w(O,[["__scopeId","data-v-c927f830"]]);export{V as default};
