"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),h=require("@aplus-frontend/antdv"),N=require("lodash-unified");require("../../ap-field/index.js");const R=require("../../ap-field/hooks/use-default-placeholder.js");require("../../config-provider/index.js");require("../../hooks/index.js");require("../../utils/index.js");require("./popover-input/index.vue.js");const j=require("./style/index.js"),L=require("./utils.js"),O=require("../../hooks/useControllableValue.js"),z=require("../../config-provider/hooks/use-locale.js"),E=require("../../config-provider/hooks/use-namespace.js"),M=require("../../utils/is.js"),T=require("../../ap-field/select/index.vue.js"),_=require("../../ap-field/text/index.js"),D=require("./popover-input/index.vue2.js"),d="GROUP_SEARCH_ALL",K=e.defineComponent({name:"BatchInputGroup",__name:"index",props:{style:{type:[Boolean,null,String,Object,Array]},inputStyle:{type:[Boolean,null,String,Object,Array]},options:{},hasAll:{type:Boolean,default:!0},value:{},"onUpdate:value":{},popoverPlacement:{default:"left"},maxNum:{default:200},getPopupContainer:{},mode:{default:"edit"},class:{},emptyText:{default:"--"},customReadMode:{},variant:{},size:{},name:{},type:{default:"text"},onCompositionend:{},onCompositionstart:{},onFocus:{},onBlur:{},onChange:{},onInput:{},onKeydown:{},onKeyup:{},onMousedown:{},focused:{type:Boolean},hidden:{type:Boolean},disabled:{type:Boolean},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:{},valueModifiers:{},status:{},defaultValue:{},inputElement:{},triggerFocus:{},handleReset:{},addonBefore:{},addonAfter:{},prefix:{},suffix:{},clearIcon:{},allowClear:{type:Boolean,default:!0},beforeInput:{}},emits:["update:value"],setup(u,{emit:g}){const n=u,x=R.useDefaultPlaceholder("Text",n),B=g,{value:a,updateValue:r}=O.useControllableValue(n,B),c=e.ref(),f=e.ref(),{t:C}=z.useLocale(),{b}=E.useNamespace("batch-input-group"),m=j.default("batch-input-group"),s=h.Form.useInjectFormItemContext(),q=e.computed(()=>n.options?n.options.length>1&&n.hasAll?[{value:d,label:C("ap.common.all")},...n.options]:n.options:[]),A=e.computed(()=>n.options?n.options.map(t=>t.value):[]),V=e.computed(()=>e.unref(a)?.value?.length?e.unref(a).value.join(","):""),I=e.computed(()=>e.unref(a)?.value?.length?e.unref(a).value.join(`
`):""),S=e.computed(()=>{const t=e.unref(a)?.key;if(t?.length)return t.length===1||!n.hasAll?t[0]:d}),k=e.computed(()=>{const t=e.unref(a)?.key;return!t||t?.length<=1||n.hasAll===!1?e.unref(x):(n.options||[]).filter(o=>t.includes(o.value)).map(o=>o.label).join("/")});function F(t){const l=e.unref(a)||{},o=t===d?e.unref(A):M.isDef(t)?[t]:[];r({...l,key:o}),s.onFieldChange()}function P(t){const l=e.unref(a)||{},o=t.target.value||"";let p=L.splitValue(o,",",",",n.maxNum);if(o!==p){const y=f.value?.$el?.querySelector("input");y&&(y.value=p)}let i=p.split(",");i.length===1&&i[0]===""&&(i=[]),r({...l,value:i}),s.onFieldChange()}function U(t){const l=e.unref(a)||{};let o=t.split(/,|\n/);r({...l,value:o}),s.onFieldChange()}function v(){const t=e.unref(a)||{},l=t.value?.filter(Boolean);r({...t,value:l}),s.onFieldChange()}function w(t){v(),n.onBlur?.(t)}return(t,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:c,class:e.normalizeClass([e.unref(b)(),e.unref(m)]),onFocus:l[0]||(l[0]=(...o)=>u.onFocus&&u.onFocus(...o)),onBlur:l[1]||(l[1]=(...o)=>u.onBlur&&u.onBlur(...o))},[e.createVNode(e.unref(h.Space).Compact,{block:""},{default:e.withCtx(()=>[u.options?.length?(e.openBlock(),e.createBlock(e.unref(T.default),{key:0,style:e.normalizeStyle(u.style),options:q.value,value:S.value,"allow-clear":!1,"dropdown-match-select-width":!1,disabled:u.disabled,"get-popup-container":()=>c.value,"onUpdate:value":F},null,8,["style","options","value","disabled","get-popup-container"])):e.createCommentVNode("",!0),e.createVNode(e.unref(_.ApFieldText),e.mergeProps(e.unref(N.omit)(n,["style","value","onUpdate:value","inputStyle","hasAll","options","onBlur"]),{ref_key:"inputRef",ref:f,style:u.inputStyle,value:V.value,placeholder:k.value,onInput:P,onBlur:w}),{suffix:e.withCtx(()=>[e.createVNode(D.default,{_parent:c.value,value:I.value,disabled:u.disabled,placement:n.popoverPlacement,"max-num":u.maxNum,class:e.normalizeClass(e.unref(m)),"get-popup-container":u.getPopupContainer,"onUpdate:value":U,onClose:v},null,8,["_parent","value","disabled","placement","max-num","class","get-popup-container"])]),_:1},16,["style","value","placeholder"])]),_:1})],34))}});exports.default=K;
