@c-code/c-code-fw 1.1.0 → 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.
@@ -0,0 +1,198 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, HostListener, Input, Directive, signal } from '@angular/core';
3
+
4
+ class ElementActiveService {
5
+ currentActiveElement = null;
6
+ elementsClickedRegister = [];
7
+ setActiveElement(element, classActiveName) {
8
+ this.deactivateElementsOtherThanOneClicked(classActiveName, element);
9
+ this.currentActiveElement = element;
10
+ this.currentActiveElement.classList.add(classActiveName);
11
+ if (!this.elementsClickedRegister.includes(element)) {
12
+ this.elementsClickedRegister.push(element);
13
+ }
14
+ }
15
+ deactivateElementsOtherThanOneClicked(classActiveName, excludeElement) {
16
+ this.elementsClickedRegister.forEach(element => {
17
+ if (element !== excludeElement) {
18
+ element.classList.remove(classActiveName);
19
+ }
20
+ });
21
+ }
22
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
23
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveService });
24
+ }
25
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveService, decorators: [{
26
+ type: Injectable
27
+ }] });
28
+
29
+ class ElementActiveDirective {
30
+ el;
31
+ render;
32
+ elementService;
33
+ activeClass = "active";
34
+ constructor(el, render, elementService) {
35
+ this.el = el;
36
+ this.render = render;
37
+ this.elementService = elementService;
38
+ }
39
+ onClick() {
40
+ this.elementService.setActiveElement(this.el.nativeElement, this.activeClass);
41
+ this.render.addClass(this.el.nativeElement, this.activeClass);
42
+ }
43
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: ElementActiveService }], target: i0.ɵɵFactoryTarget.Directive });
44
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: ElementActiveDirective, isStandalone: true, selector: "[appElementActive]", inputs: { activeClass: "activeClass" }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
45
+ }
46
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveDirective, decorators: [{
47
+ type: Directive,
48
+ args: [{
49
+ selector: '[appElementActive]',
50
+ standalone: true,
51
+ }]
52
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: ElementActiveService }], propDecorators: { activeClass: [{
53
+ type: Input
54
+ }], onClick: [{
55
+ type: HostListener,
56
+ args: ['click']
57
+ }] } });
58
+
59
+ var ElementStatusType;
60
+ (function (ElementStatusType) {
61
+ ElementStatusType[ElementStatusType["SHOW"] = 0] = "SHOW";
62
+ ElementStatusType[ElementStatusType["HIDDEN"] = 1] = "HIDDEN";
63
+ ElementStatusType[ElementStatusType["DEFAULT"] = 2] = "DEFAULT";
64
+ })(ElementStatusType || (ElementStatusType = {}));
65
+
66
+ /**
67
+ * Service to manage the state and classes of HTML elements,
68
+ * used in menus and buttons to show or hide content.
69
+ *
70
+ */
71
+ class ElementToggleService {
72
+ elementStatus = signal(ElementStatusType.DEFAULT);
73
+ elementsHistory = [];
74
+ currentToggleClass = '';
75
+ /**
76
+ * Gets the current state of the element.
77
+ * @returns Signal with the current state.
78
+ */
79
+ get elementStatusToggle() {
80
+ if (this.elementStatus() === ElementStatusType.DEFAULT) {
81
+ console.warn('The element state is default. A different value should be set.');
82
+ }
83
+ return this.elementStatus;
84
+ }
85
+ /**
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
+ */
90
+ toggleByElementStatusType(status) {
91
+ if (status === ElementStatusType.DEFAULT) {
92
+ throw Error('The element state cannot be default.');
93
+ }
94
+ if (this.elementStatus() === ElementStatusType.SHOW &&
95
+ status === ElementStatusType.SHOW) {
96
+ this.elementStatus.set(ElementStatusType.HIDDEN);
97
+ }
98
+ else {
99
+ this.elementStatus.set(status);
100
+ }
101
+ }
102
+ /**
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
+ */
108
+ toggleByClassName(element, className) {
109
+ if (!className.trim()) {
110
+ throw Error('The class name cannot be null or empty.');
111
+ }
112
+ element.classList.toggle(className);
113
+ this.currentToggleClass = className;
114
+ if (!this.elementsHistory.includes(element)) {
115
+ this.elementsHistory.push(element);
116
+ }
117
+ }
118
+ /**
119
+ * Removes the active class from all elements stored in the history.
120
+ * @throws Error if the history is empty.
121
+ */
122
+ removeActiveClassToAllElements() {
123
+ if (this.elementsHistory.length <= 0) {
124
+ throw Error('The element history is empty.');
125
+ }
126
+ this.elementsHistory.forEach((element) => {
127
+ element.classList.remove(this.currentToggleClass);
128
+ });
129
+ }
130
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementToggleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
131
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementToggleService });
132
+ }
133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementToggleService, decorators: [{
134
+ type: Injectable
135
+ }] });
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
+
189
+ /*
190
+ * Public API Surface of core
191
+ */
192
+
193
+ /**
194
+ * Generated bundle index. Do not edit.
195
+ */
196
+
197
+ export { ElementActiveDirective, ElementActiveService, ElementStatusType, ElementToggleService, ScreenWidthEventService };
198
+ //# sourceMappingURL=c-code-c-code-fw.mjs.map
@@ -0,0 +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/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,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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;;;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;;;;"}
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Generated bundle index. Do not edit.
3
3
  */
4
- /// <amd-module name="core" />
4
+ /// <amd-module name="@c-code/c-code-fw" />
5
5
  export * from './public-api';
@@ -0,0 +1,37 @@
1
+ import { ElementStatusType } from './types/element_status-type';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Service to manage the state and classes of HTML elements,
5
+ * used in menus and buttons to show or hide content.
6
+ *
7
+ */
8
+ export declare class ElementToggleService {
9
+ private elementStatus;
10
+ private elementsHistory;
11
+ private currentToggleClass;
12
+ /**
13
+ * Gets the current state of the element.
14
+ * @returns Signal with the current state.
15
+ */
16
+ get elementStatusToggle(): import("@angular/core").WritableSignal<ElementStatusType>;
17
+ /**
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
+ */
22
+ toggleByElementStatusType(status: ElementStatusType): void;
23
+ /**
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
+ */
29
+ toggleByClassName(element: HTMLElement, className: string): void;
30
+ /**
31
+ * Removes the active class from all elements stored in the history.
32
+ * @throws Error if the history is empty.
33
+ */
34
+ removeActiveClassToAllElements(): void;
35
+ static ɵfac: i0.ɵɵFactoryDeclaration<ElementToggleService, never>;
36
+ static ɵprov: i0.ɵɵInjectableDeclaration<ElementToggleService>;
37
+ }
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum ElementStatusType {
2
+ SHOW = 0,
3
+ HIDDEN = 1,
4
+ DEFAULT = 2
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-code/c-code-fw",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^19.2.0",
6
6
  "@angular/core": "^19.2.0"
@@ -9,7 +9,7 @@
9
9
  "tslib": "^2.3.0"
10
10
  },
11
11
  "sideEffects": false,
12
- "module": "fesm2022/core.mjs",
12
+ "module": "fesm2022/c-code-c-code-fw.mjs",
13
13
  "typings": "index.d.ts",
14
14
  "exports": {
15
15
  "./package.json": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  ".": {
19
19
  "types": "./index.d.ts",
20
- "default": "./fesm2022/core.mjs"
20
+ "default": "./fesm2022/c-code-c-code-fw.mjs"
21
21
  }
22
22
  }
23
23
  }
package/public-api.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './lib/element-active.directive';
2
2
  export * from './lib/element-active.service';
3
- export * from './lib/element-open.service';
3
+ export * from './lib/element_toggle.service';
4
+ export * from './lib/types/element_status-type';
5
+ export * from './lib/screen_width-event.service';
package/fesm2022/core.mjs DELETED
@@ -1,84 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, HostListener, Input, Directive } from '@angular/core';
3
-
4
- class ElementActiveService {
5
- currentActiveElement = null;
6
- elementsClickedRegister = [];
7
- setActiveElement(element, classActiveName) {
8
- this.deactivateElementsOtherThanOneClicked(classActiveName, element);
9
- this.currentActiveElement = element;
10
- this.currentActiveElement.classList.add(classActiveName);
11
- if (!this.elementsClickedRegister.includes(element)) {
12
- this.elementsClickedRegister.push(element);
13
- }
14
- }
15
- deactivateElementsOtherThanOneClicked(classActiveName, excludeElement) {
16
- this.elementsClickedRegister.forEach(element => {
17
- if (element !== excludeElement) {
18
- element.classList.remove(classActiveName);
19
- }
20
- });
21
- }
22
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
23
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveService });
24
- }
25
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveService, decorators: [{
26
- type: Injectable
27
- }] });
28
-
29
- class ElementActiveDirective {
30
- el;
31
- render;
32
- elementService;
33
- activeClass = "active";
34
- constructor(el, render, elementService) {
35
- this.el = el;
36
- this.render = render;
37
- this.elementService = elementService;
38
- }
39
- onClick() {
40
- this.elementService.setActiveElement(this.el.nativeElement, this.activeClass);
41
- this.render.addClass(this.el.nativeElement, this.activeClass);
42
- }
43
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: ElementActiveService }], target: i0.ɵɵFactoryTarget.Directive });
44
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: ElementActiveDirective, isStandalone: true, selector: "[appElementActive]", inputs: { activeClass: "activeClass" }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
45
- }
46
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementActiveDirective, decorators: [{
47
- type: Directive,
48
- args: [{
49
- selector: '[appElementActive]',
50
- standalone: true,
51
- }]
52
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: ElementActiveService }], propDecorators: { activeClass: [{
53
- type: Input
54
- }], onClick: [{
55
- type: HostListener,
56
- args: ['click']
57
- }] } });
58
-
59
- class ElementOpenService {
60
- element;
61
- toggleActiveClass(element, classActive) {
62
- if (!element) {
63
- throw Error('El elemento ingresado es null, no se puede activar.');
64
- }
65
- this.element = element;
66
- this.element.classList.toggle(classActive);
67
- }
68
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementOpenService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
69
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementOpenService });
70
- }
71
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ElementOpenService, decorators: [{
72
- type: Injectable
73
- }] });
74
-
75
- /*
76
- * Public API Surface of core
77
- */
78
-
79
- /**
80
- * Generated bundle index. Do not edit.
81
- */
82
-
83
- export { ElementActiveDirective, ElementActiveService, ElementOpenService };
84
- //# sourceMappingURL=core.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.mjs","sources":["../../../projects/core/src/lib/element-active.service.ts","../../../projects/core/src/lib/element-active.directive.ts","../../../projects/core/src/lib/element-open.service.ts","../../../projects/core/src/public-api.ts","../../../projects/core/src/core.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 ","import { Injectable } from '@angular/core';\r\n\r\n@Injectable()\r\nexport class ElementOpenService{\r\n\r\n private element! : HTMLElement;\r\n\r\n toggleActiveClass(element : HTMLElement, classActive:string){\r\n if(!element){\r\n throw Error('El elemento ingresado es null, no se puede activar.');\r\n }\r\n this.element = element\r\n this.element.classList.toggle(classActive);\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-open.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,OA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A,KAAA,EAAA,EAAA,CAAA,SAAA,EAAA,EAAA,EAAA,KAAA,EAAAA,oBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAtB,sBAAsB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,oBAAA,EAAA,MAAA,EAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,WAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAtB,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAJlC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,UAAU,EAAE,IAAI;AACjB,iBAAA;uIAEU,WAAW,EAAA,CAAA;sBAAnB;gBAMsB,OAAO,EAAA,CAAA;sBAA7B,YAAY;uBAAC,OAAO;;;MCjBZ,kBAAkB,CAAA;AAEnB,IAAA,OAAO;IAEf,iBAAiB,CAAC,OAAqB,EAAE,WAAkB,EAAA;QACvD,IAAG,CAAC,OAAO,EAAC;AACR,YAAA,MAAM,KAAK,CAAC,qDAAqD,CAAC;;AAEtE,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;QACtB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC;;uGATrC,kBAAkB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAAlB,kBAAkB,EAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAD9B;;;ACFD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,7 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- export declare class ElementOpenService {
3
- private element;
4
- toggleActiveClass(element: HTMLElement, classActive: string): void;
5
- static ɵfac: i0.ɵɵFactoryDeclaration<ElementOpenService, never>;
6
- static ɵprov: i0.ɵɵInjectableDeclaration<ElementOpenService>;
7
- }