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

23 lines (22 loc) 688 B
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