New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-maskedinput

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-maskedinput - npm Package Compare versions

Comparing version 3.3.2 to 3.3.3

46

es6/index.js

@@ -5,3 +5,3 @@ 'use strict';

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

@@ -241,2 +241,14 @@ var React = require('react');

_keyPressPropName: function _keyPressPropName() {
return navigator.userAgent.match(/Android/i) ? 'onBeforeInput' : 'onKeyPress';
},
_getEventHandlers: function _getEventHandlers() {
return _defineProperty({
onChange: this._onChange,
onKeyDown: this._onKeyDown,
onPaste: this._onPaste
}, this._keyPressPropName(), this._onKeyPress);
},
focus: function focus() {

@@ -253,25 +265,17 @@ this.input.focus();

var ref = function ref(r) {
return _this.input = r;
};
var maxLength = this.mask.pattern.length;
var value = this._getDisplayValue();
var eventHandlers = this._getEventHandlers();
var _props = this.props;
var mask = _props.mask;
var formatCharacters = _props.formatCharacters;
var size = _props.size;
var placeholder = _props.placeholder;
var placeholderChar = _props.placeholderChar;
var _props$size = _props.size;
var size = _props$size === undefined ? maxLength : _props$size;
var _props$placeholder = _props.placeholder;
var placeholder = _props$placeholder === undefined ? this.mask.emptyValue : _props$placeholder;
var props = _objectWithoutProperties(_props, ['mask', 'formatCharacters', 'size', 'placeholder', 'placeholderChar']);
var props = _extends({}, this.props, eventHandlers, { ref: ref, maxLength: maxLength, value: value, size: size, placeholder: placeholder });
var patternLength = this.mask.pattern.length;
return React.createElement('input', _extends({}, props, {
ref: function (r) {
return _this.input = r;
},
maxLength: patternLength,
onChange: this._onChange,
onKeyDown: this._onKeyDown,
onBeforeInput: this._onKeyPress,
onPaste: this._onPaste,
placeholder: placeholder || this.mask.emptyValue,
size: size || patternLength,
value: this._getDisplayValue()
}));
return React.createElement('input', props);
}

@@ -278,0 +282,0 @@ });

@@ -5,3 +5,3 @@ 'use strict';

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

@@ -241,2 +241,14 @@ var React = require('react');

_keyPressPropName: function _keyPressPropName() {
return navigator.userAgent.match(/Android/i) ? 'onBeforeInput' : 'onKeyPress';
},
_getEventHandlers: function _getEventHandlers() {
return _defineProperty({
onChange: this._onChange,
onKeyDown: this._onKeyDown,
onPaste: this._onPaste
}, this._keyPressPropName(), this._onKeyPress);
},
focus: function focus() {

@@ -253,25 +265,17 @@ this.input.focus();

var ref = function ref(r) {
return _this.input = r;
};
var maxLength = this.mask.pattern.length;
var value = this._getDisplayValue();
var eventHandlers = this._getEventHandlers();
var _props = this.props;
var mask = _props.mask;
var formatCharacters = _props.formatCharacters;
var size = _props.size;
var placeholder = _props.placeholder;
var placeholderChar = _props.placeholderChar;
var _props$size = _props.size;
var size = _props$size === undefined ? maxLength : _props$size;
var _props$placeholder = _props.placeholder;
var placeholder = _props$placeholder === undefined ? this.mask.emptyValue : _props$placeholder;
var props = _objectWithoutProperties(_props, ['mask', 'formatCharacters', 'size', 'placeholder', 'placeholderChar']);
var props = _extends({}, this.props, eventHandlers, { ref: ref, maxLength: maxLength, value: value, size: size, placeholder: placeholder });
var patternLength = this.mask.pattern.length;
return React.createElement('input', _extends({}, props, {
ref: function (r) {
return _this.input = r;
},
maxLength: patternLength,
onChange: this._onChange,
onKeyDown: this._onKeyDown,
onBeforeInput: this._onKeyPress,
onPaste: this._onPaste,
placeholder: placeholder || this.mask.emptyValue,
size: size || patternLength,
value: this._getDisplayValue()
}));
return React.createElement('input', props);
}

@@ -278,0 +282,0 @@ });

{
"name": "react-maskedinput",
"description": "Masked <input/> React component",
"version": "3.3.2",
"version": "3.3.3",
"main": "./lib/index.js",

@@ -6,0 +6,0 @@ "jsnext:main": "es6/index.js",

/*!
* react-maskedinput 3.3.1 - https://github.com/insin/react-maskedinput
* react-maskedinput 3.3.2 - https://github.com/insin/react-maskedinput
* MIT Licensed

@@ -65,3 +65,3 @@ */

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

@@ -301,2 +301,14 @@ var React = __webpack_require__(2);

_keyPressPropName: function _keyPressPropName() {
return navigator.userAgent.match(/Android/i) ? 'onBeforeInput' : 'onKeyPress';
},
_getEventHandlers: function _getEventHandlers() {
return _defineProperty({
onChange: this._onChange,
onKeyDown: this._onKeyDown,
onPaste: this._onPaste
}, this._keyPressPropName(), this._onKeyPress);
},
focus: function focus() {

@@ -313,25 +325,17 @@ this.input.focus();

var ref = function ref(r) {
return _this.input = r;
};
var maxLength = this.mask.pattern.length;
var value = this._getDisplayValue();
var eventHandlers = this._getEventHandlers();
var _props = this.props;
var mask = _props.mask;
var formatCharacters = _props.formatCharacters;
var size = _props.size;
var placeholder = _props.placeholder;
var placeholderChar = _props.placeholderChar;
var _props$size = _props.size;
var size = _props$size === undefined ? maxLength : _props$size;
var _props$placeholder = _props.placeholder;
var placeholder = _props$placeholder === undefined ? this.mask.emptyValue : _props$placeholder;
var props = _objectWithoutProperties(_props, ['mask', 'formatCharacters', 'size', 'placeholder', 'placeholderChar']);
var props = _extends({}, this.props, eventHandlers, { ref: ref, maxLength: maxLength, value: value, size: size, placeholder: placeholder });
var patternLength = this.mask.pattern.length;
return React.createElement('input', _extends({}, props, {
ref: function (r) {
return _this.input = r;
},
maxLength: patternLength,
onChange: this._onChange,
onKeyDown: this._onKeyDown,
onBeforeInput: this._onKeyPress,
onPaste: this._onPaste,
placeholder: placeholder || this.mask.emptyValue,
size: size || patternLength,
value: this._getDisplayValue()
}));
return React.createElement('input', props);
}

@@ -338,0 +342,0 @@ });

/*!
* react-maskedinput 3.3.1 - https://github.com/insin/react-maskedinput
* react-maskedinput 3.3.2 - https://github.com/insin/react-maskedinput
* MIT Licensed
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.MaskedInput=e(require("react")):t.MaskedInput=e(t.React)}(this,function(t){return function(t){function e(i){if(s[i])return s[i].exports;var a=s[i]={exports:{},id:i,loaded:!1};return t[i].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var s={};return e.m=t,e.c=s,e.p="",e(0)}([function(t,e,s){"use strict";function i(t,e){var s={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(s[i]=t[i]);return s}function a(t){return(t.ctrlKey||t.metaKey)&&t.keyCode===(t.shiftKey?c:u)}function n(t){return(t.ctrlKey||t.metaKey)&&t.keyCode===(t.shiftKey?u:c)}function r(t){var e,s,i,a;if(void 0!==t.selectionStart)e=t.selectionStart,s=t.selectionEnd;else try{t.focus(),i=t.createTextRange(),a=i.duplicate(),i.moveToBookmark(document.selection.createRange().getBookmark()),a.setEndPoint("EndToStart",i),e=a.text.length,s=e+i.text.length}catch(n){}return{start:e,end:s}}function o(t,e){var s;try{void 0!==t.selectionStart?(t.focus(),t.setSelectionRange(e.start,e.end)):(t.focus(),s=t.createTextRange(),s.collapse(!0),s.moveStart("character",e.start),s.moveEnd("character",e.end-e.start),s.select())}catch(i){}}var h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},l=s(2),p=s(1),u=90,c=89,d=l.createClass({displayName:"MaskedInput",propTypes:{mask:l.PropTypes.string.isRequired,formatCharacters:l.PropTypes.object,placeholderChar:l.PropTypes.string},getDefaultProps:function(){return{value:""}},componentWillMount:function(){var t={pattern:this.props.mask,value:this.props.value,formatCharacters:this.props.formatCharacters};this.props.placeholderChar&&(t.placeholderChar=this.props.placeholderChar),this.mask=new p(t)},componentWillReceiveProps:function(t){this.props.mask!==t.mask&&this.props.value!==t.mask?this.mask.getValue()===this.mask.emptyValue?this.mask.setPattern(t.mask,{value:t.value}):this.mask.setPattern(t.mask,{value:this.mask.getRawValue()}):this.props.mask!==t.mask?this.mask.setPattern(t.mask,{value:this.mask.getRawValue()}):this.props.value!==t.value&&this.mask.setValue(t.value)},componentWillUpdate:function(t,e){t.mask!==this.props.mask&&this._updatePattern(t)},componentDidUpdate:function(t){t.mask!==this.props.mask&&this.mask.selection.start&&this._updateInputSelection()},_updatePattern:function(t){this.mask.setPattern(t.mask,{value:this.mask.getRawValue(),selection:r(this.input)})},_updateMaskSelection:function(){this.mask.selection=r(this.input)},_updateInputSelection:function(){o(this.input,this.mask.selection)},_onChange:function(t){var e=this.mask.getValue();if(t.target.value!==e){if(t.target.value.length<e.length){var s=e.length-t.target.value.length;this._updateMaskSelection(),this.mask.selection.end=this.mask.selection.start+s,this.mask.backspace()}var i=this._getDisplayValue();t.target.value=i,i&&this._updateInputSelection()}this.props.onChange&&this.props.onChange(t)},_onKeyDown:function(t){if(a(t))return t.preventDefault(),void(this.mask.undo()&&(t.target.value=this._getDisplayValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(t)));if(n(t))return t.preventDefault(),void(this.mask.redo()&&(t.target.value=this._getDisplayValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(t)));if("Backspace"===t.key&&(t.preventDefault(),this._updateMaskSelection(),this.mask.backspace())){var e=this._getDisplayValue();t.target.value=e,e&&this._updateInputSelection(),this.props.onChange&&this.props.onChange(t)}},_onKeyPress:function(t){t.metaKey||t.altKey||t.ctrlKey||"Enter"===t.key||(t.preventDefault(),this._updateMaskSelection(),this.mask.input(t.key||t.data)&&(t.target.value=this.mask.getValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(t)))},_onPaste:function(t){t.preventDefault(),this._updateMaskSelection(),this.mask.paste(t.clipboardData.getData("Text"))&&(t.target.value=this.mask.getValue(),setTimeout(this._updateInputSelection,0),this.props.onChange&&this.props.onChange(t))},_getDisplayValue:function(){var t=this.mask.getValue();return t===this.mask.emptyValue?"":t},focus:function(){this.input.focus()},blur:function(){this.input.blur()},render:function(){var t=this,e=this.props,s=(e.mask,e.formatCharacters,e.size),a=e.placeholder,n=(e.placeholderChar,i(e,["mask","formatCharacters","size","placeholder","placeholderChar"])),r=this.mask.pattern.length;return l.createElement("input",h({},n,{ref:function(e){return t.input=e},maxLength:r,onChange:this._onChange,onKeyDown:this._onKeyDown,onBeforeInput:this._onKeyPress,onPaste:this._onPaste,placeholder:a||this.mask.emptyValue,size:s||r,value:this._getDisplayValue()}))}});t.exports=d},function(t,e){"use strict";function s(t,e){if(e)for(var s=Object.keys(e),i=0,a=s.length;i<a;i++)t[s[i]]=e[s[i]];return t}function i(t){return s({},t)}function a(t){var e=i(c);if(t)for(var s=Object.keys(t),a=0,n=s.length;a<n;a++){var r=s[a];null==t[r]?delete e[r]:e[r]=t[r]}return e}function n(t,e,s,i){return this instanceof n?(this.placeholderChar=s||u,this.formatCharacters=e||c,this.source=t,this.pattern=[],this.length=0,this.firstEditableIndex=null,this.lastEditableIndex=null,this._editableIndices={},this.isRevealingMask=i||!1,void this._parse()):new n(t,e,s)}function r(t){if(!(this instanceof r))return new r(t);if(t=s({formatCharacters:null,pattern:null,isRevealingMask:!1,placeholderChar:u,selection:{start:0,end:0},value:""},t),null==t.pattern)throw new Error("InputMask: you must provide a pattern.");if("string"!=typeof t.placeholderChar||t.placeholderChar.length>1)throw new Error("InputMask: placeholderChar should be a single character or an empty string.");this.placeholderChar=t.placeholderChar,this.formatCharacters=a(t.formatCharacters),this.setPattern(t.pattern,{value:t.value,selection:t.selection,isRevealingMask:t.isRevealingMask})}var o="\\",h=/^\d$/,l=/^[A-Za-z]$/,p=/^[\dA-Za-z]$/,u="_",c={"*":{validate:function(t){return p.test(t)}},1:{validate:function(t){return h.test(t)}},a:{validate:function(t){return l.test(t)}},A:{validate:function(t){return l.test(t)},transform:function(t){return t.toUpperCase()}},"#":{validate:function(t){return p.test(t)},transform:function(t){return t.toUpperCase()}}};n.prototype._parse=function(){for(var t=this.source.split(""),e=0,s=[],i=0,a=t.length;i<a;i++){var n=t[i];if(n===o){if(i===a-1)throw new Error("InputMask: pattern ends with a raw "+o);n=t[++i]}else n in this.formatCharacters&&(null===this.firstEditableIndex&&(this.firstEditableIndex=e),this.lastEditableIndex=e,this._editableIndices[e]=!0);s.push(n),e++}if(null===this.firstEditableIndex)throw new Error('InputMask: pattern "'+this.source+'" does not contain any editable characters.');this.pattern=s,this.length=s.length},n.prototype.formatValue=function(t){for(var e=new Array(this.length),s=0,i=0,a=this.length;i<a;i++)if(this.isEditableIndex(i)){if(this.isRevealingMask&&t.length<=s&&!this.isValidAtIndex(t[s],i))break;e[i]=t.length>s&&this.isValidAtIndex(t[s],i)?this.transform(t[s],i):this.placeholderChar,s++}else e[i]=this.pattern[i],t.length>s&&t[s]===this.pattern[i]&&s++;return e},n.prototype.isEditableIndex=function(t){return!!this._editableIndices[t]},n.prototype.isValidAtIndex=function(t,e){return this.formatCharacters[this.pattern[e]].validate(t)},n.prototype.transform=function(t,e){var s=this.formatCharacters[this.pattern[e]];return"function"==typeof s.transform?s.transform(t):t},r.prototype.input=function(t){if(this.selection.start===this.selection.end&&this.selection.start===this.pattern.length)return!1;var e=i(this.selection),s=this.getValue(),a=this.selection.start;if(a<this.pattern.firstEditableIndex&&(a=this.pattern.firstEditableIndex),this.pattern.isEditableIndex(a)){if(!this.pattern.isValidAtIndex(t,a))return!1;this.value[a]=this.pattern.transform(t,a)}for(var n=this.selection.end-1;n>a;)this.pattern.isEditableIndex(n)&&(this.value[n]=this.placeholderChar),n--;for(this.selection.start=this.selection.end=a+1;this.pattern.length>this.selection.start&&!this.pattern.isEditableIndex(this.selection.start);)this.selection.start++,this.selection.end++;return null!=this._historyIndex&&(this._history.splice(this._historyIndex,this._history.length-this._historyIndex),this._historyIndex=null),("input"!==this._lastOp||e.start!==e.end||null!==this._lastSelection&&e.start!==this._lastSelection.start)&&this._history.push({value:s,selection:e,lastOp:this._lastOp}),this._lastOp="input",this._lastSelection=i(this.selection),!0},r.prototype.backspace=function(){if(0===this.selection.start&&0===this.selection.end)return!1;var t=i(this.selection),e=this.getValue();if(this.selection.start===this.selection.end)this.pattern.isEditableIndex(this.selection.start-1)&&(this.value[this.selection.start-1]=this.placeholderChar),this.selection.start--,this.selection.end--;else{for(var s=this.selection.end-1;s>=this.selection.start;)this.pattern.isEditableIndex(s)&&(this.value[s]=this.placeholderChar),s--;this.selection.end=this.selection.start}return null!=this._historyIndex&&this._history.splice(this._historyIndex,this._history.length-this._historyIndex),("backspace"!==this._lastOp||t.start!==t.end||null!==this._lastSelection&&t.start!==this._lastSelection.start)&&this._history.push({value:e,selection:t,lastOp:this._lastOp}),this._lastOp="backspace",this._lastSelection=i(this.selection),!0},r.prototype.paste=function(t){var e={value:this.value.slice(),selection:i(this.selection),_lastOp:this._lastOp,_history:this._history.slice(),_historyIndex:this._historyIndex,_lastSelection:i(this._lastSelection)};if(this.selection.start<this.pattern.firstEditableIndex){for(var a=0,n=this.pattern.firstEditableIndex-this.selection.start;a<n;a++)if(t.charAt(a)!==this.pattern.pattern[a])return!1;t=t.substring(this.pattern.firstEditableIndex-this.selection.start),this.selection.start=this.pattern.firstEditableIndex}for(a=0,n=t.length;a<n&&this.selection.start<=this.pattern.lastEditableIndex;a++){var r=this.input(t.charAt(a));if(!r){if(this.selection.start>0){var o=this.selection.start-1;if(!this.pattern.isEditableIndex(o)&&t.charAt(a)===this.pattern.pattern[o])continue}return s(this,e),!1}}return!0},r.prototype.undo=function(){if(0===this._history.length||0===this._historyIndex)return!1;var t;if(null==this._historyIndex){this._historyIndex=this._history.length-1,t=this._history[this._historyIndex];var e=this.getValue();t.value===e&&t.selection.start===this.selection.start&&t.selection.end===this.selection.end||this._history.push({value:e,selection:i(this.selection),lastOp:this._lastOp,startUndo:!0})}else t=this._history[--this._historyIndex];return this.value=t.value.split(""),this.selection=t.selection,this._lastOp=t.lastOp,!0},r.prototype.redo=function(){if(0===this._history.length||null==this._historyIndex)return!1;var t=this._history[++this._historyIndex];return this._historyIndex===this._history.length-1&&(this._historyIndex=null,t.startUndo&&this._history.pop()),this.value=t.value.split(""),this.selection=t.selection,this._lastOp=t.lastOp,!0},r.prototype.setPattern=function(t,e){e=s({selection:{start:0,end:0},value:""},e),this.pattern=new n(t,this.formatCharacters,this.placeholderChar,e.isRevealingMask),this.setValue(e.value),this.emptyValue=this.pattern.formatValue([]).join(""),this.selection=e.selection,this._resetHistory()},r.prototype.setSelection=function(t){if(this.selection=i(t),this.selection.start===this.selection.end){if(this.selection.start<this.pattern.firstEditableIndex)return this.selection.start=this.selection.end=this.pattern.firstEditableIndex,!0;for(var e=this.selection.start;e>=this.pattern.firstEditableIndex;){if(this.pattern.isEditableIndex(e-1)&&this.value[e-1]!==this.placeholderChar||e===this.pattern.firstEditableIndex){this.selection.start=this.selection.end=e;break}e--}return!0}return!1},r.prototype.setValue=function(t){null==t&&(t=""),this.value=this.pattern.formatValue(t.split(""))},r.prototype.getValue=function(){return this.value.join("")},r.prototype.getRawValue=function(){for(var t=[],e=0;e<this.value.length;e++)this.pattern._editableIndices[e]===!0&&t.push(this.value[e]);return t.join("")},r.prototype._resetHistory=function(){this._history=[],this._historyIndex=null,this._lastOp=null,this._lastSelection=i(this.selection)},r.Pattern=n,t.exports=r},function(e,s){e.exports=t}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.MaskedInput=e(require("react")):t.MaskedInput=e(t.React)}(this,function(t){return function(t){function e(i){if(s[i])return s[i].exports;var n=s[i]={exports:{},id:i,loaded:!1};return t[i].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var s={};return e.m=t,e.c=s,e.p="",e(0)}([function(t,e,s){"use strict";function i(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function n(t){return(t.ctrlKey||t.metaKey)&&t.keyCode===(t.shiftKey?c:u)}function a(t){return(t.ctrlKey||t.metaKey)&&t.keyCode===(t.shiftKey?u:c)}function r(t){var e,s,i,n;if(void 0!==t.selectionStart)e=t.selectionStart,s=t.selectionEnd;else try{t.focus(),i=t.createTextRange(),n=i.duplicate(),i.moveToBookmark(document.selection.createRange().getBookmark()),n.setEndPoint("EndToStart",i),e=n.text.length,s=e+i.text.length}catch(a){}return{start:e,end:s}}function o(t,e){var s;try{void 0!==t.selectionStart?(t.focus(),t.setSelectionRange(e.start,e.end)):(t.focus(),s=t.createTextRange(),s.collapse(!0),s.moveStart("character",e.start),s.moveEnd("character",e.end-e.start),s.select())}catch(i){}}var h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},l=s(2),p=s(1),u=90,c=89,d=l.createClass({displayName:"MaskedInput",propTypes:{mask:l.PropTypes.string.isRequired,formatCharacters:l.PropTypes.object,placeholderChar:l.PropTypes.string},getDefaultProps:function(){return{value:""}},componentWillMount:function(){var t={pattern:this.props.mask,value:this.props.value,formatCharacters:this.props.formatCharacters};this.props.placeholderChar&&(t.placeholderChar=this.props.placeholderChar),this.mask=new p(t)},componentWillReceiveProps:function(t){this.props.mask!==t.mask&&this.props.value!==t.mask?this.mask.getValue()===this.mask.emptyValue?this.mask.setPattern(t.mask,{value:t.value}):this.mask.setPattern(t.mask,{value:this.mask.getRawValue()}):this.props.mask!==t.mask?this.mask.setPattern(t.mask,{value:this.mask.getRawValue()}):this.props.value!==t.value&&this.mask.setValue(t.value)},componentWillUpdate:function(t,e){t.mask!==this.props.mask&&this._updatePattern(t)},componentDidUpdate:function(t){t.mask!==this.props.mask&&this.mask.selection.start&&this._updateInputSelection()},_updatePattern:function(t){this.mask.setPattern(t.mask,{value:this.mask.getRawValue(),selection:r(this.input)})},_updateMaskSelection:function(){this.mask.selection=r(this.input)},_updateInputSelection:function(){o(this.input,this.mask.selection)},_onChange:function(t){var e=this.mask.getValue();if(t.target.value!==e){if(t.target.value.length<e.length){var s=e.length-t.target.value.length;this._updateMaskSelection(),this.mask.selection.end=this.mask.selection.start+s,this.mask.backspace()}var i=this._getDisplayValue();t.target.value=i,i&&this._updateInputSelection()}this.props.onChange&&this.props.onChange(t)},_onKeyDown:function(t){if(n(t))return t.preventDefault(),void(this.mask.undo()&&(t.target.value=this._getDisplayValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(t)));if(a(t))return t.preventDefault(),void(this.mask.redo()&&(t.target.value=this._getDisplayValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(t)));if("Backspace"===t.key&&(t.preventDefault(),this._updateMaskSelection(),this.mask.backspace())){var e=this._getDisplayValue();t.target.value=e,e&&this._updateInputSelection(),this.props.onChange&&this.props.onChange(t)}},_onKeyPress:function(t){t.metaKey||t.altKey||t.ctrlKey||"Enter"===t.key||(t.preventDefault(),this._updateMaskSelection(),this.mask.input(t.key||t.data)&&(t.target.value=this.mask.getValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(t)))},_onPaste:function(t){t.preventDefault(),this._updateMaskSelection(),this.mask.paste(t.clipboardData.getData("Text"))&&(t.target.value=this.mask.getValue(),setTimeout(this._updateInputSelection,0),this.props.onChange&&this.props.onChange(t))},_getDisplayValue:function(){var t=this.mask.getValue();return t===this.mask.emptyValue?"":t},_keyPressPropName:function(){return navigator.userAgent.match(/Android/i)?"onBeforeInput":"onKeyPress"},_getEventHandlers:function(){return i({onChange:this._onChange,onKeyDown:this._onKeyDown,onPaste:this._onPaste},this._keyPressPropName(),this._onKeyPress)},focus:function(){this.input.focus()},blur:function(){this.input.blur()},render:function(){var t=this,e=function(e){return t.input=e},s=this.mask.pattern.length,i=this._getDisplayValue(),n=this._getEventHandlers(),a=this.props,r=a.size,o=void 0===r?s:r,p=a.placeholder,u=void 0===p?this.mask.emptyValue:p,c=h({},this.props,n,{ref:e,maxLength:s,value:i,size:o,placeholder:u});return l.createElement("input",c)}});t.exports=d},function(t,e){"use strict";function s(t,e){if(e)for(var s=Object.keys(e),i=0,n=s.length;i<n;i++)t[s[i]]=e[s[i]];return t}function i(t){return s({},t)}function n(t){var e=i(c);if(t)for(var s=Object.keys(t),n=0,a=s.length;n<a;n++){var r=s[n];null==t[r]?delete e[r]:e[r]=t[r]}return e}function a(t,e,s,i){return this instanceof a?(this.placeholderChar=s||u,this.formatCharacters=e||c,this.source=t,this.pattern=[],this.length=0,this.firstEditableIndex=null,this.lastEditableIndex=null,this._editableIndices={},this.isRevealingMask=i||!1,void this._parse()):new a(t,e,s)}function r(t){if(!(this instanceof r))return new r(t);if(t=s({formatCharacters:null,pattern:null,isRevealingMask:!1,placeholderChar:u,selection:{start:0,end:0},value:""},t),null==t.pattern)throw new Error("InputMask: you must provide a pattern.");if("string"!=typeof t.placeholderChar||t.placeholderChar.length>1)throw new Error("InputMask: placeholderChar should be a single character or an empty string.");this.placeholderChar=t.placeholderChar,this.formatCharacters=n(t.formatCharacters),this.setPattern(t.pattern,{value:t.value,selection:t.selection,isRevealingMask:t.isRevealingMask})}var o="\\",h=/^\d$/,l=/^[A-Za-z]$/,p=/^[\dA-Za-z]$/,u="_",c={"*":{validate:function(t){return p.test(t)}},1:{validate:function(t){return h.test(t)}},a:{validate:function(t){return l.test(t)}},A:{validate:function(t){return l.test(t)},transform:function(t){return t.toUpperCase()}},"#":{validate:function(t){return p.test(t)},transform:function(t){return t.toUpperCase()}}};a.prototype._parse=function(){for(var t=this.source.split(""),e=0,s=[],i=0,n=t.length;i<n;i++){var a=t[i];if(a===o){if(i===n-1)throw new Error("InputMask: pattern ends with a raw "+o);a=t[++i]}else a in this.formatCharacters&&(null===this.firstEditableIndex&&(this.firstEditableIndex=e),this.lastEditableIndex=e,this._editableIndices[e]=!0);s.push(a),e++}if(null===this.firstEditableIndex)throw new Error('InputMask: pattern "'+this.source+'" does not contain any editable characters.');this.pattern=s,this.length=s.length},a.prototype.formatValue=function(t){for(var e=new Array(this.length),s=0,i=0,n=this.length;i<n;i++)if(this.isEditableIndex(i)){if(this.isRevealingMask&&t.length<=s&&!this.isValidAtIndex(t[s],i))break;e[i]=t.length>s&&this.isValidAtIndex(t[s],i)?this.transform(t[s],i):this.placeholderChar,s++}else e[i]=this.pattern[i],t.length>s&&t[s]===this.pattern[i]&&s++;return e},a.prototype.isEditableIndex=function(t){return!!this._editableIndices[t]},a.prototype.isValidAtIndex=function(t,e){return this.formatCharacters[this.pattern[e]].validate(t)},a.prototype.transform=function(t,e){var s=this.formatCharacters[this.pattern[e]];return"function"==typeof s.transform?s.transform(t):t},r.prototype.input=function(t){if(this.selection.start===this.selection.end&&this.selection.start===this.pattern.length)return!1;var e=i(this.selection),s=this.getValue(),n=this.selection.start;if(n<this.pattern.firstEditableIndex&&(n=this.pattern.firstEditableIndex),this.pattern.isEditableIndex(n)){if(!this.pattern.isValidAtIndex(t,n))return!1;this.value[n]=this.pattern.transform(t,n)}for(var a=this.selection.end-1;a>n;)this.pattern.isEditableIndex(a)&&(this.value[a]=this.placeholderChar),a--;for(this.selection.start=this.selection.end=n+1;this.pattern.length>this.selection.start&&!this.pattern.isEditableIndex(this.selection.start);)this.selection.start++,this.selection.end++;return null!=this._historyIndex&&(this._history.splice(this._historyIndex,this._history.length-this._historyIndex),this._historyIndex=null),("input"!==this._lastOp||e.start!==e.end||null!==this._lastSelection&&e.start!==this._lastSelection.start)&&this._history.push({value:s,selection:e,lastOp:this._lastOp}),this._lastOp="input",this._lastSelection=i(this.selection),!0},r.prototype.backspace=function(){if(0===this.selection.start&&0===this.selection.end)return!1;var t=i(this.selection),e=this.getValue();if(this.selection.start===this.selection.end)this.pattern.isEditableIndex(this.selection.start-1)&&(this.value[this.selection.start-1]=this.placeholderChar),this.selection.start--,this.selection.end--;else{for(var s=this.selection.end-1;s>=this.selection.start;)this.pattern.isEditableIndex(s)&&(this.value[s]=this.placeholderChar),s--;this.selection.end=this.selection.start}return null!=this._historyIndex&&this._history.splice(this._historyIndex,this._history.length-this._historyIndex),("backspace"!==this._lastOp||t.start!==t.end||null!==this._lastSelection&&t.start!==this._lastSelection.start)&&this._history.push({value:e,selection:t,lastOp:this._lastOp}),this._lastOp="backspace",this._lastSelection=i(this.selection),!0},r.prototype.paste=function(t){var e={value:this.value.slice(),selection:i(this.selection),_lastOp:this._lastOp,_history:this._history.slice(),_historyIndex:this._historyIndex,_lastSelection:i(this._lastSelection)};if(this.selection.start<this.pattern.firstEditableIndex){for(var n=0,a=this.pattern.firstEditableIndex-this.selection.start;n<a;n++)if(t.charAt(n)!==this.pattern.pattern[n])return!1;t=t.substring(this.pattern.firstEditableIndex-this.selection.start),this.selection.start=this.pattern.firstEditableIndex}for(n=0,a=t.length;n<a&&this.selection.start<=this.pattern.lastEditableIndex;n++){var r=this.input(t.charAt(n));if(!r){if(this.selection.start>0){var o=this.selection.start-1;if(!this.pattern.isEditableIndex(o)&&t.charAt(n)===this.pattern.pattern[o])continue}return s(this,e),!1}}return!0},r.prototype.undo=function(){if(0===this._history.length||0===this._historyIndex)return!1;var t;if(null==this._historyIndex){this._historyIndex=this._history.length-1,t=this._history[this._historyIndex];var e=this.getValue();t.value===e&&t.selection.start===this.selection.start&&t.selection.end===this.selection.end||this._history.push({value:e,selection:i(this.selection),lastOp:this._lastOp,startUndo:!0})}else t=this._history[--this._historyIndex];return this.value=t.value.split(""),this.selection=t.selection,this._lastOp=t.lastOp,!0},r.prototype.redo=function(){if(0===this._history.length||null==this._historyIndex)return!1;var t=this._history[++this._historyIndex];return this._historyIndex===this._history.length-1&&(this._historyIndex=null,t.startUndo&&this._history.pop()),this.value=t.value.split(""),this.selection=t.selection,this._lastOp=t.lastOp,!0},r.prototype.setPattern=function(t,e){e=s({selection:{start:0,end:0},value:""},e),this.pattern=new a(t,this.formatCharacters,this.placeholderChar,e.isRevealingMask),this.setValue(e.value),this.emptyValue=this.pattern.formatValue([]).join(""),this.selection=e.selection,this._resetHistory()},r.prototype.setSelection=function(t){if(this.selection=i(t),this.selection.start===this.selection.end){if(this.selection.start<this.pattern.firstEditableIndex)return this.selection.start=this.selection.end=this.pattern.firstEditableIndex,!0;for(var e=this.selection.start;e>=this.pattern.firstEditableIndex;){if(this.pattern.isEditableIndex(e-1)&&this.value[e-1]!==this.placeholderChar||e===this.pattern.firstEditableIndex){this.selection.start=this.selection.end=e;break}e--}return!0}return!1},r.prototype.setValue=function(t){null==t&&(t=""),this.value=this.pattern.formatValue(t.split(""))},r.prototype.getValue=function(){return this.value.join("")},r.prototype.getRawValue=function(){for(var t=[],e=0;e<this.value.length;e++)this.pattern._editableIndices[e]===!0&&t.push(this.value[e]);return t.join("")},r.prototype._resetHistory=function(){this._history=[],this._historyIndex=null,this._lastOp=null,this._lastSelection=i(this.selection)},r.Pattern=a,t.exports=r},function(e,s){e.exports=t}])});
//# sourceMappingURL=react-maskedinput.min.js.map

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc