chaqui-catalog-frontend-lib 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.
Files changed (55) hide show
  1. package/EXAMPLES.md +255 -0
  2. package/INSTALLATION.md +226 -0
  3. package/README.md +310 -0
  4. package/STRUCTURE.md +123 -0
  5. package/dist/lib/catalog.module.d.ts +19 -0
  6. package/dist/lib/catalog.module.d.ts.map +1 -0
  7. package/dist/lib/catalog.module.js +49 -0
  8. package/dist/lib/catalog.module.js.map +1 -0
  9. package/dist/lib/components/catalog-items-select/catalog-items-select.component.d.ts +58 -0
  10. package/dist/lib/components/catalog-items-select/catalog-items-select.component.d.ts.map +1 -0
  11. package/dist/lib/components/catalog-items-select/catalog-items-select.component.js +147 -0
  12. package/dist/lib/components/catalog-items-select/catalog-items-select.component.js.map +1 -0
  13. package/dist/lib/components/index.d.ts +2 -0
  14. package/dist/lib/components/index.d.ts.map +1 -0
  15. package/dist/lib/components/index.js +2 -0
  16. package/dist/lib/components/index.js.map +1 -0
  17. package/dist/lib/config/catalog.config.d.ts +15 -0
  18. package/dist/lib/config/catalog.config.d.ts.map +1 -0
  19. package/dist/lib/config/catalog.config.js +5 -0
  20. package/dist/lib/config/catalog.config.js.map +1 -0
  21. package/dist/lib/models/catalog.model.d.ts +27 -0
  22. package/dist/lib/models/catalog.model.d.ts.map +1 -0
  23. package/dist/lib/models/catalog.model.js +2 -0
  24. package/dist/lib/models/catalog.model.js.map +1 -0
  25. package/dist/lib/models/index.d.ts +2 -0
  26. package/dist/lib/models/index.d.ts.map +1 -0
  27. package/dist/lib/models/index.js +2 -0
  28. package/dist/lib/models/index.js.map +1 -0
  29. package/dist/lib/services/catalog.service.d.ts +33 -0
  30. package/dist/lib/services/catalog.service.d.ts.map +1 -0
  31. package/dist/lib/services/catalog.service.js +74 -0
  32. package/dist/lib/services/catalog.service.js.map +1 -0
  33. package/dist/lib/services/index.d.ts +2 -0
  34. package/dist/lib/services/index.d.ts.map +1 -0
  35. package/dist/lib/services/index.js +2 -0
  36. package/dist/lib/services/index.js.map +1 -0
  37. package/dist/public-api.d.ts +9 -0
  38. package/dist/public-api.d.ts.map +1 -0
  39. package/dist/public-api.js +9 -0
  40. package/dist/public-api.js.map +1 -0
  41. package/index.ts +6 -0
  42. package/ng-package.json +6 -0
  43. package/package.json +44 -0
  44. package/src/lib/catalog.module.ts +40 -0
  45. package/src/lib/components/catalog-items-select/catalog-items-select.component.css +71 -0
  46. package/src/lib/components/catalog-items-select/catalog-items-select.component.html +43 -0
  47. package/src/lib/components/catalog-items-select/catalog-items-select.component.ts +125 -0
  48. package/src/lib/components/index.ts +1 -0
  49. package/src/lib/config/catalog.config.ts +15 -0
  50. package/src/lib/models/catalog.model.ts +28 -0
  51. package/src/lib/models/index.ts +1 -0
  52. package/src/lib/services/catalog.service.ts +71 -0
  53. package/src/lib/services/index.ts +1 -0
  54. package/src/public-api.ts +8 -0
  55. package/tsconfig.lib.json +28 -0
@@ -0,0 +1,147 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Component, Input, Output, EventEmitter } from '@angular/core';
11
+ import { CatalogService } from '../../services/catalog.service.js';
12
+ import { Subject } from 'rxjs';
13
+ import { takeUntil } from 'rxjs/operators';
14
+ let CatalogItemsSelectComponent = class CatalogItemsSelectComponent {
15
+ catalogService;
16
+ /**
17
+ * ID del catálogo del cual cargar los items
18
+ */
19
+ catalogId;
20
+ /**
21
+ * ID del item actualmente seleccionado (opcional)
22
+ */
23
+ selectedItemId;
24
+ /**
25
+ * Label del input del catálogo
26
+ */
27
+ catalogLabel = 'ID del Catálogo';
28
+ /**
29
+ * Placeholder del select de items
30
+ */
31
+ itemSelectPlaceholder = 'Selecciona un item';
32
+ /**
33
+ * Emite cuando se selecciona un item
34
+ */
35
+ itemSelected = new EventEmitter();
36
+ /**
37
+ * Emite cuando hay un error al cargar los items
38
+ */
39
+ error = new EventEmitter();
40
+ items = [];
41
+ isLoading = false;
42
+ errorMessage = '';
43
+ destroy$ = new Subject();
44
+ constructor(catalogService) {
45
+ this.catalogService = catalogService;
46
+ }
47
+ ngOnInit() {
48
+ if (this.catalogId) {
49
+ this.loadItems();
50
+ }
51
+ }
52
+ ngOnDestroy() {
53
+ this.destroy$.next();
54
+ this.destroy$.complete();
55
+ }
56
+ /**
57
+ * Carga los items del catálogo especificado
58
+ */
59
+ loadItems() {
60
+ if (!this.catalogId) {
61
+ this.errorMessage = 'Por favor ingresa un ID de catálogo válido';
62
+ this.error.emit(this.errorMessage);
63
+ return;
64
+ }
65
+ this.isLoading = true;
66
+ this.errorMessage = '';
67
+ this.items = [];
68
+ this.catalogService.getItemsByCatalogId(this.catalogId)
69
+ .pipe(takeUntil(this.destroy$))
70
+ .subscribe({
71
+ next: (items) => {
72
+ this.items = items;
73
+ this.isLoading = false;
74
+ },
75
+ error: (err) => {
76
+ this.isLoading = false;
77
+ this.errorMessage = err?.message || 'Error al cargar los items del catálogo';
78
+ this.error.emit(this.errorMessage);
79
+ console.error('Error cargando items:', err);
80
+ }
81
+ });
82
+ }
83
+ /**
84
+ * Maneja el cambio de catálogo
85
+ * @param event Evento del input
86
+ */
87
+ onCatalogIdChange(event) {
88
+ const value = event.target.value;
89
+ this.catalogId = value ? Number(value) : null;
90
+ if (this.catalogId) {
91
+ this.loadItems();
92
+ }
93
+ }
94
+ /**
95
+ * Maneja la selección de un item
96
+ * @param event Evento del select
97
+ */
98
+ onItemSelected(event) {
99
+ const itemId = Number(event.target.value);
100
+ const selectedItem = this.items.find(item => item.id === itemId);
101
+ if (selectedItem) {
102
+ this.itemSelected.emit(selectedItem);
103
+ }
104
+ }
105
+ /**
106
+ * Obtiene el nombre del item para mostrar en el select
107
+ * @param item Item del catálogo
108
+ * @returns Nombre del item o ID si no hay nombre
109
+ */
110
+ getItemDisplayName(item) {
111
+ return item.name || `Item ${item.id}`;
112
+ }
113
+ };
114
+ __decorate([
115
+ Input(),
116
+ __metadata("design:type", Number)
117
+ ], CatalogItemsSelectComponent.prototype, "catalogId", void 0);
118
+ __decorate([
119
+ Input(),
120
+ __metadata("design:type", Number)
121
+ ], CatalogItemsSelectComponent.prototype, "selectedItemId", void 0);
122
+ __decorate([
123
+ Input(),
124
+ __metadata("design:type", String)
125
+ ], CatalogItemsSelectComponent.prototype, "catalogLabel", void 0);
126
+ __decorate([
127
+ Input(),
128
+ __metadata("design:type", String)
129
+ ], CatalogItemsSelectComponent.prototype, "itemSelectPlaceholder", void 0);
130
+ __decorate([
131
+ Output(),
132
+ __metadata("design:type", Object)
133
+ ], CatalogItemsSelectComponent.prototype, "itemSelected", void 0);
134
+ __decorate([
135
+ Output(),
136
+ __metadata("design:type", Object)
137
+ ], CatalogItemsSelectComponent.prototype, "error", void 0);
138
+ CatalogItemsSelectComponent = __decorate([
139
+ Component({
140
+ selector: 'catalog-items-select',
141
+ templateUrl: './catalog-items-select.component.html',
142
+ styleUrls: ['./catalog-items-select.component.css']
143
+ }),
144
+ __metadata("design:paramtypes", [CatalogService])
145
+ ], CatalogItemsSelectComponent);
146
+ export { CatalogItemsSelectComponent };
147
+ //# sourceMappingURL=catalog-items-select.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-items-select.component.js","sourceRoot":"","sources":["../../../../src/lib/components/catalog-items-select/catalog-items-select.component.ts"],"names":[],"mappings":";;;;;;;;;AAAA,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AAI,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;QAEjE,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,IAAiB;QAClC,OAAO,IAAI,CAAC,IAAI,IAAI,QAAQ,IAAI,CAAC,EAAE,EAAE,CAAC;IACxC,CAAC;CACF,CAAA;AA7GU;IAAR,KAAK,EAAE;;8DAAoB;AAKnB;IAAR,KAAK,EAAE;;mEAAyB;AAKxB;IAAR,KAAK,EAAE;;iEAA0C;AAKzC;IAAR,KAAK,EAAE;;0EAAsD;AAKpD;IAAT,MAAM,EAAE;;iEAAgD;AAK/C;IAAT,MAAM,EAAE;;0DAAoC;AA7BlC,2BAA2B;IALvC,SAAS,CAAC;QACT,QAAQ,EAAE,sBAAsB;QAChC,WAAW,EAAE,uCAAuC;QACpD,SAAS,EAAE,CAAC,sCAAsC,CAAC;KACpD,CAAC;qCAsCoC,cAAc;GArCvC,2BAA2B,CAiHvC","sourcesContent":["import { Component, Input, Output, EventEmitter, OnInit, OnDestroy } from '@angular/core';\nimport { CatalogService } from '../../services/catalog.service.js';\nimport { CatalogItem } from '../../models/catalog.model.js';\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\n@Component({\n selector: 'catalog-items-select',\n templateUrl: './catalog-items-select.component.html',\n styleUrls: ['./catalog-items-select.component.css']\n})\nexport class CatalogItemsSelectComponent implements OnInit, OnDestroy {\n /**\n * ID del catálogo del cual cargar los items\n */\n @Input() catalogId!: number;\n\n /**\n * ID del item actualmente seleccionado (opcional)\n */\n @Input() selectedItemId?: number;\n\n /**\n * Label del input del catálogo\n */\n @Input() catalogLabel: string = 'ID del Catálogo';\n\n /**\n * Placeholder del select de items\n */\n @Input() itemSelectPlaceholder: string = 'Selecciona un item';\n\n /**\n * Emite cuando se selecciona un item\n */\n @Output() itemSelected = new EventEmitter<CatalogItem>();\n\n /**\n * Emite cuando hay un error al cargar los items\n */\n @Output() error = new EventEmitter<string>();\n\n items: CatalogItem[] = [];\n isLoading: boolean = false;\n errorMessage: string = '';\n\n private destroy$ = new Subject<void>();\n\n constructor(private catalogService: CatalogService) {}\n\n ngOnInit(): void {\n if (this.catalogId) {\n this.loadItems();\n }\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n\n /**\n * Carga los items del catálogo especificado\n */\n loadItems(): void {\n if (!this.catalogId) {\n this.errorMessage = 'Por favor ingresa un ID de catálogo válido';\n this.error.emit(this.errorMessage);\n return;\n }\n\n this.isLoading = true;\n this.errorMessage = '';\n this.items = [];\n\n this.catalogService.getItemsByCatalogId(this.catalogId)\n .pipe(takeUntil(this.destroy$))\n .subscribe({\n next: (items: CatalogItem[]) => {\n this.items = items;\n this.isLoading = false;\n },\n error: (err: any) => {\n this.isLoading = false;\n this.errorMessage = err?.message || 'Error al cargar los items del catálogo';\n this.error.emit(this.errorMessage);\n console.error('Error cargando items:', err);\n }\n });\n }\n\n /**\n * Maneja el cambio de catálogo\n * @param event Evento del input\n */\n onCatalogIdChange(event: any): void {\n const value = event.target.value;\n this.catalogId = value ? Number(value) : null as any;\n if (this.catalogId) {\n this.loadItems();\n }\n }\n\n /**\n * Maneja la selección de un item\n * @param event Evento del select\n */\n onItemSelected(event: any): void {\n const itemId = Number(event.target.value);\n const selectedItem = this.items.find(item => item.id === itemId);\n \n if (selectedItem) {\n this.itemSelected.emit(selectedItem);\n }\n }\n\n /**\n * Obtiene el nombre del item para mostrar en el select\n * @param item Item del catálogo\n * @returns Nombre del item o ID si no hay nombre\n */\n getItemDisplayName(item: CatalogItem): string {\n return item.name || `Item ${item.id}`;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './catalog-items-select/catalog-items-select.component.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,0DAA0D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './catalog-items-select/catalog-items-select.component.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,0DAA0D,CAAC","sourcesContent":["export * from './catalog-items-select/catalog-items-select.component.js';\n"]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Configuración de la librería de Catálogos
3
+ */
4
+ export interface CatalogConfig {
5
+ /**
6
+ * URL base del servicio de catálogos
7
+ * Ejemplo: 'http://localhost:3000/api'
8
+ */
9
+ apiBaseUrl: string;
10
+ }
11
+ /**
12
+ * Token de inyección para la configuración
13
+ */
14
+ export declare const CATALOG_CONFIG_TOKEN = "CATALOG_CONFIG";
15
+ //# sourceMappingURL=catalog.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/catalog.config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,mBAAmB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Token de inyección para la configuración
3
+ */
4
+ export const CATALOG_CONFIG_TOKEN = 'CATALOG_CONFIG';
5
+ //# sourceMappingURL=catalog.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.config.js","sourceRoot":"","sources":["../../../src/lib/config/catalog.config.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC","sourcesContent":["/**\n * Configuración de la librería de Catálogos\n */\nexport interface CatalogConfig {\n /**\n * URL base del servicio de catálogos\n * Ejemplo: 'http://localhost:3000/api'\n */\n apiBaseUrl: string;\n}\n\n/**\n * Token de inyección para la configuración\n */\nexport const CATALOG_CONFIG_TOKEN = 'CATALOG_CONFIG';\n"]}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Interfaz para representar un Catálogo
3
+ */
4
+ export interface Catalog {
5
+ id: number;
6
+ name: string;
7
+ description?: string;
8
+ }
9
+ /**
10
+ * Interfaz para representar un Item de Catálogo
11
+ */
12
+ export interface CatalogItem {
13
+ id: number;
14
+ catalogId: number;
15
+ name: string;
16
+ description?: string;
17
+ [key: string]: any;
18
+ }
19
+ /**
20
+ * Interfaz para la respuesta de error de la API
21
+ */
22
+ export interface ApiErrorResponse {
23
+ message: string;
24
+ status?: number;
25
+ error?: any;
26
+ }
27
+ //# sourceMappingURL=catalog.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.model.d.ts","sourceRoot":"","sources":["../../../src/lib/models/catalog.model.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=catalog.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.model.js","sourceRoot":"","sources":["../../../src/lib/models/catalog.model.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Interfaz para representar un Catálogo\n */\nexport interface Catalog {\n id: number;\n name: string;\n description?: string;\n}\n\n/**\n * Interfaz para representar un Item de Catálogo\n */\nexport interface CatalogItem {\n id: number;\n catalogId: number;\n name: string;\n description?: string;\n [key: string]: any;\n}\n\n/**\n * Interfaz para la respuesta de error de la API\n */\nexport interface ApiErrorResponse {\n message: string;\n status?: number;\n error?: any;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './catalog.model.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './catalog.model.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './catalog.model.js';\n"]}
@@ -0,0 +1,33 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import { Catalog, CatalogItem } from '../models/catalog.model.js';
4
+ import type { CatalogConfig } from '../config/catalog.config.js';
5
+ export declare class CatalogService {
6
+ private http;
7
+ private apiBaseUrl;
8
+ constructor(http: HttpClient, config: CatalogConfig);
9
+ /**
10
+ * Obtiene todos los catálogos disponibles
11
+ * @returns Observable con la lista de catálogos
12
+ */
13
+ getCatalogs(): Observable<Catalog[]>;
14
+ /**
15
+ * Obtiene todos los items de un catálogo específico
16
+ * @param catalogId ID del catálogo
17
+ * @returns Observable con la lista de items
18
+ */
19
+ getItemsByCatalogId(catalogId: number): Observable<CatalogItem[]>;
20
+ /**
21
+ * Obtiene un item específico por su ID
22
+ * @param itemId ID del item
23
+ * @returns Observable con los datos del item
24
+ */
25
+ getItemById(itemId: number): Observable<CatalogItem>;
26
+ /**
27
+ * Maneja los errores de las peticiones HTTP
28
+ * @param error Error de la petición
29
+ * @returns Observable con el error
30
+ */
31
+ private handleError;
32
+ }
33
+ //# sourceMappingURL=catalog.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/catalog.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAoB,MAAM,4BAA4B,CAAC;AAEpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,qBAGa,cAAc;IAIvB,OAAO,CAAC,IAAI;IAHd,OAAO,CAAC,UAAU,CAAS;gBAGjB,IAAI,EAAE,UAAU,EACM,MAAM,EAAE,aAAa;IAKrD;;;OAGG;IACH,WAAW,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;IAOpC;;;;OAIG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAOjE;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC;IAOpD;;;;OAIG;IACH,OAAO,CAAC,WAAW;CASpB"}
@@ -0,0 +1,74 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Injectable, Inject } from '@angular/core';
14
+ import { HttpClient } from '@angular/common/http';
15
+ import { throwError } from 'rxjs';
16
+ import { catchError } from 'rxjs/operators';
17
+ import { CATALOG_CONFIG_TOKEN } from '../config/catalog.config.js';
18
+ let CatalogService = class CatalogService {
19
+ http;
20
+ apiBaseUrl;
21
+ constructor(http, config) {
22
+ this.http = http;
23
+ this.apiBaseUrl = config.apiBaseUrl;
24
+ }
25
+ /**
26
+ * Obtiene todos los catálogos disponibles
27
+ * @returns Observable con la lista de catálogos
28
+ */
29
+ getCatalogs() {
30
+ return this.http.get(`${this.apiBaseUrl}/catalogs`)
31
+ .pipe(catchError(this.handleError));
32
+ }
33
+ /**
34
+ * Obtiene todos los items de un catálogo específico
35
+ * @param catalogId ID del catálogo
36
+ * @returns Observable con la lista de items
37
+ */
38
+ getItemsByCatalogId(catalogId) {
39
+ return this.http.get(`${this.apiBaseUrl}/catalogs/${catalogId}/items`)
40
+ .pipe(catchError(this.handleError));
41
+ }
42
+ /**
43
+ * Obtiene un item específico por su ID
44
+ * @param itemId ID del item
45
+ * @returns Observable con los datos del item
46
+ */
47
+ getItemById(itemId) {
48
+ return this.http.get(`${this.apiBaseUrl}/items/${itemId}`)
49
+ .pipe(catchError(this.handleError));
50
+ }
51
+ /**
52
+ * Maneja los errores de las peticiones HTTP
53
+ * @param error Error de la petición
54
+ * @returns Observable con el error
55
+ */
56
+ handleError(error) {
57
+ const errorResponse = {
58
+ message: error.message || 'Error en la petición',
59
+ status: error.status,
60
+ error: error.error
61
+ };
62
+ console.error('Error en CatalogService:', errorResponse);
63
+ return throwError(() => errorResponse);
64
+ }
65
+ };
66
+ CatalogService = __decorate([
67
+ Injectable({
68
+ providedIn: 'root'
69
+ }),
70
+ __param(1, Inject(CATALOG_CONFIG_TOKEN)),
71
+ __metadata("design:paramtypes", [HttpClient, Object])
72
+ ], CatalogService);
73
+ export { CatalogService };
74
+ //# sourceMappingURL=catalog.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.service.js","sourceRoot":"","sources":["../../../src/lib/services/catalog.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAc,UAAU,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAM5D,IAAM,cAAc,GAApB,MAAM,cAAc;IAIf;IAHF,UAAU,CAAS;IAE3B,YACU,IAAgB,EACM,MAAqB;QAD3C,SAAI,GAAJ,IAAI,CAAY;QAGxB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAY,GAAG,IAAI,CAAC,UAAU,WAAW,CAAC;aAC3D,IAAI,CACH,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAC7B,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,SAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAgB,GAAG,IAAI,CAAC,UAAU,aAAa,SAAS,QAAQ,CAAC;aAClF,IAAI,CACH,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAC7B,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAc,GAAG,IAAI,CAAC,UAAU,UAAU,MAAM,EAAE,CAAC;aACpE,IAAI,CACH,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAC7B,CAAC;IACN,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,KAAU;QAC5B,MAAM,aAAa,GAAqB;YACtC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,sBAAsB;YAChD,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAC;QACzD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AA3DY,cAAc;IAH1B,UAAU,CAAC;QACV,UAAU,EAAE,MAAM;KACnB,CAAC;IAMG,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;qCADf,UAAU;GAJf,cAAc,CA2D1B","sourcesContent":["import { Injectable, Inject } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, throwError } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\nimport { Catalog, CatalogItem, ApiErrorResponse } from '../models/catalog.model.js';\nimport { CATALOG_CONFIG_TOKEN } from '../config/catalog.config.js';\nimport type { CatalogConfig } from '../config/catalog.config.js';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class CatalogService {\n private apiBaseUrl: string;\n\n constructor(\n private http: HttpClient,\n @Inject(CATALOG_CONFIG_TOKEN) config: CatalogConfig\n ) {\n this.apiBaseUrl = config.apiBaseUrl;\n }\n\n /**\n * Obtiene todos los catálogos disponibles\n * @returns Observable con la lista de catálogos\n */\n getCatalogs(): Observable<Catalog[]> {\n return this.http.get<Catalog[]>(`${this.apiBaseUrl}/catalogs`)\n .pipe(\n catchError(this.handleError)\n );\n }\n\n /**\n * Obtiene todos los items de un catálogo específico\n * @param catalogId ID del catálogo\n * @returns Observable con la lista de items\n */\n getItemsByCatalogId(catalogId: number): Observable<CatalogItem[]> {\n return this.http.get<CatalogItem[]>(`${this.apiBaseUrl}/catalogs/${catalogId}/items`)\n .pipe(\n catchError(this.handleError)\n );\n }\n\n /**\n * Obtiene un item específico por su ID\n * @param itemId ID del item\n * @returns Observable con los datos del item\n */\n getItemById(itemId: number): Observable<CatalogItem> {\n return this.http.get<CatalogItem>(`${this.apiBaseUrl}/items/${itemId}`)\n .pipe(\n catchError(this.handleError)\n );\n }\n\n /**\n * Maneja los errores de las peticiones HTTP\n * @param error Error de la petición\n * @returns Observable con el error\n */\n private handleError(error: any) {\n const errorResponse: ApiErrorResponse = {\n message: error.message || 'Error en la petición',\n status: error.status,\n error: error.error\n };\n console.error('Error en CatalogService:', errorResponse);\n return throwError(() => errorResponse);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './catalog.service.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './catalog.service.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './catalog.service.js';\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Exporta todos los módulos, servicios y componentes públicos de la librería
3
+ */
4
+ export * from './lib/catalog.module.js';
5
+ export * from './lib/services/index.js';
6
+ export * from './lib/models/index.js';
7
+ export * from './lib/components/index.js';
8
+ export * from './lib/config/catalog.config.js';
9
+ //# sourceMappingURL=public-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Exporta todos los módulos, servicios y componentes públicos de la librería
3
+ */
4
+ export * from './lib/catalog.module.js';
5
+ export * from './lib/services/index.js';
6
+ export * from './lib/models/index.js';
7
+ export * from './lib/components/index.js';
8
+ export * from './lib/config/catalog.config.js';
9
+ //# sourceMappingURL=public-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC","sourcesContent":["/**\n * Exporta todos los módulos, servicios y componentes públicos de la librería\n */\nexport * from './lib/catalog.module.js';\nexport * from './lib/services/index.js';\nexport * from './lib/models/index.js';\nexport * from './lib/components/index.js';\nexport * from './lib/config/catalog.config.js';\n"]}
package/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Librería Angular para Catálogos
3
+ *
4
+ * Exporta todos los módulos, servicios y componentes de la librería
5
+ */
6
+ export * from './src/public-api.js';
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "node_modules/ng-packagr/ng-package.schema.json",
3
+ "lib": {
4
+ "entryFile": "src/public-api.ts"
5
+ }
6
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "chaqui-catalog-frontend-lib",
3
+ "version": "1.0.0",
4
+ "description": "Librería Angular para consumir el servicio de catálogos",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "scripts": {
9
+ "build": "tsc -p tsconfig.lib.json",
10
+ "watch": "tsc -p tsconfig.lib.json --watch"
11
+ },
12
+ "peerDependencies": {
13
+ "@angular/animations": "^15.0.0 || ^16.0.0 || ^17.0.0",
14
+ "@angular/common": "^15.0.0 || ^16.0.0 || ^17.0.0",
15
+ "@angular/compiler": "^15.0.0 || ^16.0.0 || ^17.0.0",
16
+ "@angular/core": "^15.0.0 || ^16.0.0 || ^17.0.0",
17
+ "@angular/forms": "^15.0.0 || ^16.0.0 || ^17.0.0",
18
+ "@angular/platform-browser": "^15.0.0 || ^16.0.0 || ^17.0.0",
19
+ "@angular/platform-browser-dynamic": "^15.0.0 || ^16.0.0 || ^17.0.0",
20
+ "rxjs": "^7.8.0",
21
+ "tslib": "^2.4.0",
22
+ "zone.js": "^0.12.0 || ^0.13.0 || ^0.14.0"
23
+ },
24
+ "devDependencies": {
25
+ "@angular/animations": "^17.3.12",
26
+ "@angular/common": "^17.3.12",
27
+ "@angular/compiler": "^17.3.12",
28
+ "@angular/compiler-cli": "^17.3.12",
29
+ "@angular/core": "^17.3.12",
30
+ "@angular/forms": "^17.3.12",
31
+ "@angular/platform-browser": "^17.3.12",
32
+ "@angular/platform-browser-dynamic": "^17.3.12",
33
+ "rxjs": "^7.8.0",
34
+ "tslib": "^2.4.0",
35
+ "typescript": "~5.4.0",
36
+ "zone.js": "^0.14.0"
37
+ },
38
+ "exports": {
39
+ ".": {
40
+ "import": "./dist/public-api.js",
41
+ "require": "./dist/public-api.js"
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,40 @@
1
+ import { NgModule, ModuleWithProviders } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { HttpClientModule } from '@angular/common/http';
4
+ import { CatalogItemsSelectComponent } from './components/catalog-items-select/catalog-items-select.component.js';
5
+ import { CatalogService } from './services/catalog.service.js';
6
+ import { CATALOG_CONFIG_TOKEN } from './config/catalog.config.js';
7
+ import type { CatalogConfig } from './config/catalog.config.js';
8
+
9
+ @NgModule({
10
+ declarations: [CatalogItemsSelectComponent],
11
+ imports: [CommonModule, HttpClientModule],
12
+ exports: [CatalogItemsSelectComponent]
13
+ })
14
+ export class CatalogModule {
15
+ /**
16
+ * Configura el módulo con la URL base del servicio de catálogos
17
+ * @param config Configuración del módulo
18
+ * @returns Módulo configurado con los proveedores
19
+ *
20
+ * @example
21
+ * // En tu app.module.ts
22
+ * imports: [
23
+ * CatalogModule.forRoot({
24
+ * apiBaseUrl: 'http://localhost:3000/api'
25
+ * })
26
+ * ]
27
+ */
28
+ static forRoot(config: CatalogConfig): ModuleWithProviders<CatalogModule> {
29
+ return {
30
+ ngModule: CatalogModule,
31
+ providers: [
32
+ CatalogService,
33
+ {
34
+ provide: CATALOG_CONFIG_TOKEN,
35
+ useValue: config
36
+ }
37
+ ]
38
+ };
39
+ }
40
+ }
@@ -0,0 +1,71 @@
1
+ .catalog-items-select-container {
2
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
3
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
4
+ sans-serif;
5
+ -webkit-font-smoothing: antialiased;
6
+ -moz-osx-font-smoothing: grayscale;
7
+ }
8
+
9
+ .form-group {
10
+ margin-bottom: 1.5rem;
11
+ display: flex;
12
+ flex-direction: column;
13
+ }
14
+
15
+ .form-label {
16
+ margin-bottom: 0.5rem;
17
+ font-weight: 500;
18
+ color: #333;
19
+ font-size: 0.95rem;
20
+ }
21
+
22
+ .form-input,
23
+ .form-select {
24
+ padding: 0.75rem 0.75rem;
25
+ border: 1px solid #ddd;
26
+ border-radius: 4px;
27
+ font-size: 1rem;
28
+ font-family: inherit;
29
+ transition: border-color 0.2s, box-shadow 0.2s;
30
+ }
31
+
32
+ .form-input:focus,
33
+ .form-select:focus {
34
+ outline: none;
35
+ border-color: #0066cc;
36
+ box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
37
+ }
38
+
39
+ .form-input:disabled,
40
+ .form-select:disabled {
41
+ background-color: #f5f5f5;
42
+ color: #999;
43
+ cursor: not-allowed;
44
+ }
45
+
46
+ .loading {
47
+ color: #666;
48
+ font-style: italic;
49
+ padding: 0.75rem;
50
+ text-align: center;
51
+ background-color: #f0f0f0;
52
+ border-radius: 4px;
53
+ }
54
+
55
+ .error-message {
56
+ color: #d32f2f;
57
+ background-color: #ffebee;
58
+ padding: 0.75rem;
59
+ border-radius: 4px;
60
+ border-left: 4px solid #d32f2f;
61
+ font-size: 0.9rem;
62
+ }
63
+
64
+ .no-items {
65
+ color: #666;
66
+ padding: 0.75rem;
67
+ text-align: center;
68
+ background-color: #f5f5f5;
69
+ border-radius: 4px;
70
+ font-style: italic;
71
+ }
@@ -0,0 +1,43 @@
1
+ <div class="catalog-items-select-container">
2
+ <div class="form-group">
3
+ <label for="catalogId" class="form-label">{{ catalogLabel }}</label>
4
+ <input
5
+ id="catalogId"
6
+ type="number"
7
+ class="form-input"
8
+ placeholder="Ingresa el ID del catálogo"
9
+ [value]="catalogId"
10
+ (change)="onCatalogIdChange($event)"
11
+ min="1"
12
+ />
13
+ </div>
14
+
15
+ <div class="form-group">
16
+ <label for="itemSelect" class="form-label">Items</label>
17
+
18
+ <div *ngIf="isLoading" class="loading">
19
+ Cargando items...
20
+ </div>
21
+
22
+ <div *ngIf="errorMessage && !isLoading" class="error-message">
23
+ {{ errorMessage }}
24
+ </div>
25
+
26
+ <select
27
+ *ngIf="!isLoading && items.length > 0"
28
+ id="itemSelect"
29
+ class="form-select"
30
+ [value]="selectedItemId || ''"
31
+ (change)="onItemSelected($event)"
32
+ >
33
+ <option value="">{{ itemSelectPlaceholder }}</option>
34
+ <option *ngFor="let item of items" [value]="item.id">
35
+ {{ getItemDisplayName(item) }}
36
+ </option>
37
+ </select>
38
+
39
+ <div *ngIf="!isLoading && items.length === 0 && !errorMessage" class="no-items">
40
+ No hay items disponibles
41
+ </div>
42
+ </div>
43
+ </div>