UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

78 lines (77 loc) 2.41 kB
import { jsx as t, jsxs as S } from "react/jsx-runtime"; import { useTheme as y, Box as g, FormControl as C, OutlinedInput as V, InputAdornment as v, Select as I, MenuItem as u } from "@mui/material"; import { useState as a } from "react"; import { getSearchToken as b } from "../SynapseNavDrawer/SynapseNavDrawer.js"; import { parseSynId as $ } from "../../utils/functions/RegularExpressions.js"; function M({ gotoPlace: o }) { const c = y(), [s, p] = a(""), [i, h] = a(""), [n, m] = a( 0 /* SEARCH */ ), l = () => { if (n == 0) { const e = s.toLowerCase().trim(), r = $(e); if (r && r.targetVersionNumber) { const x = `${r.targetId}.${r.targetVersionNumber}`; o(`/Synapse:${x}`); return; } o( `/SearchV2:default?query=${b( e.split(/[ ,]+/) )}` ); } else o(`/Chat:initialMessage=${encodeURIComponent(i)}`); }, d = (e) => { e.preventDefault(), l(); }, f = (e) => { e.key === "Enter" && (e.preventDefault(), l()); }; return /* @__PURE__ */ t(g, { component: "form", onSubmit: d, children: /* @__PURE__ */ t(C, { fullWidth: !0, sx: { m: 1 }, children: /* @__PURE__ */ t( V, { value: n == 0 ? s : i, startAdornment: /* @__PURE__ */ t( v, { position: "start", sx: { p: "0px", ml: "7px", mr: "13px" }, children: /* @__PURE__ */ S( I, { value: n, sx: { fontSize: "24px", fontWeight: 400, minWidth: "125px", color: c.palette.secondary[600], '& div[role="combobox"]': { p: "14px 12px" } }, onChange: (e) => { m(e.target.value); }, children: [ /* @__PURE__ */ t(u, { value: 0, children: "Search" }), /* @__PURE__ */ t(u, { value: 1, children: "Chat" }) ] } ) } ), placeholder: n == 0 ? "Search Synapse" : "Ask a question", sx: { fontSize: "24px", borderRadius: 96.6 }, onChange: (e) => { n == 0 ? p(e.target.value) : h(e.target.value); }, onKeyDown: f } ) }) }); } export { M as SynapseHomepageChatSearch }; //# sourceMappingURL=SynapseHomepageChatSearch.js.map