Checker.40bdbb46.js 1.9 KB

1
  1. import{O as C,z as x,d as y,N as z,aB as B,v as _,R as D,y as r,c as t,a5 as G,U as v}from"./index.5f7ffb46.js";const R={name:C,disabled:Boolean,iconSize:x,modelValue:C,checkedColor:String,labelPosition:String,labelDisabled:Boolean};var w=y({props:z({},R,{bem:B(Function),role:String,shape:String,parent:Object,checked:Boolean,bindGroup:_,indeterminate:{type:Boolean,default:null}}),emits:["click","toggle"],setup(e,{emit:k,slots:d}){const h=D(),o=n=>{if(e.parent&&e.bindGroup)return e.parent.props[n]},a=r(()=>{if(e.parent&&e.bindGroup){const n=o("disabled")||e.disabled;if(e.role==="checkbox"){const c=o("modelValue").length,l=o("max"),i=l&&c>=+l;return n||i&&!e.checked}return n}return e.disabled}),P=r(()=>o("direction")),u=r(()=>{const n=e.checkedColor||o("checkedColor");if(n&&e.checked&&!a.value)return{borderColor:n,backgroundColor:n}}),s=r(()=>e.shape||o("shape")||"round"),S=n=>{const{target:c}=n,l=h.value,i=l===c||(l==null?void 0:l.contains(c));!a.value&&(i||!e.labelDisabled)&&k("toggle"),k("click",n)},m=()=>{var n,c;const{bem:l,checked:i,indeterminate:g}=e,b=e.iconSize||o("iconSize");return t("div",{ref:h,class:l("icon",[s.value,{disabled:a.value,checked:i,indeterminate:g}]),style:s.value!=="dot"?{fontSize:v(b)}:{width:v(b),height:v(b),borderColor:(n=u.value)==null?void 0:n.borderColor}},[d.icon?d.icon({checked:i,disabled:a.value}):s.value!=="dot"?t(G,{name:g?"minus":"success",style:u.value},null):t("div",{class:l("icon--dot__icon"),style:{backgroundColor:(c=u.value)==null?void 0:c.backgroundColor}},null)])},f=()=>{if(d.default)return t("span",{class:e.bem("label",[e.labelPosition,{disabled:a.value}])},[d.default()])};return()=>{const n=e.labelPosition==="left"?[f(),m()]:[m(),f()];return t("div",{role:e.role,class:e.bem([{disabled:a.value,"label-disabled":e.labelDisabled},P.value]),tabindex:a.value?void 0:0,"aria-checked":e.checked,onClick:S},[n])}}});export{R as c,w as s};