UNPKG

igniteui-angular

Version:

Ignite UI for Angular is a dependency-free Angular toolkit for building modern web apps

1 lines 9.58 kB
{"version":3,"file":"igniteui-angular-toast.mjs","sources":["../../../projects/igniteui-angular/toast/src/toast/toast.component.ts","../../../projects/igniteui-angular/toast/src/toast/toast.component.html","../../../projects/igniteui-angular/toast/src/toast/toast.module.ts","../../../projects/igniteui-angular/toast/src/igniteui-angular-toast.ts"],"sourcesContent":["import { Component, ElementRef, EventEmitter, HostBinding, Input, OnInit, Output, inject } from '@angular/core';\nimport { takeUntil } from 'rxjs/operators';\nimport {\n HorizontalAlignment,\n VerticalAlignment,\n GlobalPositionStrategy,\n PositionSettings\n} from 'igniteui-angular/core';\nimport { IgxNotificationsDirective } from 'igniteui-angular/directives';\nimport { ToggleViewEventArgs } from 'igniteui-angular/directives';\nimport { useAnimation } from '@angular/animations';\nimport { fadeIn, fadeOut } from 'igniteui-angular/animations';\n\nlet NEXT_ID = 0;\n\n/**\n * **Ignite UI for Angular Toast** -\n * [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/toast)\n *\n * The Ignite UI Toast provides information and warning messages that are non-interactive and cannot\n * be dismissed by the user. Toasts can be displayed at the bottom, middle, or top of the page.\n *\n * Example:\n * ```html\n * <button type=\"button\" igxButton (click)=\"toast.open()\">Show notification</button>\n * <igx-toast #toast displayTime=\"1000\">\n * Notification displayed\n * </igx-toast>\n * ```\n */\n@Component({\n selector: 'igx-toast',\n templateUrl: 'toast.component.html',\n standalone: true\n})\nexport class IgxToastComponent extends IgxNotificationsDirective implements OnInit {\n private _element = inject(ElementRef);\n\n /**\n * @hidden\n */\n @HostBinding('class.igx-toast')\n public cssClass = 'igx-toast';\n\n /**\n * Sets/gets the `id` of the toast.\n * If not set, the `id` will have value `\"igx-toast-0\"`.\n * ```html\n * <igx-toast id = \"my-first-toast\"></igx-toast>\n * ```\n * ```typescript\n * let toastId = this.toast.id;\n * ```\n */\n @HostBinding('attr.id')\n @Input()\n public override id = `igx-toast-${NEXT_ID++}`;\n\n /**\n * Sets/gets the `role` attribute.\n * If not set, `role` will have value `\"alert\"`.\n * ```html\n * <igx-toast [role] = \"'notify'\"></igx-toast>\n * ```\n * ```typescript\n * let toastRole = this.toast.role;\n * ```\n *\n * @memberof IgxToastComponent\n */\n @HostBinding('attr.role')\n @Input()\n public role = 'alert';\n\n /**\n * @hidden\n */\n @Output()\n public isVisibleChange = new EventEmitter<ToggleViewEventArgs>();\n\n /**\n * Get the position and animation settings used by the toast.\n * ```typescript\n * @ViewChild('toast', { static: true }) public toast: IgxToastComponent;\n * let currentPosition: PositionSettings = this.toast.positionSettings\n * ```\n */\n @Input()\n public get positionSettings(): PositionSettings {\n return this._positionSettings;\n }\n\n /**\n * Set the position and animation settings used by the toast.\n * ```html\n * <igx-toast [positionSettings]=\"newPositionSettings\"></igx-toast>\n * ```\n * ```typescript\n * import { slideInTop, slideOutBottom } from 'igniteui-angular';\n * ...\n * @ViewChild('toast', { static: true }) public toast: IgxToastComponent;\n * public newPositionSettings: PositionSettings = {\n * openAnimation: useAnimation(slideInTop, { params: { duration: '1000ms', fromPosition: 'translateY(100%)'}}),\n * closeAnimation: useAnimation(slideOutBottom, { params: { duration: '1000ms', fromPosition: 'translateY(0)'}}),\n * horizontalDirection: HorizontalAlignment.Left,\n * verticalDirection: VerticalAlignment.Middle,\n * horizontalStartPoint: HorizontalAlignment.Left,\n * verticalStartPoint: VerticalAlignment.Middle\n * };\n * this.toast.positionSettings = this.newPositionSettings;\n * ```\n */\n public set positionSettings(settings: PositionSettings) {\n this._positionSettings = settings;\n }\n\n private _positionSettings: PositionSettings = {\n horizontalDirection: HorizontalAlignment.Center,\n verticalDirection: VerticalAlignment.Bottom,\n openAnimation: useAnimation(fadeIn),\n closeAnimation: useAnimation(fadeOut),\n };\n\n /**\n * Gets the nativeElement of the toast.\n * ```typescript\n * let nativeElement = this.toast.element;\n * ```\n *\n * @memberof IgxToastComponent\n */\n public override get element() {\n return this._element.nativeElement;\n }\n\n /**\n * Shows the toast.\n * If `autoHide` is enabled, the toast will hide after `displayTime` is over.\n *\n * ```typescript\n * this.toast.open();\n * ```\n */\n public override open(message?: string, settings?: PositionSettings) {\n if (message !== undefined) {\n this.textMessage = message;\n }\n if (settings !== undefined) {\n this.positionSettings = settings;\n }\n this.strategy = new GlobalPositionStrategy(this.positionSettings);\n super.open();\n }\n\n /**\n * Opens or closes the toast, depending on its current state.\n *\n * ```typescript\n * this.toast.toggle();\n * ```\n */\n public override toggle() {\n if (this.collapsed || this.isClosing) {\n this.open();\n } else {\n this.close();\n }\n }\n\n /**\n * @hidden\n */\n public override ngOnInit() {\n this.opened.pipe(takeUntil(this.destroy$)).subscribe(() => {\n const openedEventArgs: ToggleViewEventArgs = { owner: this, id: this._overlayId };\n this.isVisibleChange.emit(openedEventArgs);\n });\n\n this.closed.pipe(takeUntil(this.destroy$)).subscribe(() => {\n const closedEventArgs: ToggleViewEventArgs = { owner: this, id: this._overlayId };\n this.isVisibleChange.emit(closedEventArgs);\n });\n }\n}\n","<ng-content></ng-content>\n<span>{{ textMessage }}</span>\n\n","import { NgModule } from '@angular/core';\nimport { IgxToastComponent } from './toast.component';\n\n/**\n * @hidden\n * IMPORTANT: The following is NgModule exported for backwards-compatibility before standalone components\n */\n@NgModule({\n imports: [\n IgxToastComponent\n ],\n exports: [\n IgxToastComponent\n ]\n})\nexport class IgxToastModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;AAaA,IAAI,OAAO,GAAG,CAAC;AAEf;;;;;;;;;;;;;;AAcG;AAMG,MAAO,iBAAkB,SAAQ,yBAAyB,CAAA;AALhE,IAAA,WAAA,GAAA;;AAMY,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;AAErC;;AAEG;QAEI,IAAA,CAAA,QAAQ,GAAG,WAAW;AAE7B;;;;;;;;;AASG;AAGa,QAAA,IAAA,CAAA,EAAE,GAAG,CAAA,UAAA,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