UNPKG

@vectara/vectara-ui

Version:

Vectara's design system, codified as a React and Sass component library

27 lines (26 loc) 1.92 kB
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { forwardRef } from "react"; import classNames from "classnames"; import { VuiLink } from "../link/Link"; import { VuiText } from "../typography/Text"; import { VuiTextColor } from "../typography/TextColor"; const highlightUrl = (url, text) => `${url}#:~:text=${text}`; export const VuiChatSearchResult = forwardRef((_a, ref) => { var { result, className } = _a, rest = __rest(_a, ["result", "className"]); const { title, url, date, snippet: { pre, post, text } } = result; // Protect users' privacy in FullStory. // https://help.fullstory.com/hc/en-us/articles/360020623574-How-do-I-protect-my-users-privacy-in-FullStory-#01F5DPW1AJHZHR8TBM9YQEDRMH const classes = classNames("vuiChatSearchResult", "fs-mask", className); return (_jsxs("div", Object.assign({ className: classes, ref: ref }, rest, { children: [(title || url) && (_jsx(VuiText, { children: url ? (_jsx(VuiLink, Object.assign({ href: highlightUrl(url, text), target: "_blank" }, { children: _jsx("p", { children: title !== null && title !== void 0 ? title : url }) }))) : (_jsx("p", { children: title })) })), _jsx(VuiText, Object.assign({ size: "s" }, { children: _jsxs("p", { children: [date && _jsxs(VuiTextColor, Object.assign({ color: "subdued" }, { children: [date, " \u2014 "] })), pre, " ", _jsx("strong", { children: text }), " ", post] }) }))] }))); });