UNPKG

@tarojs/components

Version:
1 lines 7.03 kB
import{r as e,c as i,h as l,H as r,g as o}from"./p-d0cabaaa.js";const t=class{constructor(l){e(this,l),this.onChange=i(this,"checkboxchange",7),this.handleChange=e=>{e.stopPropagation(),this.onChange.emit({value:this.value})},this.name=void 0,this.value="",this.color=void 0,this.id=void 0,this.checked=!1,this.disabled=!1,this.nativeProps={},this.isWillLoadCalled=!1}watchId(e){this.isWillLoadCalled&&e&&this.inputEl.setAttribute("id",e)}componentWillLoad(){this.isWillLoadCalled=!0}componentDidRender(){this.id&&this.el.removeAttribute("id")}render(){const{checked:e,name:i,color:o,value:t,disabled:c,nativeProps:a}=this;return l(r,{className:"weui-cells_checkbox"},l("input",Object.assign({ref:e=>{e&&(this.inputEl=e,this.id&&e.setAttribute("id",this.id))},type:"checkbox",value:t,name:i,class:"taro-checkbox_checked",style:{color:o},checked:e,disabled:c,onChange:this.handleChange},a)),l("slot",null))}get el(){return o(this)}static get watchers(){return{id:["watchId"]}}};t.style='page,body{--weui-cellMarginLR:16px;--weui-cellPaddingLR:16px}.weui-cells__group{border:0}.weui-cells__group:first-child{margin-top:0}.weui-cells__group_form{margin-top:24px}.weui-cells__group_form .weui-cells{margin-left:var(--weui-cellMarginLR);margin-right:var(--weui-cellMarginLR)}.weui-cells__group_form .weui-cells:before,.weui-cells__group_form .weui-cells:after{left:var(--weui-cellPaddingLR);right:var(--weui-cellPaddingLR)}.weui-cells__group_form .weui-cell{padding:16px var(--weui-cellPaddingLR)}.weui-cells__group_form .weui-cell:before{left:var(--weui-cellPaddingLR);right:var(--weui-cellPaddingLR)}.weui-cells__group_form .weui-cell:not(.weui-cell_vertical) .weui-cell__hd{padding-right:16px}.weui-cells__group_form .weui-cell:not(.weui-cell_vertical) .weui-cell__ft{padding-left:16px}.weui-cells__group_form .weui-cells__title{margin-top:24px;margin-bottom:8px;padding:0 32px}.weui-cells__group_form:first-child .weui-cells__title{margin-top:0}.weui-cells__group_form .weui-cells__tips{padding:0 calc(var(--weui-cellMarginLR) + var(--weui-cellPaddingLR));color:var(--weui-FG-2);margin-top:8px}.weui-cells__group_form .weui-cells__tips a{font-weight:700}.weui-cells__group_form .weui-cells__tips_warn{color:var(--weui-RED)}.weui-cells__group_form .weui-label{max-width:5em;margin-right:8px}.weui-cells__group_form .weui-cell_access:active:after,.weui-cells__group_form .weui-cell_active:active:after{border-radius:8px}.weui-cells__group_form .weui-cell_warn input{color:#e64340}.weui-cells__group_form .weui-icon-warn,.weui-cells__group_form .weui-cell_switch:active:after,.weui-cells__group_form .weui-cell_vcode:active:after,.weui-cells__group_form .weui-cell_readonly:active:after,.weui-cells__group_form .weui-cell_disabled:active:after{display:none}.weui-cells__group_form input,.weui-cells__group_form textarea,.weui-cells__group_form label[for]{-webkit-tap-highlight-color:transparent}.weui-cells__group_form .weui-cell_wrap{-ms-flex-align:initial;align-items:initial;padding-top:8px;padding-bottom:8px}.weui-cells__group_form .weui-cell_wrap .weui-cell__hd{padding-right:0}.weui-cells__group_form .weui-cell_wrap .weui-label{margin-top:8px}.weui-cells__group_form .weui-cell_wrap .weui-cell__bd{-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex}.weui-cells__group_form .weui-cell__control{margin:8px 0 8px 16px}.weui-cells__group_form .weui-cell__control_flex{-ms-flex:1;flex:1;min-width:30vw}.weui-cells__group_form .weui-vcode-btn{color:#000;background-color:#f8f8f8;border-radius:6px;width:auto;height:auto;padding:0 12px;font-size:16px;line-height:2}.weui-cells__group_form .weui-vcode-btn:before{display:none}.weui-cells__group_form .weui-cell_vcode.weui-cell_wrap{padding-top:4px;padding-bottom:4px}.weui-cells__group_form .weui-cell_vcode.weui-cell_wrap .weui-label{margin-top:12px}.weui-cells__group_form .weui-cell_vcode.weui-cell_wrap .weui-input{min-height:1.88235em;font-size:17px}.weui-cells__group_form .weui-cells_checkbox .weui-check__label:before{left:calc(40px + var(--weui-cellPaddingLR))}.weui-cells__group_form .weui-cell_select{padding:0}.weui-cells__group_form .weui-cell_select-before .weui-cell__hd{padding-right:0}.weui-cells__group_form .weui-cell_switch{padding:12px 16px}.weui-cells__group_form-primary{margin-top:32px}.weui-cells__group_form-primary .weui-cells{background:var(--weui-BG-1);border-radius:8px;overflow:hidden}.weui-cells__group_form-primary .weui-cells:before,.weui-cells__group_form-primary .weui-cells:after{display:none}.weui-cells__group_form-primary .weui-cell_access:active:after,.weui-cells__group_form-primary .weui-cell_active:active:after{border-radius:0}.taro-checkbox{display:inline-block;position:relative}.taro-checkbox_checked{-webkit-appearance:none;-moz-appearance:none;appearance:none;vertical-align:0;color:#1aad19;background-color:#fff;border:1px solid #d1d1d1;border-radius:3px;outline:0;width:23px;height:23px;min-height:0;font-size:23px;display:inline-block;position:relative;top:5px}.taro-checkbox_checked:checked:before{vertical-align:middle;text-decoration:inherit;text-align:center;text-transform:none;font-variant:normal;font-family:weui;font-style:normal;font-weight:400;font-size:inherit;color:inherit;content:"";speak:none;display:inline-block;position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-48%)scale(.73);transform:translate(-50%,-48%)scale(.73)}';var c,a=function(e,i,l,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof i?e!==i||!o:!i.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,l):o?o.value=l:i.set(e,l),l},u=function(e,i,l,r){if("a"===l&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof i?e!==i||!r:!i.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===l?r:"a"===l?r.call(e):r?r.value:i.get(e)};const s=class{constructor(l){e(this,l),this.onChange=i(this,"change",7),this.uniqueName=Date.now().toString(36),c.set(this,void 0),this.name=void 0}function(e){if(e.stopPropagation(),"TARO-CHECKBOX-CORE"!==e.target.tagName)return;const i=this.el.querySelectorAll("taro-checkbox-core");a(this,c,this.getValues(i),"f"),this.onChange.emit({value:u(this,c,"f")})}componentDidLoad(){this.el.querySelectorAll("taro-checkbox-core").forEach((e=>{e.setAttribute("name",this.name||this.uniqueName)})),Object.defineProperty(this.el,"value",{get:()=>{if(!u(this,c,"f")){const e=this.el.querySelectorAll("taro-checkbox-core");a(this,c,this.getValues(e),"f")}return u(this,c,"f")},configurable:!0})}getValues(e){return Array.from(e).filter((e=>{const i=e.querySelector("input");return null==i?void 0:i.checked})).map((e=>e.value))}render(){return l(r,null)}get el(){return o(this)}};c=new WeakMap;export{t as taro_checkbox_core,s as taro_checkbox_group_core}