Skip to content

Commit

Permalink
fix(ngx-tooltip): ngx prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
vapkse committed Jul 23, 2024
1 parent 1239feb commit 552ce59
Show file tree
Hide file tree
Showing 7 changed files with 806 additions and 27 deletions.
797 changes: 788 additions & 9 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion projects/tooltip/src/tooltip-component.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ElementRef } from '@angular/core';

export interface TooltipComponentInterface {
export interface NgxTooltipComponentInterface {
elementRef: ElementRef<HTMLElement>;
}
4 changes: 2 additions & 2 deletions projects/tooltip/src/tooltip.directive.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Directive, ElementRef, Input } from '@angular/core';
import { NgxDestroy } from '@hug/ngx-core';
import { fromEvent, Observable, of, switchMap, take, takeUntil, timer } from 'rxjs';
import { Observable, fromEvent, of, switchMap, take, takeUntil, timer } from 'rxjs';

@Directive({
selector: '[ngx-tooltip]',
standalone: true
})
export class TooltipDirective extends NgxDestroy {
export class NgxTooltipDirective extends NgxDestroy {
// eslint-disable-next-line @angular-eslint/no-input-rename
@Input('ngx-tooltip-delay') public delay = 300;

Expand Down
2 changes: 1 addition & 1 deletion projects/tooltip/src/tooltip.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MatDialogConfig } from '@angular/material/dialog';

export class TooltipConfig<D> extends MatDialogConfig<D> {
export class NgxTooltipConfig<D> extends MatDialogConfig<D> {
public hideDelay?: number;
}
18 changes: 9 additions & 9 deletions projects/tooltip/src/tooltip.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Type } from '@angular/core';
import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dialog';
import { AbstractLazyModule, NgxLazyLoaderService, subscribeWith } from '@hug/ngx-core';
import { merge } from 'lodash-es';
import { debounceTime, delay, EMPTY, filter, fromEvent, map, mergeWith, Observable, shareReplay, Subject, switchMap, tap, withLatestFrom } from 'rxjs';
import { EMPTY, Observable, Subject, debounceTime, delay, filter, fromEvent, map, mergeWith, shareReplay, switchMap, tap, withLatestFrom } from 'rxjs';

import { TooltipConfig } from './tooltip.model';
import { TooltipComponentInterface } from './tooltip-component.interface';
import { NgxTooltipComponentInterface } from './tooltip-component.interface';
import { NgxTooltipConfig } from './tooltip.model';

export abstract class TooltipService<D> {
export abstract class NgxTooltipService<D> {
protected close$ = new Subject<void>();

protected positions: readonly ConnectedPosition[] = [
Expand Down Expand Up @@ -86,7 +86,7 @@ export abstract class TooltipService<D> {
}
}

public open$(triggerElement: HTMLElement, tooltipData: D, tooltipConfig?: TooltipConfig<D>): Observable<void> {
public open$(triggerElement: HTMLElement, tooltipData: D, tooltipConfig?: NgxTooltipConfig<D>): Observable<void> {
this.close();

const additionalPanelClass = (tooltipConfig?.panelClass && tooltipConfig.panelClass instanceof Array && tooltipConfig.panelClass)
Expand All @@ -96,7 +96,7 @@ export abstract class TooltipService<D> {
const config = merge(tooltipConfig, {
hasBackdrop: false,
panelClass: ['ngx-tooltip-overlay', 'no-padding-dialog', 'ngx-tooltip-opening', ...additionalPanelClass]
} as TooltipConfig<D>);
} as NgxTooltipConfig<D>);


const dialogRef$ = this.openRef$(tooltipData, triggerElement, config).pipe(
Expand Down Expand Up @@ -147,15 +147,15 @@ export abstract class TooltipService<D> {
this.close$.next();
}

protected openRef$(tooltipData: D, triggerElement: HTMLElement, tooltipConfig: Partial<TooltipConfig<D>>): Observable<MatDialogRef<TooltipComponentInterface, void>> {
protected openRef$(tooltipData: D, triggerElement: HTMLElement, tooltipConfig: Partial<NgxTooltipConfig<D>>): Observable<MatDialogRef<NgxTooltipComponentInterface, void>> {
return this.lazyLoaderService.loadModule$(this.getModule()).pipe(
switchMap(moduleInfos => {
const config = merge({}, this.tooltipConfig, tooltipConfig || {} as Partial<MatDialogConfig<D>>);
config.data = tooltipData || {} as D;
config.minWidth = config.minWidth || '100px';
config.injector = moduleInfos.injector;

const dialogRef = this.dialog.open<TooltipComponentInterface, D, void>(moduleInfos.module.componentType, config);
const dialogRef = this.dialog.open<NgxTooltipComponentInterface, D, void>(moduleInfos.module.componentType, config);
return dialogRef.afterOpened().pipe(
map(() => dialogRef)
);
Expand Down Expand Up @@ -254,5 +254,5 @@ export abstract class TooltipService<D> {
);
}

protected abstract getModule(): Promise<Type<AbstractLazyModule<TooltipComponentInterface>>>;
protected abstract getModule(): Promise<Type<AbstractLazyModule<NgxTooltipComponentInterface>>>;
}
4 changes: 2 additions & 2 deletions projects/user-tooltip/src/user-tooltip.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ChangeDetectionStrategy, Component, ElementRef, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { TooltipComponentInterface } from '@hug/ngx-tooltip';
import { NgxTooltipComponentInterface } from '@hug/ngx-tooltip';
import { NgxUserCard } from '@hug/ngx-user-card';

@Component({
selector: 'ngx-user-tooltip',
templateUrl: './user-tooltip.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class NgxUserTooltipComponent implements TooltipComponentInterface {
export class NgxUserTooltipComponent implements NgxTooltipComponentInterface {
public constructor(
public elementRef: ElementRef<HTMLElement>,
@Inject(MAT_DIALOG_DATA) protected user: NgxUserCard
Expand Down
6 changes: 3 additions & 3 deletions projects/user-tooltip/src/user-tooltip.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Injectable, Type } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { AbstractLazyModule, NgxLazyLoaderService } from '@hug/ngx-core';
import { TooltipComponentInterface, TooltipService } from '@hug/ngx-tooltip';
import { NgxTooltipComponentInterface, NgxTooltipService } from '@hug/ngx-tooltip';
import { NgxUserCard } from '@hug/ngx-user-card';

@Injectable({
providedIn: 'root'
})
export class NgxUserTooltipService extends TooltipService<NgxUserCard> {
export class NgxUserTooltipService extends NgxTooltipService<NgxUserCard> {
public constructor(
lazyLoaderService: NgxLazyLoaderService,
dialog: MatDialog
Expand All @@ -19,7 +19,7 @@ export class NgxUserTooltipService extends TooltipService<NgxUserCard> {
} as MatDialogConfig<NgxUserCard>);
}

protected getModule(): Promise<Type<AbstractLazyModule<TooltipComponentInterface>>> {
protected getModule(): Promise<Type<AbstractLazyModule<NgxTooltipComponentInterface>>> {
return import('./user-tooltip.module').then(m => m.NgxUserTooltipModule);
}
}

0 comments on commit 552ce59

Please sign in to comment.