"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("@aplus-frontend/antdv"),u=require("lodash-unified");require("../../config-provider/index.js");require("../../hooks/index.js");const C=require("../hooks/use-options.js"),S=require("../style/index.js"),p=require("./helper.js"),V=require("../../config-provider/hooks/use-namespace.js"),T=require("../../hooks/useControllableValue.js"),F=e.defineComponent({name:"ApFieldCheckbox",inheritAttrs:!1,__name:"index",props:{mode:{default:"edit"},class:{},style:{},emptyText:{default:"--"},customReadMode:{},defaultValue:{},value:{},onChange:{},"onUpdate:value":{},name:{},prefixCls:{},options:{default:()=>[]},disabled:{type:Boolean,default:void 0},id:{},request:{},vertical:{type:Boolean}},emits:["update:value"],setup(o,{expose:f,emit:m}){const v=m,t=o,k=e.computed(()=>u.omit(t,["onUpdate:value","value","request","vertical","emptyText"])),y=e.useSlots(),{options:s,updateOptions:q}=C.default(t),{b:x,m:g}=V.useNamespace("field-checkbox"),B=S.default("field"),r=e.ref(!1);async function i(){if(u.isFunction(t.request))return r.value=!0,t.request().then(l=>q(l)).finally(()=>{r.value=!1})}e.onMounted(()=>{i()});const{value:a,updateValue:h}=T.useControllableValue(t,v,{defaultValue:[]});return f({request:i}),(l,O)=>o.mode==="read"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.unref(u.isNil)(e.unref(a))?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(t.emptyText),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(e.unref(s)?.filter(n=>e.unref(a).indexOf(e.unref(p.getOptionValue)(n))>-1).map(n=>e.unref(p.getOptionLabel)(n)).join("、")||t.emptyText),1)],64))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[r.value?(e.openBlock(),e.createBlock(e.unref(d.Spin),{key:0,size:"small"})):(e.openBlock(),e.createBlock(e.unref(d.CheckboxGroup),e.mergeProps({key:1},k.value,{options:e.unref(s),value:e.unref(a),class:[e.unref(x)(),o.vertical?e.unref(g)("vertical"):null,e.unref(B)],"onUpdate:value":e.unref(h)}),e.createSlots({_:2},[e.renderList(y,(n,c)=>({name:c,fn:e.withCtx(b=>[e.renderSlot(l.$slots,c,e.normalizeProps(e.guardReactiveProps(b||{})))])}))]),1040,["options","value","class","onUpdate:value"]))],64))}});exports.default=F;
