@experteam-mx/ngx-input-number 1.6.5 → 1.6.6
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/esm2020/experteam-mx-ngx-input-number.mjs +5 -0
- package/esm2020/lib/di.mjs +3 -0
- package/esm2020/lib/ngx-input-number.component.mjs +148 -0
- package/esm2020/lib/ngx-input-number.module.mjs +49 -0
- package/esm2020/lib/ngx-input-number.service.mjs +63 -0
- package/esm2020/lib/types.mjs +5 -0
- package/esm2020/lib/typesProvider.mjs +30 -0
- package/esm2020/public-api.mjs +9 -0
- package/experteam-mx-ngx-input-number.d.ts +5 -0
- package/fesm2015/experteam-mx-ngx-input-number.mjs +297 -0
- package/fesm2015/experteam-mx-ngx-input-number.mjs.map +1 -0
- package/fesm2020/experteam-mx-ngx-input-number.mjs +295 -0
- package/fesm2020/experteam-mx-ngx-input-number.mjs.map +1 -0
- package/{src/lib/di.ts → lib/di.d.ts} +1 -2
- package/lib/ngx-input-number.component.d.ts +36 -0
- package/lib/ngx-input-number.module.d.ts +13 -0
- package/lib/ngx-input-number.service.d.ts +18 -0
- package/lib/types.d.ts +12 -0
- package/lib/typesProvider.d.ts +19 -0
- package/package.json +22 -5
- package/{src/public-api.ts → public-api.d.ts} +5 -9
- package/.browserslistrc +0 -16
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -11
- package/src/lib/ngx-input-number.component.html +0 -14
- package/src/lib/ngx-input-number.component.sass +0 -11
- package/src/lib/ngx-input-number.component.spec.ts +0 -25
- package/src/lib/ngx-input-number.component.ts +0 -160
- package/src/lib/ngx-input-number.module.ts +0 -38
- package/src/lib/ngx-input-number.service.spec.ts +0 -16
- package/src/lib/ngx-input-number.service.ts +0 -59
- package/src/lib/types.ts +0 -14
- package/src/lib/typesProvider.ts +0 -26
- package/src/test.ts +0 -27
- package/tsconfig.lib.json +0 -27
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experteam-mx-ngx-input-number.mjs","sources":["../../../projects/ngx-input-number/src/lib/typesProvider.ts","../../../projects/ngx-input-number/src/lib/di.ts","../../../projects/ngx-input-number/src/lib/types.ts","../../../projects/ngx-input-number/src/lib/ngx-input-number.service.ts","../../../projects/ngx-input-number/src/lib/ngx-input-number.component.ts","../../../projects/ngx-input-number/src/lib/ngx-input-number.component.html","../../../projects/ngx-input-number/src/lib/ngx-input-number.module.ts","../../../projects/ngx-input-number/src/public-api.ts","../../../projects/ngx-input-number/src/experteam-mx-ngx-input-number.ts"],"sourcesContent":["import { Injectable, Provider } from '@angular/core';\r\n\r\nexport class inputConfigs {\r\n groupSeparator?: string;\r\n radixPoint?: string;\r\n}\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport abstract class typesProvider {\r\n abstract get config(): inputConfigs;\r\n}\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class defaultTypesProvider extends typesProvider {\r\n get config(): inputConfigs {\r\n // return default config\r\n return {\r\n groupSeparator: \",\",\r\n radixPoint: \".\"\r\n };\r\n }\r\n}\r\n\r\nexport class inputConfigsHelp {\r\n config?: Provider;\r\n}","import { InjectionToken } from '@angular/core';\r\nimport { inputConfigs } from './types';\r\n\r\nexport const INPUT_CONFIG_TOKEN = new InjectionToken<inputConfigs>('INPUT_CONFIG');","import { Provider } from '@angular/core';\r\n\r\nexport class inputConfigs {\r\n groupSeparator?: string;\r\n radixPoint?: string;\r\n lblKeyInvalid?: string;\r\n max?: number;\r\n decimals?: number;\r\n negative?: boolean;\r\n}\r\n\r\nexport class inputConfigsHelp {\r\n config?: Provider;\r\n}","import { Injectable, Optional, Inject, EventEmitter, Output } from '@angular/core';\nimport { INPUT_CONFIG_TOKEN } from './di';\nimport { inputConfigs } from './types';\nimport { BehaviorSubject, Subject } from \"rxjs\";\n\n@Injectable({\n providedIn: 'root'\n})\nexport class NgxInputNumberService {\n\n changeEvent = new BehaviorSubject<boolean>(false);\n groupSeparator = ','\n radixPoint = '.'\n lblKeyInvalid = 'Please enter a valid amount'\n negative: any = true\n max: any = undefined\n decimals = 2\n\n constructor(\n @Optional() @Inject(INPUT_CONFIG_TOKEN)\n private readonly config: inputConfigs | null,\n ) {\n if( config != null ){\n this.groupSeparator = config.groupSeparator!\n this.radixPoint = config.radixPoint!\n this.lblKeyInvalid = config.lblKeyInvalid!\n this.negative = config.negative!\n this.max = config.max!\n this.decimals = config.decimals!\n }\n }\n\n onChangeParams( config: inputConfigs ){\n if( config.groupSeparator ){\n this.groupSeparator = config.groupSeparator\n }\n if( config.radixPoint ){\n this.radixPoint = config.radixPoint\n }\n if( config.lblKeyInvalid ){\n this.lblKeyInvalid = config.lblKeyInvalid\n }\n if( config.negative !== undefined ){\n this.negative = config.negative\n }\n if( config.max ){\n this.max = config.max!\n }\n if( config.decimals ){\n this.decimals = config.decimals\n }\n\n this.changeEvent.next( true )\n }\n\n getChangeEvent(){\n return this.changeEvent\n }\n}\n","import { Component, OnInit, Input, OnChanges, AfterViewInit, AfterContentInit, ElementRef, ViewChild, SimpleChanges, ChangeDetectorRef } from '@angular/core';\nimport { FormBuilder, Validators, FormArray, FormGroup, FormControl } from \"@angular/forms\";\nimport { createMask, InputmaskOptions } from '@ngneat/input-mask';\n\nimport { inputConfigs, typesProvider } from './typesProvider';\nimport { NgxInputNumberService } from './ngx-input-number.service';\n\n@Component({\n selector: 'app-input-number',\n templateUrl: './ngx-input-number.component.html',\n styleUrls: ['./ngx-input-number.component.sass']\n})\nexport class NgxInputNumberComponent implements OnInit, OnChanges {\n\n constructor(\n private _ChangeDetectorRef: ChangeDetectorRef,\n private readonly _typesProvider: typesProvider,\n private _NgxInputNumberService: NgxInputNumberService,\n ) { }\n\n @ViewChild('inputElement') inputElement!: ElementRef;\n\n @Input() control!: FormControl\n @Input() negative!: any\n @Input() autofocus: any = false\n @Input() decimals: any\n @Input() max: any\n @Input() idForLabel: any = \"\"\n @Input() tabIndex: any\n @Input() addClass: any = \"form-control-sm\"\n @Input() groupSeparator: any\n @Input() radixPoint: any\n @Input() lblKeyInvalid: any\n lblKeyInvalidRender: any\n\n inputMask: InputmaskOptions<any> = {}\n\n placeholder = \"0\"\n\n loading = false\n\n ngAfterViewInit(): void {\n if( this.autofocus ){\n setTimeout(()=>{\n this.inputElement.nativeElement.focus();\n })\n }\n }\n\n ngAfterContentInit(): void {\n }\n\n render(){\n this._ChangeDetectorRef.detectChanges()\n\n this.lblKeyInvalidRender = this._NgxInputNumberService.lblKeyInvalid\n\n this.inputMask = createMask({\n allowMinus: this._NgxInputNumberService.negative,\n alias: 'numeric',\n numericInput: false,\n inputType: \"number\",\n inputmode: \"numeric\",\n groupSeparator: this._NgxInputNumberService.groupSeparator,\n radixPoint : this._NgxInputNumberService.radixPoint,\n max : this._NgxInputNumberService.max,\n digits: this._NgxInputNumberService.decimals,\n digitsOptional: false,\n placeholder: '0',\n unmaskAsNumber: true,\n autoUnmask: true,\n showMaskOnFocus: false,\n showMaskOnHover: false,\n onBeforePaste: ( pastedValue: any, opts ) =>{\n return pastedValue.replaceAll( opts.groupSeparator!, \"\" )\n },\n onKeyValidation: ( key, result ) => {\n if( !result ){\n this.inputElement.nativeElement.classList.add(\"key-invalid\")\n setTimeout(\n ()=>{\n this.inputElement.nativeElement.classList.remove(\"key-invalid\")\n },\n 1000\n )\n }\n }\n })\n \n if( this.negative !== undefined ){\n this.inputMask.allowMinus = this.negative\n }\n if( this.max !== undefined ){\n this.inputMask.max = this.max\n }\n \n if( this.groupSeparator !== undefined ){\n this.inputMask.groupSeparator = this.groupSeparator\n }\n if( this.radixPoint !== undefined ){\n this.inputMask.radixPoint = this.radixPoint\n }\n if( this.lblKeyInvalid !== undefined ){\n this.lblKeyInvalidRender = this.lblKeyInvalid\n }\n\n if( this.decimals !== undefined ){\n this.inputMask.digits = this.decimals\n }\n\n\n\n if( this.inputMask.digits! > 0 ){\n this.placeholder = '0' + String(this.inputMask.radixPoint)\n }\n for( let x = 0; x < this.inputMask.digits!; x++ ){\n this.placeholder += \"0\"\n }\n\n this.loading = false\n\n }\n\n onBlur(value: any){\n // if( value != '' && Number( this.inputMask.digits ) > 0 ){\n // let valueBlurSplit = String(value).split(\".\")\n // let valueString = \"\"\n // if( valueBlurSplit.length == 1 ){\n // valueString = valueBlurSplit[0] + \".\" + String(\"\").padEnd(Number(this.inputMask.digits), \"0\")\n // }else{\n // valueString = valueBlurSplit[0] + \".\" + String(valueBlurSplit[1]).padEnd(Number(this.inputMask.digits), \"0\")\n // }\n // this.control.setValue( parseFloat( valueString ) )\n // }\n this.control.setValue( value )\n }\n\n ngOnInit(): void {\n this._NgxInputNumberService.getChangeEvent().subscribe(\n ( configs )=>{\n if( configs ){\n this.loading = true\n\n setTimeout(() => {\n this.render()\n }, 0);\n }\n }\n )\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n this.loading = true\n\n setTimeout(() => {\n this.render()\n }, 0);\n }\n\n}\n","<div class=\"position-relative\">\r\n <input\r\n *ngIf=\"!loading\"\r\n #inputElement\r\n type=\"text\"\r\n class=\"form-control {{ addClass }}\"\r\n [class.is-invalid]=\"control.touched && control.invalid\"\r\n [formControl]=\"control\"\r\n [tabindex]=\"tabIndex\"\r\n [(inputMask)]=\"inputMask\"\r\n [id]=\"idForLabel\"\r\n >\r\n <label class=\"lbl-key-invalid position-absolute top-100 end-0 p-2 d-none\" [innerHTML]=\"lblKeyInvalidRender\"></label>\r\n</div>\r\n","import { NgModule, ModuleWithProviders } from '@angular/core';\nimport { CommonModule } from '@angular/common'; \nimport { FormsModule, ReactiveFormsModule } from \"@angular/forms\";\n\nimport { NgxInputNumberComponent } from './ngx-input-number.component';\nimport { InputMaskModule } from '@ngneat/input-mask';\n\nimport { inputConfigsHelp, typesProvider, defaultTypesProvider } from './typesProvider';\n\n@NgModule({\n declarations: [\n NgxInputNumberComponent\n ],\n imports: [\n CommonModule,\n InputMaskModule.forRoot({ inputSelector: 'input', isAsync: true }),\n FormsModule,\n ReactiveFormsModule,\n ],\n exports: [\n NgxInputNumberComponent\n ],\n providers:[\n ]\n})\nexport class NgxInputNumberModule {\n static forRoot(config: inputConfigsHelp = {} ): ModuleWithProviders<NgxInputNumberModule> {\n return {\n ngModule: NgxInputNumberModule,\n providers: [\n config.config || {\n provide: typesProvider,\n useClass: defaultTypesProvider\n }\n ],\n }\n }\n}\n","/*\n * Public API Surface of ngx-input-number\n */\n\nexport * from './lib/typesProvider';\nexport * from './lib/ngx-input-number.service';\nexport * from './lib/ngx-input-number.component';\nexport * from './lib/ngx-input-number.module';\nexport * from '@ngneat/input-mask';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["inputConfigs","inputConfigsHelp"],"mappings":";;;;;;;;;;;MAEaA,cAAY;CAGxB;MAGqB,aAAa;;0GAAb,aAAa;8GAAb,aAAa,cADT,MAAM;2FACV,aAAa;kBADlC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;MAMrB,oBAAqB,SAAQ,aAAa;IACrD,IAAI,MAAM;;QAER,OAAO;YACH,cAAc,EAAE,GAAG;YACnB,UAAU,EAAE,GAAG;SAClB,CAAC;KACH;;iHAPU,oBAAoB;qHAApB,oBAAoB,cADP,MAAM;2FACnB,oBAAoB;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;MAWrBC,kBAAgB;;;ACpBtB,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAAe,cAAc,CAAC;;MCDrE,YAAY;CAOxB;MAEY,gBAAgB;;;MCHhB,qBAAqB;IAUhC,YAEmB,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;QAV9C,gBAAW,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC,CAAC;QAClD,mBAAc,GAAG,GAAG,CAAA;QACpB,eAAU,GAAG,GAAG,CAAA;QAChB,kBAAa,GAAG,6BAA6B,CAAA;QAC7C,aAAQ,GAAQ,IAAI,CAAA;QACpB,QAAG,GAAQ,SAAS,CAAA;QACp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,QAAQ;sBAAhB,KAAK;gBACG,cAAc;sBAAtB,KAAK;gBACG,UAAU;sBAAlB,KAAK;gBACG,aAAa;sBAArB,KAAK;;;MEPK,oBAAoB;IAC/B,OAAO,OAAO,CAAC,SAA2B,EAAE;QAC1C,OAAO;YACL,QAAQ,EAAE,oBAAoB;YAC9B,SAAS,EAAE;gBACT,MAAM,CAAC,MAAM,IAAI;oBACf,OAAO,EAAE,aAAa;oBACtB,QAAQ,EAAE,oBAAoB;iBAC/B;aACF;SACF,CAAA;KACF;;iHAXU,oBAAoB;kHAApB,oBAAoB,iBAd7B,uBAAuB,aAGvB,YAAY,sBAEZ,WAAW;QACX,mBAAmB,aAGnB,uBAAuB;kHAKd,oBAAoB,aAHrB,EACT,YAVQ;YACP,YAAY;YACZ,eAAe,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAClE,WAAW;YACX,mBAAmB;SACpB;2FAOU,oBAAoB;kBAhBhC,QAAQ;mBAAC;oBACR,YAAY,EAAE;wBACZ,uBAAuB;qBACxB;oBACD,OAAO,EAAE;wBACP,YAAY;wBACZ,eAAe,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wBAClE,WAAW;wBACX,mBAAmB;qBACpB;oBACD,OAAO,EAAE;wBACP,uBAAuB;qBACxB;oBACD,SAAS,EAAC,EACT;iBACF;;;ACxBD;;;;ACAA;;;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { OnInit, OnChanges, ElementRef, SimpleChanges, ChangeDetectorRef } from '@angular/core';
|
|
2
|
+
import { FormControl } from "@angular/forms";
|
|
3
|
+
import { InputmaskOptions } from '@ngneat/input-mask';
|
|
4
|
+
import { typesProvider } from './typesProvider';
|
|
5
|
+
import { NgxInputNumberService } from './ngx-input-number.service';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export declare class NgxInputNumberComponent implements OnInit, OnChanges {
|
|
8
|
+
private _ChangeDetectorRef;
|
|
9
|
+
private readonly _typesProvider;
|
|
10
|
+
private _NgxInputNumberService;
|
|
11
|
+
constructor(_ChangeDetectorRef: ChangeDetectorRef, _typesProvider: typesProvider, _NgxInputNumberService: NgxInputNumberService);
|
|
12
|
+
inputElement: ElementRef;
|
|
13
|
+
control: FormControl;
|
|
14
|
+
negative: any;
|
|
15
|
+
autofocus: any;
|
|
16
|
+
decimals: any;
|
|
17
|
+
max: any;
|
|
18
|
+
idForLabel: any;
|
|
19
|
+
tabIndex: any;
|
|
20
|
+
addClass: any;
|
|
21
|
+
groupSeparator: any;
|
|
22
|
+
radixPoint: any;
|
|
23
|
+
lblKeyInvalid: any;
|
|
24
|
+
lblKeyInvalidRender: any;
|
|
25
|
+
inputMask: InputmaskOptions<any>;
|
|
26
|
+
placeholder: string;
|
|
27
|
+
loading: boolean;
|
|
28
|
+
ngAfterViewInit(): void;
|
|
29
|
+
ngAfterContentInit(): void;
|
|
30
|
+
render(): void;
|
|
31
|
+
onBlur(value: any): void;
|
|
32
|
+
ngOnInit(): void;
|
|
33
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
34
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxInputNumberComponent, never>;
|
|
35
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NgxInputNumberComponent, "app-input-number", never, { "control": "control"; "negative": "negative"; "autofocus": "autofocus"; "decimals": "decimals"; "max": "max"; "idForLabel": "idForLabel"; "tabIndex": "tabIndex"; "addClass": "addClass"; "groupSeparator": "groupSeparator"; "radixPoint": "radixPoint"; "lblKeyInvalid": "lblKeyInvalid"; }, {}, never, never>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { inputConfigsHelp } from './typesProvider';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "./ngx-input-number.component";
|
|
5
|
+
import * as i2 from "@angular/common";
|
|
6
|
+
import * as i3 from "@ngneat/input-mask";
|
|
7
|
+
import * as i4 from "@angular/forms";
|
|
8
|
+
export declare class NgxInputNumberModule {
|
|
9
|
+
static forRoot(config?: inputConfigsHelp): ModuleWithProviders<NgxInputNumberModule>;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxInputNumberModule, never>;
|
|
11
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxInputNumberModule, [typeof i1.NgxInputNumberComponent], [typeof i2.CommonModule, typeof i3.InputMaskModule, typeof i4.FormsModule, typeof i4.ReactiveFormsModule], [typeof i1.NgxInputNumberComponent]>;
|
|
12
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<NgxInputNumberModule>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inputConfigs } from './types';
|
|
2
|
+
import { BehaviorSubject } from "rxjs";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class NgxInputNumberService {
|
|
5
|
+
private readonly config;
|
|
6
|
+
changeEvent: BehaviorSubject<boolean>;
|
|
7
|
+
groupSeparator: string;
|
|
8
|
+
radixPoint: string;
|
|
9
|
+
lblKeyInvalid: string;
|
|
10
|
+
negative: any;
|
|
11
|
+
max: any;
|
|
12
|
+
decimals: number;
|
|
13
|
+
constructor(config: inputConfigs | null);
|
|
14
|
+
onChangeParams(config: inputConfigs): void;
|
|
15
|
+
getChangeEvent(): BehaviorSubject<boolean>;
|
|
16
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxInputNumberService, [{ optional: true; }]>;
|
|
17
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NgxInputNumberService>;
|
|
18
|
+
}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Provider } from '@angular/core';
|
|
2
|
+
export declare class inputConfigs {
|
|
3
|
+
groupSeparator?: string;
|
|
4
|
+
radixPoint?: string;
|
|
5
|
+
lblKeyInvalid?: string;
|
|
6
|
+
max?: number;
|
|
7
|
+
decimals?: number;
|
|
8
|
+
negative?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class inputConfigsHelp {
|
|
11
|
+
config?: Provider;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Provider } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class inputConfigs {
|
|
4
|
+
groupSeparator?: string;
|
|
5
|
+
radixPoint?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class typesProvider {
|
|
8
|
+
abstract get config(): inputConfigs;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<typesProvider, never>;
|
|
10
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<typesProvider>;
|
|
11
|
+
}
|
|
12
|
+
export declare class defaultTypesProvider extends typesProvider {
|
|
13
|
+
get config(): inputConfigs;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<defaultTypesProvider, never>;
|
|
15
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<defaultTypesProvider>;
|
|
16
|
+
}
|
|
17
|
+
export declare class inputConfigsHelp {
|
|
18
|
+
config?: Provider;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@experteam-mx/ngx-input-number",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"peerDependencies": {},
|
|
6
6
|
"dependencies": {
|
|
@@ -11,7 +11,24 @@
|
|
|
11
11
|
"inputmask": "^5.0.7",
|
|
12
12
|
"tslib": "^2.1.0"
|
|
13
13
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
"module": "fesm2015/experteam-mx-ngx-input-number.mjs",
|
|
15
|
+
"es2020": "fesm2020/experteam-mx-ngx-input-number.mjs",
|
|
16
|
+
"esm2020": "esm2020/experteam-mx-ngx-input-number.mjs",
|
|
17
|
+
"fesm2020": "fesm2020/experteam-mx-ngx-input-number.mjs",
|
|
18
|
+
"fesm2015": "fesm2015/experteam-mx-ngx-input-number.mjs",
|
|
19
|
+
"typings": "experteam-mx-ngx-input-number.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
"./package.json": {
|
|
22
|
+
"default": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./experteam-mx-ngx-input-number.d.ts",
|
|
26
|
+
"esm2020": "./esm2020/experteam-mx-ngx-input-number.mjs",
|
|
27
|
+
"es2020": "./fesm2020/experteam-mx-ngx-input-number.mjs",
|
|
28
|
+
"es2015": "./fesm2015/experteam-mx-ngx-input-number.mjs",
|
|
29
|
+
"node": "./fesm2015/experteam-mx-ngx-input-number.mjs",
|
|
30
|
+
"default": "./fesm2020/experteam-mx-ngx-input-number.mjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": false
|
|
34
|
+
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export * from '
|
|
6
|
-
export * from './lib/ngx-input-number.service';
|
|
7
|
-
export * from './lib/ngx-input-number.component';
|
|
8
|
-
export * from './lib/ngx-input-number.module';
|
|
9
|
-
export * from '@ngneat/input-mask';
|
|
1
|
+
export * from './lib/typesProvider';
|
|
2
|
+
export * from './lib/ngx-input-number.service';
|
|
3
|
+
export * from './lib/ngx-input-number.component';
|
|
4
|
+
export * from './lib/ngx-input-number.module';
|
|
5
|
+
export * from '@ngneat/input-mask';
|
package/.browserslistrc
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
|
2
|
-
# For additional information regarding the format and rule options, please see:
|
|
3
|
-
# https://github.com/browserslist/browserslist#queries
|
|
4
|
-
|
|
5
|
-
# For the full list of supported browsers by the Angular framework, please see:
|
|
6
|
-
# https://angular.io/guide/browser-support
|
|
7
|
-
|
|
8
|
-
# You can see what browsers were selected by your queries by running:
|
|
9
|
-
# npx browserslist
|
|
10
|
-
|
|
11
|
-
last 1 Chrome version
|
|
12
|
-
last 1 Firefox version
|
|
13
|
-
last 2 Edge major versions
|
|
14
|
-
last 2 Safari major versions
|
|
15
|
-
last 2 iOS major versions
|
|
16
|
-
Firefox ESR
|
package/karma.conf.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Karma configuration file, see link for more information
|
|
2
|
-
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
-
|
|
4
|
-
module.exports = function (config) {
|
|
5
|
-
config.set({
|
|
6
|
-
basePath: '',
|
|
7
|
-
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
-
plugins: [
|
|
9
|
-
require('karma-jasmine'),
|
|
10
|
-
require('karma-chrome-launcher'),
|
|
11
|
-
require('karma-jasmine-html-reporter'),
|
|
12
|
-
require('karma-coverage'),
|
|
13
|
-
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
-
],
|
|
15
|
-
client: {
|
|
16
|
-
jasmine: {
|
|
17
|
-
// you can add configuration options for Jasmine here
|
|
18
|
-
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
|
19
|
-
// for example, you can disable the random execution with `random: false`
|
|
20
|
-
// or set a specific seed with `seed: 4321`
|
|
21
|
-
},
|
|
22
|
-
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
23
|
-
},
|
|
24
|
-
jasmineHtmlReporter: {
|
|
25
|
-
suppressAll: true // removes the duplicated traces
|
|
26
|
-
},
|
|
27
|
-
coverageReporter: {
|
|
28
|
-
dir: require('path').join(__dirname, '../../coverage/ngx-input-number'),
|
|
29
|
-
subdir: '.',
|
|
30
|
-
reporters: [
|
|
31
|
-
{ type: 'html' },
|
|
32
|
-
{ type: 'text-summary' }
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
reporters: ['progress', 'kjhtml'],
|
|
36
|
-
port: 9876,
|
|
37
|
-
colors: true,
|
|
38
|
-
logLevel: config.LOG_INFO,
|
|
39
|
-
autoWatch: true,
|
|
40
|
-
browsers: ['Chrome'],
|
|
41
|
-
singleRun: false,
|
|
42
|
-
restartOnFileChange: true
|
|
43
|
-
});
|
|
44
|
-
};
|
package/ng-package.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<div class="position-relative">
|
|
2
|
-
<input
|
|
3
|
-
*ngIf="!loading"
|
|
4
|
-
#inputElement
|
|
5
|
-
type="text"
|
|
6
|
-
class="form-control {{ addClass }}"
|
|
7
|
-
[class.is-invalid]="control.touched && control.invalid"
|
|
8
|
-
[formControl]="control"
|
|
9
|
-
[tabindex]="tabIndex"
|
|
10
|
-
[(inputMask)]="inputMask"
|
|
11
|
-
[id]="idForLabel"
|
|
12
|
-
>
|
|
13
|
-
<label class="lbl-key-invalid position-absolute top-100 end-0 p-2 d-none" [innerHTML]="lblKeyInvalidRender"></label>
|
|
14
|
-
</div>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { NgxInputNumberComponent } from './ngx-input-number.component';
|
|
4
|
-
|
|
5
|
-
describe('NgxInputNumberComponent', () => {
|
|
6
|
-
let component: NgxInputNumberComponent;
|
|
7
|
-
let fixture: ComponentFixture<NgxInputNumberComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
declarations: [ NgxInputNumberComponent ]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
fixture = TestBed.createComponent(NgxInputNumberComponent);
|
|
18
|
-
component = fixture.componentInstance;
|
|
19
|
-
fixture.detectChanges();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should create', () => {
|
|
23
|
-
expect(component).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { Component, OnInit, Input, OnChanges, AfterViewInit, AfterContentInit, ElementRef, ViewChild, SimpleChanges, ChangeDetectorRef } from '@angular/core';
|
|
2
|
-
import { FormBuilder, Validators, FormArray, FormGroup, FormControl } from "@angular/forms";
|
|
3
|
-
import { createMask, InputmaskOptions } from '@ngneat/input-mask';
|
|
4
|
-
|
|
5
|
-
import { inputConfigs, typesProvider } from './typesProvider';
|
|
6
|
-
import { NgxInputNumberService } from './ngx-input-number.service';
|
|
7
|
-
|
|
8
|
-
@Component({
|
|
9
|
-
selector: 'app-input-number',
|
|
10
|
-
templateUrl: './ngx-input-number.component.html',
|
|
11
|
-
styleUrls: ['./ngx-input-number.component.sass']
|
|
12
|
-
})
|
|
13
|
-
export class NgxInputNumberComponent implements OnInit, OnChanges {
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
private _ChangeDetectorRef: ChangeDetectorRef,
|
|
17
|
-
private readonly _typesProvider: typesProvider,
|
|
18
|
-
private _NgxInputNumberService: NgxInputNumberService,
|
|
19
|
-
) { }
|
|
20
|
-
|
|
21
|
-
@ViewChild('inputElement') inputElement!: ElementRef;
|
|
22
|
-
|
|
23
|
-
@Input() control!: FormControl
|
|
24
|
-
@Input() negative!: any
|
|
25
|
-
@Input() autofocus: any = false
|
|
26
|
-
@Input() decimals: any
|
|
27
|
-
@Input() max: any
|
|
28
|
-
@Input() idForLabel: any = ""
|
|
29
|
-
@Input() tabIndex: any
|
|
30
|
-
@Input() addClass: any = "form-control-sm"
|
|
31
|
-
@Input() groupSeparator: any
|
|
32
|
-
@Input() radixPoint: any
|
|
33
|
-
@Input() lblKeyInvalid: any
|
|
34
|
-
lblKeyInvalidRender: any
|
|
35
|
-
|
|
36
|
-
inputMask: InputmaskOptions<any> = {}
|
|
37
|
-
|
|
38
|
-
placeholder = "0"
|
|
39
|
-
|
|
40
|
-
loading = false
|
|
41
|
-
|
|
42
|
-
ngAfterViewInit(): void {
|
|
43
|
-
if( this.autofocus ){
|
|
44
|
-
setTimeout(()=>{
|
|
45
|
-
this.inputElement.nativeElement.focus();
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
ngAfterContentInit(): void {
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
render(){
|
|
54
|
-
this._ChangeDetectorRef.detectChanges()
|
|
55
|
-
|
|
56
|
-
this.lblKeyInvalidRender = this._NgxInputNumberService.lblKeyInvalid
|
|
57
|
-
|
|
58
|
-
this.inputMask = createMask({
|
|
59
|
-
allowMinus: this._NgxInputNumberService.negative,
|
|
60
|
-
alias: 'numeric',
|
|
61
|
-
numericInput: false,
|
|
62
|
-
inputType: "number",
|
|
63
|
-
inputmode: "numeric",
|
|
64
|
-
groupSeparator: this._NgxInputNumberService.groupSeparator,
|
|
65
|
-
radixPoint : this._NgxInputNumberService.radixPoint,
|
|
66
|
-
max : this._NgxInputNumberService.max,
|
|
67
|
-
digits: this._NgxInputNumberService.decimals,
|
|
68
|
-
digitsOptional: false,
|
|
69
|
-
placeholder: '0',
|
|
70
|
-
unmaskAsNumber: true,
|
|
71
|
-
autoUnmask: true,
|
|
72
|
-
showMaskOnFocus: false,
|
|
73
|
-
showMaskOnHover: false,
|
|
74
|
-
onBeforePaste: ( pastedValue: any, opts ) =>{
|
|
75
|
-
return pastedValue.replaceAll( opts.groupSeparator!, "" )
|
|
76
|
-
},
|
|
77
|
-
onKeyValidation: ( key, result ) => {
|
|
78
|
-
if( !result ){
|
|
79
|
-
this.inputElement.nativeElement.classList.add("key-invalid")
|
|
80
|
-
setTimeout(
|
|
81
|
-
()=>{
|
|
82
|
-
this.inputElement.nativeElement.classList.remove("key-invalid")
|
|
83
|
-
},
|
|
84
|
-
1000
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
if( this.negative !== undefined ){
|
|
91
|
-
this.inputMask.allowMinus = this.negative
|
|
92
|
-
}
|
|
93
|
-
if( this.max !== undefined ){
|
|
94
|
-
this.inputMask.max = this.max
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if( this.groupSeparator !== undefined ){
|
|
98
|
-
this.inputMask.groupSeparator = this.groupSeparator
|
|
99
|
-
}
|
|
100
|
-
if( this.radixPoint !== undefined ){
|
|
101
|
-
this.inputMask.radixPoint = this.radixPoint
|
|
102
|
-
}
|
|
103
|
-
if( this.lblKeyInvalid !== undefined ){
|
|
104
|
-
this.lblKeyInvalidRender = this.lblKeyInvalid
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if( this.decimals !== undefined ){
|
|
108
|
-
this.inputMask.digits = this.decimals
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if( this.inputMask.digits! > 0 ){
|
|
114
|
-
this.placeholder = '0' + String(this.inputMask.radixPoint)
|
|
115
|
-
}
|
|
116
|
-
for( let x = 0; x < this.inputMask.digits!; x++ ){
|
|
117
|
-
this.placeholder += "0"
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
this.loading = false
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
onBlur(value: any){
|
|
125
|
-
// if( value != '' && Number( this.inputMask.digits ) > 0 ){
|
|
126
|
-
// let valueBlurSplit = String(value).split(".")
|
|
127
|
-
// let valueString = ""
|
|
128
|
-
// if( valueBlurSplit.length == 1 ){
|
|
129
|
-
// valueString = valueBlurSplit[0] + "." + String("").padEnd(Number(this.inputMask.digits), "0")
|
|
130
|
-
// }else{
|
|
131
|
-
// valueString = valueBlurSplit[0] + "." + String(valueBlurSplit[1]).padEnd(Number(this.inputMask.digits), "0")
|
|
132
|
-
// }
|
|
133
|
-
// this.control.setValue( parseFloat( valueString ) )
|
|
134
|
-
// }
|
|
135
|
-
this.control.setValue( value )
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
ngOnInit(): void {
|
|
139
|
-
this._NgxInputNumberService.getChangeEvent().subscribe(
|
|
140
|
-
( configs )=>{
|
|
141
|
-
if( configs ){
|
|
142
|
-
this.loading = true
|
|
143
|
-
|
|
144
|
-
setTimeout(() => {
|
|
145
|
-
this.render()
|
|
146
|
-
}, 0);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
ngOnChanges(changes: SimpleChanges): void {
|
|
153
|
-
this.loading = true
|
|
154
|
-
|
|
155
|
-
setTimeout(() => {
|
|
156
|
-
this.render()
|
|
157
|
-
}, 0);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { NgModule, ModuleWithProviders } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
|
4
|
-
|
|
5
|
-
import { NgxInputNumberComponent } from './ngx-input-number.component';
|
|
6
|
-
import { InputMaskModule } from '@ngneat/input-mask';
|
|
7
|
-
|
|
8
|
-
import { inputConfigsHelp, typesProvider, defaultTypesProvider } from './typesProvider';
|
|
9
|
-
|
|
10
|
-
@NgModule({
|
|
11
|
-
declarations: [
|
|
12
|
-
NgxInputNumberComponent
|
|
13
|
-
],
|
|
14
|
-
imports: [
|
|
15
|
-
CommonModule,
|
|
16
|
-
InputMaskModule.forRoot({ inputSelector: 'input', isAsync: true }),
|
|
17
|
-
FormsModule,
|
|
18
|
-
ReactiveFormsModule,
|
|
19
|
-
],
|
|
20
|
-
exports: [
|
|
21
|
-
NgxInputNumberComponent
|
|
22
|
-
],
|
|
23
|
-
providers:[
|
|
24
|
-
]
|
|
25
|
-
})
|
|
26
|
-
export class NgxInputNumberModule {
|
|
27
|
-
static forRoot(config: inputConfigsHelp = {} ): ModuleWithProviders<NgxInputNumberModule> {
|
|
28
|
-
return {
|
|
29
|
-
ngModule: NgxInputNumberModule,
|
|
30
|
-
providers: [
|
|
31
|
-
config.config || {
|
|
32
|
-
provide: typesProvider,
|
|
33
|
-
useClass: defaultTypesProvider
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { NgxInputNumberService } from './ngx-input-number.service';
|
|
4
|
-
|
|
5
|
-
describe('NgxInputNumberService', () => {
|
|
6
|
-
let service: NgxInputNumberService;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
TestBed.configureTestingModule({});
|
|
10
|
-
service = TestBed.inject(NgxInputNumberService);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('should be created', () => {
|
|
14
|
-
expect(service).toBeTruthy();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Injectable, Optional, Inject, EventEmitter, Output } from '@angular/core';
|
|
2
|
-
import { INPUT_CONFIG_TOKEN } from './di';
|
|
3
|
-
import { inputConfigs } from './types';
|
|
4
|
-
import { BehaviorSubject, Subject } from "rxjs";
|
|
5
|
-
|
|
6
|
-
@Injectable({
|
|
7
|
-
providedIn: 'root'
|
|
8
|
-
})
|
|
9
|
-
export class NgxInputNumberService {
|
|
10
|
-
|
|
11
|
-
changeEvent = new BehaviorSubject<boolean>(false);
|
|
12
|
-
groupSeparator = ','
|
|
13
|
-
radixPoint = '.'
|
|
14
|
-
lblKeyInvalid = 'Please enter a valid amount'
|
|
15
|
-
negative: any = true
|
|
16
|
-
max: any = undefined
|
|
17
|
-
decimals = 2
|
|
18
|
-
|
|
19
|
-
constructor(
|
|
20
|
-
@Optional() @Inject(INPUT_CONFIG_TOKEN)
|
|
21
|
-
private readonly config: inputConfigs | null,
|
|
22
|
-
) {
|
|
23
|
-
if( config != null ){
|
|
24
|
-
this.groupSeparator = config.groupSeparator!
|
|
25
|
-
this.radixPoint = config.radixPoint!
|
|
26
|
-
this.lblKeyInvalid = config.lblKeyInvalid!
|
|
27
|
-
this.negative = config.negative!
|
|
28
|
-
this.max = config.max!
|
|
29
|
-
this.decimals = config.decimals!
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
onChangeParams( config: inputConfigs ){
|
|
34
|
-
if( config.groupSeparator ){
|
|
35
|
-
this.groupSeparator = config.groupSeparator
|
|
36
|
-
}
|
|
37
|
-
if( config.radixPoint ){
|
|
38
|
-
this.radixPoint = config.radixPoint
|
|
39
|
-
}
|
|
40
|
-
if( config.lblKeyInvalid ){
|
|
41
|
-
this.lblKeyInvalid = config.lblKeyInvalid
|
|
42
|
-
}
|
|
43
|
-
if( config.negative !== undefined ){
|
|
44
|
-
this.negative = config.negative
|
|
45
|
-
}
|
|
46
|
-
if( config.max ){
|
|
47
|
-
this.max = config.max!
|
|
48
|
-
}
|
|
49
|
-
if( config.decimals ){
|
|
50
|
-
this.decimals = config.decimals
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this.changeEvent.next( true )
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
getChangeEvent(){
|
|
57
|
-
return this.changeEvent
|
|
58
|
-
}
|
|
59
|
-
}
|
package/src/lib/types.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Provider } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
export class inputConfigs {
|
|
4
|
-
groupSeparator?: string;
|
|
5
|
-
radixPoint?: string;
|
|
6
|
-
lblKeyInvalid?: string;
|
|
7
|
-
max?: number;
|
|
8
|
-
decimals?: number;
|
|
9
|
-
negative?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class inputConfigsHelp {
|
|
13
|
-
config?: Provider;
|
|
14
|
-
}
|
package/src/lib/typesProvider.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Injectable, Provider } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
export class inputConfigs {
|
|
4
|
-
groupSeparator?: string;
|
|
5
|
-
radixPoint?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
@Injectable({ providedIn: 'root' })
|
|
9
|
-
export abstract class typesProvider {
|
|
10
|
-
abstract get config(): inputConfigs;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@Injectable({ providedIn: 'root' })
|
|
14
|
-
export class defaultTypesProvider extends typesProvider {
|
|
15
|
-
get config(): inputConfigs {
|
|
16
|
-
// return default config
|
|
17
|
-
return {
|
|
18
|
-
groupSeparator: ",",
|
|
19
|
-
radixPoint: "."
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class inputConfigsHelp {
|
|
25
|
-
config?: Provider;
|
|
26
|
-
}
|