UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

80 lines (79 loc) 2.54 kB
/** * DevExtreme (esm/__internal/ui/chat/alertlist.js) * Version: 25.2.7 * Build date: Tue May 05 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ 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 Object.assign({}, 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;