Skip to content

Commit e24503d

Browse files
authored
Update node version in .nvmrc (#87)
* chore(nvmrc): bump node version a little higher * chore(workflow): run test on .nvmrc change * chore(workflow): separate test on main from PR * chore(package.json): remove unused * chore(workflow): switch to npm * chore(workflow): package managers bin wilding
1 parent 123eaf1 commit e24503d

File tree

10 files changed

+16392
-7450
lines changed

10 files changed

+16392
-7450
lines changed
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
name: Test
1+
name: Test PR
22

33
on:
44
pull_request:
55
branches: [main]
66
paths:
77
- 'src/**'
88
- '__tests__/**'
9-
- yarn.lock
9+
- package-lock.json
10+
- .nvmrc
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -20,7 +21,7 @@ jobs:
2021
- uses: actions/setup-node@v3
2122
with:
2223
node-version-file: '.nvmrc'
23-
cache: 'yarn'
24-
- run: yarn install --frozen-lockfile
25-
- run: yarn run coverage
26-
- run: yarn run build
24+
cache: 'npm'
25+
- run: npm ci --legacy-peer-deps
26+
- run: npm run coverage
27+
- run: npm run build

.github/workflows/publish-on-npm.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches: [main, beta]
66
paths:
77
- 'src/**'
8-
- yarn.lock
8+
- package-lock.json
99

1010
jobs:
1111
release:
@@ -15,8 +15,8 @@ jobs:
1515
- uses: actions/setup-node@v3
1616
with:
1717
node-version-file: '.nvmrc'
18-
cache: 'yarn'
19-
- run: yarn install --frozen-lockfile
18+
cache: 'npm'
19+
- run: npm ci --legacy-peer-deps
2020
- run: npx semantic-release
2121
env:
2222
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/report-coverage.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
push:
55
branches: [main]
66
paths:
7-
- 'src/**'
8-
- '__tests__/**'
7+
- 'src/**'
8+
- '__tests__/**'
99

1010
jobs:
1111
report_test_coverage:
@@ -15,9 +15,9 @@ jobs:
1515
- uses: actions/setup-node@v3
1616
with:
1717
node-version-file: '.nvmrc'
18-
cache: 'yarn'
19-
- run: yarn install --frozen-lockfile
20-
- run: yarn run coverage
18+
cache: 'npm'
19+
- run: npm ci --legacy-peer-deps
20+
- run: npm run coverage
2121
- uses: coverallsapp/github-action@master
2222
with:
23-
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-main.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Test main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
test_pull_request:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-node@v3
13+
with:
14+
node-version-file: '.nvmrc'
15+
cache: 'npm'
16+
- run: npm ci --legacy-peer-deps
17+
- run: npm run coverage
18+
- run: npm run build

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.12.1
1+
20.11.0

README.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@
1515

1616
## Installation
1717

18+
```sh
19+
npm install react-click-away-listener
20+
```
21+
22+
or
23+
1824
```sh
1925
yarn add react-click-away-listener
2026
```
2127

22-
- It's quite **small** in size! Just [![Bundlephobia](https://img.shields.io/bundlephobia/min/react-click-away-listener.svg?style=flat-square&label "Bundle size (minified)")](https://bundlephobia.com/result?p=react-click-away-listener) minified, or [![Bundlephobia](https://img.shields.io/bundlephobia/minzip/react-click-away-listener.svg?style=flat-square&label "Bundle size (minified+gzipped)")](https://bundlephobia.com/result?p=react-click-away-listener) minified & gzipp’d.
28+
- It's quite **small** in size! Just [![Bundlephobia](https://img.shields.io/bundlephobia/min/react-click-away-listener.svg?style=flat-square&label 'Bundle size (minified)')](https://bundlephobia.com/result?p=react-click-away-listener) minified, or [![Bundlephobia](https://img.shields.io/bundlephobia/minzip/react-click-away-listener.svg?style=flat-square&label 'Bundle size (minified+gzipped)')](https://bundlephobia.com/result?p=react-click-away-listener) minified & gzipp’d.
2329
- It's built with **TypeScript**.
2430
- It works with [React Portals](https://reactjs.org/docs/portals.html) ([v2.0.0](https://github.com/ooade/react-click-away-listener/releases/tag/v2.0.0) onwards).
2531
- It supports **mouse**, **touch** and **focus** events.
@@ -37,7 +43,10 @@ const App = () => {
3743
return (
3844
<div id="app">
3945
<ClickAwayListener onClickAway={handleClickAway}>
40-
<div> Triggers whenever a click event is registered outside this div element </div>
46+
<div>
47+
{' '}
48+
Triggers whenever a click event is registered outside this div element{' '}
49+
</div>
4150
</ClickAwayListener>
4251
</div>
4352
);
@@ -66,11 +75,11 @@ If you have multiple child components to pass, you can simply wrap them around a
6675
```jsx
6776
// Assume the `handleClickAway` function is defined.
6877
<ClickAwayListener onClickAway={handleClickAway}>
69-
<>
70-
<p>First paragraph</p>
71-
<button>Example Button</button>
72-
<p>Second paragraph</p>
73-
</>
78+
<>
79+
<p>First paragraph</p>
80+
<button>Example Button</button>
81+
<p>Second paragraph</p>
82+
</>
7483
</ClickAwayListener>
7584
```
7685

@@ -79,21 +88,18 @@ Or if you only have text nodes, you can also wrap them in a [React Fragment](htt
7988
```jsx
8089
// Assume the `handleClickAway` function is defined.
8190
<ClickAwayListener onClickAway={handleClickAway}>
82-
<>
83-
First text node
84-
Second text node
85-
</>
91+
<>First text node Second text node</>
8692
</ClickAwayListener>
8793
```
8894

8995
## Props
9096

91-
| Name | Type | Default | Description |
92-
| ----------- | ----------------------------------| ------------- |---------------------------------------------------------- |
93-
| onClickAway | (event) => void | | Fires when a user clicks outside the click away component |
94-
| mouseEvent | 'click' \|<br/>'mousedown' \|<br/>'mouseup'| 'click' | The mouse event type that gets fired on ClickAway |
95-
| touchEvent | 'touchstart' \|<br/>'touchend' | 'touchend' | The touch event type that gets fired on ClickAway |
96-
| focusEvent | 'focusin' \|<br/>'focusout' | 'focusin' | The focus event type that gets fired on ClickAway |
97+
| Name | Type | Default | Description |
98+
| ----------- | ------------------------------------------- | ---------- | --------------------------------------------------------- |
99+
| onClickAway | (event) => void | | Fires when a user clicks outside the click away component |
100+
| mouseEvent | 'click' \|<br/>'mousedown' \|<br/>'mouseup' | 'click' | The mouse event type that gets fired on ClickAway |
101+
| touchEvent | 'touchstart' \|<br/>'touchend' | 'touchend' | The touch event type that gets fired on ClickAway |
102+
| focusEvent | 'focusin' \|<br/>'focusout' | 'focusin' | The focus event type that gets fired on ClickAway |
97103

98104
## Examples
99105

__tests__/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('ClickAway Listener', () => {
7878
fireEvent[fireEventFn](getByText(/A button/i));
7979
fireEvent[fireEventFn](getByText(/A text element/i));
8080
fireEvent[fireEventFn](getByText(/Hello World/i));
81-
expect(handleClickAway).toBeCalledTimes(2);
81+
expect(handleClickAway).toHaveBeenCalledTimes(2);
8282
}
8383
);
8484

@@ -107,7 +107,7 @@ describe('ClickAway Listener', () => {
107107
fireEvent[fireEventFn](getByText(/A button/i));
108108
fireEvent[fireEventFn](getByText(/A text element/i));
109109
fireEvent[fireEventFn](getByText(/Hello World/i));
110-
expect(handleClickAway).toBeCalledTimes(2);
110+
expect(handleClickAway).toHaveBeenCalledTimes(2);
111111
}
112112
);
113113

@@ -136,7 +136,7 @@ describe('ClickAway Listener', () => {
136136
fireEvent[fireEventFn](getByText(/A button/i));
137137
fireEvent[fireEventFn](getByText(/A text element/i));
138138
fireEvent[fireEventFn](getByText(/Hello World/i));
139-
expect(handleClickAway).toBeCalledTimes(2);
139+
expect(handleClickAway).toHaveBeenCalledTimes(2);
140140
}
141141
);
142142

@@ -168,14 +168,14 @@ describe('ClickAway Listener', () => {
168168
fireEvent.click(getByTestId('text-one'));
169169
fireEvent.click(getByTestId('hello-world'));
170170
fireEvent.click(getByTestId('some-other-button-one'));
171-
expect(handleClickAway).toBeCalledTimes(3);
171+
expect(handleClickAway).toHaveBeenCalledTimes(3);
172172

173173
// 4 from the previous ones, and the 3 new ones
174174
fireEvent.click(getByTestId('button-two'));
175175
fireEvent.click(getByTestId('text-two'));
176176
fireEvent.click(getByTestId('foo-bar'));
177177
fireEvent.click(getByTestId('some-other-button-two'));
178-
expect(handleClickAway2).toBeCalledTimes(7);
178+
expect(handleClickAway2).toHaveBeenCalledTimes(7);
179179
});
180180

181181
const Input = React.forwardRef<HTMLInputElement>((props, ref) => {
@@ -214,7 +214,7 @@ describe('ClickAway Listener', () => {
214214

215215
fireEvent.click(getByText(/A button/i));
216216
fireEvent.click(getByText(/A text element/i));
217-
expect(handleClickAway).toBeCalledTimes(2);
217+
expect(handleClickAway).toHaveBeenCalledTimes(2);
218218
expect(result.current.ref).toStrictEqual(inputRef);
219219
});
220220

@@ -234,8 +234,8 @@ describe('ClickAway Listener', () => {
234234

235235
fireEvent.click(getByText('Hello World'));
236236
fireEvent.click(getByText('The new boston'));
237-
expect(handleClickAway).toBeCalledTimes(1);
238-
expect(handleClick).toBeCalledTimes(1);
237+
expect(handleClickAway).toHaveBeenCalledTimes(1);
238+
expect(handleClick).toHaveBeenCalledTimes(1);
239239
});
240240

241241
it('should work with function refs', () => {
@@ -269,7 +269,7 @@ describe('ClickAway Listener', () => {
269269
buttonRef.click();
270270
divRef.click();
271271
expect(buttonRef).toHaveProperty('type', 'submit');
272-
expect(handleClickAway).toBeCalledTimes(1);
272+
expect(handleClickAway).toHaveBeenCalledTimes(1);
273273
});
274274

275275
it('should work with Portals', () => {
@@ -311,6 +311,6 @@ describe('ClickAway Listener', () => {
311311
jest.advanceTimersByTime(0);
312312
fireEvent.click(getByText(/Hello World/i));
313313
fireEvent.click(getByText(/A button/i));
314-
expect(handleClickAway).toBeCalledTimes(1);
314+
expect(handleClickAway).toHaveBeenCalledTimes(1);
315315
});
316316
});

0 commit comments

Comments
 (0)