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