@unifylib/ui-lib 1.1.30 → 1.1.32

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.
@@ -1806,9 +1806,7 @@ class DecimalOnlyDirective {
1806
1806
  }
1807
1807
  onKeyDown(event) {
1808
1808
  const input = this.el.nativeElement;
1809
- const value = input.value;
1810
- const start = input.selectionStart ?? 0;
1811
- const end = input.selectionEnd ?? 0;
1809
+ const cursor = input.selectionStart ?? 0;
1812
1810
  if (event.ctrlKey ||
1813
1811
  event.metaKey ||
1814
1812
  event.altKey ||
@@ -1816,7 +1814,7 @@ class DecimalOnlyDirective {
1816
1814
  return;
1817
1815
  }
1818
1816
  if (event.key === '.') {
1819
- if (value.includes('.') || start === 0 || start === value.length) {
1817
+ if (cursor === 0 || input.value.includes('.')) {
1820
1818
  event.preventDefault();
1821
1819
  }
1822
1820
  return;
@@ -1825,20 +1823,14 @@ class DecimalOnlyDirective {
1825
1823
  event.preventDefault();
1826
1824
  }
1827
1825
  }
1828
- onBlur() {
1829
- const input = this.el.nativeElement;
1830
- if (input.value.endsWith('.')) {
1831
- input.value = input.value.slice(0, -1);
1832
- }
1833
- }
1834
1826
  onPaste(event) {
1835
1827
  const pasted = event.clipboardData?.getData('text') ?? '';
1836
- if (!/^\d+(\.\d+)?$/.test(pasted)) {
1828
+ if (!/^\d+(\.\d*)?$/.test(pasted)) {
1837
1829
  event.preventDefault();
1838
1830
  }
1839
1831
  }
1840
1832
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DecimalOnlyDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
1841
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: DecimalOnlyDirective, isStandalone: true, selector: "[numbersOnly]", host: { listeners: { "keydown": "onKeyDown($event)", "blur": "onBlur()", "paste": "onPaste($event)" } }, ngImport: i0 }); }
1833
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: DecimalOnlyDirective, isStandalone: true, selector: "[numbersOnly]", host: { listeners: { "keydown": "onKeyDown($event)", "paste": "onPaste($event)" } }, ngImport: i0 }); }
1842
1834
  }
1843
1835
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DecimalOnlyDirective, decorators: [{
1844
1836
  type: Directive,
@@ -1849,9 +1841,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
1849
1841
  }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { onKeyDown: [{
1850
1842
  type: HostListener,
1851
1843
  args: ['keydown', ['$event']]
1852
- }], onBlur: [{
1853
- type: HostListener,
1854
- args: ['blur']
1855
1844
  }], onPaste: [{
1856
1845
  type: HostListener,
1857
1846
  args: ['paste', ['$event']]