{"name":"react-onclickout","version":"2.0.8","description":"An ES6-friendly on-click-outside React component.","main":"index.js","scripts":{"build":"babel src/index.jsx --out-file index.js","test":"npm run build && mocha --compilers .jsx:test/compiler.js test/*.jsx","prepublish":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/boblauer/react-onclickout.git"},"keywords":["react","onclick","onclickout","onclickoutside"],"author":{"name":"Bob Lauer","email":"rlauer@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/boblauer/react-onclickout/issues"},"homepage":"https://github.com/boblauer/react-onclickout#readme","peerDependencies":{"react":"^15.x || ^16.x","react-dom":"^15.x || ^16.x"},"devDependencies":{"babel-cli":"^6.26.0","babel-preset-es2015":"^6.24.1","babel-preset-react":"^6.24.1","babel-register":"^6.26.0","jsdom":"^11.3.0","mocha":"^2.2.5","react":"^16.x","react-dom":"^16.x","sinon":"^1.17.2"},"gitHead":"fab4629482d6e9819951a3ae1546e6cce03b21aa","_id":"react-onclickout@2.0.8","_shasum":"d178b13fb87a481356761b454aa60df7069b2da4","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.11.2","_npmUser":{"name":"boblauer","email":"rlauer@gmail.com"},"dist":{"shasum":"d178b13fb87a481356761b454aa60df7069b2da4","tarball":"http://registry-npm.ywwl.com/react-onclickout/download/react-onclickout-2.0.8.tgz","integrity":"sha512-JpcIHZwCq6Ba/lVsvrvQWzAKHg4SPavqDr++nOpzgUNELXK1gIS4+fV40C1I1W/j7IrORR9WDuK6IBjcWw4R1Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGz7ZaxjVVBm3J4JuXL89InpQXBZ7jeQCqOUdxyuf6s0AiEA04r9ZoyTV4eOAPI/n/1Fk5IzFFw0cI1rkzeK2thOYmU="}],"size":6821,"noattachment":false,"key":"/react-onclickout/-/react-onclickout-2.0.8.tgz"},"maintainers":[{"name":"boblauer","email":"rlauer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-onclickout-2.0.8.tgz_1507671719519_0.3983162152580917"},"directories":{},"readme":"# An ES6-friendly on-click-outside React component.\n\nThis is a React component that can be used to listen for clicks outside of a given component.  As an example, you may need to hide a menu when a user clicks elsewhere on the page.\n\nThis component was created specifically to support ES6-style React components.  If you want to use a mixin instead, I would recommend the [react-onclickoutside](https://github.com/Pomax/react-onclickoutside) mixin.\n\n## Installation\n\n```\nnpm install react-onclickout --save\n```\n\n## React Version Support\n\nFor React `0.14` or later, use version `2.x` of this package.  For React `0.13` or earlier, use version `1.x` of this package.\n\n## Usage\n\nThere are two ways to use this component.\n\n### As a wrapper component\n\n```jsx\nconst ClickOutHandler = require('react-onclickout');\n\nclass ExampleComponent extends React.Component {\n\n  onClickOut(e) {\n    alert('user clicked outside of the component!');\n  }\n\n  render() {\n    return (\n      <ClickOutHandler onClickOut={this.onClickOut}>\n        <div>Click outside of me!</div>\n      </ClickOutHandler>\n    );\n  }\n}\n```\n\n### As a base component\n\n```jsx\nconst ClickOutComponent = require('react-onclickout');\n\nclass ExampleComponent extends ClickOutComponent {\n\n  onClickOut(e) {\n    alert('user clicked outside of the component!');\n  }\n\n  render() {\n    return (\n      <div>Click outside of me!</div>\n    );\n  }\n}\n```\n\n## Ignoring Elements\n\nThere are times when you may want to ignore certain elements that were clicked outside of the target component.  You can handle such a scenario by inspecting the event passed to your `onClickOut` method handler.\n\n```jsx\nconst ClickOutHandler = require('react-onclickout');\n\nclass ExampleComponent extends React.Component {\n\n  onClickOut(e) {\n    if (hasClass(e.target, 'ignore-me')) return;\n    alert('user clicked outside of the component!');\n  }\n\n  render() {\n    return (\n      <ClickOutHandler onClickOut={this.onClickOut}>\n        <div>Click outside of me!</div>\n      </ClickOutHandler>\n    );\n  }\n}\n```\n\nThat's pretty much it.  Pull requests are more than welcome!\n","publish_time":1507671720593,"_cnpm_publish_time":1507671720593,"dist-tags":{"latest":"2.0.8"}}