UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

61 lines (60 loc) • 2.01 kB
/** * DevExtreme (esm/__internal/grids/grid_core/toast/toast_view.js) * Version: 26.1.6 * Build date: Fri Oct 16 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import $ from "../../../../core/renderer"; import dxToast from "../../../../ui/toast"; import { View } from "../modules/modules"; export class ToastView extends View { constructor() { super(...arguments); this._toastInstance = null; this._$toastContainer = null } _createToastInstance(options) { if (this._toastInstance) { return this._toastInstance } if (!this._$toastContainer) { this._$toastContainer = $("<div>").appendTo(this.component.$element()) } this._toastInstance = this._createComponent(this._$toastContainer, dxToast, Object.assign({ position: { my: "bottom", at: "bottom", of: this.component.$element().get(0) } }, options, { visible: false })); return this._toastInstance } showToast(message) { let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; const toast = this._createToastInstance(options); null === toast || void 0 === toast || toast.option(Object.assign({}, options, { message: message, visible: true })) } async hideToast() { var _this$_toastInstance; await (null === (_this$_toastInstance = this._toastInstance) || void 0 === _this$_toastInstance ? void 0 : _this$_toastInstance.hide()) } dispose() { if (this._toastInstance) { this._toastInstance.dispose(); this._toastInstance = null } if (this._$toastContainer) { this._$toastContainer.remove(); this._$toastContainer = null } } }