credit-card-input-mask
Advanced tools
Comparing version 3.0.0 to 3.0.1
import { Pattern } from "./parse-pattern"; | ||
import type { Selection } from "../input-selection"; | ||
export declare type FormatMetadata = { | ||
export type FormatMetadata = { | ||
value: string; | ||
@@ -5,0 +5,0 @@ selection: Selection; |
@@ -8,3 +8,3 @@ "use strict"; | ||
function PatternFormatter(pattern) { | ||
this.pattern = parse_pattern_1.parsePattern(pattern); | ||
this.pattern = (0, parse_pattern_1.parsePattern)(pattern); | ||
} | ||
@@ -108,3 +108,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); | ||
@@ -111,0 +111,0 @@ deletionEnd = selection.start; |
@@ -1,2 +0,2 @@ | ||
export declare type Pattern = { | ||
export type Pattern = { | ||
value: RegExp | string; | ||
@@ -3,0 +3,0 @@ isPermaChar: boolean; |
@@ -7,3 +7,3 @@ "use strict"; | ||
var WILD_REGEX = /./; | ||
var PLACEHOLDER_REGEX = /^[A-Za-z0-9\*]$/; | ||
var PLACEHOLDER_REGEX = /^[A-Za-z0-9*]$/; | ||
var PLACEHOLDER_PATTERN = "({{[^}]+}})"; | ||
@@ -10,0 +10,0 @@ var PERMACHAR_REGEX = "(\\s|\\S)"; |
import { Input } from "./strategies/strategy-interface"; | ||
export declare type Selection = { | ||
export type Selection = { | ||
start: number; | ||
@@ -4,0 +4,0 @@ end: number; |
@@ -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; | ||
@@ -38,3 +38,3 @@ } | ||
this.inputElement.addEventListener("keypress", function (event) { | ||
if (key_cannot_mutate_value_1.keyCannotMutateValue(event)) { | ||
if ((0, key_cannot_mutate_value_1.keyCannotMutateValue)(event)) { | ||
return; | ||
@@ -86,3 +86,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); | ||
@@ -89,0 +89,0 @@ }; |
@@ -68,3 +68,3 @@ "use strict"; | ||
} | ||
if (key_cannot_mutate_value_1.keyCannotMutateValue(event)) { | ||
if ((0, key_cannot_mutate_value_1.keyCannotMutateValue)(event)) { | ||
return; | ||
@@ -81,3 +81,3 @@ } | ||
} | ||
if (key_cannot_mutate_value_1.keyCannotMutateValue(event)) { | ||
if ((0, key_cannot_mutate_value_1.keyCannotMutateValue)(event)) { | ||
return; | ||
@@ -105,3 +105,3 @@ } | ||
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); | ||
}; | ||
@@ -115,7 +115,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); | ||
@@ -136,3 +136,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({ | ||
@@ -143,3 +143,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); | ||
}; | ||
@@ -166,3 +166,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(""); | ||
@@ -177,3 +177,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(); | ||
@@ -189,3 +189,3 @@ }; | ||
var input = this.inputElement; | ||
var selection = input_selection_1.get(input); | ||
var selection = (0, input_selection_1.get)(input); | ||
var stateToFormat = { | ||
@@ -192,0 +192,0 @@ selection: selection, |
@@ -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 @@ }); |
@@ -1,6 +0,6 @@ | ||
export declare type Input = HTMLInputElement | HTMLTextAreaElement; | ||
export declare type OnPasteEventMethod = (options: { | ||
export type Input = HTMLInputElement | HTMLTextAreaElement; | ||
export type OnPasteEventMethod = (options: { | ||
unformattedInputValue: string; | ||
}) => void; | ||
export declare type StrategyOptions = { | ||
export type StrategyOptions = { | ||
element: Input; | ||
@@ -7,0 +7,0 @@ pattern: string; |
@@ -5,3 +5,3 @@ "use strict"; | ||
// Digits get dropped in samsung browser | ||
return !device_1.isSamsungBrowser(); | ||
return !(0, device_1.isSamsungBrowser)(); | ||
}; |
{ | ||
"name": "credit-card-input-mask", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Restrict inputs to certain valid characters (e.g. formatting phone or card numbers)", | ||
@@ -5,0 +5,0 @@ "author": "Braintree <code@getbraintree.com> (https://www.braintreepayments.com/)", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
54884
0