@unifylib/ui-lib 1.1.29 → 1.1.31
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.
|
@@ -1805,6 +1805,8 @@ class DecimalOnlyDirective {
|
|
|
1805
1805
|
this.el = el;
|
|
1806
1806
|
}
|
|
1807
1807
|
onKeyDown(event) {
|
|
1808
|
+
const input = this.el.nativeElement;
|
|
1809
|
+
const cursor = input.selectionStart ?? 0;
|
|
1808
1810
|
if (event.ctrlKey ||
|
|
1809
1811
|
event.metaKey ||
|
|
1810
1812
|
event.altKey ||
|
|
@@ -1812,7 +1814,7 @@ class DecimalOnlyDirective {
|
|
|
1812
1814
|
return;
|
|
1813
1815
|
}
|
|
1814
1816
|
if (event.key === '.') {
|
|
1815
|
-
if (
|
|
1817
|
+
if (cursor === 0 || input.value.includes('.')) {
|
|
1816
1818
|
event.preventDefault();
|
|
1817
1819
|
}
|
|
1818
1820
|
return;
|
|
@@ -1823,7 +1825,7 @@ class DecimalOnlyDirective {
|
|
|
1823
1825
|
}
|
|
1824
1826
|
onPaste(event) {
|
|
1825
1827
|
const pasted = event.clipboardData?.getData('text') ?? '';
|
|
1826
|
-
if (!/^\d
|
|
1828
|
+
if (!/^\d+(\.\d*)?$/.test(pasted)) {
|
|
1827
1829
|
event.preventDefault();
|
|
1828
1830
|
}
|
|
1829
1831
|
}
|