UNPKG

@servicetitan/assist-ui

Version:

ServiceTitan Atlas UI Components

97 lines (96 loc) 3.89 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import { Flex, Icon, Text } from '@servicetitan/anvil2'; import IconAtlasLogo from '@servicetitan/anvil2/assets/icons/st/atlas_logo.svg'; import { core } from '@servicetitan/anvil2/token'; import { Loader } from '../loader'; import { ErrorMessage } from './error-message'; import * as styles from './message.module.less'; export const MarkdownMessage = ({ error, message, className, assistant, svgIcon, onRetry })=>{ return /*#__PURE__*/ _jsxs(Flex, { gap: 2, direction: "column", className: className, children: [ /*#__PURE__*/ _jsxs(Flex, { alignItems: "center", children: [ /*#__PURE__*/ _jsx(Icon, { className: styles.messageIcon, svg: svgIcon !== null && svgIcon !== void 0 ? svgIcon : IconAtlasLogo, size: "medium", inherit: true }), /*#__PURE__*/ _jsx(Text, { inline: true, children: /*#__PURE__*/ _jsx("b", { children: assistant !== null && assistant !== void 0 ? assistant : 'Atlas' }) }) ] }), /*#__PURE__*/ _jsxs(Flex, { direction: "column", children: [ message && !error && /*#__PURE__*/ _jsx("div", { className: styles.markdownContent, children: /*#__PURE__*/ _jsx(ReactMarkdown, { remarkPlugins: [ remarkGfm ], children: message }) }), error && /*#__PURE__*/ _jsx(ErrorMessage, { error: error, message: message, onRetry: onRetry }), !message && !error && /*#__PURE__*/ _jsx(Loader, {}) ] }) ] }); }; export const Thinking = ({ error, message, className, assistant, svgIcon, onRetry })=>{ return /*#__PURE__*/ _jsxs(Flex, { direction: "column", className: className, children: [ /*#__PURE__*/ _jsxs(Flex, { children: [ /*#__PURE__*/ _jsx("span", { className: "m-inline-end-1", style: { color: core.semantic.ForegroundColorPrimary.value }, children: /*#__PURE__*/ _jsx(Icon, { svg: svgIcon !== null && svgIcon !== void 0 ? svgIcon : IconAtlasLogo, size: "large", inherit: true }) }), /*#__PURE__*/ _jsx(Text, { inline: true, children: /*#__PURE__*/ _jsx("b", { children: assistant !== null && assistant !== void 0 ? assistant : 'Atlas' }) }) ] }), /*#__PURE__*/ _jsxs(Flex, { direction: "column", children: [ /*#__PURE__*/ _jsx(Loader, {}), error && /*#__PURE__*/ _jsx(ErrorMessage, { error: error, message: message, onRetry: onRetry }) ] }) ] }); }; //# sourceMappingURL=markdown-message.js.map