{"name":"react-highlight-words","version":"0.1.7","keywords":["react","reactjs","react-component","highlighter","highlight","text","words","matches","substring","occurrences","search"],"author":{"name":"Brian Vaughn"},"license":"MIT","_id":"react-highlight-words@0.1.7","maintainers":[{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"}],"homepage":"https://github.com/bvaughn/react-highlight-words#readme","bugs":{"url":"https://github.com/bvaughn/react-highlight-words/issues"},"dist":{"shasum":"7066409c8e50c2987d943907cea37850f7747c11","tarball":"http://registry-npm.ywwl.com/react-highlight-words/download/react-highlight-words-0.1.7.tgz","integrity":"sha512-U2g2XhMGM8FTVKWa/tI55SOgPA5aEvIzxCqB2jjULQ9uz61dXCEYYYYJOgmDhF/J+Zi3KefjEgIiInbYDLmK5g==","signatures":[{"sig":"MEQCIBko77ELAiQLDsoJNr6j1Vgove9QOlQXUyobWx9llL2pAiAW0i0E7IzEK3JqCSqcFXLQNldAQ5sMPFR8fDUwDegxeg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":572433,"noattachment":false,"key":"/react-highlight-words/-/react-highlight-words-0.1.7.tgz"},"main":"dist/main.js","_from":".","_shasum":"7066409c8e50c2987d943907cea37850f7747c11","gitHead":"9c68e7ad18d3665ce2d82742dff24508ac56390e","scripts":{"lint":"standard","test":"NODE_ENV=test karma start","build":"npm run build:website && npm run build:dist","clean":"npm run clean:website && npm run clean:dist","start":"webpack-dev-server --hot --inline --config webpack.config.dev.js","watch":"watch 'clear && npm run lint -s && npm run test -s' src","deploy":"gh-pages -d build","prebuild":"npm run lint","build:dist":"npm run clean:dist && NODE_ENV=production webpack --config webpack.config.dist.js --bail","clean:dist":"rimraf dist","prepublish":"npm run build","postpublish":"npm run deploy","build:website":"npm run clean:website && NODE_ENV=production webpack --config webpack.config.website.js -p --bail","clean:website":"rimraf build"},"_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"standard":{"global":["afterAll","afterEach","beforeAll","beforeEach","describe","it","jasmine"],"ignore":["build","dist","node_modules"],"parser":"babel-eslint"},"repository":{"url":"git+https://github.com/bvaughn/react-highlight-words.git","type":"git"},"_npmVersion":"3.3.12","description":"React component to highlight words within a larger body of text","directories":{},"_nodeVersion":"5.3.0","dependencies":{},"devDependencies":{"babel":"^5.8.34","karma":"^0.13.15","mocha":"^2.3.4","react":"^15.1.0","watch":"^0.16.0","rimraf":"^2.4.4","cssnext":"^1.8.4","webpack":"^1.12.9","gh-pages":"^0.8.0","standard":"^5.4.1","expect.js":"^0.3.1","react-dom":"^15.1.0","babel-core":"^5.8.34","css-loader":"^0.23.0","phantomjs2":"^2.0.2","karma-mocha":"^0.2.1","babel-eslint":"^4.1.6","babel-loader":"^5.4.0","redbox-react":"^1.0.1","style-loader":"^0.13.0","karma-webpack":"^1.7.0","worker-loader":"^0.7.0","cssnext-loader":"^1.0.1","webpack-dev-server":"^1.14.0","html-webpack-plugin":"^1.7.0","karma-spec-reporter":"0.0.23","react-transform-hmr":"^1.0.1","karma-junit-reporter":"^0.3.8","karma-sourcemap-loader":"^0.3.6","karma-phantomjs2-launcher":"^0.3.2","babel-plugin-react-transform":"^1.1.1","react-transform-catch-errors":"^1.0.0"},"peerDependencies":{"react":"^0.14.0 || ^15.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-highlight-words-0.1.7.tgz_1465170882577_0.29065350722521544","host":"packages-16-east.internal.npmjs.com"},"readme":"<img src=\"https://react-highlight-words.vercel.app/og.png\" alt=\"react-highlight-words logo\" width=\"400\" height=\"210\" />\n\nReact component to highlight words within a larger body of text.\n\n## Installation\n\nBegin by installing the library from NPM:\n\n```sh\nnpm install react-highlight-words\n```\n\n## TypeScript types\n\nTypeScript definitions are included within the published `dist` folder.\n\n## Documentation\n\nDocumentation and examples for this project are available at [react-highlight-words.vercel.app](https://react-highlight-words.vercel.app/).\n\n## Usage\n\nTo use it, just provide it with an array of search terms and a body of text to highlight.\n\n```tsx\nimport Highlighter from \"react-highlight-words\";\n\nfunction Example() {\n  return (\n    <Highlighter\n      highlightClassName=\"YourHighlightClass\"\n      searchWords={[\"and\", \"or\", \"the\"]}\n      textToHighlight=\"The dog is chasing the cat. Or perhaps they're just playing?\"\n    />\n  );\n}\n```\n\nAnd the `Highlighter` will mark all occurrences of search terms within the text:\n\n<img width=\"368\" alt=\"screen shot 2015-12-19 at 8 23 43 am\" src=\"https://cloud.githubusercontent.com/assets/29597/11914033/e3c319f6-a629-11e5-896d-1a5ce22c9ea2.png\">\n\n### Highlighter\n\n<!-- Highlighter:description:begin -->\nHighlights all occurrences of one or more search terms within a larger body of text.\n\nHighlighted matches are wrapped in a `<mark>` element by default, and unhighlighted text is wrapped in a `<span>`.\nBoth of these can be customized with the `highlightTag` and `unhighlightTag` props.\n\nℹ️ Any other props (such as `title` or `data-*` attributes) are applied to the outer/wrapper `<span>`, and a `ref` is forwarded to it.\n<!-- Highlighter:description:end -->\n\n#### Required props\n\n<!-- Highlighter:required-props:begin -->\n\n<table>\n  <thead>\n    <tr>\n      <th>Name</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>searchWords</td>\n      <td><p>Array of search words.\nString search terms are matched literally, unless <code>autoEscape</code> is false\n(in which case they are treated as regular expressions, and strings that aren&#39;t valid regular expressions are matched literally).\nRegExp search terms are used as-is (with their own flags).</p>\n</td>\n    </tr>\n    <tr>\n      <td>textToHighlight</td>\n      <td><p>Text to highlight matches in.</p>\n<p>ℹ️ Browsers collapse whitespace and newlines by default; to preserve them, set the <code>white-space</code> style (e.g. <code>style={{ whiteSpace: &quot;pre-wrap&quot; }}</code>).</p>\n</td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- Highlighter:required-props:end -->\n\n#### Optional props\n\n<!-- Highlighter:optional-props:begin -->\n\n<table>\n  <thead>\n    <tr>\n      <th>Name</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>className</td>\n      <td><p>Class name applied to the outer/wrapper <code>&lt;span&gt;</code>.</p>\n</td>\n    </tr>\n    <tr>\n      <td>activeClassName</td>\n      <td><p>Class name applied to the active match.</p>\n<p>ℹ️ Use along with <code>activeIndex</code>.</p>\n</td>\n    </tr>\n    <tr>\n      <td>activeIndex</td>\n      <td><p>Index of the match that should be actively highlighted.</p>\n<p>ℹ️ Use along with <code>activeClassName</code> or <code>activeStyle</code>.</p>\n</td>\n    </tr>\n    <tr>\n      <td>activeStyle</td>\n      <td><p>Inline styles applied to the active match.</p>\n<p>ℹ️ Use along with <code>activeIndex</code>.</p>\n</td>\n    </tr>\n    <tr>\n      <td>autoEscape</td>\n      <td><p>Match string search terms literally (defaults to <code>true</code>).\nSet to <code>false</code> to treat them as regular expressions.\n(They are compiled without the <code>u</code> flag, so syntax that requires it, such as <code>\\p{L}</code>, only works in RegExp search terms.)</p>\n<p>⚠️ Only set this to <code>false</code> for trusted search terms;\na malicious regular expression can take an extremely long time to run.</p>\n</td>\n    </tr>\n    <tr>\n      <td>caseSensitive</td>\n      <td><p>Match string search terms case sensitively.\nRegExp search terms are case sensitive unless they have the <code>i</code> flag.</p>\n</td>\n    </tr>\n    <tr>\n      <td>findChunks</td>\n      <td><p>Custom function to search for matching chunks.\nThis makes it possible to use arbitrary logic when looking for matches.</p>\n<p>It receives the search options (with defaults applied) and returns the <code>start</code> and <code>end</code> index of each range of text to highlight,\nalong with the <code>searchIndex</code> of the search word that matched it.\nOverlapping ranges are combined automatically.</p>\n<p>See the default <code>findChunks</code> function in <a href=\"https://github.com/bvaughn/highlight-words-core\">highlight-words-core</a> for reference.</p>\n</td>\n    </tr>\n    <tr>\n      <td>highlightClassName</td>\n      <td><p>Class name applied to highlighted text,\nor an object mapping search term matches to class names.</p>\n<p>ℹ️ Object keys are compared with the matched text first, then with the string search term that matched it\n(case insensitively, unless <code>caseSensitive</code> is true).</p>\n</td>\n    </tr>\n    <tr>\n      <td>highlightStyle</td>\n      <td><p>Inline styles applied to highlighted text.</p>\n</td>\n    </tr>\n    <tr>\n      <td>highlightTag</td>\n      <td><p>Type of tag to wrap around highlighted matches.\nDefaults to <code>mark</code> but can also be a React component (class or function).</p>\n<p>ℹ️ Custom components will receive <code>children</code>, <code>className</code>, <code>highlightIndex</code>, <code>searchIndex</code>, and <code>style</code> props.</p>\n</td>\n    </tr>\n    <tr>\n      <td>sanitize</td>\n      <td><p>Process each string search word and the text to highlight before comparing (e.g. to remove accents).\nMatches always refer to the original text, even if sanitizing changes its length (e.g. &quot;Æ&quot; to &quot;AE&quot;).</p>\n<p>ℹ️ Sanitizing should transform characters independently;\nif it changes the text, it is applied to each character separately.\nRegExp search terms are not sanitized, but they are matched against the sanitized text.</p>\n</td>\n    </tr>\n    <tr>\n      <td>unhighlightClassName</td>\n      <td><p>Class name applied to unhighlighted text.</p>\n</td>\n    </tr>\n    <tr>\n      <td>unhighlightStyle</td>\n      <td><p>Inline styles applied to unhighlighted text.</p>\n</td>\n    </tr>\n    <tr>\n      <td>unhighlightTag</td>\n      <td><p>Type of tag applied to unhighlighted parts of the text.\nDefaults to <code>span</code> but can also be a React component (class or function).</p>\n</td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- Highlighter:optional-props:end -->\n\n### Custom highlight tag\n\nBy default, this component uses an HTML Mark Text element (`<mark>`) to wrap matched text, but you can inject a custom\ntag using the `highlightTag` property. This tag should be a React component that accepts the following properties:\n\n| Property         | Type   | Description            |\n| ---------------- | ------ | ---------------------- |\n| `children`       | String | Text to be highlighted |\n| `className`      | String | Class name(s) to apply |\n| `highlightIndex` | Number | Index of matched text  |\n| `searchIndex`    | Number | Index of the matching search word |\n| `style`          | Object | Inline styles to apply |\n\nFor example:\n\n```tsx\nimport { type HighlightTagProps } from \"react-highlight-words\";\n\nfunction Highlight({ children, highlightIndex }: HighlightTagProps) {\n  return <strong className=\"highlighted-text\">{children}</strong>;\n}\n```\n\n## License\n\nMIT License - fork, modify and use however you want.\n","publish_time":1465170886068,"_cnpm_publish_time":1465170886068,"dist-tags":{"latest":"1.0.0"}}