Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@filerobot/common / lib / TextWithHighlights.js
Size: Mime:
import { jsx as _jsx } from "react/jsx-runtime";
var TextWithHighlights = function TextWithHighlights(_ref) {
  var _ref$text = _ref.text,
    text = _ref$text === void 0 ? '' : _ref$text,
    _ref$hightlightText = _ref.hightlightText,
    hightlightText = _ref$hightlightText === void 0 ? '' : _ref$hightlightText,
    _ref$hightlightBackgr = _ref.hightlightBackgroundColor,
    hightlightBackgroundColor = _ref$hightlightBackgr === void 0 ? 'rgb(104 121 235 / 17%)' : _ref$hightlightBackgr;
  if (!text || !hightlightText) {
    return text;
  }

  // to handle search with "+"
  var regexp = hightlightText === '+' ? new RegExp("[".concat(hightlightText, "]"), 'gi') : new RegExp(hightlightText, 'gi');
  var includesSubStr = hightlightText === '+' ? regexp.test([text] || '') : regexp.test(text || '');
  if (!includesSubStr) {
    return text;
  }
  return /*#__PURE__*/_jsx("span", {
    // eslint-disable-next-line react/no-danger
    dangerouslySetInnerHTML: {
      __html: text.replace(regexp, "<span style=\"background: ".concat(hightlightBackgroundColor, ";\">$&</span>"))
    }
  });
};
export default TextWithHighlights;