UNPKG

2.5 kBJavaScriptView Raw
1System.register(["./p-b2d01686.system.js"],(function(e){"use strict";var t,r,n,i;return{setters:[function(e){t=e.r;r=e.c;n=e.h;i=e.g}],execute:function(){var o=e("taro_form_core",function(){function e(e){t(this,e);this.onSubmit=r(this,"submit",7);this.value={}}e.prototype.watchSlotParent=function(e){if(!this.orginalAppendChild){this.orginalAppendChild=this.el.appendChild;this.orginalInsertBefore=this.el.insertBefore;this.orginalReplaceChild=this.el.replaceChild;this.orginalRemoveChild=this.el.removeChild}if(!e){this.el.appendChild=this.orginalAppendChild;this.el.insertBefore=this.orginalInsertBefore;this.el.replaceChild=this.orginalReplaceChild;this.el.removeChild=this.orginalRemoveChild;return}this.el.appendChild=function(t){return e.appendChild(t)};this.el.insertBefore=function(t,r){return e.insertBefore(t,r)};this.el.replaceChild=function(t,r){return e.replaceChild(t,r)};this.el.removeChild=function(t){return e.removeChild(t)}};e.prototype.onButtonSubmit=function(e){e.stopPropagation();this.value=this.getFormValue();this.onSubmit.emit({value:this.value})};e.prototype.onButtonReset=function(e){e.stopPropagation();this.form.reset()};e.prototype.componentDidLoad=function(){var e=this;this.value=this.getFormValue();Object.defineProperty(this.el,"value",{get:function(){return e.value},configurable:true})};e.prototype.componentDidRender=function(){this.setSlotParent(this.form)};e.prototype.getFormValue=function(){var e=this.el;var t=[];var r=e.getElementsByTagName("input");for(var n=0;n<r.length;n++){t.push(r[n])}var i={};var o={};t.forEach((function(e){if(e.className.indexOf("weui-switch")!==-1){i[e.name]=e.checked;return}if(e.type==="radio"){if(e.checked){o[e.name]=true;i[e.name]=e.value}else{if(!o[e.name]){i[e.name]=""}}return}if(e.type==="checkbox"){if(e.checked){if(o[e.name]){i[e.name].push(e.value)}else{o[e.name]=true;i[e.name]=[e.value]}}else{if(!o[e.name]){i[e.name]=[]}}return}i[e.name]=e.value}));var a=e.getElementsByTagName("textarea");var l=[];for(var s=0;s<a.length;s++){l.push(a[s])}l.forEach((function(e){i[e.name]=e.value}));return i};e.prototype.setSlotParent=function(e){this.slotParent=e};e.prototype.render=function(){var e=this;return n("form",{ref:function(t){if(t){e.form=t}}},n("slot",null))};Object.defineProperty(e.prototype,"el",{get:function(){return i(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{slotParent:["watchSlotParent"]}},enumerable:false,configurable:true});return e}())}}}));
\No newline at end of file