devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
69 lines (68 loc) • 2.74 kB
JavaScript
/**
* DevExtreme (cjs/__internal/grids/grid_core/ai_chat/utils.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/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.needToShowRegenerateButton = exports.needToRenderCommandList = exports.getMessageStateClass = exports.getMessageIconName = exports.getCommandItemStyle = exports.findMessageById = void 0;
var _const = require("../../../grids/grid_core/ai_assistant/const");
var _const2 = require("./const");
const getMessageStateClass = status => {
switch (status) {
case "success":
return _const2.CLASSES.messageSuccess;
case "failure":
return _const2.CLASSES.messageError;
default:
return _const2.CLASSES.messagePending
}
};
exports.getMessageStateClass = getMessageStateClass;
const getMessageIconName = message => {
switch (message.status) {
case _const.MessageStatus.Failure:
return "errorcircle";
case _const.MessageStatus.Success:
return "checkmarkcirclefilled";
case _const.MessageStatus.Pending:
default:
return "sparkle"
}
};
exports.getMessageIconName = getMessageIconName;
const findMessageById = (items, id) => null === items || void 0 === items ? void 0 : items.find(item => item.id === id);
exports.findMessageById = findMessageById;
const needToShowRegenerateButton = message => {
var _message$commands;
const isError = message.status === _const.MessageStatus.Failure;
return isError && !(null !== (_message$commands = message.commands) && void 0 !== _message$commands && _message$commands.length)
};
exports.needToShowRegenerateButton = needToShowRegenerateButton;
const getCommandItemStyle = status => {
switch (status) {
case "failure":
return {
stateClass: _const2.CLASSES.actionListItemError, emoji: _const2.ERROR_ITEM_EMOJI
};
case "aborted":
return {
stateClass: _const2.CLASSES.actionListItemAborted, emoji: _const2.ABORTED_ITEM_EMOJI
};
default:
return {
stateClass: _const2.CLASSES.actionListItemSuccess, emoji: _const2.SUCCESS_ITEM_EMOJI
}
}
};
exports.getCommandItemStyle = getCommandItemStyle;
const needToRenderCommandList = message => {
var _message$commands2;
return !!(null !== (_message$commands2 = message.commands) && void 0 !== _message$commands2 && _message$commands2.length)
};
exports.needToRenderCommandList = needToRenderCommandList;