@tarojs/components
Version:
1 lines • 3.15 kB
JavaScript
System.register(["./p-2b70c348.system.js"],(function(e){"use strict";var t,r,i,n;return{setters:[function(e){t=e.r;r=e.c;i=e.h;n=e.g}],execute:function(){var o=undefined&&undefined.__classPrivateFieldSet||function(e,t,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r};var a=undefined&&undefined.__classPrivateFieldGet||function(e,t,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(e):i?i.value:t.get(e)};var s;var l=e("taro_form_core",function(){function e(e){t(this,e);this.onSubmit=r(this,"submit",7);s.set(this,{})}e.prototype.onButtonSubmit=function(e){e.stopPropagation();o(this,s,this.getFormValue(),"f");this.onSubmit.emit({value:a(this,s,"f")})};e.prototype.onButtonReset=function(e){e.stopPropagation();this.form.reset()};e.prototype.componentDidLoad=function(){var e=this;o(this,s,this.getFormValue(),"f");Object.defineProperty(this.el,"value",{get:function(){return a(e,s,"f")},configurable:true})};e.prototype.componentDidRender=function(){var e=this;if(!this.originalAppendChild){this.originalAppendChild=this.el.appendChild;this.originalInsertBefore=this.el.insertBefore;this.originalReplaceChild=this.el.replaceChild;this.originalRemoveChild=this.el.removeChild}if(!this.form){this.el.appendChild=this.originalAppendChild;this.el.insertBefore=this.originalInsertBefore;this.el.replaceChild=this.originalReplaceChild;this.el.removeChild=this.originalRemoveChild;return}this.el.appendChild=function(t){return e.form.appendChild(t)};this.el.insertBefore=function(t,r){return e.form.insertBefore(t,r)};this.el.replaceChild=function(t,r){return e.form.replaceChild(t,r)};this.el.removeChild=function(t){return e.form.removeChild(t)}};e.prototype.getFormValue=function(){var e=this.el;var t=[];var r=e.getElementsByTagName("input");for(var i=0;i<r.length;i++){t.push(r[i])}var n={};var o={};t.forEach((function(e){if(typeof e.name!=="string")return;if(e.className.indexOf("weui-switch")!==-1){n[e.name]=e.checked;return}if(e.type==="radio"){if(e.checked){o[e.name]=true;n[e.name]=e.value}else{if(!o[e.name]){n[e.name]=""}}return}if(e.type==="checkbox"){if(e.checked){if(o[e.name]){n[e.name].push(e.value)}else{o[e.name]=true;n[e.name]=[e.value]}}else{if(!o[e.name]){n[e.name]=[]}}return}n[e.name]=e.value}));var a=e.getElementsByTagName("textarea");var s=[];for(var l=0;l<a.length;l++){s.push(a[l])}s.forEach((function(e){if(typeof e.name!=="string")return;n[e.name]=e.value}));return n};e.prototype.render=function(){var e=this;return i("form",{ref:function(t){e.form=t}},i("slot",null))};Object.defineProperty(e.prototype,"el",{get:function(){return n(this)},enumerable:false,configurable:true});return e}());s=new WeakMap}}}));