UNPKG

2.56 kBJavaScriptView Raw
1import{r as t,c as e,h as i,H as o,g as s}from"./p-059912fd.js";let n=class{constructor(i){t(this,i),this.onChange=e(this,"checkboxchange",7),this.value="",this.checked=!1,this.disabled=!1,this.nativeProps={},this.isWillLoadCalled=!1,this.handleChange=t=>{t.stopPropagation(),this.onChange.emit({value:this.value})}}watchId(t){this.isWillLoadCalled&&t&&this.inputEl.setAttribute("id",t)}componentWillLoad(){this.isWillLoadCalled=!0}componentDidRender(){this.id&&this.el.removeAttribute("id")}render(){const{checked:t,name:e,color:s,value:n,disabled:r,nativeProps:c}=this;return i(o,{className:"weui-cells_checkbox"},i("input",Object.assign({ref:t=>{t&&(this.inputEl=t,this.id&&t.setAttribute("id",this.id))},type:"checkbox",value:n,name:e,class:"taro-checkbox_checked",style:{color:s},checked:t,disabled:r,onChange:this.handleChange},c)),i("slot",null))}get el(){return s(this)}static get watchers(){return{id:["watchId"]}}};n.style='.taro-checkbox{display:inline-block;position:relative}.taro-checkbox_checked{display:inline-block;position:relative;top:5px;border:1px solid #d1d1d1;border-radius:3px;width:23px;height:23px;min-height:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:0;background-color:#fff;vertical-align:0;font-size:23px;color:#1aad19}.taro-checkbox_checked:checked::before{display:inline-block;position:absolute;left:50%;top:50%;vertical-align:middle;text-decoration:inherit;text-align:center;text-transform:none;font-family:weui;font-style:normal;font-weight:normal;font-variant:normal;font-size:inherit;color:inherit;content:"\\ea08";-webkit-transform:translate(-50%, -48%) scale(0.73);transform:translate(-50%, -48%) scale(0.73);speak:none}';let r=class{constructor(i){t(this,i),this.onChange=e(this,"change",7),this.uniqueName=Date.now().toString(36)}function(t){if(t.stopPropagation(),"TARO-CHECKBOX-CORE"!==t.target.tagName)return;const e=this.el.querySelectorAll("taro-checkbox-core");this.value=this.getValues(e),this.onChange.emit({value:this.value})}componentDidLoad(){this.el.querySelectorAll("taro-checkbox-core").forEach((t=>{t.setAttribute("name",this.name||this.uniqueName)})),Object.defineProperty(this.el,"value",{get:()=>{if(!this.value){const t=this.el.querySelectorAll("taro-checkbox-core");this.value=this.getValues(t)}return this.value},configurable:!0})}getValues(t){return Array.from(t).filter((t=>{const e=t.querySelector("input");return null==e?void 0:e.checked})).map((t=>t.value))}render(){return i(o,null)}get el(){return s(this)}};export{n as taro_checkbox_core,r as taro_checkbox_group_core}
\No newline at end of file