@dropi/ui-components 1.0.4 → 1.0.6
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/README.md +44 -97
- package/dist/README.md +44 -97
- package/dist/esm2022/index.mjs +2 -2
- package/dist/esm2022/lib/elements-registry.mjs +29 -2
- package/dist/fesm2022/dropi-ui-components.mjs +25 -22
- package/dist/fesm2022/dropi-ui-components.mjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/lib/elements-registry.d.ts +7 -23
- package/package.json +8 -5
- package/scripts/init.js +65 -0
- package/src/components-source/alert/alert.component.ts +56 -40
- package/src/components-source/dropi-search/dropi-search.component.ts +83 -63
- package/src/components-source/dropi-switch/dropi-switch.component.ts +8 -11
- package/src/components-source/dropi-tag/dropi-tag.component.ts +45 -35
- package/src/components-source/input/input.component.ts +21 -14
- package/src/index.ts +1 -0
- package/src/lib/elements-registry.ts +44 -4
- package/src/libreria work space.code-workspace +11 -0
|
@@ -1,43 +1,52 @@
|
|
|
1
|
-
import { CommonModule } from
|
|
2
|
-
import { Component, Input, OnInit } from
|
|
3
|
-
import { IconComponent } from
|
|
4
|
-
import { trigger, transition, style, animate } from
|
|
1
|
+
import { CommonModule } from "@angular/common";
|
|
2
|
+
import { Component, Input, OnInit } from "@angular/core";
|
|
3
|
+
import { IconComponent } from "../icon/icon.component";
|
|
4
|
+
import { trigger, transition, style, animate } from "@angular/animations";
|
|
5
5
|
|
|
6
|
-
export type tagStates =
|
|
7
|
-
|
|
6
|
+
export type tagStates =
|
|
7
|
+
| "default"
|
|
8
|
+
| "success"
|
|
9
|
+
| "info"
|
|
10
|
+
| "warning"
|
|
11
|
+
| "error"
|
|
12
|
+
| "legacy";
|
|
13
|
+
export type tagTypes = "primary" | "secondary";
|
|
8
14
|
|
|
9
15
|
@Component({
|
|
10
|
-
selector:
|
|
11
|
-
templateUrl:
|
|
12
|
-
styleUrls: [
|
|
16
|
+
selector: "dropi-wc-tag",
|
|
17
|
+
templateUrl: "./dropi-tag.component.html",
|
|
18
|
+
styleUrls: ["./dropi-tag.component.scss"],
|
|
13
19
|
standalone: true,
|
|
14
20
|
imports: [CommonModule, IconComponent],
|
|
15
21
|
animations: [
|
|
16
|
-
trigger(
|
|
17
|
-
transition(
|
|
18
|
-
style({ opacity: 0, transform:
|
|
19
|
-
animate(
|
|
22
|
+
trigger("fade", [
|
|
23
|
+
transition(":enter", [
|
|
24
|
+
style({ opacity: 0, transform: "scale(0.8)" }),
|
|
25
|
+
animate("200ms ease-out", style({ opacity: 1, transform: "scale(1)" })),
|
|
20
26
|
]),
|
|
21
|
-
transition(
|
|
22
|
-
animate(
|
|
27
|
+
transition(":leave", [
|
|
28
|
+
animate(
|
|
29
|
+
"150ms ease-in",
|
|
30
|
+
style({ opacity: 0, transform: "scale(0.8)" }),
|
|
31
|
+
),
|
|
23
32
|
]),
|
|
24
33
|
]),
|
|
25
34
|
],
|
|
26
35
|
})
|
|
27
36
|
export class DropiTagComponent implements OnInit {
|
|
28
|
-
@Input() type: tagTypes =
|
|
29
|
-
@Input() state: tagStates =
|
|
37
|
+
@Input() type: tagTypes = "primary";
|
|
38
|
+
@Input() state: tagStates = "default";
|
|
30
39
|
@Input() showIcon: boolean = false;
|
|
31
|
-
@Input() icon: string =
|
|
32
|
-
@Input() text: string =
|
|
40
|
+
@Input() icon: string = "";
|
|
41
|
+
@Input() text: string = "";
|
|
33
42
|
|
|
34
43
|
colorMap: { [key: string]: string } = {
|
|
35
|
-
default:
|
|
36
|
-
success:
|
|
37
|
-
info:
|
|
38
|
-
warning:
|
|
39
|
-
error:
|
|
40
|
-
legacy:
|
|
44
|
+
default: "Primary-Primary",
|
|
45
|
+
success: "Success-Success",
|
|
46
|
+
info: "Info-Info",
|
|
47
|
+
warning: "Warning-Warning",
|
|
48
|
+
error: "Error-Error",
|
|
49
|
+
legacy: "Gray-Gray",
|
|
41
50
|
};
|
|
42
51
|
|
|
43
52
|
fontColor: string;
|
|
@@ -54,17 +63,17 @@ export class DropiTagComponent implements OnInit {
|
|
|
54
63
|
let stylesTags = {
|
|
55
64
|
primary: {
|
|
56
65
|
bgc: `var(--${this.colorMap[this.state]}-500)`,
|
|
57
|
-
cl:
|
|
66
|
+
cl: "var(--Neutral-White)",
|
|
58
67
|
},
|
|
59
68
|
secondary: {
|
|
60
|
-
bgc: `var(--${this.colorMap[this.state]}${this.state ==
|
|
61
|
-
cl: `var(--${this.colorMap[this.state]}${this.state ==
|
|
69
|
+
bgc: `var(--${this.colorMap[this.state]}${this.state == "default" || this.state == "legacy" ? "-100" : "-50"})`,
|
|
70
|
+
cl: `var(--${this.colorMap[this.state]}${this.state == "default" ? "-500" : "-700"})`,
|
|
62
71
|
},
|
|
63
72
|
};
|
|
64
73
|
|
|
65
74
|
let styleToApply: {
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
"background-color": any;
|
|
76
|
+
"border-radius": any;
|
|
68
77
|
color: any;
|
|
69
78
|
};
|
|
70
79
|
|
|
@@ -72,15 +81,16 @@ export class DropiTagComponent implements OnInit {
|
|
|
72
81
|
const selectedStyle = stylesTags[this.type];
|
|
73
82
|
|
|
74
83
|
styleToApply = {
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
"background-color": selectedStyle.bgc,
|
|
85
|
+
"border-radius": "var(--Border-5)",
|
|
77
86
|
color: selectedStyle.cl,
|
|
78
87
|
};
|
|
79
88
|
|
|
80
89
|
this.fontColor =
|
|
81
|
-
this.type ==
|
|
82
|
-
?
|
|
83
|
-
: this.colorMap[this.state] +
|
|
90
|
+
this.type == "primary"
|
|
91
|
+
? "Neutral-White"
|
|
92
|
+
: this.colorMap[this.state] +
|
|
93
|
+
(this.state == "default" ? "-500" : "-700");
|
|
84
94
|
|
|
85
95
|
return styleToApply;
|
|
86
96
|
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
Input,
|
|
4
|
+
OnChanges,
|
|
5
|
+
OnInit,
|
|
6
|
+
SimpleChanges,
|
|
7
|
+
SimpleChange,
|
|
8
|
+
} from "@angular/core";
|
|
9
|
+
import { CommonModule } from "@angular/common";
|
|
10
|
+
import { InputProperties } from "@app/utilities/interfaces/ui/input-interface";
|
|
11
|
+
import { Validators, ReactiveFormsModule } from "@angular/forms";
|
|
12
|
+
import { IconComponent } from "../icon/icon.component";
|
|
13
|
+
import { ThousandSeparatorDirective } from "@app/utilities/directives/thousand-separator.directive";
|
|
14
|
+
import { TranslateModule } from "@ngx-translate/core";
|
|
15
|
+
import { OnlyNumbersDirective } from "@app/utilities/directives/only-numbers.directive";
|
|
16
|
+
import { OnlyLettersDirective } from "@app/utilities/directives/only-letters.directive";
|
|
10
17
|
|
|
11
18
|
@Component({
|
|
12
|
-
selector:
|
|
19
|
+
selector: "dropi-wc-input",
|
|
13
20
|
standalone: true,
|
|
14
21
|
imports: [
|
|
15
22
|
CommonModule,
|
|
@@ -20,8 +27,8 @@ import { OnlyLettersDirective } from '@app/utilities/directives/only-letters.dir
|
|
|
20
27
|
OnlyNumbersDirective,
|
|
21
28
|
OnlyLettersDirective,
|
|
22
29
|
],
|
|
23
|
-
templateUrl:
|
|
24
|
-
styleUrls: [
|
|
30
|
+
templateUrl: "./input.component.html",
|
|
31
|
+
styleUrls: ["./input.component.scss"],
|
|
25
32
|
})
|
|
26
33
|
export class InputComponent implements OnInit, OnChanges {
|
|
27
34
|
/**
|
|
@@ -91,8 +98,8 @@ export class InputComponent implements OnInit, OnChanges {
|
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
ngOnChanges(changes: SimpleChanges): void {
|
|
94
|
-
if (changes[
|
|
95
|
-
const disabledChange = changes[
|
|
101
|
+
if (changes["disabled"]) {
|
|
102
|
+
const disabledChange = changes["disabled"];
|
|
96
103
|
}
|
|
97
104
|
}
|
|
98
105
|
|
package/src/index.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* como Custom Elements del navegador usando Angular Elements.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Injector, Type } from
|
|
9
|
-
import { createCustomElement } from
|
|
8
|
+
import { Injector, Type, ApplicationRef } from "@angular/core";
|
|
9
|
+
import { createCustomElement } from "@angular/elements";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Interface para definición de componentes
|
|
@@ -40,7 +40,24 @@ interface ComponentDefinition {
|
|
|
40
40
|
* });
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
import { createApplication } from "@angular/platform-browser";
|
|
44
|
+
import { ButtonComponent } from "../components-source/dropi-button/dropi-button.component";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Lista interna de todos los componentes disponibles para registro automático
|
|
48
|
+
*/
|
|
49
|
+
const ALL_COMPONENTS: ComponentDefinition[] = [
|
|
50
|
+
{
|
|
51
|
+
selector: "dropi-wc-button",
|
|
52
|
+
component: ButtonComponent,
|
|
53
|
+
description: "Button Component",
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
export function registerDropiElements(
|
|
58
|
+
injector: Injector,
|
|
59
|
+
components: ComponentDefinition[],
|
|
60
|
+
): void {
|
|
44
61
|
// Registrar cada componente como custom element
|
|
45
62
|
components.forEach(({ selector, component, description }) => {
|
|
46
63
|
try {
|
|
@@ -48,7 +65,9 @@ export function registerDropiElements(injector: Injector, components: ComponentD
|
|
|
48
65
|
if (!customElements.get(selector)) {
|
|
49
66
|
const element = createCustomElement(component, { injector });
|
|
50
67
|
customElements.define(selector, element);
|
|
51
|
-
console.log(
|
|
68
|
+
console.log(
|
|
69
|
+
`✅ Web Component registrado: <${selector}> - ${description}`,
|
|
70
|
+
);
|
|
52
71
|
} else {
|
|
53
72
|
console.warn(`⚠️ Custom element <${selector}> ya está definido`);
|
|
54
73
|
}
|
|
@@ -58,6 +77,27 @@ export function registerDropiElements(injector: Injector, components: ComponentD
|
|
|
58
77
|
});
|
|
59
78
|
}
|
|
60
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Inicializa el entorno de Angular y registra todos los Web Components automáticamente.
|
|
82
|
+
* Ideal para uso en frameworks como React, Vue, o Vanilla JS.
|
|
83
|
+
*/
|
|
84
|
+
export function defineCustomElements(config?: {
|
|
85
|
+
providers?: any[];
|
|
86
|
+
}): Promise<void> {
|
|
87
|
+
const appConfig =
|
|
88
|
+
config && config.providers
|
|
89
|
+
? { providers: config.providers }
|
|
90
|
+
: { providers: [] };
|
|
91
|
+
return createApplication(appConfig)
|
|
92
|
+
.then((appRef: ApplicationRef) => {
|
|
93
|
+
registerDropiElements(appRef.injector, ALL_COMPONENTS);
|
|
94
|
+
console.log("🚀 Dropi UI Elements initialized successfully");
|
|
95
|
+
})
|
|
96
|
+
.catch((err: any) =>
|
|
97
|
+
console.error("❌ Error initializing Dropi UI Elements", err),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
61
101
|
/**
|
|
62
102
|
* Función auxiliar para verificar si un componente está registrado
|
|
63
103
|
*/
|