react-input-mask
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -0,1 +1,3 @@ | ||
// https://github.com/sanniassin/react-input-mask | ||
"use strict"; | ||
@@ -5,6 +7,2 @@ | ||
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } | ||
// https://github.com/sanniassin/react-input-mask | ||
var React = require("react"); | ||
@@ -22,3 +20,3 @@ | ||
lastCaretPos: null, | ||
isAndroidBrowser: function isAndroidBrowser() { | ||
isAndroidBrowser: function () { | ||
var windows = new RegExp("windows", "i"); | ||
@@ -30,8 +28,8 @@ var firefox = new RegExp("firefox", "i"); | ||
}, | ||
isDOMElement: function isDOMElement(element) { | ||
return (typeof HTMLElement === "undefined" ? "undefined" : _typeof(HTMLElement)) === "object" ? element instanceof HTMLElement // DOM2 | ||
isDOMElement: function (element) { | ||
return typeof HTMLElement === "object" ? element instanceof HTMLElement // DOM2 | ||
: element.nodeType === 1 && typeof element.nodeName === "string"; | ||
}, | ||
// getDOMNode is deprecated but we need it to stay compatible with React 0.12 | ||
getInputDOMNode: function getInputDOMNode() { | ||
getInputDOMNode: function () { | ||
var input = this.refs.input; | ||
@@ -46,3 +44,3 @@ | ||
}, | ||
getPrefix: function getPrefix(newState) { | ||
getPrefix: function (newState) { | ||
var prefix = ""; | ||
@@ -59,3 +57,3 @@ | ||
}, | ||
getFilledLength: function getFilledLength() { | ||
getFilledLength: function () { | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? this.state.value : arguments[0]; | ||
@@ -79,3 +77,3 @@ | ||
}, | ||
getLeftEditablePos: function getLeftEditablePos(pos) { | ||
getLeftEditablePos: function (pos) { | ||
for (var i = pos; i >= 0; --i) { | ||
@@ -88,3 +86,3 @@ if (!this.isPermanentChar(i)) { | ||
}, | ||
getRightEditablePos: function getRightEditablePos(pos) { | ||
getRightEditablePos: function (pos) { | ||
var mask = this.state.mask; | ||
@@ -98,3 +96,3 @@ for (var i = pos; i < mask.length; ++i) { | ||
}, | ||
isEmpty: function isEmpty() { | ||
isEmpty: function () { | ||
var _this = this; | ||
@@ -108,3 +106,3 @@ | ||
}, | ||
isFilled: function isFilled() { | ||
isFilled: function () { | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? this.state.value : arguments[0]; | ||
@@ -114,3 +112,3 @@ | ||
}, | ||
createFilledArray: function createFilledArray(length, val) { | ||
createFilledArray: function (length, val) { | ||
var array = []; | ||
@@ -122,3 +120,3 @@ for (var i = 0; i < length; i++) { | ||
}, | ||
formatValue: function formatValue(value, newState) { | ||
formatValue: function (value, newState) { | ||
var _this2 = this; | ||
@@ -148,3 +146,3 @@ | ||
}, | ||
clearRange: function clearRange(value, start, len) { | ||
clearRange: function (value, start, len) { | ||
var _this3 = this; | ||
@@ -172,6 +170,6 @@ | ||
}, | ||
replaceSubstr: function replaceSubstr(value, newSubstr, pos) { | ||
replaceSubstr: function (value, newSubstr, pos) { | ||
return value.slice(0, pos) + newSubstr + value.slice(pos + newSubstr.length); | ||
}, | ||
insertRawSubstr: function insertRawSubstr(value, substr, pos, newState) { | ||
insertRawSubstr: function (value, substr, pos, newState) { | ||
var _ref3 = newState || this.state; | ||
@@ -208,3 +206,3 @@ | ||
}, | ||
getRawSubstrLength: function getRawSubstrLength(value, substr, pos, newState) { | ||
getRawSubstrLength: function (value, substr, pos, newState) { | ||
var _ref4 = newState || this.state; | ||
@@ -228,3 +226,3 @@ | ||
}, | ||
isAllowedChar: function isAllowedChar(char, pos, newState) { | ||
isAllowedChar: function (char, pos, newState) { | ||
var mask = newState ? newState.mask : this.state.mask; | ||
@@ -238,7 +236,7 @@ if (this.isPermanentChar(pos, newState)) { | ||
}, | ||
isPermanentChar: function isPermanentChar(pos, newState) { | ||
isPermanentChar: function (pos, newState) { | ||
var permanents = newState ? newState.permanents : this.state.permanents; | ||
return permanents.indexOf(pos) !== -1; | ||
}, | ||
setCaretToEnd: function setCaretToEnd() { | ||
setCaretToEnd: function () { | ||
var filledLen = this.getFilledLength(); | ||
@@ -250,3 +248,3 @@ var pos = this.getRightEditablePos(filledLen); | ||
}, | ||
getSelection: function getSelection() { | ||
getSelection: function () { | ||
var input = this.getInputDOMNode(); | ||
@@ -276,3 +274,3 @@ var start = 0; | ||
}, | ||
getCaretPos: function getCaretPos() { | ||
getCaretPos: function () { | ||
var input = this.getInputDOMNode(); | ||
@@ -292,5 +290,5 @@ var pos = 0; | ||
}, | ||
setCaretPos: function setCaretPos(pos) { | ||
setCaretPos: function (pos) { | ||
var input; | ||
var setPos = function setPos() { | ||
var setPos = function () { | ||
if ("selectionStart" in input && "selectionEnd" in input) { | ||
@@ -317,6 +315,6 @@ input.selectionStart = input.selectionEnd = pos; | ||
}, | ||
isFocused: function isFocused() { | ||
isFocused: function () { | ||
return document.activeElement === this.getInputDOMNode(); | ||
}, | ||
parseMask: function parseMask(mask) { | ||
parseMask: function (mask) { | ||
var _this4 = this; | ||
@@ -351,6 +349,6 @@ | ||
}, | ||
getStringValue: function getStringValue(value) { | ||
getStringValue: function (value) { | ||
return !value && value !== 0 ? "" : value + ""; | ||
}, | ||
getInitialState: function getInitialState() { | ||
getInitialState: function () { | ||
var mask = this.parseMask(this.props.mask); | ||
@@ -371,3 +369,3 @@ var defaultValue = this.props.defaultValue != null ? this.props.defaultValue : null; | ||
}, | ||
componentWillMount: function componentWillMount() { | ||
componentWillMount: function () { | ||
var _state = this.state; | ||
@@ -381,3 +379,3 @@ var mask = _state.mask; | ||
}, | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
componentWillReceiveProps: function (nextProps) { | ||
var mask = this.parseMask(nextProps.mask); | ||
@@ -406,3 +404,3 @@ var maskChar = "maskChar" in nextProps ? nextProps.maskChar : this.defaultMaskChar; | ||
}, | ||
componentDidUpdate: function componentDidUpdate(prevProps, prevState) { | ||
componentDidUpdate: function (prevProps, prevState) { | ||
var mask = this.state.mask; | ||
@@ -419,3 +417,3 @@ if (!mask) { | ||
}, | ||
onKeyDown: function onKeyDown(event) { | ||
onKeyDown: function (event) { | ||
var hasHandler = typeof this.props.onKeyDown === "function"; | ||
@@ -475,3 +473,3 @@ if (event.ctrlKey || event.metaKey) { | ||
}, | ||
onKeyPress: function onKeyPress(event) { | ||
onKeyPress: function (event) { | ||
var key = event.key; | ||
@@ -521,3 +519,3 @@ var hasHandler = typeof this.props.onKeyPress === "function"; | ||
}, | ||
onChange: function onChange(event) { | ||
onChange: function (event) { | ||
var pasteSelection = this.pasteSelection; | ||
@@ -552,3 +550,3 @@ if (pasteSelection) { | ||
}, | ||
onFocus: function onFocus(event) { | ||
onFocus: function (event) { | ||
if (!this.state.value) { | ||
@@ -573,3 +571,3 @@ var prefix = this.getPrefix(); | ||
}, | ||
onBlur: function onBlur(event) { | ||
onBlur: function (event) { | ||
if (!this.props.alwaysShowMask && this.isEmpty(this.state.value)) { | ||
@@ -589,3 +587,3 @@ event.target.value = ""; | ||
}, | ||
onPaste: function onPaste(event) { | ||
onPaste: function (event) { | ||
if (this.isAndroidBrowser()) { | ||
@@ -610,3 +608,3 @@ this.pasteSelection = this.getSelection(); | ||
}, | ||
pasteText: function pasteText(value, text, selection) { | ||
pasteText: function (value, text, selection) { | ||
var caretPos = selection.start; | ||
@@ -631,3 +629,3 @@ if (selection.length) { | ||
}, | ||
render: function render() { | ||
render: function () { | ||
var _this5 = this; | ||
@@ -643,8 +641,3 @@ | ||
} | ||
return React.createElement("input", _extends({ ref: "input" }, this.props, ourProps, { | ||
__source: { | ||
fileName: "../../../InputElement.js", | ||
lineNumber: 595 | ||
} | ||
})); | ||
return React.createElement("input", _extends({ ref: "input" }, this.props, ourProps)); | ||
} | ||
@@ -651,0 +644,0 @@ }); |
{ | ||
"name": "react-input-mask", | ||
"description": "Masked input component for React", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"homepage": "https://github.com/sanniassin/react-input-mask", | ||
@@ -19,6 +19,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"babel-cli": "^6.1.4", | ||
"babel-preset-es2015": "^6.1.2", | ||
"babel-preset-react": "^6.1.2", | ||
"babel-preset-stage-2": "^6.1.2" | ||
"babel": "^5.8.34" | ||
}, | ||
@@ -25,0 +22,0 @@ "main": "build/InputElement.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
42537
1121