@goweekdays/layer-common 1.6.2 → 1.6.3
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.
- package/CHANGELOG.md +6 -0
- package/components/Input/Currency.vue +39 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -37,22 +37,58 @@ const format = () => {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
function onInput(val: string) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
// Filter out any non-numeric characters except commas
|
|
41
|
+
const filtered = val.replace(/[^0-9,]/g, "");
|
|
42
|
+
model.value = parse(filtered);
|
|
43
|
+
display.value = filtered;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
function onKeydown(e: KeyboardEvent) {
|
|
47
|
+
// Allow: backspace, delete, tab, escape, enter, arrows, home, end
|
|
48
|
+
const allowedKeys = [
|
|
49
|
+
"Backspace",
|
|
50
|
+
"Delete",
|
|
51
|
+
"Tab",
|
|
52
|
+
"Escape",
|
|
53
|
+
"Enter",
|
|
54
|
+
"ArrowLeft",
|
|
55
|
+
"ArrowRight",
|
|
56
|
+
"ArrowUp",
|
|
57
|
+
"ArrowDown",
|
|
58
|
+
"Home",
|
|
59
|
+
"End",
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
// Allow: Ctrl/Cmd+A, Ctrl/Cmd+C, Ctrl/Cmd+V, Ctrl/Cmd+X
|
|
63
|
+
if (
|
|
64
|
+
(e.ctrlKey || e.metaKey) &&
|
|
65
|
+
["a", "c", "v", "x"].includes(e.key.toLowerCase())
|
|
66
|
+
) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
46
70
|
if (e.key === "ArrowUp") {
|
|
47
71
|
e.preventDefault();
|
|
48
72
|
model.value += localProps.step;
|
|
49
73
|
format();
|
|
74
|
+
return;
|
|
50
75
|
}
|
|
51
76
|
|
|
52
77
|
if (e.key === "ArrowDown") {
|
|
53
78
|
e.preventDefault();
|
|
54
79
|
model.value = Math.max(0, model.value - localProps.step);
|
|
55
80
|
format();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Allow navigation and control keys
|
|
85
|
+
if (allowedKeys.includes(e.key)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Block if not a number or comma
|
|
90
|
+
if (!/^[0-9,]$/.test(e.key)) {
|
|
91
|
+
e.preventDefault();
|
|
56
92
|
}
|
|
57
93
|
}
|
|
58
94
|
|