@c-code/c-code-fw 1.1.2 → 1.1.4

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,5 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, HostListener, Input, Directive, signal } from '@angular/core';
3
+ import { fromEvent, debounceTime } from 'rxjs';
3
4
 
4
5
  class ElementActiveService {
5
6
  currentActiveElement = null;
@@ -64,8 +65,8 @@ var ElementStatusType;
64
65
  })(ElementStatusType || (ElementStatusType = {}));
65
66
 
66
67
  /**
67
- * Servicio para manejar el estado y las clases de elementos HTML,
68
- * uso en menus y botones para mostrar o cerrar contenido
68
+ * Service to manage the state and classes of HTML elements,
69
+ * used in menus and buttons to show or hide content.
69
70
  *
70
71
  */
71
72
  class ElementToggleService {
@@ -73,23 +74,23 @@ class ElementToggleService {
73
74
  elementsHistory = [];
74
75
  currentToggleClass = '';
75
76
  /**
76
- * Obtiene el estado actual del elemento.
77
- * @returns Signal con el estado actual.
77
+ * Gets the current state of the element.
78
+ * @returns Signal with the current state.
78
79
  */
79
80
  get elementStatusToggle() {
80
81
  if (this.elementStatus() === ElementStatusType.DEFAULT) {
81
- console.warn('El estado del elemento es default. Se debe insertar un valor diferente.');
82
+ console.warn('The element state is default. A different value should be set.');
82
83
  }
83
84
  return this.elementStatus;
84
85
  }
85
86
  /**
86
- * Cambia el estado del elemento por uno específico, si el estado ya es SHOW se cambia a.
87
- * @param status Estado nuevo del tipo ElementStatusType.
88
- * @throws Error si el estado es DEFAULT.
87
+ * Changes the state of the element to a specific one. If the state is already SHOW, it changes to HIDDEN.
88
+ * @param status New state of type ElementStatusType.
89
+ * @throws Error if the state is DEFAULT.
89
90
  */
90
91
  toggleByElementStatusType(status) {
91
92
  if (status === ElementStatusType.DEFAULT) {
92
- throw Error('El estado del elemento no puede ser default.');
93
+ throw Error('The element state cannot be default.');
93
94
  }
94
95
  if (this.elementStatus() === ElementStatusType.SHOW &&
95
96
  status === ElementStatusType.SHOW) {
@@ -100,14 +101,14 @@ class ElementToggleService {
100
101
  }
101
102
  }
102
103
  /**
103
- * Alterna una clase CSS en un elemento y lo guarda en el historial.
104
- * @param element Elemento HTML al que se le alternará la clase.
105
- * @param className Nombre de la clase a alternar.
106
- * @throws Error si el nombre de la clase es nulo o vacío.
104
+ * Toggles a CSS class on an element and saves it in the history.
105
+ * @param element HTML element to toggle the class on.
106
+ * @param className Name of the class to toggle.
107
+ * @throws Error if the class name is null or empty.
107
108
  */
108
109
  toggleByClassName(element, className) {
109
- if (className == null || className == '') {
110
- throw Error('El nombre de la clase no puede ser nulo o vacio.');
110
+ if (!className.trim()) {
111
+ throw Error('The class name cannot be null or empty.');
111
112
  }
112
113
  element.classList.toggle(className);
113
114
  this.currentToggleClass = className;
@@ -116,12 +117,12 @@ class ElementToggleService {
116
117
  }
117
118
  }
118
119
  /**
119
- * Remueve la clase activa de todos los elementos almacenados en el historial.
120
- * @throws Error si el historial está vacío.
120
+ * Removes the active class from all elements stored in the history.
121
+ * @throws Error if the history is empty.
121
122
  */
122
123
  removeActiveClassToAllElements() {
123
124
  if (this.elementsHistory.length <= 0) {
124
- throw Error('El historial de elementos está vacío.');
125
+ throw Error('The element history is empty.');
125
126
  }
126
127
  this.elementsHistory.forEach((element) => {
127
128
  element.classList.remove(this.currentToggleClass);
@@ -134,6 +135,67 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImpor
134
135
  type: Injectable
135
136
  }] });
136
137
 
138
+ /**
139
+ * Tailwind CSS Breakpoints:
140
+ * - xs: < 640px (Extra small, below Tailwind's `sm`)
141
+ * - sm: 640px (Small screens)
142
+ * - md: 768px (Medium screens)
143
+ * - lg: 1024px (Large screens)
144
+ * - xl: 1280px (Extra large screens)
145
+ * - 2xl: 1536px (2x Extra large screens)
146
+ */
147
+ // @Service: ScreenWidthEventService
148
+ class ScreenWidthEventService {
149
+ // @Property: Stores the current screen width
150
+ screenWidth = window.innerWidth;
151
+ // @Property: Stores the current screen height
152
+ screenHeight = window.innerHeight;
153
+ /**
154
+ * @Method: getScreenWidth
155
+ * @Description: Returns the current screen width
156
+ * @Returns: number - The current screen width
157
+ */
158
+ getScreenWidth() {
159
+ return this.screenWidth;
160
+ }
161
+ /**
162
+ * @Method: getScreenHeight
163
+ * @Description: Returns the current screen height
164
+ * @Returns: number - The current screen height
165
+ */
166
+ getScreenHeight() {
167
+ return this.screenHeight;
168
+ }
169
+ /**
170
+ * @Method: executeFuncByScreenWidth
171
+ * @Description: Executes a function if the screen width is less than or equal to the specified width
172
+ * @Param: func - The function to execute
173
+ * @Param: width - The maximum screen width to trigger the function
174
+ */
175
+ executeFuncByScreenWidth(func, width) {
176
+ if (this.screenWidth <= width) {
177
+ func();
178
+ }
179
+ }
180
+ onResize(func) {
181
+ fromEvent(window, 'resize')
182
+ .pipe(debounceTime(200))
183
+ .subscribe(() => {
184
+ this.screenWidth = window.innerWidth;
185
+ this.screenHeight = window.innerHeight;
186
+ func();
187
+ });
188
+ }
189
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ScreenWidthEventService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
190
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ScreenWidthEventService, providedIn: 'root' });
191
+ }
192
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ScreenWidthEventService, decorators: [{
193
+ type: Injectable,
194
+ args: [{
195
+ providedIn: 'root',
196
+ }]
197
+ }] });
198
+
137
199
  /*
138
200
  * Public API Surface of core
139
201
  */
@@ -142,5 +204,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImpor
142
204
  * Generated bundle index. Do not edit.
143
205
  */
144
206
 
145
- export { ElementActiveDirective, ElementActiveService, ElementStatusType, ElementToggleService };
207
+ export { ElementActiveDirective, ElementActiveService, ElementStatusType, ElementToggleService, ScreenWidthEventService };
146
208
  //# sourceMappingURL=c-code-c-code-fw.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"c-code-c-code-fw.mjs","sources":["../../../projects/core/src/lib/element-active.service.ts","../../../projects/core/src/lib/element-active.directive.ts","../../../projects/core/src/lib/types/element_status-type.ts","../../../projects/core/src/lib/element_toggle.service.ts","../../../projects/core/src/public-api.ts","../../../projects/core/src/c-code-c-code-fw.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable(\r\n \r\n)\r\nexport class ElementActiveService {\r\n private currentActiveElement: HTMLElement | null = null;\r\n private elementsClickedRegister: HTMLElement[] = [];\r\n setActiveElement(element: HTMLElement, classActiveName: string) {\r\n this.deactivateElementsOtherThanOneClicked(classActiveName,element);\r\n\r\n this.currentActiveElement = element;\r\n this.currentActiveElement.classList.add(classActiveName);\r\n\r\n if(!this.elementsClickedRegister.includes(element)){\r\n this.elementsClickedRegister.push(element);\r\n }\r\n }\r\n\r\n private deactivateElementsOtherThanOneClicked(classActiveName: string, excludeElement: HTMLElement) {\r\n this.elementsClickedRegister.forEach(element => {\r\n if (element !== excludeElement) {\r\n element.classList.remove(classActiveName);\r\n }\r\n });\r\n}\r\n}\r\n","import {\r\n Directive,\r\n ElementRef,\r\n HostListener,\r\n Input,\r\n Renderer2,\r\n } from '@angular/core';\r\nimport { ElementActiveService } from './element-active.service';\r\n \r\n @Directive({\r\n selector: '[appElementActive]',\r\n standalone: true,\r\n })\r\n export class ElementActiveDirective {\r\n @Input() activeClass:string = \"active\"\r\n constructor(\r\n private el: ElementRef,\r\n private render: Renderer2,\r\n private elementService: ElementActiveService\r\n ) {}\r\n @HostListener('click') onClick() {\r\n this.elementService.setActiveElement(this.el.nativeElement,this.activeClass);\r\n this.render.addClass(this.el.nativeElement, this.activeClass)\r\n }\r\n }\r\n ","export enum ElementStatusType{\r\n SHOW,\r\n HIDDEN,\r\n DEFAULT\r\n}","import { Injectable, signal } from '@angular/core';\r\nimport { ElementStatusType } from './types/element_status-type';\r\n\r\n/**\r\n * Servicio para manejar el estado y las clases de elementos HTML,\r\n * uso en menus y botones para mostrar o cerrar contenido\r\n *\r\n */\r\n@Injectable()\r\nexport class ElementToggleService {\r\n private elementStatus = signal<ElementStatusType>(ElementStatusType.DEFAULT);\r\n private elementsHistory: HTMLElement[] = [];\r\n private currentToggleClass: string = '';\r\n\r\n /**\r\n * Obtiene el estado actual del elemento.\r\n * @returns Signal con el estado actual.\r\n */\r\n get elementStatusToggle() {\r\n if (this.elementStatus() === ElementStatusType.DEFAULT) {\r\n console.warn(\r\n 'El estado del elemento es default. Se debe insertar un valor diferente.'\r\n );\r\n }\r\n return this.elementStatus;\r\n }\r\n\r\n /**\r\n * Cambia el estado del elemento por uno específico, si el estado ya es SHOW se cambia a.\r\n * @param status Estado nuevo del tipo ElementStatusType.\r\n * @throws Error si el estado es DEFAULT.\r\n */\r\n toggleByElementStatusType(status: ElementStatusType) {\r\n if (status === ElementStatusType.DEFAULT) {\r\n throw Error('El estado del elemento no puede ser default.');\r\n }\r\n if (\r\n this.elementStatus() === ElementStatusType.SHOW &&\r\n status === ElementStatusType.SHOW\r\n ) {\r\n this.elementStatus.set(ElementStatusType.HIDDEN);\r\n } else {\r\n this.elementStatus.set(status);\r\n }\r\n }\r\n\r\n /**\r\n * Alterna una clase CSS en un elemento y lo guarda en el historial.\r\n * @param element Elemento HTML al que se le alternará la clase.\r\n * @param className Nombre de la clase a alternar.\r\n * @throws Error si el nombre de la clase es nulo o vacío.\r\n */\r\n toggleByClassName(element: HTMLElement, className: string) {\r\n if (className == null || className == '') {\r\n throw Error('El nombre de la clase no puede ser nulo o vacio.');\r\n }\r\n\r\n element.classList.toggle(className);\r\n this.currentToggleClass = className;\r\n if (!this.elementsHistory.includes(element)) {\r\n this.elementsHistory.push(element);\r\n }\r\n }\r\n\r\n /**\r\n * Remueve la clase activa de todos los elementos almacenados en el historial.\r\n * @throws Error si el historial está vacío.\r\n */\r\n removeActiveClassToAllElements() {\r\n if (this.elementsHistory.length <= 0) {\r\n throw Error('El historial de elementos está vacío.');\r\n }\r\n\r\n this.elementsHistory.forEach((element) => {\r\n element.classList.remove(this.currentToggleClass);\r\n });\r\n }\r\n}\r\n","/*\r\n * Public API Surface of core\r\n */\r\n\r\nexport * from './lib/element-active.directive';\r\nexport * from './lib/element-active.service';\r\nexport * from './lib/element_toggle.service';\r\nexport * from './lib/types/element_status-type'","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.ElementActiveService"],"mappings":";;;MAKa,oBAAoB,CAAA;IACvB,oBAAoB,GAAuB,IAAI;IAC/C,uBAAuB,GAAkB,EAAE;IACnD,gBAAgB,CAAC,OAAoB,EAAE,eAAuB,EAAA;AAC5D,QAAA,IAAI,CAAC,qCAAqC,CAAC,eAAe,EAAC,OAAO,CAAC;AAEnE,QAAA,IAAI,CAAC,oBAAoB,GAAG,OAAO;QACnC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC;QAExD,IAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAC;AAC/C,YAAA,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC;;;IAIxC,qCAAqC,CAAC,eAAuB,EAAE,cAA2B,EAAA;AAClG,QAAA,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,OAAO,IAAG;AAC7C,YAAA,IAAI,OAAO,KAAK,cAAc,EAAE;AAC9B,gBAAA,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC;;AAE7C,SAAC,CAAC;;uGAnBS,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAApB,oBAAoB,EAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CA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AE,EAAE;AACxC,YAAA,MAAM,KAAK,CAAC,kDAAkD,CAAC;;AAGjE,QAAA,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC;AACnC,QAAA,IAAI,CAAC,kBAAkB,GAAG,SAAS;QACnC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;AAC3C,YAAA,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;;;AAItC;;;AAGG;IACH,8BAA8B,GAAA;QAC5B,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,IAAI,CAAC,EAAE;AACpC,YAAA,MAAM,KAAK,CAAC,uCAAuC,CAAC;;QAGtD,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,OAAO,KAAI;YACvC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC;AACnD,SAAC,CAAC;;uGAlEO,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAApB,oBAAoB,EAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC;;;ACRD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"c-code-c-code-fw.mjs","sources":["../../../projects/core/src/lib/element-active.service.ts","../../../projects/core/src/lib/element-active.directive.ts","../../../projects/core/src/lib/types/element_status-type.ts","../../../projects/core/src/lib/element_toggle.service.ts","../../../projects/core/src/lib/screen_width-event.service.ts","../../../projects/core/src/public-api.ts","../../../projects/core/src/c-code-c-code-fw.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable(\r\n \r\n)\r\nexport class ElementActiveService {\r\n private currentActiveElement: HTMLElement | null = null;\r\n private elementsClickedRegister: HTMLElement[] = [];\r\n setActiveElement(element: HTMLElement, classActiveName: string) {\r\n this.deactivateElementsOtherThanOneClicked(classActiveName,element);\r\n\r\n this.currentActiveElement = element;\r\n this.currentActiveElement.classList.add(classActiveName);\r\n\r\n if(!this.elementsClickedRegister.includes(element)){\r\n this.elementsClickedRegister.push(element);\r\n }\r\n }\r\n\r\n private deactivateElementsOtherThanOneClicked(classActiveName: string, excludeElement: HTMLElement) {\r\n this.elementsClickedRegister.forEach(element => {\r\n if (element !== excludeElement) {\r\n element.classList.remove(classActiveName);\r\n }\r\n });\r\n}\r\n}\r\n","import {\r\n Directive,\r\n ElementRef,\r\n HostListener,\r\n Input,\r\n Renderer2,\r\n } from '@angular/core';\r\nimport { ElementActiveService } from './element-active.service';\r\n \r\n @Directive({\r\n selector: '[appElementActive]',\r\n standalone: true,\r\n })\r\n export class ElementActiveDirective {\r\n @Input() activeClass:string = \"active\"\r\n constructor(\r\n private el: ElementRef,\r\n private render: Renderer2,\r\n private elementService: ElementActiveService\r\n ) {}\r\n @HostListener('click') onClick() {\r\n this.elementService.setActiveElement(this.el.nativeElement,this.activeClass);\r\n this.render.addClass(this.el.nativeElement, this.activeClass)\r\n }\r\n }\r\n ","export enum ElementStatusType{\r\n SHOW,\r\n HIDDEN,\r\n DEFAULT\r\n}","import { Injectable, signal } from '@angular/core';\r\nimport { ElementStatusType } from './types/element_status-type';\r\n\r\n/**\r\n * Service to manage the state and classes of HTML elements,\r\n * used in menus and buttons to show or hide content.\r\n *\r\n */\r\n@Injectable()\r\nexport class ElementToggleService {\r\n private elementStatus = signal<ElementStatusType>(ElementStatusType.DEFAULT);\r\n private elementsHistory: HTMLElement[] = [];\r\n private currentToggleClass: string = '';\r\n\r\n /**\r\n * Gets the current state of the element.\r\n * @returns Signal with the current state.\r\n */\r\n get elementStatusToggle() {\r\n if (this.elementStatus() === ElementStatusType.DEFAULT) {\r\n console.warn(\r\n 'The element state is default. A different value should be set.'\r\n );\r\n }\r\n return this.elementStatus;\r\n }\r\n\r\n /**\r\n * Changes the state of the element to a specific one. If the state is already SHOW, it changes to HIDDEN.\r\n * @param status New state of type ElementStatusType.\r\n * @throws Error if the state is DEFAULT.\r\n */\r\n toggleByElementStatusType(status: ElementStatusType) {\r\n if (status === ElementStatusType.DEFAULT) {\r\n throw Error('The element state cannot be default.');\r\n }\r\n if (\r\n this.elementStatus() === ElementStatusType.SHOW &&\r\n status === ElementStatusType.SHOW\r\n ) {\r\n this.elementStatus.set(ElementStatusType.HIDDEN);\r\n } else {\r\n this.elementStatus.set(status);\r\n }\r\n }\r\n\r\n /**\r\n * Toggles a CSS class on an element and saves it in the history.\r\n * @param element HTML element to toggle the class on.\r\n * @param className Name of the class to toggle.\r\n * @throws Error if the class name is null or empty.\r\n */\r\n toggleByClassName(element: HTMLElement, className: string) {\r\n if (!className.trim()) {\r\n throw Error('The class name cannot be null or empty.');\r\n }\r\n\r\n element.classList.toggle(className);\r\n this.currentToggleClass = className;\r\n if (!this.elementsHistory.includes(element)) {\r\n this.elementsHistory.push(element);\r\n }\r\n }\r\n\r\n /**\r\n * Removes the active class from all elements stored in the history.\r\n * @throws Error if the history is empty.\r\n */\r\n removeActiveClassToAllElements() {\r\n if (this.elementsHistory.length <= 0) {\r\n throw Error('The element history is empty.');\r\n }\r\n\r\n this.elementsHistory.forEach((element) => {\r\n element.classList.remove(this.currentToggleClass);\r\n });\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { debounceTime, fromEvent } from 'rxjs';\r\n\r\n/**\r\n * Tailwind CSS Breakpoints:\r\n * - xs: < 640px (Extra small, below Tailwind's `sm`)\r\n * - sm: 640px (Small screens)\r\n * - md: 768px (Medium screens)\r\n * - lg: 1024px (Large screens)\r\n * - xl: 1280px (Extra large screens)\r\n * - 2xl: 1536px (2x Extra large screens)\r\n */\r\n\r\n// @Service: ScreenWidthEventService\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class ScreenWidthEventService {\r\n // @Property: Stores the current screen width\r\n private screenWidth: number = window.innerWidth;\r\n\r\n // @Property: Stores the current screen height\r\n private screenHeight: number = window.innerHeight;\r\n\r\n /**\r\n * @Method: getScreenWidth\r\n * @Description: Returns the current screen width\r\n * @Returns: number - The current screen width\r\n */\r\n public getScreenWidth(): number {\r\n return this.screenWidth;\r\n }\r\n\r\n /**\r\n * @Method: getScreenHeight\r\n * @Description: Returns the current screen height\r\n * @Returns: number - The current screen height\r\n */\r\n public getScreenHeight(): number {\r\n return this.screenHeight;\r\n }\r\n\r\n /**\r\n * @Method: executeFuncByScreenWidth\r\n * @Description: Executes a function if the screen width is less than or equal to the specified width\r\n * @Param: func - The function to execute\r\n * @Param: width - The maximum screen width to trigger the function\r\n */\r\n public executeFuncByScreenWidth(func: () => void, width: number): void {\r\n if (this.screenWidth <= width) {\r\n func();\r\n }\r\n }\r\n\r\n public onResize(func: () => void): void {\r\n fromEvent(window, 'resize')\r\n .pipe(debounceTime(200))\r\n .subscribe(() =>{\r\n this.screenWidth = window.innerWidth;\r\n this.screenHeight = window.innerHeight;\r\n func();\r\n })\r\n }\r\n}","/*\r\n * Public API Surface of core\r\n */\r\n\r\nexport * from './lib/element-active.directive';\r\nexport * from './lib/element-active.service';\r\nexport * from './lib/element_toggle.service';\r\nexport * from './lib/types/element_status-type'\r\nexport * from './lib/screen_width-event.service';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.ElementActiveService"],"mappings":";;;;MAKa,oBAAoB,CAAA;IACvB,oBAAoB,GAAuB,IAAI;IAC/C,uBAAuB,GAAkB,EAAE;IACnD,gBAAgB,CAAC,OAAoB,EAAE,eAAuB,EAAA;AAC5D,QAAA,IAAI,CAAC,qCAAqC,CAAC,eAAe,EAAC,OAAO,CAAC;AAEnE,QAAA,IAAI,CAAC,oBAAoB,GAAG,OAAO;QACnC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC;QAExD,IAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAC;AAC/C,YAAA,IAAI,CAAC,uBAAuB,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AuB,CAAA;;AAExB,IAAA,WAAW,GAAW,MAAM,CAAC,UAAU;;AAGvC,IAAA,YAAY,GAAW,MAAM,CAAC,WAAW;AAEjD;;;;AAIG;IACI,cAAc,GAAA;QACjB,OAAO,IAAI,CAAC,WAAW;;AAG3B;;;;AAIG;IACI,eAAe,GAAA;QAClB,OAAO,IAAI,CAAC,YAAY;;AAG5B;;;;;AAKG;IACI,wBAAwB,CAAC,IAAgB,EAAE,KAAa,EAAA;AAC3D,QAAA,IAAI,IAAI,CAAC,WAAW,IAAI,KAAK,EAAE;AAC3B,YAAA,IAAI,EAAE;;;AAIP,IAAA,QAAQ,CAAC,IAAgB,EAAA;AAC5B,QAAA,SAAS,CAAC,MAAM,EAAE,QAAQ;AACrB,aAAA,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;aACtB,SAAS,CAAC,MAAK;AACZ,YAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU;AACpC,YAAA,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW;AACtC,YAAA,IAAI,EAAE;AACV,SAAC,CAAC;;uGA5CD,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAvB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uBAAuB,cAFpB,MAAM,EAAA,CAAA;;2FAET,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAHnC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE,MAAM;AACrB,iBAAA;;;AChBD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,8 +1,8 @@
1
1
  import { ElementStatusType } from './types/element_status-type';
2
2
  import * as i0 from "@angular/core";
3
3
  /**
4
- * Servicio para manejar el estado y las clases de elementos HTML,
5
- * uso en menus y botones para mostrar o cerrar contenido
4
+ * Service to manage the state and classes of HTML elements,
5
+ * used in menus and buttons to show or hide content.
6
6
  *
7
7
  */
8
8
  export declare class ElementToggleService {
@@ -10,26 +10,26 @@ export declare class ElementToggleService {
10
10
  private elementsHistory;
11
11
  private currentToggleClass;
12
12
  /**
13
- * Obtiene el estado actual del elemento.
14
- * @returns Signal con el estado actual.
13
+ * Gets the current state of the element.
14
+ * @returns Signal with the current state.
15
15
  */
16
16
  get elementStatusToggle(): import("@angular/core").WritableSignal<ElementStatusType>;
17
17
  /**
18
- * Cambia el estado del elemento por uno específico, si el estado ya es SHOW se cambia a.
19
- * @param status Estado nuevo del tipo ElementStatusType.
20
- * @throws Error si el estado es DEFAULT.
18
+ * Changes the state of the element to a specific one. If the state is already SHOW, it changes to HIDDEN.
19
+ * @param status New state of type ElementStatusType.
20
+ * @throws Error if the state is DEFAULT.
21
21
  */
22
22
  toggleByElementStatusType(status: ElementStatusType): void;
23
23
  /**
24
- * Alterna una clase CSS en un elemento y lo guarda en el historial.
25
- * @param element Elemento HTML al que se le alternará la clase.
26
- * @param className Nombre de la clase a alternar.
27
- * @throws Error si el nombre de la clase es nulo o vacío.
24
+ * Toggles a CSS class on an element and saves it in the history.
25
+ * @param element HTML element to toggle the class on.
26
+ * @param className Name of the class to toggle.
27
+ * @throws Error if the class name is null or empty.
28
28
  */
29
29
  toggleByClassName(element: HTMLElement, className: string): void;
30
30
  /**
31
- * Remueve la clase activa de todos los elementos almacenados en el historial.
32
- * @throws Error si el historial está vacío.
31
+ * Removes the active class from all elements stored in the history.
32
+ * @throws Error if the history is empty.
33
33
  */
34
34
  removeActiveClassToAllElements(): void;
35
35
  static ɵfac: i0.ɵɵFactoryDeclaration<ElementToggleService, never>;
@@ -0,0 +1,36 @@
1
+ import * as i0 from "@angular/core";
2
+ /**
3
+ * Tailwind CSS Breakpoints:
4
+ * - xs: < 640px (Extra small, below Tailwind's `sm`)
5
+ * - sm: 640px (Small screens)
6
+ * - md: 768px (Medium screens)
7
+ * - lg: 1024px (Large screens)
8
+ * - xl: 1280px (Extra large screens)
9
+ * - 2xl: 1536px (2x Extra large screens)
10
+ */
11
+ export declare class ScreenWidthEventService {
12
+ private screenWidth;
13
+ private screenHeight;
14
+ /**
15
+ * @Method: getScreenWidth
16
+ * @Description: Returns the current screen width
17
+ * @Returns: number - The current screen width
18
+ */
19
+ getScreenWidth(): number;
20
+ /**
21
+ * @Method: getScreenHeight
22
+ * @Description: Returns the current screen height
23
+ * @Returns: number - The current screen height
24
+ */
25
+ getScreenHeight(): number;
26
+ /**
27
+ * @Method: executeFuncByScreenWidth
28
+ * @Description: Executes a function if the screen width is less than or equal to the specified width
29
+ * @Param: func - The function to execute
30
+ * @Param: width - The maximum screen width to trigger the function
31
+ */
32
+ executeFuncByScreenWidth(func: () => void, width: number): void;
33
+ onResize(func: () => void): void;
34
+ static ɵfac: i0.ɵɵFactoryDeclaration<ScreenWidthEventService, never>;
35
+ static ɵprov: i0.ɵɵInjectableDeclaration<ScreenWidthEventService>;
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-code/c-code-fw",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^19.2.0",
6
6
  "@angular/core": "^19.2.0"
package/public-api.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './lib/element-active.directive';
2
2
  export * from './lib/element-active.service';
3
3
  export * from './lib/element_toggle.service';
4
4
  export * from './lib/types/element_status-type';
5
+ export * from './lib/screen_width-event.service';