UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

133 lines (131 loc) 4.79 kB
/** * DevExtreme (cjs/__internal/ui/informer/informer.js) * Version: 25.2.5 * Build date: Fri Feb 20 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.INFORMER_TEXT_CLASS = exports.INFORMER_CLASS = void 0; var _component_registrator = _interopRequireDefault(require("../../../core/component_registrator")); var _renderer = _interopRequireDefault(require("../../../core/renderer")); var _m_icon = require("../../core/utils/m_icon"); var _widget = _interopRequireDefault(require("../../core/widget/widget")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e } } const INFORMER_CLASS = exports.INFORMER_CLASS = "dx-informer"; const INFORMER_ERROR_CLASS = "dx-informer-error"; const INFORMER_INFO_CLASS = "dx-informer-info"; const INFORMER_ALIGNMENT_START_CLASS = "dx-informer-alignment-start"; const INFORMER_ALIGNMENT_CENTER_CLASS = "dx-informer-alignment-center"; const INFORMER_ALIGNMENT_END_CLASS = "dx-informer-alignment-end"; const INFORMER_BG_CLASS = "dx-informer-bg"; const INFORMER_TEXT_CLASS = exports.INFORMER_TEXT_CLASS = "dx-informer-text"; const INFORMER_ICON_CLASS = "dx-informer-icon"; class Informer extends _widget.default { _getDefaultOptions() { return Object.assign({}, super._getDefaultOptions(), { contentAlignment: "center", icon: "", showBackground: true, text: "", type: "error" }) } _initMarkup() { const { showBackground: showBackground } = this.option(); this.$element().addClass(INFORMER_CLASS); this.$element().toggleClass("dx-informer-bg", showBackground); this._setAlignmentClass(); this._setTypeClass(); super._initMarkup(); this._renderIcon(); this._renderText() } _setAlignmentClass() { this.$element().removeClass("dx-informer-alignment-start").removeClass("dx-informer-alignment-center").removeClass("dx-informer-alignment-end"); const { contentAlignment: contentAlignment } = this.option(); switch (contentAlignment) { case "start": this.$element().addClass("dx-informer-alignment-start"); break; case "end": this.$element().addClass("dx-informer-alignment-end"); break; default: this.$element().addClass("dx-informer-alignment-center") } } _setTypeClass() { this.$element().removeClass("dx-informer-error").removeClass("dx-informer-info"); const { type: type } = this.option(); if ("info" === type) { this.$element().addClass("dx-informer-info") } else { this.$element().addClass("dx-informer-error") } } _renderIcon() { var _this$_$icon; null === (_this$_$icon = this._$icon) || void 0 === _this$_$icon || _this$_$icon.remove(); const { icon: icon } = this.option(); const $icon = (0, _m_icon.getImageContainer)(icon); if (!$icon) { return } this._$icon = (0, _renderer.default)("<div>").addClass("dx-informer-icon").prependTo(this.$element()).append($icon) } _renderText() { const { text: text = "" } = this.option(); this._$text = (0, _renderer.default)("<div>").addClass(INFORMER_TEXT_CLASS).appendTo(this.$element()).text(text) } _updateText() { const { text: text = "" } = this.option(); this._$text.text(text) } _optionChanged(args) { const { name: name, value: value } = args; switch (name) { case "icon": this._renderIcon(); break; case "contentAlignment": this._setAlignmentClass(); break; case "showBackground": this.$element().toggleClass("dx-informer-bg", value); break; case "text": this._updateText(); break; case "type": this._setTypeClass(); break; default: super._optionChanged(args) } } }(0, _component_registrator.default)("dxInformer", Informer); var _default = exports.default = Informer;