"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),C=require("@aplus-frontend/antdv"),R=require("lodash-unified");require("../../render/index.js");require("../../hooks/index.js");const q=require("../hooks/use-default-placeholder.js"),S=require("../../hooks/useControllableValue.js"),P=require("../../render/render.js"),k=e.defineComponent({name:"ApFieldText",__name:"index",props:{mode:{default:"edit"},class:{},style:{},emptyText:{default:"--"},customReadMode:{},variant:{},size:{},value:{},name:{},type:{default:"text"},onCompositionend:{},onCompositionstart:{},onFocus:{},onBlur:{},onChange:{},onInput:{},onKeydown:{},onKeyup:{},onMousedown:{},focused:{type:Boolean},hidden:{type:Boolean},disabled:{type:Boolean,default:void 0},prefixCls:{},id:{},readonly:{type:Boolean},autofocus:{type:Boolean},autocomplete:{},placeholder:{},lazy:{type:Boolean,default:!0},maxlength:{},loading:{type:Boolean},bordered:{type:Boolean,default:!0},showCount:{type:[Boolean,Object]},htmlSize:{},onPressEnter:{},onMouseUp:{},onRawInput:{},"onUpdate:value":{},valueModifiers:{},status:{},defaultValue:{},inputElement:{},triggerFocus:{},handleReset:{},addonBefore:{},addonAfter:{},prefix:{},suffix:{},clearIcon:{},allowClear:{type:Boolean,default:!0},beforeInput:{}},emits:["update:value"],setup(r,{expose:p,emit:i}){const s=e.useSlots(),o=r,c=i,{value:d,updateValue:f}=S.useControllableValue(o,c),m=q.useDefaultPlaceholder("Text",o),v=e.computed(()=>R.omit(o,["mode","emptyText","value","onUpdate:value","beforeInput"])),y=()=>{const t=d.value||o.emptyText,n=e.createVNode("span",null,[o.prefix||s.prefix?.(),t,o.suffix||s.suffix?.()]);return o.customReadMode?.(t,n)??n},u=e.shallowRef(),h=t=>{u.value?.focus(t)},x=()=>{u.value?.blur()},B=(t,n,l)=>{u.value?.setSelectionRange(t,n,l)},b=()=>{u.value?.select()};function g(t){const n=t.target.value||"",l=o.beforeInput?o.beforeInput?.(n):n,a=u.value?.$el?.querySelector("input");a&&(a.value=l),f(l)}return p({focus:h,blur:x,setSelectionRange:B,select:b,input:e.computed(()=>u.value?.input)}),(t,n)=>r.mode==="edit"?(e.openBlock(),e.createBlock(e.unref(C.Input),e.mergeProps({key:0},v.value,{ref_key:"inputRef",ref:u,placeholder:e.unref(m),value:e.unref(d),onInput:g}),e.createSlots({_:2},[e.renderList(t.$slots,(l,a)=>({name:a,fn:e.withCtx(I=>[e.renderSlot(t.$slots,a,e.normalizeProps(e.guardReactiveProps(I||{})))])}))]),1040,["placeholder","value"])):(e.openBlock(),e.createBlock(e.unref(P.default),{key:1,node:y()},null,8,["node"]))}});exports.default=k;
