import { Prop, toNative, Watch } from 'vue-facing-decorator'; import TsxComponent, { Component } from '../../app/vuetsx'; import { TooltipLifecycle } from '../../common/utils/tooltip-lifecycle'; import { AlertLayout } from './alert-layout'; interface AlertArgs { cssClass?: string; layout?: AlertLayout; tooltip?: string; } @Component class AlertComponent extends TsxComponent implements AlertArgs { @Prop() cssClass!: string; @Prop() layout!: AlertLayout; @Prop() tooltip!: string; getCssClass(): string { return ( this.getParsedLayout() + (this.cssClass != null ? ` ${this.cssClass}` : '') ); } getParsedLayout() { return this.layout ?? AlertLayout.Primary; } mounted() { this.syncTooltip(); } beforeUnmount() { TooltipLifecycle.dispose(this.$el); } @Watch('tooltip', { flush: 'post' }) syncTooltip() { // Render emits no `title`, so sync() owns the attribute end to end. TooltipLifecycle.sync(this.$el as HTMLElement, this.tooltip); } render(h) { return ( ); } } const Alert = toNative(AlertComponent); export default Alert;