Socket
Socket
Sign inDemoInstall

react-input-mask

Package Overview
Dependencies
3
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.1 to 0.8.2

105

build/InputElement.js

@@ -30,3 +30,3 @@ "use strict";

_this.hasValue = props.value != null;
_this.charsRules = "formatChars" in props ? props.formatChars : _this.defaultCharsRules;
_this.charsRules = props.formatChars != null ? props.formatChars : _this.defaultCharsRules;

@@ -64,3 +64,3 @@ var mask = _this.parseMask(props.mask);

this.defaultMaskChar = "_";
this.lastCaretPos = null;
this.lastCursorPos = null;

@@ -367,7 +367,7 @@ this.isAndroidBrowser = function () {

this.setCaretToEnd = function () {
this.setCursorToEnd = function () {
var filledLen = _this2.getFilledLength();
var pos = _this2.getRightEditablePos(filledLen);
if (pos !== null) {
_this2.setCaretPos(pos);
_this2.setCursorPos(pos);
}

@@ -420,7 +420,7 @@ };

this.getCaretPos = function () {
this.getCursorPos = function () {
return _this2.getSelection().start;
};
this.setCaretPos = function (pos) {
this.setCursorPos = function (pos) {
var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (fn) {

@@ -435,3 +435,3 @@ return setTimeout(fn, 0);

_this2.lastCaretPos = pos;
_this2.lastCursorPos = pos;
};

@@ -492,3 +492,3 @@

_this2.hasValue = _this2.props.value != null;
_this2.charsRules = "formatChars" in nextProps ? nextProps.formatChars : _this2.defaultCharsRules;
_this2.charsRules = nextProps.formatChars != null ? nextProps.formatChars : _this2.defaultCharsRules;

@@ -505,3 +505,3 @@ var oldMask = _this2.mask;

if (!_this2.mask) {
_this2.lastCaretPos = null;
_this2.lastCursorPos = null;
return;

@@ -521,3 +521,3 @@ }

if (isMaskChanged) {
var pos = _this2.lastCaretPos;
var pos = _this2.lastCursorPos;
var filledLen = _this2.getFilledLength(newValue);

@@ -530,3 +530,3 @@ if (pos === null || filledLen < pos) {

}
_this2.setCaretPos(pos);
_this2.setCursorPos(pos);
}

@@ -568,3 +568,3 @@ }

var caretPos = _this2.getCaretPos();
var cursorPos = _this2.getCursorPos();
var value = _this2.state.value;

@@ -581,9 +581,9 @@ var key = event.key;

value = _this2.clearRange(value, selectionRange.start, selectionRange.length);
} else if (caretPos < prefixLen || !deleteFromRight && caretPos === prefixLen) {
caretPos = prefixLen;
} else if (cursorPos < prefixLen || !deleteFromRight && cursorPos === prefixLen) {
cursorPos = prefixLen;
} else {
var editablePos = deleteFromRight ? _this2.getRightEditablePos(caretPos) : _this2.getLeftEditablePos(caretPos - 1);
var editablePos = deleteFromRight ? _this2.getRightEditablePos(cursorPos) : _this2.getLeftEditablePos(cursorPos - 1);
if (editablePos !== null) {
value = _this2.clearRange(value, editablePos, 1);
caretPos = editablePos;
cursorPos = editablePos;
}

@@ -613,3 +613,3 @@ }

event.preventDefault();
_this2.setCaretPos(caretPos);
_this2.setCursorPos(cursorPos);
}

@@ -632,3 +632,3 @@ };

var caretPos = _this2.getCaretPos();
var cursorPos = _this2.getCursorPos();
var selection = _this2.getSelection();

@@ -643,11 +643,11 @@ var value = _this2.state.value;

if (_this2.isPermanentChar(caretPos) && mask[caretPos] === key) {
value = _this2.insertRawSubstr(value, key, caretPos);
++caretPos;
if (_this2.isPermanentChar(cursorPos) && mask[cursorPos] === key) {
value = _this2.insertRawSubstr(value, key, cursorPos);
++cursorPos;
} else {
var editablePos = _this2.getRightEditablePos(caretPos);
var editablePos = _this2.getRightEditablePos(cursorPos);
if (editablePos !== null && _this2.isAllowedChar(key, editablePos)) {
value = _this2.clearRange(value, selection.start, selection.length);
value = _this2.insertRawSubstr(value, key, editablePos);
caretPos = editablePos + 1;
cursorPos = editablePos + 1;
}

@@ -666,6 +666,6 @@ }

event.preventDefault();
if (caretPos < lastEditablePos && caretPos > prefixLen) {
caretPos = _this2.getRightEditablePos(caretPos);
if (cursorPos < lastEditablePos && cursorPos > prefixLen) {
cursorPos = _this2.getRightEditablePos(cursorPos);
}
_this2.setCaretPos(caretPos);
_this2.setCursorPos(cursorPos);
};

@@ -695,3 +695,3 @@

var selection = _this2.getSelection();
var caretPos = selection.end;
var cursorPos = selection.end;
var maskLen = mask.length;

@@ -709,5 +709,5 @@ var valueLen = value.length;

if (startPos < lastEditablePos && (substrLen !== 1 || enteredSubstr !== mask[startPos])) {
caretPos = _this2.getRightEditablePos(startPos);
cursorPos = _this2.getRightEditablePos(startPos);
} else {
caretPos = startPos;
cursorPos = startPos;
}

@@ -718,10 +718,10 @@

clearedValue = _this2.clearRange(value, startPos, maskLen - startPos);
clearedValue = _this2.insertRawSubstr(clearedValue, enteredSubstr, caretPos);
clearedValue = _this2.insertRawSubstr(clearedValue, enteredSubstr, cursorPos);
value = _this2.insertRawSubstr(oldValue, enteredSubstr, caretPos);
value = _this2.insertRawSubstr(oldValue, enteredSubstr, cursorPos);
if (substrLen !== 1 || caretPos >= prefixLen && caretPos < lastEditablePos) {
caretPos = _this2.getFilledLength(clearedValue);
} else if (caretPos < lastEditablePos) {
caretPos++;
if (substrLen !== 1 || cursorPos >= prefixLen && cursorPos < lastEditablePos) {
cursorPos = _this2.getFilledLength(clearedValue);
} else if (cursorPos < lastEditablePos) {
cursorPos++;
}

@@ -742,5 +742,5 @@ } else if (valueLen < oldValueLen) {

if (!clearOnly) {
caretPos = _this2.getFilledLength(clearedValue);
} else if (caretPos < prefixLen) {
caretPos = prefixLen;
cursorPos = _this2.getFilledLength(clearedValue);
} else if (cursorPos < prefixLen) {
cursorPos = prefixLen;
}

@@ -765,3 +765,3 @@ }

_this2.setCaretPos(caretPos);
_this2.setCursorPos(cursorPos);
}, 0);

@@ -794,3 +794,3 @@ } else {

_this2.setCaretPos(caretPos);
_this2.setCursorPos(cursorPos);
}

@@ -815,3 +815,3 @@ };

value: _this2.hasValue ? _this2.state.value : inputValue
}, _this2.setCaretToEnd);
}, _this2.setCursorToEnd);

@@ -822,3 +822,3 @@ if (isInputValueChanged && typeof _this2.props.onChange === "function") {

} else if (_this2.getFilledLength() < _this2.mask.length) {
_this2.setCaretToEnd();
_this2.setCursorToEnd();
}

@@ -873,10 +873,10 @@

this.pasteText = function (value, text, selection, event) {
var caretPos = selection.start;
var cursorPos = selection.start;
if (selection.length) {
value = _this2.clearRange(value, caretPos, selection.length);
value = _this2.clearRange(value, cursorPos, selection.length);
}
var textLen = _this2.getRawSubstrLength(value, text, caretPos);
value = _this2.insertRawSubstr(value, text, caretPos);
caretPos += textLen;
caretPos = _this2.getRightEditablePos(caretPos) || caretPos;
var textLen = _this2.getRawSubstrLength(value, text, cursorPos);
value = _this2.insertRawSubstr(value, text, cursorPos);
cursorPos += textLen;
cursorPos = _this2.getRightEditablePos(cursorPos) || cursorPos;
if (value !== _this2.getInputValue()) {

@@ -893,3 +893,3 @@ if (event) {

}
_this2.setCaretPos(caretPos);
_this2.setCursorPos(cursorPos);
};

@@ -902,4 +902,7 @@

if (Object.getOwnPropertyDescriptor && Object.getPrototypeOf && Object.defineProperty) {
var input = _this2.getInputDOMNode();
var input = _this2.getInputDOMNode();
// workaround for Jest
// it doesn't mount a real node so input will be null
if (input && Object.getOwnPropertyDescriptor && Object.getPrototypeOf && Object.defineProperty) {
var valueDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value');

@@ -906,0 +909,0 @@ _this2.canUseAccessors = !!(valueDescriptor && valueDescriptor.get && valueDescriptor.set);

@@ -12,3 +12,3 @@ // https://github.com/sanniassin/react-input-mask

defaultMaskChar = "_"
lastCaretPos = null
lastCursorPos = null

@@ -19,3 +19,5 @@ constructor(props) {

this.hasValue = props.value != null;
this.charsRules = "formatChars" in props ? props.formatChars : this.defaultCharsRules;
this.charsRules = props.formatChars != null
? props.formatChars
: this.defaultCharsRules;

@@ -341,7 +343,7 @@ var mask = this.parseMask(props.mask);

setCaretToEnd = () => {
setCursorToEnd = () => {
var filledLen = this.getFilledLength();
var pos = this.getRightEditablePos(filledLen);
if (pos !== null) {
this.setCaretPos(pos);
this.setCursorPos(pos);
}

@@ -394,7 +396,7 @@ }

getCaretPos = () => {
getCursorPos = () => {
return this.getSelection().start;
}
setCaretPos = (pos) => {
setCursorPos = (pos) => {
var raf = window.requestAnimationFrame

@@ -413,3 +415,3 @@ ||

this.lastCaretPos = pos;
this.lastCursorPos = pos;
}

@@ -471,3 +473,5 @@

this.hasValue = this.props.value != null;
this.charsRules = "formatChars" in nextProps ? nextProps.formatChars : this.defaultCharsRules;
this.charsRules = nextProps.formatChars != null
? nextProps.formatChars
: this.defaultCharsRules;

@@ -484,3 +488,3 @@ var oldMask = this.mask;

if (!this.mask) {
this.lastCaretPos = null;
this.lastCursorPos = null;
return;

@@ -502,3 +506,3 @@ }

if (isMaskChanged) {
var pos = this.lastCaretPos;
var pos = this.lastCursorPos;
var filledLen = this.getFilledLength(newValue);

@@ -512,3 +516,3 @@ if (pos === null || filledLen < pos) {

}
this.setCaretPos(pos);
this.setCursorPos(pos);
}

@@ -550,3 +554,3 @@ }

var caretPos = this.getCaretPos();
var cursorPos = this.getCursorPos();
var value = this.state.value;

@@ -564,10 +568,10 @@ var key = event.key;

}
else if (caretPos < prefixLen || (!deleteFromRight && caretPos === prefixLen)) {
caretPos = prefixLen;
else if (cursorPos < prefixLen || (!deleteFromRight && cursorPos === prefixLen)) {
cursorPos = prefixLen;
}
else {
var editablePos = deleteFromRight ? this.getRightEditablePos(caretPos) : this.getLeftEditablePos(caretPos - 1);
var editablePos = deleteFromRight ? this.getRightEditablePos(cursorPos) : this.getLeftEditablePos(cursorPos - 1);
if (editablePos !== null) {
value = this.clearRange(value, editablePos, 1);
caretPos = editablePos;
cursorPos = editablePos;
}

@@ -597,3 +601,3 @@ }

event.preventDefault();
this.setCaretPos(caretPos);
this.setCursorPos(cursorPos);
}

@@ -616,3 +620,3 @@ }

var caretPos = this.getCaretPos();
var cursorPos = this.getCursorPos();
var selection = this.getSelection();

@@ -624,12 +628,12 @@ var { value } = this.state;

if (this.isPermanentChar(caretPos) && mask[caretPos] === key) {
value = this.insertRawSubstr(value, key, caretPos);
++caretPos;
if (this.isPermanentChar(cursorPos) && mask[cursorPos] === key) {
value = this.insertRawSubstr(value, key, cursorPos);
++cursorPos;
}
else {
var editablePos = this.getRightEditablePos(caretPos);
var editablePos = this.getRightEditablePos(cursorPos);
if (editablePos !== null && this.isAllowedChar(key, editablePos)) {
value = this.clearRange(value, selection.start, selection.length);
value = this.insertRawSubstr(value, key, editablePos);
caretPos = editablePos + 1;
cursorPos = editablePos + 1;
}

@@ -648,6 +652,6 @@ }

event.preventDefault();
if (caretPos < lastEditablePos && caretPos > prefixLen) {
caretPos = this.getRightEditablePos(caretPos);
if (cursorPos < lastEditablePos && cursorPos > prefixLen) {
cursorPos = this.getRightEditablePos(cursorPos);
}
this.setCaretPos(caretPos);
this.setCursorPos(cursorPos);
}

@@ -672,3 +676,3 @@

var selection = this.getSelection();
var caretPos = selection.end;
var cursorPos = selection.end;
var maskLen = mask.length;

@@ -686,6 +690,6 @@ var valueLen = value.length;

if (startPos < lastEditablePos && (substrLen !== 1 || enteredSubstr !== mask[startPos])) {
caretPos = this.getRightEditablePos(startPos);
cursorPos = this.getRightEditablePos(startPos);
}
else {
caretPos = startPos;
cursorPos = startPos;
}

@@ -696,11 +700,11 @@

clearedValue = this.clearRange(value, startPos, maskLen - startPos);
clearedValue = this.insertRawSubstr(clearedValue, enteredSubstr, caretPos);
clearedValue = this.insertRawSubstr(clearedValue, enteredSubstr, cursorPos);
value = this.insertRawSubstr(oldValue, enteredSubstr, caretPos);
value = this.insertRawSubstr(oldValue, enteredSubstr, cursorPos);
if (substrLen !== 1 || (caretPos >= prefixLen && caretPos < lastEditablePos)) {
caretPos = this.getFilledLength(clearedValue);
if (substrLen !== 1 || (cursorPos >= prefixLen && cursorPos < lastEditablePos)) {
cursorPos = this.getFilledLength(clearedValue);
}
else if (caretPos < lastEditablePos) {
caretPos++;
else if (cursorPos < lastEditablePos) {
cursorPos++;
}

@@ -722,6 +726,6 @@ }

if (!clearOnly) {
caretPos = this.getFilledLength(clearedValue);
cursorPos = this.getFilledLength(clearedValue);
}
else if (caretPos < prefixLen) {
caretPos = prefixLen;
else if (cursorPos < prefixLen) {
cursorPos = prefixLen;
}

@@ -746,3 +750,3 @@ }

this.setCaretPos(caretPos);
this.setCursorPos(cursorPos);
}, 0);

@@ -776,3 +780,3 @@ }

this.setCaretPos(caretPos);
this.setCursorPos(cursorPos);
}

@@ -797,3 +801,3 @@ }

value: this.hasValue ? this.state.value : inputValue
}, this.setCaretToEnd);
}, this.setCursorToEnd);

@@ -805,3 +809,3 @@ if (isInputValueChanged && typeof this.props.onChange === "function") {

else if (this.getFilledLength() < this.mask.length) {
this.setCaretToEnd();
this.setCursorToEnd();
}

@@ -856,10 +860,10 @@

pasteText = (value, text, selection, event) => {
var caretPos = selection.start;
var cursorPos = selection.start;
if (selection.length) {
value = this.clearRange(value, caretPos, selection.length);
value = this.clearRange(value, cursorPos, selection.length);
}
var textLen = this.getRawSubstrLength(value, text, caretPos);
value = this.insertRawSubstr(value, text, caretPos);
caretPos += textLen;
caretPos = this.getRightEditablePos(caretPos) || caretPos;
var textLen = this.getRawSubstrLength(value, text, cursorPos);
value = this.insertRawSubstr(value, text, cursorPos);
cursorPos += textLen;
cursorPos = this.getRightEditablePos(cursorPos) || cursorPos;
if (value !== this.getInputValue()) {

@@ -876,3 +880,3 @@ if (event) {

}
this.setCaretPos(caretPos);
this.setCursorPos(cursorPos);
}

@@ -885,4 +889,7 @@

if (Object.getOwnPropertyDescriptor && Object.getPrototypeOf && Object.defineProperty) {
var input = this.getInputDOMNode();
var input = this.getInputDOMNode();
// workaround for Jest
// it doesn't mount a real node so input will be null
if (input && Object.getOwnPropertyDescriptor && Object.getPrototypeOf && Object.defineProperty) {
var valueDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value');

@@ -889,0 +896,0 @@ this.canUseAccessors = !!(valueDescriptor && valueDescriptor.get && valueDescriptor.set);

{
"name": "react-input-mask",
"description": "Masked input component for React",
"version": "0.8.1",
"version": "0.8.2",
"homepage": "https://github.com/sanniassin/react-input-mask",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -96,3 +96,3 @@ import React from 'react';

expect(input.getCaretPos()).toEqual(4);
expect(input.getCursorPos()).toEqual(4);

@@ -103,6 +103,6 @@ inputNode.blur();

setInputProps(input, { value: '+7 (___) ___ _1 __' });
input.setCaretPos(2);
input.setCursorPos(2);
inputNode.focus();
TestUtils.Simulate.focus(inputNode);
expect(input.getCaretPos()).toEqual(16);
expect(input.getCursorPos()).toEqual(16);

@@ -113,6 +113,6 @@ inputNode.blur();

setInputProps(input, { value: '+7 (___) ___ _1 _1' });
input.setCaretPos(2);
input.setCursorPos(2);
inputNode.focus();
TestUtils.Simulate.focus(inputNode);
expect(input.getCaretPos()).toEqual(2);
expect(input.getCursorPos()).toEqual(2);

@@ -129,15 +129,15 @@ ReactDOM.unmountComponentAtNode(container);

input.setCaretPos(0);
input.setCursorPos(0);
inputNode.value = 'a' + inputNode.value;
input.setCaretPos(1);
input.setCursorPos(1);
TestUtils.Simulate.change(inputNode);
expect(inputNode.value).toEqual('a___ ____ ____ ____');
expect(input.getCaretPos()).toEqual(1);
expect(input.getCursorPos()).toEqual(1);
input.setSelection(0, 19);
inputNode.value = 'a';
input.setCaretPos(1);
input.setCursorPos(1);
TestUtils.Simulate.change(inputNode);
expect(inputNode.value).toEqual('a___ ____ ____ ____');
expect(input.getCaretPos()).toEqual(1);
expect(input.getCursorPos()).toEqual(1);

@@ -148,6 +148,6 @@ inputNode.value = 'aaaaa___ ____ ____ ____';

expect(inputNode.value).toEqual('aaaa a___ ____ ____');
expect(input.getCaretPos()).toEqual(6);
expect(input.getCursorPos()).toEqual(6);
inputNode.value = 'aaa a___ ____ ____';
input.setCaretPos(3);
input.setCursorPos(3);
TestUtils.Simulate.change(inputNode);

@@ -157,3 +157,3 @@ expect(inputNode.value).toEqual('aaa_ a___ ____ ____');

inputNode.value = 'aaaaaa___ ____ ____';
input.setCaretPos(6);
input.setCursorPos(6);
TestUtils.Simulate.change(inputNode);

@@ -163,6 +163,6 @@ expect(inputNode.value).toEqual('aaaa aa__ ____ ____');

inputNode.value = 'aaaaxa__ ____ ____';
input.setCaretPos(5);
input.setCursorPos(5);
TestUtils.Simulate.change(inputNode);
expect(inputNode.value).toEqual('aaaa xa__ ____ ____');
expect(input.getCaretPos()).toEqual(6);
expect(input.getCursorPos()).toEqual(6);

@@ -179,26 +179,26 @@ ReactDOM.unmountComponentAtNode(container);

input.setCaretPos(0);
input.setCursorPos(0);
inputNode.value = 'aaaa';
input.setCaretPos(4);
input.setCursorPos(4);
TestUtils.Simulate.change(inputNode);
expect(inputNode.value).toEqual('aaaa');
expect(input.getCaretPos()).toEqual(4);
expect(input.getCursorPos()).toEqual(4);
inputNode.value = 'aaaaa';
input.setCaretPos(5);
input.setCursorPos(5);
TestUtils.Simulate.change(inputNode);
expect(inputNode.value).toEqual('aaaa a');
expect(input.getCaretPos()).toEqual(6);
expect(input.getCursorPos()).toEqual(6);
inputNode.value = 'aaaa afgh ijkl mnop';
input.setCaretPos(19);
input.setCursorPos(19);
TestUtils.Simulate.change(inputNode);
expect(inputNode.value).toEqual('aaaa afgh ijkl mnop');
expect(input.getCaretPos()).toEqual(19);
expect(input.getCursorPos()).toEqual(19);
inputNode.value = 'aaaa afgh ijkl mnopq';
input.setCaretPos(20);
input.setCursorPos(20);
TestUtils.Simulate.change(inputNode);
expect(inputNode.value).toEqual('aaaa afgh ijkl mnop');
expect(input.getCaretPos()).toEqual(19);
expect(input.getCursorPos()).toEqual(19);

@@ -215,11 +215,11 @@ ReactDOM.unmountComponentAtNode(container);

input.setCaretPos(0);
input.setCursorPos(0);
TestUtils.Simulate.keyPress(inputNode, { key: '+' });
expect(inputNode.value).toEqual('+7 (___) ___ __ __');
input.setCaretPos(0);
input.setCursorPos(0);
TestUtils.Simulate.keyPress(inputNode, { key: '7' });
expect(inputNode.value).toEqual('+7 (7__) ___ __ __');
input.setCaretPos(0);
input.setCursorPos(0);
TestUtils.Simulate.keyPress(inputNode, { key: 'E' });

@@ -244,3 +244,3 @@ expect(inputNode.value).toEqual('+7 (E__) ___ __ __');

input.setCaretPos(4);
input.setCursorPos(4);
TestUtils.Simulate.keyPress(inputNode, { key: 'E' });

@@ -253,3 +253,3 @@ expect(inputNode.value).toEqual('+7 (111) 123 45 6');

input.setCaretPos(14)
input.setCursorPos(14)
TestUtils.Simulate.keyPress(inputNode, { key: '7' });

@@ -262,5 +262,5 @@ TestUtils.Simulate.keyPress(inputNode, { key: '8' });

inputNode.value = '+7 (';
input.setCaretPos(4);
input.setCursorPos(4);
TestUtils.Simulate.change(inputNode);
input.setCaretPos(0);
input.setCursorPos(0);
TestUtils.Simulate.keyPress(inputNode, { key: '+' });

@@ -279,6 +279,6 @@ expect(inputNode.value).toEqual('+7 (');

input.setCaretPos(3);
input.setCursorPos(3);
TestUtils.Simulate.keyPress(inputNode, { key: '1' });
expect(inputNode.value).toEqual('(111)');
expect(input.getCaretPos()).toEqual(4);
expect(input.getCursorPos()).toEqual(4);

@@ -295,3 +295,3 @@ ReactDOM.unmountComponentAtNode(container);

input.setCaretPos(10);
input.setCursorPos(10);
TestUtils.Simulate.keyDown(inputNode, { key: 'Backspace' });

@@ -313,3 +313,3 @@ expect(inputNode.value).toEqual('+7 (495) _15 64 54');

input.setCaretPos(10);
input.setCursorPos(10);
TestUtils.Simulate.keyDown(inputNode, { key: 'Backspace' });

@@ -319,3 +319,3 @@ expect(inputNode.value).toEqual('+7 (495) 156 45 4');

inputNode.value = '+7 (';
input.setCaretPos(4);
input.setCursorPos(4);
TestUtils.Simulate.change(inputNode);

@@ -325,3 +325,3 @@ expect(inputNode.value).toEqual('+7 (');

inputNode.value = '+7 ';
input.setCaretPos(3);
input.setCursorPos(3);
TestUtils.Simulate.change(inputNode);

@@ -340,12 +340,12 @@ expect(inputNode.value).toEqual('+7 (');

input.setCaretPos(10);
input.setCursorPos(10);
TestUtils.Simulate.keyDown(inputNode, { key: 'Backspace' });
expect(input.getCaretPos()).toEqual(9);
expect(input.getCursorPos()).toEqual(9);
TestUtils.Simulate.keyDown(inputNode, { key: 'Backspace' });
expect(input.getCaretPos()).toEqual(6);
expect(input.getCursorPos()).toEqual(6);
input.setCaretPos(4);
input.setCursorPos(4);
TestUtils.Simulate.keyDown(inputNode, { key: 'Backspace' });
expect(input.getCaretPos()).toEqual(4);
expect(input.getCursorPos()).toEqual(4);

@@ -378,3 +378,3 @@ ReactDOM.unmountComponentAtNode(container);

TestUtils.Simulate.keyDown(inputNode, { key: 'Backspace' });
expect(input.getCaretPos()).toEqual(1);
expect(input.getCursorPos()).toEqual(1);

@@ -391,11 +391,11 @@ ReactDOM.unmountComponentAtNode(container);

input.setCaretPos(0);
input.setCursorPos(0);
TestUtils.Simulate.keyDown(inputNode, { key: 'Delete' });
expect(inputNode.value).toEqual('+7 (495) 315 64 54');
input.setCaretPos(7);
input.setCursorPos(7);
TestUtils.Simulate.keyDown(inputNode, { key: 'Delete' });
expect(inputNode.value).toEqual('+7 (495) _15 64 54');
input.setCaretPos(11);
input.setCursorPos(11);
TestUtils.Simulate.keyDown(inputNode, { key: 'Delete' });

@@ -414,13 +414,13 @@ expect(inputNode.value).toEqual('+7 (495) _1_ 64 54');

input.setCaretPos(0);
input.setCursorPos(0);
TestUtils.Simulate.keyDown(inputNode, { key: 'Delete' });
expect(input.getCaretPos()).toEqual(4);
expect(input.getCursorPos()).toEqual(4);
input.setCaretPos(7);
input.setCursorPos(7);
TestUtils.Simulate.keyDown(inputNode, { key: 'Delete' });
expect(input.getCaretPos()).toEqual(9);
expect(input.getCursorPos()).toEqual(9);
input.setCaretPos(11);
input.setCursorPos(11);
TestUtils.Simulate.keyDown(inputNode, { key: 'Delete' });
expect(input.getCaretPos()).toEqual(11);
expect(input.getCursorPos()).toEqual(11);

@@ -476,3 +476,3 @@ ReactDOM.unmountComponentAtNode(container);

input.setCaretPos(3);
input.setCursorPos(3);
input.pasteText(inputNode.value, '3-__81-2_6917', input.getSelection());

@@ -495,7 +495,7 @@ expect(inputNode.value).toEqual('___3-__81-2_69-17_3');

input.setCaretPos(1);
input.setCursorPos(1);
input.pasteText(inputNode.value, '12345', input.getSelection());
expect(inputNode.value).toEqual('3123-4547-8122-6917');
input.setCaretPos(1);
input.setCursorPos(1);
input.pasteText(inputNode.value, '4321', input.getSelection());

@@ -532,2 +532,9 @@ expect(inputNode.value).toEqual('3432-1547-8122-6917');

}));
it('Null as formatChars', createInput(
<Input mask="99-99" formatChars={null} alwaysShowMask />, (input) => {
var inputNode = ReactDOM.findDOMNode(input);
expect(inputNode.value).toEqual('__-__');
}));
});
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