@progress/kendo-react-conversational-ui
Version:
React Chat component allows the user to participate in chat sessions with users or chat bots. KendoReact Conversational UI components
68 lines (67 loc) • 2.52 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import * as s from "react";
import { classNames as p } from "@progress/kendo-react-common";
import { Avatar as m } from "@progress/kendo-react-layout";
import i from "./Attachment.mjs";
import { isAuthor as n } from "../utils.mjs";
import { provideLocalizationService as l } from "@progress/kendo-react-intl";
import { avatarAlt as o, messages as c } from "../messages/index.mjs";
class G extends s.Component {
render() {
const { avatarUrl: a, avatarAltText: e, name: t } = this.props.group.author, r = l(this);
return /* @__PURE__ */ s.createElement("div", { className: this.getMsgGroupClassNames() }, t && /* @__PURE__ */ s.createElement("p", { className: "k-author" }, t), a && /* @__PURE__ */ s.createElement(m, { type: "image" }, /* @__PURE__ */ s.createElement(
"img",
{
src: a,
alt: e !== void 0 ? e : r.toLanguageString(o, c[o])
}
)), this.getGroupMessagesView());
}
getMsgGroupClassNames() {
return p("k-message-group", {
"k-no-avatar": !this.props.group.author.avatarUrl,
"k-alt": n(this.props.user, this.props.group.messages[0])
});
}
getGroupMessagesView() {
const a = this.props.group.messages.length - 1;
return this.props.group.messages.map((e, t) => {
const r = [
/* @__PURE__ */ s.createElement(
this.props.message,
{
item: e,
template: this.props.itemTemplate,
selected: e.selectionIndex === this.props.selectedItemIndex,
onRequestSelection: this.props.onRequestSelection,
tabIndex: t === a && this.props.isLastGroup ? 0 : -1,
isFirstItemInGroup: t === 0,
isLastItemInGroup: t === a,
isOnlyItemInGroup: a === 0,
key: t
}
)
];
return e.attachments && e.attachments.length === 1 && r.push(
/* @__PURE__ */ s.createElement(
i,
{
item: e.attachments[0],
template: this.props.attachmentTemplate,
selected: !1,
key: `att-${t}`
}
)
), r;
});
}
}
export {
G as default
};