@eccenca/gui-elements
Version:
GUI elements based on other libraries, usable in React application, written in Typescript.
59 lines • 3.9 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import React from "react";
import { CLASSPREFIX as eccgui } from "../../configuration/constants.js";
import { Markdown } from "./../../cmem/markdown/Markdown.js";
import { FlexibleLayoutContainer, FlexibleLayoutItem } from "./../FlexibleLayout/index.js";
import { Spacing } from "./../Separation/Spacing.js";
import { HtmlContentBlock } from "./../Typography/index.js";
/**
* Component to display single chat contents, including avatar and status line.
*/
export var ChatContent = function (_a) {
var className = _a.className, children = _a.children, statusLine = _a.statusLine, avatar = _a.avatar, _b = _a.displayType, displayType = _b === void 0 ? "bubble" : _b, indentationSize = _a.indentationSize, _c = _a.alignment, alignment = _c === void 0 ? "left" : _c, limitHeight = _a.limitHeight, markdownProps = _a.markdownProps, actionButton = _a.actionButton, otherDivProps = __rest(_a, ["className", "children", "statusLine", "avatar", "displayType", "indentationSize", "alignment", "limitHeight", "markdownProps", "actionButton"]);
var content = markdownProps && typeof children === "string" ? React.createElement(Markdown, __assign({}, markdownProps), children) : children;
var chatitem = (React.createElement("div", __assign({ className: "".concat(eccgui, "-chat__content") +
" ".concat(eccgui, "-chat__content--display-").concat(displayType) +
" ".concat(eccgui, "-chat__content--align-").concat(alignment) +
(limitHeight ? " ".concat(eccgui, "-chat__content--limitheight") : "") +
(className ? " ".concat(className) : "") }, otherDivProps),
statusLine && (React.createElement(HtmlContentBlock, { small: true },
statusLine,
React.createElement(Spacing, { size: "tiny" }))),
content));
var indentationSizes = {
small: "8%",
medium: "21%",
large: "34%",
};
return (React.createElement("div", { style: {
marginLeft: alignment === "right" && indentationSize ? indentationSizes[indentationSize] : undefined,
marginRight: alignment === "left" && indentationSize ? indentationSizes[indentationSize] : undefined,
} },
React.createElement(FlexibleLayoutContainer, { noEqualItemSpace: true, gapSize: "tiny" },
avatar && (React.createElement(FlexibleLayoutItem, { className: "".concat(eccgui, "-chat__content-avatar"), growFactor: 0, shrinkFactor: 0, style: alignment === "right" ? { order: 1 } : undefined }, React.cloneElement(avatar, { size: "small", ratio: "1:1", rounded: true, resizing: "cover" }))),
React.createElement(FlexibleLayoutItem, { className: "".concat(eccgui, "-chat__content-wrapper") }, chatitem),
actionButton && (React.createElement(FlexibleLayoutItem, { className: "".concat(eccgui, "-chat__content-sizetoggle"), growFactor: 0, shrinkFactor: 0, style: alignment === "right" ? { order: -1 } : undefined }, actionButton)))));
};
export default ChatContent;
//# sourceMappingURL=ChatContent.js.map