package.dist.components.highlight.highlight.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of react Show documentation
Show all versions of react Show documentation
A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.
The newest version!
import { jsx } from 'react/jsx-runtime';
import { Fragment } from 'react';
import { createSplitProps } from '../../utils/create-split-props.js';
import { useHighlight } from './use-highlight.js';
const Highlight = (props) => {
if (typeof props.text !== "string") {
throw new Error("[ark-ui/highlight] text must be a string");
}
const [highlightProps, localProps] = createSplitProps()(props, [
"query",
"text",
"ignoreCase",
"matchAll"
]);
const chunks = useHighlight(highlightProps);
return /* @__PURE__ */ jsx(Fragment, { children: chunks.map(
({ text, match }, i) => match ? /* @__PURE__ */ jsx("mark", { ...localProps, children: text }, i) : /* @__PURE__ */ jsx(Fragment, { children: text }, i)
) });
};
export { Highlight };
© 2015 - 2025 Weber Informatics LLC | Privacy Policy