import{r as u,c as x,e as c,g as b,D as E,E as g,i as n,B as k,C as h,n as p,L as w}from"./index-a0da86f0.js";import{_ as B}from"./_plugin-vue_export-helper-c27b6911.js";const D={key:0,class:"editable-text"},I={__name:"EditableInput",props:{text:{type:String,default:""},placeholder:{type:String,default:""},emptyLabel:{type:String,default:""}},emits:["update:modelValue"],setup(d,{emit:f}){const e=d,_=f,t=u(!1),a=u(""),s=u(null),m=x(()=>e.text?e.text:e.emptyLabel?e.emptyLabel:e.placeholder||"点击编辑");async function v(){var o,l;t.value=!0,a.value=e.text,await w(),(o=s.value)==null||o.focus(),(l=s.value)==null||l.select()}function i(){t.value&&(_("update:modelValue",a.value),t.value=!1)}function r(){a.value=e.text,t.value=!1}return(o,l)=>(p(),c("span",{class:k(["editable-input",{"is-editing":t.value}]),onDblclick:h(v,["stop"]),onKeydown:[n(i,["enter"]),n(r,["escape"])],tabindex:"0"},[t.value?E((p(),c("input",{key:1,ref_key:"inputRef",ref:s,type:"text",class:"form-control","onUpdate:modelValue":l[0]||(l[0]=y=>a.value=y),onBlur:i,onKeydown:[n(i,["enter"]),n(r,["escape"])]},null,544)),[[g,a.value]]):(p(),c("span",D,b(m.value),1))],34))}},V=B(I,[["__scopeId","data-v-c7790eb2"]]);export{V as default};
