blob: 0e81aad1a95a753bac2a3e9d1579ab0941955419 [file] [log] [blame]
{
"version": 3,
"file": "covalent-core-notifications.js",
"sources": [
"ng://@covalent/core/notifications/out/notifications.module.ts",
"ng://@covalent/core/notifications/out/notification-count.component.ts"
],
"sourcesContent": [
"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 class CovalentNotificationsModule {\n\n}\n",
"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\n@Component({\n selector: 'td-notification-count',\n styles: [`:host{\n position:relative;\n display:block;\n text-align:center;\n min-width:40px;\n height:40px; }\n :host.td-notification-hidden{\n min-width:0; }\n\n.td-notification-count{\n line-height:21px;\n width:20px;\n height:20px;\n position:absolute;\n font-size:10px;\n font-weight:600;\n border-radius:50%;\n z-index:1; }\n .td-notification-count.td-notification-center-x{\n margin-left:auto;\n margin-right:auto;\n left:0;\n right:0; }\n .td-notification-count.td-notification-center-y{\n margin-top:auto;\n margin-bottom:auto;\n top:0;\n bottom:0; }\n .td-notification-count.td-notification-top{\n top:0; }\n .td-notification-count.td-notification-bottom{\n bottom:0; }\n .td-notification-count.td-notification-before{\n left:0; }\n .td-notification-count.td-notification-after{\n right:0; }\n .td-notification-count.td-notification-no-count{\n width:8px;\n height:8px; }\n .td-notification-count.td-notification-no-count.td-notification-top{\n top:8px; }\n .td-notification-count.td-notification-no-count.td-notification-bottom{\n bottom:8px; }\n .td-notification-count.td-notification-no-count.td-notification-before{\n left:8px; }\n .td-notification-count.td-notification-no-count.td-notification-after{\n right:8px; }\n ::ng-deep [dir='rtl'] .td-notification-count.td-notification-before{\n right:0;\n left:auto; }\n ::ng-deep [dir='rtl'] .td-notification-count.td-notification-after{\n left:0;\n right:auto; }\n ::ng-deep [dir='rtl'] .td-notification-count.td-notification-no-count.td-notification-before{\n right:8px;\n left:auto; }\n ::ng-deep [dir='rtl'] .td-notification-count.td-notification-no-count.td-notification-after{\n left:8px;\n right:auto; }\n\n.td-notification-content, .td-notification-content ::ng-deep > *{\n line-height:40px; }\n`],\n template: `<div #content class=\"td-notification-content\">\n <ng-content></ng-content>\n</div>\n<div *ngIf=\"show\"\n class=\"td-notification-count mat-{{color}}\"\n [class.td-notification-top]=\"positionY === 'top'\"\n [class.td-notification-bottom]=\"positionY === 'bottom'\"\n [class.td-notification-before]=\"positionX === 'before'\"\n [class.td-notification-after]=\"positionX === 'after'\"\n [class.td-notification-center-y]=\"positionY === 'center'\"\n [class.td-notification-center-x]=\"positionX === 'center'\"\n [class.td-notification-no-count]=\"noCount\">\n {{noCount ? '' : notificationsDisplay}}\n</div>`,\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\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 @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 > 99) {\n return '99+';\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"
],
"names": [],
"mappings": ";;;;;;;ACAA;;IAIA,GAAA,EAAQ,KAAK;IACb,MAAA,EAAW,QAAQ;IACnB,MAAA,EAAW,QAAQ;;;;IAInB,MAAA,EAAW,QAAQ;IACn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