acdr-ui/dist/build/mp-weixin/node-modules/wot-design-uni/components/wd-checkbox/wd-checkbox.js

2 lines
3.0 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";var e=Object.defineProperty,o=Object.defineProperties,l=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,u=(o,l,a)=>l in o?e(o,l,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[l]=a;const c=require("../../../../common/vendor.js");if(!Array){c.resolveComponent("wd-icon")()}Math;const r=c.defineComponent((p=((e,o)=>{for(var l in o||(o={}))t.call(o,l)&&u(e,l,o[l]);if(a)for(var l of a(o))s.call(o,l)&&u(e,l,o[l]);return e})({},{name:"wd-checkbox",options:{addGlobalClass:!0,virtualHost:!0,styleIsolation:"shared"}}),n={props:c.checkboxProps,emits:["change","update:modelValue"],setup(e,{expose:o,emit:l}){const a=e,t=l;o({toggle:f});const{parent:s,index:u}=c.useParent(c.CHECKBOX_GROUP_KEY),r=c.computed((()=>s?s.props.modelValue.indexOf(a.modelValue)>-1:a.modelValue===a.trueValue)),p=c.computed((()=>0===u.value)),n=c.computed((()=>{const e=c.isDef(s)?s.children:[];return u.value===e.length-1})),{proxy:d}=c.getCurrentInstance();c.watch((()=>a.modelValue),(()=>{s&&s&&s.children&&s.children.forEach((e=>{e.$.uid!==d.$.uid&&(e.modelValue,a.modelValue)}))})),c.watch((()=>a.shape),(e=>{["circle","square","button"].indexOf(e)}));const i=c.computed((()=>!a.shape&&s&&s.props.shape?s.props.shape:a.shape)),m=c.computed((()=>!a.checkedColor&&s&&s.props.checkedColor?s.props.checkedColor:a.checkedColor)),h=c.computed((()=>{let e=a.disabled;return s&&(s.props.max&&s.props.modelValue.length>=s.props.max&&!r.value||s.props.min&&s.props.modelValue.length<=s.props.min&&r.value||!0===a.disabled||s.props.disabled&&null===a.disabled)&&(e=!0),e})),v=c.computed((()=>!(!s||!s.props.inline)&&s.props.inline)),b=c.computed((()=>!(!s||!s.props.cell)&&s.props.cell)),x=c.computed((()=>!a.size&&s&&s.props.size?s.props.size:a.size));function f(){if(!h.value)if(s)t("change",{value:!r.value}),s.changeSelectState(a.modelValue);else{const e=a.modelValue===a.trueValue?a.falseValue:a.trueValue;t("update:modelValue",e),t("change",{value:e})}}return c.onBeforeMount((()=>{a.modelValue})),(e,o)=>c.e({a:"button"!==i.value},"button"!==i.value?{b:c.p({"custom-class":"wd-checkbox__check",name:"check-bold",size:"14px"}),c:c.n(`wd-checkbox__shape ${"square"===i.value?"is-square":""} ${e.customShapeClass}`),d:c.s(r.value&&!h.value&&m.value?"color :"+m.value:"")}:{},{e:"button"===i.value&&r.value},"button"===i.value&&r.value?{f:c.p({"custom-class":"wd-checkbox__btn-check",name:"check-bold",size:"14px"})}:{},{g:c.s(e.maxWidth?"max-width:"+e.maxWidth:""),h:c.n(`wd-checkbox__label ${e.customLabelClass}`),i:c.s(r.value&&"button"===i.value&&!h.value&&m.value?"color:"+m.value:""),j:c.n(`wd-checkbox ${b.value?"is-cell-box":""} ${"button"===i.value?"is-button-box":""} ${r.value?"is-checked":""} ${p.value?"is-first-child":""} ${n.value?"is-last-child":""} ${v.value?"is-inline":""} ${"button"===i.value?"is-button":""} ${h.value?"is-disabled":""} ${x.value?"is-"+x.value:""} ${e.customClass}`),k:c.s(e.customStyle),l:c.o(f)})}},o(p,l(n))));var p,n;const d=c._export_sfc(r,[["__scopeId","data-v-273e3091"]]);wx.createComponent(d);