From 00e3618d3550f568a04f48d0aae4d804e04eeebe Mon Sep 17 00:00:00 2001 From: sanniassin Date: Tue, 4 Jul 2017 13:30:16 +0300 Subject: [PATCH] version 1.0.3 --- dist/react-input-mask.js | 4 ++-- dist/react-input-mask.min.js | 2 +- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/react-input-mask.js b/dist/react-input-mask.js index 2b170fe..87f559c 100644 --- a/dist/react-input-mask.js +++ b/dist/react-input-mask.js @@ -374,7 +374,7 @@ var _initialiseProps = function _initialiseProps() { _this2.isWindowsPhoneBrowser = isWindowsPhoneBrowser(); _this2.isAndroidFirefox = isAndroidFirefox(); - if (_this2.getInputValue() !== _this2.value) { + if (_this2.maskOptions.mask && _this2.getInputValue() !== _this2.value) { _this2.setInputValue(_this2.value); } }; @@ -423,7 +423,7 @@ var _initialiseProps = function _initialiseProps() { }; this.componentDidUpdate = function () { - if (_this2.getInputValue() !== _this2.value) { + if (_this2.maskOptions.mask && _this2.getInputValue() !== _this2.value) { _this2.setInputValue(_this2.value); } }; diff --git a/dist/react-input-mask.min.js b/dist/react-input-mask.min.js index bf5c6b5..83e69f2 100644 --- a/dist/react-input-mask.min.js +++ b/dist/react-input-mask.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):e.ReactInputMask=t(e.React)}(this,function(e){"use strict";function t(){var e=new RegExp("windows","i"),t=new RegExp("firefox","i"),n=new RegExp("android","i"),o=navigator.userAgent;return!e.test(o)&&!t.test(o)&&n.test(o)}function n(){var e=new RegExp("windows","i"),t=new RegExp("phone","i"),n=navigator.userAgent;return e.test(n)&&t.test(n)}function o(){var e=new RegExp("windows","i"),t=new RegExp("firefox","i"),n=new RegExp("android","i"),o=navigator.userAgent;return!e.test(o)&&t.test(o)&&n.test(o)}function s(e,t){return-1!==e.permanents.indexOf(t)}function a(e,t,n){var o=e.mask,a=e.charsRules;if(!n)return!1;if(s(e,t))return o[t]===n;var r=a[o[t]];return new RegExp(r).test(n)}function r(e,t){return t.split("").every(function(t,n){return s(e,n)||!a(e,n,t)})}function i(e,t){var n=e.maskChar,o=e.prefix;if(!n){for(;t.length>o.length&&s(e,t.length-1);)t=t.slice(0,t.length-1);return t.length}for(var r=o.length,i=t.length;i>=o.length;i--){var u=t[i];if(!s(e,i)&&a(e,i,u)){r=i+1;break}}return r}function u(e,t){return i(e,t)===e.mask.length}function l(e,t){var n=e.maskChar,o=e.mask,a=e.prefix;if(!n)return t=c(e,"",t,0),(t=t.slice(0,i(e,t))).length=a?t:s(e,o)?i[o]:r}).join(""):(n=Math.max(u.length,n),p.splice(n,a-n),t=p.join(""),l(e,t))}function c(e,t,n,o){var r=e.mask,i=e.maskChar,p=e.prefix,c=n.split(""),f=u(e,t),h=function(t,n){return!s(e,t)||n===r[t]},m=function(t,n){return!i||!s(e,n)||t!==i};return!i&&o>t.length&&(t+=r.slice(t.length,o)),c.every(function(n){for(;!h(o,n);){if(o>=t.length&&(t+=r[o]),!m(n,o))return!0;if(++o>=r.length)return!1}return!a(e,o,n)&&n!==i||(o=r.length)return!1;return(a(e,o,t)||t===i)&&o++,o=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function v(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e="default"in e?e["default"]:e;var d={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},k=function(e,t,n){if(t===undefined&&(t="_"),null==n&&(n=d),!e||"string"!=typeof e)return{maskChar:t,charsRules:n,mask:null,prefix:null,lastEditablePos:null,permanents:[]};var o="",s="",a=[],r=!1,i=null;return e.split("").forEach(function(e){r||"\\"!==e?(r||!n[e]?(a.push(o.length),o.length===a.length-1&&(s+=e)):i=o.length+1,o+=e,r=!1):r=!0}),{maskChar:t,charsRules:n,prefix:s,mask:o,lastEditablePos:i,permanents:a}},O=function(e){return(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){return setTimeout(e,0)})(e)},y=Object.assign||function(e){for(var t=1;t=0;--t)if(!s(a.maskOptions,t))return t;return null},this.getRightEditablePos=function(e){for(var t=a.maskOptions.mask,n=e;n1&&arguments[1]!==undefined?arguments[1]:0,n=a.getInputDOMNode();if(n){var o=e+t;if("selectionStart"in n&&"selectionEnd"in n)n.selectionStart=e,n.selectionEnd=o;else{var s=n.createTextRange();s.collapse(!0),s.moveStart("character",e),s.moveEnd("character",o-e),s.select()}}},this.getSelection=function(){var e=a.getInputDOMNode(),t=0,n=0;if("selectionStart"in e&&"selectionEnd"in e)t=e.selectionStart,n=e.selectionEnd;else{var o=document.selection.createRange();o.parentElement()===e&&(t=-o.moveStart("character",-e.value.length),n=-o.moveEnd("character",-e.value.length))}return{start:t,end:n,length:n-t}},this.getCursorPos=function(){return a.getSelection().start},this.setCursorPos=function(e){a.setSelection(e,0),O(function(){a.setSelection(e,0)}),a.lastCursorPos=e},this.isFocused=function(){return document.activeElement===a.getInputDOMNode()},this.getStringValue=function(e){return e||0===e?e+"":""},this.onKeyDown=function(e){a.backspaceOrDeleteRemoval=null,"function"==typeof a.props.onKeyDown&&a.props.onKeyDown(e);var t=e.key,n=e.ctrlKey,o=e.metaKey,s=e.defaultPrevented;n||o||s||"Backspace"!==t&&"Delete"!==t||(a.backspaceOrDeleteRemoval={key:t,selection:a.getSelection()},O(function(){a.backspaceOrDeleteRemoval=null}))},this.onChange=function(e){var t=a.paste,n=a.maskOptions,o=n.mask,s=n.maskChar,r=n.lastEditablePos,u=n.prefix,f=a.getInputValue(),h=a.value;if(t)return a.paste=null,void a.pasteText(t.value,f,t.selection,e);var m,g,v=a.getSelection(),d=v.end,k=o.length,y=f.length,b=h.length;if(a.backspaceOrDeleteRemoval){var w="Delete"===a.backspaceOrDeleteRemoval.key;if(f=a.value,v=a.backspaceOrDeleteRemoval.selection,d=v.start,a.backspaceOrDeleteRemoval=null,v.length)f=p(a.maskOptions,f,v.start,v.length);else if(v.startb){var C=y-b,P=v.end-C;g=f.substr(P,C),d=P=u.length&&ds.length&&o(e,t.length-1);)t=t.slice(0,t.length-1);return t.length}for(var r=s.length,i=t.length;i>=s.length;i--){var u=t[i];if(!o(e,i)&&a(e,i,u)){r=i+1;break}}return r}function u(e,t){return i(e,t)===e.mask.length}function l(e,t){var n=e.maskChar,s=e.mask,a=e.prefix;if(!n)return t=c(e,"",t,0),(t=t.slice(0,i(e,t))).length=a?t:o(e,s)?i[s]:r}).join(""):(n=Math.max(u.length,n),p.splice(n,a-n),t=p.join(""),l(e,t))}function c(e,t,n,s){var r=e.mask,i=e.maskChar,p=e.prefix,c=n.split(""),f=u(e,t),h=function(t,n){return!o(e,t)||n===r[t]},m=function(t,n){return!i||!o(e,n)||t!==i};return!i&&s>t.length&&(t+=r.slice(t.length,s)),c.every(function(n){for(;!h(s,n);){if(s>=t.length&&(t+=r[s]),!m(n,s))return!0;if(++s>=r.length)return!1}return!a(e,s,n)&&n!==i||(s=r.length)return!1;return(a(e,s,t)||t===i)&&s++,s=0||Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s]);return n}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function v(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e="default"in e?e["default"]:e;var k={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},d=function(e,t,n){if(t===undefined&&(t="_"),null==n&&(n=k),!e||"string"!=typeof e)return{maskChar:t,charsRules:n,mask:null,prefix:null,lastEditablePos:null,permanents:[]};var s="",o="",a=[],r=!1,i=null;return e.split("").forEach(function(e){r||"\\"!==e?(r||!n[e]?(a.push(s.length),s.length===a.length-1&&(o+=e)):i=s.length+1,s+=e,r=!1):r=!0}),{maskChar:t,charsRules:n,prefix:o,mask:s,lastEditablePos:i,permanents:a}},O=function(e){return(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){return setTimeout(e,0)})(e)},y=Object.assign||function(e){for(var t=1;t=0;--t)if(!o(a.maskOptions,t))return t;return null},this.getRightEditablePos=function(e){for(var t=a.maskOptions.mask,n=e;n1&&arguments[1]!==undefined?arguments[1]:0,n=a.getInputDOMNode();if(n){var s=e+t;if("selectionStart"in n&&"selectionEnd"in n)n.selectionStart=e,n.selectionEnd=s;else{var o=n.createTextRange();o.collapse(!0),o.moveStart("character",e),o.moveEnd("character",s-e),o.select()}}},this.getSelection=function(){var e=a.getInputDOMNode(),t=0,n=0;if("selectionStart"in e&&"selectionEnd"in e)t=e.selectionStart,n=e.selectionEnd;else{var s=document.selection.createRange();s.parentElement()===e&&(t=-s.moveStart("character",-e.value.length),n=-s.moveEnd("character",-e.value.length))}return{start:t,end:n,length:n-t}},this.getCursorPos=function(){return a.getSelection().start},this.setCursorPos=function(e){a.setSelection(e,0),O(function(){a.setSelection(e,0)}),a.lastCursorPos=e},this.isFocused=function(){return document.activeElement===a.getInputDOMNode()},this.getStringValue=function(e){return e||0===e?e+"":""},this.onKeyDown=function(e){a.backspaceOrDeleteRemoval=null,"function"==typeof a.props.onKeyDown&&a.props.onKeyDown(e);var t=e.key,n=e.ctrlKey,s=e.metaKey,o=e.defaultPrevented;n||s||o||"Backspace"!==t&&"Delete"!==t||(a.backspaceOrDeleteRemoval={key:t,selection:a.getSelection()},O(function(){a.backspaceOrDeleteRemoval=null}))},this.onChange=function(e){var t=a.paste,n=a.maskOptions,s=n.mask,o=n.maskChar,r=n.lastEditablePos,u=n.prefix,f=a.getInputValue(),h=a.value;if(t)return a.paste=null,void a.pasteText(t.value,f,t.selection,e);var m,g,v=a.getSelection(),k=v.end,d=s.length,y=f.length,b=h.length;if(a.backspaceOrDeleteRemoval){var w="Delete"===a.backspaceOrDeleteRemoval.key;if(f=a.value,v=a.backspaceOrDeleteRemoval.selection,k=v.start,a.backspaceOrDeleteRemoval=null,v.length)f=p(a.maskOptions,f,v.start,v.length);else if(v.startb){var C=y-b,P=v.end-C;g=f.substr(P,C),k=P=u.length&&k",