"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue"),N=require("@ant-design/icons-vue/EnterOutlined"),l=require("../_util/KeyCode.js"),T=require("../_util/classNames.js"),p=require("../input/TextArea.js"),z=require("./style/index.js"),$=()=>({prefixCls:String,value:String,maxlength:Number,autoSize:{type:[Boolean,Object]},onSave:Function,onCancel:Function,onEnd:Function,onChange:Function,originContent:String,direction:String,component:String}),q=i.defineComponent({compatConfig:{MODE:3},name:"Editable",inheritAttrs:!1,props:$(),setup(n,{emit:r,slots:s,attrs:f}){const{prefixCls:a}=i.toRefs(n),t=i.reactive({current:n.value||"",lastKeyCode:void 0,inComposition:!1,cancelFlag:!1});i.watch(()=>n.value,e=>{t.current=e});const c=i.ref();i.onMounted(()=>{if(c.value){const o=c.value?.resizableTextArea?.textArea;o.focus();const{length:u}=o.value;o.setSelectionRange(u,u)}});function C(e){c.value=e}function m({target:{value:e}}){t.current=e.replace(/[\r\n]/g,""),r("change",t.current)}function g(){t.inComposition=!0}function v(){t.inComposition=!1}function x(e){const{keyCode:o}=e;o===l.default.ENTER&&e.preventDefault(),!t.inComposition&&(t.lastKeyCode=o)}function S(e){const{keyCode:o,ctrlKey:u,altKey:E,metaKey:b,shiftKey:A}=e;t.lastKeyCode===o&&!t.inComposition&&!u&&!E&&!b&&!A&&(o===l.default.ENTER?(d(),r("end")):o===l.default.ESC&&(t.current=n.originContent,r("cancel")))}function y(){d()}function d(){r("save",t.current.trim())}const[h,K]=z.default(a);return()=>{const e=T.default({[`${a.value}`]:!0,[`${a.value}-edit-content`]:!0,[`${a.value}-rtl`]:n.direction==="rtl",[n.component?`${a.value}-${n.component}`:""]:!0},f.class,K.value);return h(i.createVNode("div",{...f,class:e},[i.createVNode(p.default,{ref:C,maxlength:n.maxlength,value:t.current,onChange:m,onKeydown:x,onKeyup:S,onCompositionstart:g,onCompositionend:v,onBlur:y,rows:1,autoSize:n.autoSize===void 0||n.autoSize},null),s.enterIcon?s.enterIcon({className:`${n.prefixCls}-edit-content-confirm`}):i.createVNode(N,{class:`${n.prefixCls}-edit-content-confirm`},null)]))}}});exports.default=q;
