blob: 926b0a5dfc716149fbf81173ae074856fb9a3617 [file] [log] [blame]
{"version":3,"sources":["../../../../src/platform/core/notifications/notification-count.component.ts","../../../../src/platform/core/notifications/notifications.module.ts"],"names":["TdNotificationCountPositionY","Top","Bottom","Center","TdNotificationCountPositionX","Before","After","TdNotificationCountComponent","this","_notifications","_limit","color","Object","defineProperty","prototype","_positionX","positionX","_positionY","positionY","notifications","limit","show","_hasContent","toString","isNaN","ngAfterContentInit","content","contentElement","nativeElement","children","length","textContent","trim","Component","args","selector","template","changeDetection","ChangeDetectionStrategy","OnPush","ViewChild","static","Input","HostBinding","TD_NOTIFICATIONS","NgModule","imports","CommonModule","declarations","exports"],"mappings":"sdAUYA,EAA4B,CACtCC,IAAG,MACHC,OAAM,SACNC,OAAM,UAGIC,EAA4B,CACtCC,OAAM,SACNC,MAAK,QACLH,OAAM,uBAKR,SAAAI,IAOUC,KAAAC,eAAmC,EAGnCD,KAAAE,OAZwC,GAuBvCF,KAAAG,MAAuC,cAOhDC,OAAAC,eACIN,EAAAO,UAAA,YAAS,KAGb,WACE,OAAON,KAAKO,gBALd,SACcC,GACZR,KAAKO,WAAaC,mCAWpBJ,OAAAC,eACIN,EAAAO,UAAA,YAAS,KAGb,WACE,OAAON,KAAKS,gBALd,SACcC,GACZV,KAAKS,WAAaC,mCAUpBN,OAAAC,eACIN,EAAAO,UAAA,gBAAa,KADjB,SACkBK,GAChBX,KAAKC,eAAiBU,mCAOxBP,OAAAC,eACIN,EAAAO,UAAA,QAAK,KADT,SACUM,GACRZ,KAAKE,OAASU,mCAGhBR,OAAAC,eACIN,EAAAO,UAAA,WAAQ,KADZ,WAEE,OAAQN,KAAKa,OAASb,KAAKc,+CAO7BV,OAAAC,eAAIN,EAAAO,UAAA,UAAO,KAAX,WACE,OAA+B,IAAxBN,KAAKC,gDAOdG,OAAAC,eAAIN,EAAAO,UAAA,uBAAoB,KAAxB,WACE,OAAIN,KAAKC,eAAiBD,KAAKE,OACnBF,KAAKE,OAAM,IAEhBF,KAAKC,eAAec,4CAM7BX,OAAAC,eAAIN,EAAAO,UAAA,OAAI,KAAR,WACE,OAA+B,IAAxBN,KAAKC,iBAA6Be,MAAWhB,KAAmB,iBAAKA,KAAKC,eAAiB,mCAMpGF,EAAAO,UAAAW,mBAAA,WACOjB,KAAKO,aACRP,KAAKQ,UAAYR,KAAKc,cAAgBlB,EAA6BE,MAAQF,EAA6BD,QAErGK,KAAKS,aACRT,KAAKU,UAAYV,KAAKc,cAAgBtB,EAA6BC,IAAMD,EAA6BG,SAOlGI,EAAAO,UAAAQ,YAAA,WACN,GAAId,KAAKkB,QAAS,KACVC,EAA8BnB,KAAKkB,QAAQE,cACjD,OAAOD,IAAmBA,EAAeE,SAASC,OAAS,KAAOH,EAAeI,YAAYC,QAE/F,OAAO,4BAtHVC,EAAAA,UAASC,KAAA,CAAC,CACTC,SAAU,wBAEVC,SAAA,inBACAC,gBAAiBC,EAAAA,wBAAwBC,4iDAWxCC,EAAAA,UAASN,KAAA,CAAC,UAAW,CAAEO,QAAQ,mBAM/BC,EAAAA,yBAOAA,EAAAA,yBAaAA,EAAAA,6BAYAA,EAAAA,qBASAA,EAAAA,wBAKAC,EAAAA,YAAWT,KAAA,CAAC,uCCpFTU,EAAgC,CAACrC,KAOvC,iCALCsC,EAAAA,SAAQX,KAAA,CAAC,CACRY,QAAS,CAACC,EAAAA,cACVC,aAAc,CAACJ,GACfK,QAAS,CAACL,oEDUsC","sourcesContent":["import {\n Component,\n Input,\n HostBinding,\n ChangeDetectionStrategy,\n ViewChild,\n ElementRef,\n AfterContentInit,\n} 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 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', { static: true }) 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 const contentElement: HTMLElement = this.content.nativeElement;\n return contentElement && (contentElement.children.length > 0 || !!contentElement.textContent.trim());\n }\n return false;\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>[] = [TdNotificationCountComponent];\n\n@NgModule({\n imports: [CommonModule],\n declarations: [TD_NOTIFICATIONS],\n exports: [TD_NOTIFICATIONS],\n})\nexport class CovalentNotificationsModule {}\n"]}