UNPKG

@xysfe/actui

Version:

A fantastic mobile ui lib implement by Vue

1 lines 8.02 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@xysfe/actui/es/assets/utils/create/index.js"),require("@xysfe/actui/es/assets/utils/helpers.js")):"function"==typeof define&&define.amd?define(["@xysfe/actui/es/assets/utils/create/index.js","@xysfe/actui/es/assets/utils/helpers.js"],t):"object"==typeof exports?exports.BaseInput=t(require("@xysfe/actui/es/assets/utils/create/index.js"),require("@xysfe/actui/es/assets/utils/helpers.js")):e.BaseInput=t(e["@xysfe/actui/es/assets/utils/create/index.js"],e["@xysfe/actui/es/assets/utils/helpers.js"])}("undefined"!=typeof self?self:this,function(e,t){return function(e){function t(i){if(n[i])return n[i].exports;var a=n[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="../es",t(t.s=1421)}({1060:function(e,t,n){"use strict";var i=n(39);n.n(i);t.a={name:"ActBaseInput",mixins:[],data:function(){return{inputValue:"",inputState:0,maxLenValue:"",oldInputValue:"",canSetSelectionList:["text","search","url","tel","password"],isNeedSetSelectionRange:!1}},props:{value:{type:[String,Number,Object],default:""},type:{type:String,default:"text"},placeholder:{type:String,default:""},maxLength:{type:[String,Number],default:""},allowSpace:{type:Boolean,default:!1},isVerifyCode:{type:Boolean,default:!1}},computed:{inputType:function(){return"mobile"===this.type||"bankcard"===this.type?"tel":"idcard"===this.type?"tel":this.type},paddingBlank:function(){return"mobile"===this.type?i.formatMobile:"bankcard"===this.type?i.formatBankCard:null},maxLen:function(){return""!==this.maxLength&&Number(this.maxLength)>0?Number(this.maxLength):""},currentValue:function(){var e=this.inputValue.replace(/(^\s*)|(\s*$)/g,"");return this.paddingBlank&&(e=this.removeBlank(e)),e}},methods:{focus:function(){this.$refs.input.focus()},blur:function(){this.$refs.input.blur()},setInputValue:function(e){this.inputValue!==e&&(this.inputValue=this.formatValue(e))},onFocus:function(e){this.$emit("focus",e)},onBlur:function(e){/ip(hone|od).*(micromessenger|mqqbrowser)/i.test(navigator.userAgent)&&window.scrollTo(window.scrollX,window.scrollY),this.changeValue(e),this.$emit("blur",e)},onPaste:function(e){e.target._paste=!0},onInput:function(e){var t=this;this.setInputState();var n=!i.isMucWebAutoTester&&this.paddingBlank,a=this.inputValue;this.allowSpace||(a=this.inputValue.replace(/\s/g,""));var u=e.target.selectionStart,s=!0;this.isNeedSetSelectionRange=!1,n&&(this.isNeedSetSelectionRange=!0,(a=a.replace(/\D/g,""))!==this.inputValue.replace(/\s/g,"")&&(s=!1,u--));var r=a;if(this.isOverLength(a)&&(this.isNeedSetSelectionRange=!0,e.target._paste?r=r.slice(0,this.maxLen):(r=this.maxLenValue,u--)),r=this.getValueByCheck(r),this.maxLenValue=r,n){if(this.inputValue=this.paddingBlank(r),s){var o=this.inputValue[u-1];/\s/g.test(o)&&1===this.inputState&&u++}}else this.inputValue=r;this.isNeedSetSelectionRange&&this.$nextTick(function(){e.target._paste?(t.canSetSelectionList.indexOf(e.target.type)>-1&&setTimeout(function(){e.target.setSelectionRange(t.inputValue.length,t.inputValue.length)},30),e.target._paste=!1):t.canSetSelectionList.indexOf(e.target.type)>-1&&setTimeout(function(){e.target.setSelectionRange(u,u)},30)}),this.$emit("input",this.currentValue,e)},getValueByCheck:function(e){var t=e;return this.isVerifyCode&&(t=this.checkVerifyCode(t)),t&&"lowercase"===this.type?(this.isNeedSetSelectionRange=!0,t=t.toLowerCase()):t&&"uppercase"===this.type?(this.isNeedSetSelectionRange=!0,t=t.toUpperCase()):t&&"email"===this.type&&(t=t.replace(/[\u4e00-\u9fa5]/gi,"").replace(/\s*/gi,"").substr(0,40)),t},onClick:function(e){this.$emit("click",e)},onTap:function(e){this.$emit("tap",e)},formatValue:function(e){return!i.isMucWebAutoTester&&this.paddingBlank?this.paddingBlank(e):e},removeBlank:function(e){return e.replace(/\s/g,"")},setInputState:function(){if(this.paddingBlank){var e=this.inputValue.replace(/\s/g,"").length,t=this.oldInputValue.replace(/\s/g,"").length;this.inputState=e>t?1:e<t?2:0}this.oldInputValue=this.inputValue},changeValue:function(e){var t=e.srcElement?e.srcElement:e.target,n=t.value.replace(/(^\s*)|(\s*$)/g,"");this.paddingBlank&&(n=this.removeBlank(n)),this.value!==n&&this.$emit("change",n)},isOverLength:function(e){var t=e.match(/\s/g)||[];return""!==this.maxLen&&e.length-t.length>this.maxLen},mucChange:function(e){this.$emit("mucChange",e)},checkVerifyCode:function(e){if(!e)return"";var t=String(e);if(t.length&&t.length>=8){var n=Math.floor(t.length/2),i=t.slice(0,n);if(i===t.slice(n,t.length))return i}return t}},mounted:function(){this.inputValue=this.formatValue(this.value),this.$watch("value",function(e,t){this.inputValue=this.formatValue(e)})}}},1421:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(26),a=n.n(i),u=n(1422);u.a.install=function(e){e.component(u.a.name,u.a),e.prototype.$createBaseInput=a()(u.a,e)},t.default=u.a},1422:function(e,t,n){"use strict";function i(e){r||n(1423)}var a=n(1060),u=n(1424),s=n(7),r=!1,o=i,l=Object(s.a)(a.a,u.a,u.b,!1,o,"data-v-18134e52",null);l.options.__file="src\\components\\BaseInput\\src\\index.vue",t.a=l.exports},1423:function(e,t){},1424:function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return a});var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return"checkbox"===e.inputType?n("input",{directives:[{name:"model",rawName:"v-model",value:e.inputValue,expression:"inputValue"}],ref:"input",attrs:{placeholder:e.placeholder,type:"checkbox"},domProps:{checked:Array.isArray(e.inputValue)?e._i(e.inputValue,null)>-1:e.inputValue},on:{focus:e.onFocus,blur:e.onBlur,input:e.onInput,paste:e.onPaste,click:e.onClick,tap:e.onTap,mucChange:function(t){return e.mucChange(t)},change:function(t){var n=e.inputValue,i=t.target,a=!!i.checked;if(Array.isArray(n)){var u=e._i(n,null);i.checked?u<0&&(e.inputValue=n.concat([null])):u>-1&&(e.inputValue=n.slice(0,u).concat(n.slice(u+1)))}else e.inputValue=a}}}):"radio"===e.inputType?n("input",{directives:[{name:"model",rawName:"v-model",value:e.inputValue,expression:"inputValue"}],ref:"input",attrs:{placeholder:e.placeholder,type:"radio"},domProps:{checked:e._q(e.inputValue,null)},on:{focus:e.onFocus,blur:e.onBlur,input:e.onInput,paste:e.onPaste,click:e.onClick,tap:e.onTap,mucChange:function(t){return e.mucChange(t)},change:function(t){e.inputValue=null}}}):n("input",{directives:[{name:"model",rawName:"v-model",value:e.inputValue,expression:"inputValue"}],ref:"input",attrs:{placeholder:e.placeholder,type:e.inputType},domProps:{value:e.inputValue},on:{focus:e.onFocus,blur:e.onBlur,input:[function(t){t.target.composing||(e.inputValue=t.target.value)},e.onInput],paste:e.onPaste,click:e.onClick,tap:e.onTap,mucChange:function(t){return e.mucChange(t)}}})},a=[];i._withStripped=!0},26:function(t,n){t.exports=e},39:function(e,n){e.exports=t},7:function(e,t,n){"use strict";function i(e,t,n,i,a,u,s,r){e=e||{};var o=typeof e.default;"object"!==o&&"function"!==o||(e=e.default);var l="function"==typeof e?e.options:e;t&&(l.render=t,l.staticRenderFns=n,l._compiled=!0),i&&(l.functional=!0),u&&(l._scopeId=u);var c;if(s?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),a&&a.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},l._ssrRegister=c):a&&(c=r?function(){a.call(this,this.$root.$options.shadowRoot)}:a),c)if(l.functional){l._injectStyles=c;var p=l.render;l.render=function(e,t){return c.call(t),p(e,t)}}else{var h=l.beforeCreate;l.beforeCreate=h?[].concat(h,c):[c]}return{exports:e,options:l}}t.a=i}})});