@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.
@@ -1,43 +1,52 @@
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';
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 = 'default' | 'success' | 'info' | 'warning' | 'error' | 'legacy';
7
- export type tagTypes = 'primary' | 'secondary';
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: 'app-dropi-tag',
11
- templateUrl: './dropi-tag.component.html',
12
- styleUrls: ['./dropi-tag.component.scss'],
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('fade', [
17
- transition(':enter', [
18
- style({ opacity: 0, transform: 'scale(0.8)' }),
19
- animate('200ms ease-out', style({ opacity: 1, transform: 'scale(1)' })),
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(':leave', [
22
- animate('150ms ease-in', style({ opacity: 0, transform: 'scale(0.8)' })),
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 = 'primary';
29
- @Input() state: tagStates = 'default';
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: 'Primary-Primary',
36
- success: 'Success-Success',
37
- info: 'Info-Info',
38
- warning: 'Warning-Warning',
39
- error: 'Error-Error',
40
- legacy: 'Gray-Gray',
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: 'var(--Neutral-White)',
66
+ cl: "var(--Neutral-White)",
58
67
  },
59
68
  secondary: {
60
- bgc: `var(--${this.colorMap[this.state]}${this.state == 'default' || this.state == 'legacy' ? '-100' : '-50'})`,
61
- cl: `var(--${this.colorMap[this.state]}${this.state == 'default' ? '-500' : '-700'})`,
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
- 'background-color': any;
67
- 'border-radius': any;
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
- 'background-color': selectedStyle.bgc,
76
- 'border-radius': 'var(--Border-5)',
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 == 'primary'
82
- ? 'Neutral-White'
83
- : this.colorMap[this.state] + (this.state == 'default' ? '-500' : '-700');
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 { Component, Input, OnChanges, OnInit, SimpleChanges, SimpleChange } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { InputProperties } from '@app/utilities/interfaces/ui/input-interface';
4
- import { Validators, ReactiveFormsModule } from '@angular/forms';
5
- import { IconComponent } from '../icon/icon.component';
6
- import { ThousandSeparatorDirective } from '@app/utilities/directives/thousand-separator.directive';
7
- import { TranslateModule } from '@ngx-translate/core';
8
- import { OnlyNumbersDirective } from '@app/utilities/directives/only-numbers.directive';
9
- import { OnlyLettersDirective } from '@app/utilities/directives/only-letters.directive';
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: 'app-input',
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: './input.component.html',
24
- styleUrls: ['./input.component.scss'],
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['disabled']) {
95
- const disabledChange = changes['disabled'];
101
+ if (changes["disabled"]) {
102
+ const disabledChange = changes["disabled"];
96
103
  }
97
104
  }
98
105
 
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ export { DropiElementsModule } from "./lib/elements.module";
11
11
  // Exportar funciones de registro
12
12
  export {
13
13
  registerDropiElements,
14
+ defineCustomElements,
14
15
  isComponentRegistered,
15
16
  } from "./lib/elements-registry";
16
17
 
@@ -5,8 +5,8 @@
5
5
  * como Custom Elements del navegador usando Angular Elements.
6
6
  */
7
7
 
8
- import { Injector, Type } from '@angular/core';
9
- import { createCustomElement } from '@angular/elements';
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
- export function registerDropiElements(injector: Injector, components: ComponentDefinition[]): void {
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(`✅ Web Component registrado: <${selector}> - ${description}`);
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
  */
@@ -0,0 +1,11 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": "../../../Documents/react prueba"
5
+ },
6
+ {
7
+ "path": ".."
8
+ }
9
+ ],
10
+ "settings": {}
11
+ }