mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +08:00
2 lines
3.8 KiB
JavaScript
2 lines
3.8 KiB
JavaScript
var e=Object.defineProperty,l=Object.defineProperties,a=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,u=(l,a,s)=>a in l?e(l,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):l[a]=s,r=(e,l)=>{for(var a in l||(l={}))t.call(l,a)&&u(e,a,l[a]);if(s)for(var a of s(l))o.call(l,a)&&u(e,a,l[a]);return e},c=(e,s)=>l(e,a(s));import{d as n,c as d,B as i,J as p,C as b,ar as m,a7 as h,b as v,g as f,w as y,z as x,h as g,i as k,E as V,q as $,D as _}from"./index-ChV97F5w.js";import{b as S,c as w,m as C,a as O,w as j,_ as q}from"./base64.D3gEw_Hf.js";import{e as z}from"./page-wraper.D9WpzC1k.js";const B=Symbol("wd-checkbox-group"),P=c(r({},S),{modelValue:{type:Array,default:()=>[]},cell:w(!1),shape:O("circle"),checkedColor:String,disabled:w(!1),min:C(0),max:C(0),inline:w(!1),size:String}),E=c(r({},S),{customLabelClass:O(""),customShapeClass:O(""),modelValue:{type:[String,Number,Boolean],required:!0,default:!1},shape:{type:String},checkedColor:String,disabled:{type:[Boolean,null],default:null},trueValue:{type:[String,Number,Boolean],default:!0},falseValue:{type:[String,Number,Boolean],default:!1},size:String,maxWidth:String}),I=q(n(c(r({},{name:"wd-checkbox",options:{addGlobalClass:!0,virtualHost:!0,styleIsolation:"shared"}}),{props:E,emits:["change","update:modelValue"],setup(e,{expose:l,emit:a}){const s=e,t=a;l({toggle:I});const{parent:o,index:u}=z(B),r=d((()=>o?o.props.modelValue.indexOf(s.modelValue)>-1:s.modelValue===s.trueValue)),c=d((()=>0===u.value)),n=d((()=>{const e=i(o)?o.children:[];return u.value===e.length-1})),{proxy:S}=p();b((()=>s.modelValue),(()=>{o&&o&&o.children&&o.children.forEach((e=>{e.$.uid!==S.$.uid&&e.modelValue===s.modelValue&&console.error(`The checkbox's bound value: ${s.modelValue} has been used`)}))})),b((()=>s.shape),(e=>{const l=["circle","square","button"];i(e)&&-1===l.indexOf(e)&&console.error(`shape must be one of ${l.toString()}`)}));const w=d((()=>s.shape||m(o,"props.shape")||"circle")),C=d((()=>s.checkedColor||m(o,"props.checkedColor"))),O=d((()=>{if(!o)return s.disabled;const{max:e,min:l,modelValue:a,disabled:t}=o.props;return!!(e&&a.length>=e&&!r.value||l&&a.length<=l&&r.value||!0===s.disabled||t&&null===s.disabled)||s.disabled})),q=d((()=>m(o,"props.inline")||!1)),P=d((()=>m(o,"props.cell")||!1)),E=d((()=>s.size||m(o,"props.size")));function I(){if(!O.value)if(o)t("change",{value:!r.value}),o.changeSelectState(s.modelValue);else{const e=s.modelValue===s.trueValue?s.falseValue:s.trueValue;t("update:modelValue",e),t("change",{value:e})}}return h((()=>{null===s.modelValue&&console.error("checkbox's value must be set")})),(e,l)=>{const a=k;return f(),v(a,{class:$(`wd-checkbox ${P.value?"is-cell-box":""} ${"button"===w.value?"is-button-box":""} ${r.value?"is-checked":""} ${c.value?"is-first-child":""} ${n.value?"is-last-child":""} ${q.value?"is-inline":""} ${"button"===w.value?"is-button":""} ${O.value?"is-disabled":""} ${E.value?"is-"+E.value:""} ${e.customClass}`),style:V(e.customStyle),onClick:I},{default:y((()=>["button"!==w.value?(f(),v(a,{key:0,class:$(`wd-checkbox__shape ${"square"===w.value?"is-square":""} ${e.customShapeClass}`),style:V(r.value&&!O.value&&C.value?"color :"+C.value:"")},{default:y((()=>[g(j,{"custom-class":"wd-checkbox__check",name:"check-bold"})])),_:1},8,["class","style"])):x("",!0),g(a,{class:$(`wd-checkbox__label ${e.customLabelClass}`),style:V(r.value&&"button"===w.value&&!O.value&&C.value?"color:"+C.value:"")},{default:y((()=>["button"===w.value&&r.value?(f(),v(j,{key:0,"custom-class":"wd-checkbox__btn-check",name:"check-bold"})):x("",!0),g(a,{class:"wd-checkbox__txt",style:V(e.maxWidth?"max-width:"+e.maxWidth:"")},{default:y((()=>[_(e.$slots,"default",{},void 0,!0)])),_:3},8,["style"])])),_:3},8,["class","style"])])),_:3},8,["class","style"])}}})),[["__scopeId","data-v-ca91cda4"]]);export{B as C,I as _,P as c};
|