Skip to content

Commit

Permalink
v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ooade committed Aug 27, 2020
1 parent 5492331 commit c4bfae2
Show file tree
Hide file tree
Showing 6 changed files with 1,889 additions and 1,943 deletions.
6 changes: 3 additions & 3 deletions __tests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ describe('ClickAway Listener', () => {
);
expect(container.firstElementChild.tagName).toBe('DIV');
});

it('should be able to get rendered as a specified element', () => {
const { container } = render(
const { getByText } = render(
<ClickAwayListener as="article" onClickAway={() => null}>
Hello Article
</ClickAwayListener>
);
expect(container.firstElementChild.tagName).toBe('ARTICLE');
expect(getByText(/Hello Article/).nodeName).toBe('ARTICLE');
});

it('should take in props to be used like every other elements', () => {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-click-away-listener",
"version": "1.3.0",
"version": "1.4.0",
"description": "A simple click away listener built with React Hooks",
"main": "dist/react-click-away-listener.js",
"module": "dist/react-click-away-listener.es.js",
Expand Down Expand Up @@ -29,6 +29,7 @@
"@babel/preset-env": "^7.3.1",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.10.4",
"@rollup/plugin-babel": "^5.2.0",
"@testing-library/react": "^9.3.1",
"@types/jest": "^24.0.21",
"@types/react": "^16.9.11",
Expand All @@ -50,8 +51,7 @@
"react-dom": "^16.11.0",
"rimraf": "^3.0.2",
"rollup": "^1.26.3",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-terser": "^5.1.2",
"rollup-plugin-terser": "^7.0.0",
"typescript": "^3.6.4"
},
"peerDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import babel from 'rollup-plugin-babel';
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';

const pkg = JSON.parse(
Expand All @@ -13,6 +13,7 @@ export default {
plugins: [
babel({
extensions,
babelHelpers: 'bundled',
exclude: 'node_modules/**'
}),
terser()
Expand Down
5 changes: 2 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ interface Props extends React.HTMLAttributes<HTMLElement> {
}

const ClickAwayListener: FunctionComponent<Props> = ({
as = 'div',
onClickAway,
mouseEvent = 'click',
touchEvent = 'touchend',
children,
as = 'div',
...props
}) => {
let node = useRef<HTMLElement>(null);
Expand All @@ -38,7 +37,7 @@ const ClickAwayListener: FunctionComponent<Props> = ({
};
}, [mouseEvent, onClickAway, touchEvent]);

return React.createElement(as, { ref: node, ...props }, children);
return React.createElement(as, { ref: node, ...props });
};

export default ClickAwayListener;
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
"skipLibCheck": true,
Expand Down

0 comments on commit c4bfae2

Please sign in to comment.