react-infinite-scroll-component 6.1.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +23 -11
- package/.github/workflows/push.yml +34 -14
- package/package.json +1 -1
- package/dist/stories/InfiniteScrollWithHeight.d.ts +0 -9
- package/dist/stories/PullDownToRefreshInfScroll.d.ts +0 -8
- package/dist/stories/ScrollableTargetInfScroll.d.ts +0 -8
- package/dist/stories/ScrolleableTop.d.ts +0 -8
- package/dist/stories/WindowInfiniteScrollComponent.d.ts +0 -12
- package/dist/stories/stories.d.ts +0 -1
- package/src/stories/InfiniteScrollWithHeight.tsx +0 -60
- package/src/stories/PullDownToRefreshInfScroll.tsx +0 -59
- package/src/stories/ScrollableTargetInfScroll.tsx +0 -52
- package/src/stories/ScrolleableTop.tsx +0 -62
- package/src/stories/WindowInfiniteScrollComponent.tsx +0 -41
- package/src/stories/stories.tsx +0 -34
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Publish on Release
|
|
2
2
|
|
|
3
|
-
on:
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
4
6
|
|
|
5
7
|
jobs:
|
|
6
|
-
|
|
8
|
+
publish:
|
|
7
9
|
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
id-token: write
|
|
8
13
|
|
|
9
14
|
steps:
|
|
10
|
-
- uses: actions/checkout@
|
|
15
|
+
- uses: actions/checkout@v4
|
|
11
16
|
|
|
12
|
-
- name:
|
|
13
|
-
|
|
17
|
+
- name: Setup Node
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: 20.x
|
|
21
|
+
cache: 'yarn'
|
|
22
|
+
registry-url: 'https://registry.npmjs.org'
|
|
14
23
|
|
|
15
|
-
- name:
|
|
16
|
-
run:
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: yarn install --frozen-lockfile
|
|
26
|
+
|
|
27
|
+
- name: Build
|
|
28
|
+
run: yarn build
|
|
29
|
+
|
|
30
|
+
- name: Publish to npm
|
|
19
31
|
env:
|
|
20
|
-
CI: true
|
|
21
32
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
33
|
+
run: npm publish --access public || true
|
|
@@ -1,30 +1,50 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: CI
|
|
2
2
|
|
|
3
|
-
on:
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ['**']
|
|
6
|
+
pull_request:
|
|
4
7
|
|
|
5
8
|
jobs:
|
|
6
9
|
test:
|
|
7
10
|
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [16.x, 18.x, 20.x]
|
|
8
15
|
|
|
9
16
|
steps:
|
|
10
|
-
- uses: actions/checkout@
|
|
17
|
+
- uses: actions/checkout@v4
|
|
11
18
|
|
|
12
|
-
- name:
|
|
13
|
-
|
|
19
|
+
- name: Setup Node
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: ${{ matrix.node-version }}
|
|
23
|
+
cache: 'yarn'
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: yarn install --frozen-lockfile
|
|
14
27
|
|
|
15
|
-
- name:
|
|
28
|
+
- name: Lint
|
|
16
29
|
run: yarn lint
|
|
17
30
|
|
|
18
|
-
- name:
|
|
31
|
+
- name: Prettier check
|
|
19
32
|
run: yarn prettier:check
|
|
20
33
|
|
|
21
|
-
- name:
|
|
22
|
-
run: yarn test
|
|
23
|
-
|
|
24
|
-
- name: ts type checks
|
|
34
|
+
- name: Type check
|
|
25
35
|
run: yarn ts-check
|
|
26
36
|
|
|
27
|
-
-
|
|
37
|
+
- name: Unit tests
|
|
38
|
+
run: yarn test --coverage --runInBand
|
|
39
|
+
|
|
40
|
+
- name: Build package
|
|
41
|
+
run: yarn build
|
|
42
|
+
|
|
43
|
+
- name: Upload coverage to Codecov
|
|
44
|
+
if: matrix.node-version == '20.x'
|
|
45
|
+
uses: codecov/codecov-action@v4
|
|
28
46
|
with:
|
|
29
|
-
token: ${{secrets.CODECOV_TOKEN}}
|
|
30
|
-
|
|
47
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
48
|
+
files: ./coverage/lcov.info
|
|
49
|
+
flags: unittests
|
|
50
|
+
fail_ci_if_error: false
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
declare type State = {
|
|
3
|
-
data: number[];
|
|
4
|
-
};
|
|
5
|
-
export default class WindowInfiniteScrollComponent extends React.Component<{}, State> {
|
|
6
|
-
state: {
|
|
7
|
-
data: any[];
|
|
8
|
-
};
|
|
9
|
-
next: () => void;
|
|
10
|
-
render(): JSX.Element;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from 'react-dom';
|
|
3
|
-
import InfiniteScroll from '../index';
|
|
4
|
-
|
|
5
|
-
const style = {
|
|
6
|
-
height: 30,
|
|
7
|
-
border: '1px solid green',
|
|
8
|
-
margin: 6,
|
|
9
|
-
padding: 8,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default class App extends React.Component {
|
|
13
|
-
state = {
|
|
14
|
-
items: Array.from({ length: 20 }),
|
|
15
|
-
hasMore: true,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
fetchMoreData = () => {
|
|
19
|
-
if (this.state.items.length >= 500) {
|
|
20
|
-
this.setState({ hasMore: false });
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
// a fake async api call like which sends
|
|
24
|
-
// 20 more records in .5 secs
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
this.setState({
|
|
27
|
-
items: this.state.items.concat(Array.from({ length: 20 })),
|
|
28
|
-
});
|
|
29
|
-
}, 500);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
render() {
|
|
33
|
-
return (
|
|
34
|
-
<div>
|
|
35
|
-
<h1>demo: Infinite Scroll with fixed height</h1>
|
|
36
|
-
<hr />
|
|
37
|
-
<InfiniteScroll
|
|
38
|
-
dataLength={this.state.items.length}
|
|
39
|
-
next={this.fetchMoreData}
|
|
40
|
-
hasMore={this.state.hasMore}
|
|
41
|
-
loader={<h4>Loading...</h4>}
|
|
42
|
-
height={400}
|
|
43
|
-
endMessage={
|
|
44
|
-
<p style={{ textAlign: 'center' }}>
|
|
45
|
-
<b>Yay! You have seen it all</b>
|
|
46
|
-
</p>
|
|
47
|
-
}
|
|
48
|
-
>
|
|
49
|
-
{this.state.items.map((_, index) => (
|
|
50
|
-
<div style={style} key={index}>
|
|
51
|
-
div - #{index}
|
|
52
|
-
</div>
|
|
53
|
-
))}
|
|
54
|
-
</InfiniteScroll>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
render(<App />, document.getElementById('root'));
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from 'react-dom';
|
|
3
|
-
import InfiniteScroll from '../index';
|
|
4
|
-
|
|
5
|
-
const style = {
|
|
6
|
-
height: 30,
|
|
7
|
-
border: '1px solid green',
|
|
8
|
-
margin: 6,
|
|
9
|
-
padding: 8,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default class App extends React.Component {
|
|
13
|
-
state = {
|
|
14
|
-
items: Array.from({ length: 20 }),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
fetchMoreData = () => {
|
|
18
|
-
// a fake async api call like which sends
|
|
19
|
-
// 20 more records in 1.5 secs
|
|
20
|
-
setTimeout(() => {
|
|
21
|
-
this.setState({
|
|
22
|
-
items: this.state.items.concat(Array.from({ length: 20 })),
|
|
23
|
-
});
|
|
24
|
-
}, 1500);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
render() {
|
|
28
|
-
return (
|
|
29
|
-
<div>
|
|
30
|
-
<h1>demo: Pull down to refresh</h1>
|
|
31
|
-
<hr />
|
|
32
|
-
<InfiniteScroll
|
|
33
|
-
dataLength={this.state.items.length}
|
|
34
|
-
next={this.fetchMoreData}
|
|
35
|
-
hasMore={true}
|
|
36
|
-
loader={<h4>Loading...</h4>}
|
|
37
|
-
pullDownToRefresh
|
|
38
|
-
pullDownToRefreshContent={
|
|
39
|
-
<h3 style={{ textAlign: 'center' }}>
|
|
40
|
-
↓ Pull down to refresh
|
|
41
|
-
</h3>
|
|
42
|
-
}
|
|
43
|
-
releaseToRefreshContent={
|
|
44
|
-
<h3 style={{ textAlign: 'center' }}>↑ Release to refresh</h3>
|
|
45
|
-
}
|
|
46
|
-
refreshFunction={this.fetchMoreData}
|
|
47
|
-
>
|
|
48
|
-
{this.state.items.map((_, index) => (
|
|
49
|
-
<div style={style} key={index}>
|
|
50
|
-
div - #{index}
|
|
51
|
-
</div>
|
|
52
|
-
))}
|
|
53
|
-
</InfiniteScroll>
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
render(<App />, document.getElementById('root'));
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from 'react-dom';
|
|
3
|
-
import InfiniteScroll from '../index';
|
|
4
|
-
|
|
5
|
-
const style = {
|
|
6
|
-
height: 30,
|
|
7
|
-
border: '1px solid green',
|
|
8
|
-
margin: 6,
|
|
9
|
-
padding: 8,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default class App extends React.Component {
|
|
13
|
-
state = {
|
|
14
|
-
items: Array.from({ length: 20 }),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
fetchMoreData = () => {
|
|
18
|
-
// a fake async api call like which sends
|
|
19
|
-
// 20 more records in 1.5 secs
|
|
20
|
-
setTimeout(() => {
|
|
21
|
-
this.setState({
|
|
22
|
-
items: this.state.items.concat(Array.from({ length: 20 })),
|
|
23
|
-
});
|
|
24
|
-
}, 1500);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
render() {
|
|
28
|
-
return (
|
|
29
|
-
<div>
|
|
30
|
-
<h1>demo: Infinite Scroll with scrollable target</h1>
|
|
31
|
-
<hr />
|
|
32
|
-
<div id="scrollableDiv" style={{ height: 300, overflow: 'auto' }}>
|
|
33
|
-
<InfiniteScroll
|
|
34
|
-
dataLength={this.state.items.length}
|
|
35
|
-
next={this.fetchMoreData}
|
|
36
|
-
hasMore={true}
|
|
37
|
-
loader={<h4>Loading...</h4>}
|
|
38
|
-
scrollableTarget="scrollableDiv"
|
|
39
|
-
>
|
|
40
|
-
{this.state.items.map((_, index) => (
|
|
41
|
-
<div style={style} key={index}>
|
|
42
|
-
div - #{index}
|
|
43
|
-
</div>
|
|
44
|
-
))}
|
|
45
|
-
</InfiniteScroll>
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
render(<App />, document.getElementById('root'));
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from 'react-dom';
|
|
3
|
-
import InfiniteScroll from '../index';
|
|
4
|
-
|
|
5
|
-
const style = {
|
|
6
|
-
height: 30,
|
|
7
|
-
border: '1px solid green',
|
|
8
|
-
margin: 6,
|
|
9
|
-
padding: 8,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default class App extends React.Component {
|
|
13
|
-
state = {
|
|
14
|
-
items: Array.from({ length: 20 }),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
fetchMoreData = () => {
|
|
18
|
-
// a fake async api call like which sends
|
|
19
|
-
// 20 more records in 1.5 secs
|
|
20
|
-
setTimeout(() => {
|
|
21
|
-
this.setState({
|
|
22
|
-
items: this.state.items.concat(Array.from({ length: 20 })),
|
|
23
|
-
});
|
|
24
|
-
}, 1500);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
render() {
|
|
28
|
-
return (
|
|
29
|
-
<div>
|
|
30
|
-
<h1>demo: Infinite Scroll on top</h1>
|
|
31
|
-
<hr />
|
|
32
|
-
<div
|
|
33
|
-
id="scrollableDiv"
|
|
34
|
-
style={{
|
|
35
|
-
height: 300,
|
|
36
|
-
overflow: 'auto',
|
|
37
|
-
display: 'flex',
|
|
38
|
-
flexDirection: 'column-reverse',
|
|
39
|
-
}}
|
|
40
|
-
>
|
|
41
|
-
<InfiniteScroll
|
|
42
|
-
dataLength={this.state.items.length}
|
|
43
|
-
next={this.fetchMoreData}
|
|
44
|
-
style={{ display: 'flex', flexDirection: 'column-reverse' }} //To put endMessage and loader to the top.
|
|
45
|
-
inverse={true}
|
|
46
|
-
hasMore={true}
|
|
47
|
-
loader={<h4>Loading...</h4>}
|
|
48
|
-
scrollableTarget="scrollableDiv"
|
|
49
|
-
>
|
|
50
|
-
{this.state.items.map((_, index) => (
|
|
51
|
-
<div style={style} key={index}>
|
|
52
|
-
div - #{index}
|
|
53
|
-
</div>
|
|
54
|
-
))}
|
|
55
|
-
</InfiniteScroll>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
render(<App />, document.getElementById('root'));
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import InfiniteScroll from '../index';
|
|
3
|
-
type State = {
|
|
4
|
-
data: number[];
|
|
5
|
-
};
|
|
6
|
-
export default class WindowInfiniteScrollComponent extends React.Component<
|
|
7
|
-
{},
|
|
8
|
-
State
|
|
9
|
-
> {
|
|
10
|
-
state = {
|
|
11
|
-
data: new Array(100).fill(1),
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
next = () => {
|
|
15
|
-
setTimeout(() => {
|
|
16
|
-
const newData = [...this.state.data, new Array(100).fill(1)];
|
|
17
|
-
this.setState({ data: newData });
|
|
18
|
-
}, 2000);
|
|
19
|
-
};
|
|
20
|
-
render() {
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
<InfiniteScroll
|
|
24
|
-
hasMore={true}
|
|
25
|
-
next={this.next}
|
|
26
|
-
loader={<h1>Loading...</h1>}
|
|
27
|
-
dataLength={this.state.data.length}
|
|
28
|
-
>
|
|
29
|
-
{this.state.data.map((_, i) => (
|
|
30
|
-
<div
|
|
31
|
-
key={i}
|
|
32
|
-
style={{ height: 30, margin: 4, border: '1px solid hotpink' }}
|
|
33
|
-
>
|
|
34
|
-
#{i + 1} row
|
|
35
|
-
</div>
|
|
36
|
-
))}
|
|
37
|
-
</InfiniteScroll>
|
|
38
|
-
</>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/stories/stories.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import WindowInf from './WindowInfiniteScrollComponent';
|
|
5
|
-
import PullDownToRefreshInfScroll from './PullDownToRefreshInfScroll';
|
|
6
|
-
import InfiniteScrollWithHeight from './InfiniteScrollWithHeight';
|
|
7
|
-
import ScrollableTargetInfiniteScroll from './ScrollableTargetInfScroll';
|
|
8
|
-
import ScrolleableTop from './ScrolleableTop';
|
|
9
|
-
|
|
10
|
-
const stories = storiesOf('Components', module);
|
|
11
|
-
|
|
12
|
-
stories.add('InfiniteScroll', () => <WindowInf />, {
|
|
13
|
-
info: { inline: true },
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
stories.add('PullDownToRefresh', () => <PullDownToRefreshInfScroll />, {
|
|
17
|
-
info: { inline: true },
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
stories.add('InfiniteScrollWithHeight', () => <InfiniteScrollWithHeight />, {
|
|
21
|
-
info: { inline: true },
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
stories.add(
|
|
25
|
-
'ScrollableTargetInfiniteScroll',
|
|
26
|
-
() => <ScrollableTargetInfiniteScroll />,
|
|
27
|
-
{
|
|
28
|
-
info: { inline: true },
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
stories.add('InfiniteScrollTop', () => <ScrolleableTop />, {
|
|
33
|
-
info: { inline: true },
|
|
34
|
-
});
|