@tarojs/components
Version:
Taro 组件库。
1 lines • 3.31 kB
JavaScript
import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-5bd7cbab.js";var indexCss='@charset "UTF-8";.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:"";-webkit-transform:translate(-50%, -48%) scale(0.73);transform:translate(-50%, -48%) scale(0.73);speak:none}';var Checkbox=function(){function e(e){var t=this;registerInstance(this,e);this.onChange=createEvent(this,"checkboxchange",7);this.value="";this.checked=false;this.disabled=false;this.nativeProps={};this.isWillLoadCalled=false;this.handleChange=function(e){e.stopPropagation();t.onChange.emit({value:t.value})}}e.prototype.watchId=function(e){if(!this.isWillLoadCalled)return;if(e)this.inputEl.setAttribute("id",e)};e.prototype.componentWillLoad=function(){this.isWillLoadCalled=true};e.prototype.componentDidRender=function(){this.id&&this.el.removeAttribute("id")};e.prototype.render=function(){var e=this;var t=this,n=t.checked,o=t.name,r=t.color,i=t.value,a=t.disabled,c=t.nativeProps;return h(Host,{className:"weui-cells_checkbox"},h("input",Object.assign({ref:function(t){if(!t)return;e.inputEl=t;if(e.id)t.setAttribute("id",e.id)},type:"checkbox",value:i,name:o,class:"taro-checkbox_checked",style:{color:r},checked:n,disabled:a,onChange:this.handleChange},c)),h("slot",null))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{id:["watchId"]}},enumerable:false,configurable:true});return e}();Checkbox.style=indexCss;var CheckboxGroup=function(){function e(e){registerInstance(this,e);this.onChange=createEvent(this,"change",7);this.uniqueName=Date.now().toString(36)}e.prototype.function=function(e){e.stopPropagation();if(e.target.tagName!=="TARO-CHECKBOX-CORE")return;var t=this.el.querySelectorAll("taro-checkbox-core");this.value=this.getValues(t);this.onChange.emit({value:this.value})};e.prototype.componentDidLoad=function(){var e=this;var t=this.el.querySelectorAll("taro-checkbox-core");t.forEach((function(t){t.setAttribute("name",e.name||e.uniqueName)}));Object.defineProperty(this.el,"value",{get:function(){if(!e.value){var t=e.el.querySelectorAll("taro-checkbox-core");e.value=e.getValues(t)}return e.value},configurable:true})};e.prototype.getValues=function(e){return Array.from(e).filter((function(e){var t=e.querySelector("input");return t===null||t===void 0?void 0:t.checked})).map((function(e){return e.value}))};e.prototype.render=function(){return h(Host,null)};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();export{Checkbox as taro_checkbox_core,CheckboxGroup as taro_checkbox_group_core};