@dvirus-js/angular 0.0.2 → 0.0.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,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, ElementRef, input, output, effect, Directive } from '@angular/core';
2
+ import { inject, ElementRef, EventEmitter, Output, Input, Directive } from '@angular/core';
3
3
 
4
4
  /**
5
5
  * Directive that emits an event when a click occurs outside the host element or a group of elements.
@@ -22,42 +22,41 @@ class ClickOutsideDirective {
22
22
  * Optional group of elements to consider as 'inside'.
23
23
  * If the click is inside any of these, the event will not fire.
24
24
  */
25
- group = input([], ...(ngDevMode ? [{ debugName: "group" }] : []));
25
+ group = [];
26
26
  /**
27
27
  * Event emitted when a click occurs outside the host and group elements.
28
28
  */
29
- clickOutside = output();
29
+ clickOutside = new EventEmitter();
30
30
  /**
31
31
  * Handles document click events and emits if the click is outside.
32
32
  * @param event MouseEvent from the document
33
33
  */
34
34
  handleClick = (event) => {
35
- const allElements = [this.el.nativeElement, ...this.group()];
35
+ const allElements = [this.el.nativeElement, ...this.group];
36
36
  const clickedInside = allElements.some((el) => el.contains(event.target));
37
37
  if (!clickedInside) {
38
38
  this.clickOutside.emit(event);
39
39
  }
40
40
  };
41
- /**
42
- * Sets up the document click listener and cleans up on destroy.
43
- */
44
- constructor() {
45
- effect((cleanFn) => {
46
- document.addEventListener('click', this.handleClick, true);
47
- cleanFn(() => {
48
- document.removeEventListener('click', this.handleClick, true);
49
- });
50
- });
41
+ ngOnInit() {
42
+ document.addEventListener('click', this.handleClick, true);
43
+ }
44
+ ngOnDestroy() {
45
+ document.removeEventListener('click', this.handleClick, true);
51
46
  }
52
47
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: ClickOutsideDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
53
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.4", type: ClickOutsideDirective, isStandalone: true, selector: "[djsClickOutside]", inputs: { group: { classPropertyName: "group", publicName: "group", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { clickOutside: "clickOutside" }, ngImport: i0 });
48
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.4", type: ClickOutsideDirective, isStandalone: true, selector: "[djsClickOutside]", inputs: { group: "group" }, outputs: { clickOutside: "clickOutside" }, ngImport: i0 });
54
49
  }
55
50
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: ClickOutsideDirective, decorators: [{
56
51
  type: Directive,
57
52
  args: [{
58
53
  selector: '[djsClickOutside]',
59
54
  }]
60
- }], ctorParameters: () => [], propDecorators: { group: [{ type: i0.Input, args: [{ isSignal: true, alias: "group", required: false }] }], clickOutside: [{ type: i0.Output, args: ["clickOutside"] }] } });
55
+ }], propDecorators: { group: [{
56
+ type: Input
57
+ }], clickOutside: [{
58
+ type: Output
59
+ }] } });
61
60
 
62
61
  /**
63
62
  * Generated bundle index. Do not edit.
@@ -1 +1 @@
1
- {"version":3,"file":"dvirus-js-angular.mjs","sources":["../../../../../packages/angular/angular-utils/src/lib/directives/click-outside.directive.ts","../../../../../packages/angular/angular-utils/src/dvirus-js-angular.ts"],"sourcesContent":["import { Directive, effect, ElementRef, inject, input, output } from '@angular/core';\n\n/**\n * Directive that emits an event when a click occurs outside the host element or a group of elements.\n *\n * Usage:\n * ```html\n * <div [clickOutside]=\"handler\"></div>\n * ```\n *\n * - Emits `clickOutside` when a click is detected outside the host and any elements in the `group` input.\n * - Useful for closing popups, dropdowns, or dialogs when clicking outside.\n */\n@Directive({\n selector: '[djsClickOutside]',\n})\nexport class ClickOutsideDirective {\n /**\n * Reference to the host element.\n * @internal\n */\n private el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Optional group of elements to consider as 'inside'.\n * If the click is inside any of these, the event will not fire.\n */\n group = input<HTMLElement[]>([]);\n\n /**\n * Event emitted when a click occurs outside the host and group elements.\n */\n clickOutside = output<MouseEvent>();\n\n /**\n * Handles document click events and emits if the click is outside.\n * @param event MouseEvent from the document\n */\n private handleClick = (event: MouseEvent) => {\n const allElements = [this.el.nativeElement, ...this.group()];\n const clickedInside = allElements.some((el) => el.contains(event.target as Node));\n\n if (!clickedInside) {\n this.clickOutside.emit(event);\n }\n };\n\n /**\n * Sets up the document click listener and cleans up on destroy.\n */\n constructor() {\n effect((cleanFn) => {\n document.addEventListener('click', this.handleClick, true);\n\n cleanFn(() => {\n document.removeEventListener('click', this.handleClick, true);\n });\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAEA;;;;;;;;;;AAUG;MAIU,qBAAqB,CAAA;AAChC;;;AAGG;AACK,IAAA,EAAE,GAAG,MAAM,CAA0B,UAAU,CAAC;AAExD;;;AAGG;AACH,IAAA,KAAK,GAAG,KAAK,CAAgB,EAAE,iDAAC;AAEhC;;AAEG;IACH,YAAY,GAAG,MAAM,EAAc;AAEnC;;;AAGG;AACK,IAAA,WAAW,GAAG,CAAC,KAAiB,KAAI;AAC1C,QAAA,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC5D,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC,CAAC;QAEjF,IAAI,CAAC,aAAa,EAAE;AAClB,YAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAC/B;AACF,IAAA,CAAC;AAED;;AAEG;AACH,IAAA,WAAA,GAAA;AACE,QAAA,MAAM,CAAC,CAAC,OAAO,KAAI;YACjB,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;YAE1D,OAAO,CAAC,MAAK;gBACX,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;AAC/D,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;IACJ;uGA1CW,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAArB,qBAAqB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,YAAA,EAAA,cAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAArB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAHjC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,mBAAmB;AAC9B,iBAAA;;;ACfD;;AAEG;;;;"}
1
+ {"version":3,"file":"dvirus-js-angular.mjs","sources":["../../../../../packages/angular/angular-utils/src/lib/directives/click-outside.directive.ts","../../../../../packages/angular/angular-utils/src/dvirus-js-angular.ts"],"sourcesContent":["import { Directive, ElementRef, EventEmitter, inject, Input, OnDestroy, OnInit, Output } from '@angular/core';\n\n/**\n * Directive that emits an event when a click occurs outside the host element or a group of elements.\n *\n * Usage:\n * ```html\n * <div [clickOutside]=\"handler\"></div>\n * ```\n *\n * - Emits `clickOutside` when a click is detected outside the host and any elements in the `group` input.\n * - Useful for closing popups, dropdowns, or dialogs when clicking outside.\n */\n@Directive({\n selector: '[djsClickOutside]',\n})\nexport class ClickOutsideDirective implements OnInit, OnDestroy {\n /**\n * Reference to the host element.\n * @internal\n */\n private el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Optional group of elements to consider as 'inside'.\n * If the click is inside any of these, the event will not fire.\n */\n @Input() group: HTMLElement[] = [];\n\n /**\n * Event emitted when a click occurs outside the host and group elements.\n */\n @Output() clickOutside = new EventEmitter<MouseEvent>();\n\n /**\n * Handles document click events and emits if the click is outside.\n * @param event MouseEvent from the document\n */\n private handleClick = (event: MouseEvent) => {\n const allElements = [this.el.nativeElement, ...this.group];\n const clickedInside = allElements.some((el) => el.contains(event.target as Node));\n\n if (!clickedInside) {\n this.clickOutside.emit(event);\n }\n };\n\n ngOnInit(): void {\n document.addEventListener('click', this.handleClick, true);\n }\n\n ngOnDestroy(): void {\n document.removeEventListener('click', this.handleClick, true);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAEA;;;;;;;;;;AAUG;MAIU,qBAAqB,CAAA;AAChC;;;AAGG;AACK,IAAA,EAAE,GAAG,MAAM,CAA0B,UAAU,CAAC;AAExD;;;AAGG;IACM,KAAK,GAAkB,EAAE;AAElC;;AAEG;AACO,IAAA,YAAY,GAAG,IAAI,YAAY,EAAc;AAEvD;;;AAGG;AACK,IAAA,WAAW,GAAG,CAAC,KAAiB,KAAI;AAC1C,QAAA,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC1D,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC,CAAC;QAEjF,IAAI,CAAC,aAAa,EAAE;AAClB,YAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAC/B;AACF,IAAA,CAAC;IAED,QAAQ,GAAA;QACN,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;IAC5D;IAEA,WAAW,GAAA;QACT,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;IAC/D;uGArCW,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAArB,qBAAqB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,OAAA,EAAA,EAAA,OAAA,EAAA,EAAA,YAAA,EAAA,cAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAArB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAHjC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,mBAAmB;AAC9B,iBAAA;;sBAYE;;sBAKA;;;AChCH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dvirus-js/angular",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "peerDependencies": {
5
- "@angular/core": "^21.1.0",
6
- "@angular/forms": "^21.1.0"
5
+ "@angular/core": ">=16.0.0 <22.0.0",
6
+ "@angular/forms": ">=16.0.0 <22.0.0"
7
7
  },
8
8
  "sideEffects": false,
9
9
  "publishConfig": {
@@ -1,4 +1,5 @@
1
- import * as _angular_core from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { OnInit, OnDestroy, EventEmitter } from '@angular/core';
2
3
 
3
4
  /**
4
5
  * Directive that emits an event when a click occurs outside the host element or a group of elements.
@@ -11,7 +12,7 @@ import * as _angular_core from '@angular/core';
11
12
  * - Emits `clickOutside` when a click is detected outside the host and any elements in the `group` input.
12
13
  * - Useful for closing popups, dropdowns, or dialogs when clicking outside.
13
14
  */
14
- declare class ClickOutsideDirective {
15
+ declare class ClickOutsideDirective implements OnInit, OnDestroy {
15
16
  /**
16
17
  * Reference to the host element.
17
18
  * @internal
@@ -21,22 +22,20 @@ declare class ClickOutsideDirective {
21
22
  * Optional group of elements to consider as 'inside'.
22
23
  * If the click is inside any of these, the event will not fire.
23
24
  */
24
- group: _angular_core.InputSignal<HTMLElement[]>;
25
+ group: HTMLElement[];
25
26
  /**
26
27
  * Event emitted when a click occurs outside the host and group elements.
27
28
  */
28
- clickOutside: _angular_core.OutputEmitterRef<MouseEvent>;
29
+ clickOutside: EventEmitter<MouseEvent>;
29
30
  /**
30
31
  * Handles document click events and emits if the click is outside.
31
32
  * @param event MouseEvent from the document
32
33
  */
33
34
  private handleClick;
34
- /**
35
- * Sets up the document click listener and cleans up on destroy.
36
- */
37
- constructor();
38
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<ClickOutsideDirective, never>;
39
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<ClickOutsideDirective, "[djsClickOutside]", never, { "group": { "alias": "group"; "required": false; "isSignal": true; }; }, { "clickOutside": "clickOutside"; }, never, never, true, never>;
35
+ ngOnInit(): void;
36
+ ngOnDestroy(): void;
37
+ static ɵfac: i0.ɵɵFactoryDeclaration<ClickOutsideDirective, never>;
38
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ClickOutsideDirective, "[djsClickOutside]", never, { "group": { "alias": "group"; "required": false; }; }, { "clickOutside": "clickOutside"; }, never, never, true, never>;
40
39
  }
41
40
 
42
41
  export { ClickOutsideDirective };