UNPKG

@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

82 lines (81 loc) 5.06 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ const n = { textField: "text", statusField: "status", authorIdField: "authorId", authorNameField: "authorName", authorImageUrlField: "authorImageUrl", authorImageAltTextField: "authorImageAltText", idField: "id", timestampField: "timestamp", filesField: "files", attachmentsField: "attachments", replyToIdField: "replyToId", isDeletedField: "isDeleted", isPinnedField: "isPinned", typingField: "typing", suggestedActionsField: "suggestedActions" }, r = (i, d = {}) => { const t = { ...n, ...d }; let e; i.author && typeof i.author == "object" ? e = { id: i.author.id || i.author[t.authorIdField] || i[t.authorIdField] || "", name: i.author.name || i.author[t.authorNameField] || i[t.authorNameField], avatarUrl: i.author.avatarUrl || i.author[t.authorImageUrlField] || i[t.authorImageUrlField], avatarAltText: i.author.avatarAltText || i.author[t.authorImageAltTextField] || i[t.authorImageAltTextField] } : e = { id: i[t.authorIdField] || i.authorId || "", name: i[t.authorNameField] || i.authorName, avatarUrl: i[t.authorImageUrlField] || i.authorImageUrl, avatarAltText: i[t.authorImageAltTextField] || i.authorImageAltText }; let o; i.timestamp ? o = new Date(i.timestamp) : i[t.timestampField] ? o = new Date(i[t.timestampField]) : o = /* @__PURE__ */ new Date(); const l = { id: i.id !== void 0 ? i.id : i[t.idField], text: i.text !== void 0 ? i.text : i[t.textField] || "", author: e, timestamp: o, status: i.status !== void 0 ? i.status : i[t.statusField], attachments: i.attachments !== void 0 ? i.attachments : i[t.attachmentsField], attachmentLayout: i.attachmentLayout || "list", suggestedActions: i.suggestedActions !== void 0 ? i.suggestedActions : i[t.suggestedActionsField], isPinned: i.isPinned !== void 0 ? i.isPinned : i[t.isPinnedField] || !1, typing: i.typing !== void 0 ? i.typing : i[t.typingField], files: i.files !== void 0 ? i.files : i[t.filesField] || [] }; return i.pinnedAt && (l.pinnedAt = new Date(i.pinnedAt)), i.pinnedBy && (l.pinnedBy = i.pinnedBy), i.replyToId !== void 0 ? l.replyToId = i.replyToId : i[t.replyToIdField] !== void 0 && (l.replyToId = i[t.replyToIdField]), i.isDeleted !== void 0 ? l.isDeleted = i.isDeleted : i[t.isDeletedField] !== void 0 && (l.isDeleted = i[t.isDeletedField]), { ...l, dataItem: i }; }, u = (i, d = {}) => Array.isArray(i) ? i.map((t) => r(t, d)) : [], F = (i) => i && typeof i.id != "undefined" && typeof i.text == "string" && i.author && typeof i.author == "object" && typeof i.author.id != "undefined" && (i.timestamp instanceof Date || typeof i.timestamp == "string" || typeof i.timestamp == "number"), h = (i) => ({ textField: i.textField, statusField: i.statusField, authorIdField: i.authorIdField, authorNameField: i.authorNameField, authorImageUrlField: i.authorImageUrlField, authorImageAltTextField: i.authorImageAltTextField, idField: i.idField, timestampField: i.timestampField, filesField: i.filesField, attachmentsField: i.attachmentsField, replyToIdField: i.replyToIdField, isDeletedField: i.isDeletedField, isPinnedField: i.isPinnedField, typingField: i.typingField, suggestedActionsField: i.suggestedActionsField }), f = (i, d = {}) => { const t = { ...n, ...d }, e = {}; return i.id !== void 0 && (e[t.idField] = i.id), i.text !== void 0 && (e[t.textField] = i.text), i.status !== void 0 && (e[t.statusField] = i.status), i.timestamp !== void 0 && (e[t.timestampField] = i.timestamp), i.attachments !== void 0 && (e[t.attachmentsField] = i.attachments), i.files !== void 0 && (e[t.filesField] = i.files), i.suggestedActions !== void 0 && (e[t.suggestedActionsField] = i.suggestedActions), i.replyToId !== void 0 && (e[t.replyToIdField] = i.replyToId), i.isDeleted !== void 0 && (e[t.isDeletedField] = i.isDeleted), i.isPinned !== void 0 && (e[t.isPinnedField] = i.isPinned), i.typing !== void 0 && (e[t.typingField] = i.typing), i.author && (i.author.id !== void 0 && (e[t.authorIdField] = i.author.id), i.author.name !== void 0 && (e[t.authorNameField] = i.author.name), i.author.avatarUrl !== void 0 && (e[t.authorImageUrlField] = i.author.avatarUrl), i.author.avatarAltText !== void 0 && (e[t.authorImageAltTextField] = i.author.avatarAltText)), i.pinnedAt !== void 0 && (e.pinnedAt = i.pinnedAt), i.pinnedBy !== void 0 && (e.pinnedBy = i.pinnedBy), i.attachmentLayout !== void 0 && (e.attachmentLayout = i.attachmentLayout), e; }; export { n as DEFAULT_FIELD_MAPPING, h as extractFieldMappingFromProps, F as isStandardMessageFormat, u as mapDataArrayToMessages, r as mapDataToMessage, f as mapMessageToCustomFormat };