UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

83 lines (81 loc) 3.17 kB
/** * DevExtreme (cjs/__internal/ui/chat/suggestions.js) * Version: 26.1.3 * Build date: Wed Jun 10 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 = void 0; var _renderer = _interopRequireDefault(require("../../../core/renderer")); var _button_group = _interopRequireDefault(require("../../../ui/button_group")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e } } const CHAT_SUGGESTIONS_CLASS = "dx-chat-suggestions"; class Suggestions { constructor($container, options) { this._$container = $container; this._renderMarkup(); this._initButtonGroup(options) } _getConfiguration() { var _options$items; let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; const items = (null === options || void 0 === options || null === (_options$items = options.items) || void 0 === _options$items ? void 0 : _options$items.map(item => Object.assign({ type: "default" }, item))) ?? []; return Object.assign({ stylingMode: "outlined" }, options, { items: items, selectionMode: "none" }) } _renderMarkup() { var _this$_$container; this._$element = (0, _renderer.default)("<div>"); null === (_this$_$container = this._$container) || void 0 === _this$_$container || _this$_$container.append(this._$element) } _initButtonGroup() { let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; if (this._hasItems(options) && this._$element) { this._$element.addClass("dx-chat-suggestions"); this._buttonGroup = new _button_group.default(this._$element.get(0), this._getConfiguration(options)) } } _hasItems(options) { var _options$items2; return Boolean(null === options || void 0 === options || null === (_options$items2 = options.items) || void 0 === _options$items2 ? void 0 : _options$items2.length) } updateOptions(options) { if (!this._hasItems(options)) { this.clean(); return } if (!this._buttonGroup) { this._initButtonGroup(options); return } this._buttonGroup.option(this._getConfiguration(options)) } clean() { var _this$_buttonGroup, _this$_$element; null === (_this$_buttonGroup = this._buttonGroup) || void 0 === _this$_buttonGroup || _this$_buttonGroup.dispose(); this._buttonGroup = void 0; null === (_this$_$element = this._$element) || void 0 === _this$_$element || _this$_$element.empty() } dispose() { var _this$_$element2; this.clean(); null === (_this$_$element2 = this._$element) || void 0 === _this$_$element2 || _this$_$element2.remove(); this._$element = void 0 } } var _default = exports.default = Suggestions;