UNPKG

4.02 kBJavaScriptView Raw
1System.register(["./p-b2d01686.system.js"],(function(t){"use strict";var e,n,i,o;return{setters:[function(t){e=t.r;n=t.c;i=t.h;o=t.g}],execute:function(){var s="taro-input-core{display:block}input{display:block;overflow:hidden;height:1.4rem;text-overflow:clip;text-align:inherit;white-space:nowrap}";function a(t,e,n){if(e==="search")t="search";if(n)t="password";if(typeof t==="undefined"){return"text"}if(!t){throw new Error("unexpected type")}if(t==="digit")t="number";return t}function u(t){return t!==null&&t!==void 0?t:""}var r=t("taro_input_core",function(){function t(t){var i=this;e(this,t);this.onInput=n(this,"input",7);this.onPaste=n(this,"paste",7);this.onFocus=n(this,"focus",7);this.onBlur=n(this,"blur",7);this.onConfirm=n(this,"confirm",7);this.onChange=n(this,"change",7);this.onKeyDown=n(this,"keydown",7);this.isOnComposition=false;this.isOnPaste=false;this.onInputExcuted=false;this.password=false;this.disabled=false;this.maxlength=140;this.autoFocus=false;this.confirmType="done";this.nativeProps={};this.handleInput=function(t){t.stopPropagation();var e=i,n=e.type,o=e.maxlength,s=e.confirmType,u=e.password;if(!i.isOnComposition&&!i.onInputExcuted){var r=t.target.value;var l=a(n,s,u);i.onInputExcuted=true;if(l==="number"&&r&&o<=r.length){r=r.substring(0,o);t.target.value=r}i.value=r;i.onInput.emit({value:r,cursor:r.length})}};this.handlePaste=function(t){i.isOnPaste=true;i.onPaste.emit({value:t.target.value})};this.handleFocus=function(t){i.onInputExcuted=false;i.onFocus.emit({value:t.target.value})};this.handleBlur=function(t){i.onBlur.emit({value:t.target.value})};this.handleChange=function(t){t.stopPropagation();i.onChange.emit({value:t.target.value});if(i.isOnPaste){i.isOnPaste=false;i.value=t.target.value;i.onInput.emit({value:t.target.value,cursor:t.target.value.length})}};this.handleKeyDown=function(t){var e=t.target.value;var n=t.keyCode||t.code;i.onInputExcuted=false;t.stopPropagation();i.onKeyDown.emit({value:e,cursor:e.length,keyCode:n});n===13&&i.onConfirm.emit({value:e})};this.handleComposition=function(t){if(!(t.target instanceof HTMLInputElement))return;if(t.type==="compositionend"){i.isOnComposition=false;i.value=t.target.value;i.onInput.emit({value:t.target.value,cursor:t.target.value.length})}else{i.isOnComposition=true}}}t.prototype.watchFocus=function(t,e){var n;if(!e&&t){(n=this.inputRef)===null||n===void 0?void 0:n.focus()}};t.prototype.componentDidLoad=function(){var t=this;var e,n,i;if(this.type==="file"){this.fileListener=function(){t.onInput.emit()};(e=this.inputRef)===null||e===void 0?void 0:e.addEventListener("change",this.fileListener)}else{(n=this.inputRef)===null||n===void 0?void 0:n.addEventListener("compositionstart",this.handleComposition);(i=this.inputRef)===null||i===void 0?void 0:i.addEventListener("compositionend",this.handleComposition)}Object.defineProperty(this.el,"value",{get:function(){var e;return(e=t.inputRef)===null||e===void 0?void 0:e.value},set:function(e){return t.value=e},configurable:true})};t.prototype.disconnectedCallback=function(){var t;if(this.type==="file"){(t=this.inputRef)===null||t===void 0?void 0:t.removeEventListener("change",this.fileListener)}};t.prototype.render=function(){var t=this;var e=this,n=e.value,o=e.type,s=e.password,r=e.placeholder,l=e.autoFocus,h=e.disabled,p=e.maxlength,c=e.confirmType,f=e.name,d=e.nativeProps;return i("input",Object.assign({ref:function(e){t.inputRef=e},class:"weui-input",value:u(n),type:a(o,c,s),placeholder:r,autoFocus:l,disabled:h,maxlength:p,name:f,onInput:this.handleInput,onFocus:this.handleFocus,onBlur:this.handleBlur,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onPaste:this.handlePaste,onCompositionStart:this.handleComposition,onCompositionEnd:this.handleComposition},d))};Object.defineProperty(t.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{autoFocus:["watchFocus"]}},enumerable:false,configurable:true});return t}());r.style=s}}}));
\No newline at end of file