appproject-components 0.0.31 → 1.0.0
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 → esm2022}/appproject-components.mjs +4 -4
- package/{esm2020 → esm2022}/lib/appproject-components.component.mjs +15 -15
- package/{esm2020 → esm2022}/lib/appproject-components.module.mjs +96 -96
- package/{esm2020 → esm2022}/lib/appproject-components.service.mjs +14 -14
- package/esm2022/lib/baseInputComponent.mjs +66 -0
- package/esm2022/lib/input-area/input-area.component.mjs +53 -0
- package/esm2022/lib/input-arquivo/input-arquivo.component.mjs +115 -0
- package/esm2022/lib/input-cep/input-cep.component.mjs +180 -0
- package/esm2022/lib/input-format/input-format.component.mjs +138 -0
- package/esm2022/lib/input-pesquisa/input-pesquisa.component.mjs +548 -0
- package/esm2022/lib/input-select/input-select.component.mjs +88 -0
- package/esm2022/lib/input-text/input-text.component.mjs +76 -0
- package/esm2022/lib/input-valor/input-valor.component.mjs +158 -0
- package/{esm2020 → esm2022}/lib/model-treeview/model-treeview.component.mjs +14 -14
- package/{esm2020 → esm2022}/public-api.mjs +18 -18
- package/fesm2022/appproject-components.mjs +1511 -0
- package/fesm2022/appproject-components.mjs.map +1 -0
- package/index.d.ts +5 -5
- package/lib/appproject-components.component.d.ts +8 -8
- package/lib/appproject-components.module.d.ts +26 -26
- package/lib/appproject-components.service.d.ts +6 -6
- package/lib/baseInputComponent.d.ts +27 -27
- package/lib/input-area/input-area.component.d.ts +21 -21
- package/lib/input-arquivo/input-arquivo.component.d.ts +34 -34
- package/lib/input-cep/input-cep.component.d.ts +29 -29
- package/lib/input-format/input-format.component.d.ts +27 -25
- package/lib/input-pesquisa/input-pesquisa.component.d.ts +68 -68
- package/lib/input-select/input-select.component.d.ts +29 -28
- package/lib/input-text/input-text.component.d.ts +29 -25
- package/lib/input-valor/input-valor.component.d.ts +28 -25
- package/lib/model-treeview/model-treeview.component.d.ts +8 -8
- package/package.json +8 -14
- package/public-api.d.ts +13 -13
- package/esm2020/lib/baseInputComponent.mjs +0 -65
- package/esm2020/lib/input-area/input-area.component.mjs +0 -53
- package/esm2020/lib/input-arquivo/input-arquivo.component.mjs +0 -114
- package/esm2020/lib/input-cep/input-cep.component.mjs +0 -180
- package/esm2020/lib/input-format/input-format.component.mjs +0 -129
- package/esm2020/lib/input-pesquisa/input-pesquisa.component.mjs +0 -540
- package/esm2020/lib/input-select/input-select.component.mjs +0 -80
- package/esm2020/lib/input-text/input-text.component.mjs +0 -65
- package/esm2020/lib/input-valor/input-valor.component.mjs +0 -125
- package/fesm2015/appproject-components.mjs +0 -1456
- package/fesm2015/appproject-components.mjs.map +0 -1
- package/fesm2020/appproject-components.mjs +0 -1441
- package/fesm2020/appproject-components.mjs.map +0 -1
|
@@ -0,0 +1,1511 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Component, EventEmitter, Input, Output, ElementRef, ViewChild, Inject, InjectionToken, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
3
|
+
import * as i3 from '@angular/forms';
|
|
4
|
+
import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
|
|
5
|
+
import * as i1 from '@angular/common';
|
|
6
|
+
import { CommonModule } from '@angular/common';
|
|
7
|
+
import * as i2 from '@ionic/angular';
|
|
8
|
+
import { IonicModule } from '@ionic/angular';
|
|
9
|
+
import * as i1$1 from '@angular/common/http';
|
|
10
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
11
|
+
import { Subject, of, Observable } from 'rxjs';
|
|
12
|
+
import { debounceTime, switchMap } from 'rxjs/operators';
|
|
13
|
+
import * as i1$2 from 'appproject-utils';
|
|
14
|
+
|
|
15
|
+
class AppprojectComponentsService {
|
|
16
|
+
constructor() { }
|
|
17
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: AppprojectComponentsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
18
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: AppprojectComponentsService, providedIn: 'root' }); }
|
|
19
|
+
}
|
|
20
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: AppprojectComponentsService, decorators: [{
|
|
21
|
+
type: Injectable,
|
|
22
|
+
args: [{
|
|
23
|
+
providedIn: 'root'
|
|
24
|
+
}]
|
|
25
|
+
}], ctorParameters: () => [] });
|
|
26
|
+
|
|
27
|
+
class AppprojectComponentsComponent {
|
|
28
|
+
constructor() { }
|
|
29
|
+
ngOnInit() {
|
|
30
|
+
}
|
|
31
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: AppprojectComponentsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
32
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: AppprojectComponentsComponent, selector: "kb-appproject-components", ngImport: i0, template: `
|
|
33
|
+
<p>
|
|
34
|
+
appproject-components works!
|
|
35
|
+
</p>
|
|
36
|
+
`, isInline: true }); }
|
|
37
|
+
}
|
|
38
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: AppprojectComponentsComponent, decorators: [{
|
|
39
|
+
type: Component,
|
|
40
|
+
args: [{ selector: 'kb-appproject-components', template: `
|
|
41
|
+
<p>
|
|
42
|
+
appproject-components works!
|
|
43
|
+
</p>
|
|
44
|
+
` }]
|
|
45
|
+
}], ctorParameters: () => [] });
|
|
46
|
+
|
|
47
|
+
class BaseInputComponent {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.labelPosition = 'stacked';
|
|
50
|
+
this.placeholder = '';
|
|
51
|
+
this.max = '10';
|
|
52
|
+
this.type = "text";
|
|
53
|
+
this.readonly = false;
|
|
54
|
+
this.leitura = false;
|
|
55
|
+
this.itemClass = "padding";
|
|
56
|
+
this.blur = new EventEmitter();
|
|
57
|
+
this.botaoLimpar = false;
|
|
58
|
+
this.labelColor = 'dark';
|
|
59
|
+
this.inputBackgroungColor = 'auto';
|
|
60
|
+
}
|
|
61
|
+
ngOnInit() {
|
|
62
|
+
throw new Error('Method not implemented.');
|
|
63
|
+
}
|
|
64
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: BaseInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
65
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: BaseInputComponent, selector: "ng-component", inputs: { label: "label", labelPosition: "labelPosition", nome: "nome", placeholder: "placeholder", form: "form", campo: "campo", formControlName: "formControlName", max: "max", validation_messages: "validation_messages", type: "type", readonly: "readonly", leitura: "leitura", itemClass: "itemClass", botaoLimpar: "botaoLimpar", labelColor: "labelColor", inputBackgroungColor: "inputBackgroungColor", blurArgs: "blurArgs" }, outputs: { blur: "blur" }, ngImport: i0, template: '', isInline: true }); }
|
|
66
|
+
}
|
|
67
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: BaseInputComponent, decorators: [{
|
|
68
|
+
type: Component,
|
|
69
|
+
args: [{
|
|
70
|
+
template: ''
|
|
71
|
+
}]
|
|
72
|
+
}], ctorParameters: () => [], propDecorators: { label: [{
|
|
73
|
+
type: Input
|
|
74
|
+
}], labelPosition: [{
|
|
75
|
+
type: Input
|
|
76
|
+
}], nome: [{
|
|
77
|
+
type: Input
|
|
78
|
+
}], placeholder: [{
|
|
79
|
+
type: Input
|
|
80
|
+
}], form: [{
|
|
81
|
+
type: Input
|
|
82
|
+
}], campo: [{
|
|
83
|
+
type: Input
|
|
84
|
+
}], formControlName: [{
|
|
85
|
+
type: Input,
|
|
86
|
+
args: ['formControlName']
|
|
87
|
+
}], max: [{
|
|
88
|
+
type: Input
|
|
89
|
+
}], validation_messages: [{
|
|
90
|
+
type: Input
|
|
91
|
+
}], type: [{
|
|
92
|
+
type: Input
|
|
93
|
+
}], readonly: [{
|
|
94
|
+
type: Input
|
|
95
|
+
}], leitura: [{
|
|
96
|
+
type: Input
|
|
97
|
+
}], itemClass: [{
|
|
98
|
+
type: Input
|
|
99
|
+
}], blur: [{
|
|
100
|
+
type: Output
|
|
101
|
+
}], botaoLimpar: [{
|
|
102
|
+
type: Input
|
|
103
|
+
}], labelColor: [{
|
|
104
|
+
type: Input
|
|
105
|
+
}], inputBackgroungColor: [{
|
|
106
|
+
type: Input
|
|
107
|
+
}], blurArgs: [{
|
|
108
|
+
type: Input
|
|
109
|
+
}] } });
|
|
110
|
+
|
|
111
|
+
class InputTextComponent extends BaseInputComponent {
|
|
112
|
+
writeValue(value) {
|
|
113
|
+
//console.log('write value', value);
|
|
114
|
+
this.onChange(value);
|
|
115
|
+
this.data = value;
|
|
116
|
+
}
|
|
117
|
+
registerOnChange(fn) {
|
|
118
|
+
this.onChange = fn;
|
|
119
|
+
}
|
|
120
|
+
registerOnTouched(fn) {
|
|
121
|
+
this.onTouch = fn;
|
|
122
|
+
}
|
|
123
|
+
setDisabledState(isDisabled) {
|
|
124
|
+
this.disabled = this.disabled;
|
|
125
|
+
}
|
|
126
|
+
constructor() {
|
|
127
|
+
super();
|
|
128
|
+
this.inputSpanAfter = null;
|
|
129
|
+
this.onChange = (data) => { };
|
|
130
|
+
this.onTouch = () => { };
|
|
131
|
+
this.disabled = false;
|
|
132
|
+
this.console = console;
|
|
133
|
+
}
|
|
134
|
+
ngOnInit() {
|
|
135
|
+
}
|
|
136
|
+
onBlur() {
|
|
137
|
+
console.log('control name', this.formControlName);
|
|
138
|
+
if (this.form) {
|
|
139
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
limparClick() {
|
|
143
|
+
this.writeValue(undefined);
|
|
144
|
+
}
|
|
145
|
+
isReadonly() {
|
|
146
|
+
return this.leitura;
|
|
147
|
+
}
|
|
148
|
+
changeTypeOfInput() {
|
|
149
|
+
this.type =
|
|
150
|
+
this.type == 'password' ?
|
|
151
|
+
'text' : 'password';
|
|
152
|
+
}
|
|
153
|
+
setFocus() {
|
|
154
|
+
this.inputTextEdit.nativeElement.setFocus();
|
|
155
|
+
}
|
|
156
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputTextComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
157
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: InputTextComponent, selector: "kb-input-text", inputs: { iconInput: "iconInput", inputSpanAfter: "inputSpanAfter", campoFoco: "campoFoco" }, providers: [{
|
|
158
|
+
provide: NG_VALUE_ACCESSOR,
|
|
159
|
+
useExisting: InputTextComponent,
|
|
160
|
+
multi: true
|
|
161
|
+
}], viewQueries: [{ propertyName: "inputTextEdit", first: true, predicate: ["inputText"], descendants: true, read: ElementRef, static: true }], usesInheritance: true, ngImport: i0, template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent; padding-right: 0px;\" [class]=\"itemClass\"\r\n [style.opacity]=\"readonly ? '0.5' : '1'\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label position=\"{{ labelPosition }}\" color=\"{{ labelColor }}\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ campo }}\" -->\r\n <ion-input #inputText\r\n type=\"{{type}}\" \r\n [placeholder]=\"placeholder\" \r\n maxlength=\"{{ max }}\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n (input)=\"writeValue(inputText.value)\" \r\n autocomplete=\"new-password\"\r\n [style.--background]=\"inputBackgroungColor\"\r\n [disabled]=\"readonly\"\r\n [clearInput]=\"botaoLimpar\">\r\n <ion-icon *ngIf=\"iconInput\" name=\"{{ iconInput }}\"></ion-icon>\r\n </ion-input>\r\n \r\n <ion-button size=\"small\" slot=\"end\" *ngIf=\"showSeePassword\" style=\"margin-top: 27px; margin-inline-start: 4px !important;\" fill=\"clear\" color=\"dark\" (click)=\"changeTypeOfInput()\">\r\n <!-- (click)=\"limparClick()\" -->\r\n <ion-icon [name]=\"type == 'password' ? 'eye-outline' : 'eye-off-outline' \"></ion-icon>\r\n </ion-button>\r\n\r\n <span *ngIf=\"inputSpanAfter\" slot=\"end\" class=\"inputSpanAfter-item\"> {{ inputSpanAfter }}</span>\r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n \r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n \r\n </div>\r\n </div>", styles: [".no-padding-end{--inner-padding-end: 0}ion-input ion-icon{padding-right:6px;font-size:18px}.input-login{height:36px}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { kind: "component", type: i2.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: i2.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "legacy", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "directive", type: i2.TextValueAccessor, selector: "ion-input:not([type=number]),ion-textarea,ion-searchbar" }] }); }
|
|
162
|
+
}
|
|
163
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputTextComponent, decorators: [{
|
|
164
|
+
type: Component,
|
|
165
|
+
args: [{ selector: 'kb-input-text', providers: [{
|
|
166
|
+
provide: NG_VALUE_ACCESSOR,
|
|
167
|
+
useExisting: InputTextComponent,
|
|
168
|
+
multi: true
|
|
169
|
+
}], template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent; padding-right: 0px;\" [class]=\"itemClass\"\r\n [style.opacity]=\"readonly ? '0.5' : '1'\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label position=\"{{ labelPosition }}\" color=\"{{ labelColor }}\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ campo }}\" -->\r\n <ion-input #inputText\r\n type=\"{{type}}\" \r\n [placeholder]=\"placeholder\" \r\n maxlength=\"{{ max }}\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n (input)=\"writeValue(inputText.value)\" \r\n autocomplete=\"new-password\"\r\n [style.--background]=\"inputBackgroungColor\"\r\n [disabled]=\"readonly\"\r\n [clearInput]=\"botaoLimpar\">\r\n <ion-icon *ngIf=\"iconInput\" name=\"{{ iconInput }}\"></ion-icon>\r\n </ion-input>\r\n \r\n <ion-button size=\"small\" slot=\"end\" *ngIf=\"showSeePassword\" style=\"margin-top: 27px; margin-inline-start: 4px !important;\" fill=\"clear\" color=\"dark\" (click)=\"changeTypeOfInput()\">\r\n <!-- (click)=\"limparClick()\" -->\r\n <ion-icon [name]=\"type == 'password' ? 'eye-outline' : 'eye-off-outline' \"></ion-icon>\r\n </ion-button>\r\n\r\n <span *ngIf=\"inputSpanAfter\" slot=\"end\" class=\"inputSpanAfter-item\"> {{ inputSpanAfter }}</span>\r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n \r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n \r\n </div>\r\n </div>", styles: [".no-padding-end{--inner-padding-end: 0}ion-input ion-icon{padding-right:6px;font-size:18px}.input-login{height:36px}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"] }]
|
|
170
|
+
}], ctorParameters: () => [], propDecorators: { iconInput: [{
|
|
171
|
+
type: Input
|
|
172
|
+
}], inputSpanAfter: [{
|
|
173
|
+
type: Input
|
|
174
|
+
}], inputTextEdit: [{
|
|
175
|
+
type: ViewChild,
|
|
176
|
+
args: ['inputText', { read: ElementRef, static: true }]
|
|
177
|
+
}], campoFoco: [{
|
|
178
|
+
type: Input
|
|
179
|
+
}] } });
|
|
180
|
+
|
|
181
|
+
class InputFormatComponent extends BaseInputComponent {
|
|
182
|
+
writeValue(value) {
|
|
183
|
+
//console.log('write value', value);
|
|
184
|
+
this.onChange(value);
|
|
185
|
+
this.data = value;
|
|
186
|
+
}
|
|
187
|
+
registerOnChange(fn) {
|
|
188
|
+
this.onChange = fn;
|
|
189
|
+
}
|
|
190
|
+
registerOnTouched(fn) {
|
|
191
|
+
this.onTouch = fn;
|
|
192
|
+
}
|
|
193
|
+
setDisabledState(isDisabled) {
|
|
194
|
+
this.disabled = this.disabled;
|
|
195
|
+
}
|
|
196
|
+
constructor() {
|
|
197
|
+
super();
|
|
198
|
+
this.formato = null;
|
|
199
|
+
this.keyEnter = new EventEmitter();
|
|
200
|
+
//control value acessor
|
|
201
|
+
this.data = null;
|
|
202
|
+
this.onChange = (data) => { };
|
|
203
|
+
this.onTouch = () => { };
|
|
204
|
+
this.disabled = false;
|
|
205
|
+
this.console = console;
|
|
206
|
+
}
|
|
207
|
+
ngOnInit() { }
|
|
208
|
+
digitarFormatado(event) {
|
|
209
|
+
//console.log(event);
|
|
210
|
+
const index = event.target.selectionStart >= 1 ? (event.target.selectionStart - 1) : 0;
|
|
211
|
+
const keyAt = event.target.value.charCodeAt(index);
|
|
212
|
+
if ((event.keyCode >= 48 && event.keyCode <= 57)
|
|
213
|
+
|| (keyAt >= 48 && keyAt <= 57)
|
|
214
|
+
|| (event.keyCode >= 96 && event.keyCode <= 105)
|
|
215
|
+
|| (event.keyCode == 8)
|
|
216
|
+
|| (event.keyCode == 9)
|
|
217
|
+
|| (event.keyCode == 39)
|
|
218
|
+
|| (event.keyCode == 37)
|
|
219
|
+
|| (event.keyCode == 46)) {
|
|
220
|
+
//console.log(this.formControlName, this.form.get(this.formControlName).value);
|
|
221
|
+
setTimeout(() => {
|
|
222
|
+
if (this.form) {
|
|
223
|
+
this.form.patchValue({
|
|
224
|
+
[this.formControlName]: this.formataCampoValor(this.form.get(this.formControlName)?.value, this.formato ?? '', event)
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
this.data = this.formataCampoValor(this.data ?? '', this.formato ?? '', event);
|
|
229
|
+
this.writeValue(this.data);
|
|
230
|
+
}
|
|
231
|
+
}, 100);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
onKeyEnter() {
|
|
239
|
+
if (this.keyEnter != null) {
|
|
240
|
+
this.keyEnter.emit();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
onBlur() {
|
|
244
|
+
if (this.form) {
|
|
245
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
246
|
+
}
|
|
247
|
+
if (this.blur) {
|
|
248
|
+
this.blur.emit(this.blurArgs);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
setFocus() {
|
|
252
|
+
this.inputFormatEdit.nativeElement.setFocus();
|
|
253
|
+
}
|
|
254
|
+
formataCampoValor(valor, Mascara, evento) {
|
|
255
|
+
console.log(valor);
|
|
256
|
+
if (!valor)
|
|
257
|
+
return null;
|
|
258
|
+
//console.log(evento);
|
|
259
|
+
//if (!this.keypressInteiro(evento))
|
|
260
|
+
// return;
|
|
261
|
+
var boleanoMascara;
|
|
262
|
+
var Digitato = evento != null ? evento.keyCode : 0;
|
|
263
|
+
let exp = /\-|\.|\/|\(|\)| /g;
|
|
264
|
+
let campoSoNumeros = valor.replace(exp, "");
|
|
265
|
+
var posicaoCampo = 0;
|
|
266
|
+
var NovoValorCampo = "";
|
|
267
|
+
var TamanhoMascara = campoSoNumeros.length;
|
|
268
|
+
;
|
|
269
|
+
if (Digitato != 8) { // backspace
|
|
270
|
+
for (let i = 0; i <= TamanhoMascara; i++) {
|
|
271
|
+
boleanoMascara = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
|
|
272
|
+
|| (Mascara.charAt(i) == "/"));
|
|
273
|
+
boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == "(")
|
|
274
|
+
|| (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " "));
|
|
275
|
+
if (boleanoMascara) {
|
|
276
|
+
NovoValorCampo += Mascara.charAt(i);
|
|
277
|
+
TamanhoMascara++;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
|
|
281
|
+
posicaoCampo++;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return NovoValorCampo;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
return valor;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputFormatComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
291
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: InputFormatComponent, selector: "kb-input-format", inputs: { formato: "formato", keyEnter: "keyEnter" }, providers: [{
|
|
292
|
+
provide: NG_VALUE_ACCESSOR,
|
|
293
|
+
useExisting: InputFormatComponent,
|
|
294
|
+
multi: true
|
|
295
|
+
}], viewQueries: [{ propertyName: "inputFormatEdit", first: true, predicate: ["inputFormat"], descendants: true, read: ElementRef, static: true }], usesInheritance: true, ngImport: i0, template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<!--comando --inner-padding-end: utilizado pra remover padding desnecess\u00E1rios-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background: inherited;--background-focused: transparent;--inner-padding-end: 0px;\" [class]=\"itemClass\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label [position]=\"labelPosition\">{{ label }}</ion-label>\r\n <!-- formControlName={{formControlName}} -->\r\n <ion-input #inputFormat\r\n type=\"tel\" \r\n [placeholder]=\"placeholder\"\r\n maxlength=\"{{ max }}\" \r\n (keydown)=\"digitarFormatado($event)\" \r\n (keyup.enter)=\"onKeyEnter()\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n (input)=\"writeValue(inputFormat.value)\"\r\n [disabled]=\"readonly\"></ion-input>\r\n \r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n </div>\r\n </div>", styles: [".item-inner{padding-right:0!important}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "legacy", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "directive", type: i2.TextValueAccessor, selector: "ion-input:not([type=number]),ion-textarea,ion-searchbar" }] }); }
|
|
296
|
+
}
|
|
297
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputFormatComponent, decorators: [{
|
|
298
|
+
type: Component,
|
|
299
|
+
args: [{ selector: 'kb-input-format', providers: [{
|
|
300
|
+
provide: NG_VALUE_ACCESSOR,
|
|
301
|
+
useExisting: InputFormatComponent,
|
|
302
|
+
multi: true
|
|
303
|
+
}], template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<!--comando --inner-padding-end: utilizado pra remover padding desnecess\u00E1rios-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background: inherited;--background-focused: transparent;--inner-padding-end: 0px;\" [class]=\"itemClass\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label [position]=\"labelPosition\">{{ label }}</ion-label>\r\n <!-- formControlName={{formControlName}} -->\r\n <ion-input #inputFormat\r\n type=\"tel\" \r\n [placeholder]=\"placeholder\"\r\n maxlength=\"{{ max }}\" \r\n (keydown)=\"digitarFormatado($event)\" \r\n (keyup.enter)=\"onKeyEnter()\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n (input)=\"writeValue(inputFormat.value)\"\r\n [disabled]=\"readonly\"></ion-input>\r\n \r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n </div>\r\n </div>", styles: [".item-inner{padding-right:0!important}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"] }]
|
|
304
|
+
}], ctorParameters: () => [], propDecorators: { formato: [{
|
|
305
|
+
type: Input
|
|
306
|
+
}], keyEnter: [{
|
|
307
|
+
type: Input
|
|
308
|
+
}], inputFormatEdit: [{
|
|
309
|
+
type: ViewChild,
|
|
310
|
+
args: ['inputFormat', { read: ElementRef, static: true }]
|
|
311
|
+
}] } });
|
|
312
|
+
|
|
313
|
+
class InputSelectComponent extends BaseInputComponent {
|
|
314
|
+
writeValue(value) {
|
|
315
|
+
console.log('write value select', value);
|
|
316
|
+
this.onChange(value);
|
|
317
|
+
this.data = value;
|
|
318
|
+
}
|
|
319
|
+
registerOnChange(fn) {
|
|
320
|
+
this.onChange = fn;
|
|
321
|
+
}
|
|
322
|
+
registerOnTouched(fn) {
|
|
323
|
+
this.onTouch = fn;
|
|
324
|
+
}
|
|
325
|
+
setDisabledState(isDisabled) {
|
|
326
|
+
this.disabled = this.disabled;
|
|
327
|
+
}
|
|
328
|
+
constructor() {
|
|
329
|
+
super();
|
|
330
|
+
this.selectChange = new EventEmitter();
|
|
331
|
+
this.selectChangeEntity = new EventEmitter();
|
|
332
|
+
this.itens = [];
|
|
333
|
+
this.itemId = "Id";
|
|
334
|
+
this.itemNome = "Nome";
|
|
335
|
+
this.showNovo = false;
|
|
336
|
+
this.itemNull = true;
|
|
337
|
+
this.opcaoDefault = 'Selecionar';
|
|
338
|
+
this.onChange = (data) => { };
|
|
339
|
+
this.onTouch = () => { };
|
|
340
|
+
this.disabled = false;
|
|
341
|
+
this.console = console;
|
|
342
|
+
}
|
|
343
|
+
ngOnInit() {
|
|
344
|
+
}
|
|
345
|
+
onSelectChange(value) {
|
|
346
|
+
this.writeValue(value);
|
|
347
|
+
if (this.selectChange != null) {
|
|
348
|
+
//console.log('emit', value);
|
|
349
|
+
this.selectChange.emit(value);
|
|
350
|
+
}
|
|
351
|
+
if (this.selectChangeEntity != null) {
|
|
352
|
+
const existe = this.itens.find(i => i[this.itemId] == value);
|
|
353
|
+
this.selectChangeEntity.emit(existe);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
onBlur() {
|
|
357
|
+
//console.log('input select blur')
|
|
358
|
+
if (this.form) {
|
|
359
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
363
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: InputSelectComponent, selector: "kb-input-select", inputs: { itens: "itens", itemId: "itemId", itemNome: "itemNome", showNovo: "showNovo", itemNull: "itemNull", opcaoDefault: "opcaoDefault" }, outputs: { selectChange: "selectChange", selectChangeEntity: "selectChangeEntity" }, providers: [{
|
|
364
|
+
provide: NG_VALUE_ACCESSOR,
|
|
365
|
+
useExisting: InputSelectComponent,
|
|
366
|
+
multi: true
|
|
367
|
+
}], usesInheritance: true, ngImport: i0, template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent;\" [class]=\"itemClass\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label *ngIf=\"label\" [position]=\"labelPosition\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ formControlName }}\" -->\r\n <select #inputSelect\r\n style=\"width: 100%;\" (change)=\"onSelectChange(inputSelect.value)\"\r\n (blur)=\"onBlur()\" [disabled]=\"readonly\">\r\n <option *ngIf=\"itemNull\" [value]=\"''\" selected>{{ opcaoDefault }}</option>\r\n <option *ngFor=\"let item of itens\" [value]=\"item[itemId]\" [selected]=\"item[itemId] == data\">{{ item[itemNome] }}\r\n </option>\r\n </select> \r\n </ion-item>\r\n \r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n </div>\r\n \r\n </div>", styles: ["select{padding:var(--select-padding, 4px);border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;height:var(--select-height, 28px);margin-left:0}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:42px!important}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }] }); }
|
|
368
|
+
}
|
|
369
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputSelectComponent, decorators: [{
|
|
370
|
+
type: Component,
|
|
371
|
+
args: [{ selector: 'kb-input-select', providers: [{
|
|
372
|
+
provide: NG_VALUE_ACCESSOR,
|
|
373
|
+
useExisting: InputSelectComponent,
|
|
374
|
+
multi: true
|
|
375
|
+
}], template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent;\" [class]=\"itemClass\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label *ngIf=\"label\" [position]=\"labelPosition\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ formControlName }}\" -->\r\n <select #inputSelect\r\n style=\"width: 100%;\" (change)=\"onSelectChange(inputSelect.value)\"\r\n (blur)=\"onBlur()\" [disabled]=\"readonly\">\r\n <option *ngIf=\"itemNull\" [value]=\"''\" selected>{{ opcaoDefault }}</option>\r\n <option *ngFor=\"let item of itens\" [value]=\"item[itemId]\" [selected]=\"item[itemId] == data\">{{ item[itemNome] }}\r\n </option>\r\n </select> \r\n </ion-item>\r\n \r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n </div>\r\n \r\n </div>", styles: ["select{padding:var(--select-padding, 4px);border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;height:var(--select-height, 28px);margin-left:0}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:42px!important}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"] }]
|
|
376
|
+
}], ctorParameters: () => [], propDecorators: { selectChange: [{
|
|
377
|
+
type: Output
|
|
378
|
+
}], selectChangeEntity: [{
|
|
379
|
+
type: Output
|
|
380
|
+
}], itens: [{
|
|
381
|
+
type: Input
|
|
382
|
+
}], itemId: [{
|
|
383
|
+
type: Input
|
|
384
|
+
}], itemNome: [{
|
|
385
|
+
type: Input
|
|
386
|
+
}], showNovo: [{
|
|
387
|
+
type: Input
|
|
388
|
+
}], itemNull: [{
|
|
389
|
+
type: Input
|
|
390
|
+
}], opcaoDefault: [{
|
|
391
|
+
type: Input
|
|
392
|
+
}] } });
|
|
393
|
+
|
|
394
|
+
class ModelTreeviewComponent {
|
|
395
|
+
constructor() { }
|
|
396
|
+
ngOnInit() {
|
|
397
|
+
}
|
|
398
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: ModelTreeviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
399
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: ModelTreeviewComponent, selector: "kb-model-treeview", ngImport: i0, template: "<p>model-treeview works!</p>\n", styles: [""] }); }
|
|
400
|
+
}
|
|
401
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: ModelTreeviewComponent, decorators: [{
|
|
402
|
+
type: Component,
|
|
403
|
+
args: [{ selector: 'kb-model-treeview', template: "<p>model-treeview works!</p>\n" }]
|
|
404
|
+
}], ctorParameters: () => [] });
|
|
405
|
+
|
|
406
|
+
class InputPesquisaComponent extends BaseInputComponent {
|
|
407
|
+
writeValue(value) {
|
|
408
|
+
//console.log('write value', value);
|
|
409
|
+
this.onChange(value);
|
|
410
|
+
this.data = value;
|
|
411
|
+
if (value == null || value == 0) {
|
|
412
|
+
this.writePesquisa('');
|
|
413
|
+
this.selectedItem = null;
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
if (this.loadInit == true) {
|
|
417
|
+
this.loadInit = false;
|
|
418
|
+
this.modelChanged.next(value);
|
|
419
|
+
//this.carregaItemIdParaLista(value);
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
//console.log(this.selectedItem);
|
|
423
|
+
if (!this.selectedItem || (this.selectedItem && this.selectedItem[this.campoId] != value)) {
|
|
424
|
+
console.log('Id diferente');
|
|
425
|
+
this.modelChanged.next(value);
|
|
426
|
+
//this.carregaItemIdParaLista(value);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
registerOnChange(fn) {
|
|
432
|
+
this.onChange = fn;
|
|
433
|
+
}
|
|
434
|
+
registerOnTouched(fn) {
|
|
435
|
+
this.onTouch = fn;
|
|
436
|
+
}
|
|
437
|
+
setDisabledState(isDisabled) {
|
|
438
|
+
this.disabled = this.disabled;
|
|
439
|
+
}
|
|
440
|
+
constructor(config, httpClient, modalCtrl) {
|
|
441
|
+
super();
|
|
442
|
+
this.config = config;
|
|
443
|
+
this.httpClient = httpClient;
|
|
444
|
+
this.modalCtrl = modalCtrl;
|
|
445
|
+
this.podePesquisar = true;
|
|
446
|
+
this.textoPesquisa = '';
|
|
447
|
+
this.selectElementVisivel = false;
|
|
448
|
+
this.listaPesquisa = [];
|
|
449
|
+
this.max = '30';
|
|
450
|
+
this.pesquisaSubject = new Subject();
|
|
451
|
+
this.filterFunction = null;
|
|
452
|
+
this.selectId = 'selectElement';
|
|
453
|
+
this.campoId = 'Id';
|
|
454
|
+
this.campoPaiId = 'PaiId';
|
|
455
|
+
this.campoDisplay = 'Descricao';
|
|
456
|
+
this.tipo = '';
|
|
457
|
+
//@ViewChild('selectElement', { read: ElementRef, static: true }) selectElement;
|
|
458
|
+
this.selectElement = null;
|
|
459
|
+
this.pesquisaChange = new EventEmitter();
|
|
460
|
+
//parametros para chamada API
|
|
461
|
+
//endpoint para pesquisa por digitação
|
|
462
|
+
this.url = '';
|
|
463
|
+
this.urlItem = '';
|
|
464
|
+
//endpoint para montar a arvore, se estiver vazia será usado o campo 'url'
|
|
465
|
+
this.urlTree = '';
|
|
466
|
+
this.empresa = 0;
|
|
467
|
+
this.loadInit = false;
|
|
468
|
+
this.onChange = (data) => { };
|
|
469
|
+
this.onTouch = () => { };
|
|
470
|
+
this.disabled = false;
|
|
471
|
+
this.console = console;
|
|
472
|
+
this.modelChanged = new Subject();
|
|
473
|
+
this.BASE_API = this.config.apiUrl;
|
|
474
|
+
this.modelChangeSubscription = this.modelChanged
|
|
475
|
+
.pipe(debounceTime(500))
|
|
476
|
+
.subscribe(data => {
|
|
477
|
+
this.carregaItemIdParaLista(data);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
onBlur(event) {
|
|
481
|
+
console.log('blur', event);
|
|
482
|
+
//console.log(event.detail.relatedTarget);
|
|
483
|
+
if (event.detail.relatedTarget == null || event.detail.relatedTarget.id.indexOf(this.selectId + 'IonItem') == -1) {
|
|
484
|
+
//console.log("true", event.detail.relatedTarget.id);
|
|
485
|
+
//pesquisar item na lista
|
|
486
|
+
if (!this.existeNaListaTexto(this.textoPesquisa, true)) {
|
|
487
|
+
this.limparClick();
|
|
488
|
+
}
|
|
489
|
+
this.dropDownPesquisa(0);
|
|
490
|
+
if (this.form) {
|
|
491
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
ngOnInit() {
|
|
496
|
+
//tratar urls
|
|
497
|
+
this.url = this.url.startsWith('http') ? this.url : `${this.BASE_API}/${this.url}`;
|
|
498
|
+
this.urlItem = this.urlItem.startsWith('http') ? this.urlItem : `${this.BASE_API}/${this.urlItem}`;
|
|
499
|
+
this.pesquisaSubject.pipe(switchMap((url) => {
|
|
500
|
+
this.console.log('subject url:', url);
|
|
501
|
+
if (!this.isEmpty(url))
|
|
502
|
+
return this.httpClient.get(url);
|
|
503
|
+
else
|
|
504
|
+
return of([]);
|
|
505
|
+
}))
|
|
506
|
+
.subscribe({
|
|
507
|
+
next: (result) => {
|
|
508
|
+
//this.listaPesquisa = result;
|
|
509
|
+
this.console.log('subject subscribe result:', result);
|
|
510
|
+
this.listaPesquisa = [];
|
|
511
|
+
if (result && result.length > 0) {
|
|
512
|
+
if (this.filterFunction) {
|
|
513
|
+
result = result.filter(this.filterFunction);
|
|
514
|
+
}
|
|
515
|
+
result.forEach((ent, index) => {
|
|
516
|
+
this.listaPesquisa.push({ ...ent, Index: index, Selected: false });
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
this.podePesquisar = true;
|
|
520
|
+
if (this.listaPesquisa.length > 0) {
|
|
521
|
+
this.dropDownPesquisa(this.listaPesquisa.length);
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
error: (error) => {
|
|
525
|
+
this.podePesquisar = true;
|
|
526
|
+
console.log('erro pesquisa', error);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
writePesquisa(value) {
|
|
531
|
+
//console.log('write pesquisa', value);
|
|
532
|
+
this.textoPesquisa = value;
|
|
533
|
+
}
|
|
534
|
+
showPesquisa(e) {
|
|
535
|
+
//console.log('show pesquisa', e.keyCode);
|
|
536
|
+
var self = this;
|
|
537
|
+
const index = e.target.selectionStart >= 1 ? (e.target.selectionStart - 1) : 0;
|
|
538
|
+
//console.log(index, 'valor ', event.target.value, 'char ', event.target.value.charCodeAt(index));
|
|
539
|
+
const keyAt = e.target.value.charCodeAt(index);
|
|
540
|
+
/*
|
|
541
|
+
if ((e.keyCode >= 48 && e.keyCode <= 57) ||
|
|
542
|
+
(keyAt >= 48 && keyAt <= 57) ||
|
|
543
|
+
(e.keyCode >= 65 && e.keyCode <= 90) ||
|
|
544
|
+
(e.keyCode >= 96 && e.keyCode <= 105) ||
|
|
545
|
+
(e.keyCode == 8)) {
|
|
546
|
+
*/
|
|
547
|
+
if (e.keyCode != 40 && e.keyCode != 38) {
|
|
548
|
+
if (!self.podePesquisar) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
let filtro = self.textoPesquisa;
|
|
552
|
+
if (filtro != null && filtro != '' && filtro.length >= 2) {
|
|
553
|
+
self.pesquisarEntidade(filtro);
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
if (e.keyCode == 8 && !filtro) {
|
|
557
|
+
this.limparClick();
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
if (e.keyCode == 40 || e.keyCode == 38) {
|
|
563
|
+
self.dropDownPesquisa(self.listaPesquisa.length);
|
|
564
|
+
if (self.selectElementVisivel == true) {
|
|
565
|
+
//let select = self.selectElement; //document.getElementById(self.TemplateSelect1Id());
|
|
566
|
+
//ion-list
|
|
567
|
+
//selecionado
|
|
568
|
+
//console.log(self.listaPesquisa);
|
|
569
|
+
let inc = e.keyCode == 40 ? 1 : -1;
|
|
570
|
+
let selected = self.listaPesquisa.find(s => s['Selected'] === true);
|
|
571
|
+
let cur = 0;
|
|
572
|
+
if (selected != null) {
|
|
573
|
+
cur = selected['Index'];
|
|
574
|
+
//desmarcar o atual
|
|
575
|
+
selected['Selected'] = false;
|
|
576
|
+
cur = cur + inc;
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
cur = 0;
|
|
580
|
+
}
|
|
581
|
+
if (cur < 0) {
|
|
582
|
+
cur = self.listaPesquisa.length - 1;
|
|
583
|
+
}
|
|
584
|
+
else if (cur >= self.listaPesquisa.length) {
|
|
585
|
+
cur = 0;
|
|
586
|
+
}
|
|
587
|
+
let novoSelected = self.listaPesquisa.find(n => n['Index'] === cur);
|
|
588
|
+
if (novoSelected != null) {
|
|
589
|
+
novoSelected['Selected'] = true;
|
|
590
|
+
self.selectedItem = novoSelected;
|
|
591
|
+
self.textoPesquisa = novoSelected[self.campoDisplay];
|
|
592
|
+
}
|
|
593
|
+
/*
|
|
594
|
+
let select = document.getElementById(this.selectId) as any;
|
|
595
|
+
console.log('select Element', select)
|
|
596
|
+
if (select != null) {
|
|
597
|
+
let inc = e.keyCode == 40 ? 1 : -1;
|
|
598
|
+
let cur = select.selectedIndex;
|
|
599
|
+
if (cur == NaN) cur = -1;
|
|
600
|
+
select.selectedIndex = cur + inc;
|
|
601
|
+
if (select.selectedIndex >= 0 && select.selectedIndex < self.listaPesquisa.length) {
|
|
602
|
+
self.selectedItem = self.listaPesquisa[select.selectedIndex];
|
|
603
|
+
if (self.selectedItem != null) {
|
|
604
|
+
self.textoPesquisa = self.selectedItem[self.campoDisplay];
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
*/
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
else if (e.keyCode == 13) {
|
|
612
|
+
console.log('enter key', e);
|
|
613
|
+
//self.selecionarComboClick(e);
|
|
614
|
+
self.selecionarComboClick(null);
|
|
615
|
+
//return false;
|
|
616
|
+
}
|
|
617
|
+
else if (e.keyCode == 27) {
|
|
618
|
+
//ESC
|
|
619
|
+
self.dropDownPesquisa(0);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
highlight(texto) {
|
|
624
|
+
let index = texto.toLowerCase().indexOf(this.textoPesquisa.toLowerCase());
|
|
625
|
+
//console.log(index);
|
|
626
|
+
if (index >= 0) {
|
|
627
|
+
return texto.substring(0, index) + '<strong>' + texto.substring(index, index + this.textoPesquisa.length) + '</strong>' + texto.substring(index + this.textoPesquisa.length); //texto.replace(this.textoPesquisa, `<strong>${this.textoPesquisa}</strong>`);
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
return texto;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
selecionarComboClick(item) {
|
|
634
|
+
// console.log(item);
|
|
635
|
+
var self = this;
|
|
636
|
+
// console.log('combo click', self);
|
|
637
|
+
/*
|
|
638
|
+
let select = document.getElementById(this.selectId) as any;
|
|
639
|
+
if (select.selectedIndex >= 0) {
|
|
640
|
+
self.selectedItem = self.listaPesquisa[select.selectedIndex];
|
|
641
|
+
}
|
|
642
|
+
console.log('selected', this.selectedItem);
|
|
643
|
+
//self.selectedItem = this.listaPesquisa.find(i => i[this.campoId] == e);
|
|
644
|
+
if (self.selectedItem != null) {
|
|
645
|
+
self.textoPesquisa = self.selectedItem[self.campoDisplay];
|
|
646
|
+
self.writeValue(self.selectedItem[self.campoId]);
|
|
647
|
+
if (e != null) {
|
|
648
|
+
self.selectElementVisivel = false;
|
|
649
|
+
if (self.action != null) {
|
|
650
|
+
self.action(self.selectedItem(), e);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
self.selectElementVisivel = false;
|
|
656
|
+
}
|
|
657
|
+
*/
|
|
658
|
+
// pesquisar selecionado
|
|
659
|
+
// console.log(this.listaPesquisa);
|
|
660
|
+
let selected = this.listaPesquisa.find(s => s['Selected'] === true);
|
|
661
|
+
// if (!selected) {
|
|
662
|
+
// console.log(this.campoId, item);
|
|
663
|
+
// selected = this.listaPesquisa.filter( s => s[this.campoId] == item[this.campoId]);
|
|
664
|
+
// }
|
|
665
|
+
//se o item form passado como parametro (click no ion-item)
|
|
666
|
+
if (item != null) {
|
|
667
|
+
if (selected != null) {
|
|
668
|
+
selected['Selected'] = false;
|
|
669
|
+
}
|
|
670
|
+
item['Selected'] = true;
|
|
671
|
+
selected = item;
|
|
672
|
+
}
|
|
673
|
+
if (selected != null) {
|
|
674
|
+
self.selectedItem = selected;
|
|
675
|
+
self.textoPesquisa = selected[self.campoDisplay];
|
|
676
|
+
self.writeValue(selected[self.campoId]);
|
|
677
|
+
self.selectElementVisivel = false;
|
|
678
|
+
//console.log('action', self.change);
|
|
679
|
+
if (self.pesquisaChange != null) {
|
|
680
|
+
self.pesquisaChange.emit(self.selectedItem);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
self.selectElementVisivel = false;
|
|
685
|
+
}
|
|
686
|
+
// this.listaPesquisa.forEach( pesquisa => {
|
|
687
|
+
// console.log(pesquisa, self.data);
|
|
688
|
+
// } );
|
|
689
|
+
// console.log(this.textoPesquisa);
|
|
690
|
+
}
|
|
691
|
+
selecionarComboChange(e) {
|
|
692
|
+
var self = this;
|
|
693
|
+
console.log('combo change', e);
|
|
694
|
+
self.selectedItem = this.listaPesquisa.find(i => i[this.campoId] == e);
|
|
695
|
+
if (self.selectedItem != null) {
|
|
696
|
+
self.writeValue(e);
|
|
697
|
+
self.textoPesquisa = self.selectedItem[self.campoDisplay];
|
|
698
|
+
if (e != null) {
|
|
699
|
+
self.selectElementVisivel = false;
|
|
700
|
+
if (self.pesquisaChange != null) {
|
|
701
|
+
self.pesquisaChange.emit(self.selectedItem);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
else {
|
|
706
|
+
self.selectElementVisivel = false;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
dropDownPesquisa(length) {
|
|
710
|
+
var self = this;
|
|
711
|
+
if (self.listaPesquisa != null && self.listaPesquisa.length > 0) {
|
|
712
|
+
if (length == -1) {
|
|
713
|
+
length = self.listaPesquisa.length;
|
|
714
|
+
}
|
|
715
|
+
self.selectElementVisivel = length == 0 ? false : true;
|
|
716
|
+
//console.log(this.selectElement);
|
|
717
|
+
//this.selectElement.open();
|
|
718
|
+
/*
|
|
719
|
+
//let element = this.selectElement;
|
|
720
|
+
let element = document.getElementById(this.selectId);
|
|
721
|
+
console.log('dropDown', element);
|
|
722
|
+
(element as any).size = length + 1;
|
|
723
|
+
if (length == 0) {
|
|
724
|
+
self.selectElementVisivel = false;
|
|
725
|
+
} else {
|
|
726
|
+
self.selectElementVisivel = true;
|
|
727
|
+
}
|
|
728
|
+
*/
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
pesquisarEntidade(filtro) {
|
|
732
|
+
let url = this.url.replace('<<FILTRO>>', filtro).replace('<<EMPRESA>>', this.empresa.toString());
|
|
733
|
+
console.log('pesquisarEntidade url', url);
|
|
734
|
+
this.podePesquisar = false;
|
|
735
|
+
this.pesquisaSubject.next(url);
|
|
736
|
+
}
|
|
737
|
+
pesquisarEntidadeOld(filtro) {
|
|
738
|
+
let url = this.url.replace('<<FILTRO>>', filtro).replace('<<EMPRESA>>', this.empresa.toString());
|
|
739
|
+
console.log('pesquisarEntidade url', url);
|
|
740
|
+
this.podePesquisar = false;
|
|
741
|
+
this.httpClient.get(url)
|
|
742
|
+
.subscribe({ next: (result) => {
|
|
743
|
+
//this.listaPesquisa = result;
|
|
744
|
+
if (this.filterFunction) {
|
|
745
|
+
result = result.filter(this.filterFunction);
|
|
746
|
+
}
|
|
747
|
+
this.listaPesquisa = [];
|
|
748
|
+
result.forEach((ent, index) => {
|
|
749
|
+
this.listaPesquisa.push({ ...ent, Index: index, Selected: false });
|
|
750
|
+
});
|
|
751
|
+
this.podePesquisar = true;
|
|
752
|
+
if (this.listaPesquisa.length > 0) {
|
|
753
|
+
this.dropDownPesquisa(this.listaPesquisa.length);
|
|
754
|
+
}
|
|
755
|
+
}, error: error => {
|
|
756
|
+
console.log('erro pesquisa', error);
|
|
757
|
+
this.podePesquisar = true;
|
|
758
|
+
} });
|
|
759
|
+
}
|
|
760
|
+
existeNaLista(id, setRegistro = false) {
|
|
761
|
+
if (this.listaPesquisa && this.listaPesquisa.length > 0) {
|
|
762
|
+
let existe = this.listaPesquisa.find(l => l[this.campoId] === id);
|
|
763
|
+
if (existe) {
|
|
764
|
+
if (setRegistro) {
|
|
765
|
+
this.selectedItem = existe;
|
|
766
|
+
this.selecionarComboClick(this.selectedItem);
|
|
767
|
+
}
|
|
768
|
+
return true;
|
|
769
|
+
}
|
|
770
|
+
else {
|
|
771
|
+
return false;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
return false;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
existeNaListaTexto(texto, setRegistro = false) {
|
|
779
|
+
console.log("existe texto:", texto, this.campoDisplay, this.listaPesquisa);
|
|
780
|
+
if (this.listaPesquisa && this.listaPesquisa.length > 0) {
|
|
781
|
+
let existe = this.listaPesquisa.find(l => l[this.campoDisplay].toUpperCase() === texto.toUpperCase());
|
|
782
|
+
if (existe) {
|
|
783
|
+
if (setRegistro) {
|
|
784
|
+
this.selectedItem = existe;
|
|
785
|
+
this.selecionarComboClick(this.selectedItem);
|
|
786
|
+
}
|
|
787
|
+
return true;
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
validarItemSelecionado(setarRegistro = false) {
|
|
798
|
+
console.log('validar selecionado');
|
|
799
|
+
//passar pela função de filtro
|
|
800
|
+
let valido = false;
|
|
801
|
+
if (this.selectedItem) {
|
|
802
|
+
if (this.filterFunction) {
|
|
803
|
+
let existe = [{ ...this.selectedItem }].filter(this.filterFunction);
|
|
804
|
+
if (existe != null && existe.length > 0) {
|
|
805
|
+
valido = true;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
valido = true;
|
|
810
|
+
}
|
|
811
|
+
if (valido && setarRegistro) {
|
|
812
|
+
this.selecionarComboClick(this.selectedItem);
|
|
813
|
+
}
|
|
814
|
+
return valido;
|
|
815
|
+
}
|
|
816
|
+
else {
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
carregaItemIdParaLista(id) {
|
|
821
|
+
let url = this.urlItem.replace('<<ID>>', id.toString());
|
|
822
|
+
console.log(this.urlItem);
|
|
823
|
+
console.log('pesquisar ID url', url);
|
|
824
|
+
this.podePesquisar = false;
|
|
825
|
+
this.httpClient.get(url)
|
|
826
|
+
.subscribe({ next: (result) => {
|
|
827
|
+
this.listaPesquisa = [];
|
|
828
|
+
this.listaPesquisa.push({ ...result, Index: 0, Selected: true });
|
|
829
|
+
this.podePesquisar = true;
|
|
830
|
+
if (this.listaPesquisa.length > 0) {
|
|
831
|
+
this.selectedItem = this.listaPesquisa[0];
|
|
832
|
+
this.selecionarComboClick(this.selectedItem);
|
|
833
|
+
}
|
|
834
|
+
}, error: error => {
|
|
835
|
+
console.log('erro pesquisa', error);
|
|
836
|
+
this.podePesquisar = true;
|
|
837
|
+
} });
|
|
838
|
+
}
|
|
839
|
+
limparClick() {
|
|
840
|
+
this.writeValue(null);
|
|
841
|
+
this.writePesquisa(null);
|
|
842
|
+
this.listaPesquisa = [];
|
|
843
|
+
this.dropDownPesquisa(0);
|
|
844
|
+
//this.podePesquisar = true;
|
|
845
|
+
this.pesquisaSubject.next('');
|
|
846
|
+
if (this.limpar) {
|
|
847
|
+
this.limpar();
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
verificarPesquisa() {
|
|
851
|
+
//TODO: verificar se o texto corresponde com um item da lista
|
|
852
|
+
this.selecionarComboClick(null);
|
|
853
|
+
}
|
|
854
|
+
async pesquisarClick() {
|
|
855
|
+
/*
|
|
856
|
+
if (this.pesquisaAction != null) {
|
|
857
|
+
this.pesquisaAction();
|
|
858
|
+
}
|
|
859
|
+
*/
|
|
860
|
+
//pesquisaCategoria
|
|
861
|
+
console.log(this.filterFunction, this.url, this.urlTree);
|
|
862
|
+
const modal = await this.modalCtrl.create({
|
|
863
|
+
component: ModelTreeviewComponent,
|
|
864
|
+
componentProps: {
|
|
865
|
+
//campoId: this.campoId,
|
|
866
|
+
//campoPai: this.campoPaiId,
|
|
867
|
+
//campoLabel: this.campoDisplay,
|
|
868
|
+
filterFunction: this.filterFunction,
|
|
869
|
+
empresaSelecionadaId: this.empresa,
|
|
870
|
+
tipo: this.tipo,
|
|
871
|
+
//especifico
|
|
872
|
+
//planoContas: this.planoContas,
|
|
873
|
+
url: this.isEmpty(this.urlTree) ? this.url : this.urlTree
|
|
874
|
+
},
|
|
875
|
+
cssClass: 'my-custom-modal-pesquisa'
|
|
876
|
+
});
|
|
877
|
+
modal.onDidDismiss().then(data => {
|
|
878
|
+
let result = data['data'];
|
|
879
|
+
console.log(result);
|
|
880
|
+
if (result != null && result.Id > 0) {
|
|
881
|
+
this.carregaItemIdParaLista(result.Id);
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
modal.present();
|
|
885
|
+
}
|
|
886
|
+
isEmpty(valor) {
|
|
887
|
+
return valor == null || valor == undefined || valor == '';
|
|
888
|
+
}
|
|
889
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputPesquisaComponent, deps: [{ token: LibConfigService }, { token: i1$1.HttpClient }, { token: i2.ModalController }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
890
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: InputPesquisaComponent, selector: "kb-input-pesquisa", inputs: { textoPesquisa: "textoPesquisa", max: "max", filterFunction: "filterFunction", selectId: "selectId", campoId: "campoId", campoPaiId: "campoPaiId", campoDisplay: "campoDisplay", tipo: "tipo", pesquisaChange: "pesquisaChange", pesquisaAction: "pesquisaAction", limpar: "limpar", url: "url", urlItem: "urlItem", urlTree: "urlTree", empresa: "empresa", loadInit: "loadInit" }, providers: [{
|
|
891
|
+
provide: NG_VALUE_ACCESSOR,
|
|
892
|
+
useExisting: InputPesquisaComponent,
|
|
893
|
+
multi: true
|
|
894
|
+
}], viewQueries: [{ propertyName: "selectElement", first: true, predicate: ["selectElement"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div style=\"padding-inline-end: 0px;\">\r\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent; margin-top: 2px;\" [class]=\"itemClass\">\r\n <ion-label position=\"{{ labelPosition }}\" color=\"{{ labelColor }}\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ campo }}\" -->\r\n <ion-spinner *ngIf=\"!podePesquisar\"\r\n style=\"--min-height: 0px !important; margin-inline-end: 5px !important; margin-top: 16px;\" \r\n slot=\"start\" name=\"lines\"></ion-spinner>\r\n <!-- (ionBlur)=\"verificarPesquisa()\" -->\r\n <!-- conflito com click da lista -->\r\n <ion-input #inputPesquisa\r\n type=\"{{type}}\" \r\n [placeholder]=\"placeholder\" \r\n maxlength=\"{{ max }}\" \r\n (ionBlur)=\"onBlur($event)\"\r\n [value]=\"textoPesquisa\" (input)=\"writePesquisa(inputPesquisa.value)\" \r\n (keyup)=\"showPesquisa($event)\"\r\n autocomplete=\"off\" [style.--background]=\"inputBackgroungColor\"\r\n (click)=\"dropDownPesquisa(-1)\"\r\n [disabled]=\"readonly\" debounce=\"500\"></ion-input>\r\n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\r\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\r\n (click)=\"limparClick()\">\r\n <ion-icon name=\"close-outline\"></ion-icon>\r\n </ion-button>\r\n \r\n <!--\r\n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\r\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\r\n (click)=\"pesquisarClick()\">\r\n <ion-icon color=\"primary\" name=\"search\"></ion-icon>\r\n </ion-button>\r\n -->\r\n \r\n </ion-item>\r\n \r\n <ion-list tabindex=\"-1\" [hidden]=\"!selectElementVisivel || !listaPesquisa || listaPesquisa.length == 0\" class=\"pesquisa-list\" style=\"max-height: 250px; overflow-y: auto;\">\r\n \r\n <ion-item tabindex=\"-1\" button *ngFor=\"let item of listaPesquisa\" \r\n (click)=\"selecionarComboClick(item)\" [id]=\"selectId + 'IonItem' + item['Index']\"\r\n class=\"pesquisa-item\">\r\n <!-- {{ item | json}} -->\r\n <span [class]=\"{'selected-item': item['Selected'] === true}\" [innerHTML]=\"highlight(item[campoDisplay])\"></span>\r\n </ion-item>\r\n \r\n </ion-list>\r\n \r\n <!--\r\n <ion-select interface=\"popover\" #selectElement tabindex=\"-1\" [hidden]=\"!selectElementVisivel\"\r\n (ionChange)=\"selecionarComboChange($event.target.value)\">\r\n <ion-select-option *ngFor=\"let item of listaPesquisa\" [value]=\"item[campoId]\" (click)=\"selecionarComboClick(item[campoId])\">\r\n {{ item[campoDisplay] }}\r\n </ion-select-option>\r\n </ion-select>\r\n -->\r\n \r\n <!--\r\n <select [id]=\"selectId\" #selectElement tabindex=\"-1\" [hidden]=\"!selectElementVisivel\"\r\n (change)=\"selecionarComboChange($event.target.value)\" class=\"pesquisa-select\">\r\n <option *ngFor=\"let item of listaPesquisa\" [value]=\"item[campoId]\" (click)=\"selecionarComboClick(item[campoId])\">\r\n {{ item[campoDisplay] }}\r\n </option>\r\n \r\n </select>\r\n -->\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n \r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n \r\n </div>\r\n </div>", styles: [".pesquisa-select{display:block;position:absolute;top:58px;left:20px;width:100%;z-index:800;font-size:16px;font-family:Roboto,Helvetica Neue,sans-serif;border-bottom-left-radius:5px;border-bottom-right-radius:5px}.pesquisa-select option{overflow-y:hidden}.pesquisa-select option:hover,.pesquisa-select option:checked{background-color:#add8e6}.pesquisa-list{display:block;position:absolute;margin-left:20px;margin-top:-4px;width:calc(100% - 50px);z-index:800;border:1px lightgrey solid;border-bottom-left-radius:5px;border-bottom-right-radius:5px;padding:0}.pesquisa-item{--inner-padding-top: 0px;--inner-padding-bottom: 0px;--padding-top: 0px;--padding-bottom: 0px;--min-height: 30px !important;font-size:12px}.pesquisa-item button{padding:0}.selected-item{background-color:#add8e6}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { kind: "component", type: i2.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: i2.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "legacy", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: i2.IonList, selector: "ion-list", inputs: ["inset", "lines", "mode"] }, { kind: "component", type: i2.IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }, { kind: "directive", type: i2.TextValueAccessor, selector: "ion-input:not([type=number]),ion-textarea,ion-searchbar" }] }); }
|
|
895
|
+
}
|
|
896
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputPesquisaComponent, decorators: [{
|
|
897
|
+
type: Component,
|
|
898
|
+
args: [{ selector: 'kb-input-pesquisa', providers: [{
|
|
899
|
+
provide: NG_VALUE_ACCESSOR,
|
|
900
|
+
useExisting: InputPesquisaComponent,
|
|
901
|
+
multi: true
|
|
902
|
+
}], template: "<div style=\"padding-inline-end: 0px;\">\r\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent; margin-top: 2px;\" [class]=\"itemClass\">\r\n <ion-label position=\"{{ labelPosition }}\" color=\"{{ labelColor }}\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ campo }}\" -->\r\n <ion-spinner *ngIf=\"!podePesquisar\"\r\n style=\"--min-height: 0px !important; margin-inline-end: 5px !important; margin-top: 16px;\" \r\n slot=\"start\" name=\"lines\"></ion-spinner>\r\n <!-- (ionBlur)=\"verificarPesquisa()\" -->\r\n <!-- conflito com click da lista -->\r\n <ion-input #inputPesquisa\r\n type=\"{{type}}\" \r\n [placeholder]=\"placeholder\" \r\n maxlength=\"{{ max }}\" \r\n (ionBlur)=\"onBlur($event)\"\r\n [value]=\"textoPesquisa\" (input)=\"writePesquisa(inputPesquisa.value)\" \r\n (keyup)=\"showPesquisa($event)\"\r\n autocomplete=\"off\" [style.--background]=\"inputBackgroungColor\"\r\n (click)=\"dropDownPesquisa(-1)\"\r\n [disabled]=\"readonly\" debounce=\"500\"></ion-input>\r\n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\r\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\r\n (click)=\"limparClick()\">\r\n <ion-icon name=\"close-outline\"></ion-icon>\r\n </ion-button>\r\n \r\n <!--\r\n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\r\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\r\n (click)=\"pesquisarClick()\">\r\n <ion-icon color=\"primary\" name=\"search\"></ion-icon>\r\n </ion-button>\r\n -->\r\n \r\n </ion-item>\r\n \r\n <ion-list tabindex=\"-1\" [hidden]=\"!selectElementVisivel || !listaPesquisa || listaPesquisa.length == 0\" class=\"pesquisa-list\" style=\"max-height: 250px; overflow-y: auto;\">\r\n \r\n <ion-item tabindex=\"-1\" button *ngFor=\"let item of listaPesquisa\" \r\n (click)=\"selecionarComboClick(item)\" [id]=\"selectId + 'IonItem' + item['Index']\"\r\n class=\"pesquisa-item\">\r\n <!-- {{ item | json}} -->\r\n <span [class]=\"{'selected-item': item['Selected'] === true}\" [innerHTML]=\"highlight(item[campoDisplay])\"></span>\r\n </ion-item>\r\n \r\n </ion-list>\r\n \r\n <!--\r\n <ion-select interface=\"popover\" #selectElement tabindex=\"-1\" [hidden]=\"!selectElementVisivel\"\r\n (ionChange)=\"selecionarComboChange($event.target.value)\">\r\n <ion-select-option *ngFor=\"let item of listaPesquisa\" [value]=\"item[campoId]\" (click)=\"selecionarComboClick(item[campoId])\">\r\n {{ item[campoDisplay] }}\r\n </ion-select-option>\r\n </ion-select>\r\n -->\r\n \r\n <!--\r\n <select [id]=\"selectId\" #selectElement tabindex=\"-1\" [hidden]=\"!selectElementVisivel\"\r\n (change)=\"selecionarComboChange($event.target.value)\" class=\"pesquisa-select\">\r\n <option *ngFor=\"let item of listaPesquisa\" [value]=\"item[campoId]\" (click)=\"selecionarComboClick(item[campoId])\">\r\n {{ item[campoDisplay] }}\r\n </option>\r\n \r\n </select>\r\n -->\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n \r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n \r\n </div>\r\n </div>", styles: [".pesquisa-select{display:block;position:absolute;top:58px;left:20px;width:100%;z-index:800;font-size:16px;font-family:Roboto,Helvetica Neue,sans-serif;border-bottom-left-radius:5px;border-bottom-right-radius:5px}.pesquisa-select option{overflow-y:hidden}.pesquisa-select option:hover,.pesquisa-select option:checked{background-color:#add8e6}.pesquisa-list{display:block;position:absolute;margin-left:20px;margin-top:-4px;width:calc(100% - 50px);z-index:800;border:1px lightgrey solid;border-bottom-left-radius:5px;border-bottom-right-radius:5px;padding:0}.pesquisa-item{--inner-padding-top: 0px;--inner-padding-bottom: 0px;--padding-top: 0px;--padding-bottom: 0px;--min-height: 30px !important;font-size:12px}.pesquisa-item button{padding:0}.selected-item{background-color:#add8e6}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"] }]
|
|
903
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
904
|
+
type: Inject,
|
|
905
|
+
args: [LibConfigService]
|
|
906
|
+
}] }, { type: i1$1.HttpClient }, { type: i2.ModalController }], propDecorators: { textoPesquisa: [{
|
|
907
|
+
type: Input
|
|
908
|
+
}], max: [{
|
|
909
|
+
type: Input
|
|
910
|
+
}], filterFunction: [{
|
|
911
|
+
type: Input
|
|
912
|
+
}], selectId: [{
|
|
913
|
+
type: Input
|
|
914
|
+
}], campoId: [{
|
|
915
|
+
type: Input
|
|
916
|
+
}], campoPaiId: [{
|
|
917
|
+
type: Input
|
|
918
|
+
}], campoDisplay: [{
|
|
919
|
+
type: Input
|
|
920
|
+
}], tipo: [{
|
|
921
|
+
type: Input
|
|
922
|
+
}], selectElement: [{
|
|
923
|
+
type: ViewChild,
|
|
924
|
+
args: ['selectElement', { static: false }]
|
|
925
|
+
}], pesquisaChange: [{
|
|
926
|
+
type: Input
|
|
927
|
+
}], pesquisaAction: [{
|
|
928
|
+
type: Input
|
|
929
|
+
}], limpar: [{
|
|
930
|
+
type: Input
|
|
931
|
+
}], url: [{
|
|
932
|
+
type: Input
|
|
933
|
+
}], urlItem: [{
|
|
934
|
+
type: Input
|
|
935
|
+
}], urlTree: [{
|
|
936
|
+
type: Input
|
|
937
|
+
}], empresa: [{
|
|
938
|
+
type: Input
|
|
939
|
+
}], loadInit: [{
|
|
940
|
+
type: Input
|
|
941
|
+
}] } });
|
|
942
|
+
|
|
943
|
+
class InputValorComponent extends BaseInputComponent {
|
|
944
|
+
writeValue(value) {
|
|
945
|
+
//console.log('write value', value);
|
|
946
|
+
this.onChange(value);
|
|
947
|
+
this.data = value;
|
|
948
|
+
}
|
|
949
|
+
registerOnChange(fn) {
|
|
950
|
+
this.onChange = fn;
|
|
951
|
+
}
|
|
952
|
+
registerOnTouched(fn) {
|
|
953
|
+
this.onTouch = fn;
|
|
954
|
+
}
|
|
955
|
+
setDisabledState(isDisabled) {
|
|
956
|
+
this.disabled = this.disabled;
|
|
957
|
+
}
|
|
958
|
+
constructor() {
|
|
959
|
+
super();
|
|
960
|
+
this.maxValor = null;
|
|
961
|
+
this.onChange = (data) => { };
|
|
962
|
+
this.onTouch = () => { };
|
|
963
|
+
this.disabled = false;
|
|
964
|
+
this.console = console;
|
|
965
|
+
}
|
|
966
|
+
ngOnInit() { }
|
|
967
|
+
onBlur() {
|
|
968
|
+
if (this.form) {
|
|
969
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
970
|
+
}
|
|
971
|
+
//verificar o valor
|
|
972
|
+
if (this.maxValor) {
|
|
973
|
+
if (this.form) {
|
|
974
|
+
//console.log(this.form.get(this.formControlName).value);
|
|
975
|
+
let valor = this.strToFloatZero(this.form.get(this.formControlName).value);
|
|
976
|
+
if (valor > this.maxValor) {
|
|
977
|
+
this.form.patchValue({
|
|
978
|
+
[this.formControlName]: this.converterValorDecimalMil((this.maxValor * 100).toString())
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
else {
|
|
983
|
+
let valor = this.strToFloatZero(this.data);
|
|
984
|
+
if (valor > this.maxValor) {
|
|
985
|
+
this.data = this.converterValorDecimalMil((this.maxValor * 100).toString());
|
|
986
|
+
this.writeValue(this.data);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
if (this.blur) {
|
|
991
|
+
this.blur.emit(this.blurArgs);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
digitarValor(event) {
|
|
995
|
+
//this.item.vendaunitario = this.utils.converterValorDecimal(this.item.vendaunitario);
|
|
996
|
+
setTimeout(() => {
|
|
997
|
+
if (this.form) {
|
|
998
|
+
this.form.patchValue({
|
|
999
|
+
[this.formControlName]: this.converterValorDecimalMil(this.form.get(this.formControlName)?.value)
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
this.data = this.converterValorDecimalMil(this.data);
|
|
1004
|
+
this.writeValue(this.data);
|
|
1005
|
+
}
|
|
1006
|
+
}, 100);
|
|
1007
|
+
return true;
|
|
1008
|
+
}
|
|
1009
|
+
isEmpty(str) {
|
|
1010
|
+
return str == null || str == undefined || str == '';
|
|
1011
|
+
}
|
|
1012
|
+
converterValorDecimalMil(campo, casas = 2) {
|
|
1013
|
+
if (!this.isEmpty(campo)) {
|
|
1014
|
+
//console.log('converterValorDecimal');
|
|
1015
|
+
//console.log('campo:', campo, ' replaced: ', campo.replace(',', '').replace('.', ''));
|
|
1016
|
+
if (campo == '-') {
|
|
1017
|
+
return campo;
|
|
1018
|
+
}
|
|
1019
|
+
let valor = parseFloat(campo.replace(',', '').replace('.', '').replace('.', '').replace('.', ''));
|
|
1020
|
+
if (isNaN(valor)) {
|
|
1021
|
+
return '';
|
|
1022
|
+
}
|
|
1023
|
+
let valordiv = parseInt("1" + this.stringOfChar("0", casas));
|
|
1024
|
+
//valor /= 100;
|
|
1025
|
+
console.log(valor, '/', valordiv);
|
|
1026
|
+
valor /= valordiv;
|
|
1027
|
+
console.log('=', valor);
|
|
1028
|
+
return this.decimalToStringMil(valor);
|
|
1029
|
+
/*
|
|
1030
|
+
var str = valor.toString().replace('.', ',');
|
|
1031
|
+
var aStr = str.split(',');
|
|
1032
|
+
if (aStr.length == 1) {
|
|
1033
|
+
//str += ',00';
|
|
1034
|
+
str += ',' + this.stringOfChar('0', casas);
|
|
1035
|
+
}
|
|
1036
|
+
else {
|
|
1037
|
+
//str += this.stringOfChar('0', 2 - aStr[1].length);
|
|
1038
|
+
str += this.stringOfChar('0', casas - aStr[1].length);
|
|
1039
|
+
}
|
|
1040
|
+
return str;
|
|
1041
|
+
*/
|
|
1042
|
+
}
|
|
1043
|
+
else
|
|
1044
|
+
return campo;
|
|
1045
|
+
}
|
|
1046
|
+
decimalToStringMil(number) {
|
|
1047
|
+
if (number != null) {
|
|
1048
|
+
if (number == 0 || number == '0') {
|
|
1049
|
+
return '0,00';
|
|
1050
|
+
}
|
|
1051
|
+
//console.log(number);
|
|
1052
|
+
let numero = number.toFixed(2).split('.');
|
|
1053
|
+
numero[0] = numero[0].split(/(?=(?:...)*$)/).join('.');
|
|
1054
|
+
return numero.join(',').replace('-.', '-');
|
|
1055
|
+
}
|
|
1056
|
+
else
|
|
1057
|
+
return '';
|
|
1058
|
+
}
|
|
1059
|
+
stringOfChar(str, tam) {
|
|
1060
|
+
var res = '';
|
|
1061
|
+
for (var i = 0; i < tam; i++) {
|
|
1062
|
+
res += str;
|
|
1063
|
+
}
|
|
1064
|
+
return res;
|
|
1065
|
+
}
|
|
1066
|
+
strToFloatZero(str) {
|
|
1067
|
+
if (Number.isFinite(str))
|
|
1068
|
+
return str;
|
|
1069
|
+
if (this.isEmpty(str))
|
|
1070
|
+
return 0;
|
|
1071
|
+
else
|
|
1072
|
+
return parseFloat(str.replace('.', '').replace(',', '.'));
|
|
1073
|
+
}
|
|
1074
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputValorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1075
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: InputValorComponent, selector: "kb-input-valor", inputs: { maxValor: "maxValor" }, providers: [{
|
|
1076
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1077
|
+
useExisting: InputValorComponent,
|
|
1078
|
+
multi: true
|
|
1079
|
+
}], viewQueries: [{ propertyName: "inputValorEdit", first: true, predicate: ["inputValor"], descendants: true, read: ElementRef, static: true }], usesInheritance: true, ngImport: i0, template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background-focused: transparent;\" [class]=\"itemClass\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label position=\"{{ labelPosition }}\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ formControlName }}\" -->\r\n <ion-input #inputValor\r\n type=\"text\" \r\n [placeholder]=\"placeholder\" \r\n maxlength=\"{{ max }}\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n (input)=\"writeValue(inputValor.value)\" \r\n (keypress)=\"digitarValor($event)\"\r\n [clearInput]=\"botaoLimpar\"\r\n [disabled]=\"readonly\"></ion-input>\r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n \r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n \r\n </div>\r\n </div>", styles: [".item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end}.align-to-right ion-label{position:relative;left:25%;text-align:end}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "legacy", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "directive", type: i2.TextValueAccessor, selector: "ion-input:not([type=number]),ion-textarea,ion-searchbar" }] }); }
|
|
1080
|
+
}
|
|
1081
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputValorComponent, decorators: [{
|
|
1082
|
+
type: Component,
|
|
1083
|
+
args: [{ selector: 'kb-input-valor', providers: [{
|
|
1084
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1085
|
+
useExisting: InputValorComponent,
|
|
1086
|
+
multi: true
|
|
1087
|
+
}], template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background-focused: transparent;\" [class]=\"itemClass\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label position=\"{{ labelPosition }}\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ formControlName }}\" -->\r\n <ion-input #inputValor\r\n type=\"text\" \r\n [placeholder]=\"placeholder\" \r\n maxlength=\"{{ max }}\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n (input)=\"writeValue(inputValor.value)\" \r\n (keypress)=\"digitarValor($event)\"\r\n [clearInput]=\"botaoLimpar\"\r\n [disabled]=\"readonly\"></ion-input>\r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n \r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n \r\n </div>\r\n </div>", styles: [".item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end}.align-to-right ion-label{position:relative;left:25%;text-align:end}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"] }]
|
|
1088
|
+
}], ctorParameters: () => [], propDecorators: { maxValor: [{
|
|
1089
|
+
type: Input
|
|
1090
|
+
}], inputValorEdit: [{
|
|
1091
|
+
type: ViewChild,
|
|
1092
|
+
args: ['inputValor', { read: ElementRef, static: true }]
|
|
1093
|
+
}] } });
|
|
1094
|
+
|
|
1095
|
+
class InputAreaComponent extends BaseInputComponent {
|
|
1096
|
+
writeValue(value) {
|
|
1097
|
+
//console.log('write value', value);
|
|
1098
|
+
this.onChange(value);
|
|
1099
|
+
this.data = value;
|
|
1100
|
+
}
|
|
1101
|
+
registerOnChange(fn) {
|
|
1102
|
+
this.onChange = fn;
|
|
1103
|
+
}
|
|
1104
|
+
registerOnTouched(fn) {
|
|
1105
|
+
this.onTouch = fn;
|
|
1106
|
+
}
|
|
1107
|
+
setDisabledState(isDisabled) {
|
|
1108
|
+
this.disabled = this.disabled;
|
|
1109
|
+
}
|
|
1110
|
+
constructor() {
|
|
1111
|
+
super();
|
|
1112
|
+
this.linhas = 5;
|
|
1113
|
+
this.onChange = (data) => { };
|
|
1114
|
+
this.onTouch = () => { };
|
|
1115
|
+
this.disabled = false;
|
|
1116
|
+
this.console = console;
|
|
1117
|
+
}
|
|
1118
|
+
ngOnInit() { }
|
|
1119
|
+
onBlur() {
|
|
1120
|
+
if (this.form) {
|
|
1121
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputAreaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1125
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: InputAreaComponent, selector: "kb-input-area", inputs: { linhas: "linhas" }, providers: [{
|
|
1126
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1127
|
+
useExisting: InputAreaComponent,
|
|
1128
|
+
multi: true
|
|
1129
|
+
}], usesInheritance: true, ngImport: i0, template: "<div>\r\n <ion-item lines=\"none\" style=\"--background-focused: transparent;\" [class]=\"itemClass\">\r\n <ion-label position=\"{{ labelPosition }}\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ formControlName }}\" -->\r\n <ion-textarea #inputArea \r\n [placeholder]=\"placeholder\" \r\n maxlength=\"{{ max }}\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n [rows]=\"linhas\" \r\n (input)=\"writeValue(inputArea.value)\"\r\n [disabled]=\"readonly\"></ion-textarea>\r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n \r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n \r\n </div>\r\n </div>", styles: ["ion-label{margin-bottom:4px!important}ion-textarea{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: i2.IonTextarea, selector: "ion-textarea", inputs: ["autoGrow", "autocapitalize", "autofocus", "clearOnEdit", "color", "cols", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "legacy", "maxlength", "minlength", "mode", "name", "placeholder", "readonly", "required", "rows", "shape", "spellcheck", "value", "wrap"] }, { kind: "directive", type: i2.TextValueAccessor, selector: "ion-input:not([type=number]),ion-textarea,ion-searchbar" }] }); }
|
|
1130
|
+
}
|
|
1131
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputAreaComponent, decorators: [{
|
|
1132
|
+
type: Component,
|
|
1133
|
+
args: [{ selector: 'kb-input-area', providers: [{
|
|
1134
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1135
|
+
useExisting: InputAreaComponent,
|
|
1136
|
+
multi: true
|
|
1137
|
+
}], template: "<div>\r\n <ion-item lines=\"none\" style=\"--background-focused: transparent;\" [class]=\"itemClass\">\r\n <ion-label position=\"{{ labelPosition }}\">{{ label }}</ion-label>\r\n <!-- formControlName=\"{{ formControlName }}\" -->\r\n <ion-textarea #inputArea \r\n [placeholder]=\"placeholder\" \r\n maxlength=\"{{ max }}\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n [rows]=\"linhas\" \r\n (input)=\"writeValue(inputArea.value)\"\r\n [disabled]=\"readonly\"></ion-textarea>\r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n \r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n \r\n </div>\r\n </div>", styles: ["ion-label{margin-bottom:4px!important}ion-textarea{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px}\n", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"] }]
|
|
1138
|
+
}], ctorParameters: () => [], propDecorators: { linhas: [{
|
|
1139
|
+
type: Input
|
|
1140
|
+
}] } });
|
|
1141
|
+
|
|
1142
|
+
class InputCepComponent extends BaseInputComponent {
|
|
1143
|
+
constructor() {
|
|
1144
|
+
super();
|
|
1145
|
+
this.formato = '00000-000';
|
|
1146
|
+
this.keyEnter = null;
|
|
1147
|
+
this.getResultados = null;
|
|
1148
|
+
//control value acessor
|
|
1149
|
+
this.data = null;
|
|
1150
|
+
this.onChange = (data) => { };
|
|
1151
|
+
this.onTouch = () => { };
|
|
1152
|
+
this.disabled = false;
|
|
1153
|
+
}
|
|
1154
|
+
writeValue(value) {
|
|
1155
|
+
//console.log('write value', value);
|
|
1156
|
+
this.onChange(value);
|
|
1157
|
+
this.data = value;
|
|
1158
|
+
}
|
|
1159
|
+
registerOnChange(fn) {
|
|
1160
|
+
this.onChange = fn;
|
|
1161
|
+
}
|
|
1162
|
+
registerOnTouched(fn) {
|
|
1163
|
+
this.onTouch = fn;
|
|
1164
|
+
}
|
|
1165
|
+
setDisabledState(isDisabled) {
|
|
1166
|
+
this.disabled = this.disabled;
|
|
1167
|
+
}
|
|
1168
|
+
ngOnInit() {
|
|
1169
|
+
}
|
|
1170
|
+
digitarFormatado(event) {
|
|
1171
|
+
console.log(event);
|
|
1172
|
+
if ((event.keyCode >= 48 && event.keyCode <= 57)
|
|
1173
|
+
|| (event.keyCode >= 96 && event.keyCode <= 105)
|
|
1174
|
+
|| (event.keyCode == 8)
|
|
1175
|
+
|| (event.keyCode == 9)
|
|
1176
|
+
|| (event.keyCode == 39)
|
|
1177
|
+
|| (event.keyCode == 37)
|
|
1178
|
+
|| (event.keyCode == 46)) {
|
|
1179
|
+
//console.log(this.formControlName, this.form.get(this.formControlName).value);
|
|
1180
|
+
setTimeout(() => {
|
|
1181
|
+
if (this.form) {
|
|
1182
|
+
this.form.patchValue({
|
|
1183
|
+
[this.formControlName]: this.formataCampoValor(this.form.get(this.formControlName)?.value, this.formato ?? '', event)
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
else {
|
|
1187
|
+
this.data = this.formataCampoValor(this.data ?? '', this.formato ?? '', event);
|
|
1188
|
+
this.writeValue(this.data);
|
|
1189
|
+
}
|
|
1190
|
+
}, 100);
|
|
1191
|
+
return true;
|
|
1192
|
+
}
|
|
1193
|
+
else {
|
|
1194
|
+
return false;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
onKeyEnter() {
|
|
1198
|
+
if (this.keyEnter != null) {
|
|
1199
|
+
this.keyEnter();
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
if (this.getResultados != null) {
|
|
1203
|
+
this.pesquisarClick();
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
onBlur() {
|
|
1208
|
+
if (this.form) {
|
|
1209
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
1210
|
+
}
|
|
1211
|
+
if (this.blur) {
|
|
1212
|
+
this.blur.emit(this.blurArgs);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
formataCampoValor(valor, Mascara, evento) {
|
|
1216
|
+
console.log(valor);
|
|
1217
|
+
if (!valor)
|
|
1218
|
+
return null;
|
|
1219
|
+
//console.log(evento);
|
|
1220
|
+
//if (!this.keypressInteiro(evento))
|
|
1221
|
+
// return;
|
|
1222
|
+
var boleanoMascara;
|
|
1223
|
+
var Digitato = evento != null ? evento.keyCode : 0;
|
|
1224
|
+
let exp = /\-|\.|\/|\(|\)| /g;
|
|
1225
|
+
let campoSoNumeros = valor.replace(exp, "");
|
|
1226
|
+
var posicaoCampo = 0;
|
|
1227
|
+
var NovoValorCampo = "";
|
|
1228
|
+
var TamanhoMascara = campoSoNumeros.length;
|
|
1229
|
+
;
|
|
1230
|
+
if (Digitato != 8) { // backspace
|
|
1231
|
+
for (let i = 0; i <= TamanhoMascara; i++) {
|
|
1232
|
+
boleanoMascara = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
|
|
1233
|
+
|| (Mascara.charAt(i) == "/"));
|
|
1234
|
+
boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == "(")
|
|
1235
|
+
|| (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " "));
|
|
1236
|
+
if (boleanoMascara) {
|
|
1237
|
+
NovoValorCampo += Mascara.charAt(i);
|
|
1238
|
+
TamanhoMascara++;
|
|
1239
|
+
}
|
|
1240
|
+
else {
|
|
1241
|
+
NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
|
|
1242
|
+
posicaoCampo++;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
return NovoValorCampo;
|
|
1246
|
+
}
|
|
1247
|
+
else {
|
|
1248
|
+
return valor;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
pesquisarClick() {
|
|
1252
|
+
const cep = this.data;
|
|
1253
|
+
//se não estiver informado o cep, não fazer a pesquisa
|
|
1254
|
+
if (cep == null || cep == "") {
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
this.getEnderecoPeloCep(cep).subscribe({
|
|
1258
|
+
next: (result) => {
|
|
1259
|
+
console.log('result CEP', result);
|
|
1260
|
+
let cidadePesquisa = result.localidade;
|
|
1261
|
+
cidadePesquisa = this.converteCaracteresEspeciais(cidadePesquisa.toUpperCase());
|
|
1262
|
+
if (this.getResultados) {
|
|
1263
|
+
this.getResultados(result);
|
|
1264
|
+
}
|
|
1265
|
+
}, error: (error) => {
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
//substituição de caracteres
|
|
1270
|
+
converteCaracteresEspeciais(nome) {
|
|
1271
|
+
var res = nome.replace(/Ã/g, "A");
|
|
1272
|
+
res = res.replace(/Á/g, "A");
|
|
1273
|
+
res = res.replace(/Ç/g, "C");
|
|
1274
|
+
res = res.replace(/É/g, "E");
|
|
1275
|
+
res = res.replace(/Â/g, "A");
|
|
1276
|
+
res = res.replace(/Ô/g, "O");
|
|
1277
|
+
res = res.replace(/Ó/g, "O");
|
|
1278
|
+
res = res.replace(/Ú/g, "U");
|
|
1279
|
+
res = res.replace(/Í/g, "I");
|
|
1280
|
+
return res;
|
|
1281
|
+
}
|
|
1282
|
+
getEnderecoPeloCep(cep) {
|
|
1283
|
+
return new Observable((x) => {
|
|
1284
|
+
var request = new XMLHttpRequest();
|
|
1285
|
+
request.open('get', `https://viacep.com.br/ws/${cep}/json/`, true);
|
|
1286
|
+
request.send();
|
|
1287
|
+
request.onload = function () {
|
|
1288
|
+
var data = JSON.parse(this.response);
|
|
1289
|
+
x.next(data);
|
|
1290
|
+
};
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputCepComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1294
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: InputCepComponent, selector: "kb-input-cep", inputs: { formato: "formato", keyEnter: "keyEnter", getResultados: "getResultados" }, providers: [{
|
|
1295
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1296
|
+
useExisting: InputCepComponent,
|
|
1297
|
+
multi: true
|
|
1298
|
+
}], usesInheritance: true, ngImport: i0, template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<!--comando --inner-padding-end: utilizado pra remover padding desnecess\u00E1rios-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background: inherited;--background-focused: transparent;--inner-padding-end: 0px;\" [class]=\"itemClass\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label [position]=\"labelPosition\">{{ label }}</ion-label>\r\n <!-- formControlName={{formControlName}} -->\r\n <ion-input #inputCep\r\n type=\"tel\" \r\n [placeholder]=\"placeholder\"\r\n maxlength=\"{{ max }}\" \r\n (keydown)=\"digitarFormatado($event)\" \r\n (keyup.enter)=\"onKeyEnter()\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n (input)=\"writeValue(inputCep.value)\"\r\n [disabled]=\"readonly\"></ion-input>\r\n\r\n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\r\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\r\n (click)=\"pesquisarClick()\">\r\n <ion-icon color=\"primary\" name=\"search\"></ion-icon>\r\n </ion-button>\r\n \r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n </div>\r\n </div>", styles: ["", "@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { kind: "component", type: i2.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: i2.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "legacy", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "directive", type: i2.TextValueAccessor, selector: "ion-input:not([type=number]),ion-textarea,ion-searchbar" }] }); }
|
|
1299
|
+
}
|
|
1300
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputCepComponent, decorators: [{
|
|
1301
|
+
type: Component,
|
|
1302
|
+
args: [{ selector: 'kb-input-cep', providers: [{
|
|
1303
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1304
|
+
useExisting: InputCepComponent,
|
|
1305
|
+
multi: true
|
|
1306
|
+
}], template: "<!--\r\n<div [formGroup]=\"form\">\r\n-->\r\n<!--comando --inner-padding-end: utilizado pra remover padding desnecess\u00E1rios-->\r\n<div>\r\n <ion-item lines=\"none\" style=\"--background: inherited;--background-focused: transparent;--inner-padding-end: 0px;\" [class]=\"itemClass\"\r\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\r\n >\r\n <ion-label [position]=\"labelPosition\">{{ label }}</ion-label>\r\n <!-- formControlName={{formControlName}} -->\r\n <ion-input #inputCep\r\n type=\"tel\" \r\n [placeholder]=\"placeholder\"\r\n maxlength=\"{{ max }}\" \r\n (keydown)=\"digitarFormatado($event)\" \r\n (keyup.enter)=\"onKeyEnter()\"\r\n (ionBlur)=\"onBlur()\"\r\n [value]=\"data\"\r\n (input)=\"writeValue(inputCep.value)\"\r\n [disabled]=\"readonly\"></ion-input>\r\n\r\n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\r\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\r\n (click)=\"pesquisarClick()\">\r\n <ion-icon color=\"primary\" name=\"search\"></ion-icon>\r\n </ion-button>\r\n \r\n </ion-item>\r\n \r\n <div class=\"validation-errors\" *ngIf=\"form\">\r\n <ng-container *ngFor=\"let validation of validation_messages\">\r\n <div class=\"error-message\"\r\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\r\n • {{ validation.message }}\r\n </div>\r\n </ng-container>\r\n </div>\r\n </div>", styles: ["@charset \"UTF-8\";ion-label{margin-bottom:4px!important}ion-item ion-label{overflow:initial!important}ion-input{padding:var(--input-padding, 8px)!important;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:var(--input-max-height, 29px);transition:.2s ease}.has-focus{border:1px solid var(--ion-color-bluetool, #1f477d)}input:focus ion-input,input:focus ion-textarea{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}input:disabled{opacity:.9!important}.error-message{font-size:small;color:var(--error-text-color, red);margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-end{--inner-padding-end: 0px}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.item-inner{padding-right:0!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}.error-input ion-input,.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid var(--error-text-color, red)!important}@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-input ion-label,.error-shake ion-label{color:var(--error-text-color, red)!important}.error-input ion-input,.error-shake ion-input{border:1px solid red!important}.error-shake ion-input{animation:shake .4s 1 linear}\n"] }]
|
|
1307
|
+
}], ctorParameters: () => [], propDecorators: { formato: [{
|
|
1308
|
+
type: Input
|
|
1309
|
+
}], keyEnter: [{
|
|
1310
|
+
type: Input
|
|
1311
|
+
}], getResultados: [{
|
|
1312
|
+
type: Input
|
|
1313
|
+
}] } });
|
|
1314
|
+
|
|
1315
|
+
class InputArquivoComponent {
|
|
1316
|
+
showImageBrowser() {
|
|
1317
|
+
this.myInput.nativeElement.click();
|
|
1318
|
+
}
|
|
1319
|
+
writeValue(value) {
|
|
1320
|
+
this.onChange(value);
|
|
1321
|
+
this.data = value;
|
|
1322
|
+
if (this.callback)
|
|
1323
|
+
this.callback.emit(this.filename);
|
|
1324
|
+
}
|
|
1325
|
+
registerOnChange(fn) {
|
|
1326
|
+
this.onChange = fn;
|
|
1327
|
+
}
|
|
1328
|
+
registerOnTouched(fn) {
|
|
1329
|
+
this.onTouch = fn;
|
|
1330
|
+
}
|
|
1331
|
+
setDisabledState(isDisabled) {
|
|
1332
|
+
this.disabled = this.disabled;
|
|
1333
|
+
}
|
|
1334
|
+
constructor(utils) {
|
|
1335
|
+
this.utils = utils;
|
|
1336
|
+
this.subir = false;
|
|
1337
|
+
this.callback = new EventEmitter();
|
|
1338
|
+
this.form = false;
|
|
1339
|
+
this.showIcon = false;
|
|
1340
|
+
this.sucessoEvent = new Subject();
|
|
1341
|
+
this.onChange = (selectedColor) => { };
|
|
1342
|
+
this.onTouch = () => { };
|
|
1343
|
+
this.disabled = false;
|
|
1344
|
+
}
|
|
1345
|
+
ngOnInit() {
|
|
1346
|
+
}
|
|
1347
|
+
loadImagem() {
|
|
1348
|
+
//console.log(this.myInput);
|
|
1349
|
+
if (this.form) {
|
|
1350
|
+
this.formFile = this.myInput.nativeElement.files[0];
|
|
1351
|
+
this.sucessoEvent.next(true);
|
|
1352
|
+
}
|
|
1353
|
+
else {
|
|
1354
|
+
this.formFile = this.myInput.nativeElement.files[0];
|
|
1355
|
+
this.utils.getBase64FromFile(this.myInput.nativeElement.files[0])
|
|
1356
|
+
.then(result => {
|
|
1357
|
+
//console.log('file: ', result.toString());
|
|
1358
|
+
//console.log('nome do arquivo: ', this.nomeArquivo.toLowerCase());
|
|
1359
|
+
let searchstr = result.toString().substring(0, result.toString().indexOf('base64,')) + 'base64,';
|
|
1360
|
+
console.log('searchstring', searchstr);
|
|
1361
|
+
if (this.subir) {
|
|
1362
|
+
this.captureDataUrl = result.toString().replace(searchstr, '');
|
|
1363
|
+
}
|
|
1364
|
+
else {
|
|
1365
|
+
this.captureDataUrl = result.toString();
|
|
1366
|
+
}
|
|
1367
|
+
//this.utils.showToast('Imagem carregada em memória.');
|
|
1368
|
+
this.sucessoEvent.next(true);
|
|
1369
|
+
console.log('file', this.myInput.nativeElement.files[0]);
|
|
1370
|
+
this.filename = this.myInput.nativeElement.files[0].name;
|
|
1371
|
+
this.writeValue(this.captureDataUrl);
|
|
1372
|
+
// if (this.nomeArquivo && this.subir) {
|
|
1373
|
+
// this.arquivoService.setImagem({ Nome: this.nomeArquivo, Conteudo: this.captureDataUrl, Status: 0, Pasta: this.pasta })
|
|
1374
|
+
// .subscribe(result => {
|
|
1375
|
+
// console.log('result set imagem', result);
|
|
1376
|
+
// if (result.Status == 200) {
|
|
1377
|
+
// this.utils.showToast('Sucesso!');
|
|
1378
|
+
// } else {
|
|
1379
|
+
// this.utils.showAlert('Erro. Tente mais tarde.' + result.Conteudo);
|
|
1380
|
+
// }
|
|
1381
|
+
// }, error => {
|
|
1382
|
+
// this.utils.showAlert('Erro. Tente mais tarde.');
|
|
1383
|
+
// })
|
|
1384
|
+
// }
|
|
1385
|
+
}).catch(error => {
|
|
1386
|
+
this.sucessoEvent.next(false);
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputArquivoComponent, deps: [{ token: i1$2.AppprojectUtilsService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1391
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.7", type: InputArquivoComponent, selector: "kb-input-arquivo", inputs: { nomeArquivo: "nomeArquivo", caption: "caption", pasta: "pasta", subir: "subir", callback: "callback", form: "form", showIcon: "showIcon" }, providers: [{
|
|
1392
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1393
|
+
useExisting: InputArquivoComponent,
|
|
1394
|
+
multi: true
|
|
1395
|
+
}], viewQueries: [{ propertyName: "myInput", first: true, predicate: ["inputNome"], descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div style=\"text-align:center;\">\r\n <ion-button style=\"box-shadow: #4c8dff 0px 3px 3px 0.05px\" fill=\"outline\" size=\"normal\" color=\"primary\" \r\n (click)=\"showImageBrowser()\" expand=\"block\">\r\n <ion-icon *ngIf=\"showIcon\" class=\"ion-padding-end\" src=\"/assets/icon/image_primary_24dp.svg\"></ion-icon>\r\n {{ caption }}\r\n </ion-button>\r\n <input type=\"file\" id=\"upimgfile\" name=\"uploadfile\" #inputNome accept=\"image/*\" (change)=\"loadImagem()\"\r\n style=\"display: none;\" />\r\n </div>\r\n ", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { kind: "component", type: i2.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }] }); }
|
|
1396
|
+
}
|
|
1397
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: InputArquivoComponent, decorators: [{
|
|
1398
|
+
type: Component,
|
|
1399
|
+
args: [{ selector: 'kb-input-arquivo', providers: [{
|
|
1400
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1401
|
+
useExisting: InputArquivoComponent,
|
|
1402
|
+
multi: true
|
|
1403
|
+
}], template: "<div style=\"text-align:center;\">\r\n <ion-button style=\"box-shadow: #4c8dff 0px 3px 3px 0.05px\" fill=\"outline\" size=\"normal\" color=\"primary\" \r\n (click)=\"showImageBrowser()\" expand=\"block\">\r\n <ion-icon *ngIf=\"showIcon\" class=\"ion-padding-end\" src=\"/assets/icon/image_primary_24dp.svg\"></ion-icon>\r\n {{ caption }}\r\n </ion-button>\r\n <input type=\"file\" id=\"upimgfile\" name=\"uploadfile\" #inputNome accept=\"image/*\" (change)=\"loadImagem()\"\r\n style=\"display: none;\" />\r\n </div>\r\n " }]
|
|
1404
|
+
}], ctorParameters: () => [{ type: i1$2.AppprojectUtilsService }], propDecorators: { nomeArquivo: [{
|
|
1405
|
+
type: Input
|
|
1406
|
+
}], caption: [{
|
|
1407
|
+
type: Input
|
|
1408
|
+
}], pasta: [{
|
|
1409
|
+
type: Input
|
|
1410
|
+
}], subir: [{
|
|
1411
|
+
type: Input
|
|
1412
|
+
}], callback: [{
|
|
1413
|
+
type: Input
|
|
1414
|
+
}], form: [{
|
|
1415
|
+
type: Input
|
|
1416
|
+
}], showIcon: [{
|
|
1417
|
+
type: Input
|
|
1418
|
+
}], myInput: [{
|
|
1419
|
+
type: ViewChild,
|
|
1420
|
+
args: ['inputNome', { read: ElementRef, static: true }]
|
|
1421
|
+
}] } });
|
|
1422
|
+
|
|
1423
|
+
const LibConfigService = new InjectionToken('LibConfig');
|
|
1424
|
+
class AppprojectComponentsModule {
|
|
1425
|
+
static forRoot(config) {
|
|
1426
|
+
return {
|
|
1427
|
+
ngModule: AppprojectComponentsModule,
|
|
1428
|
+
providers: [
|
|
1429
|
+
AppprojectComponentsService,
|
|
1430
|
+
{
|
|
1431
|
+
provide: LibConfigService,
|
|
1432
|
+
useValue: config
|
|
1433
|
+
}
|
|
1434
|
+
]
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: AppprojectComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1438
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.7", ngImport: i0, type: AppprojectComponentsModule, declarations: [AppprojectComponentsComponent,
|
|
1439
|
+
InputTextComponent,
|
|
1440
|
+
InputFormatComponent,
|
|
1441
|
+
InputSelectComponent,
|
|
1442
|
+
InputPesquisaComponent,
|
|
1443
|
+
ModelTreeviewComponent,
|
|
1444
|
+
InputValorComponent,
|
|
1445
|
+
InputAreaComponent,
|
|
1446
|
+
InputCepComponent,
|
|
1447
|
+
InputArquivoComponent], imports: [CommonModule,
|
|
1448
|
+
HttpClientModule,
|
|
1449
|
+
IonicModule,
|
|
1450
|
+
ReactiveFormsModule], exports: [AppprojectComponentsComponent,
|
|
1451
|
+
InputTextComponent,
|
|
1452
|
+
InputFormatComponent,
|
|
1453
|
+
InputSelectComponent,
|
|
1454
|
+
InputPesquisaComponent,
|
|
1455
|
+
ModelTreeviewComponent,
|
|
1456
|
+
InputValorComponent,
|
|
1457
|
+
InputAreaComponent,
|
|
1458
|
+
InputCepComponent,
|
|
1459
|
+
InputArquivoComponent] }); }
|
|
1460
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: AppprojectComponentsModule, imports: [CommonModule,
|
|
1461
|
+
HttpClientModule,
|
|
1462
|
+
IonicModule,
|
|
1463
|
+
ReactiveFormsModule] }); }
|
|
1464
|
+
}
|
|
1465
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.7", ngImport: i0, type: AppprojectComponentsModule, decorators: [{
|
|
1466
|
+
type: NgModule,
|
|
1467
|
+
args: [{
|
|
1468
|
+
declarations: [
|
|
1469
|
+
AppprojectComponentsComponent,
|
|
1470
|
+
InputTextComponent,
|
|
1471
|
+
InputFormatComponent,
|
|
1472
|
+
InputSelectComponent,
|
|
1473
|
+
InputPesquisaComponent,
|
|
1474
|
+
ModelTreeviewComponent,
|
|
1475
|
+
InputValorComponent,
|
|
1476
|
+
InputAreaComponent,
|
|
1477
|
+
InputCepComponent,
|
|
1478
|
+
InputArquivoComponent
|
|
1479
|
+
],
|
|
1480
|
+
imports: [
|
|
1481
|
+
CommonModule,
|
|
1482
|
+
HttpClientModule,
|
|
1483
|
+
IonicModule,
|
|
1484
|
+
ReactiveFormsModule
|
|
1485
|
+
],
|
|
1486
|
+
exports: [
|
|
1487
|
+
AppprojectComponentsComponent,
|
|
1488
|
+
InputTextComponent,
|
|
1489
|
+
InputFormatComponent,
|
|
1490
|
+
InputSelectComponent,
|
|
1491
|
+
InputPesquisaComponent,
|
|
1492
|
+
ModelTreeviewComponent,
|
|
1493
|
+
InputValorComponent,
|
|
1494
|
+
InputAreaComponent,
|
|
1495
|
+
InputCepComponent,
|
|
1496
|
+
InputArquivoComponent
|
|
1497
|
+
],
|
|
1498
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
|
1499
|
+
}]
|
|
1500
|
+
}] });
|
|
1501
|
+
|
|
1502
|
+
/*
|
|
1503
|
+
* Public API Surface of appproject-components
|
|
1504
|
+
*/
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Generated bundle index. Do not edit.
|
|
1508
|
+
*/
|
|
1509
|
+
|
|
1510
|
+
export { AppprojectComponentsComponent, AppprojectComponentsModule, AppprojectComponentsService, BaseInputComponent, InputAreaComponent, InputArquivoComponent, InputCepComponent, InputFormatComponent, InputPesquisaComponent, InputSelectComponent, InputTextComponent, InputValorComponent, LibConfigService, ModelTreeviewComponent };
|
|
1511
|
+
//# sourceMappingURL=appproject-components.mjs.map
|