keevo-components 1.3.7 → 1.3.8
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/ng-package.json +7 -0
- package/package.json +20 -39
- package/src/index.ts +1 -0
- package/src/lib/api/base-components/base-component-button.ts +26 -0
- package/src/lib/api/base-components/base-component-dropdown.ts +127 -0
- package/src/lib/api/base-components/base-component-input.ts +91 -0
- package/src/lib/api/base-components/base-component.ts +46 -0
- package/src/lib/api/components/error/error.component.html +3 -0
- package/src/lib/api/components/error/error.component.scss +0 -0
- package/src/lib/api/components/error/error.component.ts +22 -0
- package/src/lib/api/components/error/kverror.module.ts +23 -0
- package/src/lib/api/components/table/action-item.ts +5 -0
- package/{lib/api/components/table/kv-menuitem.d.ts → src/lib/api/components/table/kv-menuitem.ts} +4 -3
- package/src/lib/api/components/table/table.config.column.ts +10 -0
- package/src/lib/api/components/table/table.config.ts +14 -0
- package/src/lib/api/components/table/table.paginate.ts +6 -0
- package/src/lib/api/helpers/component-providers.ts +16 -0
- package/src/lib/api/helpers/translate-primeng.ts +25 -0
- package/src/lib/api/modules/primeng.module.ts +97 -0
- package/src/lib/api/services/component.service.ts +22 -0
- package/src/lib/api/services/notification.service.ts +82 -0
- package/src/lib/api/services/object.service.ts +20 -0
- package/src/lib/buttons/button-personalize/button-personalize.component.html +9 -0
- package/src/lib/buttons/button-personalize/button-personalize.component.scss +0 -0
- package/src/lib/buttons/button-personalize/button-personalize.component.ts +13 -0
- package/src/lib/buttons/button-secondary/button-secondary.component.html +9 -0
- package/src/lib/buttons/button-secondary/button-secondary.component.scss +13 -0
- package/src/lib/buttons/button-secondary/button-secondary.component.ts +13 -0
- package/src/lib/buttons/button-success/button-success.component.html +9 -0
- package/src/lib/buttons/button-success/button-success.component.scss +12 -0
- package/src/lib/buttons/button-success/button-success.component.ts +13 -0
- package/src/lib/buttons/kvbutton.module.ts +22 -0
- package/src/lib/directives/template.directive.ts +15 -0
- package/src/lib/inputs/check/check.component.html +11 -0
- package/src/lib/inputs/check/check.component.scss +0 -0
- package/src/lib/inputs/check/check.component.ts +24 -0
- package/src/lib/inputs/dropdown/dropdown.component.html +43 -0
- package/src/lib/inputs/dropdown/dropdown.component.scss +0 -0
- package/src/lib/inputs/dropdown/dropdown.component.ts +19 -0
- package/src/lib/inputs/input-calendar/input-calendar.component.html +22 -0
- package/src/lib/inputs/input-calendar/input-calendar.component.scss +0 -0
- package/src/lib/inputs/input-calendar/input-calendar.component.ts +54 -0
- package/src/lib/inputs/input-mask/input-mask.component.html +15 -0
- package/src/lib/inputs/input-mask/input-mask.component.scss +0 -0
- package/src/lib/inputs/input-mask/input-mask.component.ts +20 -0
- package/src/lib/inputs/input-number/input-number.component.html +15 -0
- package/src/lib/inputs/input-number/input-number.component.scss +0 -0
- package/src/lib/inputs/input-number/input-number.component.ts +51 -0
- package/src/lib/inputs/input-password/input-password.component.html +18 -0
- package/src/lib/inputs/input-password/input-password.component.scss +0 -0
- package/src/lib/inputs/input-password/input-password.component.ts +23 -0
- package/src/lib/inputs/input-text/input-text.component.html +14 -0
- package/src/lib/inputs/input-text/input-text.component.scss +18 -0
- package/src/lib/inputs/input-text/input-text.component.ts +17 -0
- package/src/lib/inputs/input-textarea/input-textarea.component.html +17 -0
- package/src/lib/inputs/input-textarea/input-textarea.component.scss +0 -0
- package/src/lib/inputs/input-textarea/input-textarea.component.ts +33 -0
- package/src/lib/inputs/input-time/input-time.component.html +18 -0
- package/src/lib/inputs/input-time/input-time.component.scss +0 -0
- package/src/lib/inputs/input-time/input-time.component.ts +20 -0
- package/src/lib/inputs/kvinputs.module.ts +53 -0
- package/src/lib/inputs/multi-select/multi-select.component.html +21 -0
- package/src/lib/inputs/multi-select/multi-select.component.scss +0 -0
- package/src/lib/inputs/multi-select/multi-select.component.ts +44 -0
- package/src/lib/inputs/switch/switch.component.html +11 -0
- package/src/lib/inputs/switch/switch.component.scss +3 -0
- package/src/lib/inputs/switch/switch.component.ts +24 -0
- package/src/lib/keevo-components.module.ts +20 -0
- package/src/lib/pipes/codigofile.pipe.ts +15 -0
- package/src/lib/pipes/cpfcnpj.pipe.ts +21 -0
- package/src/lib/pipes/pipes.module.ts +22 -0
- package/src/lib/pipes/telefone.pipe.ts +38 -0
- package/src/lib/styles-components.scss +3 -0
- package/src/lib/table/kvtable.module.ts +20 -0
- package/src/lib/table/table.component.html +189 -0
- package/src/lib/table/table.component.scss +21 -0
- package/src/lib/table/table.component.spec.ts +28 -0
- package/src/lib/table/table.component.ts +211 -0
- package/{public-api.d.ts → src/public-api.ts} +11 -4
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2020/keevo-components.mjs +0 -5
- package/esm2020/lib/api/base-components/base-component-button.mjs +0 -36
- package/esm2020/lib/api/base-components/base-component-dropdown.mjs +0 -116
- package/esm2020/lib/api/base-components/base-component-input.mjs +0 -77
- package/esm2020/lib/api/base-components/base-component.mjs +0 -49
- package/esm2020/lib/api/components/error/error.component.mjs +0 -26
- package/esm2020/lib/api/components/error/kverror.module.mjs +0 -35
- package/esm2020/lib/api/components/table/action-item.mjs +0 -2
- package/esm2020/lib/api/components/table/kv-menuitem.mjs +0 -3
- package/esm2020/lib/api/components/table/table.config.column.mjs +0 -2
- package/esm2020/lib/api/components/table/table.config.mjs +0 -2
- package/esm2020/lib/api/components/table/table.paginate.mjs +0 -9
- package/esm2020/lib/api/helpers/component-providers.mjs +0 -16
- package/esm2020/lib/api/helpers/translate-primeng.mjs +0 -23
- package/esm2020/lib/api/modules/primeng.module.mjs +0 -191
- package/esm2020/lib/api/services/component.service.mjs +0 -27
- package/esm2020/lib/api/services/notification.service.mjs +0 -67
- package/esm2020/lib/api/services/object.service.mjs +0 -26
- package/esm2020/lib/buttons/button-personalize/button-personalize.component.mjs +0 -17
- package/esm2020/lib/buttons/button-secondary/button-secondary.component.mjs +0 -17
- package/esm2020/lib/buttons/button-success/button-success.component.mjs +0 -17
- package/esm2020/lib/buttons/kvbutton.module.mjs +0 -34
- package/esm2020/lib/directives/template.directive.mjs +0 -24
- package/esm2020/lib/inputs/check/check.component.mjs +0 -26
- package/esm2020/lib/inputs/dropdown/dropdown.component.mjs +0 -26
- package/esm2020/lib/inputs/input-calendar/input-calendar.component.mjs +0 -62
- package/esm2020/lib/inputs/input-mask/input-mask.component.mjs +0 -22
- package/esm2020/lib/inputs/input-number/input-number.component.mjs +0 -56
- package/esm2020/lib/inputs/input-password/input-password.component.mjs +0 -32
- package/esm2020/lib/inputs/input-text/input-text.component.mjs +0 -20
- package/esm2020/lib/inputs/input-textarea/input-textarea.component.mjs +0 -42
- package/esm2020/lib/inputs/input-time/input-time.component.mjs +0 -23
- package/esm2020/lib/inputs/kvinputs.module.mjs +0 -89
- package/esm2020/lib/inputs/multi-select/multi-select.component.mjs +0 -50
- package/esm2020/lib/inputs/switch/switch.component.mjs +0 -26
- package/esm2020/lib/keevo-components.module.mjs +0 -35
- package/esm2020/lib/pipes/codigofile.pipe.mjs +0 -19
- package/esm2020/lib/pipes/cpfcnpj.pipe.mjs +0 -25
- package/esm2020/lib/pipes/pipes.module.mjs +0 -34
- package/esm2020/lib/pipes/telefone.pipe.mjs +0 -45
- package/esm2020/lib/table/kvtable.module.mjs +0 -28
- package/esm2020/lib/table/table.component.mjs +0 -194
- package/esm2020/public-api.mjs +0 -44
- package/fesm2015/keevo-components.mjs +0 -1481
- package/fesm2015/keevo-components.mjs.map +0 -1
- package/fesm2020/keevo-components.mjs +0 -1490
- package/fesm2020/keevo-components.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/api/base-components/base-component-button.d.ts +0 -14
- package/lib/api/base-components/base-component-dropdown.d.ts +0 -31
- package/lib/api/base-components/base-component-input.d.ts +0 -26
- package/lib/api/base-components/base-component.d.ts +0 -21
- package/lib/api/components/error/error.component.d.ts +0 -12
- package/lib/api/components/error/kverror.module.d.ts +0 -10
- package/lib/api/components/table/action-item.d.ts +0 -5
- package/lib/api/components/table/table.config.column.d.ts +0 -10
- package/lib/api/components/table/table.config.d.ts +0 -12
- package/lib/api/components/table/table.paginate.d.ts +0 -6
- package/lib/api/helpers/component-providers.d.ts +0 -2
- package/lib/api/helpers/translate-primeng.d.ts +0 -4
- package/lib/api/modules/primeng.module.d.ts +0 -46
- package/lib/api/services/component.service.d.ts +0 -11
- package/lib/api/services/notification.service.d.ts +0 -25
- package/lib/api/services/object.service.d.ts +0 -8
- package/lib/buttons/button-personalize/button-personalize.component.d.ts +0 -7
- package/lib/buttons/button-secondary/button-secondary.component.d.ts +0 -7
- package/lib/buttons/button-success/button-success.component.d.ts +0 -7
- package/lib/buttons/kvbutton.module.d.ts +0 -10
- package/lib/directives/template.directive.d.ts +0 -11
- package/lib/inputs/check/check.component.d.ts +0 -11
- package/lib/inputs/dropdown/dropdown.component.d.ts +0 -9
- package/lib/inputs/input-calendar/input-calendar.component.d.ts +0 -21
- package/lib/inputs/input-mask/input-mask.component.d.ts +0 -10
- package/lib/inputs/input-number/input-number.component.d.ts +0 -18
- package/lib/inputs/input-password/input-password.component.d.ts +0 -13
- package/lib/inputs/input-text/input-text.component.d.ts +0 -9
- package/lib/inputs/input-textarea/input-textarea.component.d.ts +0 -16
- package/lib/inputs/input-time/input-time.component.d.ts +0 -10
- package/lib/inputs/kvinputs.module.d.ts +0 -21
- package/lib/inputs/multi-select/multi-select.component.d.ts +0 -20
- package/lib/inputs/switch/switch.component.d.ts +0 -11
- package/lib/keevo-components.module.d.ts +0 -9
- package/lib/pipes/codigofile.pipe.d.ts +0 -7
- package/lib/pipes/cpfcnpj.pipe.d.ts +0 -7
- package/lib/pipes/pipes.module.d.ts +0 -10
- package/lib/pipes/telefone.pipe.d.ts +0 -7
- package/lib/table/kvtable.module.d.ts +0 -9
- package/lib/table/table.component.d.ts +0 -56
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,39 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "keevo-components",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"peerDependencies": {
|
|
5
|
-
"@angular/common": "^15.2.0",
|
|
6
|
-
"@angular/core": "^15.2.0"
|
|
7
|
-
},
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"tslib": "^2.3.0"
|
|
10
|
-
},
|
|
11
|
-
"sideEffects": false,
|
|
12
|
-
"description": "Componentes utilizados no frontend dos sistemas da Keevo Software.",
|
|
13
|
-
"author": {
|
|
14
|
-
"name": "Rafael",
|
|
15
|
-
"url": "https://github.com/rafaelalvesmds"
|
|
16
|
-
},
|
|
17
|
-
"keywords": [
|
|
18
|
-
"keevo components library"
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
"es2020": "fesm2020/keevo-components.mjs",
|
|
22
|
-
"esm2020": "esm2020/keevo-components.mjs",
|
|
23
|
-
"fesm2020": "fesm2020/keevo-components.mjs",
|
|
24
|
-
"fesm2015": "fesm2015/keevo-components.mjs",
|
|
25
|
-
"typings": "index.d.ts",
|
|
26
|
-
"exports": {
|
|
27
|
-
"./package.json": {
|
|
28
|
-
"default": "./package.json"
|
|
29
|
-
},
|
|
30
|
-
".": {
|
|
31
|
-
"types": "./index.d.ts",
|
|
32
|
-
"esm2020": "./esm2020/keevo-components.mjs",
|
|
33
|
-
"es2020": "./fesm2020/keevo-components.mjs",
|
|
34
|
-
"es2015": "./fesm2015/keevo-components.mjs",
|
|
35
|
-
"node": "./fesm2015/keevo-components.mjs",
|
|
36
|
-
"default": "./fesm2020/keevo-components.mjs"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "keevo-components",
|
|
3
|
+
"version": "1.3.8",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^15.2.0",
|
|
6
|
+
"@angular/core": "^15.2.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"description": "Componentes utilizados no frontend dos sistemas da Keevo Software.",
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Rafael",
|
|
15
|
+
"url": "https://github.com/rafaelalvesmds"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"keevo components library"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './public-api';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
EventEmitter,
|
|
4
|
+
Input,
|
|
5
|
+
Output
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
template: '',
|
|
10
|
+
})
|
|
11
|
+
export class BaseComponentButton {
|
|
12
|
+
|
|
13
|
+
@Input() icon: string = '';
|
|
14
|
+
@Input() label: string = '';
|
|
15
|
+
@Input() loading: boolean = false;
|
|
16
|
+
@Input() disabled: boolean = false;
|
|
17
|
+
@Input() color: string = 'bg-blue-100';
|
|
18
|
+
|
|
19
|
+
@Output() onClick: EventEmitter<any> = new EventEmitter();
|
|
20
|
+
|
|
21
|
+
constructor() { }
|
|
22
|
+
|
|
23
|
+
click(event: any): void {
|
|
24
|
+
this.onClick.emit();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
EventEmitter,
|
|
4
|
+
Input,
|
|
5
|
+
OnInit,
|
|
6
|
+
Output,
|
|
7
|
+
Type,
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
|
|
10
|
+
import { FormControl } from '@angular/forms';
|
|
11
|
+
import { of } from 'rxjs';
|
|
12
|
+
import { DialogService } from 'primeng/dynamicdialog';
|
|
13
|
+
|
|
14
|
+
import { BaseComponentInput } from './base-component-input';
|
|
15
|
+
|
|
16
|
+
import { ComponentService } from '../services/component.service';
|
|
17
|
+
import { ObjectService } from '../services/object.service';
|
|
18
|
+
|
|
19
|
+
@Component({
|
|
20
|
+
template: '',
|
|
21
|
+
})
|
|
22
|
+
export abstract class BaseComponentDropDown
|
|
23
|
+
extends BaseComponentInput<any>
|
|
24
|
+
implements OnInit
|
|
25
|
+
{
|
|
26
|
+
@Input() options!: any[];
|
|
27
|
+
@Input() filteredOptions!: any[];
|
|
28
|
+
@Input() optionLabel!: string;
|
|
29
|
+
@Input() optionValue!: string;
|
|
30
|
+
@Input() addButton: boolean = false;
|
|
31
|
+
@Input() filter: boolean = true;
|
|
32
|
+
@Input() showClear: boolean = true;
|
|
33
|
+
|
|
34
|
+
@Output() onAddClick: EventEmitter<any> = new EventEmitter();
|
|
35
|
+
@Output() onSelectionChange: EventEmitter<any> = new EventEmitter();
|
|
36
|
+
@Output() onSelectionValue: EventEmitter<any> = new EventEmitter();
|
|
37
|
+
@Output() onClick: EventEmitter<any> = new EventEmitter();
|
|
38
|
+
|
|
39
|
+
constructor(
|
|
40
|
+
componentService: ComponentService,
|
|
41
|
+
private dialogService: DialogService
|
|
42
|
+
) {
|
|
43
|
+
super(componentService);
|
|
44
|
+
this.registerOnTouched(() => {});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override ngOnInit(): void {
|
|
48
|
+
super.ngOnInit();
|
|
49
|
+
// this.carregarCombo();
|
|
50
|
+
this.setPlaceHolder('Selecione um valor');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected addClick(event: Event) {
|
|
54
|
+
this.onAddClick.emit(event);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private carregarCombo(): void {
|
|
58
|
+
this.listar().subscribe({
|
|
59
|
+
next: (data: any) => {
|
|
60
|
+
this.options = data;
|
|
61
|
+
this.filteredOptions = data;
|
|
62
|
+
},
|
|
63
|
+
error: (error: any) => {},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public filterOptions(field: string, value: any): void {
|
|
68
|
+
if (this.options) {
|
|
69
|
+
let lista = ObjectService.filterObject(this.options, field, value);
|
|
70
|
+
if (lista?.length > 0) {
|
|
71
|
+
of(lista).subscribe((opts: any[]) => {
|
|
72
|
+
this.filteredOptions = opts;
|
|
73
|
+
});
|
|
74
|
+
} else this.filteredOptions = [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected listar(): any {}
|
|
79
|
+
|
|
80
|
+
onInputClick(event: any) {
|
|
81
|
+
this.onClick.emit(event);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
protected openDialog(
|
|
85
|
+
componentType: Type<any>,
|
|
86
|
+
width?: string,
|
|
87
|
+
height?: string
|
|
88
|
+
) {
|
|
89
|
+
const ref = this.dialogService.open(componentType, {
|
|
90
|
+
width: width || '70%',
|
|
91
|
+
height: height,
|
|
92
|
+
closable: false,
|
|
93
|
+
maximizable: true,
|
|
94
|
+
data: { popup: true },
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
ref.onClose.subscribe((id: any) => {
|
|
98
|
+
if (id) {
|
|
99
|
+
this.listar().subscribe((data: any) => {
|
|
100
|
+
this.options = data;
|
|
101
|
+
this.filteredOptions = data;
|
|
102
|
+
if (id) this.formControl?.setValue(id);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
protected selectionValue(event: any) {
|
|
109
|
+
this.onSelectionValue.emit(event);
|
|
110
|
+
|
|
111
|
+
let currentItem = null;
|
|
112
|
+
|
|
113
|
+
const controlName = this.getName(this.formControl as FormControl);
|
|
114
|
+
if (controlName)
|
|
115
|
+
currentItem = ObjectService.findObject(
|
|
116
|
+
this.options,
|
|
117
|
+
controlName,
|
|
118
|
+
event.value
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
this.onSelectionChange.emit(currentItem);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
protected setPlaceHolder(p: string) {
|
|
125
|
+
if (!this.placeholder) this.placeholder = p;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AfterContentInit,
|
|
3
|
+
AfterViewInit,
|
|
4
|
+
Component,
|
|
5
|
+
ContentChildren,
|
|
6
|
+
EventEmitter,
|
|
7
|
+
Input,
|
|
8
|
+
OnInit,
|
|
9
|
+
Output,
|
|
10
|
+
QueryList,
|
|
11
|
+
ViewChildren
|
|
12
|
+
} from "@angular/core";
|
|
13
|
+
|
|
14
|
+
import { FormControl } from '@angular/forms';
|
|
15
|
+
|
|
16
|
+
import { BaseComponent } from './base-component';
|
|
17
|
+
|
|
18
|
+
import { ComponentService } from '../services/component.service';
|
|
19
|
+
import { ErrorComponent } from '../components/error/error.component';
|
|
20
|
+
|
|
21
|
+
@Component({
|
|
22
|
+
template: '',
|
|
23
|
+
})
|
|
24
|
+
export abstract class BaseComponentInput<T> extends BaseComponent<T> implements OnInit, AfterContentInit, AfterViewInit {
|
|
25
|
+
|
|
26
|
+
protected formControl: FormControl | undefined;
|
|
27
|
+
protected hasError: boolean | undefined = false;
|
|
28
|
+
|
|
29
|
+
@Input() placeholder: string = '';
|
|
30
|
+
|
|
31
|
+
@Output() onBlur: EventEmitter<any> = new EventEmitter();
|
|
32
|
+
|
|
33
|
+
@ViewChildren(ErrorComponent) viewErrors!: QueryList<ErrorComponent>;
|
|
34
|
+
@ContentChildren(ErrorComponent) contentErrors!: QueryList<ErrorComponent>;
|
|
35
|
+
|
|
36
|
+
constructor(protected readonly componentService: ComponentService) {
|
|
37
|
+
super();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public get baseInputClass(): string {
|
|
41
|
+
return `${this.hasError ? 'ng-invalid ng-dirty' : ''} !important`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
erroMessage(): string | undefined {
|
|
45
|
+
if (!this.formControl?.errors) return;
|
|
46
|
+
|
|
47
|
+
let message: string = '';
|
|
48
|
+
|
|
49
|
+
if (this.formControl.errors) {
|
|
50
|
+
const objErrors = this.formControl.errors as any;
|
|
51
|
+
if (objErrors.erroMessage) message = objErrors.erroMessage;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return message;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
getName(control: FormControl): string | null {
|
|
58
|
+
return Object.entries(control.parent?.controls ?? []).find(([_, value]) => value === control)?.[0] ?? null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
hasControlError(): boolean {
|
|
62
|
+
if (!this.formControl) return false;
|
|
63
|
+
return (this.formControl.dirty || this.formControl.touched) && this.formControl.errors !== null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
ngAfterViewInit(): void {
|
|
67
|
+
this.viewErrors.forEach(c => {
|
|
68
|
+
c.emitError.subscribe(res => {
|
|
69
|
+
this.hasError = res;
|
|
70
|
+
this.componentService.changeDetectorRef.detectChanges();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
ngAfterContentInit() {
|
|
76
|
+
this.contentErrors.forEach(c => {
|
|
77
|
+
c.emitError.subscribe(res => {
|
|
78
|
+
this.hasError = res;
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
ngOnInit(): void {
|
|
84
|
+
this.formControl = this.componentService.getFormControl();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
onInputBlur(event: Event) {
|
|
88
|
+
this.onTouched();
|
|
89
|
+
this.onBlur.emit(event);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Component, Input } from "@angular/core";
|
|
2
|
+
import { ControlValueAccessor } from "@angular/forms";
|
|
3
|
+
import { Subject } from "rxjs";
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
template: ''
|
|
7
|
+
})
|
|
8
|
+
export abstract class BaseComponent<T> implements ControlValueAccessor {
|
|
9
|
+
|
|
10
|
+
protected stateChanges: Subject<void> = new Subject();
|
|
11
|
+
protected onChange!: (value: T) => void;
|
|
12
|
+
protected onTouched!: () => void;
|
|
13
|
+
protected _value!: T;
|
|
14
|
+
|
|
15
|
+
@Input('required') isRequired: boolean = false;
|
|
16
|
+
|
|
17
|
+
public set value(value: T) {
|
|
18
|
+
this._value = value;
|
|
19
|
+
if (this.onChange) this.onChange(value);
|
|
20
|
+
this.stateChanges.next();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public get value(): T {
|
|
24
|
+
return this._value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Input() componentId!: string;
|
|
28
|
+
@Input() label!: string;
|
|
29
|
+
@Input() disabled: boolean = false;
|
|
30
|
+
|
|
31
|
+
registerOnChange(fn: any): void {
|
|
32
|
+
this.onChange = fn;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
registerOnTouched(fn: any): void {
|
|
36
|
+
this.onTouched = fn;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setDisabledState?(isDisabled: boolean): void {
|
|
40
|
+
this.disabled = isDisabled;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
writeValue(value: T): void {
|
|
44
|
+
this.value = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input } from '@angular/core';
|
|
2
|
+
import { FormControl } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'kv-error',
|
|
6
|
+
templateUrl: './error.component.html',
|
|
7
|
+
styleUrls: ['./error.component.scss']
|
|
8
|
+
})
|
|
9
|
+
export class ErrorComponent {
|
|
10
|
+
public hasError: boolean | undefined = false;
|
|
11
|
+
|
|
12
|
+
@Input() formControl!: FormControl;
|
|
13
|
+
|
|
14
|
+
@Input('hasError') set setHasError(value: boolean | undefined) {
|
|
15
|
+
this.hasError = value;
|
|
16
|
+
this.emitError.emit(value);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
emitError: EventEmitter<boolean> = new EventEmitter<boolean>();
|
|
20
|
+
|
|
21
|
+
constructor() { }
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
|
|
5
|
+
import { PrimeNgModule } from '../../modules/primeng.module';
|
|
6
|
+
|
|
7
|
+
import { ErrorComponent } from './error.component';
|
|
8
|
+
|
|
9
|
+
@NgModule({
|
|
10
|
+
declarations: [
|
|
11
|
+
ErrorComponent,
|
|
12
|
+
],
|
|
13
|
+
imports: [
|
|
14
|
+
CommonModule,
|
|
15
|
+
FormsModule,
|
|
16
|
+
PrimeNgModule,
|
|
17
|
+
ReactiveFormsModule,
|
|
18
|
+
],
|
|
19
|
+
exports: [
|
|
20
|
+
ErrorComponent,
|
|
21
|
+
]
|
|
22
|
+
})
|
|
23
|
+
export class kvErrorModule { }
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MenuItem } from 'primeng/api';
|
|
2
|
+
import { TableConfigColumn } from './table.config.column';
|
|
3
|
+
import { KvMenuItem } from './kv-menuitem';
|
|
4
|
+
|
|
5
|
+
export interface TableConfig {
|
|
6
|
+
actions: KvMenuItem[];
|
|
7
|
+
columns: TableConfigColumn[];
|
|
8
|
+
title?: string;
|
|
9
|
+
lazy: boolean;
|
|
10
|
+
fieldGroup?: string;
|
|
11
|
+
enableCation?: boolean;
|
|
12
|
+
enableFilter?: boolean;
|
|
13
|
+
enableSelect?: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Provider, forwardRef } from "@angular/core";
|
|
2
|
+
import { NG_VALUE_ACCESSOR } from "@angular/forms";
|
|
3
|
+
import { ComponentService } from '../services/component.service';
|
|
4
|
+
|
|
5
|
+
export function ComponentProviders(ref: any): Provider[] {
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
provide: NG_VALUE_ACCESSOR,
|
|
9
|
+
useExisting: forwardRef(() => ref),
|
|
10
|
+
multi: true,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
provide: ComponentService
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PrimeNGConfig } from 'primeng/api';
|
|
2
|
+
|
|
3
|
+
export class TranslatePrimeng {
|
|
4
|
+
public config(config: PrimeNGConfig): void {
|
|
5
|
+
config.ripple = true;
|
|
6
|
+
|
|
7
|
+
config.setTranslation({
|
|
8
|
+
monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
|
|
9
|
+
monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
|
|
10
|
+
dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sabádo'],
|
|
11
|
+
dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
|
|
12
|
+
dayNamesMin: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
|
|
13
|
+
today: 'Hoje',
|
|
14
|
+
weekHeader: 'Semana',
|
|
15
|
+
emptyMessage: 'Nenhum resultado encontrado',
|
|
16
|
+
emptyFilterMessage: 'Nenhum registro encontrado com o filtro informado',
|
|
17
|
+
weak: 'Fraca',
|
|
18
|
+
medium: 'Média',
|
|
19
|
+
strong: 'Forte',
|
|
20
|
+
passwordPrompt: 'Informe a senha',
|
|
21
|
+
clear: 'Limpar',
|
|
22
|
+
apply: 'Aplicar'
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { AccordionModule } from 'primeng/accordion';
|
|
3
|
+
import { AutoFocusModule } from 'primeng/autofocus';
|
|
4
|
+
import { BadgeModule } from 'primeng/badge';
|
|
5
|
+
import { ButtonModule } from 'primeng/button';
|
|
6
|
+
import { CalendarModule } from 'primeng/calendar';
|
|
7
|
+
import { CardModule } from 'primeng/card';
|
|
8
|
+
import { CarouselModule } from 'primeng/carousel';
|
|
9
|
+
import { CheckboxModule } from 'primeng/checkbox';
|
|
10
|
+
import { ConfirmDialogModule } from 'primeng/confirmdialog';
|
|
11
|
+
import { ConfirmationService, MessageService } from 'primeng/api';
|
|
12
|
+
import { ContextMenuModule } from 'primeng/contextmenu';
|
|
13
|
+
import { DialogModule } from 'primeng/dialog';
|
|
14
|
+
import { DialogService, DynamicDialogRef, DynamicDialogConfig } from 'primeng/dynamicdialog';
|
|
15
|
+
import { DividerModule } from 'primeng/divider';
|
|
16
|
+
import { DropdownModule } from 'primeng/dropdown';
|
|
17
|
+
import { DynamicDialogModule } from 'primeng/dynamicdialog';
|
|
18
|
+
import { InputMaskModule } from 'primeng/inputmask';
|
|
19
|
+
import { InputNumberModule } from 'primeng/inputnumber';
|
|
20
|
+
import { InputSwitchModule } from 'primeng/inputswitch';
|
|
21
|
+
import { InputTextModule } from 'primeng/inputtext';
|
|
22
|
+
import { InputTextareaModule } from 'primeng/inputtextarea';
|
|
23
|
+
import { MenuModule } from 'primeng/menu';
|
|
24
|
+
import { MessageModule } from 'primeng/message';
|
|
25
|
+
import { MessagesModule } from 'primeng/messages';
|
|
26
|
+
import { MultiSelectModule } from 'primeng/multiselect';
|
|
27
|
+
import { OverlayPanelModule } from 'primeng/overlaypanel';
|
|
28
|
+
import { PanelModule } from 'primeng/panel';
|
|
29
|
+
import { PasswordModule } from 'primeng/password';
|
|
30
|
+
import { PickListModule } from 'primeng/picklist';
|
|
31
|
+
import { RadioButtonModule } from 'primeng/radiobutton';
|
|
32
|
+
import { RatingModule } from 'primeng/rating';
|
|
33
|
+
import { RippleModule } from 'primeng/ripple';
|
|
34
|
+
import { SidebarModule } from 'primeng/sidebar';
|
|
35
|
+
import { SkeletonModule } from 'primeng/skeleton';
|
|
36
|
+
import { SpeedDialModule } from 'primeng/speeddial';
|
|
37
|
+
import { SplitButtonModule } from 'primeng/splitbutton';
|
|
38
|
+
import { StepsModule } from 'primeng/steps'
|
|
39
|
+
import { TableModule } from 'primeng/table';
|
|
40
|
+
import { ToastModule } from 'primeng/toast';
|
|
41
|
+
import { ToolbarModule } from 'primeng/toolbar';
|
|
42
|
+
import { TooltipModule } from 'primeng/tooltip';
|
|
43
|
+
import { OverlayModule } from 'primeng/overlay';
|
|
44
|
+
|
|
45
|
+
@NgModule({
|
|
46
|
+
exports: [
|
|
47
|
+
AccordionModule,
|
|
48
|
+
AutoFocusModule,
|
|
49
|
+
BadgeModule,
|
|
50
|
+
ButtonModule,
|
|
51
|
+
CalendarModule,
|
|
52
|
+
CardModule,
|
|
53
|
+
CarouselModule,
|
|
54
|
+
CheckboxModule,
|
|
55
|
+
ConfirmDialogModule,
|
|
56
|
+
ContextMenuModule,
|
|
57
|
+
DialogModule,
|
|
58
|
+
DividerModule,
|
|
59
|
+
DropdownModule,
|
|
60
|
+
DynamicDialogModule,
|
|
61
|
+
InputMaskModule,
|
|
62
|
+
InputNumberModule,
|
|
63
|
+
InputSwitchModule,
|
|
64
|
+
InputTextModule,
|
|
65
|
+
InputTextareaModule,
|
|
66
|
+
MenuModule,
|
|
67
|
+
MessageModule,
|
|
68
|
+
MessagesModule,
|
|
69
|
+
MultiSelectModule,
|
|
70
|
+
OverlayPanelModule,
|
|
71
|
+
OverlayPanelModule,
|
|
72
|
+
PanelModule,
|
|
73
|
+
PasswordModule,
|
|
74
|
+
PickListModule,
|
|
75
|
+
RadioButtonModule,
|
|
76
|
+
RatingModule,
|
|
77
|
+
RippleModule,
|
|
78
|
+
SidebarModule,
|
|
79
|
+
SkeletonModule,
|
|
80
|
+
SpeedDialModule,
|
|
81
|
+
SplitButtonModule,
|
|
82
|
+
StepsModule,
|
|
83
|
+
TableModule,
|
|
84
|
+
ToastModule,
|
|
85
|
+
ToolbarModule,
|
|
86
|
+
TooltipModule,
|
|
87
|
+
OverlayModule
|
|
88
|
+
],
|
|
89
|
+
providers: [
|
|
90
|
+
ConfirmationService,
|
|
91
|
+
DialogService,
|
|
92
|
+
DynamicDialogRef,
|
|
93
|
+
DynamicDialogConfig,
|
|
94
|
+
MessageService,
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
export class PrimeNgModule { }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Injectable, Injector } from '@angular/core';
|
|
2
|
+
import { FormControl, FormControlName, FormGroupDirective, NgControl } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class ComponentService {
|
|
6
|
+
|
|
7
|
+
constructor(public readonly injector: Injector, public changeDetectorRef: ChangeDetectorRef) { }
|
|
8
|
+
|
|
9
|
+
getFormControl(): FormControl<any> | undefined {
|
|
10
|
+
try {
|
|
11
|
+
const control = this.injector.get(NgControl);
|
|
12
|
+
if (control.constructor === FormControlName) {
|
|
13
|
+
return this.injector.get(FormGroupDirective).getControl(control as FormControlName);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
catch(ex){
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|