ecabs-components 0.0.2 → 0.0.3

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.
Files changed (57) hide show
  1. package/README.md +24 -24
  2. package/esm2020/lib/base/directives/digits-only.directive.module.mjs +22 -0
  3. package/esm2020/lib/ecabs-input/ecabs-input.module.mjs +6 -6
  4. package/esm2020/lib/ecabs-select/ecabs-select.component.mjs +17 -5
  5. package/esm2020/lib/ecabs-select/ecabs-select.module.mjs +11 -4
  6. package/esm2020/lib/services/ecabs-components.service.mjs +1 -1
  7. package/fesm2015/ecabs-components.mjs +47 -11
  8. package/fesm2015/ecabs-components.mjs.map +1 -1
  9. package/fesm2020/ecabs-components.mjs +47 -11
  10. package/fesm2020/ecabs-components.mjs.map +1 -1
  11. package/lib/base/directives/digits-only.directive.d.ts +3 -3
  12. package/lib/base/directives/digits-only.directive.module.d.ts +8 -0
  13. package/lib/ecabs-input/ecabs-input.module.d.ts +6 -6
  14. package/lib/ecabs-select/ecabs-select.component.d.ts +5 -1
  15. package/lib/ecabs-select/ecabs-select.module.d.ts +4 -3
  16. package/package.json +2 -2
  17. package/styles/material/overrides/_datepicker.scss +25 -1
  18. package/styles/material/overrides/_phone.scss +2 -2
  19. package/styles/scss/modules/_datepicker.scss +3 -3
  20. package/styles/scss/modules/_phone.scss +3 -1
  21. package/styles/scss/modules/_select.scss +16 -0
  22. package/lib/base/directives/digits-only.directive.ts +0 -129
  23. package/lib/base/element-base.ts +0 -72
  24. package/lib/base/element-wrapper/element-wrapper.component.html +0 -30
  25. package/lib/base/element-wrapper/element-wrapper.component.ts +0 -33
  26. package/lib/base/element-wrapper/element-wrapper.module.ts +0 -30
  27. package/lib/base/hint/hint.component.html +0 -1
  28. package/lib/base/hint/hint.component.scss +0 -0
  29. package/lib/base/hint/hint.component.ts +0 -12
  30. package/lib/base/hint/hint.module.ts +0 -13
  31. package/lib/base/validation/validation.component.html +0 -8
  32. package/lib/base/validation/validation.component.scss +0 -0
  33. package/lib/base/validation/validation.component.ts +0 -84
  34. package/lib/base/validation/validation.module.ts +0 -12
  35. package/lib/ecabs-buttons/ecabs-buttons.component.html +0 -18
  36. package/lib/ecabs-buttons/ecabs-buttons.component.ts +0 -54
  37. package/lib/ecabs-buttons/ecabs-buttons.module.ts +0 -13
  38. package/lib/ecabs-input/ecabs-input.component.html +0 -26
  39. package/lib/ecabs-input/ecabs-input.component.ts +0 -83
  40. package/lib/ecabs-input/ecabs-input.module.ts +0 -14
  41. package/lib/ecabs-loading/ecabs-loading.component.html +0 -7
  42. package/lib/ecabs-loading/ecabs-loading.component.spec.ts +0 -24
  43. package/lib/ecabs-loading/ecabs-loading.component.ts +0 -11
  44. package/lib/ecabs-loading/ecabs-loading.module.ts +0 -11
  45. package/lib/ecabs-loading/spinner/spinner.component.html +0 -5
  46. package/lib/ecabs-loading/spinner/spinner.component.scss +0 -61
  47. package/lib/ecabs-loading/spinner/spinner.component.spec.ts +0 -24
  48. package/lib/ecabs-loading/spinner/spinner.component.ts +0 -11
  49. package/lib/ecabs-select/ecabs-select.component.html +0 -38
  50. package/lib/ecabs-select/ecabs-select.component.ts +0 -246
  51. package/lib/ecabs-select/ecabs-select.module.ts +0 -34
  52. package/lib/ecabs-textarea/ecabs-textarea.component.html +0 -13
  53. package/lib/ecabs-textarea/ecabs-textarea.component.ts +0 -61
  54. package/lib/ecabs-textarea/ecabs-textarea.module.ts +0 -12
  55. package/lib/services/ecabs-components.service.ts +0 -33
  56. package/public-api.ts +0 -11
  57. package/test.ts +0 -27
@@ -1,129 +0,0 @@
1
- import { Directive, ElementRef, HostListener, Input, OnInit } from '@angular/core';
2
-
3
- @Directive({
4
- selector: '[appDigitsOnly]',
5
- })
6
- export class DigitsOnlyDirective implements OnInit {
7
- @Input()
8
- digitsOnly = false;
9
-
10
- @Input()
11
- allowHyphen = false;
12
-
13
- @Input() decimal? = false;
14
- @Input() decimalSeparator? = '.';
15
- @Input() unit? = 0;
16
-
17
- inputElement: HTMLInputElement;
18
- minus = '-';
19
- minusCounter = 0;
20
- regex!: RegExp;
21
-
22
- private decimalCounter = 0;
23
- private readonly navigationKeys = [
24
- 'Backspace',
25
- 'Delete',
26
- 'Tab',
27
- 'Escape',
28
- 'Enter',
29
- 'Home',
30
- 'End',
31
- 'ArrowLeft',
32
- 'ArrowRight',
33
- 'Clear',
34
- 'Copy',
35
- 'Paste',
36
- ];
37
-
38
- constructor(public el: ElementRef) {
39
- this.inputElement = el.nativeElement;
40
- }
41
-
42
- @HostListener('keydown', ['$event'])
43
- onKeyDown(e: KeyboardEvent): void {
44
- if (this.digitsOnly) {
45
- if (
46
- this.navigationKeys.indexOf(e.key) > -1 || // Allow: navigation keys: backspace, delete, arrows etc.
47
- (e.key === 'a' && e.ctrlKey) || // Allow: Ctrl+A
48
- (e.key === 'c' && e.ctrlKey) || // Allow: Ctrl+C
49
- (e.key === 'v' && e.ctrlKey) || // Allow: Ctrl+V
50
- (e.key === 'x' && e.ctrlKey) || // Allow: Ctrl+X
51
- (e.key === 'a' && e.metaKey) || // Allow: Cmd+A (Mac)
52
- (e.key === 'c' && e.metaKey) || // Allow: Cmd+C (Mac)
53
- (e.key === 'v' && e.metaKey) || // Allow: Cmd+V (Mac)
54
- (e.key === 'x' && e.metaKey) || // Allow: Cmd+X (Mac)
55
- (this.decimal && e.key === this.decimalSeparator && this.decimalCounter < 1) || // Allow: only one decimal point
56
- (this.decimal && e.key === this.minus && this.minusCounter < 1) // Allow: only one minus
57
- ) {
58
- return;
59
- }
60
-
61
- // Ensure that it is a number and stop the keypress
62
- if (e.key === ' ' || !this.regex.test(e.key)) {
63
- e.preventDefault();
64
- }
65
- }
66
- }
67
-
68
- @HostListener('keyup', ['$event'])
69
- onKeyUp(): void {
70
- if (this.digitsOnly) {
71
- if (!this.decimal) {
72
- return;
73
- }
74
-
75
- this.decimalCounter = this.el.nativeElement.value.split(this.decimalSeparator).length - 1;
76
- this.minusCounter = this.el.nativeElement.value.split(this.minus).length - 1;
77
-
78
- if (isNaN(+this.inputElement.value)) {
79
- this.inputElement.value = this.sanitizeInput(this.inputElement.value);
80
- }
81
- }
82
- }
83
-
84
- @HostListener('paste', ['$event'])
85
- onPaste(event: ClipboardEvent): void {
86
- if (this.digitsOnly) {
87
- const pastedInput = event.clipboardData?.getData('text/plain') as string;
88
- this.pasteData(pastedInput);
89
- event.preventDefault();
90
- }
91
- }
92
-
93
- ngOnInit(): void {
94
- this.regex = new RegExp(this.allowHyphen ? '^[\\d -]+$' : '\\d');
95
- }
96
-
97
- private pasteData(pastedContent: string): void {
98
- const sanitizedContent = isNaN(+pastedContent) ? this.sanitizeInput(pastedContent) : pastedContent;
99
- const pasted = document.execCommand('insertText', false, sanitizedContent);
100
- if (!pasted) {
101
- const { selectionStart: start, selectionEnd: end } = this.inputElement;
102
- this.inputElement.setRangeText(sanitizedContent, start as number, end as number, 'end');
103
- }
104
- }
105
-
106
- private sanitizeInput(input: string): string {
107
- let result = '';
108
- if (this.decimal && this.isValidDecimal(input)) {
109
- const regex = new RegExp(`^[\d -${this.decimalSeparator}]+$`, 'g');
110
- result = input.replace(regex, '');
111
- } else {
112
- result = input.replace(`/${this.regex}/g`, '');
113
- }
114
-
115
- const maxLength = this.inputElement.maxLength;
116
-
117
- if (maxLength > 0) {
118
- // the input element has maxLength limit
119
- const allowedLength = maxLength - this.inputElement.value.length;
120
- result = allowedLength > 0 ? result.substring(0, allowedLength) : '';
121
- }
122
-
123
- return result;
124
- }
125
-
126
- private isValidDecimal(inputString: string): boolean {
127
- return inputString.split(this.decimalSeparator as string).length <= 2;
128
- }
129
- }
@@ -1,72 +0,0 @@
1
- import { Input, Output, EventEmitter, Component } from '@angular/core';
2
- import { AbstractControl, UntypedFormControl } from '@angular/forms';
3
-
4
- @Component({
5
- template: '',
6
- })
7
- export default class ElementBaseComponent {
8
- @Input() type!:string;
9
- @Input() name!:string;
10
- @Input() label!:string;
11
- @Input() placeholder = '';
12
- @Input() validationLabel!:string;
13
- @Input() disabled = false;
14
- @Input() showValidation = true;
15
- @Input() showValidationOnNotTouched = false;
16
- @Input() hideValidationMessage = false;
17
- @Input() iconClass = '';
18
- @Input() loading = false;
19
- @Input() showHint: boolean = false;
20
- @Input() maxLength!: number;
21
- @Input() tooltip!: string;
22
- @Input() showAsterisk: boolean = true;
23
-
24
- @Output() focused = new EventEmitter<any>();
25
- @Output() focusOuted = new EventEmitter<any>();
26
-
27
- control!: UntypedFormControl;
28
- required: boolean = false;
29
-
30
- getData(): any {
31
- return {
32
- type: this.type || 'text',
33
- label: this.label,
34
- placeholder: this.placeholder,
35
- validationLabel: this.validationLabel,
36
- disabled: this.disabled,
37
- showValidation: this.showValidation,
38
- showValidationOnNotTouched: this.showValidationOnNotTouched,
39
- hideValidationMessage: this.hideValidationMessage,
40
- iconClass: this.iconClass,
41
- control: this.control,
42
- loading: this.loading,
43
- showHint: this.showHint,
44
- maxLength: this.maxLength,
45
- tooltip: this.tooltip,
46
- name: this.name,
47
- required: this.isRequired(this.control),
48
- showAsterisk: this.showAsterisk,
49
- };
50
- }
51
-
52
- private isRequired = (ctrl: any): boolean => {
53
- if (ctrl?.validator) {
54
- const validator = ctrl.validator({} as AbstractControl);
55
- if (validator && validator['required']) {
56
- return true;
57
- }
58
- }
59
-
60
- if (ctrl?.['controls']) {
61
- for (const name in ctrl['controls']) {
62
- if (ctrl['controls'][name]) {
63
- if (this.isRequired(ctrl['controls'][name])) {
64
- return true;
65
- }
66
- }
67
- }
68
- }
69
-
70
- return false;
71
- };
72
- }
@@ -1,30 +0,0 @@
1
- <div
2
- class="form-field"
3
- [ngClass]="{
4
- 'form-field--invalid':
5
- data?.showValidation && (data?.control?.touched || data?.showValidationOnNotTouched) && data?.control?.invalid,
6
- disabled: data?.disabled,
7
- 'form-field--required': data?.required && data?.showAsterisk
8
- }"
9
- >
10
- <div>
11
- <label class="form-field__label" [attr.for]="data?.name" *ngIf="data?.label">
12
- <span [innerHTML]="data?.label"></span>
13
- <mat-icon class="icon" *ngIf="data?.tooltip" [matTooltip]="data?.tooltip">error_outline</mat-icon>
14
- </label>
15
- </div>
16
-
17
- <ng-content></ng-content>
18
-
19
- <ecabs-loading-spinner class="spinner" size="tiny" *ngIf="data.loading"></ecabs-loading-spinner>
20
-
21
- <app-hint [element]="data?.control" [showHint]="data?.showHint" [maxValue]="data?.maxLength"></app-hint>
22
-
23
- <app-validations-messages
24
- *ngIf="data?.showValidation && !data?.hideValidationMessage"
25
- [element]="data?.control"
26
- [label]="data?.label ? data?.label : data?.placeholder ? data.placeholder : data?.validationLabel"
27
- [showValidationOnNotTouched]="data?.showValidationOnNotTouched"
28
- >
29
- </app-validations-messages>
30
- </div>
@@ -1,33 +0,0 @@
1
- import { Component, Input, Output, EventEmitter } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'app-element-wrapper',
5
- templateUrl: './element-wrapper.component.html',
6
- })
7
- export class ElementWrapperComponent {
8
- @Input() data!:any;
9
- @Input() showCloseIcon!:boolean;
10
- @Input() focusedFlag!:any;
11
- @Input() showPassword!:boolean;
12
- @Input() control!:any;
13
- @Output() showHidePassword = new EventEmitter<any>();
14
- @Output() clear = new EventEmitter<any>();
15
- @Output() increase = new EventEmitter<any>();
16
- @Output() decrease = new EventEmitter<any>();
17
-
18
- showHidePasswordFn(event:any): void {
19
- this.showHidePassword.emit(event);
20
- }
21
-
22
- clearFn(): void {
23
- this.clear.emit();
24
- }
25
-
26
- increaseFn(): void {
27
- this.increase.emit();
28
- }
29
-
30
- decreaseFn(): void {
31
- this.decrease.emit();
32
- }
33
- }
@@ -1,30 +0,0 @@
1
-
2
- import { CommonModule } from '@angular/common';
3
- import { NgModule } from '@angular/core';
4
- import { FormsModule } from '@angular/forms';
5
- import { MatFormFieldModule } from '@angular/material/form-field';
6
- import { MatInputModule } from '@angular/material/input';
7
-
8
- import { HintModule } from '../hint/hint.module';
9
- import { ValidationModule } from '../validation/validation.module';
10
- import { ElementWrapperComponent } from './element-wrapper.component';
11
- import { MatIconModule } from '@angular/material/icon';
12
- import { MatTooltipModule } from '@angular/material/tooltip';
13
- import { EcabsLoadingModule } from '../../ecabs-loading/ecabs-loading.module';
14
-
15
- @NgModule({
16
- declarations: [ElementWrapperComponent],
17
- imports: [
18
- CommonModule,
19
- FormsModule,
20
- EcabsLoadingModule,
21
- ValidationModule,
22
- MatFormFieldModule,
23
- MatInputModule,
24
- MatIconModule,
25
- MatTooltipModule,
26
- HintModule,
27
- ],
28
- exports: [ElementWrapperComponent],
29
- })
30
- export class ElementWrapperModule {}
@@ -1 +0,0 @@
1
- <div class="hint" *ngIf="element && showHint">{{ element?.value?.length || 0 }}/{{ this.maxValue }}</div>
File without changes
@@ -1,12 +0,0 @@
1
- import { Component, Input } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'app-hint',
5
- templateUrl: './hint.component.html',
6
- styleUrls: ['./hint.component.scss'],
7
- })
8
- export class HintComponent {
9
- @Input() element!:any;
10
- @Input() maxValue!:number;
11
- @Input() showHint = false;
12
- }
@@ -1,13 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { NgModule } from '@angular/core';
3
- import { FormsModule } from '@angular/forms';
4
- import { MatFormFieldModule } from '@angular/material/form-field';
5
-
6
- import { HintComponent } from './hint.component';
7
-
8
- @NgModule({
9
- declarations: [HintComponent],
10
- imports: [CommonModule, FormsModule, MatFormFieldModule],
11
- exports: [HintComponent],
12
- })
13
- export class HintModule {}
@@ -1,8 +0,0 @@
1
- <div
2
- class="form-field__validation"
3
- *ngIf="element && (element?.touched || showValidationOnNotTouched) && element?.invalid"
4
- >
5
- <div class="form-field__validation__item" *ngFor="let item of element?.errors | keyvalue">
6
- {{ getMessageDetail(item.key) }}
7
- </div>
8
- </div>
File without changes
@@ -1,84 +0,0 @@
1
- import {
2
- Component,
3
- OnInit,
4
- Input,
5
- OnChanges,
6
- SimpleChanges,
7
- } from '@angular/core';
8
- import {
9
- EcabsComponentsConfig,
10
- EcabsComponentsService,
11
- } from '../../services/ecabs-components.service';
12
-
13
- @Component({
14
- selector: 'app-validations-messages',
15
- templateUrl: './validation.component.html',
16
- styleUrls: ['./validation.component.scss'],
17
- })
18
- export class ValidationComponent implements OnInit, OnChanges {
19
- @Input() element!: any;
20
- @Input() label!: string;
21
- @Input() showValidationOnNotTouched = false;
22
- @Input() updatedErrors!: { type: string; message: string }[];
23
- config!: EcabsComponentsConfig;
24
- private _messages: any = {};
25
-
26
- get messages(): any {
27
- if (this.element) {
28
- for (const errorKey in this.element.errors) {
29
- for (const key in this.element.errors[errorKey]) {
30
- if (this._messages[errorKey]) {
31
- this._messages[errorKey] = this._messages[errorKey].replace(
32
- `[${key}]`,
33
- this.element.errors[errorKey][key]
34
- );
35
- }
36
- }
37
- }
38
- }
39
-
40
- return this._messages;
41
- }
42
-
43
- set messages(m) {
44
- this._messages = m;
45
- }
46
-
47
- constructor(private ecabsService: EcabsComponentsService) {}
48
-
49
- ngOnInit() {
50
- this.config = this.ecabsService.getConfig();
51
- for (let error of this.config.errorMessages) {
52
- this.messages[error.type] = this.replaceTokens(error.message);
53
- }
54
- }
55
-
56
- ngOnChanges(changes: SimpleChanges): void {
57
- const { updatedErrors } = changes;
58
-
59
- if (
60
- updatedErrors &&
61
- updatedErrors.currentValue &&
62
- updatedErrors.currentValue.length > 0
63
- ) {
64
- for (const error of updatedErrors.currentValue) {
65
- this.messages[error.type] = error.message;
66
- }
67
- }
68
- }
69
-
70
- replaceTokens(message: string): string {
71
- let retMessage: string;
72
- if (this.label) {
73
- retMessage = message.replace('[label]', this.label);
74
- } else {
75
- retMessage = message;
76
- }
77
-
78
- return retMessage;
79
- }
80
-
81
- getMessageDetail(key: any): string {
82
- return this.messages[key];
83
- }
84
- }
@@ -1,12 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { ValidationComponent } from './validation.component';
3
- import { FormsModule } from '@angular/forms';
4
- import { CommonModule } from '@angular/common';
5
- import { MatFormFieldModule } from '@angular/material/form-field';
6
-
7
- @NgModule({
8
- declarations: [ValidationComponent],
9
- imports: [CommonModule, FormsModule, MatFormFieldModule],
10
- exports: [ValidationComponent],
11
- })
12
- export class ValidationModule {}
@@ -1,18 +0,0 @@
1
- <button
2
- mat-button
3
- [ngClass]="{
4
- '!w-full': full,
5
- 'mat-stroked-button': stroked,
6
- 'mat-raised-button': raised
7
- }"
8
- [color]="color"
9
- [disabled]="disabled"
10
- [type]="type"
11
- [attr.form]="form"
12
- >
13
- <ecabs-loading-spinner size="tiny" *ngIf="loading"></ecabs-loading-spinner>
14
- <ng-container *ngIf="!loading">
15
- <ng-content select="mat-icon"></ng-content>
16
- <ng-content></ng-content>
17
- </ng-container>
18
- </button>
@@ -1,54 +0,0 @@
1
- import { Component, HostBinding, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
2
- import { ThemePalette } from '@angular/material/core';
3
-
4
- @Component({
5
- selector: 'ecabs-buttons',
6
- templateUrl: './ecabs-buttons.component.html',
7
- })
8
- export class ButtonsComponent implements OnInit, OnChanges {
9
- @Input()
10
- label!: string;
11
-
12
- @Input()
13
- disabled!: boolean;
14
-
15
- @Input()
16
- loading!: boolean;
17
-
18
- @Input()
19
- form!: string;
20
-
21
- @Input()
22
- size: 'default' | 'large' = 'default';
23
-
24
- @Input()
25
- type: 'button' | 'submit' = 'button';
26
-
27
- @Input() raised = false;
28
- @Input() stroked = false;
29
- @Input() full = false;
30
- @Input()
31
- color: ThemePalette | 'success' = 'primary';
32
-
33
- @HostBinding('style.width')
34
- borderWidth = '';
35
- @HostBinding('class')
36
- classAttr = '';
37
-
38
- ngOnInit(): void {
39
- if (this.full) {
40
- this.borderWidth = '100%';
41
- }
42
- }
43
-
44
- ngOnChanges(changes: SimpleChanges): void {
45
- const disabled = changes['disabled']?.currentValue !== undefined ? changes['disabled'].currentValue : this.disabled;
46
- const loading = changes['loading']?.currentValue !== undefined ? changes['loading'].currentValue : this.loading;
47
-
48
- if (disabled || loading) {
49
- this.classAttr = 'pointer-events-none';
50
- } else {
51
- this.classAttr = '';
52
- }
53
- }
54
- }
@@ -1,13 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { ButtonsComponent } from './ecabs-buttons.component';
4
- import { MatButtonModule } from '@angular/material/button';
5
- import { MatIconModule } from '@angular/material/icon';
6
- import { EcabsLoadingModule } from '../ecabs-loading/ecabs-loading.module';
7
-
8
- @NgModule({
9
- declarations: [ButtonsComponent],
10
- imports: [CommonModule, MatButtonModule, EcabsLoadingModule, MatIconModule],
11
- exports: [ButtonsComponent],
12
- })
13
- export class EcabsButtonsModule {}
@@ -1,26 +0,0 @@
1
- <app-element-wrapper [data]="getData()">
2
- <div class="form-field__input--wrapper">
3
- <input
4
- appDigitsOnly
5
- [digitsOnly]="digitsOnly"
6
- [decimal]="allowDecimal"
7
- [allowHyphen]="allowHyphen"
8
- class="form-field__input"
9
- [type]="type"
10
- [id]="name"
11
- [(ngModel)]="value"
12
- [placeholder]="placeholder"
13
- (blur)="onTouch()"
14
- [disabled]="disabled"
15
- [maxlength]="maxLength"
16
- [max]="max"
17
- [step]="step"
18
- (blur)="blurChange($event)"
19
- />
20
-
21
- <div class="form-field__input--suffix" *ngIf="type !== 'number'">
22
- <ng-content select="mat-icon"></ng-content>
23
- <ng-content select=".suffix"></ng-content>
24
- </div>
25
- </div>
26
- </app-element-wrapper>
@@ -1,83 +0,0 @@
1
- import { AfterViewInit, Component, EventEmitter, Injector, Input, OnInit, Output } from '@angular/core';
2
- import { ControlValueAccessor, UntypedFormControl, NgControl, NG_VALUE_ACCESSOR } from '@angular/forms';
3
- import ElementBaseComponent from '../base/element-base';
4
-
5
- @Component({
6
- selector: 'ecabs-input',
7
- templateUrl: './ecabs-input.component.html',
8
- providers: [
9
- {
10
- provide: NG_VALUE_ACCESSOR,
11
- useExisting: EcabsInputComponent,
12
- multi: true,
13
- },
14
- ],
15
- })
16
- export class EcabsInputComponent
17
- extends ElementBaseComponent
18
- implements ControlValueAccessor, AfterViewInit, OnInit
19
- {
20
- @Input()
21
- digitsOnly!: boolean;
22
-
23
- @Input()
24
- allowDecimal!: boolean;
25
-
26
- @Input()
27
- allowHyphen!: boolean;
28
-
29
- @Input() max!: number;
30
- @Input() step!: number;
31
-
32
- @Output() onblur = new EventEmitter<any>();
33
- val!: string | number;
34
-
35
- get value(): string | number {
36
- return this.val;
37
- }
38
-
39
- set value(val) {
40
- if (val !== undefined && this.val !== val) {
41
- this.val = val;
42
- this.onChange(val);
43
- this.onTouch(val);
44
- }
45
- }
46
-
47
- constructor(private injector: Injector) {
48
- super();
49
- }
50
-
51
- ngOnInit(): void {
52
- if (this.type === 'number') {
53
- this.digitsOnly = true;
54
- }
55
- }
56
-
57
- ngAfterViewInit(): void {
58
- const ngControl: NgControl = this.injector.get(NgControl, null) as NgControl;
59
- if (ngControl) {
60
- this.control = ngControl.control as UntypedFormControl;
61
- }
62
- }
63
-
64
- onChange: any = () => {};
65
-
66
- onTouch: any = () => {};
67
-
68
- writeValue(value: any): void {
69
- this.value = value;
70
- }
71
-
72
- registerOnChange(fn: any): void {
73
- this.onChange = fn;
74
- }
75
-
76
- registerOnTouched(fn: any): void {
77
- this.onTouch = fn;
78
- }
79
-
80
- blurChange(e:any): void {
81
- this.onblur.emit(e);
82
- }
83
- }
@@ -1,14 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { EcabsInputComponent } from './ecabs-input.component';
4
- import { MatInputModule } from '@angular/material/input';
5
- import { ElementWrapperModule } from '../base/element-wrapper/element-wrapper.module';
6
- import { FormsModule } from '@angular/forms';
7
- import { DigitsOnlyDirective } from '../base/directives/digits-only.directive';
8
-
9
- @NgModule({
10
- declarations: [EcabsInputComponent, DigitsOnlyDirective],
11
- imports: [CommonModule, MatInputModule, ElementWrapperModule, FormsModule],
12
- exports: [EcabsInputComponent],
13
- })
14
- export class EcabsInputModule {}
@@ -1,7 +0,0 @@
1
- <div
2
- class="flex absolute left-0 top-0 right-0 bottom-0 z-50 items-center justify-center"
3
- [ngStyle]="{ backgroundColor: backgroundColor }"
4
- *ngIf="loading"
5
- >
6
- <ecabs-loading-spinner [size]="size" *ngIf="loading"></ecabs-loading-spinner>
7
- </div>