UNPKG

@codeperate/opgl-ui-library

Version:

Opengamela UI Library

1 lines 1.03 kB
import{r as s,h as t,H as e}from"./p-68d67f25.js";const i=class{constructor(t){s(this,t),this.checked=!1}propsChangeHandler(){this.inputProps.checked&&(this.checked=this.inputProps.checked)}componentWillLoad(){this.propsChangeHandler()}changeHandler(s){this.checked=s.target.checked,this.inputProps.onChange&&this.inputProps.onChange(s)}inputElHandler(s){this.inputEl=s,this.inputProps.ref&&this.inputProps.ref(s)}render(){let s="absolute z-10 rounded-full h-7 w-7 border transform transition-all ease-in shadow bg-gray-100 "+(this.checked?"translate-x-full":"");return t(e,{class:this.inputProps.class+" border block shadow rounded-full w-14 h-7 relative transform transition-all ease-in "+(this.checked?"bg-blue-500":""),onClick:s=>{s.target!=this.inputEl&&this.inputEl.click()}},t("input",Object.assign({},this.inputProps,{ref:s=>this.inputElHandler(s),type:"checkbox",onChange:s=>this.changeHandler(s),class:"hidden"})),t("div",{class:s}))}static get watchers(){return{inputProps:["propsChangeHandler"]}}};export{i as opgl_toggle}