synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
23 lines (22 loc) • 688 B
JavaScript
import { jsx as t } from "react/jsx-runtime";
import { Typography as p } from "@mui/material";
import s from "./HighlightedTypography.module.scss.js";
function h(e) {
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function u({
text: e,
searchTerms: i,
...r
}) {
if (i.length === 0)
return /* @__PURE__ */ t(p, { ...r, children: e });
const g = i.map(h).join("|"), o = new RegExp(`(${g})`, "gi"), c = e.split(o);
return /* @__PURE__ */ t(p, { ...r, children: c.map(
(n, l) => o.test(n) ? /* @__PURE__ */ t("span", { className: s.highlight, children: n }, l) : n
) });
}
export {
u as HighlightedTypography
};
//# sourceMappingURL=HighlightedTypography.js.map