Skip to content

Commit

Permalink
Merge branch 'ng18b'
Browse files Browse the repository at this point in the history
  • Loading branch information
Badisi committed Sep 11, 2024
2 parents 335274d + 6559722 commit 7bcd0f1
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 69 deletions.
11 changes: 5 additions & 6 deletions projects/core/src/services/dialog.service.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -9,11 +9,10 @@ export abstract class NgxDialogService<ReturnType, DataType> {
protected dialogResponse$: Observable<ReturnType | undefined>;
protected dialogRef!: MatDialogRef<unknown, ReturnType>;

public constructor(
private lazyLoaderService: NgxLazyLoaderService,
private dialog: MatDialog,
matDialogConfig?: MatDialogConfig<DataType>
) {
protected lazyLoaderService = inject(NgxLazyLoaderService);
protected dialog = inject(MatDialog);

public constructor(matDialogConfig?: MatDialogConfig<DataType>) {
this.dialogResponse$ = this.openDialogSub$.pipe(
throttleTime(11),
take(1),
Expand Down
6 changes: 2 additions & 4 deletions projects/core/src/services/lazy-loader.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentType } from '@angular/cdk/portal';
import { Injectable, Injector, ɵcreateInjector as createInjector, Type } from '@angular/core';
import { inject, Injectable, Injector, ɵcreateInjector as createInjector, Type } from '@angular/core';
import { from, map, Observable } from 'rxjs';

export interface LoadModuleInfos<T> {
Expand All @@ -17,9 +17,7 @@ export abstract class NgxAbstractLazyModule<Component> {
providedIn: 'root'
})
export class NgxLazyLoaderService {
public constructor(
private injector: Injector
) {}
private injector = inject(Injector);

public loadModule$<T extends NgxAbstractLazyModule<unknown>>(path: Promise<Type<T>>, parentInjector?: Injector): Observable<LoadModuleInfos<T>> {
return from(path).pipe(
Expand Down
17 changes: 9 additions & 8 deletions projects/core/src/services/media.service.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -97,15 +97,16 @@ export class NgxMediaService implements OnDestroy {
public mediaChanged$ = new BehaviorSubject('lg');
public mql = {} as Record<string, MediaQueryList>;

public constructor(
private zone: NgZone,
@Optional() @Inject(mediaQueryDefinitions) mediaDefinitions?: NgxMediaQueryDefinition[]
) {
if (!mediaDefinitions) {
mediaDefinitions = simplifiedMediaQueryDefinitions;
private zone = inject(NgZone);
private mediaDefinitions? = inject<NgxMediaQueryDefinition[]>(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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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';

Expand Down Expand Up @@ -37,13 +37,12 @@ export class NgxMultiFormatDateAdapter extends DateAdapter<TypeForAdapter, Local
private delegateType = inject<Type<DateAdapter<Date>>>(MULTI_FORMAT_DATE_DELEGATE);
// private matDateLocale = inject<Record<string, unknown>>(MAT_DATE_LOCALE, { optional: true }); //todo
private acceptedValues = inject<readonly (string | RegExp)[]>(ACCEPTED_NON_DATE_VALUES, { optional: true });
private matDateLocale = inject<Record<string, unknown>>(MAT_DATE_LOCALE);

public constructor(
@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: Record<string, unknown>
) {
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 {
Expand Down
12 changes: 5 additions & 7 deletions projects/message-box-dialog/src/message-box-dialog.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -9,11 +9,9 @@ import { NgxMessageBoxDialogButtons, NgxMessageBoxDialogData, NgxMessageBoxDialo
providedIn: 'root'
})
export class NgxMessageBoxDialogService extends NgxDialogService<NgxMessageBoxDialogResponse, NgxMessageBoxDialogData | string> {
public constructor(
lazyLoaderService: NgxLazyLoaderService,
dialog: MatDialog
) {
super(lazyLoaderService, dialog, {

public constructor() {
super({
panelClass: 'no-padding-dialog'
} as MatDialogConfig<NgxMessageBoxDialogData>);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
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';

@Injectable({
providedIn: 'root'
})
export class NgxStatusDetailDialogService extends NgxDialogService<void, NgxStatus> {
public constructor(
lazyLoaderService: NgxLazyLoaderService,
dialog: MatDialog
) {
super(lazyLoaderService, dialog, {
public constructor() {
super({
disableClose: false,
hasBackdrop: true,
width: '700px',
Expand Down
15 changes: 7 additions & 8 deletions projects/status/src/status-detail/status-detail.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,13 +15,12 @@ export class NgxStatusDetailComponent {
protected fullTextError: string;
protected messageBoxType: NgxMessageBoxType;

public constructor(
protected dialogRef: MatDialogRef<NgxStatusDetailComponent, void>,
@Inject(MAT_DIALOG_DATA) protected status: NgxStatus
) {
this.fullTextError = `Error Date: ${(status.date ?? new Date()).toUTCString()}\n${status.technicalText || ''}`;
protected status = inject<NgxStatus>(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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormsModule } from '@angular/forms';
import { MatButtonToggle, MatButtonToggleGroup } from '@angular/material/button-toggle';
import { MatFormField, MatLabel, MatPrefix, MatSuffix } from '@angular/material/form-field';
import { MatInput } from '@angular/material/input';
Expand All @@ -18,7 +18,7 @@ const meta: Meta<NgxNumericStepperComponent> = {
}),
moduleMetadata({
imports: [
MatLabel, MatInput, MatPrefix, MatSuffix, MatFormField, ReactiveFormsModule, FormsModule
MatLabel, MatInput, MatPrefix, MatSuffix, MatFormField, FormsModule
]
})
],
Expand Down
4 changes: 2 additions & 2 deletions projects/story-book/src/overlay/overlay.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormsModule } from '@angular/forms';
import { MatButton, MatIconButton } from '@angular/material/button';
import { MatFormField, MatHint, MatLabel } from '@angular/material/form-field';
import { MatIcon } from '@angular/material/icon';
Expand Down Expand Up @@ -113,7 +113,7 @@ export const overlayWidth: Story = {
decorators: [
moduleMetadata({
imports: [
MatFormField, MatLabel, MatHint, FormsModule, MatInput, ReactiveFormsModule
MatFormField, MatLabel, MatHint, FormsModule, MatInput
]
})
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FormsModule } from '@angular/forms';
import { MatList, MatListItem } from '@angular/material/list';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatTooltip } from '@angular/material/tooltip';
import { type Meta, moduleMetadata, type StoryObj } from '@storybook/angular';

import { NgxSearchContainerComponent, NgxSearchInputDirective } from '../../../search-container/src/search-container.component';
Expand All @@ -13,7 +13,7 @@ const meta: Meta<NgxSearchContainerComponent> = {
moduleMetadata({
imports: [
NgxSearchInputDirective,
MatTooltipModule,
MatTooltip,
FormsModule
]
})
Expand Down
4 changes: 2 additions & 2 deletions projects/story-book/src/splitter/splitter.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormsModule } from '@angular/forms';
import { MatButtonToggle, MatButtonToggleGroup } from '@angular/material/button-toggle';
import { MatFormField, MatLabel } from '@angular/material/form-field';
import { MatInput } from '@angular/material/input';
Expand Down Expand Up @@ -252,7 +252,7 @@ export const customizableSplitAreas: Story = {
decorators: [
moduleMetadata({
imports: [
MatFormField, MatLabel, FormsModule, MatInput, ReactiveFormsModule
MatFormField, MatLabel, FormsModule, MatInput
]
})
],
Expand Down
4 changes: 2 additions & 2 deletions projects/story-book/src/user-card/user-card.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatButtonToggle } from '@angular/material/button-toggle';
import { type Meta, moduleMetadata, type StoryObj } from '@storybook/angular';

import { NgxUserCardComponent } from '../../../user-card/src/user-card.component';
Expand All @@ -11,7 +11,7 @@ const meta: Meta<NgxUserCardComponent> = {
decorators: [
moduleMetadata({
imports: [
MatButtonToggleModule
MatButtonToggle
]
})
],
Expand Down
11 changes: 5 additions & 6 deletions projects/tooltip/src/tooltip.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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';
Expand Down Expand Up @@ -76,11 +76,10 @@ export abstract class NgxTooltipService<D> {
}
];

public constructor(
private lazyLoaderService: NgxLazyLoaderService,
private dialog: MatDialog,
private tooltipConfig?: MatDialogConfig<D>
) {
protected lazyLoaderService = inject(NgxLazyLoaderService);
protected dialog = inject(MatDialog);

public constructor(private tooltipConfig?: MatDialogConfig<D>) {
if (!this.tooltipConfig) {
this.tooltipConfig = new MatDialogConfig();
}
Expand Down
11 changes: 4 additions & 7 deletions projects/user-tooltip/src/user-tooltip.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
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';

@Injectable({
providedIn: 'root'
})
export class NgxUserTooltipService extends NgxTooltipService<NgxUserCard> {
public constructor(
lazyLoaderService: NgxLazyLoaderService,
dialog: MatDialog
) {
super(lazyLoaderService, dialog, {
public constructor() {
super({
width: 'auto',
minWidth: '16px',
panelClass: 'no-padding-dialog'
Expand Down

0 comments on commit 7bcd0f1

Please sign in to comment.