redux-paginator-immutable 17.0.50 → 17.1.0
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/{lib/Info.d.ts → Info.d.ts} +0 -0
- package/{lib/Info.js → Info.js} +0 -0
- package/{lib/Info.js.map → Info.js.map} +0 -0
- package/{lib/LoadDataItem.d.ts → LoadDataItem.d.ts} +0 -0
- package/{lib/LoadDataItem.js → LoadDataItem.js} +0 -0
- package/{lib/LoadDataItem.js.map → LoadDataItem.js.map} +0 -0
- package/{lib/LoadPaginator.d.ts → LoadPaginator.d.ts} +0 -0
- package/{lib/LoadPaginator.js → LoadPaginator.js} +0 -0
- package/{lib/LoadPaginator.js.map → LoadPaginator.js.map} +0 -0
- package/{lib/LoadPaginatorTypes.d.ts → LoadPaginatorTypes.d.ts} +0 -0
- package/{lib/LoadPaginatorTypes.js → LoadPaginatorTypes.js} +0 -0
- package/{lib/LoadPaginatorTypes.js.map → LoadPaginatorTypes.js.map} +0 -0
- package/{lib/LoadingButton.d.ts → LoadingButton.d.ts} +0 -0
- package/{lib/LoadingButton.js → LoadingButton.js} +0 -0
- package/{lib/LoadingButton.js.map → LoadingButton.js.map} +0 -0
- package/{lib/actionTypes.d.ts → actionTypes.d.ts} +0 -0
- package/{lib/actionTypes.js → actionTypes.js} +0 -0
- package/{lib/actionTypes.js.map → actionTypes.js.map} +0 -0
- package/{lib/actions.d.ts → actions.d.ts} +0 -0
- package/{lib/actions.js → actions.js} +0 -0
- package/{lib/actions.js.map → actions.js.map} +0 -0
- package/{lib/agent.d.ts → agent.d.ts} +0 -0
- package/{lib/agent.js → agent.js} +0 -0
- package/{lib/agent.js.map → agent.js.map} +0 -0
- package/{lib/createDataReducer.d.ts → createDataReducer.d.ts} +0 -0
- package/{lib/createDataReducer.js → createDataReducer.js} +0 -0
- package/{lib/createDataReducer.js.map → createDataReducer.js.map} +0 -0
- package/{lib/createItemReducer.d.ts → createItemReducer.d.ts} +0 -0
- package/{lib/createItemReducer.js → createItemReducer.js} +0 -0
- package/{lib/createItemReducer.js.map → createItemReducer.js.map} +0 -0
- package/{lib/createPaginator.d.ts → createPaginator.d.ts} +0 -0
- package/{lib/createPaginator.js → createPaginator.js} +0 -0
- package/{lib/createPaginator.js.map → createPaginator.js.map} +0 -0
- package/{lib/index.d.ts → index.d.ts} +0 -0
- package/{lib/index.js → index.js} +0 -0
- package/{lib/index.js.map → index.js.map} +0 -0
- package/package.json +122 -112
- package/{lib/paginatorMiddleware.d.ts → paginatorMiddleware.d.ts} +0 -0
- package/{lib/paginatorMiddleware.js → paginatorMiddleware.js} +0 -0
- package/{lib/paginatorMiddleware.js.map → paginatorMiddleware.js.map} +0 -0
- package/{lib/reducerItemData.d.ts → reducerItemData.d.ts} +0 -0
- package/{lib/reducerItemData.js → reducerItemData.js} +0 -0
- package/{lib/reducerItemData.js.map → reducerItemData.js.map} +0 -0
- package/{lib/reducerOperations.d.ts → reducerOperations.d.ts} +0 -0
- package/{lib/reducerOperations.js → reducerOperations.js} +0 -0
- package/{lib/reducerOperations.js.map → reducerOperations.js.map} +0 -0
- package/{lib/reducers.d.ts → reducers.d.ts} +0 -0
- package/{lib/reducers.js → reducers.js} +0 -0
- package/{lib/reducers.js.map → reducers.js.map} +0 -0
- package/{lib/selectors.d.ts → selectors.d.ts} +0 -0
- package/{lib/selectors.js → selectors.js} +0 -0
- package/{lib/selectors.js.map → selectors.js.map} +0 -0
- package/style.css +0 -0
- package/{lib/types.d.ts → types.d.ts} +0 -0
- package/{lib/types.js → types.js} +0 -0
- package/{lib/types.js.map → types.js.map} +0 -0
- package/{lib/util.d.ts → util.d.ts} +0 -0
- package/{lib/util.js → util.js} +0 -0
- package/{lib/util.js.map → util.js.map} +0 -0
- package/README.md +0 -3
- package/src/Info.tsx +0 -28
- package/src/LoadDataItem.tsx +0 -84
- package/src/LoadPaginator.tsx +0 -104
- package/src/LoadPaginatorTypes.ts +0 -31
- package/src/LoadingButton.tsx +0 -44
- package/src/__tests__/actions.spec.js +0 -130
- package/src/__tests__/agent.spec.js +0 -32
- package/src/__tests__/createPaginator.spec.js +0 -39
- package/src/__tests__/reducers.spec.js +0 -131
- package/src/__tests__/selectors.spec.js +0 -180
- package/src/__tests__/setup.js +0 -1
- package/src/actionTypes.ts +0 -9
- package/src/actions.ts +0 -156
- package/src/agent.ts +0 -62
- package/src/createDataReducer.ts +0 -90
- package/src/createItemReducer.ts +0 -29
- package/src/createPaginator.ts +0 -104
- package/src/index.ts +0 -26
- package/src/paginatorMiddleware.ts +0 -93
- package/src/reducerItemData.ts +0 -74
- package/src/reducerOperations.ts +0 -92
- package/src/reducers.ts +0 -77
- package/src/selectors.ts +0 -111
- package/src/types.ts +0 -130
- package/src/util.ts +0 -51
|
File without changes
|
package/{lib/Info.js → Info.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,116 +1,126 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
"name": "redux-paginator-immutable",
|
|
3
|
+
"version": "17.1.0",
|
|
4
|
+
"description": "redux-paginator-immutable",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"load": "npm run intern-pre && cd dist && npm run ts && npm run intern-copy && npm publish",
|
|
9
|
+
"load-beta": "npm run intern-pre && cd dist && npm run ts && npm run intern-copy && npm publish --tag beta",
|
|
10
|
+
"eslint": "eslint --ext .tsx,.ts src --fix",
|
|
11
|
+
"intern-pre": "npm run eslint && npm run intern-clean && npm run intern-build",
|
|
12
|
+
"intern-build-scss": "node-sass --output-style compressed src -o dist",
|
|
13
|
+
"intern-copy": " copy package.json dist",
|
|
14
|
+
"intern-build": "npm run intern-build-scss",
|
|
15
|
+
"intern-clean": "rimraf dist dist",
|
|
16
|
+
"intern-test": "jest",
|
|
17
|
+
"check": "node script/check & npm run depcheck & npm run check:npm-check",
|
|
18
|
+
"check:npm-check": "npm-check -u -i \"{babel-jest,jest}\" --specials=bin,eslint,babel,webpack",
|
|
19
|
+
"depcheck": "depcheck --ignores=@types/jest,@docusaurus/react-loadable,webpack-cli,@hot-loader/react-dom --ignore-patterns=server,node_modules,tmp,fonts",
|
|
20
|
+
"check:global": "npm-check -gu",
|
|
21
|
+
"ts:check": "tsc --noEmit",
|
|
22
|
+
"ts": "tsc --declaration"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/cristian-sima/redux-paginator-immutable.git"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [],
|
|
29
|
+
"author": "SC SIDEWORK SRL",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/cristian-sima/redux-paginator-immutable/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/cristian-sima/redux-paginator-immutable#readme",
|
|
35
|
+
"babel": {
|
|
36
|
+
"presets": [
|
|
37
|
+
"@babel/env",
|
|
38
|
+
"@babel/preset-typescript",
|
|
39
|
+
"@babel/preset-react"
|
|
40
|
+
],
|
|
41
|
+
"env": {
|
|
42
|
+
"production": {
|
|
43
|
+
"plugins": [
|
|
44
|
+
"@babel/plugin-syntax-dynamic-import",
|
|
45
|
+
"@babel/plugin-proposal-class-properties",
|
|
46
|
+
"@babel/plugin-proposal-export-default-from",
|
|
47
|
+
"@babel/plugin-transform-modules-commonjs",
|
|
48
|
+
"@babel/plugin-transform-react-constant-elements",
|
|
49
|
+
"@babel/plugin-transform-react-inline-elements",
|
|
50
|
+
"@babel/plugin-transform-typescript",
|
|
51
|
+
"transform-react-remove-prop-types"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"development": {
|
|
55
|
+
"plugins": [
|
|
56
|
+
"@babel/plugin-syntax-dynamic-import",
|
|
57
|
+
"@babel/plugin-proposal-class-properties",
|
|
58
|
+
"@babel/plugin-proposal-export-default-from",
|
|
59
|
+
"@babel/plugin-transform-modules-commonjs"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": "^17.0.0"
|
|
66
|
+
},
|
|
67
|
+
"jest": {
|
|
68
|
+
"transform": {
|
|
69
|
+
"^.+\\.tsx?$": "babel-jest"
|
|
70
|
+
},
|
|
71
|
+
"testRegex": "src/.*-test.ts$",
|
|
72
|
+
"modulePaths": [
|
|
73
|
+
"src"
|
|
28
74
|
]
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
78
|
+
"@babel/plugin-proposal-export-default-from": "^7.18.10",
|
|
79
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
80
|
+
"@babel/plugin-transform-modules-commonjs": "^7.19.6",
|
|
81
|
+
"@babel/plugin-transform-react-constant-elements": "^7.18.12",
|
|
82
|
+
"@babel/plugin-transform-react-inline-elements": "^7.18.6",
|
|
83
|
+
"@babel/plugin-transform-typescript": "^7.20.0",
|
|
84
|
+
"@babel/preset-env": "^7.19.4",
|
|
85
|
+
"@babel/preset-react": "^7.18.6",
|
|
86
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
87
|
+
"@types/jest": "^29.2.0",
|
|
88
|
+
"@types/superagent": "^4.1.15",
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^5.41.0",
|
|
90
|
+
"@typescript-eslint/parser": "^5.41.0",
|
|
91
|
+
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
92
|
+
"copy": "^0.3.2",
|
|
93
|
+
"css-loader": "^6.7.1",
|
|
94
|
+
"depcheck": "^1.4.3",
|
|
95
|
+
"eslint": "^8.26.0",
|
|
96
|
+
"eslint-plugin-import": "^2.26.0",
|
|
97
|
+
"eslint-plugin-react": "^7.31.10",
|
|
98
|
+
"jest-cli": "^29.2.2",
|
|
99
|
+
"jest-immutable-matchers": "^3.0.0",
|
|
100
|
+
"npm-check": "^6.0.1",
|
|
101
|
+
"style-loader": "^3.3.1",
|
|
102
|
+
"ts-loader": "^9.4.1",
|
|
103
|
+
"webpack": "^5.74.0"
|
|
104
|
+
},
|
|
105
|
+
"dependencies": {
|
|
106
|
+
"@docusaurus/react-loadable": "^5.5.2",
|
|
107
|
+
"@reduxjs/toolkit": "^1.8.6",
|
|
108
|
+
"classnames": "^2.3.2",
|
|
109
|
+
"immutable": "^4.2.2",
|
|
110
|
+
"jest": "^27.5.1",
|
|
111
|
+
"moment": "^2.29.4",
|
|
112
|
+
"node-sass": "^7.0.3",
|
|
113
|
+
"query-string": "^8.1.0",
|
|
114
|
+
"react": "^17.0.2",
|
|
115
|
+
"react-final-form": "^6.5.9",
|
|
116
|
+
"react-intersection-observer": "^9.4.1",
|
|
117
|
+
"react-notification-system-redux2": "^3.0.4",
|
|
118
|
+
"react-redux": "^8.0.4",
|
|
119
|
+
"react-simple-tooltip": "^2.6.3",
|
|
120
|
+
"redux": "^4.2.0",
|
|
121
|
+
"reselect": "^4.1.6",
|
|
122
|
+
"superagent": "^8.0.3",
|
|
123
|
+
"typescript": "^4.8.4",
|
|
124
|
+
"x25": "^17.3.17"
|
|
36
125
|
}
|
|
37
|
-
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"clean": "rimraf dist lib",
|
|
40
|
-
"eslint": "eslint --ext .jsx,.js,.ts,.tsx src --fix",
|
|
41
|
-
"load": "npm run test && npm run clean && npm run eslint && npm run ts && npm publish",
|
|
42
|
-
"test": "ts-mocha src/__tests__/*.spec.js",
|
|
43
|
-
"test:watch": "npm test -- --watch",
|
|
44
|
-
"test:cov": "babel-node ./node_modules/isparta/bin/isparta cover ./node_modules/mocha/bin/_mocha -- --recursive \"src/**/__tests__/*\" --require src/__tests__/setup.js",
|
|
45
|
-
"test:codecov": "cat ./coverage/coverage.json | ./node_modules/.bin/codecov",
|
|
46
|
-
"check": "npm run depcheck & npm run check:npm-check",
|
|
47
|
-
"check:npm-check": "npm-check -u -i babel-jest -i jest --specials=bin,eslint,babel,webpack",
|
|
48
|
-
"depcheck": "depcheck --ignores=webpack-cli,@hot-loader/react-dom --ignore-patterns=server,node_modules,tmp,fonts",
|
|
49
|
-
"check:global": "npm-check -gu",
|
|
50
|
-
"ts:check": "tsc --noEmit ",
|
|
51
|
-
"ts": "tsc --declaration"
|
|
52
|
-
},
|
|
53
|
-
"repository": {
|
|
54
|
-
"type": "git",
|
|
55
|
-
"url": "git+https://github.com/cristian-sima/redux-paginator-immutable.git"
|
|
56
|
-
},
|
|
57
|
-
"files": [
|
|
58
|
-
"dist",
|
|
59
|
-
"lib",
|
|
60
|
-
"src"
|
|
61
|
-
],
|
|
62
|
-
"keywords": [
|
|
63
|
-
"redux",
|
|
64
|
-
"paginator",
|
|
65
|
-
"pagination",
|
|
66
|
-
"async",
|
|
67
|
-
"immutablejs",
|
|
68
|
-
"immutable",
|
|
69
|
-
"paginate",
|
|
70
|
-
"paging"
|
|
71
|
-
],
|
|
72
|
-
"author": "Cristian Sima",
|
|
73
|
-
"license": "MIT",
|
|
74
|
-
"bugs": {
|
|
75
|
-
"url": "https://github.com/cristian-sima/redux-paginator-immutable/issues"
|
|
76
|
-
},
|
|
77
|
-
"homepage": "https://github.com/cristian-sima/redux-paginator-immutable#readme",
|
|
78
|
-
"devDependencies": {
|
|
79
|
-
"@babel/preset-env": "^7.20.2",
|
|
80
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
81
|
-
"@types/superagent": "^4.1.16",
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
83
|
-
"@typescript-eslint/parser": "^5.48.0",
|
|
84
|
-
"babel-plugin-transform-decorators-legacy": "^1.3.5",
|
|
85
|
-
"babel-polyfill": "^6.26.0",
|
|
86
|
-
"chai": "^4.3.7",
|
|
87
|
-
"chai-immutable": "^2.1.0",
|
|
88
|
-
"codecov": "^3.8.1",
|
|
89
|
-
"depcheck": "^1.4.3",
|
|
90
|
-
"es3ify": "^0.2.2",
|
|
91
|
-
"eslint": "^8.31.0",
|
|
92
|
-
"eslint-plugin-import": "^2.26.0",
|
|
93
|
-
"eslint-plugin-react": "^7.31.11",
|
|
94
|
-
"expect": "^28.1.0",
|
|
95
|
-
"flux-standard-action": "^2.1.1",
|
|
96
|
-
"glob": "^8.0.3",
|
|
97
|
-
"isparta": "^4.1.1",
|
|
98
|
-
"mocha": "^10.1.0",
|
|
99
|
-
"npm-check": "^5.9.2",
|
|
100
|
-
"rimraf": "^3.0.2",
|
|
101
|
-
"ts-mocha": "^10.0.0",
|
|
102
|
-
"typescript": "^4.9.4",
|
|
103
|
-
"webpack": "^5.75.0"
|
|
104
|
-
},
|
|
105
|
-
"dependencies": {
|
|
106
|
-
"immutable": "^3.8.2",
|
|
107
|
-
"query-string": "^7.1.1",
|
|
108
|
-
"react": "^17.0.2",
|
|
109
|
-
"react-intersection-observer": "^9.4.1",
|
|
110
|
-
"react-redux": "^8.0.5",
|
|
111
|
-
"redux": "^4.2.0",
|
|
112
|
-
"reselect": "^4.1.7",
|
|
113
|
-
"superagent": "^7.1.3",
|
|
114
|
-
"x25": "^17.3.13"
|
|
115
|
-
}
|
|
116
126
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/style.css
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/{lib/util.js → util.js}
RENAMED
|
File without changes
|
|
File without changes
|
package/README.md
DELETED
package/src/Info.tsx
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
type InfoPropTypes = {
|
|
2
|
-
shown: number;
|
|
3
|
-
total: number;
|
|
4
|
-
one: string;
|
|
5
|
-
all: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { words } from "x25/utility";
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
getNumberForm = (value: number, one: string, all: string): string => {
|
|
13
|
-
if (value === 1) {
|
|
14
|
-
return `1 ${one}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return `${words.getNumberTense(value)} ${all}`;
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
Info = ({ shown, total, one, all }: InfoPropTypes) => (
|
|
21
|
-
<div className="text-muted">
|
|
22
|
-
{`${words.Showing} `}
|
|
23
|
-
{shown === total ? `${words.All} - ` : `${shown} ${words.Of}`}
|
|
24
|
-
{` ${getNumberForm(total, one, all)}`}
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export default Info;
|
package/src/LoadDataItem.tsx
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
type LoadDataItemPropTypes = {
|
|
4
|
-
isFetching: boolean;
|
|
5
|
-
fetched: boolean;
|
|
6
|
-
id: string;
|
|
7
|
-
hasError: boolean;
|
|
8
|
-
data: any;
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
shouldFetch: any;
|
|
11
|
-
fetchItem: () => void;
|
|
12
|
-
};
|
|
13
|
-
type OwnProps = {
|
|
14
|
-
id: string;
|
|
15
|
-
settings: {
|
|
16
|
-
selectors: any;
|
|
17
|
-
dataItemURL: string;
|
|
18
|
-
endpoint: string;
|
|
19
|
-
manageEntity: any;
|
|
20
|
-
normalizeDataItem: any;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
import { connect } from "react-redux";
|
|
24
|
-
import { LargeErrorMessage, LoadingMessage } from "x25/Messages";
|
|
25
|
-
import { words } from "x25/utility";
|
|
26
|
-
import { fetchItem as fetchItemAction } from "./actions";
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
mapStateToProps = (state: any, {
|
|
30
|
-
settings: {
|
|
31
|
-
selectors,
|
|
32
|
-
},
|
|
33
|
-
id,
|
|
34
|
-
}: OwnProps) => ({
|
|
35
|
-
data : selectors.getItem(state, id),
|
|
36
|
-
hasError : selectors.getItemHasError(state, id),
|
|
37
|
-
fetched : selectors.getItemIsFetched(state, id),
|
|
38
|
-
isFetching : selectors.getIsFetchingItemInfo(state, id),
|
|
39
|
-
shouldFetch : selectors.getShouldFetchItemInfo(state, id),
|
|
40
|
-
}),
|
|
41
|
-
mapDispatchToProps = (dispatch: any, {
|
|
42
|
-
id,
|
|
43
|
-
settings,
|
|
44
|
-
}: OwnProps) => ({
|
|
45
|
-
fetchItem () {
|
|
46
|
-
dispatch(fetchItemAction({
|
|
47
|
-
...settings,
|
|
48
|
-
id,
|
|
49
|
-
}));
|
|
50
|
-
},
|
|
51
|
-
}),
|
|
52
|
-
|
|
53
|
-
LoadDataItem = (props: LoadDataItemPropTypes) : any => {
|
|
54
|
-
const {
|
|
55
|
-
children,
|
|
56
|
-
data,
|
|
57
|
-
isFetching,
|
|
58
|
-
shouldFetch,
|
|
59
|
-
hasError,
|
|
60
|
-
fetchItem,
|
|
61
|
-
} = props;
|
|
62
|
-
|
|
63
|
-
React.useEffect(() => {
|
|
64
|
-
if (shouldFetch) {
|
|
65
|
-
fetchItem();
|
|
66
|
-
}
|
|
67
|
-
}, [shouldFetch, isFetching, hasError]);
|
|
68
|
-
|
|
69
|
-
if (isFetching) {
|
|
70
|
-
return <LoadingMessage message={words.LoadingData} />;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (hasError) {
|
|
74
|
-
return <LargeErrorMessage message={words.ThereWasAProblem} onRetry={fetchItem} />;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (data.size === 0) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return children;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default connect(mapStateToProps, mapDispatchToProps)(LoadDataItem);
|
package/src/LoadPaginator.tsx
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
import * as Immutable from "immutable";
|
|
3
|
-
import { useDispatch, useSelector } from "react-redux";
|
|
4
|
-
import { LargeErrorMessage, LoadingMessage } from "x25/Messages";
|
|
5
|
-
import { words } from "x25/utility";
|
|
6
|
-
import selectors from "./selectors";
|
|
7
|
-
import LoadingButton from "./LoadingButton";
|
|
8
|
-
|
|
9
|
-
import { ChangeView, List, LoadData, LoadPaginatorPropTypes, ResetView } from "./LoadPaginatorTypes";
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
LoadPaginator = (props : LoadPaginatorPropTypes) => {
|
|
13
|
-
const
|
|
14
|
-
{ token, settings } = props,
|
|
15
|
-
|
|
16
|
-
{ list, entities } = useSelector((state : never) => (
|
|
17
|
-
selectors.getPaginators(state, settings.key)
|
|
18
|
-
)),
|
|
19
|
-
|
|
20
|
-
currentPage = selectors.getCurrentView(list, token),
|
|
21
|
-
isFetching = selectors.isPageFetching(list, token, currentPage),
|
|
22
|
-
isFetched = selectors.isPageFetched(list, token, currentPage),
|
|
23
|
-
resultsUpTo = (
|
|
24
|
-
selectors.getResultsUpToPage(list, token, entities, currentPage, settings.rowsPerLoad)
|
|
25
|
-
),
|
|
26
|
-
items = settings.manipulateItems(resultsUpTo),
|
|
27
|
-
total = selectors.getCurrentTotalResultsCount(list, token),
|
|
28
|
-
hasProblems = selectors.hasPageProblems(list, token),
|
|
29
|
-
|
|
30
|
-
paginator = Immutable.Map({
|
|
31
|
-
currentPage,
|
|
32
|
-
hasProblems,
|
|
33
|
-
isFetched,
|
|
34
|
-
isFetching,
|
|
35
|
-
items,
|
|
36
|
-
total,
|
|
37
|
-
}),
|
|
38
|
-
|
|
39
|
-
dispatch = useDispatch(),
|
|
40
|
-
resetView : ResetView = (currentToken) => dispatch(settings.resetView(currentToken)),
|
|
41
|
-
changeView : ChangeView = (data) => dispatch(settings.changeView(data)),
|
|
42
|
-
loadData : LoadData = (page) => dispatch(settings.requestPage(page, token)),
|
|
43
|
-
|
|
44
|
-
showLoading = paginator.get("total") !== items.size,
|
|
45
|
-
|
|
46
|
-
shouldFetch = !isFetched && !isFetching,
|
|
47
|
-
handleLoadMoreClick = () => {
|
|
48
|
-
if (hasProblems) {
|
|
49
|
-
loadData(currentPage);
|
|
50
|
-
} else {
|
|
51
|
-
changeView({
|
|
52
|
-
token,
|
|
53
|
-
view: currentPage + 1,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (shouldFetch) {
|
|
60
|
-
loadData(currentPage);
|
|
61
|
-
}
|
|
62
|
-
}, [shouldFetch]);
|
|
63
|
-
|
|
64
|
-
useEffect(() => () => resetView(token), []);
|
|
65
|
-
|
|
66
|
-
if (items.size === 0 && isFetching) {
|
|
67
|
-
return <LoadingMessage message={words.LoadingData} />;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (hasProblems && currentPage === 1) {
|
|
71
|
-
return (
|
|
72
|
-
<LargeErrorMessage
|
|
73
|
-
message={words.ThereWasAProblem}
|
|
74
|
-
onRetry={handleLoadMoreClick}
|
|
75
|
-
/>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<>
|
|
81
|
-
{
|
|
82
|
-
React.cloneElement(props.children as React.ReactElement<List>, {
|
|
83
|
-
token : props.token,
|
|
84
|
-
settings : props.settings,
|
|
85
|
-
paginator,
|
|
86
|
-
changeView,
|
|
87
|
-
resetView,
|
|
88
|
-
loadData,
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
{
|
|
92
|
-
showLoading ? (
|
|
93
|
-
<LoadingButton
|
|
94
|
-
hasProblems={hasProblems}
|
|
95
|
-
isFetching={isFetching}
|
|
96
|
-
onLoadMoreClick={handleLoadMoreClick}
|
|
97
|
-
/>
|
|
98
|
-
) : null
|
|
99
|
-
}
|
|
100
|
-
</>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export default LoadPaginator;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
type Settings = {
|
|
2
|
-
key: string;
|
|
3
|
-
rowsPerLoad: number;
|
|
4
|
-
manipulateItems: (items: any) => any;
|
|
5
|
-
resetView: (data: any) => any;
|
|
6
|
-
changeView: (data: any) => any;
|
|
7
|
-
requestPage: (page: number, token: string) => any;
|
|
8
|
-
};
|
|
9
|
-
export type LoadPaginatorPropTypes = {
|
|
10
|
-
token: string;
|
|
11
|
-
settings: Settings;
|
|
12
|
-
children: JSX.Element;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type ChangeView = (info: {
|
|
16
|
-
token: string;
|
|
17
|
-
view: number;
|
|
18
|
-
}) => any;
|
|
19
|
-
|
|
20
|
-
export type ResetView = (token: string) => any;
|
|
21
|
-
|
|
22
|
-
export type LoadData = (page: number) => any;
|
|
23
|
-
|
|
24
|
-
export type List = {
|
|
25
|
-
token: string;
|
|
26
|
-
settings: Settings;
|
|
27
|
-
paginator: any;
|
|
28
|
-
changeView: ChangeView;
|
|
29
|
-
resetView: ResetView;
|
|
30
|
-
loadData: LoadData;
|
|
31
|
-
}
|