@tetacom/ng-components 1.5.0 → 1.5.1
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.
|
@@ -18,6 +18,7 @@ export declare class OnlyNumberDirective {
|
|
|
18
18
|
private readonly _minusSign;
|
|
19
19
|
constructor(_elementRef: ElementRef<HTMLInputElement>, _control: NgControl);
|
|
20
20
|
onChange(e: any): void;
|
|
21
|
+
onBlur(e: any): void;
|
|
21
22
|
dblclick(e: any): void;
|
|
22
23
|
onPaste(e: any): void;
|
|
23
24
|
onKeyDown(e: KeyboardEvent): void;
|
|
@@ -3801,7 +3801,18 @@ class OnlyNumberDirective {
|
|
|
3801
3801
|
if (this.tetaOnlyNumber === false) {
|
|
3802
3802
|
return;
|
|
3803
3803
|
}
|
|
3804
|
-
|
|
3804
|
+
e.preventDefault();
|
|
3805
|
+
e.stopPropagation();
|
|
3806
|
+
// this.validateValue(this._elementRef.nativeElement.value);
|
|
3807
|
+
}
|
|
3808
|
+
onBlur(e) {
|
|
3809
|
+
e.preventDefault();
|
|
3810
|
+
e.stopPropagation();
|
|
3811
|
+
const value = this._elementRef.nativeElement.value;
|
|
3812
|
+
if (value.endsWith('.')) {
|
|
3813
|
+
this._elementRef.nativeElement.value = value.replace('.', '');
|
|
3814
|
+
this._elementRef.nativeElement.dispatchEvent(new Event('input'));
|
|
3815
|
+
}
|
|
3805
3816
|
}
|
|
3806
3817
|
dblclick(e) {
|
|
3807
3818
|
if (this.tetaOnlyNumber === false) {
|
|
@@ -3828,11 +3839,7 @@ class OnlyNumberDirective {
|
|
|
3828
3839
|
const allowedKeys = ['Backspace', 'ArrowLeft', 'ArrowRight', 'Delete', 'Escape', 'Tab', 'Home', 'End'];
|
|
3829
3840
|
const separatorIsCloseToSign = signExists && cursorPosition <= 1;
|
|
3830
3841
|
if (this.allowDecimals && !separatorIsCloseToSign && !separatorExists) {
|
|
3831
|
-
// if (this.decimalSeparator === '.') {
|
|
3832
3842
|
allowedKeys.push('.');
|
|
3833
|
-
// } else {
|
|
3834
|
-
// allowedKeys.push(',');
|
|
3835
|
-
// }
|
|
3836
3843
|
}
|
|
3837
3844
|
const firstCharacterIsSeparator = originalValue.charAt(0) !== this.decimalSeparator;
|
|
3838
3845
|
if (this.allowSign && !signExists && firstCharacterIsSeparator && cursorPosition === 0 && !this.onlyPositive) {
|
|
@@ -3853,11 +3860,8 @@ class OnlyNumberDirective {
|
|
|
3853
3860
|
}
|
|
3854
3861
|
else {
|
|
3855
3862
|
if (e.key === ',' && originalValue.indexOf('.') < 0) {
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
this._control.control.patchValue(`${originalValue.slice(0, cursorPosition)}.${originalValue.slice(cursorPosition)}`, {
|
|
3859
|
-
emitEvent: false,
|
|
3860
|
-
});
|
|
3863
|
+
this._elementRef.nativeElement.value = `${originalValue.slice(0, cursorPosition)}.${originalValue.slice(cursorPosition)}`;
|
|
3864
|
+
this._elementRef.nativeElement.dispatchEvent(new Event('input'));
|
|
3861
3865
|
if (this._elementRef.nativeElement.setSelectionRange) {
|
|
3862
3866
|
this._elementRef.nativeElement.setSelectionRange(cursorPosition + 1, cursorPosition + 1);
|
|
3863
3867
|
}
|
|
@@ -3928,9 +3932,12 @@ class OnlyNumberDirective {
|
|
|
3928
3932
|
emitEvent: false,
|
|
3929
3933
|
});
|
|
3930
3934
|
}
|
|
3935
|
+
else {
|
|
3936
|
+
console.error('INVALID VALUE');
|
|
3937
|
+
}
|
|
3931
3938
|
}
|
|
3932
3939
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: OnlyNumberDirective, deps: [{ token: i0.ElementRef }, { token: i2.NgControl }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
3933
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.5", type: OnlyNumberDirective, isStandalone: true, selector: "[tetaOnlyNumber]", inputs: { tetaOnlyNumber: "tetaOnlyNumber", allowDecimals: "allowDecimals", allowSign: "allowSign", decimalSeparator: "decimalSeparator", commaSeparator: "commaSeparator", onlyPositive: "onlyPositive" }, host: { listeners: { "
|
|
3940
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.5", type: OnlyNumberDirective, isStandalone: true, selector: "[tetaOnlyNumber]", inputs: { tetaOnlyNumber: "tetaOnlyNumber", allowDecimals: "allowDecimals", allowSign: "allowSign", decimalSeparator: "decimalSeparator", commaSeparator: "commaSeparator", onlyPositive: "onlyPositive" }, host: { listeners: { "input": "onChange($event)", "blur": "onBlur($event)", "dblclick": "dblclick($event)", "paste": "onPaste($event)", "keydown": "onKeyDown($event)" } }, ngImport: i0 }); }
|
|
3934
3941
|
}
|
|
3935
3942
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: OnlyNumberDirective, decorators: [{
|
|
3936
3943
|
type: Directive,
|
|
@@ -3952,7 +3959,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
|
|
|
3952
3959
|
type: Input
|
|
3953
3960
|
}], onChange: [{
|
|
3954
3961
|
type: HostListener,
|
|
3955
|
-
args: ['
|
|
3962
|
+
args: ['input', ['$event']]
|
|
3963
|
+
}], onBlur: [{
|
|
3964
|
+
type: HostListener,
|
|
3965
|
+
args: ['blur', ['$event']]
|
|
3956
3966
|
}], dblclick: [{
|
|
3957
3967
|
type: HostListener,
|
|
3958
3968
|
args: ['dblclick', ['$event']]
|