blob: 0e886df60ac4e55c56d975918c52875c9dcd7796 [file] [log] [blame]
{"version":3,"file":"covalent-core-notifications.js.map","sources":["ng://@covalent/core/notifications/notification-count.component.ts","ng://@covalent/core/notifications/notifications.module.ts"],"sourcesContent":["import { Component, Input, HostBinding, ChangeDetectionStrategy,\n ViewChild, ElementRef, AfterContentInit } from '@angular/core';\n\nexport enum TdNotificationCountPositionY {\n Top = 'top',\n Bottom = 'bottom',\n Center = 'center',\n}\n\nexport enum TdNotificationCountPositionX {\n Before = 'before',\n After = 'after',\n Center = 'center',\n}\n\nexport const DEFAULT_NOTIFICATION_LIMIT: number = 99;\n\n@Component({\n selector: 'td-notification-count',\n styleUrls: ['./notification-count.component.scss' ],\n templateUrl: './notification-count.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class TdNotificationCountComponent implements AfterContentInit {\n\n private _notifications: number | boolean = 0;\n private _positionY: TdNotificationCountPositionY;\n private _positionX: TdNotificationCountPositionX;\n private _limit: number = DEFAULT_NOTIFICATION_LIMIT;\n\n /**\n * Div content wrapper of `ng-content`.\n */\n @ViewChild('content') content: ElementRef;\n\n /**\n * color?: \"primary\" | \"accent\" | \"warn\"\n * Sets the theme color of the notification tip. Defaults to \"warn\"\n */\n @Input() color: 'primary' | 'accent' | 'warn' = 'warn';\n\n /**\n * positionX?: TdNotificationCountPositionX or \"before\" | \"after\" | \"center\"\n * Sets the X position of the notification tip.\n * Defaults to \"after\" if it has content, else 'center'.\n */\n @Input()\n set positionX(positionX: TdNotificationCountPositionX) {\n this._positionX = positionX;\n }\n get positionX(): TdNotificationCountPositionX {\n return this._positionX;\n }\n\n /**\n * positionY?: TdNotificationCountPositionY or \"top\" | \"bottom\" | \"center\"\n * Sets the Y position of the notification tip.\n * Defaults to \"top\" if it has content, else 'center'.\n */\n @Input()\n set positionY(positionY: TdNotificationCountPositionY) {\n this._positionY = positionY;\n }\n get positionY(): TdNotificationCountPositionY {\n return this._positionY;\n }\n\n /**\n * notifications?: number | boolean\n * Number for the notification count. Shows component only if the input is a positive number or 'true'\n */\n @Input()\n set notifications(notifications: number | boolean) {\n this._notifications = notifications;\n }\n\n /**\n * limit?: number\n * Limit for notification count. If the number of notifications is greater than limit, then + will be added. Defaults to 99.\n */\n @Input()\n set limit(limit: number) {\n this._limit = limit;\n }\n\n @HostBinding('class.td-notification-hidden')\n get hideHost(): boolean {\n return !this.show && !this._hasContent();\n }\n\n /**\n * Sets the component in its 'noCount' state if [notifications] is a boolean 'true'.\n * Makes the notification tip show without a count.\n */\n get noCount(): string | boolean {\n return this._notifications === true;\n }\n\n /**\n * Notification display string when a count is available.\n * Anything over 99 gets set as 99+\n */\n get notificationsDisplay(): string {\n if (this._notifications > this._limit) {\n return `${this._limit}+`;\n }\n return this._notifications.toString();\n }\n\n /**\n * Shows notification tip only when [notifications] is true or a positive integer.\n */\n get show(): boolean {\n return this._notifications === true || (!isNaN(<any>this._notifications) && this._notifications > 0);\n }\n\n /**\n * Check if [positionX] and [positionY] have been set as inputs, else use defaults depending on component content.\n */\n ngAfterContentInit(): void {\n if (!this._positionX) {\n this.positionX = this._hasContent() ? TdNotificationCountPositionX.After : TdNotificationCountPositionX.Center;\n }\n if (!this._positionY) {\n this.positionY = this._hasContent() ? TdNotificationCountPositionY.Top : TdNotificationCountPositionY.Center;\n }\n }\n\n /**\n * Method to check if element has any kind of content (elements or text)\n */\n private _hasContent(): boolean {\n if (this.content) {\n let contentElement: HTMLElement = this.content.nativeElement;\n return contentElement && (contentElement.children.length > 0 || !!contentElement.textContent.trim());\n }\n return false;\n }\n\n}\n","import { Type } from '@angular/core';\nimport { NgModule } from '@angular/core';\n\nimport { CommonModule } from '@angular/common';\n\nimport { TdNotificationCountComponent } from './notification-count.component';\n\nconst TD_NOTIFICATIONS: Type<any>[] = [\n TdNotificationCountComponent,\n];\n\n@NgModule({\n imports: [\n CommonModule,\n ],\n declarations: [\n TD_NOTIFICATIONS,\n ],\n exports: [\n TD_NOTIFICATIONS,\n ],\n})\nexport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