From ba2b0efcad8160991679f2df065f86f75f1501e6 Mon Sep 17 00:00:00 2001 From: KarimovDev Date: Fri, 1 Oct 2021 23:56:04 +0300 Subject: [PATCH] fix(core): move notification interfaces, add autoClose type --- projects/core/interfaces/index.ts | 1 + .../notification-options.ts | 10 ++++++---- projects/core/modules/notifications/index.ts | 1 - .../notification-alert/Notification-alert.ts | 8 ++++---- .../test/notification-alert.component.spec.ts | 10 +++++----- .../modules/notifications/notifications.service.ts | 8 ++++---- projects/core/tokens/notification-options.ts | 6 ++---- 7 files changed, 22 insertions(+), 22 deletions(-) rename projects/core/{modules/notifications => interfaces}/notification-options.ts (74%) diff --git a/projects/core/interfaces/index.ts b/projects/core/interfaces/index.ts index 30d7a1beb15f0..4839b1580534b 100644 --- a/projects/core/interfaces/index.ts +++ b/projects/core/interfaces/index.ts @@ -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'; diff --git a/projects/core/modules/notifications/notification-options.ts b/projects/core/interfaces/notification-options.ts similarity index 74% rename from projects/core/modules/notifications/notification-options.ts rename to projects/core/interfaces/notification-options.ts index 73b197ffa0f9d..46c395fcb4e31 100644 --- a/projects/core/modules/notifications/notification-options.ts +++ b/projects/core/interfaces/notification-options.ts @@ -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>; readonly status?: TuiNotification; readonly hasIcon?: boolean; - readonly autoClose?: - | boolean - | number - | ((status: TuiNotification) => number | boolean); + readonly autoClose?: TuiNotificationAutoClose; readonly hasCloseButton?: boolean; } diff --git a/projects/core/modules/notifications/index.ts b/projects/core/modules/notifications/index.ts index fab37713c33de..e11701177b8aa 100644 --- a/projects/core/modules/notifications/index.ts +++ b/projects/core/modules/notifications/index.ts @@ -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'; diff --git a/projects/core/modules/notifications/notification-alert/Notification-alert.ts b/projects/core/modules/notifications/notification-alert/Notification-alert.ts index efe349eba82ab..58d0235e88b54 100644 --- a/projects/core/modules/notifications/notification-alert/Notification-alert.ts +++ b/projects/core/modules/notifications/notification-alert/Notification-alert.ts @@ -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 { readonly status = this.options.status; diff --git a/projects/core/modules/notifications/notification-alert/test/notification-alert.component.spec.ts b/projects/core/modules/notifications/notification-alert/test/notification-alert.component.spec.ts index feaadb82cb0c3..ea5e1a2d68b95 100644 --- a/projects/core/modules/notifications/notification-alert/test/notification-alert.component.spec.ts +++ b/projects/core/modules/notifications/notification-alert/test/notification-alert.component.spec.ts @@ -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 { @@ -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'; diff --git a/projects/core/modules/notifications/notifications.service.ts b/projects/core/modules/notifications/notifications.service.ts index 14dccfa2d5a90..c893e378f5ab1 100644 --- a/projects/core/modules/notifications/notifications.service.ts +++ b/projects/core/modules/notifications/notifications.service.ts @@ -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'; diff --git a/projects/core/tokens/notification-options.ts b/projects/core/tokens/notification-options.ts index 435effacfe234..965e09d2fc5ed 100644 --- a/projects/core/tokens/notification-options.ts +++ b/projects/core/tokens/notification-options.ts @@ -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>; readonly status: TuiNotification; readonly hasIcon: boolean;