Skip to content

Commit

Permalink
fix(core): move notification interfaces, add autoClose type
Browse files Browse the repository at this point in the history
  • Loading branch information
KarimovDev committed Oct 7, 2021
1 parent 310e659 commit ba2b0ef
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
1 change: 1 addition & 0 deletions projects/core/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './icon-error';
export * from './number-format-settings';
export * from './value-content-context';
export * from './with-optional-min-max';
export * from './notification-options';
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import {TuiContextWithImplicit} from '@taiga-ui/cdk';
import {TuiNotification} from '@taiga-ui/core/enums';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';

export type TuiNotificationAutoClose =
| boolean
| number
| ((status: TuiNotification) => number | boolean);

export interface TuiNotificationOptions {
readonly label?: PolymorpheusContent<TuiContextWithImplicit<TuiNotification>>;
readonly status?: TuiNotification;
readonly hasIcon?: boolean;
readonly autoClose?:
| boolean
| number
| ((status: TuiNotification) => number | boolean);
readonly autoClose?: TuiNotificationAutoClose;
readonly hasCloseButton?: boolean;
}

Expand Down
1 change: 0 additions & 1 deletion projects/core/modules/notifications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export * from './notification-alert/notification-alert.module';
export * from './notification-alert/Notification-alert';
export * from './notifications-host/notifications-host.component';
export * from './notification-content-context';
export * from './notification-options';
export * from './notifications.module';
export * from './notifications.service';
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';
import {Observer} from 'rxjs';
import {TuiNotificationContentContext} from '../notification-content-context';
import {
TuiNotificationOptions,
TuiNotificationOptionsWithData,
} from '../notification-options';
} from '@taiga-ui/core/interfaces';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';
import {Observer} from 'rxjs';
import {TuiNotificationContentContext} from '../notification-content-context';

export class NotificationAlert<O, I> {
readonly status = this.options.status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import {CommonModule} from '@angular/common';
import {Component, Inject, NgModule, ViewChild} from '@angular/core';
import {ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
import {
TuiNotificationOptions,
TuiNotificationOptionsWithData,
} from '@taiga-ui/core/interfaces';
import {
NotificationTokenOptions,
TUI_NOTIFICATION_DEFAULT_OPTIONS,
TUI_NOTIFICATION_OPTIONS,
NotificationTokenOptions,
} from '@taiga-ui/core/tokens';
import {PageObject} from '@taiga-ui/testing';
import {
Expand All @@ -13,10 +17,6 @@ import {
PolymorpheusContent,
} from '@tinkoff/ng-polymorpheus';
import {TuiNotificationContentContext} from '../../notification-content-context';
import {
TuiNotificationOptions,
TuiNotificationOptionsWithData,
} from '../../notification-options';
import {NotificationAlert} from '../Notification-alert';
import {TuiNotificationAlertComponent} from '../notification-alert.component';
import {TuiNotificationAlertModule} from '../notification-alert.module';
Expand Down
8 changes: 4 additions & 4 deletions projects/core/modules/notifications/notifications.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Inject, Injectable} from '@angular/core';
import {tuiAssert} from '@taiga-ui/cdk';
import {
TuiNotificationOptions,
TuiNotificationOptionsWithData,
} from '@taiga-ui/core/interfaces';
import {NotificationTokenOptions, TUI_NOTIFICATION_OPTIONS} from '@taiga-ui/core/tokens';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';
import {BehaviorSubject, Observable, Observer} from 'rxjs';
import {NotificationAlert} from './notification-alert/Notification-alert';
import {TuiNotificationContentContext} from './notification-content-context';
import {
TuiNotificationOptions,
TuiNotificationOptionsWithData,
} from './notification-options';

const NO_HOST =
'Notifications are disabled, enable support by adding TuiNotificationsModule to your main app module';
Expand Down
6 changes: 2 additions & 4 deletions projects/core/tokens/notification-options.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {InjectionToken} from '@angular/core';
import {TuiContextWithImplicit} from '@taiga-ui/cdk';
import {TuiNotification} from '@taiga-ui/core/enums';
import {TuiNotificationAutoClose} from '@taiga-ui/core/interfaces';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';

export interface NotificationTokenOptions {
readonly autoClose:
| boolean
| number
| ((status: TuiNotification) => number | boolean);
readonly autoClose: TuiNotificationAutoClose;
readonly label: PolymorpheusContent<TuiContextWithImplicit<TuiNotification>>;
readonly status: TuiNotification;
readonly hasIcon: boolean;
Expand Down

0 comments on commit ba2b0ef

Please sign in to comment.