restricted-input
Advanced tools
Comparing version 3.0.4 to 3.0.5
@@ -8,3 +8,3 @@ "use strict"; | ||
function PatternFormatter(pattern) { | ||
this.pattern = parse_pattern_1.parsePattern(pattern); | ||
this.pattern = (0, parse_pattern_1.parsePattern)(pattern); | ||
} | ||
@@ -102,3 +102,3 @@ PatternFormatter.prototype.format = function (options) { | ||
} | ||
else if (is_backspace_1.isBackspace(options.event)) { | ||
else if ((0, is_backspace_1.isBackspace)(options.event)) { | ||
deletionStart = Math.max(0, selection.start - 1); | ||
@@ -105,0 +105,0 @@ deletionEnd = selection.start; |
@@ -8,3 +8,3 @@ "use strict"; | ||
var input = (event.currentTarget || event.srcElement); | ||
var selection = input_selection_1.get(input); | ||
var selection = (0, input_selection_1.get)(input); | ||
var isAtBeginning = selection.start === 0; | ||
@@ -11,0 +11,0 @@ var isAtEnd = selection.start === input.value.length; |
@@ -22,12 +22,12 @@ "use strict"; | ||
} | ||
else if (device_1.isIos()) { | ||
else if ((0, device_1.isIos)()) { | ||
this.strategy = new ios_1.IosStrategy(options); | ||
} | ||
else if (device_1.isKitKatWebview()) { | ||
else if ((0, device_1.isKitKatWebview)()) { | ||
this.strategy = new kitkat_chromium_based_webview_1.KitKatChromiumBasedWebViewStrategy(options); | ||
} | ||
else if (device_1.isAndroidChrome()) { | ||
else if ((0, device_1.isAndroidChrome)()) { | ||
this.strategy = new android_chrome_1.AndroidChromeStrategy(options); | ||
} | ||
else if (device_1.isIE9()) { | ||
else if ((0, device_1.isIE9)()) { | ||
this.strategy = new ie9_1.IE9Strategy(options); | ||
@@ -34,0 +34,0 @@ } |
@@ -30,3 +30,3 @@ "use strict"; | ||
this.inputElement.addEventListener("keydown", function (event) { | ||
if (key_cannot_mutate_value_1.keyCannotMutateValue(event)) { | ||
if ((0, key_cannot_mutate_value_1.keyCannotMutateValue)(event)) { | ||
return; | ||
@@ -78,3 +78,3 @@ } | ||
var formattedSelection = formattedState.selection; | ||
input_selection_1.set(input, formattedSelection.end, formattedSelection.end); | ||
(0, input_selection_1.set)(input, formattedSelection.end, formattedSelection.end); | ||
}, 0); | ||
@@ -81,0 +81,0 @@ }; |
@@ -69,3 +69,3 @@ "use strict"; | ||
} | ||
if (key_cannot_mutate_value_1.keyCannotMutateValue(event)) { | ||
if ((0, key_cannot_mutate_value_1.keyCannotMutateValue)(event)) { | ||
return; | ||
@@ -83,2 +83,8 @@ } | ||
_this.reformatInput(); | ||
// if the user changes their keyboard and | ||
// the browser doesn't support the keypress event listener, | ||
// we need to reset the keypress flag to be able to enable the | ||
// fallback for the custom input event listener | ||
// to be able to format the field | ||
_this.hasKeypressEvent = false; | ||
}); | ||
@@ -110,3 +116,3 @@ this.inputElement.addEventListener("input", function (e) { | ||
BaseStrategy.prototype.isDeletion = function (event) { | ||
return is_delete_1.isDelete(event) || is_backspace_1.isBackspace(event); | ||
return (0, is_delete_1.isDelete)(event) || (0, is_backspace_1.isBackspace)(event); | ||
}; | ||
@@ -120,7 +126,7 @@ BaseStrategy.prototype.reformatInput = function () { | ||
var formattedState = this.formatter.format({ | ||
selection: input_selection_1.get(input), | ||
selection: (0, input_selection_1.get)(input), | ||
value: input.value, | ||
}); | ||
input.value = formattedState.value; | ||
input_selection_1.set(input, formattedState.selection.start, formattedState.selection.end); | ||
(0, input_selection_1.set)(input, formattedState.selection.start, formattedState.selection.end); | ||
this.afterReformatInput(formattedState); | ||
@@ -141,3 +147,3 @@ }; | ||
var input = this.inputElement; | ||
var selection = input_selection_1.get(input); | ||
var selection = (0, input_selection_1.get)(input); | ||
var unformattedState = this.formatter.unformat({ | ||
@@ -148,3 +154,3 @@ selection: selection, | ||
input.value = unformattedState.value; | ||
input_selection_1.set(input, unformattedState.selection.start, unformattedState.selection.end); | ||
(0, input_selection_1.set)(input, unformattedState.selection.start, unformattedState.selection.end); | ||
}; | ||
@@ -171,3 +177,3 @@ BaseStrategy.prototype.prePasteEventHandler = function (event) { | ||
} | ||
var selection = input_selection_1.get(this.inputElement); | ||
var selection = (0, input_selection_1.get)(this.inputElement); | ||
splicedEntry = this.inputElement.value.split(""); | ||
@@ -182,3 +188,3 @@ splicedEntry.splice(selection.start, selection.end - selection.start, entryValue); | ||
this.inputElement.value = splicedEntry; | ||
input_selection_1.set(this.inputElement, selection.start + entryValue.length, selection.start + entryValue.length); | ||
(0, input_selection_1.set)(this.inputElement, selection.start + entryValue.length, selection.start + entryValue.length); | ||
this.postPasteEventHandler(); | ||
@@ -194,3 +200,3 @@ }; | ||
var input = this.inputElement; | ||
var selection = input_selection_1.get(input); | ||
var selection = (0, input_selection_1.get)(input); | ||
var stateToFormat = { | ||
@@ -213,3 +219,3 @@ selection: selection, | ||
} | ||
if (key_cannot_mutate_value_1.keyCannotMutateValue(event)) { | ||
if ((0, key_cannot_mutate_value_1.keyCannotMutateValue)(event)) { | ||
return; | ||
@@ -216,0 +222,0 @@ } |
@@ -53,6 +53,6 @@ "use strict"; | ||
input.value = formattedState.value; | ||
input_selection_1.set(input, formattedState.selection.start, formattedState.selection.end); | ||
(0, input_selection_1.set)(input, formattedState.selection.start, formattedState.selection.end); | ||
}; | ||
IE9Strategy.prototype.keydownListener = function (event) { | ||
if (key_cannot_mutate_value_1.keyCannotMutateValue(event)) { | ||
if ((0, key_cannot_mutate_value_1.keyCannotMutateValue)(event)) { | ||
return; | ||
@@ -64,3 +64,3 @@ } | ||
event: event, | ||
selection: input_selection_1.get(this.inputElement), | ||
selection: (0, input_selection_1.get)(this.inputElement), | ||
value: this.inputElement.value, | ||
@@ -75,3 +75,3 @@ }); | ||
var oldValue = this.inputElement.value; | ||
var selection = input_selection_1.get(this.inputElement); | ||
var selection = (0, input_selection_1.get)(this.inputElement); | ||
var newValue = oldValue.slice(0, selection.start) + | ||
@@ -93,3 +93,3 @@ event.key + | ||
var input = this.inputElement; | ||
var selection = input_selection_1.get(this.inputElement); | ||
var selection = (0, input_selection_1.get)(this.inputElement); | ||
var value = this.formatter.format({ | ||
@@ -105,3 +105,3 @@ selection: selection, | ||
setTimeout(function () { | ||
input_selection_1.set(input, selection.start, selection.end); | ||
(0, input_selection_1.set)(input, selection.start, selection.end); | ||
}, 0); | ||
@@ -108,0 +108,0 @@ }; |
@@ -73,6 +73,6 @@ "use strict"; | ||
input.value = formattedState.value; | ||
input_selection_1.set(input, formattedState.selection.start, formattedState.selection.end); | ||
(0, input_selection_1.set)(input, formattedState.selection.start, formattedState.selection.end); | ||
}; | ||
IosStrategy.prototype.keydownListener = function (event) { | ||
if (key_cannot_mutate_value_1.keyCannotMutateValue(event)) { | ||
if ((0, key_cannot_mutate_value_1.keyCannotMutateValue)(event)) { | ||
return; | ||
@@ -83,3 +83,3 @@ } | ||
event: event, | ||
selection: input_selection_1.get(this.inputElement), | ||
selection: (0, input_selection_1.get)(this.inputElement), | ||
value: this.inputElement.value, | ||
@@ -86,0 +86,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
// Digits get dropped in samsung browser | ||
return !device_1.isSamsungBrowser(); | ||
return !(0, device_1.isSamsungBrowser)(); | ||
}; |
{ | ||
"name": "restricted-input", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Restrict inputs to certain valid characters (e.g. formatting phone or card numbers)", | ||
@@ -48,28 +48,30 @@ "author": "Braintree <code@getbraintree.com> (https://www.braintreepayments.com/)", | ||
"dependencies": { | ||
"@braintree/browser-detection": "^1.12.0" | ||
"@braintree/browser-detection": "^1.12.1" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.23", | ||
"@wdio/browserstack-service": "^7.7.4", | ||
"@wdio/cli": "^7.7.4", | ||
"@wdio/local-runner": "^7.7.4", | ||
"@wdio/mocha-framework": "^7.7.4", | ||
"@wdio/spec-reporter": "^7.7.3", | ||
"@wdio/sync": "^7.7.4", | ||
"@types/jest": "^27.4.0", | ||
"@typescript-eslint/eslint-plugin": "^5.9.0", | ||
"@wdio/browserstack-service": "^7.16.12", | ||
"@wdio/cli": "^7.16.12", | ||
"@wdio/local-runner": "^7.16.12", | ||
"@wdio/mocha-framework": "^7.16.11", | ||
"@wdio/spec-reporter": "^7.16.11", | ||
"@wdio/sync": "^7.16.12", | ||
"browserify": "^17.0.0", | ||
"browserstack-local": "^1.4.8", | ||
"chai": "^4.3.4", | ||
"chokidar-cli": "^2.1.0", | ||
"chokidar-cli": "^3.0.0", | ||
"dotenv": "^10.0.0", | ||
"eslint": "^7.29.0", | ||
"eslint-config-braintree": "^5.0.0-typescript-prep-rc.18", | ||
"express": "^4.17.1", | ||
"jest": "^27.0.5", | ||
"eslint": "^8.6.0", | ||
"eslint-config-braintree": "^6.0.0-typescript-prep-rc.2", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"express": "^4.17.2", | ||
"jest": "^27.4.5", | ||
"jsdoc": "^3.6.7", | ||
"prettier": "^2.3.1", | ||
"ts-jest": "^27.0.3", | ||
"prettier": "^2.5.1", | ||
"ts-jest": "^27.1.2", | ||
"tsify": "^5.0.4", | ||
"typescript": "^4.3.4", | ||
"typescript": "^4.5.4", | ||
"uuid": "^8.3.2", | ||
"webdriverio": "^7.7.4" | ||
"webdriverio": "^7.16.3" | ||
}, | ||
@@ -76,0 +78,0 @@ "jest": { |
1126
55240
25
40