Socket
Socket
Sign inDemoInstall

vue-numeric-keypad

Package Overview
Dependencies
10
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.5 to 1.2.6

44

dist/vue-numeric-keypad.esm.js

@@ -102,2 +102,3 @@ //

fixDeleteKey: Boolean(this.options.fixDeleteKey === undefined || this.options.fixDeleteKey),
fixBlankKey: Boolean(this.options.fixBlankKey === undefined || this.options.fixBlankKey),
stopPropagation: Boolean(this.options.stopPropagation === undefined || this.options.stopPropagation),

@@ -149,2 +150,3 @@ keypadClass: this.options.keypadClass || 'numeric-keypad',

this.fixDeleteKey = Boolean(options.fixDeleteKey === undefined || options.fixDeleteKey);
this.fixBlankKey = Boolean(options.fixBlankKey === undefined || options.fixBlankKey);
this.stopPropagation = Boolean(options.stopPropagation === undefined || options.stopPropagation);

@@ -292,32 +294,32 @@ this.activeButtonDelay = Number(options.activeButtonDelay) || 300;

randomize() {
let newkeyArray = [];
let delKeyCnt = 0;
let clearKeyCnt = 0;
const l = this.keyArray.length;
const newkeyArray = [...this.keyArray];
for (let i = 0; i < this.keyArray.length; i++) {
let r = Math.random();
for (let i = 0; i < l; i++) {
const key = newkeyArray[i];
if (this.checkFix(key)) continue;
let r = Math.floor(Math.random() * l);
if (r == i) r = (r + 1) % l;
let count = 0;
if (this.fixDeleteKey && this.keyArray[i] == -1) {
delKeyCnt++;
continue;
while ((this.checkFix(newkeyArray[r]) || newkeyArray[r] === newkeyArray[i]) && count < l) {
r = (r + 1) % l;
count++;
}
if (this.fixDeleteKey && this.keyArray[i] == -2) {
clearKeyCnt++;
continue;
}
if (r < 0.5) newkeyArray.push(this.keyArray[i]);else newkeyArray.unshift(this.keyArray[i]);
if (count >= l) continue;
newkeyArray[i] = newkeyArray[r];
newkeyArray[r] = key;
}
if (delKeyCnt) {
for (let i = 0; i < delKeyCnt; i++) newkeyArray.push(-1);
}
if (clearKeyCnt) {
for (let i = 0; i < clearKeyCnt; i++) newkeyArray.push(-2);
}
this.keyArray = newkeyArray;
},
checkFix(key) {
if (key === '' && this.fixBlankKey) return true;
if (key === -1 && this.fixDeleteKey) return true;
if (key === -2 && this.fixDeleteKey) return true;
return false;
},
showKey(key) {

@@ -324,0 +326,0 @@ if (key === -1) {

@@ -1,1 +0,1 @@

var VueNumericKeypad=function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var i,o,s=[],r=!0,a=!1;try{for(n=n.call(t);!(r=(i=n.next()).done)&&(s.push(i.value),!e||s.length!==e);r=!0);}catch(t){a=!0,o=t}finally{try{r||null==n.return||n.return()}finally{if(a)throw o}}return s}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||i(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}Object.entries||(Object.entries=function(t){for(var e=Object.keys(t),n=e.length,i=new Array(n);n--;)i[n]=[e[n],t[e[n]]];return i});var s=[1,2,3,4,5,6,7,8,9,"",0,-1],r=[1,2,3,4,5,6,7,8,9,0,"",-1];function a(t,e,n,i,o,s,r,a,l,u){"boolean"!=typeof r&&(l=a,a=r,r=!1);const c="function"==typeof n?n.options:n;let d;if(t&&t.render&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,o&&(c.functional=!0)),i&&(c._scopeId=i),s?(d=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,l(t)),t&&t._registeredComponents&&t._registeredComponents.add(s)},c._ssrRegister=d):e&&(d=r?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,a(t))}),d)if(c.functional){const t=c.render;c.render=function(e,n){return d.call(n),t(e,n)}}else{const t=c.beforeCreate;c.beforeCreate=t?[].concat(t,d):[d]}return n}var l=a({render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{directives:[{name:"show",rawName:"v-show",value:t.show,expression:"show"}],class:t.keypadClass,attrs:{id:t.id},on:{click:function(e){t.stopPropagation&&e.stopPropagation()}}},[n("div",{class:t.buttonWrapClass},t._l(t.keyArray,(function(e,i){return n("button",{key:i,ref:"button",refInFor:!0,class:t.setClass(e,i),attrs:{type:"button"},on:{pointerup:function(n){return t.click(e,i,n)}}},[t._v("\n "+t._s(t.showKey(e))+"\n ")])})),0),t._v(" "),t._t("default")],2)},staticRenderFns:[]},undefined,{name:"VueNumericKeypad",props:{id:{type:String,required:!1},value:{type:String,default:"",required:!0},show:{type:[Boolean,Number],default:!1,required:!0},encryptFunc:{type:Function,default:function(t){return t}},encryptedValue:{type:Array,default:function(){return[]}},options:{type:Object,default:function(){return{}},validator:function(e){return(e.keyArray||[]).some((function(e){switch(t(e)){case"number":return!Number.isInteger(e)||e<-2||e>9;case"string":return e;default:return!1}}))?(console.error("KeyArray can contain only an integer 'number' between -2 and 9 and an empty 'string'."),!1):!Object.keys(e).some((function(t){return/Class/.test(t)&&/[^0-9A-z\-_ ]/.test(e[t])}))||(console.error("Class name can contain only 'a-z' and 'A-Z', '0-9', '_', '-', ' '."),!1)},required:!1}},data:function(){var t=this,e=Number(this.options.columns)||3;return{encrypt:Boolean(this.options.encrypt),encryptedChar:"string"==typeof this.options.encryptedChar?this.options.encryptedChar.substring(0,1):"0",keyArray:this.options.keyArray||(3===e?s:r),keyRandomize:Boolean(void 0===this.options.keyRandomize||this.options.keyRandomize),randomizeWhenClick:Boolean(this.options.randomizeWhenClick),fixDeleteKey:Boolean(void 0===this.options.fixDeleteKey||this.options.fixDeleteKey),stopPropagation:Boolean(void 0===this.options.stopPropagation||this.options.stopPropagation),keypadClass:this.options.keypadClass||"numeric-keypad",buttonWrapClass:this.options.buttonWrapClass||"numeric-keypad__button-wrap",buttonClass:this.options.buttonClass||"numeric-keypad__button",deleteButtonClass:this.options.deleteButtonClass||"numeric-keypad__button--delete",clearButtonClass:this.options.clearButtonClass||"numeric-keypad__button--clear",blankButtonClass:this.options.blankButtonClass||"numeric-keypad__button--blank",activeButtonClass:this.options.activeButtonClass||"numeric-keypad__button--active",activeButtonIndexes:{},activeButtonDelay:Number(this.options.activeButtonDelay)||300,pseudoClick:Boolean(this.options.pseudoClick),pseudoClickDeleteKey:void 0===this.options.pseudoClickDeleteKey?Boolean(this.options.pseudoClick):Boolean(this.options.pseudoClickDeleteKey),pseudoClickBlankKey:void 0===this.options.pseudoClickBlankKey?Boolean(this.options.pseudoClick):Boolean(this.options.pseudoClickBlankKey),vibrate:Boolean(this.options.vibrate),vibratePattern:this.options.vibratePattern||200,rows:Number(this.options.rows)||4,columns:e,zIndex:Number(this.options.zIndex)||1,cellWidth:0,cellHeight:0,defaultStyleSheet:document.createElement("style"),defaultStyle:["all","button","wrap","none"].find((function(e){return e===t.options.defaultStyle}))||"all",keypadStylesIndex:null,deleteKeyText:void 0===this.options.deleteKeyText?"del":this.options.deleteKeyText,clearKeyText:void 0===this.options.clearKeyText?"clr":this.options.clearKeyText}},watch:{show:function(){this.$nextTick((function(){this.show&&this.resize()})),this.keyRandomize&&this.randomize()},options:{deep:!0,handler:function(e){if("object"===t(e)){var n=Number(e.columns)||3;this.encryptedChar="string"==typeof e.encryptedChar?e.encryptedChar.substring(0,1):"0",this.keyArray=e.keyArray||(3===n?s:r),this.keyRandomize=Boolean(void 0===e.keyRandomize||e.keyRandomize),this.randomizeWhenClick=Boolean(e.randomizeWhenClick),this.fixDeleteKey=Boolean(void 0===e.fixDeleteKey||e.fixDeleteKey),this.stopPropagation=Boolean(void 0===e.stopPropagation||e.stopPropagation),this.activeButtonDelay=Number(e.activeButtonDelay)||300,this.pseudoClick=Boolean(e.pseudoClick),this.pseudoClickDeleteKey=void 0===e.pseudoClickDeleteKey?Boolean(e.pseudoClick):Boolean(e.pseudoClickDeleteKey),this.pseudoClickBlankKey=void 0===e.pseudoClickBlankKey?Boolean(e.pseudoClick):Boolean(e.pseudoClickBlankKey),this.vibrate=Boolean(e.vibrate),this.vibratePattern=this.vibratePattern||200,this.rows=Number(e.rows)||4,this.zIndex=Number(e.zIndex)||1,this.deleteKeyText=void 0===e.deleteKeyText?"del":e.deleteKeyText,this.clearKeyText=void 0===e.clearKeyText?"clr":e.clearKeyText;var i=["all","button","wrap","none"].find((function(t){return t===e.defaultStyle}))||"all";this.defaultStyle!==i&&(this.defaultStyle=i,document.head.removeChild(this.defaultStyleSheet),this.defaultStyleSheet=document.createElement("style"),"none"!==this.defaultStyle&&(document.head.appendChild(this.defaultStyleSheet),this.initDefaultStyles(this.defaultStyleSheet.sheet))),this.keyRandomize&&this.randomize()}}}},computed:{keypadStyles:function(){var t=Math.round(.3*Math.min(this.cellWidth,this.cellHeight)),e="\n position: fixed;\n z-index: ".concat(this.zIndex,";\n bottom: 0;\n left: 0;\n right: 0;\n height: 40vh;\n padding: 10px;\n background-color: #fff;\n border-radius: 12px 12px 0 0;\n box-shadow: 0 -4px 4px rgba(0, 0, 0, 0.15);\n color: #000;\n overflow: hidden;\n ");return t?e+"\nfont-size: ".concat(t,"px;"):e},buttonWrapStyles:function(){return"\n display: flex;\n witdth: 100%;\n height: 100%;\n justify-content: space-between;\n align-content: space-between;\n flex-wrap: wrap;\n gridGap: 5px;\n "},buttonStyles:function(){var t="calc(".concat(Math.round(1e3/this.columns)/10,"% - ").concat(Math.ceil(5*(this.columns-1)/this.columns),"px)"),e="calc(".concat(Math.round(1e3/this.rows)/10,"% - ").concat(Math.ceil(5*(this.rows-1)/this.rows),"px)");return"\n flex: 0 0 auto;\n display: flex;\n width: ".concat(t,";\n height: ").concat(e,";\n justify-content: center;\n align-items: center;\n background-color: #fff;\n border: 1px solid #000;\n border-radius: 8px;\n font-size: inherit;\n ")}},methods:{click:function(t,e,n){if(n.isTrusted){if(this.pseudoClick&&(-1!=t&&-2!=t||this.pseudoClickDeleteKey)&&(""!=t||this.pseudoClickBlankKey)){var i=this.keyArray.length,o=Math.floor(Math.random()*(i-1)+e+1)%i;this.activeButton(o)}switch(this.activeButton(e),this.vibrate&&window.navigator.vibrate&&window.navigator.vibrate(this.vibratePattern),t){case-1:this.del();break;case-2:this.clear();case"":break;default:this.add(t)}this.keyRandomize&&this.randomizeWhenClick&&this.randomize()}},del:function(){var t=n(this.encryptedValue),e=this.value.slice(0,-1);this.$emit("update:value",String(e)),this.encrypt&&(t.pop(),this.$emit("update:encryptedValue",t))},clear:function(){this.$emit("update:value",""),this.encrypt&&this.$emit("update:encryptedValue",[])},add:function(t){var e=n(this.encryptedValue),i=this.value;this.encrypt?(i+=this.encryptedChar,e.push(this.encryptFunc(t.toString())),this.$emit("update:encryptedValue",e)):i+=t,this.$emit("update:value",String(i))},randomize:function(){for(var t=[],e=0,n=0,i=0;i<this.keyArray.length;i++){var o=Math.random();this.fixDeleteKey&&-1==this.keyArray[i]?e++:this.fixDeleteKey&&-2==this.keyArray[i]?n++:o<.5?t.push(this.keyArray[i]):t.unshift(this.keyArray[i])}if(e)for(var s=0;s<e;s++)t.push(-1);if(n)for(var r=0;r<n;r++)t.push(-2);this.keyArray=t},showKey:function(t){return-1===t?this.deleteKeyText:-2===t?this.clearKeyText:t},resize:function(){this.cellWidth=this.$refs.button[0].offsetWidth,this.cellHeight=this.$refs.button[0].offsetHeight;var t=this.defaultStyleSheet.sheet;t&&null!==this.keypadStylesIndex&&(t.deleteRule(0),t.insertRule(".".concat(this.keypadClass.trim().split(" ")[0]," {").concat(this.keypadStyles,"}"),0))},setClass:function(t,e){var n=[this.buttonClass];return-1===t&&n.push(this.deleteButtonClass),-2===t&&n.push(this.clearButtonClass),""===t&&n.push(this.blankButtonClass),this.activeButtonIndexes[e]&&n.push(this.activeButtonClass),n},activeButton:function(t){var e=this;this.activeButtonIndexes[t]?clearTimeout(this.activeButtonIndexes[t]):this.$refs.button[t].classList.add(this.activeButtonClass),this.activeButtonIndexes[t]=setTimeout((function(){e.$refs.button[t].classList.remove(e.activeButtonClass),clearTimeout(e.activeButtonIndexes[t]),delete e.activeButtonIndexes[t]}),this.activeButtonDelay)},initDefaultStyles:function(t){if("none"!==this.defaultStyle){var e=/[^0-9A-z\-_ ]/,n=0;"button"!==this.defaultStyle&&(e.test(this.keypadClass)||(this.keypadStylesIndex=n,t.insertRule(".".concat(this.keypadClass.trim().split(" ")[0]," {").concat(this.keypadStyles,"}"),n++)),e.test(this.buttonWrapClass)||t.insertRule(".".concat(this.buttonWrapClass.trim().split(" ")[0]," {").concat(this.buttonWrapStyles,"}"),n++)),"wrap"!==this.defaultStyle&&(e.test(this.buttonClass)||(t.insertRule(".".concat(this.buttonClass.trim().split(" ")[0]," {").concat(this.buttonStyles,"}"),n++),e.test(this.activeButtonClass)||t.insertRule(".".concat(this.buttonClass.trim().split(" ")[0],".").concat(this.activeButtonClass.trim().split(" ")[0]," {background-color: #eaeaea;}"),n++)))}}},mounted:function(){window.addEventListener("resize",this.resize),"none"!==this.defaultStyle&&(document.head.appendChild(this.defaultStyleSheet),this.initDefaultStyles(this.defaultStyleSheet.sheet)),this.keyRandomize&&this.randomize(),this.resize()},beforeDestroy:function(){window.removeEventListener("resize",this.resize)}},undefined,false,undefined,!1,void 0,void 0,void 0),u=function(){var t=l;return t.install=function(e){e.component("VueNumericKeypad",t)},t}(),c=Object.freeze({__proto__:null,default:u});return Object.entries(c).forEach((function(t){var n=e(t,2),i=n[0],o=n[1];"default"!==i&&(u[i]=o)})),u}();
var VueNumericKeypad=function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var i,o,s=[],a=!0,r=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(s.push(i.value),!e||s.length!==e);a=!0);}catch(t){r=!0,o=t}finally{try{a||null==n.return||n.return()}finally{if(r)throw o}}return s}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||i(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}Object.entries||(Object.entries=function(t){for(var e=Object.keys(t),n=e.length,i=new Array(n);n--;)i[n]=[e[n],t[e[n]]];return i});var s=[1,2,3,4,5,6,7,8,9,"",0,-1],a=[1,2,3,4,5,6,7,8,9,0,"",-1];function r(t,e,n,i,o,s,a,r,l,u){"boolean"!=typeof a&&(l=r,r=a,a=!1);const c="function"==typeof n?n.options:n;let d;if(t&&t.render&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,o&&(c.functional=!0)),i&&(c._scopeId=i),s?(d=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,l(t)),t&&t._registeredComponents&&t._registeredComponents.add(s)},c._ssrRegister=d):e&&(d=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,r(t))}),d)if(c.functional){const t=c.render;c.render=function(e,n){return d.call(n),t(e,n)}}else{const t=c.beforeCreate;c.beforeCreate=t?[].concat(t,d):[d]}return n}var l=r({render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{directives:[{name:"show",rawName:"v-show",value:t.show,expression:"show"}],class:t.keypadClass,attrs:{id:t.id},on:{click:function(e){t.stopPropagation&&e.stopPropagation()}}},[n("div",{class:t.buttonWrapClass},t._l(t.keyArray,(function(e,i){return n("button",{key:i,ref:"button",refInFor:!0,class:t.setClass(e,i),attrs:{type:"button"},on:{pointerup:function(n){return t.click(e,i,n)}}},[t._v("\n "+t._s(t.showKey(e))+"\n ")])})),0),t._v(" "),t._t("default")],2)},staticRenderFns:[]},undefined,{name:"VueNumericKeypad",props:{id:{type:String,required:!1},value:{type:String,default:"",required:!0},show:{type:[Boolean,Number],default:!1,required:!0},encryptFunc:{type:Function,default:function(t){return t}},encryptedValue:{type:Array,default:function(){return[]}},options:{type:Object,default:function(){return{}},validator:function(e){return(e.keyArray||[]).some((function(e){switch(t(e)){case"number":return!Number.isInteger(e)||e<-2||e>9;case"string":return e;default:return!1}}))?(console.error("KeyArray can contain only an integer 'number' between -2 and 9 and an empty 'string'."),!1):!Object.keys(e).some((function(t){return/Class/.test(t)&&/[^0-9A-z\-_ ]/.test(e[t])}))||(console.error("Class name can contain only 'a-z' and 'A-Z', '0-9', '_', '-', ' '."),!1)},required:!1}},data:function(){var t=this,e=Number(this.options.columns)||3;return{encrypt:Boolean(this.options.encrypt),encryptedChar:"string"==typeof this.options.encryptedChar?this.options.encryptedChar.substring(0,1):"0",keyArray:this.options.keyArray||(3===e?s:a),keyRandomize:Boolean(void 0===this.options.keyRandomize||this.options.keyRandomize),randomizeWhenClick:Boolean(this.options.randomizeWhenClick),fixDeleteKey:Boolean(void 0===this.options.fixDeleteKey||this.options.fixDeleteKey),fixBlankKey:Boolean(void 0===this.options.fixBlankKey||this.options.fixBlankKey),stopPropagation:Boolean(void 0===this.options.stopPropagation||this.options.stopPropagation),keypadClass:this.options.keypadClass||"numeric-keypad",buttonWrapClass:this.options.buttonWrapClass||"numeric-keypad__button-wrap",buttonClass:this.options.buttonClass||"numeric-keypad__button",deleteButtonClass:this.options.deleteButtonClass||"numeric-keypad__button--delete",clearButtonClass:this.options.clearButtonClass||"numeric-keypad__button--clear",blankButtonClass:this.options.blankButtonClass||"numeric-keypad__button--blank",activeButtonClass:this.options.activeButtonClass||"numeric-keypad__button--active",activeButtonIndexes:{},activeButtonDelay:Number(this.options.activeButtonDelay)||300,pseudoClick:Boolean(this.options.pseudoClick),pseudoClickDeleteKey:void 0===this.options.pseudoClickDeleteKey?Boolean(this.options.pseudoClick):Boolean(this.options.pseudoClickDeleteKey),pseudoClickBlankKey:void 0===this.options.pseudoClickBlankKey?Boolean(this.options.pseudoClick):Boolean(this.options.pseudoClickBlankKey),vibrate:Boolean(this.options.vibrate),vibratePattern:this.options.vibratePattern||200,rows:Number(this.options.rows)||4,columns:e,zIndex:Number(this.options.zIndex)||1,cellWidth:0,cellHeight:0,defaultStyleSheet:document.createElement("style"),defaultStyle:["all","button","wrap","none"].find((function(e){return e===t.options.defaultStyle}))||"all",keypadStylesIndex:null,deleteKeyText:void 0===this.options.deleteKeyText?"del":this.options.deleteKeyText,clearKeyText:void 0===this.options.clearKeyText?"clr":this.options.clearKeyText}},watch:{show:function(){this.$nextTick((function(){this.show&&this.resize()})),this.keyRandomize&&this.randomize()},options:{deep:!0,handler:function(e){if("object"===t(e)){var n=Number(e.columns)||3;this.encryptedChar="string"==typeof e.encryptedChar?e.encryptedChar.substring(0,1):"0",this.keyArray=e.keyArray||(3===n?s:a),this.keyRandomize=Boolean(void 0===e.keyRandomize||e.keyRandomize),this.randomizeWhenClick=Boolean(e.randomizeWhenClick),this.fixDeleteKey=Boolean(void 0===e.fixDeleteKey||e.fixDeleteKey),this.fixBlankKey=Boolean(void 0===e.fixBlankKey||e.fixBlankKey),this.stopPropagation=Boolean(void 0===e.stopPropagation||e.stopPropagation),this.activeButtonDelay=Number(e.activeButtonDelay)||300,this.pseudoClick=Boolean(e.pseudoClick),this.pseudoClickDeleteKey=void 0===e.pseudoClickDeleteKey?Boolean(e.pseudoClick):Boolean(e.pseudoClickDeleteKey),this.pseudoClickBlankKey=void 0===e.pseudoClickBlankKey?Boolean(e.pseudoClick):Boolean(e.pseudoClickBlankKey),this.vibrate=Boolean(e.vibrate),this.vibratePattern=this.vibratePattern||200,this.rows=Number(e.rows)||4,this.zIndex=Number(e.zIndex)||1,this.deleteKeyText=void 0===e.deleteKeyText?"del":e.deleteKeyText,this.clearKeyText=void 0===e.clearKeyText?"clr":e.clearKeyText;var i=["all","button","wrap","none"].find((function(t){return t===e.defaultStyle}))||"all";this.defaultStyle!==i&&(this.defaultStyle=i,document.head.removeChild(this.defaultStyleSheet),this.defaultStyleSheet=document.createElement("style"),"none"!==this.defaultStyle&&(document.head.appendChild(this.defaultStyleSheet),this.initDefaultStyles(this.defaultStyleSheet.sheet))),this.keyRandomize&&this.randomize()}}}},computed:{keypadStyles:function(){var t=Math.round(.3*Math.min(this.cellWidth,this.cellHeight)),e="\n position: fixed;\n z-index: ".concat(this.zIndex,";\n bottom: 0;\n left: 0;\n right: 0;\n height: 40vh;\n padding: 10px;\n background-color: #fff;\n border-radius: 12px 12px 0 0;\n box-shadow: 0 -4px 4px rgba(0, 0, 0, 0.15);\n color: #000;\n overflow: hidden;\n ");return t?e+"\nfont-size: ".concat(t,"px;"):e},buttonWrapStyles:function(){return"\n display: flex;\n witdth: 100%;\n height: 100%;\n justify-content: space-between;\n align-content: space-between;\n flex-wrap: wrap;\n gridGap: 5px;\n "},buttonStyles:function(){var t="calc(".concat(Math.round(1e3/this.columns)/10,"% - ").concat(Math.ceil(5*(this.columns-1)/this.columns),"px)"),e="calc(".concat(Math.round(1e3/this.rows)/10,"% - ").concat(Math.ceil(5*(this.rows-1)/this.rows),"px)");return"\n flex: 0 0 auto;\n display: flex;\n width: ".concat(t,";\n height: ").concat(e,";\n justify-content: center;\n align-items: center;\n background-color: #fff;\n border: 1px solid #000;\n border-radius: 8px;\n font-size: inherit;\n ")}},methods:{click:function(t,e,n){if(n.isTrusted){if(this.pseudoClick&&(-1!=t&&-2!=t||this.pseudoClickDeleteKey)&&(""!=t||this.pseudoClickBlankKey)){var i=this.keyArray.length,o=Math.floor(Math.random()*(i-1)+e+1)%i;this.activeButton(o)}switch(this.activeButton(e),this.vibrate&&window.navigator.vibrate&&window.navigator.vibrate(this.vibratePattern),t){case-1:this.del();break;case-2:this.clear();case"":break;default:this.add(t)}this.keyRandomize&&this.randomizeWhenClick&&this.randomize()}},del:function(){var t=n(this.encryptedValue),e=this.value.slice(0,-1);this.$emit("update:value",String(e)),this.encrypt&&(t.pop(),this.$emit("update:encryptedValue",t))},clear:function(){this.$emit("update:value",""),this.encrypt&&this.$emit("update:encryptedValue",[])},add:function(t){var e=n(this.encryptedValue),i=this.value;this.encrypt?(i+=this.encryptedChar,e.push(this.encryptFunc(t.toString())),this.$emit("update:encryptedValue",e)):i+=t,this.$emit("update:value",String(i))},randomize:function(){for(var t=this.keyArray.length,e=n(this.keyArray),i=0;i<t;i++){var o=e[i];if(!this.checkFix(o)){var s=Math.floor(Math.random()*t);s==i&&(s=(s+1)%t);for(var a=0;(this.checkFix(e[s])||e[s]===e[i])&&a<t;)s=(s+1)%t,a++;a>=t||(e[i]=e[s],e[s]=o)}}this.keyArray=e},checkFix:function(t){return!(""!==t||!this.fixBlankKey)||(!(-1!==t||!this.fixDeleteKey)||!(-2!==t||!this.fixDeleteKey))},showKey:function(t){return-1===t?this.deleteKeyText:-2===t?this.clearKeyText:t},resize:function(){this.cellWidth=this.$refs.button[0].offsetWidth,this.cellHeight=this.$refs.button[0].offsetHeight;var t=this.defaultStyleSheet.sheet;t&&null!==this.keypadStylesIndex&&(t.deleteRule(0),t.insertRule(".".concat(this.keypadClass.trim().split(" ")[0]," {").concat(this.keypadStyles,"}"),0))},setClass:function(t,e){var n=[this.buttonClass];return-1===t&&n.push(this.deleteButtonClass),-2===t&&n.push(this.clearButtonClass),""===t&&n.push(this.blankButtonClass),this.activeButtonIndexes[e]&&n.push(this.activeButtonClass),n},activeButton:function(t){var e=this;this.activeButtonIndexes[t]?clearTimeout(this.activeButtonIndexes[t]):this.$refs.button[t].classList.add(this.activeButtonClass),this.activeButtonIndexes[t]=setTimeout((function(){e.$refs.button[t].classList.remove(e.activeButtonClass),clearTimeout(e.activeButtonIndexes[t]),delete e.activeButtonIndexes[t]}),this.activeButtonDelay)},initDefaultStyles:function(t){if("none"!==this.defaultStyle){var e=/[^0-9A-z\-_ ]/,n=0;"button"!==this.defaultStyle&&(e.test(this.keypadClass)||(this.keypadStylesIndex=n,t.insertRule(".".concat(this.keypadClass.trim().split(" ")[0]," {").concat(this.keypadStyles,"}"),n++)),e.test(this.buttonWrapClass)||t.insertRule(".".concat(this.buttonWrapClass.trim().split(" ")[0]," {").concat(this.buttonWrapStyles,"}"),n++)),"wrap"!==this.defaultStyle&&(e.test(this.buttonClass)||(t.insertRule(".".concat(this.buttonClass.trim().split(" ")[0]," {").concat(this.buttonStyles,"}"),n++),e.test(this.activeButtonClass)||t.insertRule(".".concat(this.buttonClass.trim().split(" ")[0],".").concat(this.activeButtonClass.trim().split(" ")[0]," {background-color: #eaeaea;}"),n++)))}}},mounted:function(){window.addEventListener("resize",this.resize),"none"!==this.defaultStyle&&(document.head.appendChild(this.defaultStyleSheet),this.initDefaultStyles(this.defaultStyleSheet.sheet)),this.keyRandomize&&this.randomize(),this.resize()},beforeDestroy:function(){window.removeEventListener("resize",this.resize)}},undefined,false,undefined,!1,void 0,void 0,void 0),u=function(){var t=l;return t.install=function(e){e.component("VueNumericKeypad",t)},t}(),c=Object.freeze({__proto__:null,default:u});return Object.entries(c).forEach((function(t){var n=e(t,2),i=n[0],o=n[1];"default"!==i&&(u[i]=o)})),u}();

@@ -202,2 +202,3 @@ 'use strict';function _typeof(obj) {

fixDeleteKey: Boolean(this.options.fixDeleteKey === undefined || this.options.fixDeleteKey),
fixBlankKey: Boolean(this.options.fixBlankKey === undefined || this.options.fixBlankKey),
stopPropagation: Boolean(this.options.stopPropagation === undefined || this.options.stopPropagation),

@@ -249,2 +250,3 @@ keypadClass: this.options.keypadClass || 'numeric-keypad',

this.fixDeleteKey = Boolean(options.fixDeleteKey === undefined || options.fixDeleteKey);
this.fixBlankKey = Boolean(options.fixBlankKey === undefined || options.fixBlankKey);
this.stopPropagation = Boolean(options.stopPropagation === undefined || options.stopPropagation);

@@ -359,35 +361,31 @@ this.activeButtonDelay = Number(options.activeButtonDelay) || 300;

randomize: function randomize() {
var newkeyArray = [];
var delKeyCnt = 0;
var clearKeyCnt = 0;
var l = this.keyArray.length;
for (var i = 0; i < this.keyArray.length; i++) {
var r = Math.random();
var newkeyArray = _toConsumableArray(this.keyArray);
if (this.fixDeleteKey && this.keyArray[i] == -1) {
delKeyCnt++;
continue;
}
for (var i = 0; i < l; i++) {
var key = newkeyArray[i];
if (this.checkFix(key)) continue;
var r = Math.floor(Math.random() * l);
if (r == i) r = (r + 1) % l;
var count = 0;
if (this.fixDeleteKey && this.keyArray[i] == -2) {
clearKeyCnt++;
continue;
while ((this.checkFix(newkeyArray[r]) || newkeyArray[r] === newkeyArray[i]) && count < l) {
r = (r + 1) % l;
count++;
}
if (r < 0.5) newkeyArray.push(this.keyArray[i]);else newkeyArray.unshift(this.keyArray[i]);
if (count >= l) continue;
newkeyArray[i] = newkeyArray[r];
newkeyArray[r] = key;
}
if (delKeyCnt) {
for (var _i = 0; _i < delKeyCnt; _i++) {
newkeyArray.push(-1);
}
}
if (clearKeyCnt) {
for (var _i2 = 0; _i2 < clearKeyCnt; _i2++) {
newkeyArray.push(-2);
}
}
this.keyArray = newkeyArray;
},
checkFix: function checkFix(key) {
if (key === '' && this.fixBlankKey) return true;
if (key === -1 && this.fixDeleteKey) return true;
if (key === -2 && this.fixDeleteKey) return true;
return false;
},
showKey: function showKey(key) {

@@ -602,3 +600,3 @@ if (key === -1) {

var __vue_module_identifier__ = "data-v-75b866b0";
var __vue_module_identifier__ = "data-v-c821e51a";
/* functional template */

@@ -605,0 +603,0 @@

{
"name": "vue-numeric-keypad",
"version": "1.2.5",
"version": "1.2.6",
"description": "The virtual numeric keypad that can be used on Vue.",

@@ -5,0 +5,0 @@ "main": "dist/vue-numeric-keypad.ssr.js",

@@ -97,3 +97,4 @@ # Vue Numeric Keypad [![npm](https://img.shields.io/npm/v/vue-numeric-keypad)](https://www.npmjs.com/package/vue-numeric-keypad) [![npm dev dependency version](https://img.shields.io/npm/dependency-version/vue-numeric-keypad/dev/vue)](https://www.npmjs.com/package/vue/v/2.6.14)

|`randomizeWhenClick`|If the value is true and `keyRandomize` is true, randomize the key array whenever you press the key.|Boolean|false|
|`fixDeleteKey`|The delete key is fixed at the end when the key array is randomized.|Boolean|true|
|`fixDeleteKey`|The delete key is fixed when the key array is randomized.|Boolean|true|
|`fixBlankKey`|The Blank key is fixed when the key array is randomized.|Boolean|true|
|`zIndex`|Sets the z-index value.<br>Valid when `keypadStyles` is the default.|Number|1|

@@ -100,0 +101,0 @@ |`rows`|Sets the number of rows in the key array.<br>Valid when `buttonWrapStyles` is the default.|Number|4|

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc