@canutin/svelte-currency-input 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -50,6 +50,7 @@ function handleKeyDown(event) {
|
|
|
50
50
|
const isModifier = event.metaKey || event.altKey || event.ctrlKey;
|
|
51
51
|
const isArrowKey = event.key === "ArrowLeft" || event.key === "ArrowRight";
|
|
52
52
|
const isTab = event.key === "Tab";
|
|
53
|
+
const isEnter = event.key === "Enter";
|
|
53
54
|
const isInvalidCharacter = !/^\d|,|\.|-$/g.test(event.key);
|
|
54
55
|
function isPunctuationDuplicated() {
|
|
55
56
|
if (event.key !== "," && event.key !== ".") return false;
|
|
@@ -57,7 +58,7 @@ function handleKeyDown(event) {
|
|
|
57
58
|
if (!isDecimalComma) return formattedValue.split(".").length >= 2;
|
|
58
59
|
return false;
|
|
59
60
|
}
|
|
60
|
-
if (isPunctuationDuplicated() || !isDeletion && !isModifier && !isArrowKey && isInvalidCharacter && !isTab)
|
|
61
|
+
if (isPunctuationDuplicated() || !isDeletion && !isModifier && !isArrowKey && isInvalidCharacter && !isTab && !isEnter)
|
|
61
62
|
event.preventDefault();
|
|
62
63
|
}
|
|
63
64
|
function handlePlaceholder(placeholder2) {
|