diff --git a/projects/core/src/services/dialog.service.ts b/projects/core/src/services/dialog.service.ts index 2cf6ac03..037b02a3 100644 --- a/projects/core/src/services/dialog.service.ts +++ b/projects/core/src/services/dialog.service.ts @@ -1,4 +1,4 @@ -import { Type } from '@angular/core'; +import { inject, Type } from '@angular/core'; import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dialog'; import { Observable, ReplaySubject, switchMap, take, throttleTime } from 'rxjs'; @@ -9,11 +9,10 @@ export abstract class NgxDialogService { protected dialogResponse$: Observable; protected dialogRef!: MatDialogRef; - public constructor( - private lazyLoaderService: NgxLazyLoaderService, - private dialog: MatDialog, - matDialogConfig?: MatDialogConfig - ) { + protected lazyLoaderService = inject(NgxLazyLoaderService); + protected dialog = inject(MatDialog); + + public constructor(matDialogConfig?: MatDialogConfig) { this.dialogResponse$ = this.openDialogSub$.pipe( throttleTime(11), take(1), diff --git a/projects/core/src/services/lazy-loader.service.ts b/projects/core/src/services/lazy-loader.service.ts index 16c2f853..ef2f69f1 100644 --- a/projects/core/src/services/lazy-loader.service.ts +++ b/projects/core/src/services/lazy-loader.service.ts @@ -1,5 +1,5 @@ import { ComponentType } from '@angular/cdk/portal'; -import { Injectable, Injector, ɵcreateInjector as createInjector, Type } from '@angular/core'; +import { ɵcreateInjector as createInjector, inject, Injectable, Injector, Type } from '@angular/core'; import { from, map, Observable } from 'rxjs'; export interface LoadModuleInfos { @@ -17,9 +17,7 @@ export abstract class NgxAbstractLazyModule { providedIn: 'root' }) export class NgxLazyLoaderService { - public constructor( - private injector: Injector - ) {} + private injector = inject(Injector); public loadModule$>(path: Promise>, parentInjector?: Injector): Observable> { return from(path).pipe( diff --git a/projects/core/src/services/media.service.ts b/projects/core/src/services/media.service.ts index 009f700b..e948f556 100644 --- a/projects/core/src/services/media.service.ts +++ b/projects/core/src/services/media.service.ts @@ -1,4 +1,4 @@ -import { Inject, Injectable, InjectionToken, NgZone, OnDestroy, Optional } from '@angular/core'; +import { inject, Injectable, InjectionToken, NgZone, OnDestroy } from '@angular/core'; import { BehaviorSubject, distinctUntilChanged, map, Observable, shareReplay } from 'rxjs'; export interface NgxMediaQueryDefinition { @@ -97,15 +97,16 @@ export class NgxMediaService implements OnDestroy { public mediaChanged$ = new BehaviorSubject('lg'); public mql = {} as Record; - public constructor( - private zone: NgZone, - @Optional() @Inject(mediaQueryDefinitions) mediaDefinitions?: NgxMediaQueryDefinition[] - ) { - if (!mediaDefinitions) { - mediaDefinitions = simplifiedMediaQueryDefinitions; + private zone = inject(NgZone); + private mediaDefinitions? = inject>(mediaQueryDefinitions, { optional: true }); + + + public constructor() { + if (!this.mediaDefinitions) { + this.mediaDefinitions = simplifiedMediaQueryDefinitions; } - mediaDefinitions.forEach(mediaDefinition => { + this.mediaDefinitions.forEach(mediaDefinition => { const { alias, mediaQuery } = mediaDefinition; this.mql[alias] = window.matchMedia(mediaQuery); // eslint-disable-next-line @typescript-eslint/no-unsafe-argument diff --git a/projects/date-picker/src/date-adapter/multi-format-date-adapter.ts b/projects/date-picker/src/date-adapter/multi-format-date-adapter.ts index c6ed67b7..38cdbf59 100644 --- a/projects/date-picker/src/date-adapter/multi-format-date-adapter.ts +++ b/projects/date-picker/src/date-adapter/multi-format-date-adapter.ts @@ -1,9 +1,9 @@ -import { Inject, inject, Injectable, InjectionToken, Optional, Type } from '@angular/core'; +import { inject, Injectable, InjectionToken, Type } from '@angular/core'; import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core'; import { format, isValid, Locale, setHours, setMinutes, setSeconds } from 'date-fns'; -import { validateAndParseDateStr } from './date.util'; import { DateTimeAdapter } from './date-time-adapter'; +import { validateAndParseDateStr } from './date.util'; // eslint-disable-next-line @typescript-eslint/naming-convention export const ACCEPTED_NON_DATE_VALUES = new InjectionToken('ACCEPTED_NON_DATE_VALUES'); @@ -37,13 +37,12 @@ export class NgxMultiFormatDateAdapter extends DateAdapter>>(MULTI_FORMAT_DATE_DELEGATE); // private matDateLocale = inject>(MAT_DATE_LOCALE, { optional: true }); //todo private acceptedValues = inject(ACCEPTED_NON_DATE_VALUES, { optional: true }); + private matDateLocale = inject>(MAT_DATE_LOCALE); - public constructor( - @Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: Record - ) { + public constructor() { super(); - this.locale = matDateLocale; - this.delegate = new this.delegateType(matDateLocale); + this.locale = this.matDateLocale; + this.delegate = new this.delegateType(this.matDateLocale); } public getYear(date: TypeForAdapter): number { diff --git a/projects/message-box-dialog/src/message-box-dialog.service.ts b/projects/message-box-dialog/src/message-box-dialog.service.ts index 3dee4ca2..6d4d4de9 100644 --- a/projects/message-box-dialog/src/message-box-dialog.service.ts +++ b/projects/message-box-dialog/src/message-box-dialog.service.ts @@ -1,6 +1,6 @@ import { Injectable, Type } from '@angular/core'; -import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; -import { NgxAbstractLazyModule, NgxDialogService, NgxLazyLoaderService } from '@hug/ngx-core'; +import { MatDialogConfig } from '@angular/material/dialog'; +import { NgxAbstractLazyModule, NgxDialogService } from '@hug/ngx-core'; import { Observable, take } from 'rxjs'; import { NgxMessageBoxDialogButtons, NgxMessageBoxDialogData, NgxMessageBoxDialogResponse } from './message-box-dialog.model'; @@ -9,11 +9,9 @@ import { NgxMessageBoxDialogButtons, NgxMessageBoxDialogData, NgxMessageBoxDialo providedIn: 'root' }) export class NgxMessageBoxDialogService extends NgxDialogService { - public constructor( - lazyLoaderService: NgxLazyLoaderService, - dialog: MatDialog - ) { - super(lazyLoaderService, dialog, { + + public constructor() { + super({ panelClass: 'no-padding-dialog' } as MatDialogConfig); } diff --git a/projects/status/src/status-detail/status-detail-dialog.service.ts b/projects/status/src/status-detail/status-detail-dialog.service.ts index 78372c10..350de36c 100644 --- a/projects/status/src/status-detail/status-detail-dialog.service.ts +++ b/projects/status/src/status-detail/status-detail-dialog.service.ts @@ -1,6 +1,6 @@ import { Injectable, Type } from '@angular/core'; -import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; -import { NgxAbstractLazyModule, NgxDialogService, NgxLazyLoaderService } from '@hug/ngx-core'; +import { MatDialogConfig } from '@angular/material/dialog'; +import { NgxAbstractLazyModule, NgxDialogService } from '@hug/ngx-core'; import { NgxStatus } from '../status.model'; @@ -8,11 +8,8 @@ import { NgxStatus } from '../status.model'; providedIn: 'root' }) export class NgxStatusDetailDialogService extends NgxDialogService { - public constructor( - lazyLoaderService: NgxLazyLoaderService, - dialog: MatDialog - ) { - super(lazyLoaderService, dialog, { + public constructor() { + super({ disableClose: false, hasBackdrop: true, width: '700px', diff --git a/projects/status/src/status-detail/status-detail.component.ts b/projects/status/src/status-detail/status-detail.component.ts index dba42515..2dccf222 100644 --- a/projects/status/src/status-detail/status-detail.component.ts +++ b/projects/status/src/status-detail/status-detail.component.ts @@ -1,5 +1,5 @@ -import { ChangeDetectionStrategy, Component, Inject, ViewEncapsulation } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { ChangeDetectionStrategy, Component, inject, ViewEncapsulation } from '@angular/core'; +import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import { NgxMessageBoxType } from '@hug/ngx-message-box'; import { NgxStatus } from '../status.model'; @@ -15,13 +15,12 @@ export class NgxStatusDetailComponent { protected fullTextError: string; protected messageBoxType: NgxMessageBoxType; - public constructor( - protected dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) protected status: NgxStatus - ) { - this.fullTextError = `Error Date: ${(status.date ?? new Date()).toUTCString()}\n${status.technicalText || ''}`; + protected status = inject(MAT_DIALOG_DATA); - switch (status.type) { + public constructor() { + this.fullTextError = `Error Date: ${(this.status.date ?? new Date()).toUTCString()}\n${this.status.technicalText || ''}`; + + switch (this.status.type) { case 'primary': this.messageBoxType = 'primary'; break; diff --git a/projects/tooltip/src/tooltip.service.ts b/projects/tooltip/src/tooltip.service.ts index 6838b193..6bca0ccd 100644 --- a/projects/tooltip/src/tooltip.service.ts +++ b/projects/tooltip/src/tooltip.service.ts @@ -1,12 +1,12 @@ import { ConnectedPosition } from '@angular/cdk/overlay'; -import { Type } from '@angular/core'; +import { inject, Type } from '@angular/core'; import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dialog'; import { NgxAbstractLazyModule, 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 { NgxTooltipConfig } from './tooltip.model'; import { NgxTooltipComponentInterface } from './tooltip-component.interface'; +import { NgxTooltipConfig } from './tooltip.model'; export abstract class NgxTooltipService { protected close$ = new Subject(); @@ -76,11 +76,10 @@ export abstract class NgxTooltipService { } ]; - public constructor( - private lazyLoaderService: NgxLazyLoaderService, - private dialog: MatDialog, - private tooltipConfig?: MatDialogConfig - ) { + protected lazyLoaderService = inject(NgxLazyLoaderService); + protected dialog = inject(MatDialog); + + public constructor(private tooltipConfig?: MatDialogConfig) { if (!this.tooltipConfig) { this.tooltipConfig = new MatDialogConfig(); } diff --git a/projects/user-tooltip/src/user-tooltip.service.ts b/projects/user-tooltip/src/user-tooltip.service.ts index 215c2306..90988802 100644 --- a/projects/user-tooltip/src/user-tooltip.service.ts +++ b/projects/user-tooltip/src/user-tooltip.service.ts @@ -1,6 +1,6 @@ import { Injectable, Type } from '@angular/core'; -import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; -import { NgxAbstractLazyModule, NgxLazyLoaderService } from '@hug/ngx-core'; +import { MatDialogConfig } from '@angular/material/dialog'; +import { NgxAbstractLazyModule } from '@hug/ngx-core'; import { NgxTooltipComponentInterface, NgxTooltipService } from '@hug/ngx-tooltip'; import { NgxUserCard } from '@hug/ngx-user-card'; @@ -8,11 +8,8 @@ import { NgxUserCard } from '@hug/ngx-user-card'; providedIn: 'root' }) export class NgxUserTooltipService extends NgxTooltipService { - public constructor( - lazyLoaderService: NgxLazyLoaderService, - dialog: MatDialog - ) { - super(lazyLoaderService, dialog, { + public constructor() { + super({ width: 'auto', minWidth: '16px', panelClass: 'no-padding-dialog'