gentera-rdnd 0.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/.editorconfig +16 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/tasks.json +42 -0
- package/README.md +27 -0
- package/angular.json +40 -0
- package/package.json +44 -0
- package/projects/gentera-rdnd/README.md +24 -0
- package/projects/gentera-rdnd/ng-package.json +7 -0
- package/projects/gentera-rdnd/package.json +12 -0
- package/projects/gentera-rdnd/src/lib/components/button/button.component.html +21 -0
- package/projects/gentera-rdnd/src/lib/components/button/button.component.scss +41 -0
- package/projects/gentera-rdnd/src/lib/components/button/button.component.ts +81 -0
- package/projects/gentera-rdnd/src/lib/gentera-rdnd.component.ts +16 -0
- package/projects/gentera-rdnd/src/lib/gentera-rdnd.service.ts +9 -0
- package/projects/gentera-rdnd/src/lib/hooks/button.service.ts +31 -0
- package/projects/gentera-rdnd/src/lib/hooks/input.service.ts +73 -0
- package/projects/gentera-rdnd/src/lib/hooks/modal.service.ts +88 -0
- package/projects/gentera-rdnd/src/lib/styles/colors.ts +55 -0
- package/projects/gentera-rdnd/src/lib/styles/themes.ts +98 -0
- package/projects/gentera-rdnd/src/public-api.ts +5 -0
- package/projects/gentera-rdnd/tsconfig.lib.json +28 -0
- package/projects/gentera-rdnd/tsconfig.lib.prod.json +11 -0
- package/projects/gentera-rdnd/tsconfig.spec.json +15 -0
- package/tsconfig.json +37 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Editor configuration, see https://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.ts]
|
|
12
|
+
quote_type = single
|
|
13
|
+
|
|
14
|
+
[*.md]
|
|
15
|
+
max_line_length = off
|
|
16
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"configurations": [
|
|
5
|
+
{
|
|
6
|
+
"name": "ng serve",
|
|
7
|
+
"type": "chrome",
|
|
8
|
+
"request": "launch",
|
|
9
|
+
"preLaunchTask": "npm: start",
|
|
10
|
+
"url": "http://localhost:4200/"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "ng test",
|
|
14
|
+
"type": "chrome",
|
|
15
|
+
"request": "launch",
|
|
16
|
+
"preLaunchTask": "npm: test",
|
|
17
|
+
"url": "http://localhost:9876/debug.html"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"tasks": [
|
|
5
|
+
{
|
|
6
|
+
"type": "npm",
|
|
7
|
+
"script": "start",
|
|
8
|
+
"isBackground": true,
|
|
9
|
+
"problemMatcher": {
|
|
10
|
+
"owner": "typescript",
|
|
11
|
+
"pattern": "$tsc",
|
|
12
|
+
"background": {
|
|
13
|
+
"activeOnStart": true,
|
|
14
|
+
"beginsPattern": {
|
|
15
|
+
"regexp": "(.*?)"
|
|
16
|
+
},
|
|
17
|
+
"endsPattern": {
|
|
18
|
+
"regexp": "bundle generation complete"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "npm",
|
|
25
|
+
"script": "test",
|
|
26
|
+
"isBackground": true,
|
|
27
|
+
"problemMatcher": {
|
|
28
|
+
"owner": "typescript",
|
|
29
|
+
"pattern": "$tsc",
|
|
30
|
+
"background": {
|
|
31
|
+
"activeOnStart": true,
|
|
32
|
+
"beginsPattern": {
|
|
33
|
+
"regexp": "(.*?)"
|
|
34
|
+
},
|
|
35
|
+
"endsPattern": {
|
|
36
|
+
"regexp": "bundle generation complete"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# GenteraRdnd
|
|
2
|
+
|
|
3
|
+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.1.4.
|
|
4
|
+
|
|
5
|
+
## Development server
|
|
6
|
+
|
|
7
|
+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
|
|
8
|
+
|
|
9
|
+
## Code scaffolding
|
|
10
|
+
|
|
11
|
+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
|
12
|
+
|
|
13
|
+
## Build
|
|
14
|
+
|
|
15
|
+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
16
|
+
|
|
17
|
+
## Running unit tests
|
|
18
|
+
|
|
19
|
+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
20
|
+
|
|
21
|
+
## Running end-to-end tests
|
|
22
|
+
|
|
23
|
+
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
|
|
24
|
+
|
|
25
|
+
## Further help
|
|
26
|
+
|
|
27
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
package/angular.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"newProjectRoot": "projects",
|
|
5
|
+
"projects": {
|
|
6
|
+
"gentera-rdnd": {
|
|
7
|
+
"projectType": "library",
|
|
8
|
+
"root": "projects/gentera-rdnd",
|
|
9
|
+
"sourceRoot": "projects/gentera-rdnd/src",
|
|
10
|
+
"prefix": "lib",
|
|
11
|
+
"architect": {
|
|
12
|
+
"build": {
|
|
13
|
+
"builder": "@angular-devkit/build-angular:ng-packagr",
|
|
14
|
+
"options": {
|
|
15
|
+
"project": "projects/gentera-rdnd/ng-package.json"
|
|
16
|
+
},
|
|
17
|
+
"configurations": {
|
|
18
|
+
"production": {
|
|
19
|
+
"tsConfig": "projects/gentera-rdnd/tsconfig.lib.prod.json"
|
|
20
|
+
},
|
|
21
|
+
"development": {
|
|
22
|
+
"tsConfig": "projects/gentera-rdnd/tsconfig.lib.json"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"defaultConfiguration": "production"
|
|
26
|
+
},
|
|
27
|
+
"test": {
|
|
28
|
+
"builder": "@angular-devkit/build-angular:karma",
|
|
29
|
+
"options": {
|
|
30
|
+
"tsConfig": "projects/gentera-rdnd/tsconfig.spec.json",
|
|
31
|
+
"polyfills": [
|
|
32
|
+
"zone.js",
|
|
33
|
+
"zone.js/testing"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gentera-rdnd",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"ng": "ng",
|
|
6
|
+
"start": "ng serve",
|
|
7
|
+
"build": "ng build",
|
|
8
|
+
"watch": "ng build --watch --configuration development",
|
|
9
|
+
"test": "ng test"
|
|
10
|
+
},
|
|
11
|
+
"private": false,
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@angular/animations": "^18.1.0",
|
|
14
|
+
"@angular/common": "^18.1.0",
|
|
15
|
+
"@angular/compiler": "^18.1.0",
|
|
16
|
+
"@angular/core": "^18.1.0",
|
|
17
|
+
"@angular/forms": "^18.1.0",
|
|
18
|
+
"@angular/platform-browser": "^18.1.0",
|
|
19
|
+
"@angular/platform-browser-dynamic": "^18.1.0",
|
|
20
|
+
"@angular/router": "^18.1.0",
|
|
21
|
+
"@fortawesome/angular-fontawesome": "^0.15.0",
|
|
22
|
+
"@fortawesome/free-brands-svg-icons": "^6.5.2",
|
|
23
|
+
"@fortawesome/free-regular-svg-icons": "^6.5.2",
|
|
24
|
+
"@fortawesome/free-solid-svg-icons": "^6.5.2",
|
|
25
|
+
"axios": "^1.9.0",
|
|
26
|
+
"rxjs": "~7.8.0",
|
|
27
|
+
"tslib": "^2.3.0",
|
|
28
|
+
"zone.js": "~0.14.3"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@angular-devkit/build-angular": "^18.2.19",
|
|
32
|
+
"@angular/cli": "^18.1.4",
|
|
33
|
+
"@angular/compiler-cli": "^18.1.0",
|
|
34
|
+
"@types/jasmine": "~5.1.0",
|
|
35
|
+
"jasmine-core": "~5.1.0",
|
|
36
|
+
"karma": "~6.4.0",
|
|
37
|
+
"karma-chrome-launcher": "~3.2.0",
|
|
38
|
+
"karma-coverage": "~2.2.0",
|
|
39
|
+
"karma-jasmine": "~5.1.0",
|
|
40
|
+
"karma-jasmine-html-reporter": "~2.1.0",
|
|
41
|
+
"ng-packagr": "^18.2.0",
|
|
42
|
+
"typescript": "~5.5.2"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# GenteraRdnd
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project gentera-rdnd` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project gentera-rdnd`.
|
|
8
|
+
> Note: Don't forget to add `--project gentera-rdnd` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
Run `ng build gentera-rdnd` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
## Publishing
|
|
15
|
+
|
|
16
|
+
After building your library with `ng build gentera-rdnd`, go to the dist folder `cd dist/gentera-rdnd` and run `npm publish`.
|
|
17
|
+
|
|
18
|
+
## Running unit tests
|
|
19
|
+
|
|
20
|
+
Run `ng test gentera-rdnd` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
+
|
|
22
|
+
## Further help
|
|
23
|
+
|
|
24
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<button
|
|
2
|
+
[ngClass]="{
|
|
3
|
+
'full': size === 'full',
|
|
4
|
+
'contained': size === 'contained',
|
|
5
|
+
'bordered': borders,
|
|
6
|
+
'disabled': disabled
|
|
7
|
+
}"
|
|
8
|
+
[style.background]="disabled ? themes.disabled.default : theme.default"
|
|
9
|
+
[style.color]="theme.fontColor"
|
|
10
|
+
[style.border]="borders ? '1px solid ' + theme.border : 'none'"
|
|
11
|
+
[style.cursor]="disabled ? 'not-allowed' : 'pointer'"
|
|
12
|
+
[attr.type]="type"
|
|
13
|
+
[disabled]="disabled"
|
|
14
|
+
|
|
15
|
+
(mouseleave)="onMouseLeave()"
|
|
16
|
+
(click)="handleClick($event)"
|
|
17
|
+
(mouseenter)="onMouseEnter()"
|
|
18
|
+
>
|
|
19
|
+
<fa-icon *ngIf="icon" [icon]="icon" class="icon"></fa-icon>
|
|
20
|
+
{{ text }}
|
|
21
|
+
</button>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
button {
|
|
2
|
+
height: 40px;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
gap: 4px;
|
|
7
|
+
padding: 10px;
|
|
8
|
+
font-size: 14px;
|
|
9
|
+
transition: all 0.3s ease;
|
|
10
|
+
|
|
11
|
+
&.full {
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.contained {
|
|
16
|
+
width: fit-content;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.bordered {
|
|
20
|
+
border-radius: 5px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.disabled {
|
|
24
|
+
pointer-events: none;
|
|
25
|
+
background-color: #ddd;
|
|
26
|
+
border-color: transparent !important;
|
|
27
|
+
color: #9E9E9E !important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.icon {
|
|
31
|
+
transition: all 0.3s ease;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
opacity: 0.8;
|
|
36
|
+
}
|
|
37
|
+
&:active {
|
|
38
|
+
transform: scale(0.99);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Component, Input, Output, EventEmitter, OnInit, OnDestroy } from '@angular/core';
|
|
2
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import {Observable, Subscription} from 'rxjs';
|
|
4
|
+
import {FaIconComponent} from "@fortawesome/angular-fontawesome";
|
|
5
|
+
import {NgClass, NgIf} from "@angular/common";
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import {themes} from '@styles/themes';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import {ButtonService, ButtonServiceType} from "@hooks/button.service";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'rdnd-button',
|
|
14
|
+
templateUrl: './button.component.html',
|
|
15
|
+
standalone: true,
|
|
16
|
+
imports: [
|
|
17
|
+
FaIconComponent,
|
|
18
|
+
NgIf,
|
|
19
|
+
NgClass
|
|
20
|
+
],
|
|
21
|
+
styleUrls: ['./button.component.scss']
|
|
22
|
+
})
|
|
23
|
+
export class RdndButton implements OnInit, OnDestroy {
|
|
24
|
+
@Input() id!: string;
|
|
25
|
+
@Input() icon?: IconDefinition;
|
|
26
|
+
@Input() text: string = 'Enviar';
|
|
27
|
+
@Input() theme: any = themes.magenta;
|
|
28
|
+
@Input() size: 'contained' | 'full' = 'full';
|
|
29
|
+
@Input() type: 'button' | 'submit' | 'reset' = 'submit';
|
|
30
|
+
@Input() borders: boolean = true;
|
|
31
|
+
@Input() disabled: boolean = false;
|
|
32
|
+
|
|
33
|
+
@Output() callback: EventEmitter<void> = new EventEmitter<void>();
|
|
34
|
+
|
|
35
|
+
protected readonly themes = themes;
|
|
36
|
+
private subscription!: Subscription;
|
|
37
|
+
hoverBackgroundColor: string = this.theme.default;
|
|
38
|
+
|
|
39
|
+
buttonControl!: ButtonServiceType ;
|
|
40
|
+
|
|
41
|
+
constructor(private buttonService: ButtonService) {
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ngOnInit(): void {
|
|
45
|
+
this.buttonControl = this.buttonService.useButton(this.id);
|
|
46
|
+
|
|
47
|
+
this.subscription = new Subscription( () =>
|
|
48
|
+
this.buttonControl.disabled$.subscribe((isDisabled: boolean) => {
|
|
49
|
+
this.disabled = isDisabled;
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ngOnDestroy(): void {
|
|
56
|
+
if(this.subscription){
|
|
57
|
+
this.subscription.unsubscribe();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
handleClick(event: MouseEvent): void {
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
if (!this.disabled && this.type !== 'submit') {
|
|
64
|
+
this.callback.emit();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onMouseEnter() {
|
|
69
|
+
if (!this.disabled) {
|
|
70
|
+
this.hoverBackgroundColor = this.theme.hover;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
onMouseLeave() {
|
|
75
|
+
if (!this.disabled) {
|
|
76
|
+
this.hoverBackgroundColor = this.theme.default;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected readonly event = event;
|
|
81
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'lib-gentera-rdnd',
|
|
5
|
+
standalone: true,
|
|
6
|
+
imports: [],
|
|
7
|
+
template: `
|
|
8
|
+
<p>
|
|
9
|
+
gentera-rdnd works!
|
|
10
|
+
</p>
|
|
11
|
+
`,
|
|
12
|
+
styles: ``
|
|
13
|
+
})
|
|
14
|
+
export class GenteraRdndComponent {
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
export interface ButtonServiceType {
|
|
5
|
+
enable: () => void;
|
|
6
|
+
disable: () => void;
|
|
7
|
+
disabled$: Observable<boolean>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@Injectable({
|
|
11
|
+
providedIn: 'root',
|
|
12
|
+
})
|
|
13
|
+
export class ButtonService {
|
|
14
|
+
private buttonsState: { [id: string]: BehaviorSubject<boolean> } = {};
|
|
15
|
+
|
|
16
|
+
private ensureButtonExists(id: string): void {
|
|
17
|
+
if (!this.buttonsState[id]) {
|
|
18
|
+
this.buttonsState[id] = new BehaviorSubject<boolean>(false);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
useButton(id: string): ButtonServiceType {
|
|
23
|
+
this.ensureButtonExists(id);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
disabled$: this.buttonsState[id].asObservable(),
|
|
27
|
+
enable: () => this.buttonsState[id].next(false),
|
|
28
|
+
disable: () => this.buttonsState[id].next(true),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import {BehaviorSubject, Observable} from 'rxjs';
|
|
3
|
+
import { FormControl, ValidationErrors } from '@angular/forms';
|
|
4
|
+
|
|
5
|
+
export type InputStateType = {
|
|
6
|
+
isValid: boolean;
|
|
7
|
+
valid: Observable<boolean>;
|
|
8
|
+
errorMessage: Observable<string | null>;
|
|
9
|
+
setValid: (isValid: boolean) => void;
|
|
10
|
+
setErrorMessage: (message: string | null) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
@Injectable({
|
|
14
|
+
providedIn: 'root',
|
|
15
|
+
})
|
|
16
|
+
export class InputService {
|
|
17
|
+
|
|
18
|
+
private inputState: {
|
|
19
|
+
[id: string]: {
|
|
20
|
+
valid$: BehaviorSubject<boolean>;
|
|
21
|
+
errorMessage$: BehaviorSubject<string | null>;
|
|
22
|
+
};
|
|
23
|
+
} = {};
|
|
24
|
+
|
|
25
|
+
private ensureInputExists(id: string): void {
|
|
26
|
+
if (!this.inputState[id]) {
|
|
27
|
+
this.inputState[id] = {
|
|
28
|
+
valid$: new BehaviorSubject<boolean>(false),
|
|
29
|
+
errorMessage$: new BehaviorSubject<string | null>(null),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
useInput(id: string): InputStateType {
|
|
35
|
+
this.ensureInputExists(id);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
isValid: this.inputState[id].valid$.value,
|
|
39
|
+
valid: this.inputState[id].valid$.asObservable(),
|
|
40
|
+
errorMessage: this.inputState[id].errorMessage$.asObservable(),
|
|
41
|
+
setValid: (isValid: boolean) => this.inputState[id].valid$.next(isValid),
|
|
42
|
+
setErrorMessage: (message: string | null) =>
|
|
43
|
+
this.inputState[id].errorMessage$.next(message),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
updateInputState(control: FormControl, id: string): void {
|
|
48
|
+
this.ensureInputExists(id);
|
|
49
|
+
|
|
50
|
+
const errors: ValidationErrors | null = control.errors;
|
|
51
|
+
|
|
52
|
+
if (control.valid) {
|
|
53
|
+
this.inputState[id].valid$.next(true);
|
|
54
|
+
this.inputState[id].errorMessage$.next(null);
|
|
55
|
+
} else {
|
|
56
|
+
this.inputState[id].valid$.next(false);
|
|
57
|
+
this.inputState[id].errorMessage$.next(this.getErrorMessage(errors));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private getErrorMessage(errors: ValidationErrors | null): string | null {
|
|
62
|
+
if (!errors) return null;
|
|
63
|
+
|
|
64
|
+
if (errors['required']) return 'Este campo es obligatorio';
|
|
65
|
+
if (errors['minlength'])
|
|
66
|
+
return `Mínimo ${errors['minlength'].requiredLength} caracteres requeridos`;
|
|
67
|
+
if (errors['maxlength'])
|
|
68
|
+
return `Máximo ${errors['maxlength'].requiredLength} caracteres permitidos`;
|
|
69
|
+
if (errors['email']) return 'Formato de correo inválido';
|
|
70
|
+
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {Injectable, ComponentRef} from '@angular/core';
|
|
2
|
+
import {ApplicationRef, ComponentFactoryResolver, Injector} from '@angular/core';
|
|
3
|
+
import {ModalComponent} from '../components/modal/modal.component';
|
|
4
|
+
import {faCircleCheck, faCircleQuestion, faCircleXmark, IconDefinition} from '@fortawesome/free-solid-svg-icons';
|
|
5
|
+
import {faTriangleExclamation} from "@fortawesome/free-solid-svg-icons/faTriangleExclamation";
|
|
6
|
+
import {themes} from "../styles/themes";
|
|
7
|
+
import {faQuestion} from "@fortawesome/free-solid-svg-icons/faQuestion";
|
|
8
|
+
import {faTable} from "@fortawesome/free-solid-svg-icons/faTable";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@Injectable({providedIn: 'root'})
|
|
12
|
+
export class ModalService {
|
|
13
|
+
private modalRef: ComponentRef<ModalComponent> | null = null;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
private appRef: ApplicationRef,
|
|
17
|
+
private componentFactoryResolver: ComponentFactoryResolver,
|
|
18
|
+
private injector: Injector
|
|
19
|
+
) {
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
openModal(title: string, content: string, type: 'success' | 'error' | 'question' | 'warning' | 'info' = 'success', confirmText = 'Continuar', cancelText = 'Cancelar'): Promise<boolean> {
|
|
23
|
+
if (this.modalRef) return Promise.resolve(false);
|
|
24
|
+
|
|
25
|
+
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
26
|
+
this.modalRef = factory.create(this.injector);
|
|
27
|
+
|
|
28
|
+
this.modalRef.instance.title = title;
|
|
29
|
+
this.modalRef.instance.type = type;
|
|
30
|
+
this.modalRef.instance.theme = this.getStyleTheme(type);
|
|
31
|
+
this.modalRef.instance.content = content;
|
|
32
|
+
this.modalRef.instance.icon = this.getIcon(type);
|
|
33
|
+
this.modalRef.instance.confirmText = confirmText;
|
|
34
|
+
this.modalRef.instance.cancelText = cancelText;
|
|
35
|
+
|
|
36
|
+
const result = new Promise<boolean>((resolve) => {
|
|
37
|
+
this.modalRef!.instance.close.subscribe((res: boolean) => {
|
|
38
|
+
this.closeModal();
|
|
39
|
+
resolve(res);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
this.appRef.attachView(this.modalRef.hostView);
|
|
44
|
+
const domElem = (this.modalRef.hostView as any).rootNodes[0] as HTMLElement;
|
|
45
|
+
document.body.appendChild(domElem);
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getStyleTheme = (theme: 'success' | 'error' | 'question' | 'warning' | 'info') => {
|
|
51
|
+
switch (theme) {
|
|
52
|
+
case "success":
|
|
53
|
+
return themes.green;
|
|
54
|
+
case 'error':
|
|
55
|
+
return themes.magentaNormal;
|
|
56
|
+
case 'question':
|
|
57
|
+
return themes.purple
|
|
58
|
+
case 'warning':
|
|
59
|
+
return themes.yellow
|
|
60
|
+
case 'info':
|
|
61
|
+
return themes.purple
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
closeModal(): void {
|
|
66
|
+
if (this.modalRef) {
|
|
67
|
+
this.appRef.detachView(this.modalRef.hostView);
|
|
68
|
+
this.modalRef.destroy();
|
|
69
|
+
this.modalRef = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getIcon(theme: 'success' | 'error' | 'question' | 'warning' | 'info'): IconDefinition {
|
|
74
|
+
switch (theme) {
|
|
75
|
+
case 'error':
|
|
76
|
+
return faTriangleExclamation;
|
|
77
|
+
case 'question':
|
|
78
|
+
return faCircleQuestion
|
|
79
|
+
case "success":
|
|
80
|
+
return faCircleCheck
|
|
81
|
+
case "warning":
|
|
82
|
+
return faTriangleExclamation;
|
|
83
|
+
case "info":
|
|
84
|
+
return faTable;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export const colors = {
|
|
2
|
+
black: '#171717',
|
|
3
|
+
'black-light': '#343434',
|
|
4
|
+
'black-dark': '#000000',
|
|
5
|
+
'black-navy': '#191a21',
|
|
6
|
+
|
|
7
|
+
'xs-dark-gray': '#5A5A5A',
|
|
8
|
+
'dark-gray': '#9E9E9E',
|
|
9
|
+
'medium-gray': '#AFAFAF',
|
|
10
|
+
gray: '#C4C4C4',
|
|
11
|
+
'light-gray': '#C6C6C6',
|
|
12
|
+
'xs-light-gray': '#DFDFDF',
|
|
13
|
+
'xxs-light-gray': '#F2F2F2',
|
|
14
|
+
'soft-white': '#EEEEEE',
|
|
15
|
+
|
|
16
|
+
green: '#28a746',
|
|
17
|
+
'green-medium': '#208B6A',
|
|
18
|
+
'green-dark': '#156a29',
|
|
19
|
+
'green-xs-dark': 'rgb(33, 97, 90)',
|
|
20
|
+
'green-1': '#009F74',
|
|
21
|
+
'green-2': '#00B987',
|
|
22
|
+
'green-3': '#19C496',
|
|
23
|
+
'green-light': '#84ce94',
|
|
24
|
+
'green-4': '#50D8B3',
|
|
25
|
+
'green-5': '#83E6B8',
|
|
26
|
+
|
|
27
|
+
"blue-info": '#7390EC',
|
|
28
|
+
blue: '#3360fa',
|
|
29
|
+
'blue-dark': '#1a389e',
|
|
30
|
+
'blue-light': '#3390fa',
|
|
31
|
+
'blue-gray-soft': '#E5EAEDFF',
|
|
32
|
+
'blue-gray-light': 'rgb(244,247,250)',
|
|
33
|
+
|
|
34
|
+
orange: '#F77C00',
|
|
35
|
+
'orange-light': '#F7B500',
|
|
36
|
+
|
|
37
|
+
yellow: '#F09D00',
|
|
38
|
+
"yellow-normal": '#FFBC57',
|
|
39
|
+
'yellow-light': '#FFC400',
|
|
40
|
+
|
|
41
|
+
purple: '#6459be',
|
|
42
|
+
'purple-light': 'rgb(149, 138, 242)',
|
|
43
|
+
|
|
44
|
+
red: '#E60018',
|
|
45
|
+
'red-light': '#e74364',
|
|
46
|
+
'red-medium': '#c51628',
|
|
47
|
+
|
|
48
|
+
"white": "#FFFFFF",
|
|
49
|
+
"magentaStart": "#C2185B",
|
|
50
|
+
"magentaEnd": "#7E0083",
|
|
51
|
+
'magenta-normal': '#B41364',
|
|
52
|
+
|
|
53
|
+
disabled: '#C6C6C6',
|
|
54
|
+
"disabledText": "#9E9E9E",
|
|
55
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {colors} from './colors';
|
|
2
|
+
|
|
3
|
+
export const themes = {
|
|
4
|
+
disabled: {
|
|
5
|
+
default: colors.disabled,
|
|
6
|
+
hover: colors.disabled,
|
|
7
|
+
border: 'transparent',
|
|
8
|
+
active: colors.disabled,
|
|
9
|
+
fontColor: colors.disabledText,
|
|
10
|
+
},
|
|
11
|
+
magenta: {
|
|
12
|
+
default: `linear-gradient(to right, ${colors.magentaStart}, ${colors.magentaEnd})`,
|
|
13
|
+
hover: `linear-gradient(to right, ${colors.magentaEnd}, ${colors.magentaStart})`,
|
|
14
|
+
//default: `${colors.magentaStart}`,
|
|
15
|
+
border: 'transparent',
|
|
16
|
+
active: colors.magentaStart, // Color al hacer clic
|
|
17
|
+
fontColor: colors.white, // Texto en blanco
|
|
18
|
+
},
|
|
19
|
+
magentaSolid: {
|
|
20
|
+
default: `${colors.magentaStart}`,
|
|
21
|
+
hover: `${colors.magentaEnd}`,
|
|
22
|
+
border: 'transparent',
|
|
23
|
+
active: colors.magentaStart, // Color al hacer clic
|
|
24
|
+
fontColor: colors.white, // Texto en blanco
|
|
25
|
+
},
|
|
26
|
+
magentaNormal: {
|
|
27
|
+
default: `${colors["magenta-normal"]}`,
|
|
28
|
+
hover: `${colors.magentaEnd}`,
|
|
29
|
+
border: 'transparent',
|
|
30
|
+
active: colors["magenta-normal"], // Color al hacer clic
|
|
31
|
+
fontColor: colors.white, // Texto en blanco
|
|
32
|
+
},
|
|
33
|
+
gray: {
|
|
34
|
+
default: `${colors["light-gray"]}`,
|
|
35
|
+
hover: `linear-gradient(to right, ${colors.magentaEnd}, ${colors.magentaStart})`,
|
|
36
|
+
//default: `${colors.magentaStart}`,
|
|
37
|
+
border: 'transparent',
|
|
38
|
+
active: colors.magentaStart, // Color al hacer clic
|
|
39
|
+
fontColor: colors.white, // Texto en blanco
|
|
40
|
+
},
|
|
41
|
+
green: {
|
|
42
|
+
default: `${colors["green-medium"]}`,
|
|
43
|
+
hover: colors.green,
|
|
44
|
+
border: 'transparent',
|
|
45
|
+
active: colors["green-xs-dark"],
|
|
46
|
+
fontColor: colors.white,
|
|
47
|
+
},
|
|
48
|
+
red: {
|
|
49
|
+
default: `${colors["red-medium"]}`,
|
|
50
|
+
hover: colors.red,
|
|
51
|
+
border: 'transparent',
|
|
52
|
+
active: colors["red"],
|
|
53
|
+
fontColor: colors.white,
|
|
54
|
+
},
|
|
55
|
+
bordered: {
|
|
56
|
+
default: 'transparent',
|
|
57
|
+
hover: 'transparent',
|
|
58
|
+
border: colors.magentaStart,
|
|
59
|
+
active: 'transparent',
|
|
60
|
+
fontColor: colors.magentaStart
|
|
61
|
+
},
|
|
62
|
+
borderedWhite: {
|
|
63
|
+
default: 'white',
|
|
64
|
+
hover: 'white',
|
|
65
|
+
border: colors.magentaStart,
|
|
66
|
+
active: 'white',
|
|
67
|
+
fontColor: colors.magentaStart
|
|
68
|
+
},
|
|
69
|
+
transparent: {
|
|
70
|
+
default: 'transparent',
|
|
71
|
+
hover: 'transparent',
|
|
72
|
+
border: 'transparent',
|
|
73
|
+
active: 'transparent',
|
|
74
|
+
fontColor: colors.magentaStart
|
|
75
|
+
},
|
|
76
|
+
purple: {
|
|
77
|
+
default: `${colors['blue-info']}`,
|
|
78
|
+
hover: colors["purple-light"],
|
|
79
|
+
border: 'transparent',
|
|
80
|
+
active: colors.purple,
|
|
81
|
+
fontColor: colors.white,
|
|
82
|
+
},
|
|
83
|
+
yellow: {
|
|
84
|
+
default: `${colors['yellow-normal']}`,
|
|
85
|
+
hover: colors["yellow"],
|
|
86
|
+
border: 'transparent',
|
|
87
|
+
active: colors["yellow-light"],
|
|
88
|
+
fontColor: colors.white,
|
|
89
|
+
},
|
|
90
|
+
blue: {
|
|
91
|
+
default: `${colors['yellow-normal']}`,
|
|
92
|
+
hover: colors["yellow"],
|
|
93
|
+
border: 'transparent',
|
|
94
|
+
active: colors["yellow-light"],
|
|
95
|
+
fontColor: colors.white,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"baseUrl": "./",
|
|
7
|
+
"outDir": "../../out-tsc/lib",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationMap": true,
|
|
10
|
+
"inlineSources": true,
|
|
11
|
+
"types": [],
|
|
12
|
+
"experimentalDecorators": true,
|
|
13
|
+
"moduleResolution": "bundler",
|
|
14
|
+
"importHelpers": true,
|
|
15
|
+
"paths": {
|
|
16
|
+
"@components/*": ["src/lib/components/*"],
|
|
17
|
+
"@assets/*": ["src/lib/assets/*"],
|
|
18
|
+
"@services/*": ["src/lib/services/*"],
|
|
19
|
+
"@types/*": ["src/lib/interfaces/*"],
|
|
20
|
+
"@hooks/*": ["src/lib/hooks/*"],
|
|
21
|
+
"@styles/*": ["src/lib/styles/*"],
|
|
22
|
+
"@utils/*": ["src/lib/utils/*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"exclude": [
|
|
26
|
+
"**/*.spec.ts"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.lib.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"declarationMap": false
|
|
7
|
+
},
|
|
8
|
+
"angularCompilerOptions": {
|
|
9
|
+
"compilationMode": "partial"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/spec",
|
|
7
|
+
"types": [
|
|
8
|
+
"jasmine"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"**/*.spec.ts",
|
|
13
|
+
"**/*.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"compileOnSave": false,
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "./dist/out-tsc",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noImplicitOverride": true,
|
|
9
|
+
"paths": {
|
|
10
|
+
"gentera-rdnd": [
|
|
11
|
+
"./dist/gentera-rdnd"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
15
|
+
"noImplicitReturns": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"declaration": false,
|
|
21
|
+
"experimentalDecorators": true,
|
|
22
|
+
"moduleResolution": "bundler",
|
|
23
|
+
"importHelpers": true,
|
|
24
|
+
"target": "ES2022",
|
|
25
|
+
"module": "ES2022",
|
|
26
|
+
"lib": [
|
|
27
|
+
"ES2022",
|
|
28
|
+
"dom"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"angularCompilerOptions": {
|
|
32
|
+
"enableI18nLegacyMessageIdFormat": false,
|
|
33
|
+
"strictInjectionParameters": true,
|
|
34
|
+
"strictInputAccessModifiers": true,
|
|
35
|
+
"strictTemplates": true
|
|
36
|
+
}
|
|
37
|
+
}
|