"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),C=require("@aplus-frontend/antdv"),E=require("lodash-unified");require("../../ap-field/index.js");const L=require("../../ap-field/hooks/use-default-placeholder.js");require("../../config-provider/index.js");require("../../hooks/index.js");const x=require("../../utils/index.js");require("./popover-input/index.vue.js");const z=require("./style/index.js"),M=require("./utils.js"),T=require("../../hooks/useControllableValue.js"),$=require("../../config-provider/hooks/use-locale.js"),D=require("../../config-provider/hooks/use-namespace.js"),H=require("../../utils/is.js"),K=require("../../ap-field/select/index.vue.js"),G=require("../../ap-field/text/index.js"),Y=require("./popover-input/index.vue2.js"),d="GROUP_SEARCH_ALL",J=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:{},onComplete:{},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(a,{emit:B}){const n=a,b=L.useDefaultPlaceholder("Text",n),q=B,{value:o,updateValue:r}=T.useControllableValue(n,q),p=e.ref(),f=e.ref(),m=e.ref(),{t:A}=$.useLocale(),{b:V}=D.useNamespace("batch-input-group"),v=z.default("batch-input-group"),s=C.Form.useInjectFormItemContext(),I=e.computed(()=>n.options?n.options.length>1&&n.hasAll?[{value:d,label:A("ap.common.all")},...n.options]:n.options:[]),_=e.computed(()=>n.options?n.options.map(t=>t.value):[]),k=e.computed(()=>e.unref(o)?.value?.length?e.unref(o).value.join(","):""),S=e.computed(()=>e.unref(o)?.value?.length?e.unref(o).value.join(`
`):""),F=e.computed(()=>{const t=e.unref(o)?.key;if(t?.length)return t.length===1||!n.hasAll?t[0]:d}),P=e.computed(()=>{const t=e.unref(o)?.key;return!t||t?.length<=1||n.hasAll===!1?e.unref(b):(n.options||[]).filter(u=>t.includes(u.value)).map(u=>u.label).join("/")});function U(t){const l=e.unref(o)||{},u=t===d?e.unref(_):H.isDef(t)?[t]:[];r({...l,key:u}),s.onFieldChange()}function w(t){const l=e.unref(o)||{},u=t.target.value||"";let c=M.splitValue(u,",",",",n.maxNum);if(u!==c){const g=f.value?.$el?.querySelector("input");g&&(g.value=c)}let i=c.split(",");i.length===1&&i[0]===""&&(i=[]),r({...l,value:i}),s.onFieldChange()}function O(t){const l=e.unref(o)||{};let u=t.split(/,|\n/);r({...l,value:u}),s.onFieldChange()}function h(){const t=e.unref(o)||{},l=t.value?.filter(Boolean);r({...t,value:l}),s.onFieldChange()}function N(){h(),n.onComplete?.(o.value)}function R(t){x.runEventHandler(n.onFocus,t)}function y(t){x.runEventHandler(n.onBlur,t),!m.value?.getOpen()&&n.onComplete?.(o.value)}function j(t){h(),y(t)}return(t,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:p,class:e.normalizeClass([e.unref(V)(),e.unref(v)]),onFocus:R,onBlur:y},[e.createVNode(e.unref(C.Space).Compact,{block:""},{default:e.withCtx(()=>[a.options?.length?(e.openBlock(),e.createBlock(e.unref(K.default),{key:0,style:e.normalizeStyle(a.style),options:I.value,value:F.value,"allow-clear":!1,"dropdown-match-select-width":!1,disabled:a.disabled,"get-popup-container":()=>p.value,"onUpdate:value":U},null,8,["style","options","value","disabled","get-popup-container"])):e.createCommentVNode("",!0),e.createVNode(e.unref(G.ApFieldText),e.mergeProps(e.unref(E.omit)(n,["style","value","onUpdate:value","inputStyle","hasAll","options","onBlur"]),{ref_key:"inputRef",ref:f,style:a.inputStyle,value:k.value,placeholder:P.value,onInput:w,onBlur:j}),{suffix:e.withCtx(()=>[e.createVNode(Y.default,{ref_key:"popoverInput",ref:m,parent:p.value,value:S.value,disabled:a.disabled,placement:n.popoverPlacement,"max-num":a.maxNum,class:e.normalizeClass(e.unref(v)),"get-popup-container":a.getPopupContainer,"onUpdate:value":O,onClose:N},null,8,["parent","value","disabled","placement","max-num","class","get-popup-container"])]),_:1},16,["style","value","placeholder"])]),_:1})],34))}});exports.default=J;
