@dotglitch/ngx-common 1.0.3 → 1.0.7

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.
@@ -174,6 +174,7 @@ class TooltipComponent {
174
174
  this.dialogRef = dialogRef;
175
175
  this.hasBootstrapped = false;
176
176
  this.pointerIsOnVoid = false;
177
+ this.isLockedOpen = false;
177
178
  this.coverRectCords = {
178
179
  top: 0,
179
180
  left: 0,
@@ -207,7 +208,7 @@ class TooltipComponent {
207
208
  this.hasBootstrapped = true;
208
209
  if (this.pointerIsOnVoid)
209
210
  this.dialogRef.close();
210
- }, 10);
211
+ }, 200);
211
212
  }
212
213
  /**
213
214
  * Close the tooltip if these actions occur
@@ -218,9 +219,13 @@ class TooltipComponent {
218
219
  onPointerLeave() {
219
220
  this.dialogRef?.close();
220
221
  }
222
+ closeOnVoid() {
223
+ console.log("fuck you");
224
+ this.dialogRef.close();
225
+ }
221
226
  }
222
227
  TooltipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TooltipComponent, deps: [{ token: i0.ViewContainerRef }, { token: MAT_DIALOG_DATA, optional: true }, { token: i1.MatDialog, optional: true }, { token: i1.MatDialogRef, optional: true }], target: i0.ɵɵFactoryTarget.Component });
223
- TooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: TooltipComponent, isStandalone: true, selector: "ngx-tooltip", inputs: { data: "data", config: "config", ownerCords: "ownerCords", selfCords: "selfCords", template: "template" }, host: { listeners: { "window:resize": "onClose()", "window:blur": "onClose()", "pointerleave": "onPointerLeave()" } }, ngImport: i0, template: "<!-- Mouse event blocker for pointer leave -->\n<div\n *ngIf=\"coverRectCords\"\n class=\"owner-mask\"\n [style.top]=\"coverRectCords.top + 'px'\"\n [style.left]=\"coverRectCords.left + 'px'\"\n [style.height]=\"coverRectCords.height + 'px'\"\n [style.width]=\"coverRectCords.width + 'px'\"\n style=\"z-index: -1;\"\n></div>\n\n<div class=\"void\"\n (pointerenter)=\"pointerIsOnVoid = true; hasBootstrapped && dialogRef.close()\"\n (pointerleave)=\"pointerIsOnVoid = false\"\n (pointerdown)=\"hasBootstrapped && dialogRef.close()\"\n></div>\n\n<div class=\"container\">\n <ng-container\n *ngIf=\"isTemplate == false\"\n [ngComponentOutlet]=\"$any(template)\"\n >\n </ng-container>\n\n <ng-container\n *ngIf=\"isTemplate == true\"\n >\n <ng-container\n [ngTemplateOutlet]=\"$any(template)\"\n [ngTemplateOutletContext]=\"{ '$implicit': data }\"\n ></ng-container>\n </ng-container>\n</div>\n", styles: ["::ng-deep .cdk-overlay-container .ngx-tooltip{--mdc-dialog-container-color: var(--ngx-tooltip-background-color, #2f2f2f)}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog__container{transform-origin:top left}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog--open .mdc-dialog__container{transform:none}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog__surface{overflow:visible;background-color:#0000}::ng-deep .cdk-overlay-container .context-menu-backdrop.cdk-overlay-backdrop-showing{opacity:0}::ng-deep .cdk-overlay-pane.ngx-tooltip .mat-dialog-container{padding:0}:host{min-width:2px;min-height:2px;display:block}.void,.owner-mask{position:absolute}.void{top:-100vh;right:-100vw;bottom:-100vh;left:-100vw;z-index:-2}.container{width:100%;height:100%;background:var(--ngx-tooltip-background-color, #333);border-radius:6px;overflow:hidden}\n"], dependencies: [{ kind: "ngmodule", type:
228
+ TooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: TooltipComponent, isStandalone: true, selector: "ngx-tooltip", inputs: { data: "data", config: "config", ownerCords: "ownerCords", selfCords: "selfCords", template: "template" }, host: { listeners: { "window:resize": "onClose()", "window:blur": "onClose()", "pointerleave": "onPointerLeave()" } }, ngImport: i0, template: "<!-- Mouse event blocker for pointer leave -->\n<div\n *ngIf=\"coverRectCords\"\n class=\"owner-mask\"\n [style.top]=\"coverRectCords.top + 'px'\"\n [style.left]=\"coverRectCords.left + 'px'\"\n [style.height]=\"coverRectCords.height + 'px'\"\n [style.width]=\"coverRectCords.width + 'px'\"\n style=\"z-index: -1;\"\n></div>\n\n<div class=\"void\"\n (pointerenter)=\"pointerIsOnVoid = true; hasBootstrapped && !isLockedOpen && closeOnVoid()\"\n (pointerleave)=\"pointerIsOnVoid = false\"\n (pointerdown)=\"hasBootstrapped && dialogRef.close()\"\n></div>\n\n<div class=\"container\">\n <ng-container\n *ngIf=\"isTemplate == false\"\n [ngComponentOutlet]=\"$any(template)\"\n >\n </ng-container>\n\n <ng-container\n *ngIf=\"isTemplate == true\"\n >\n <ng-container\n [ngTemplateOutlet]=\"$any(template)\"\n [ngTemplateOutletContext]=\"{ '$implicit': data }\"\n ></ng-container>\n </ng-container>\n</div>\n", styles: ["::ng-deep .cdk-overlay-container .ngx-tooltip{--mdc-dialog-container-color: var(--ngx-tooltip-background-color, #2f2f2f)}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog__container{transform-origin:top left}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog--open .mdc-dialog__container{transform:none}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog__surface{overflow:visible;background-color:#0000}::ng-deep .cdk-overlay-container .context-menu-backdrop.cdk-overlay-backdrop-showing{opacity:0}::ng-deep .cdk-overlay-pane.ngx-tooltip .mat-dialog-container{padding:0}:host{min-width:2px;min-height:2px;display:block}.void,.owner-mask{position:absolute}.void{top:-100vh;right:-100vw;bottom:-100vh;left:-100vw;z-index:-2}.container{width:100%;height:100%;background:var(--ngx-tooltip-background-color, #333);border-radius:6px;overflow:hidden}\n"], dependencies: [{ kind: "ngmodule", type:
224
229
  // NgIf,
225
230
  // NgTemplateOutlet,
226
231
  // NgComponentOutlet,
@@ -232,7 +237,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
232
237
  // NgTemplateOutlet,
233
238
  // NgComponentOutlet,
234
239
  CommonModule,
235
- ], standalone: true, template: "<!-- Mouse event blocker for pointer leave -->\n<div\n *ngIf=\"coverRectCords\"\n class=\"owner-mask\"\n [style.top]=\"coverRectCords.top + 'px'\"\n [style.left]=\"coverRectCords.left + 'px'\"\n [style.height]=\"coverRectCords.height + 'px'\"\n [style.width]=\"coverRectCords.width + 'px'\"\n style=\"z-index: -1;\"\n></div>\n\n<div class=\"void\"\n (pointerenter)=\"pointerIsOnVoid = true; hasBootstrapped && dialogRef.close()\"\n (pointerleave)=\"pointerIsOnVoid = false\"\n (pointerdown)=\"hasBootstrapped && dialogRef.close()\"\n></div>\n\n<div class=\"container\">\n <ng-container\n *ngIf=\"isTemplate == false\"\n [ngComponentOutlet]=\"$any(template)\"\n >\n </ng-container>\n\n <ng-container\n *ngIf=\"isTemplate == true\"\n >\n <ng-container\n [ngTemplateOutlet]=\"$any(template)\"\n [ngTemplateOutletContext]=\"{ '$implicit': data }\"\n ></ng-container>\n </ng-container>\n</div>\n", styles: ["::ng-deep .cdk-overlay-container .ngx-tooltip{--mdc-dialog-container-color: var(--ngx-tooltip-background-color, #2f2f2f)}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog__container{transform-origin:top left}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog--open .mdc-dialog__container{transform:none}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog__surface{overflow:visible;background-color:#0000}::ng-deep .cdk-overlay-container .context-menu-backdrop.cdk-overlay-backdrop-showing{opacity:0}::ng-deep .cdk-overlay-pane.ngx-tooltip .mat-dialog-container{padding:0}:host{min-width:2px;min-height:2px;display:block}.void,.owner-mask{position:absolute}.void{top:-100vh;right:-100vw;bottom:-100vh;left:-100vw;z-index:-2}.container{width:100%;height:100%;background:var(--ngx-tooltip-background-color, #333);border-radius:6px;overflow:hidden}\n"] }]
240
+ ], standalone: true, template: "<!-- Mouse event blocker for pointer leave -->\n<div\n *ngIf=\"coverRectCords\"\n class=\"owner-mask\"\n [style.top]=\"coverRectCords.top + 'px'\"\n [style.left]=\"coverRectCords.left + 'px'\"\n [style.height]=\"coverRectCords.height + 'px'\"\n [style.width]=\"coverRectCords.width + 'px'\"\n style=\"z-index: -1;\"\n></div>\n\n<div class=\"void\"\n (pointerenter)=\"pointerIsOnVoid = true; hasBootstrapped && !isLockedOpen && closeOnVoid()\"\n (pointerleave)=\"pointerIsOnVoid = false\"\n (pointerdown)=\"hasBootstrapped && dialogRef.close()\"\n></div>\n\n<div class=\"container\">\n <ng-container\n *ngIf=\"isTemplate == false\"\n [ngComponentOutlet]=\"$any(template)\"\n >\n </ng-container>\n\n <ng-container\n *ngIf=\"isTemplate == true\"\n >\n <ng-container\n [ngTemplateOutlet]=\"$any(template)\"\n [ngTemplateOutletContext]=\"{ '$implicit': data }\"\n ></ng-container>\n </ng-container>\n</div>\n", styles: ["::ng-deep .cdk-overlay-container .ngx-tooltip{--mdc-dialog-container-color: var(--ngx-tooltip-background-color, #2f2f2f)}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog__container{transform-origin:top left}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog--open .mdc-dialog__container{transform:none}::ng-deep .cdk-overlay-container .ngx-tooltip .mdc-dialog__surface{overflow:visible;background-color:#0000}::ng-deep .cdk-overlay-container .context-menu-backdrop.cdk-overlay-backdrop-showing{opacity:0}::ng-deep .cdk-overlay-pane.ngx-tooltip .mat-dialog-container{padding:0}:host{min-width:2px;min-height:2px;display:block}.void,.owner-mask{position:absolute}.void{top:-100vh;right:-100vw;bottom:-100vh;left:-100vw;z-index:-2}.container{width:100%;height:100%;background:var(--ngx-tooltip-background-color, #333);border-radius:6px;overflow:hidden}\n"] }]
236
241
  }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: undefined, decorators: [{
237
242
  type: Optional
238
243
  }, {
@@ -275,20 +280,47 @@ class TooltipDirective {
275
280
  * Arbitrary data to pass into the template
276
281
  */
277
282
  this.data = {};
283
+ this.isCursorOverTarget = false;
284
+ this.isFreezeOnKeyCodeBound = false;
285
+ this.onKeyDownEvt = this.onKeyDown.bind(this);
286
+ if (this.config.freezeOnKeyCode !== null) {
287
+ this.isFreezeOnKeyCodeBound = true;
288
+ document.body.addEventListener("keydown", this.onKeyDownEvt);
289
+ }
278
290
  }
279
- ngOnInit() {
291
+ ngOnDestroy() {
292
+ if (this.isFreezeOnKeyCodeBound) {
293
+ document.body.removeEventListener("keydown", this.onKeyDownEvt);
294
+ }
295
+ }
296
+ onKeyDown(evt) {
297
+ // TODO: fade message 'tooltip is locked open'
298
+ if (evt.code == ("F2")) {
299
+ this.dialogInstance.componentInstance.isLockedOpen = true;
300
+ }
280
301
  }
281
302
  // Needs to be public so we can manually open the dialog
282
303
  async onPointerEnter(evt) {
283
304
  // If the template is not a template ref, do nothing.
284
305
  if (!(this.template instanceof TemplateRef))
285
306
  return;
286
- const el = this.viewContainer.element.nativeElement;
287
- this.dialogInstance = await openTooltip(this.dialog, this.template, this.data, el, this.config);
307
+ this.isCursorOverTarget = true;
308
+ setTimeout(async () => {
309
+ // If the cursor moved away in the time
310
+ if (!this.isCursorOverTarget)
311
+ return;
312
+ if (!this.dialogInstance) {
313
+ const el = this.viewContainer.element.nativeElement;
314
+ this.dialogInstance = await openTooltip(this.dialog, this.template, this.data, el, this.config);
315
+ }
316
+ }, this.config.delay ?? 250);
317
+ }
318
+ async onPointerLeave(evt) {
319
+ this.isCursorOverTarget = false;
288
320
  }
289
321
  }
290
322
  TooltipDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TooltipDirective, deps: [{ token: i1.MatDialog }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
291
- TooltipDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: TooltipDirective, isStandalone: true, selector: "[ngxTooltip],[ngx-tooltip]", inputs: { template: ["ngx-tooltip", "template"], config: ["ngx-tooltip-config", "config"], data: ["ngx-tooltip-context", "data"] }, host: { listeners: { "pointerenter": "onPointerEnter($event)" } }, providers: [
323
+ TooltipDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: TooltipDirective, isStandalone: true, selector: "[ngxTooltip],[ngx-tooltip]", inputs: { template: ["ngx-tooltip", "template"], config: ["ngx-tooltip-config", "config"], data: ["ngx-tooltip-context", "data"] }, host: { listeners: { "pointerenter": "onPointerEnter($event)", "pointerleave": "onPointerLeave($event)" } }, providers: [
292
324
  MatDialog
293
325
  ], ngImport: i0 });
294
326
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TooltipDirective, decorators: [{
@@ -321,6 +353,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
321
353
  }], onPointerEnter: [{
322
354
  type: HostListener,
323
355
  args: ['pointerenter', ['$event']]
356
+ }], onPointerLeave: [{
357
+ type: HostListener,
358
+ args: ['pointerleave', ['$event']]
324
359
  }] } });
325
360
  // Helper to open the context menu without using the directive.
326
361
  const openTooltip = async (dialog, template, data, el, config) => {
@@ -482,10 +517,10 @@ class MenuComponent {
482
517
  }
483
518
  });
484
519
  // Show the icon column if there are any items with an icon
485
- this.showIconColumn = !!this.items.find(i => typeof i == "object" &&
520
+ this.showIconColumn = !!this.items?.find(i => typeof i == "object" &&
486
521
  typeof i['icon'] == "string" &&
487
522
  i['icon'].length > 2);
488
- this.showShortcutColumn = !!this.items.find(i => typeof i == "object" &&
523
+ this.showShortcutColumn = !!this.items?.find(i => typeof i == "object" &&
489
524
  typeof i['shortcut'] == "string" &&
490
525
  i['shortcut'].length > 2);
491
526
  // setTimeout(() => {
@@ -672,7 +707,6 @@ class MenuDirective {
672
707
  });
673
708
  }
674
709
  if (!this.config?.trigger) {
675
- el.onclick = this.openMenu.bind(this);
676
710
  el.addEventListener('click', this.openMenu.bind(this));
677
711
  }
678
712
  else {
@@ -693,7 +727,7 @@ class MenuDirective {
693
727
  async openMenu(evt) {
694
728
  const el = this.viewContainer.element.nativeElement;
695
729
  el.classList.add("ngx-menu-open");
696
- return openMenu(this.dialog, this.menuItems, this.data, evt, this.config)
730
+ return openMenu(this.dialog, this.menuItems, this.data, evt, this.config, el)
697
731
  .then((...res) => {
698
732
  el.classList.remove("ngx-menu-open");
699
733
  return res;
@@ -705,36 +739,48 @@ class MenuDirective {
705
739
  }
706
740
  }
707
741
  MenuDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MenuDirective, deps: [{ token: i1.MatDialog }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
708
- MenuDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: MenuDirective, isStandalone: true, selector: "[ngx-ctxmenu],[ngx-menu]", inputs: { data: ["ngx-menu-context", "data"], ctxMenuItems: ["ngx-ctxmenu", "ctxMenuItems"], menuItems: ["ngx-menu", "menuItems"], config: ["ngx-menu-config", "config"] }, providers: [
742
+ MenuDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: MenuDirective, isStandalone: true, selector: "[ngx-contextmenu],[ngx-menu],[ngxContextmenu],[ngxMenu]", inputs: { data: ["ngx-menu-context", "data"], ctxMenuItems: ["ngx-contextmenu", "ctxMenuItems"], menuItems: ["ngx-menu", "menuItems"], config: ["ngx-menu-config", "config"] }, providers: [
709
743
  MatDialog
710
744
  ], ngImport: i0 });
711
745
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MenuDirective, decorators: [{
712
746
  type: Directive,
713
747
  args: [{
714
- selector: '[ngx-ctxmenu],[ngx-menu]',
748
+ selector: '[ngx-contextmenu],[ngx-menu],[ngxContextmenu],[ngxMenu]',
715
749
  providers: [
716
750
  MatDialog
717
751
  ],
718
752
  standalone: true
719
753
  }]
720
754
  }], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: i0.ViewContainerRef }]; }, propDecorators: { data: [{
755
+ type: Input,
756
+ args: ["ngxMenuContext"]
757
+ }, {
721
758
  type: Input,
722
759
  args: ["ngx-menu-context"]
723
760
  }], ctxMenuItems: [{
724
761
  type: Input,
725
- args: ["ngx-ctxmenu"]
762
+ args: ["ngxContextmenu"]
763
+ }, {
764
+ type: Input,
765
+ args: ["ngx-contextmenu"]
726
766
  }], menuItems: [{
767
+ type: Input,
768
+ args: ["ngxMenu"]
769
+ }, {
727
770
  type: Input,
728
771
  args: ["ngx-menu"]
729
772
  }], config: [{
773
+ type: Input,
774
+ args: ["ngxMenuConfig"]
775
+ }, {
730
776
  type: Input,
731
777
  args: ["ngx-menu-config"]
732
778
  }] } });
733
- // Helper to open the context menu without using the directive.
734
- const openMenu = async (dialog, menuItems, data, evt, config = {}) => {
779
+ // Helper to open the menu without using the directive.
780
+ const openMenu = async (dialog, menuItems, data, evt, config = {}, el) => {
735
781
  evt.preventDefault();
736
782
  evt.stopPropagation();
737
- const cords = getPosition(evt, config, await calcMenuItemBounds(menuItems, data));
783
+ const cords = getPosition(el || evt, config, await calcMenuItemBounds(menuItems, data));
738
784
  const specificId = crypto.randomUUID();
739
785
  if (!config.alignment)
740
786
  config.alignment = "start";
@@ -1966,7 +2012,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1966
2012
  * Public API Surface of package
1967
2013
  */
1968
2014
  /**
1969
- ** Directives
2015
+ ** Types
1970
2016
  */
1971
2017
 
1972
2018
  /**