UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

59 lines (58 loc) 1.87 kB
/** * DevExtreme (esm/__internal/ui/chat/messagebubble.js) * Version: 24.2.7 * Build date: Mon Apr 28 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 { getPublicElement } from "../../../core/element"; import $ from "../../../core/renderer"; import Widget from "../../core/widget/widget"; export const CHAT_MESSAGEBUBBLE_CLASS = "dx-chat-messagebubble"; const CHAT_MESSAGEBUBBLE_CONTENT_CLASS = "dx-chat-messagebubble-content"; class MessageBubble extends Widget { _getDefaultOptions() { return _extends({}, super._getDefaultOptions(), { text: "", template: null }) } _initMarkup() { const $element = $(this.element()); $element.addClass("dx-chat-messagebubble"); $("<div>").addClass("dx-chat-messagebubble-content").appendTo($element); super._initMarkup(); this._updateContent() } _updateContent() { const { text: text = "", template: template } = this.option(); const $bubbleContainer = $(this.element()).find(".dx-chat-messagebubble-content"); $bubbleContainer.empty(); if (template) { template(text, getPublicElement($bubbleContainer)); return } $bubbleContainer.text(text) } _optionChanged(args) { const { name: name } = args; switch (name) { case "text": case "template": this._updateContent(); break; default: super._optionChanged(args) } } } export default MessageBubble;