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