UNPKG

14.3 kBSource Map (JSON)View Raw
1{"version":3,"file":"covalent-core-message.mjs","sources":["../../../../libs/angular/message/src/collapse.animation.ts","../../../../libs/angular/message/src/message.component.ts","../../../../libs/angular/message/src/message.component.html","../../../../libs/angular/message/src/message.module.ts","../../../../libs/angular/message/src/covalent-core-message.ts"],"sourcesContent":["import {\n trigger,\n state,\n style,\n transition,\n animate,\n AnimationTriggerMetadata,\n AUTO_STYLE,\n query,\n animateChild,\n group,\n} from '@angular/animations';\n\nexport interface IAnimationOptions {\n anchor?: string;\n duration?: number;\n delay?: number;\n}\n\nexport interface ICollapseAnimation extends IAnimationOptions {\n easeOnClose?: string;\n easeOnOpen?: string;\n}\n\n/**\n * const tdCollapseAnimation\n *\n * Parameter Options:\n * * duration: Duration the animation will run in milliseconds. Defaults to 150 ms.\n * * delay: Delay before the animation will run in milliseconds. Defaults to 0 ms.\n * * easeOnClose: Animation accelerates and decelerates when closing. Defaults to ease-in.\n * * easeOnOpen: Animation accelerates and decelerates when opening. Defaults to ease-out.\n *\n * Returns an [AnimationTriggerMetadata] object with boolean states for a collapse/expand animation.\n *\n * usage: [@tdCollapse]=\"{ value: true | false, params: { duration: 500 }}\"\n */\nexport const tdCollapseAnimation: AnimationTriggerMetadata = trigger(\n 'tdCollapse',\n [\n state(\n '1',\n style({\n height: '0',\n overflow: 'hidden',\n })\n ),\n state(\n '0',\n style({\n height: AUTO_STYLE,\n overflow: AUTO_STYLE,\n })\n ),\n transition(\n '0 => 1',\n [\n style({\n overflow: 'hidden',\n height: AUTO_STYLE,\n }),\n group([\n query('@*', animateChild(), { optional: true }),\n animate(\n '{{ duration }}ms {{ delay }}ms {{ ease }}',\n style({\n height: '0',\n overflow: 'hidden',\n })\n ),\n ]),\n ],\n { params: { duration: 150, delay: '0', ease: 'ease-in' } }\n ),\n transition(\n '1 => 0',\n [\n style({\n height: '0',\n overflow: 'hidden',\n }),\n group([\n query('@*', animateChild(), { optional: true }),\n animate(\n '{{ duration }}ms {{ delay }}ms {{ ease }}',\n style({\n overflow: 'hidden',\n height: AUTO_STYLE,\n })\n ),\n ]),\n ],\n { params: { duration: 150, delay: '0', ease: 'ease-out' } }\n ),\n ]\n);\n","import {\n Component,\n Directive,\n Input,\n Renderer2,\n ElementRef,\n AfterViewInit,\n ViewContainerRef,\n TemplateRef,\n ViewChild,\n HostBinding,\n HostListener,\n ChangeDetectorRef,\n} from '@angular/core';\n\nimport { tdCollapseAnimation } from './collapse.animation';\n\n@Directive({\n selector: '[tdMessageContainer]',\n})\nexport class TdMessageContainerDirective {\n constructor(public viewContainer: ViewContainerRef) {}\n}\n\n@Component({\n selector: 'td-message',\n templateUrl: './message.component.html',\n styleUrls: ['./message.component.scss'],\n animations: [tdCollapseAnimation],\n})\nexport class TdMessageComponent implements AfterViewInit {\n private _color!: string;\n private _opened = true;\n private _hidden = false;\n private _animating = false;\n private _initialized = false;\n\n @ViewChild(TdMessageContainerDirective, { static: true })\n _childElement?: TdMessageContainerDirective;\n @ViewChild(TemplateRef) _template!: TemplateRef<any>;\n\n /**\n * Binding host to tdCollapse animation\n */\n @HostBinding('@tdCollapse')\n get collapsedAnimation(): any {\n return { value: !this._opened, duration: 100 };\n }\n\n /**\n * Binding host to display style when hidden\n */\n @HostBinding('style.display')\n get hidden(): string {\n return this._hidden ? 'none' : '';\n }\n\n /**\n * label: string\n *\n * Sets the label of the message.\n */\n @Input() label?: string;\n\n /**\n * sublabel?: string\n *\n * Sets the sublabel of the message.\n */\n @Input() sublabel?: string;\n\n /**\n * icon?: string\n *\n * The icon to be displayed before the title.\n * Defaults to `info_outline` icon\n */\n @Input() icon?: string = 'info_outline';\n\n /**\n * color?: primary | accent | warn\n *\n * Sets the color of the message.\n * Can also use any material color: purple | light-blue, etc.\n */\n @Input()\n set color(color: string) {\n this._renderer.removeClass(\n this._elementRef.nativeElement,\n 'mat-' + this._color\n );\n this._renderer.removeClass(\n this._elementRef.nativeElement,\n 'bgc-' + this._color + '-100'\n );\n this._renderer.removeClass(\n this._elementRef.nativeElement,\n 'tc-' + this._color + '-700'\n );\n if (color === 'primary' || color === 'accent' || color === 'warn') {\n this._renderer.addClass(this._elementRef.nativeElement, 'mat-' + color);\n } else {\n this._renderer.addClass(\n this._elementRef.nativeElement,\n 'bgc-' + color + '-100'\n );\n this._renderer.addClass(\n this._elementRef.nativeElement,\n 'tc-' + color + '-700'\n );\n }\n this._color = color;\n this._changeDetectorRef.markForCheck();\n }\n get color(): string {\n return this._color;\n }\n\n /**\n * opened?: boolean\n *\n * Shows or hiddes the message depending on its value.\n * Defaults to 'true'.\n */\n @Input()\n set opened(opened: boolean) {\n if (this._initialized) {\n if (opened) {\n this.open();\n } else {\n this.close();\n }\n } else {\n this._opened = opened;\n }\n }\n get opened(): boolean {\n return this._opened;\n }\n\n constructor(\n private _renderer: Renderer2,\n private _changeDetectorRef: ChangeDetectorRef,\n private _elementRef: ElementRef\n ) {\n this._renderer.addClass(this._elementRef.nativeElement, 'td-message');\n }\n\n /**\n * Detach element when close animation is finished to set animating state to false\n * hidden state to true and detach element from DOM\n */\n @HostListener('@tdCollapse.done')\n animationDoneListener(): void {\n if (!this._opened) {\n this._hidden = true;\n this._detach();\n }\n this._animating = false;\n this._changeDetectorRef.markForCheck();\n }\n\n /**\n * Initializes the component and attaches the content.\n */\n ngAfterViewInit(): void {\n Promise.resolve(undefined).then(() => {\n if (this._opened) {\n this._attach();\n }\n this._initialized = true;\n });\n }\n\n /**\n * Renders the message on screen\n * Validates if there is an animation currently and if its already opened\n */\n open(): void {\n if (!this._opened && !this._animating) {\n this._opened = true;\n this._attach();\n this._startAnimationState();\n }\n }\n\n /**\n * Removes the message content from screen.\n * Validates if there is an animation currently and if its already closed\n */\n close(): void {\n if (this._opened && !this._animating) {\n this._opened = false;\n this._startAnimationState();\n }\n }\n\n /**\n * Toggles between open and close depending on state.\n */\n toggle(): void {\n if (this._opened) {\n this.close();\n } else {\n this.open();\n }\n }\n\n /**\n * Method to set the state before starting an animation\n */\n private _startAnimationState(): void {\n this._animating = true;\n this._hidden = false;\n this._changeDetectorRef.markForCheck();\n }\n\n /**\n * Method to attach template to DOM\n */\n private _attach(): void {\n this._childElement?.viewContainer.createEmbeddedView(this._template);\n this._changeDetectorRef.markForCheck();\n }\n\n /**\n * Method to detach template from DOM\n */\n private _detach(): void {\n this._childElement?.viewContainer.clear();\n this._changeDetectorRef.markForCheck();\n }\n}\n","<div tdMessageContainer></div>\n<ng-template>\n <div class=\"td-message-wrapper\">\n <mat-icon class=\"td-message-icon\">{{ icon }}</mat-icon>\n <div class=\"td-message-labels\">\n <div *ngIf=\"label\" class=\"td-message-label\">{{ label }}</div>\n <div *ngIf=\"sublabel\" class=\"td-message-sublabel\">{{ sublabel }}</div>\n </div>\n <ng-content select=\"[td-message-actions]\"></ng-content>\n </div>\n</ng-template>\n","import { Type } from '@angular/core';\nimport { NgModule } from '@angular/core';\n\nimport { CommonModule } from '@angular/common';\nimport { MatIconModule } from '@angular/material/icon';\n\nimport {\n TdMessageComponent,\n TdMessageContainerDirective,\n} from './message.component';\n\nconst TD_MESSAGE: Type<any>[] = [\n TdMessageComponent,\n TdMessageContainerDirective,\n];\n\n@NgModule({\n imports: [CommonModule, MatIconModule],\n declarations: [TD_MESSAGE],\n exports: [TD_MESSAGE],\n})\nexport class CovalentMessageModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;AAwBA;;;;;;;;;;;;;AAaO,MAAM,mBAAmB,GAA6B,OAAO,CAClE,YAAY,EACZ;IACE,KAAK,CACH,GAAG,EACH,KAAK,CAAC;QACJ,MAAM,EAAE,GAAG;QACX,QAAQ,EAAE,QAAQ;KACnB,CAAC,CACH;IACD,KAAK,CACH,GAAG,EACH,KAAK,CAAC;QACJ,MAAM,EAAE,UAAU;QAClB,QAAQ,EAAE,UAAU;KACrB,CAAC,CACH;IACD,UAAU,CACR,QAAQ,EACR;QACE,KAAK,CAAC;YACJ,QAAQ,EAAE,QAAQ;YA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