@eccenca/gui-elements
Version:
GUI elements based on other libraries, usable in React application, written in Typescript.
55 lines • 3.81 kB
JavaScript
;
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatContent = void 0;
const react_1 = __importDefault(require("react"));
const constants_1 = require("../../configuration/constants");
const Markdown_1 = require("./../../cmem/markdown/Markdown");
const FlexibleLayout_1 = require("./../FlexibleLayout");
const Spacing_1 = require("./../Separation/Spacing");
const Typography_1 = require("./../Typography");
/**
* Component to display single chat contents, including avatar and status line.
*/
const ChatContent = (_a) => {
var { className, children, statusLine, avatar, displayType = "bubble", indentationSize, alignment = "left", limitHeight, markdownProps, actionButton } = _a, otherDivProps = __rest(_a, ["className", "children", "statusLine", "avatar", "displayType", "indentationSize", "alignment", "limitHeight", "markdownProps", "actionButton"]);
const content = markdownProps && typeof children === "string" ? react_1.default.createElement(Markdown_1.Markdown, Object.assign({}, markdownProps), children) : children;
const chatitem = (react_1.default.createElement("div", Object.assign({ className: `${constants_1.CLASSPREFIX}-chat__content` +
` ${constants_1.CLASSPREFIX}-chat__content--display-${displayType}` +
` ${constants_1.CLASSPREFIX}-chat__content--align-${alignment}` +
(limitHeight ? ` ${constants_1.CLASSPREFIX}-chat__content--limitheight` : "") +
(className ? ` ${className}` : "") }, otherDivProps),
statusLine && (react_1.default.createElement(Typography_1.HtmlContentBlock, { small: true },
statusLine,
react_1.default.createElement(Spacing_1.Spacing, { size: "tiny" }))),
content));
const indentationSizes = {
small: "8%",
medium: "21%",
large: "34%",
};
return (react_1.default.createElement("div", { style: {
marginLeft: alignment === "right" && indentationSize ? indentationSizes[indentationSize] : undefined,
marginRight: alignment === "left" && indentationSize ? indentationSizes[indentationSize] : undefined,
} },
react_1.default.createElement(FlexibleLayout_1.FlexibleLayoutContainer, { noEqualItemSpace: true, gapSize: "tiny" },
avatar && (react_1.default.createElement(FlexibleLayout_1.FlexibleLayoutItem, { className: `${constants_1.CLASSPREFIX}-chat__content-avatar`, growFactor: 0, shrinkFactor: 0, style: alignment === "right" ? { order: 1 } : undefined }, react_1.default.cloneElement(avatar, { size: "small", ratio: "1:1", rounded: true, resizing: "cover" }))),
react_1.default.createElement(FlexibleLayout_1.FlexibleLayoutItem, { className: `${constants_1.CLASSPREFIX}-chat__content-wrapper` }, chatitem),
actionButton && (react_1.default.createElement(FlexibleLayout_1.FlexibleLayoutItem, { className: `${constants_1.CLASSPREFIX}-chat__content-sizetoggle`, growFactor: 0, shrinkFactor: 0, style: alignment === "right" ? { order: -1 } : undefined }, actionButton)))));
};
exports.ChatContent = ChatContent;
exports.default = exports.ChatContent;
//# sourceMappingURL=ChatContent.js.map