index-039ad22f.js 2.9 KB

1
  1. import{x as C,n as D,t as g,d as v,A as P,ag as O,v as V,i as E,E as k,g as m,I,G as $,j as x,ac as w,w as S,ad as G,q as A,an as p,ae as R,p as j,m as q,D as y}from"./index-e362c2e8.js";const z={name:C,shape:D("round"),disabled:Boolean,iconSize:g,modelValue:C,checkedColor:String,labelPosition:String,labelDisabled:Boolean};var F=v({props:P({},z,{bem:O(Function),role:String,parent:Object,checked:Boolean,bindGroup:V}),emits:["click","toggle"],setup(e,{emit:t,slots:d}){const o=E(),i=a=>{if(e.parent&&e.bindGroup)return e.parent.props[a]},c=k(()=>i("disabled")||e.disabled),u=k(()=>i("direction")),n=k(()=>{const a=e.checkedColor||i("checkedColor");if(a&&e.checked&&!c.value)return{borderColor:a,backgroundColor:a}}),s=a=>{const{target:l}=a,b=o.value,f=b===l||(b==null?void 0:b.contains(l));!c.value&&(f||!e.labelDisabled)&&t("toggle"),t("click",a)},r=()=>{const{bem:a,shape:l,checked:b}=e,f=e.iconSize||i("iconSize");return m("div",{ref:o,class:a("icon",[l,{disabled:c.value,checked:b}]),style:{fontSize:$(f)}},[d.icon?d.icon({checked:b,disabled:c.value}):m(I,{name:"success",style:n.value},null)])},h=()=>{if(d.default)return m("span",{class:e.bem("label",[e.labelPosition,{disabled:c.value}])},[d.default()])};return()=>{const a=e.labelPosition==="left"?[h(),r()]:[r(),h()];return m("div",{role:e.role,class:e.bem([{disabled:c.value,"label-disabled":e.labelDisabled},u.value]),tabindex:c.value?void 0:0,"aria-checked":e.checked,onClick:s},[a])}}});const[_,K]=x("checkbox-group"),N={max:g,disabled:Boolean,iconSize:g,direction:String,modelValue:A(),checkedColor:String},B=Symbol(_);var U=v({name:_,props:N,emits:["change","update:modelValue"],setup(e,{emit:t,slots:d}){const{children:o,linkChildren:i}=w(B),c=n=>t("update:modelValue",n),u=(n={})=>{typeof n=="boolean"&&(n={checked:n});const{checked:s,skipDisabled:r}=n,a=o.filter(l=>l.props.bindGroup?l.props.disabled&&r?l.checked.value:s!=null?s:!l.checked.value:!1).map(l=>l.name);c(a)};return S(()=>e.modelValue,n=>t("change",n)),p({toggleAll:u}),G(()=>e.modelValue),i({props:e,updateValue:c}),()=>{var n;return m("div",{class:K([e.direction])},[(n=d.default)==null?void 0:n.call(d)])}}});const[H,L]=x("checkbox"),T=P({},z,{bindGroup:V});var X=v({name:H,props:T,emits:["change","update:modelValue"],setup(e,{emit:t,slots:d}){const{parent:o}=R(B),i=n=>{const{name:s}=e,{max:r,modelValue:h}=o.props,a=h.slice();if(n)!(r&&a.length>=+r)&&!a.includes(s)&&(a.push(s),e.bindGroup&&o.updateValue(a));else{const l=a.indexOf(s);l!==-1&&(a.splice(l,1),e.bindGroup&&o.updateValue(a))}},c=k(()=>o&&e.bindGroup?o.props.modelValue.indexOf(e.name)!==-1:!!e.modelValue),u=(n=!c.value)=>{o&&e.bindGroup?i(n):t("update:modelValue",n)};return S(()=>e.modelValue,n=>t("change",n)),p({toggle:u,props:e,checked:c}),G(()=>e.modelValue),()=>m(F,q({bem:L,role:"checkbox",parent:o,checked:c.value,onToggle:u},e),j(d,["default","icon"]))}});const J=y(X),M=y(U);export{M as C,J as a,z as c,F as s};