appproject-components 1.0.48 → 1.0.49

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 (154) hide show
  1. package/README.md +24 -24
  2. package/karma.conf.js +44 -0
  3. package/ng-package.json +7 -0
  4. package/package.json +15 -26
  5. package/src/lib/appproject-components.component.spec.ts +23 -0
  6. package/src/lib/appproject-components.component.ts +20 -0
  7. package/src/lib/appproject-components.module.ts +106 -0
  8. package/src/lib/appproject-components.service.spec.ts +16 -0
  9. package/src/lib/appproject-components.service.ts +9 -0
  10. package/src/lib/baseComponent.scss +162 -0
  11. package/src/lib/baseInputComponent.ts +35 -0
  12. package/src/lib/buttons/baseBtnComponent.ts +38 -0
  13. package/src/lib/buttons/btn-action/btn-action.component.html +11 -0
  14. package/src/lib/buttons/btn-action/btn-action.component.scss +7 -0
  15. package/src/lib/buttons/btn-action/btn-action.component.spec.ts +24 -0
  16. package/src/lib/buttons/btn-action/btn-action.component.ts +31 -0
  17. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.html +14 -0
  18. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.scss +5 -0
  19. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.spec.ts +24 -0
  20. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.ts +19 -0
  21. package/src/lib/buttons/btn-excluir/btn-excluir.component.html +6 -0
  22. package/src/lib/buttons/btn-excluir/btn-excluir.component.scss +5 -0
  23. package/src/lib/buttons/btn-excluir/btn-excluir.component.spec.ts +24 -0
  24. package/src/lib/buttons/btn-excluir/btn-excluir.component.ts +18 -0
  25. package/src/lib/buttons/btn-novo/btn-novo.component.html +14 -0
  26. package/src/lib/buttons/btn-novo/btn-novo.component.scss +8 -0
  27. package/src/lib/buttons/btn-novo/btn-novo.component.spec.ts +24 -0
  28. package/src/lib/buttons/btn-novo/btn-novo.component.ts +20 -0
  29. package/src/lib/buttons/btn-salvar/btn-salvar.component.html +8 -0
  30. package/src/lib/buttons/btn-salvar/btn-salvar.component.scss +5 -0
  31. package/src/lib/buttons/btn-salvar/btn-salvar.component.spec.ts +24 -0
  32. package/src/lib/buttons/btn-salvar/btn-salvar.component.ts +16 -0
  33. package/src/lib/entity-edit/entity-edit.component.html +143 -0
  34. package/src/lib/entity-edit/entity-edit.component.scss +4 -0
  35. package/src/lib/entity-edit/entity-edit.component.spec.ts +23 -0
  36. package/src/lib/entity-edit/entity-edit.component.ts +43 -0
  37. package/src/lib/grid-view/grid-view.component.html +116 -0
  38. package/src/lib/grid-view/grid-view.component.scss +47 -0
  39. package/src/lib/grid-view/grid-view.component.spec.ts +23 -0
  40. package/src/lib/grid-view/grid-view.component.ts +292 -0
  41. package/src/lib/input-area/input-area.component.html +30 -0
  42. package/src/lib/input-area/input-area.component.scss +68 -0
  43. package/src/lib/input-area/input-area.component.spec.ts +23 -0
  44. package/src/lib/input-area/input-area.component.ts +69 -0
  45. package/src/lib/input-arquivo/input-arquivo.component.html +11 -0
  46. package/src/lib/input-arquivo/input-arquivo.component.scss +0 -0
  47. package/src/lib/input-arquivo/input-arquivo.component.spec.ts +23 -0
  48. package/src/lib/input-arquivo/input-arquivo.component.ts +140 -0
  49. package/src/lib/input-cep/input-cep.component.html +38 -0
  50. package/src/lib/input-cep/input-cep.component.scss +0 -0
  51. package/src/lib/input-cep/input-cep.component.spec.ts +23 -0
  52. package/src/lib/input-cep/input-cep.component.ts +186 -0
  53. package/src/lib/input-checkbox/input-checkbox.component.html +12 -0
  54. package/src/lib/input-checkbox/input-checkbox.component.scss +11 -0
  55. package/src/lib/input-checkbox/input-checkbox.component.spec.ts +23 -0
  56. package/src/lib/input-checkbox/input-checkbox.component.ts +48 -0
  57. package/src/lib/input-format/input-format.component.html +32 -0
  58. package/src/lib/input-format/input-format.component.scss +47 -0
  59. package/src/lib/input-format/input-format.component.spec.ts +23 -0
  60. package/src/lib/input-format/input-format.component.ts +139 -0
  61. package/src/lib/input-pesquisa/input-pesquisa.component.html +77 -0
  62. package/src/lib/input-pesquisa/input-pesquisa.component.scss +127 -0
  63. package/src/lib/input-pesquisa/input-pesquisa.component.spec.ts +23 -0
  64. package/src/lib/input-pesquisa/input-pesquisa.component.ts +558 -0
  65. package/src/lib/input-radio/input-radio.component.html +21 -0
  66. package/src/lib/input-radio/input-radio.component.scss +3 -0
  67. package/src/lib/input-radio/input-radio.component.spec.ts +23 -0
  68. package/src/lib/input-radio/input-radio.component.ts +49 -0
  69. package/src/lib/input-select/input-select.component.html +29 -0
  70. package/src/lib/input-select/input-select.component.scss +62 -0
  71. package/src/lib/input-select/input-select.component.spec.ts +23 -0
  72. package/src/lib/input-select/input-select.component.ts +96 -0
  73. package/src/lib/input-text/input-text.component.html +48 -0
  74. package/src/lib/input-text/input-text.component.scss +63 -0
  75. package/src/lib/input-text/input-text.component.spec.ts +23 -0
  76. package/src/lib/input-text/input-text.component.ts +78 -0
  77. package/src/lib/input-valor/input-valor.component.html +32 -0
  78. package/src/lib/input-valor/input-valor.component.scss +47 -0
  79. package/src/lib/input-valor/input-valor.component.spec.ts +23 -0
  80. package/src/lib/input-valor/input-valor.component.ts +164 -0
  81. package/{lib/lib-config.d.ts → src/lib/lib-config.ts} +4 -3
  82. package/src/lib/model-treeview/model-treeview.component.html +20 -0
  83. package/src/lib/model-treeview/model-treeview.component.scss +0 -0
  84. package/src/lib/model-treeview/model-treeview.component.spec.ts +23 -0
  85. package/src/lib/model-treeview/model-treeview.component.ts +152 -0
  86. package/src/lib/tree-view/tree-view.component.html +96 -0
  87. package/src/lib/tree-view/tree-view.component.scss +50 -0
  88. package/src/lib/tree-view/tree-view.component.spec.ts +23 -0
  89. package/src/lib/tree-view/tree-view.component.ts +92 -0
  90. package/src/lib/tree-view-nivel/tree-view-nivel.component.html +17 -0
  91. package/src/lib/tree-view-nivel/tree-view-nivel.component.scss +8 -0
  92. package/src/lib/tree-view-nivel/tree-view-nivel.component.spec.ts +23 -0
  93. package/src/lib/tree-view-nivel/tree-view-nivel.component.ts +43 -0
  94. package/{public-api.d.ts → src/public-api.ts} +30 -24
  95. package/src/test.ts +15 -0
  96. package/tsconfig.lib.json +15 -0
  97. package/tsconfig.lib.prod.json +10 -0
  98. package/tsconfig.spec.json +17 -0
  99. package/esm2022/appproject-components.mjs +0 -5
  100. package/esm2022/lib/appproject-components.component.mjs +0 -22
  101. package/esm2022/lib/appproject-components.module.mjs +0 -159
  102. package/esm2022/lib/appproject-components.service.mjs +0 -14
  103. package/esm2022/lib/baseInputComponent.mjs +0 -69
  104. package/esm2022/lib/buttons/baseBtnComponent.mjs +0 -63
  105. package/esm2022/lib/buttons/btn-action/btn-action.component.mjs +0 -55
  106. package/esm2022/lib/buttons/btn-cancelar/btn-cancelar.component.mjs +0 -25
  107. package/esm2022/lib/buttons/btn-excluir/btn-excluir.component.mjs +0 -29
  108. package/esm2022/lib/buttons/btn-novo/btn-novo.component.mjs +0 -33
  109. package/esm2022/lib/buttons/btn-salvar/btn-salvar.component.mjs +0 -19
  110. package/esm2022/lib/entity-edit/entity-edit.component.mjs +0 -53
  111. package/esm2022/lib/grid-view/grid-view.component.mjs +0 -275
  112. package/esm2022/lib/input-area/input-area.component.mjs +0 -72
  113. package/esm2022/lib/input-arquivo/input-arquivo.component.mjs +0 -154
  114. package/esm2022/lib/input-cep/input-cep.component.mjs +0 -180
  115. package/esm2022/lib/input-checkbox/input-checkbox.component.mjs +0 -51
  116. package/esm2022/lib/input-format/input-format.component.mjs +0 -138
  117. package/esm2022/lib/input-pesquisa/input-pesquisa.component.mjs +0 -557
  118. package/esm2022/lib/input-radio/input-radio.component.mjs +0 -58
  119. package/esm2022/lib/input-select/input-select.component.mjs +0 -110
  120. package/esm2022/lib/input-text/input-text.component.mjs +0 -88
  121. package/esm2022/lib/input-valor/input-valor.component.mjs +0 -161
  122. package/esm2022/lib/lib-config.mjs +0 -2
  123. package/esm2022/lib/model-treeview/model-treeview.component.mjs +0 -126
  124. package/esm2022/lib/tree-view/tree-view.component.mjs +0 -104
  125. package/esm2022/lib/tree-view-nivel/tree-view-nivel.component.mjs +0 -50
  126. package/esm2022/public-api.mjs +0 -30
  127. package/fesm2022/appproject-components.mjs +0 -2531
  128. package/fesm2022/appproject-components.mjs.map +0 -1
  129. package/index.d.ts +0 -5
  130. package/lib/appproject-components.component.d.ts +0 -8
  131. package/lib/appproject-components.module.d.ts +0 -36
  132. package/lib/appproject-components.service.d.ts +0 -6
  133. package/lib/baseInputComponent.d.ts +0 -28
  134. package/lib/buttons/baseBtnComponent.d.ts +0 -19
  135. package/lib/buttons/btn-action/btn-action.component.d.ts +0 -21
  136. package/lib/buttons/btn-cancelar/btn-cancelar.component.d.ts +0 -10
  137. package/lib/buttons/btn-excluir/btn-excluir.component.d.ts +0 -12
  138. package/lib/buttons/btn-novo/btn-novo.component.d.ts +0 -13
  139. package/lib/buttons/btn-salvar/btn-salvar.component.d.ts +0 -9
  140. package/lib/entity-edit/entity-edit.component.d.ts +0 -22
  141. package/lib/grid-view/grid-view.component.d.ts +0 -52
  142. package/lib/input-area/input-area.component.d.ts +0 -24
  143. package/lib/input-arquivo/input-arquivo.component.d.ts +0 -43
  144. package/lib/input-cep/input-cep.component.d.ts +0 -29
  145. package/lib/input-checkbox/input-checkbox.component.d.ts +0 -21
  146. package/lib/input-format/input-format.component.d.ts +0 -27
  147. package/lib/input-pesquisa/input-pesquisa.component.d.ts +0 -69
  148. package/lib/input-radio/input-radio.component.d.ts +0 -23
  149. package/lib/input-select/input-select.component.d.ts +0 -32
  150. package/lib/input-text/input-text.component.d.ts +0 -33
  151. package/lib/input-valor/input-valor.component.d.ts +0 -29
  152. package/lib/model-treeview/model-treeview.component.d.ts +0 -39
  153. package/lib/tree-view/tree-view.component.d.ts +0 -23
  154. package/lib/tree-view-nivel/tree-view-nivel.component.d.ts +0 -17
@@ -0,0 +1,38 @@
1
+ <!--
2
+ <div [formGroup]="form">
3
+ -->
4
+ <!--comando --inner-padding-end: utilizado pra remover padding desnecessários-->
5
+ <div>
6
+ <ion-item lines="none" style="--background: inherited;--background-focused: transparent;--inner-padding-end: 0px;" [class]="itemClass"
7
+ [ngClass]="form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' "
8
+ >
9
+ <ion-label [position]="labelPosition">{{ label }}</ion-label>
10
+ <!-- formControlName={{formControlName}} -->
11
+ <ion-input #inputCep
12
+ type="tel"
13
+ [placeholder]="placeholder"
14
+ maxlength="{{ max }}"
15
+ (keydown)="digitarFormatado($event)"
16
+ (keyup.enter)="onKeyEnter()"
17
+ (ionBlur)="onBlur()"
18
+ [value]="data"
19
+ (input)="writeValue(inputCep.value)"
20
+ [disabled]="readonly"></ion-input>
21
+
22
+ <ion-button size="small" slot="end" tabindex="-1"
23
+ style="margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;" fill="clear" color="medium"
24
+ (click)="pesquisarClick()">
25
+ <ion-icon color="primary" name="search"></ion-icon>
26
+ </ion-button>
27
+
28
+ </ion-item>
29
+
30
+ <div class="validation-errors" *ngIf="form">
31
+ <ng-container *ngFor="let validation of validation_messages">
32
+ <div class="error-message"
33
+ *ngIf="form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)">
34
+ &#8226; {{ validation.message }}
35
+ </div>
36
+ </ng-container>
37
+ </div>
38
+ </div>
File without changes
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { InputCepComponent } from './input-cep.component';
4
+
5
+ describe('InputCepComponent', () => {
6
+ let component: InputCepComponent;
7
+ let fixture: ComponentFixture<InputCepComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ InputCepComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(InputCepComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,186 @@
1
+ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
2
+ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
3
+ import { Observable } from 'rxjs';
4
+ import { BaseInputComponent } from '../baseInputComponent';
5
+
6
+ @Component({
7
+ selector: 'kb-input-cep',
8
+ templateUrl: './input-cep.component.html',
9
+ styleUrls: ['./input-cep.component.scss', './../baseComponent.scss'],
10
+ providers: [{
11
+ provide: NG_VALUE_ACCESSOR,
12
+ useExisting: InputCepComponent,
13
+ multi: true
14
+ }]
15
+ })
16
+ export class InputCepComponent extends BaseInputComponent implements OnInit, ControlValueAccessor {
17
+
18
+ @Input() formato: string | null = '00000-000';
19
+ @Input() keyEnter: Function | null = null;
20
+ @Output() getResultados = new EventEmitter();
21
+
22
+ //control value acessor
23
+ public data: string | any = null;
24
+ private onChange: Function = (data: string) => { };
25
+ private onTouch: Function = () => { };
26
+ private disabled: boolean = false;
27
+ constructor() {
28
+ super();
29
+ }
30
+
31
+ writeValue(value: string | any): void {
32
+ //console.log('write value', value);
33
+ this.onChange(value);
34
+ this.data = value;
35
+ }
36
+ registerOnChange(fn: any): void {
37
+ this.onChange = fn;
38
+ }
39
+ registerOnTouched(fn: any): void {
40
+ this.onTouch = fn;
41
+ }
42
+ setDisabledState?(isDisabled: boolean): void {
43
+ this.disabled = this.disabled;
44
+ }
45
+
46
+ override ngOnInit(): void {
47
+ }
48
+
49
+ digitarFormatado(event: any) {
50
+ //console.log(event);
51
+ if ((event.keyCode >= 48 && event.keyCode <= 57)
52
+ || (event.keyCode >= 96 && event.keyCode <= 105)
53
+ || (event.keyCode == 8)
54
+ || (event.keyCode == 9)
55
+ || (event.keyCode == 39)
56
+ || (event.keyCode == 37)
57
+ || (event.keyCode == 46)) {
58
+
59
+ //console.log(this.formControlName, this.form.get(this.formControlName).value);
60
+
61
+ setTimeout(() => {
62
+ if (this.form) {
63
+ this.form.patchValue({
64
+ [this.formControlName]: this.formataCampoValor(this.form.get(this.formControlName)?.value, this.formato ?? '', event)
65
+ });
66
+ } else {
67
+ this.data = this.formataCampoValor(this.data ?? '', this.formato ?? '', event);
68
+ this.writeValue(this.data);
69
+ }
70
+ }, 100);
71
+
72
+ return true;
73
+ }
74
+ else {
75
+ return false;
76
+ }
77
+ }
78
+
79
+ onKeyEnter() {
80
+ if (this.keyEnter != null) {
81
+ this.keyEnter();
82
+ } else {
83
+ if (this.getResultados != null) {
84
+ this.pesquisarClick();
85
+ }
86
+ }
87
+ }
88
+
89
+ onBlur() {
90
+ if (this.form) {
91
+ this.form.get(this.formControlName)?.markAsTouched();
92
+ }
93
+ if (this.blur) {
94
+ this.blur.emit(this.blurArgs);
95
+ }
96
+ }
97
+
98
+ formataCampoValor(valor: string, Mascara: string, evento: any) {
99
+ //console.log(valor);
100
+ if (!valor)
101
+ return null;
102
+ //console.log(evento);
103
+
104
+ //if (!this.keypressInteiro(evento))
105
+ // return;
106
+
107
+ var boleanoMascara;
108
+
109
+ var Digitato = evento != null ? evento.keyCode : 0;
110
+ let exp = /\-|\.|\/|\(|\)| /g
111
+ let campoSoNumeros = valor.replace(exp, "");
112
+
113
+ var posicaoCampo = 0;
114
+ var NovoValorCampo = "";
115
+ var TamanhoMascara = campoSoNumeros.length;;
116
+
117
+ if (Digitato != 8) { // backspace
118
+ for (let i = 0; i <= TamanhoMascara; i++) {
119
+ boleanoMascara = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
120
+ || (Mascara.charAt(i) == "/"))
121
+ boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == "(")
122
+ || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " "))
123
+ if (boleanoMascara) {
124
+ NovoValorCampo += Mascara.charAt(i);
125
+ TamanhoMascara++;
126
+ } else {
127
+ NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
128
+ posicaoCampo++;
129
+ }
130
+ }
131
+ return NovoValorCampo;
132
+ } else {
133
+ return valor;
134
+ }
135
+ }
136
+
137
+ pesquisarClick() {
138
+ const cep = this.data;
139
+ //se não estiver informado o cep, não fazer a pesquisa
140
+ if (cep == null || cep == "") {
141
+ return;
142
+ }
143
+
144
+ this.getEnderecoPeloCep(cep).subscribe({
145
+ next: (result) => {
146
+ //console.log('result CEP', result);
147
+
148
+ let cidadePesquisa: string = result.localidade;
149
+ cidadePesquisa = this.converteCaracteresEspeciais(cidadePesquisa.toUpperCase());
150
+
151
+ if (this.getResultados) {
152
+ this.getResultados.emit(result);
153
+ }
154
+
155
+ }, error: (error) => {
156
+
157
+ }
158
+ });
159
+ }
160
+
161
+ //substituição de caracteres
162
+ converteCaracteresEspeciais(nome: string): string {
163
+ var res = nome.replace(/Ã/g, "A");
164
+ res = res.replace(/Á/g, "A");
165
+ res = res.replace(/Ç/g, "C");
166
+ res = res.replace(/É/g, "E");
167
+ res = res.replace(/Â/g, "A");
168
+ res = res.replace(/Ô/g, "O");
169
+ res = res.replace(/Ó/g, "O");
170
+ res = res.replace(/Ú/g, "U");
171
+ res = res.replace(/Í/g, "I");
172
+ return res;
173
+ }
174
+
175
+ getEnderecoPeloCep(cep: any): Observable<any> {
176
+ return new Observable((x) => {
177
+ var request = new XMLHttpRequest();
178
+ request.open('get', `https://viacep.com.br/ws/${cep}/json/`, true);
179
+ request.send();
180
+ request.onload = function () {
181
+ var data = JSON.parse(this.response);
182
+ x.next(data)
183
+ }
184
+ })
185
+ }
186
+ }
@@ -0,0 +1,12 @@
1
+ <div>
2
+ <ion-item lines="none" style="--background: inherited; --background-focused: transparent; padding-right: 0px;" [class]="itemClass">
3
+ <ion-checkbox #inputCheck
4
+ [labelPlacement]="labelPlacement" [justify]="justify"
5
+ [disabled]="readonly"
6
+ [checked]="data"
7
+ [color]="labelColor ?? 'primary'"
8
+ (ionChange)="writeValue(inputCheck.checked)">
9
+ <span [style.color]="labelColor ?? 'auto'">{{ label }}</span>
10
+ </ion-checkbox>
11
+ </ion-item>
12
+ </div>
@@ -0,0 +1,11 @@
1
+ ion-item {
2
+ --min-height: var(--checkbox-min-height, 48px) !important;
3
+ }
4
+
5
+ ion-checkbox.checkbox-disabled {
6
+ opacity: var(--item-disabled-opacity, 0.6) !important;
7
+ }
8
+
9
+ span {
10
+ color: var(--checkbox-text-color, 'inherit') !important;
11
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { InputCheckboxComponent } from './input-checkbox.component';
4
+
5
+ describe('InputCheckboxComponent', () => {
6
+ let component: InputCheckboxComponent;
7
+ let fixture: ComponentFixture<InputCheckboxComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [InputCheckboxComponent]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(InputCheckboxComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,48 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
3
+ import { BaseInputComponent } from '../baseInputComponent';
4
+
5
+ @Component({
6
+ selector: 'kb-input-checkbox',
7
+ templateUrl: './input-checkbox.component.html',
8
+ styleUrls: ['./input-checkbox.component.scss', './../baseComponent.scss'],
9
+ providers: [{
10
+ provide: NG_VALUE_ACCESSOR,
11
+ useExisting: InputCheckboxComponent,
12
+ multi: true
13
+ }]
14
+ })
15
+ export class InputCheckboxComponent extends BaseInputComponent implements OnInit, ControlValueAccessor {
16
+
17
+ @Input() justify: string = "start";
18
+ @Input() labelPlacement: string = "end";
19
+ //control value acessor
20
+ public data!: boolean | undefined;
21
+ private onChange: Function = (data: string) => { };
22
+ private onTouch: Function = () => { };
23
+ private disabled: boolean = false;
24
+ public console = console;
25
+
26
+ writeValue(value?: any): void {
27
+ console.log('write value', value);
28
+ this.onChange(value);
29
+ this.data = value;
30
+ }
31
+ registerOnChange(fn: any): void {
32
+ this.onChange = fn;
33
+ }
34
+ registerOnTouched(fn: any): void {
35
+ this.onTouch = fn;
36
+ }
37
+ setDisabledState?(isDisabled: boolean): void {
38
+ this.disabled = this.disabled;
39
+ }
40
+ constructor() {
41
+ super();
42
+ }
43
+
44
+
45
+
46
+ override ngOnInit(): void {
47
+ }
48
+ }
@@ -0,0 +1,32 @@
1
+ <!--
2
+ <div [formGroup]="form">
3
+ -->
4
+ <!--comando --inner-padding-end: utilizado pra remover padding desnecessários-->
5
+ <div>
6
+ <ion-item lines="none" style="--background: inherited;--background-focused: transparent;--inner-padding-end: 0px;" [class]="itemClass"
7
+ [ngClass]="form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' "
8
+ >
9
+ <ion-label [position]="labelPosition">{{ label }}</ion-label>
10
+ <!-- formControlName={{formControlName}} -->
11
+ <ion-input #inputFormat
12
+ type="tel"
13
+ [placeholder]="placeholder"
14
+ maxlength="{{ max }}"
15
+ (keydown)="digitarFormatado($event)"
16
+ (keyup.enter)="onKeyEnter()"
17
+ (ionBlur)="onBlur()"
18
+ [value]="data"
19
+ (input)="writeValue(inputFormat.value)"
20
+ [disabled]="readonly"></ion-input>
21
+
22
+ </ion-item>
23
+
24
+ <div class="validation-errors" *ngIf="form">
25
+ <ng-container *ngFor="let validation of validation_messages">
26
+ <div class="error-message"
27
+ *ngIf="form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)">
28
+ &#8226; {{ validation.message }}
29
+ </div>
30
+ </ng-container>
31
+ </div>
32
+ </div>
@@ -0,0 +1,47 @@
1
+ /*
2
+ @keyframes shake {
3
+ 0% { transform: translate(20px); }
4
+ 20% { transform: translate(-20px); }
5
+ 40% { transform: translate(10px); }
6
+ 60% { transform: translate(-10px); }
7
+ 80% { transform: translate(4px); }
8
+ 100% { transform: translate(0px); }
9
+ }
10
+ .error-shake {
11
+ ion-label {
12
+ color: red !important;
13
+ }
14
+ ion-input {
15
+ animation: shake 0.4s 1 linear;
16
+ border: 1px solid red !important;
17
+ }
18
+ }
19
+ */
20
+
21
+ /*
22
+ .has-focus {
23
+ border: 1px solid var(--ion-color-bluetool, #1f477d);
24
+ }
25
+ */
26
+
27
+ /*
28
+ ion-label {
29
+ margin-bottom: 4px !important;
30
+ }
31
+ */
32
+
33
+ /*
34
+ ion-input {
35
+ padding: 4px;
36
+ border: 1px solid darkgray;
37
+ border-radius: 4px;
38
+ width: 100%;
39
+ margin-top: 2px;
40
+ max-height: 29px;
41
+ }
42
+ */
43
+
44
+
45
+ .item-inner {
46
+ padding-right: 0px !important;
47
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { InputFormatComponent } from './input-format.component';
4
+
5
+ describe('InputFormatComponent', () => {
6
+ let component: InputFormatComponent;
7
+ let fixture: ComponentFixture<InputFormatComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ InputFormatComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(InputFormatComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,139 @@
1
+ import { Component, ElementRef, EventEmitter, Input, OnInit, ViewChild } from '@angular/core';
2
+ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
3
+ import { BaseInputComponent } from '../baseInputComponent';
4
+
5
+ @Component({
6
+ selector: 'kb-input-format',
7
+ templateUrl: './input-format.component.html',
8
+ styleUrls: ['./input-format.component.scss', './../baseComponent.scss'],
9
+ providers: [{
10
+ provide: NG_VALUE_ACCESSOR,
11
+ useExisting: InputFormatComponent,
12
+ multi: true
13
+ }]
14
+ })
15
+ export class InputFormatComponent extends BaseInputComponent implements OnInit, ControlValueAccessor {
16
+
17
+ @Input() formato: string | null = null;
18
+ @Input() keyEnter = new EventEmitter();
19
+ @ViewChild('inputFormat', { read: ElementRef, static: true}) inputFormatEdit;
20
+
21
+ //control value acessor
22
+ public data: string | any = null;
23
+ private onChange: Function = (data: string) => {};
24
+ private onTouch: Function = () => {};
25
+ private disabled: boolean = false;
26
+ public console = console;
27
+
28
+ writeValue(value: string | any): void {
29
+ //console.log('write value', value);
30
+ this.onChange(value);
31
+ this.data = value;
32
+ }
33
+ registerOnChange(fn: any): void {
34
+ this.onChange = fn;
35
+ }
36
+ registerOnTouched(fn: any): void {
37
+ this.onTouch = fn;
38
+ }
39
+ setDisabledState?(isDisabled: boolean): void {
40
+ this.disabled = this.disabled;
41
+ }
42
+
43
+ constructor() {
44
+ super();
45
+ }
46
+
47
+ override ngOnInit() { }
48
+
49
+ digitarFormatado(event: any) {
50
+ //console.log(event);
51
+ const index = event.target.selectionStart >= 1 ? (event.target.selectionStart - 1) : 0;
52
+ const keyAt = event.target.value.charCodeAt(index);
53
+ if ((event.keyCode >= 48 && event.keyCode <= 57)
54
+ || (keyAt >= 48 && keyAt <= 57)
55
+ || (event.keyCode >= 96 && event.keyCode <= 105)
56
+ || (event.keyCode == 8)
57
+ || (event.keyCode == 9)
58
+ || (event.keyCode == 39)
59
+ || (event.keyCode == 37)
60
+ || (event.keyCode == 46)) {
61
+
62
+ //console.log(this.formControlName, this.form.get(this.formControlName).value);
63
+
64
+ setTimeout(() => {
65
+ if (this.form) {
66
+ this.form.patchValue({
67
+ [this.formControlName]: this.formataCampoValor(this.form.get(this.formControlName)?.value, this.formato ?? '', event)
68
+ });
69
+ } else {
70
+ this.data = this.formataCampoValor(this.data ?? '', this.formato ?? '', event);
71
+ this.writeValue(this.data);
72
+ }
73
+ }, 100);
74
+
75
+ return true;
76
+ }
77
+ else {
78
+ return false;
79
+ }
80
+ }
81
+
82
+ onKeyEnter() {
83
+ if (this.keyEnter != null) {
84
+ this.keyEnter.emit();
85
+ }
86
+ }
87
+
88
+ onBlur() {
89
+ if (this.form) {
90
+ this.form.get(this.formControlName)?.markAsTouched();
91
+ }
92
+ if (this.blur) {
93
+ this.blur.emit(this.blurArgs);
94
+ }
95
+ }
96
+
97
+ setFocus() {
98
+ this.inputFormatEdit.nativeElement.setFocus();
99
+ }
100
+
101
+ formataCampoValor(valor: string, Mascara: string, evento: any) {
102
+ console.log(valor);
103
+ if (!valor)
104
+ return null;
105
+ //console.log(evento);
106
+
107
+ //if (!this.keypressInteiro(evento))
108
+ // return;
109
+
110
+ var boleanoMascara;
111
+
112
+ var Digitato = evento != null ? evento.keyCode : 0;
113
+ let exp = /\-|\.|\/|\(|\)| /g
114
+ let campoSoNumeros = valor.replace(exp, "");
115
+
116
+ var posicaoCampo = 0;
117
+ var NovoValorCampo = "";
118
+ var TamanhoMascara = campoSoNumeros.length;;
119
+
120
+ if (Digitato != 8) { // backspace
121
+ for (let i = 0; i <= TamanhoMascara; i++) {
122
+ boleanoMascara = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
123
+ || (Mascara.charAt(i) == "/"))
124
+ boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == "(")
125
+ || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " "))
126
+ if (boleanoMascara) {
127
+ NovoValorCampo += Mascara.charAt(i);
128
+ TamanhoMascara++;
129
+ } else {
130
+ NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
131
+ posicaoCampo++;
132
+ }
133
+ }
134
+ return NovoValorCampo;
135
+ } else {
136
+ return valor;
137
+ }
138
+ }
139
+ }
@@ -0,0 +1,77 @@
1
+ <div style="padding-inline-end: 0px;">
2
+ <ion-item lines="none" style="--background: inherited; --background-focused: transparent; margin-top: 2px;" [class]="itemClass">
3
+ <ion-label position="{{ labelPosition }}">{{ label }}</ion-label>
4
+ <!-- formControlName="{{ campo }}" -->
5
+ <ion-spinner *ngIf="!podePesquisar"
6
+ style="--min-height: 0px !important; margin-inline-end: 5px !important; margin-top: 16px;"
7
+ slot="start" name="lines"></ion-spinner>
8
+ <!-- (ionBlur)="verificarPesquisa()" -->
9
+ <!-- conflito com click da lista -->
10
+ <ion-input #inputPesquisa
11
+ [legacy]="true"
12
+ type="{{type}}"
13
+ [placeholder]="placeholder"
14
+ maxlength="{{ max }}"
15
+ (ionBlur)="onBlur($event)"
16
+ [value]="textoPesquisa" (input)="writePesquisa(inputPesquisa.value)"
17
+ (keyup)="showPesquisa($event)"
18
+ autocomplete="off" [style.--background]="inputBackgroungColor"
19
+ (click)="dropDownPesquisa(-1)"
20
+ [disabled]="readonly" debounce="500"></ion-input>
21
+ <ion-button size="small" slot="end" tabindex="-1"
22
+ class="botao-limpar" fill="clear" color="medium"
23
+ (click)="limparClick()">
24
+ <ion-icon name="close-outline"></ion-icon>
25
+ </ion-button>
26
+
27
+
28
+ <ion-button size="small" slot="end" tabindex="-1"
29
+ class="botao-limpar" fill="clear" color="medium"
30
+ (click)="pesquisarClick()">
31
+ <ion-icon color="primary" name="search"></ion-icon>
32
+ </ion-button>
33
+
34
+
35
+ </ion-item>
36
+
37
+ <ion-list tabindex="-1" [hidden]="!selectElementVisivel || !listaPesquisa || listaPesquisa.length == 0" class="pesquisa-list" style="max-height: 250px; overflow-y: auto;">
38
+
39
+ <ion-item tabindex="-1" button *ngFor="let item of listaPesquisa"
40
+ (click)="selecionarComboClick(item)" [id]="selectId + 'IonItem' + item['Index']"
41
+ class="pesquisa-item">
42
+ <!-- {{ item | json}} -->
43
+ <span [class]="{'selected-item': item['Selected'] === true}" [innerHTML]="highlight(item[campoDisplay])"></span>
44
+ </ion-item>
45
+
46
+ </ion-list>
47
+
48
+ <!--
49
+ <ion-select interface="popover" #selectElement tabindex="-1" [hidden]="!selectElementVisivel"
50
+ (ionChange)="selecionarComboChange($event.target.value)">
51
+ <ion-select-option *ngFor="let item of listaPesquisa" [value]="item[campoId]" (click)="selecionarComboClick(item[campoId])">
52
+ {{ item[campoDisplay] }}
53
+ </ion-select-option>
54
+ </ion-select>
55
+ -->
56
+
57
+ <!--
58
+ <select [id]="selectId" #selectElement tabindex="-1" [hidden]="!selectElementVisivel"
59
+ (change)="selecionarComboChange($event.target.value)" class="pesquisa-select">
60
+ <option *ngFor="let item of listaPesquisa" [value]="item[campoId]" (click)="selecionarComboClick(item[campoId])">
61
+ {{ item[campoDisplay] }}
62
+ </option>
63
+
64
+ </select>
65
+ -->
66
+
67
+ <div class="validation-errors" *ngIf="form">
68
+
69
+ <ng-container *ngFor="let validation of validation_messages">
70
+ <div class="error-message"
71
+ *ngIf="form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)">
72
+ &#8226; {{ validation.message }}
73
+ </div>
74
+ </ng-container>
75
+
76
+ </div>
77
+ </div>