@tarojs/components
Version:
1 lines • 2.78 kB
JavaScript
import{r as t,c as e,h as i,H as s,g as r}from"./p-dd7a128d.js";const o=class{constructor(i){t(this,i),this.onChange=e(this,"radiochange",7),this.handleClick=t=>{t.stopPropagation(),this.disabled||this.checked||(this.checked=!0)},this.name=void 0,this.value="",this.id=void 0,this.checked=!1,this.disabled=!1,this.nativeProps={},this.isWillLoadCalled=!1}watchChecked(t){this.isWillLoadCalled&&t&&this.onChange.emit({value:this.value})}watchId(t){this.isWillLoadCalled&&t&&this.inputEl.setAttribute("id",t)}componentDidRender(){this.id&&this.el.removeAttribute("id")}componentWillLoad(){this.isWillLoadCalled=!0}render(){const{checked:t,name:e,value:r,disabled:o,nativeProps:a}=this;return i(s,{className:"weui-cells_checkbox",onClick:this.handleClick},i("input",Object.assign({ref:t=>{t&&(this.inputEl=t,this.id&&t.setAttribute("id",this.id))},type:"radio",name:e,value:r,class:"weui-check",checked:t,disabled:o,onChange:t=>t.stopPropagation()},a)),i("i",{class:"weui-icon-checked"}),i("slot",null))}get el(){return r(this)}static get watchers(){return{checked:["watchChecked"],id:["watchId"]}}};var a,h=function(t,e,i,s,r){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?r.call(t,i):r?r.value=i:e.set(t,i),i},c=function(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)};const n=class{constructor(i){t(this,i),this.onChange=e(this,"change",7),this.uniqueName=Date.now().toString(36),a.set(this,void 0),this.name=void 0}function(t){if(t.stopPropagation(),"TARO-RADIO-CORE"!==t.target.tagName)return;const e=t.target;e.checked&&(this.el.querySelectorAll("taro-radio-core").forEach((t=>{t!==e&&(t.checked=!1)})),h(this,a,t.detail.value,"f"),this.onChange.emit({value:c(this,a,"f")}))}componentDidLoad(){this.el.querySelectorAll("taro-radio-core").forEach((t=>{t.setAttribute("name",this.name||this.uniqueName)})),Object.defineProperty(this.el,"value",{get:()=>{if(!c(this,a,"f")){const t=this.el.querySelectorAll("taro-radio-core");h(this,a,this.getValues(t),"f")}return c(this,a,"f")},configurable:!0})}getValues(t){let e="";return Array.from(t).forEach((t=>{const i=t.querySelector("input");(null==i?void 0:i.checked)&&(e=i.value||"")})),e}render(){return i(s,{class:"weui-cells_radiogroup"})}get el(){return r(this)}};a=new WeakMap;export{o as taro_radio_core,n as taro_radio_group_core}