UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

81 lines (80 loc) 2.6 kB
/** * DevExtreme (esm/__internal/ui/chat/alertlist.js) * Version: 25.1.3 * Build date: Wed Jun 25 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import _extends from "@babel/runtime/helpers/esm/extends"; import messageLocalization from "../../../common/core/localization/message"; import $ from "../../../core/renderer"; import Widget from "../../core/widget/widget"; import Informer from "../../ui/informer/informer"; const CHAT_ALERTLIST_CLASS = "dx-chat-alertlist"; const CHAT_ALERTLIST_ERROR_CLASS = "dx-chat-alertlist-error"; const ICON_ERRORCIRCLE = "errorcircle"; class AlertList extends Widget { _getDefaultOptions() { return _extends({}, super._getDefaultOptions(), { items: [] }) } _initMarkup() { $(this.element()).addClass("dx-chat-alertlist"); super._initMarkup(); const { items: items } = this.option(); this._renderItems(items); this._updateAria() } _renderItems(items) { this._informersInstances = []; if (null !== items && void 0 !== items && items.length) { items.forEach((itemData => { this._renderItem(itemData) })) } } _renderItem(itemData) { const $informer = $("<div>").addClass("dx-chat-alertlist-error"); this.$element().append($informer); const informer = this._createComponent($informer, Informer, { text: (null === itemData || void 0 === itemData ? void 0 : itemData.message) ?? "", icon: "errorcircle", showBackground: false }); this._informersInstances.push(informer) } _cleanItems() { this._informersInstances.forEach((informerInstance => { informerInstance.dispose() })) } _updateAria() { const aria = { role: "log", atomic: "false", label: messageLocalization.format("dxChat-alertListAriaLabel"), live: "polite", relevant: "additions" }; this.setAria(aria) } _clean() { this._cleanItems(); super._clean() } _optionChanged(args) { const { name: name } = args; if ("items" === name) { this._invalidate() } else { super._optionChanged(args) } } } export default AlertList;