(function(u,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(u=typeof globalThis<"u"?globalThis:u||self,n(u.index={},u.Vue))})(this,function(u,n){"use strict";const b="G",x={modelValue:{type:Boolean,default:null},label:{type:String,default:""},name:{type:String,default:""},color:{type:String,default:void 0},disabled:{type:Boolean,default:!1},beforeChange:{type:Function,default:void 0}},k={...x,modelValue:{type:Array,default:[],required:!0},direction:{type:String,default:"column"}},v=Symbol(`${b}CheckBoxGroup`),N=()=>n.createVNode("svg",{class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"15487",width:"16px",height:"16px"},[n.createVNode("path",{d:"M170.666667 85.333333C123.733333 85.333333 85.333333 123.733333 85.333333 170.666667L85.333333 853.333333C85.333333 900.266667 123.733333 938.666667 170.666667 938.666667L853.333333 938.666667C900.266667 938.666667 938.666667 900.266667 938.666667 853.333333L938.666667 170.666667C938.666667 123.733333 900.266667 85.333333 853.333333 85.333333L170.666667 85.333333zM170.666667 170.666667 853.333333 170.666667 853.333333 853.333333 170.666667 853.333333 170.666667 170.666667zM256 256 256 768 768 768 768 256 256 256z","p-id":"15488"},null)]),B=()=>n.createVNode("svg",{class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"24735",width:"16px",height:"16px"},[n.createVNode("path",{d:"M800.188 92.094H223.813c-72.47 0-131.72 59.25-131.72 131.719v576.375c0 72.468 59.25 131.718 131.72 131.718h576.375c72.468 0 131.718-59.25 131.718-131.718V223.813c0-72.47-59.25-131.72-131.718-131.72z m55.406 655.687c0 59.25-48.469 107.813-107.813 107.813H276.22c-59.25 0-107.813-48.469-107.813-107.813V276.22c0-59.25 48.469-107.813 107.813-107.813H747.78c59.25 0 107.813 48.469 107.813 107.813V747.78z","p-id":"24736"},null)]),M="",y="g";function g(e,o,l){let s=e;return o&&(s+=`__${o}`),l&&(s+=`--${l}`),s}function $(e,o=!1){const l=o?`.${y}-${e}`:`${y}-${e}`;return{b:()=>g(l),e:c=>c?g(l,c):"",m:c=>c?g(l,"",c):"",em:(c,m)=>c&&m?g(l,c,m):""}}const i=n.defineComponent({name:`${b}CheckBox`,props:x,emits:["change","update:modelValue"],setup(e,{emit:o,slots:l}){return()=>{const s=$("check-box"),t=n.inject(v,null),f=n.computed(()=>(t==null?void 0:t.disabled.value)||e.disabled),d=n.computed(()=>(t==null?void 0:t.isItemChecked(e.label))||e.modelValue),c=n.computed(()=>`${s.b()} ${d.value?"active":""} ${f.value?"disabled":""}`),m=n.computed(()=>{const a=(t==null?void 0:t.color.value)||e.color;return a?`fill: ${a}`:""}),h=(a,C)=>{if(f.value)return Promise.resolve(!1);const w=(t==null?void 0:t.beforeChange)||e.beforeChange;if(w){const V=w(a,C);return typeof V=="boolean"?Promise.resolve(V):V}return Promise.resolve(!0)},p=async()=>{const a=!d.value;h(a,e.label).then(C=>{C&&(t==null||t.toggleGroupVal(e.label),o("change",a),o("update:modelValue",a))})};return n.createVNode("label",{class:c.value},[n.createVNode("input",{type:"checkbox",class:s.e("input"),onChange:p,name:e.name,value:e.label,disabled:f.value,checked:d.value},null),n.createVNode("span",{class:s.e("icon"),style:m.value},[d.value?n.createVNode(N,null,null):n.createVNode(B,null,null)]),l.default?l.default():e.label])}}}),P="",r=n.defineComponent({name:`${b}CheckBoxGroup`,props:k,emits:["change","update:modelValue"],setup(e,{emit:o,slots:l}){const s=$("check-box-group"),t=n.toRef(e,"modelValue"),f=h=>{const p=t.value.findIndex(a=>a===h);if(p===-1){const a=[...t.value,h];o("change",a),o("update:modelValue",a);return}t.value.splice(p,1),o("change",t.value),o("update:modelValue",t.value)},d=h=>t.value.includes(h);n.provide(v,{disabled:n.toRef(e,"disabled"),color:n.toRef(e,"color"),beforeChange:e.beforeChange,toggleGroupVal:f,isItemChecked:d});const c={row:"is-row",column:"is-column"},m=n.computed(()=>`${s.b()} ${c[e.direction]}`);return()=>n.createVNode("div",{class:m.value},[l.default&&l.default()])}});i.install=function(e,o){e.component(o||i.name,i)},r.install=function(e,o){e.component(o||r.name,r)};const S={title:"CheckBox 多选框",category:"数据描述",status:"100%",install(e){e.component(i.name,i),e.component(r.name,r)}};u.CheckBox=i,u.CheckBoxGroup=r,u.default=S,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
