@c-code/c-code-fw 0.0.1 → 1.1.2
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.
- package/fesm2022/c-code-c-code-fw.mjs +146 -0
- package/fesm2022/c-code-c-code-fw.mjs.map +1 -0
- package/index.d.ts +1 -1
- package/lib/element_toggle.service.d.ts +37 -0
- package/lib/types/element_status-type.d.ts +5 -0
- package/package.json +3 -3
- package/public-api.d.ts +2 -0
- package/fesm2022/core.mjs +0 -68
- package/fesm2022/core.mjs.map +0 -1
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
* Servicio para manejar el estado y las clases de elementos HTML,
|
|
68
|
+
* uso en menus y botones para mostrar o cerrar contenido
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
class ElementToggleService {
|
|
72
|
+
elementStatus = signal(ElementStatusType.DEFAULT);
|
|
73
|
+
elementsHistory = [];
|
|
74
|
+
currentToggleClass = '';
|
|
75
|
+
/**
|
|
76
|
+
* Obtiene el estado actual del elemento.
|
|
77
|
+
* @returns Signal con el estado actual.
|
|
78
|
+
*/
|
|
79
|
+
get elementStatusToggle() {
|
|
80
|
+
if (this.elementStatus() === ElementStatusType.DEFAULT) {
|
|
81
|
+
console.warn('El estado del elemento es default. Se debe insertar un valor diferente.');
|
|
82
|
+
}
|
|
83
|
+
return this.elementStatus;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
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.
|
|
89
|
+
*/
|
|
90
|
+
toggleByElementStatusType(status) {
|
|
91
|
+
if (status === ElementStatusType.DEFAULT) {
|
|
92
|
+
throw Error('El estado del elemento no puede ser 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
|
+
* 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.
|
|
107
|
+
*/
|
|
108
|
+
toggleByClassName(element, className) {
|
|
109
|
+
if (className == null || className == '') {
|
|
110
|
+
throw Error('El nombre de la clase no puede ser nulo o vacio.');
|
|
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
|
+
* Remueve la clase activa de todos los elementos almacenados en el historial.
|
|
120
|
+
* @throws Error si el historial está vacío.
|
|
121
|
+
*/
|
|
122
|
+
removeActiveClassToAllElements() {
|
|
123
|
+
if (this.elementsHistory.length <= 0) {
|
|
124
|
+
throw Error('El historial de elementos está vacío.');
|
|
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
|
+
* Public API Surface of core
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Generated bundle index. Do not edit.
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
export { ElementActiveDirective, ElementActiveService, ElementStatusType, ElementToggleService };
|
|
146
|
+
//# 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/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,CA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iB,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;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ElementStatusType } from './types/element_status-type';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Servicio para manejar el estado y las clases de elementos HTML,
|
|
5
|
+
* uso en menus y botones para mostrar o cerrar contenido
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export declare class ElementToggleService {
|
|
9
|
+
private elementStatus;
|
|
10
|
+
private elementsHistory;
|
|
11
|
+
private currentToggleClass;
|
|
12
|
+
/**
|
|
13
|
+
* Obtiene el estado actual del elemento.
|
|
14
|
+
* @returns Signal con el estado actual.
|
|
15
|
+
*/
|
|
16
|
+
get elementStatusToggle(): import("@angular/core").WritableSignal<ElementStatusType>;
|
|
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.
|
|
21
|
+
*/
|
|
22
|
+
toggleByElementStatusType(status: ElementStatusType): void;
|
|
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.
|
|
28
|
+
*/
|
|
29
|
+
toggleByClassName(element: HTMLElement, className: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Remueve la clase activa de todos los elementos almacenados en el historial.
|
|
32
|
+
* @throws Error si el historial está vacío.
|
|
33
|
+
*/
|
|
34
|
+
removeActiveClassToAllElements(): void;
|
|
35
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ElementToggleService, never>;
|
|
36
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ElementToggleService>;
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c-code/c-code-fw",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.2",
|
|
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/
|
|
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/
|
|
20
|
+
"default": "./fesm2022/c-code-c-code-fw.mjs"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
package/public-api.d.ts
CHANGED
package/fesm2022/core.mjs
DELETED
|
@@ -1,68 +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
|
-
/*
|
|
60
|
-
* Public API Surface of core
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Generated bundle index. Do not edit.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
export { ElementActiveDirective, ElementActiveService };
|
|
68
|
-
//# sourceMappingURL=core.mjs.map
|
package/fesm2022/core.mjs.map
DELETED
|
@@ -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/public-api.ts","../../../projects/core/src/core.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable()\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 ","/*\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';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.ElementActiveService"],"mappings":";;;MAGa,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,CAAA;kBADhC;;;MCWc,sBAAsB,CAAA;AAGvB,IAAA,EAAA;AACA,IAAA,MAAA;AACA,IAAA,cAAA;IAJD,WAAW,GAAU,QAAQ;AACtC,IAAA,WAAA,CACU,EAAc,EACd,MAAiB,EACjB,cAAoC,EAAA;QAFpC,IAAE,CAAA,EAAA,GAAF,EAAE;QACF,IAAM,CAAA,MAAA,GAAN,MAAM;QACN,IAAc,CAAA,cAAA,GAAd,cAAc;;IAED,OA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