@experteam-mx/ngx-input-number 1.0.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.
@@ -0,0 +1,16 @@
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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # NgxInputNumber
2
+
3
+ This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0.
4
+
5
+ ## Code scaffolding
6
+
7
+ Run `ng generate component component-name --project ngx-input-number` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-input-number`.
8
+ > Note: Don't forget to add `--project ngx-input-number` or else it will be added to the default project in your `angular.json` file.
9
+
10
+ ## Build
11
+
12
+ Run `ng build ngx-input-number` to build the project. The build artifacts will be stored in the `dist/` directory.
13
+
14
+ ## Publishing
15
+
16
+ After building your library with `ng build ngx-input-number`, go to the dist folder `cd dist/ngx-input-number` and run `npm publish`.
17
+
18
+ ## Running unit tests
19
+
20
+ Run `ng test ngx-input-number` to execute the unit tests via [Karma](https://karma-runner.github.io).
21
+
22
+ ## Further help
23
+
24
+ To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
package/karma.conf.js ADDED
@@ -0,0 +1,44 @@
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
+ };
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/ngx-input-number",
4
+ "deleteDestPath": false,
5
+ "lib": {
6
+ "entryFile": "src/public-api.ts"
7
+ },
8
+ "allowedNonPeerDependencies": [
9
+ "."
10
+ ]
11
+ }
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@experteam-mx/ngx-input-number",
3
+ "version": "1.0.1",
4
+ "license": "MIT",
5
+ "peerDependencies": {},
6
+ "dependencies": {
7
+ "@angular/common": "^12.0.2",
8
+ "@angular/core": "^12.0.2",
9
+ "@ngneat/input-mask": "^5.1.0",
10
+ "bootstrap": "^5.1.3",
11
+ "inputmask": "^5.0.7",
12
+ "tslib": "^2.1.0"
13
+ },
14
+ "devDependencies": {
15
+ "@types/inputmask": "^5.0.1"
16
+ }
17
+ }
@@ -0,0 +1,10 @@
1
+ <input
2
+ #inputElement
3
+ type="text"
4
+ class="form-control form-control-sm"
5
+ [class.is-invalid]="control.touched && control.invalid"
6
+ [formControl]="control"
7
+ [inputMask]="inputMask"
8
+ [placeholder]="placeholder"
9
+ [id]="idForLabel"
10
+ >
@@ -0,0 +1 @@
1
+ @import "~bootstrap/scss/bootstrap"
@@ -0,0 +1,25 @@
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
+ });
@@ -0,0 +1,69 @@
1
+ import { Component, OnInit, Input, AfterViewInit, AfterContentInit, ElementRef, ViewChild } from '@angular/core';
2
+ import { FormBuilder, Validators, FormArray, FormGroup, FormControl } from "@angular/forms";
3
+ import { createMask } from '@ngneat/input-mask';
4
+
5
+ @Component({
6
+ selector: 'app-input-number',
7
+ templateUrl: './ngx-input-number.component.html',
8
+ styleUrls: ['./ngx-input-number.component.sass']
9
+ })
10
+ export class NgxInputNumberComponent implements OnInit {
11
+
12
+ constructor() { }
13
+
14
+ @ViewChild('inputElement') inputElement!: ElementRef;
15
+
16
+ @Input() control!: FormControl
17
+ @Input() negative!: any
18
+ @Input() autofocus: any = false
19
+ @Input() decimals: any
20
+ @Input() max: any
21
+ @Input() idForLabel: any = ""
22
+
23
+ inputMask = createMask({
24
+ allowMinus: true,
25
+ alias: 'numeric',
26
+ numericInput: true,
27
+ inputType: "number",
28
+ inputmode: "numeric",
29
+ groupSeparator: ',',
30
+ radixPoint : '.',
31
+ digits: 2,
32
+ digitsOptional: false,
33
+ placeholder: '0',
34
+ unmaskAsNumber: true,
35
+ autoUnmask: true,
36
+ })
37
+
38
+ placeholder = "0"
39
+
40
+ ngAfterViewInit(): void {
41
+ if( this.autofocus ){
42
+ setTimeout(()=>{
43
+ this.inputElement.nativeElement.focus();
44
+ })
45
+ }
46
+ }
47
+
48
+ ngAfterContentInit(): void {
49
+ }
50
+
51
+ ngOnInit(): void {
52
+ if( this.negative === false ){
53
+ this.inputMask.allowMinus = false
54
+ }
55
+ if( this.decimals !== undefined ){
56
+ this.inputMask.digits = this.decimals
57
+ if( this.decimals > 0 ){
58
+ this.placeholder += String(this.inputMask.radixPoint)
59
+ }
60
+ for( let x = 0; x < this.decimals; x++ ){
61
+ this.placeholder += "0"
62
+ }
63
+ }
64
+ if( this.max !== undefined ){
65
+ this.inputMask.max = this.max
66
+ }
67
+ }
68
+
69
+ }
@@ -0,0 +1,22 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { FormsModule, ReactiveFormsModule } from "@angular/forms";
3
+
4
+ import { NgxInputNumberComponent } from './ngx-input-number.component';
5
+ import { InputMaskModule } from '@ngneat/input-mask';
6
+
7
+
8
+
9
+ @NgModule({
10
+ declarations: [
11
+ NgxInputNumberComponent
12
+ ],
13
+ imports: [
14
+ InputMaskModule,
15
+ FormsModule,
16
+ ReactiveFormsModule,
17
+ ],
18
+ exports: [
19
+ NgxInputNumberComponent
20
+ ]
21
+ })
22
+ export class NgxInputNumberModule { }
@@ -0,0 +1,16 @@
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
+ });
@@ -0,0 +1,9 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable({
4
+ providedIn: 'root'
5
+ })
6
+ export class NgxInputNumberService {
7
+
8
+ constructor() { }
9
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Public API Surface of ngx-input-number
3
+ */
4
+
5
+ export * from './lib/ngx-input-number.service';
6
+ export * from './lib/ngx-input-number.component';
7
+ export * from './lib/ngx-input-number.module';
package/src/test.ts ADDED
@@ -0,0 +1,27 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import 'zone.js';
4
+ import 'zone.js/testing';
5
+ import { getTestBed } from '@angular/core/testing';
6
+ import {
7
+ BrowserDynamicTestingModule,
8
+ platformBrowserDynamicTesting
9
+ } from '@angular/platform-browser-dynamic/testing';
10
+
11
+ declare const require: {
12
+ context(path: string, deep?: boolean, filter?: RegExp): {
13
+ <T>(id: string): T;
14
+ keys(): string[];
15
+ };
16
+ };
17
+
18
+ // First, initialize the Angular testing environment.
19
+ getTestBed().initTestEnvironment(
20
+ BrowserDynamicTestingModule,
21
+ platformBrowserDynamicTesting(),
22
+ );
23
+
24
+ // Then we find all the tests.
25
+ const context = require.context('./', true, /\.spec\.ts$/);
26
+ // And load the modules.
27
+ context.keys().map(context);
@@ -0,0 +1,27 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "../../tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "../../out-tsc/lib",
6
+ "target": "es2015",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "inlineSources": true,
10
+ "types": [],
11
+ "lib": [
12
+ "dom",
13
+ "es2018"
14
+ ]
15
+ },
16
+ "angularCompilerOptions": {
17
+ "skipTemplateCodegen": true,
18
+ "strictMetadataEmit": true,
19
+ "enableResourceInlining": true,
20
+ "strictTemplates": false,
21
+ "enableIvy": false
22
+ },
23
+ "exclude": [
24
+ "src/test.ts",
25
+ "**/*.spec.ts"
26
+ ]
27
+ }
@@ -0,0 +1,10 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "./tsconfig.lib.json",
4
+ "compilerOptions": {
5
+ "declarationMap": false
6
+ },
7
+ "angularCompilerOptions": {
8
+ "compilationMode": "partial"
9
+ }
10
+ }
@@ -0,0 +1,17 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "../../tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "../../out-tsc/spec",
6
+ "types": [
7
+ "jasmine"
8
+ ]
9
+ },
10
+ "files": [
11
+ "src/test.ts"
12
+ ],
13
+ "include": [
14
+ "**/*.spec.ts",
15
+ "**/*.d.ts"
16
+ ]
17
+ }