@c-code/c-code-fw 1.1.2 → 1.1.3
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.
|
@@ -64,8 +64,8 @@ var ElementStatusType;
|
|
|
64
64
|
})(ElementStatusType || (ElementStatusType = {}));
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
67
|
+
* Service to manage the state and classes of HTML elements,
|
|
68
|
+
* used in menus and buttons to show or hide content.
|
|
69
69
|
*
|
|
70
70
|
*/
|
|
71
71
|
class ElementToggleService {
|
|
@@ -73,23 +73,23 @@ class ElementToggleService {
|
|
|
73
73
|
elementsHistory = [];
|
|
74
74
|
currentToggleClass = '';
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
77
|
-
* @returns Signal
|
|
76
|
+
* Gets the current state of the element.
|
|
77
|
+
* @returns Signal with the current state.
|
|
78
78
|
*/
|
|
79
79
|
get elementStatusToggle() {
|
|
80
80
|
if (this.elementStatus() === ElementStatusType.DEFAULT) {
|
|
81
|
-
console.warn('
|
|
81
|
+
console.warn('The element state is default. A different value should be set.');
|
|
82
82
|
}
|
|
83
83
|
return this.elementStatus;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
87
|
-
* @param status
|
|
88
|
-
* @throws Error
|
|
86
|
+
* Changes the state of the element to a specific one. If the state is already SHOW, it changes to HIDDEN.
|
|
87
|
+
* @param status New state of type ElementStatusType.
|
|
88
|
+
* @throws Error if the state is DEFAULT.
|
|
89
89
|
*/
|
|
90
90
|
toggleByElementStatusType(status) {
|
|
91
91
|
if (status === ElementStatusType.DEFAULT) {
|
|
92
|
-
throw Error('
|
|
92
|
+
throw Error('The element state cannot be default.');
|
|
93
93
|
}
|
|
94
94
|
if (this.elementStatus() === ElementStatusType.SHOW &&
|
|
95
95
|
status === ElementStatusType.SHOW) {
|
|
@@ -100,14 +100,14 @@ class ElementToggleService {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @param element
|
|
105
|
-
* @param className
|
|
106
|
-
* @throws Error
|
|
103
|
+
* Toggles a CSS class on an element and saves it in the history.
|
|
104
|
+
* @param element HTML element to toggle the class on.
|
|
105
|
+
* @param className Name of the class to toggle.
|
|
106
|
+
* @throws Error if the class name is null or empty.
|
|
107
107
|
*/
|
|
108
108
|
toggleByClassName(element, className) {
|
|
109
|
-
if (className
|
|
110
|
-
throw Error('
|
|
109
|
+
if (!className.trim()) {
|
|
110
|
+
throw Error('The class name cannot be null or empty.');
|
|
111
111
|
}
|
|
112
112
|
element.classList.toggle(className);
|
|
113
113
|
this.currentToggleClass = className;
|
|
@@ -116,12 +116,12 @@ class ElementToggleService {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
120
|
-
* @throws Error
|
|
119
|
+
* Removes the active class from all elements stored in the history.
|
|
120
|
+
* @throws Error if the history is empty.
|
|
121
121
|
*/
|
|
122
122
|
removeActiveClassToAllElements() {
|
|
123
123
|
if (this.elementsHistory.length <= 0) {
|
|
124
|
-
throw Error('
|
|
124
|
+
throw Error('The element history is empty.');
|
|
125
125
|
}
|
|
126
126
|
this.elementsHistory.forEach((element) => {
|
|
127
127
|
element.classList.remove(this.currentToggleClass);
|
|
@@ -134,6 +134,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImpor
|
|
|
134
134
|
type: Injectable
|
|
135
135
|
}] });
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Tailwind CSS Breakpoints:
|
|
139
|
+
* - xs: < 640px (Extra small, below Tailwind's `sm`)
|
|
140
|
+
* - sm: 640px (Small screens)
|
|
141
|
+
* - md: 768px (Medium screens)
|
|
142
|
+
* - lg: 1024px (Large screens)
|
|
143
|
+
* - xl: 1280px (Extra large screens)
|
|
144
|
+
* - 2xl: 1536px (2x Extra large screens)
|
|
145
|
+
*/
|
|
146
|
+
// @Service: ScreenWidthEventService
|
|
147
|
+
class ScreenWidthEventService {
|
|
148
|
+
// @Property: Stores the current screen width
|
|
149
|
+
screenWidth = window.innerWidth;
|
|
150
|
+
// @Property: Stores the current screen height
|
|
151
|
+
screenHeight = window.innerHeight;
|
|
152
|
+
/**
|
|
153
|
+
* @Method: getScreenWidth
|
|
154
|
+
* @Description: Returns the current screen width
|
|
155
|
+
* @Returns: number - The current screen width
|
|
156
|
+
*/
|
|
157
|
+
getScreenWidth() {
|
|
158
|
+
return this.screenWidth;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @Method: getScreenHeight
|
|
162
|
+
* @Description: Returns the current screen height
|
|
163
|
+
* @Returns: number - The current screen height
|
|
164
|
+
*/
|
|
165
|
+
getScreenHeight() {
|
|
166
|
+
return this.screenHeight;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @Method: executeFuncByScreenWidth
|
|
170
|
+
* @Description: Executes a function if the screen width is less than or equal to the specified width
|
|
171
|
+
* @Param: func - The function to execute
|
|
172
|
+
* @Param: width - The maximum screen width to trigger the function
|
|
173
|
+
*/
|
|
174
|
+
executeFuncByScreenWidth(func, width) {
|
|
175
|
+
if (this.screenWidth <= width) {
|
|
176
|
+
func();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ScreenWidthEventService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
180
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ScreenWidthEventService, providedIn: 'root' });
|
|
181
|
+
}
|
|
182
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ScreenWidthEventService, decorators: [{
|
|
183
|
+
type: Injectable,
|
|
184
|
+
args: [{
|
|
185
|
+
providedIn: 'root',
|
|
186
|
+
}]
|
|
187
|
+
}] });
|
|
188
|
+
|
|
137
189
|
/*
|
|
138
190
|
* Public API Surface of core
|
|
139
191
|
*/
|
|
@@ -142,5 +194,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImpor
|
|
|
142
194
|
* Generated bundle index. Do not edit.
|
|
143
195
|
*/
|
|
144
196
|
|
|
145
|
-
export { ElementActiveDirective, ElementActiveService, ElementStatusType, ElementToggleService };
|
|
197
|
+
export { ElementActiveDirective, ElementActiveService, ElementStatusType, ElementToggleService, ScreenWidthEventService };
|
|
146
198
|
//# 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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AE,KAAK,iBAAiB,CAAC,IAAI;AAC/C,YAAA,MAAM,KAAK,iBAAiB,CAAC,IAAI,EACjC;YACA,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC;;aAC3C;AACL,YAAA,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC;;;AAIlC;;;;;AAKG;IACH,iBAAiB,CAAC,OAAoB,EAAE,SAAiB,EAAA;QACvD,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI,EAAE,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\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 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,oBA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EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAApB,oBAAoB,EAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC;;;ACND;;;;;;;;AAQG;AAEH;MAIa,uBAAuB,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;;;uGAjCL,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;;;ACfD;;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
|
-
*
|
|
5
|
-
*
|
|
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
|
-
*
|
|
14
|
-
* @returns Signal
|
|
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
|
-
*
|
|
19
|
-
* @param status
|
|
20
|
-
* @throws Error
|
|
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
|
-
*
|
|
25
|
-
* @param element
|
|
26
|
-
* @param className
|
|
27
|
-
* @throws Error
|
|
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
|
-
*
|
|
32
|
-
* @throws Error
|
|
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,35 @@
|
|
|
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
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScreenWidthEventService, never>;
|
|
34
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ScreenWidthEventService>;
|
|
35
|
+
}
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED