All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.components.highlight.highlight.cjs Maven / Gradle / Ivy

Go to download

A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.

The newest version!
'use strict';

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

const jsxRuntime = require('react/jsx-runtime');
const react = require('react');
const createSplitProps = require('../../utils/create-split-props.cjs');
const useHighlight = require('./use-highlight.cjs');

const Highlight = (props) => {
  if (typeof props.text !== "string") {
    throw new Error("[ark-ui/highlight] text must be a string");
  }
  const [highlightProps, localProps] = createSplitProps.createSplitProps()(props, [
    "query",
    "text",
    "ignoreCase",
    "matchAll"
  ]);
  const chunks = useHighlight.useHighlight(highlightProps);
  return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: chunks.map(
    ({ text, match }, i) => match ? /* @__PURE__ */ jsxRuntime.jsx("mark", { ...localProps, children: text }, i) : /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: text }, i)
  ) });
};

exports.Highlight = Highlight;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy