UNPKG

@tarojs/components

Version:
1 lines 2.33 kB
import{r as t,c as i,h as e,g as o}from"./p-d0cabaaa.js";const c=class{constructor(e){t(this,e),this.onChange=i(this,"change",7),this.switchChange=t=>{t.stopPropagation();const i=t.target.checked;this.checked=i,this.onChange.emit({value:i})},this.type="switch",this.checked=!1,this.color="#04BE02",this.name=void 0,this.disabled=!1,this.nativeProps={},this.isWillLoadCalled=!1}function(t){this.isWillLoadCalled&&this.inputRef.checked!==t&&(this.inputRef.checked=t)}componentWillLoad(){this.isWillLoadCalled=!0}componentDidLoad(){Object.defineProperty(this.el,"value",{get:()=>this.checked,configurable:!0})}render(){const{type:t,color:i,checked:o,name:c,disabled:s,nativeProps:r}=this;return e("input",Object.assign({ref:t=>{this.inputRef=t},type:"checkbox",class:`weui-${t}`,style:o?{borderColor:i||"04BE02",backgroundColor:i||"04BE02"}:{},checked:o,name:c,disabled:s,onChange:this.switchChange},r))}get el(){return o(this)}static get watchers(){return{checked:["function"]}}};c.style='.weui-cell_switch{padding-top:6.5px;padding-bottom:6.5px}.weui-switch{appearance:none}.weui-switch,.weui-switch-cp__box{box-sizing:border-box;background-color:#dfdfdf;border:1px solid #dfdfdf;border-radius:16px;outline:0;width:52px;height:32px;transition:background-color .1s,border .1s;position:relative}.weui-switch:before,.weui-switch-cp__box:before{content:" ";background-color:#fdfdfd;border-radius:15px;width:50px;height:30px;transition:transform .35s cubic-bezier(.45,1,.4,1);position:absolute;top:0;left:0}.weui-switch:after,.weui-switch-cp__box:after{content:" ";background-color:#fff;border-radius:15px;width:30px;height:30px;transition:transform .35s cubic-bezier(.4,.4,.25,1.35);position:absolute;top:0;left:0;box-shadow:0 1px 3px rgba(0,0,0,.4)}.weui-switch:checked,.weui-switch-cp__input:checked~.weui-switch-cp__box{background-color:#04be02;border-color:#04be02}.weui-switch:checked:before,.weui-switch-cp__input:checked~.weui-switch-cp__box:before{transform:scale(0)}.weui-switch:checked:after,.weui-switch-cp__input:checked~.weui-switch-cp__box:after{transform:translate(20px)}.weui-switch-cp__input{position:absolute;left:-9999px}.weui-switch-cp__box{display:block}taro-switch-core{width:52px;height:32px;display:inline-block}taro-switch-core .weui-switch{width:100%;height:100%;display:block}';export{c as taro_switch_core}