redux-paginator-immutable 2.7.11 → 17.0.3
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.js +6 -2
- package/lib/LoadDataItem.js +36 -5
- package/lib/LoadPaginator.js +6 -2
- package/lib/LoadingButton.js +7 -3
- package/lib/words.js +15 -0
- package/package.json +17 -19
- package/src/Info.jsx +4 -2
- package/src/LoadDataItem.jsx +31 -4
- package/src/LoadPaginator.jsx +3 -2
- package/src/LoadingButton.jsx +5 -4
- package/src/words.js +12 -0
package/lib/Info.js
CHANGED
|
@@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
+
var _words = require("./words");
|
|
8
|
+
|
|
9
|
+
var _words2 = _interopRequireDefault(_words);
|
|
10
|
+
|
|
7
11
|
var _react = require("react");
|
|
8
12
|
|
|
9
13
|
var _react2 = _interopRequireDefault(_react);
|
|
@@ -28,8 +32,8 @@ var Info = function Info(_ref) {
|
|
|
28
32
|
return _react2.default.createElement(
|
|
29
33
|
"div",
|
|
30
34
|
{ className: "text-muted" },
|
|
31
|
-
"
|
|
32
|
-
shown === total ? "
|
|
35
|
+
_words2.default.Showing + " ",
|
|
36
|
+
shown === total ? _words2.default.All + " - " : shown + " " + _words2.default.Of,
|
|
33
37
|
" " + getNumberForm(total, one, all)
|
|
34
38
|
);
|
|
35
39
|
};
|
package/lib/LoadDataItem.js
CHANGED
|
@@ -6,18 +6,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
7
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
8
8
|
|
|
9
|
+
// import {
|
|
10
|
+
// useLocation,
|
|
11
|
+
// useNavigate,
|
|
12
|
+
// useParams,
|
|
13
|
+
// } from "react-router-dom";
|
|
14
|
+
|
|
15
|
+
// const withRouter = (Component) => {
|
|
16
|
+
// const ComponentWithRouterProp = (props) => {
|
|
17
|
+
// const location = useLocation();
|
|
18
|
+
// const navigate = useNavigate();
|
|
19
|
+
// const params = useParams();
|
|
20
|
+
|
|
21
|
+
// return (
|
|
22
|
+
// <Component
|
|
23
|
+
// {...props}
|
|
24
|
+
// router={{
|
|
25
|
+
// location,
|
|
26
|
+
// navigate,
|
|
27
|
+
// params,
|
|
28
|
+
// }}
|
|
29
|
+
// />
|
|
30
|
+
// );
|
|
31
|
+
// };
|
|
32
|
+
|
|
33
|
+
// return ComponentWithRouterProp;
|
|
34
|
+
// };
|
|
35
|
+
|
|
9
36
|
var _react = require("react");
|
|
10
37
|
|
|
11
38
|
var React = _interopRequireWildcard(_react);
|
|
12
39
|
|
|
13
|
-
var _reactRouterDom = require("react-router-dom");
|
|
14
|
-
|
|
15
40
|
var _reactRedux = require("react-redux");
|
|
16
41
|
|
|
17
42
|
var _actions = require("./actions");
|
|
18
43
|
|
|
19
44
|
var _Messages = require("x25/Messages");
|
|
20
45
|
|
|
46
|
+
var _words = require("./words");
|
|
47
|
+
|
|
48
|
+
var _words2 = _interopRequireDefault(_words);
|
|
49
|
+
|
|
50
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
51
|
+
|
|
21
52
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
22
53
|
|
|
23
54
|
var mapStateToProps = function mapStateToProps(state, _ref) {
|
|
@@ -59,12 +90,12 @@ var LoadDataItem = function LoadDataItem(props) {
|
|
|
59
90
|
}, [shouldFetch, isFetching, hasError]);
|
|
60
91
|
|
|
61
92
|
if (isFetching) {
|
|
62
|
-
return React.createElement(_Messages.LoadingMessage, { message:
|
|
93
|
+
return React.createElement(_Messages.LoadingMessage, { message: _words2.default.LoadingData });
|
|
63
94
|
}
|
|
64
95
|
|
|
65
96
|
if (hasError) {
|
|
66
97
|
return React.createElement(_Messages.LargeErrorMessage, {
|
|
67
|
-
message:
|
|
98
|
+
message: _words2.default.ThereWasAProblem,
|
|
68
99
|
onRetry: fetchItem
|
|
69
100
|
});
|
|
70
101
|
}
|
|
@@ -76,4 +107,4 @@ var LoadDataItem = function LoadDataItem(props) {
|
|
|
76
107
|
return children;
|
|
77
108
|
};
|
|
78
109
|
|
|
79
|
-
exports.default = (0,
|
|
110
|
+
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(LoadDataItem);
|
package/lib/LoadPaginator.js
CHANGED
|
@@ -31,6 +31,10 @@ var _LoadingButton2 = _interopRequireDefault(_LoadingButton);
|
|
|
31
31
|
|
|
32
32
|
var _Messages = require("x25/Messages");
|
|
33
33
|
|
|
34
|
+
var _words = require("./words");
|
|
35
|
+
|
|
36
|
+
var _words2 = _interopRequireDefault(_words);
|
|
37
|
+
|
|
34
38
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
35
39
|
|
|
36
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -183,12 +187,12 @@ var LoadPaginator = function (_Component) {
|
|
|
183
187
|
showLoading = total !== items.size;
|
|
184
188
|
|
|
185
189
|
if (isEmpty && isFetching) {
|
|
186
|
-
return _react2.default.createElement(_Messages.LoadingMessage, { message:
|
|
190
|
+
return _react2.default.createElement(_Messages.LoadingMessage, { message: _words2.default.LoadingData });
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
if (hasProblems && currentPage === 1) {
|
|
190
194
|
return _react2.default.createElement(_Messages.LargeErrorMessage, {
|
|
191
|
-
message:
|
|
195
|
+
message: _words2.default.ThereWasAProblem,
|
|
192
196
|
onRetry: this.handleLoadMoreClick
|
|
193
197
|
});
|
|
194
198
|
}
|
package/lib/LoadingButton.js
CHANGED
|
@@ -12,6 +12,10 @@ var _react2 = _interopRequireDefault(_react);
|
|
|
12
12
|
|
|
13
13
|
var _Messages = require("x25/Messages");
|
|
14
14
|
|
|
15
|
+
var _words = require("./words");
|
|
16
|
+
|
|
17
|
+
var _words2 = _interopRequireDefault(_words);
|
|
18
|
+
|
|
15
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
20
|
|
|
17
21
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -51,15 +55,15 @@ var LoadingButton = function (_React$Component) {
|
|
|
51
55
|
return _react2.default.createElement(
|
|
52
56
|
"div",
|
|
53
57
|
{ className: "text-center my-2" },
|
|
54
|
-
hasProblems ? _react2.default.createElement(_Messages.ErrorMessage, { message:
|
|
55
|
-
isFetching ? _react2.default.createElement(_Messages.LoadingMessage, { message:
|
|
58
|
+
hasProblems ? _react2.default.createElement(_Messages.ErrorMessage, { message: _words2.default.ThereWasAProblem }) : null,
|
|
59
|
+
isFetching ? _react2.default.createElement(_Messages.LoadingMessage, { message: _words2.default.LoadingData, sm: true }) : _react2.default.createElement(
|
|
56
60
|
"button",
|
|
57
61
|
{
|
|
58
62
|
className: "btn btn-outline-info d-print-none",
|
|
59
63
|
disabled: isFetching,
|
|
60
64
|
onClick: onLoadMoreClick,
|
|
61
65
|
type: "button" },
|
|
62
|
-
isFetching ?
|
|
66
|
+
isFetching ? _words2.default.Loading : _words2.default.LoadMore
|
|
63
67
|
)
|
|
64
68
|
);
|
|
65
69
|
}
|
package/lib/words.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var words = {
|
|
7
|
+
ThereWasAProblem: "There was a problem. Try again",
|
|
8
|
+
Showing: "Showing",
|
|
9
|
+
All: "all",
|
|
10
|
+
Of: "of",
|
|
11
|
+
LoadingData: "Loading data...",
|
|
12
|
+
LoadMore: "Load more"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.default = words;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redux-paginator-immutable",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.3",
|
|
4
4
|
"description": "redux-paginator-immutable helps you deal with paginated API by composing your existing reducers",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"babel": {
|
|
@@ -37,9 +37,8 @@
|
|
|
37
37
|
"build": "npm run build:lib",
|
|
38
38
|
"clean": "rimraf dist lib",
|
|
39
39
|
"check": "npm-check -u -i babel-jest -i jest --specials=bin,eslint,babel,webpack",
|
|
40
|
-
"flow": "flow check --color=always",
|
|
41
40
|
"eslint": "eslint --ext .jsx,.js src --fix",
|
|
42
|
-
"
|
|
41
|
+
"load": "npm run test && npm run eslint && npm run clean && npm run build && npm publish",
|
|
43
42
|
"test": "mocha --require babel-core/register --recursive --recursive \"src/**/__tests__/*\" --require src/__tests__/setup.js",
|
|
44
43
|
"test:watch": "npm test -- --watch",
|
|
45
44
|
"test:cov": "babel-node ./node_modules/isparta/bin/isparta cover ./node_modules/mocha/bin/_mocha -- --recursive \"src/**/__tests__/*\" --require src/__tests__/setup.js",
|
|
@@ -72,39 +71,38 @@
|
|
|
72
71
|
"homepage": "https://github.com/cristian-sima/redux-paginator-immutable#readme",
|
|
73
72
|
"devDependencies": {
|
|
74
73
|
"babel-cli": "^6.26.0",
|
|
75
|
-
"babel-eslint": "^10.0
|
|
74
|
+
"babel-eslint": "^10.1.0",
|
|
76
75
|
"babel-plugin-transform-decorators-legacy": "^1.3.5",
|
|
77
76
|
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
|
78
77
|
"babel-polyfill": "^6.26.0",
|
|
79
78
|
"babel-preset-env": "^1.7.0",
|
|
80
79
|
"babel-preset-react": "^6.24.1",
|
|
81
80
|
"babel-preset-stage-0": "^6.24.1",
|
|
82
|
-
"chai": "^4.
|
|
81
|
+
"chai": "^4.3.4",
|
|
83
82
|
"chai-immutable": "^2.1.0",
|
|
84
|
-
"codecov": "^3.
|
|
83
|
+
"codecov": "^3.8.1",
|
|
85
84
|
"cross-env": "^6.0.3",
|
|
86
85
|
"es3ify": "^0.2.2",
|
|
87
86
|
"eslint": "^6.7.0",
|
|
88
|
-
"eslint-plugin-react": "^7.
|
|
87
|
+
"eslint-plugin-react": "^7.23.1",
|
|
89
88
|
"expect": "^24.9.0",
|
|
90
|
-
"flow-bin": "^0.
|
|
89
|
+
"flow-bin": "^0.148.0",
|
|
91
90
|
"flux-standard-action": "^2.1.1",
|
|
92
91
|
"glob": "^7.1.6",
|
|
93
92
|
"isparta": "^4.1.1",
|
|
94
93
|
"mocha": "^6.2.2",
|
|
95
|
-
"npm-check": "^5.9.
|
|
96
|
-
"rimraf": "^3.0.
|
|
94
|
+
"npm-check": "^5.9.2",
|
|
95
|
+
"rimraf": "^3.0.2",
|
|
97
96
|
"webpack": "^4.41.2"
|
|
98
97
|
},
|
|
99
|
-
"peerDependencies": {},
|
|
100
98
|
"dependencies": {
|
|
101
|
-
"depcheck": "^
|
|
102
|
-
"immutable": "
|
|
103
|
-
"query-string": "^
|
|
104
|
-
"react": "^
|
|
105
|
-
"redux": "^4.
|
|
106
|
-
"reselect": "^4.
|
|
107
|
-
"superagent": "^
|
|
108
|
-
"x25": "^
|
|
99
|
+
"depcheck": "^1.4.3",
|
|
100
|
+
"immutable": "*",
|
|
101
|
+
"query-string": "^7.1.0",
|
|
102
|
+
"react": "^17.0.2",
|
|
103
|
+
"redux": "^4.1.2",
|
|
104
|
+
"reselect": "^4.1.5",
|
|
105
|
+
"superagent": "^7.1.1",
|
|
106
|
+
"x25": "^17.0.5"
|
|
109
107
|
}
|
|
110
108
|
}
|
package/src/Info.jsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
+
import words from "./words";
|
|
4
|
+
|
|
3
5
|
type InfoPropTypes = {
|
|
4
6
|
shown: number;
|
|
5
7
|
total: number;
|
|
@@ -20,9 +22,9 @@ const getNumberForm = (value : number, one : string, all : string) : string => {
|
|
|
20
22
|
|
|
21
23
|
const Info = ({ shown, total, one, all } : InfoPropTypes) => (
|
|
22
24
|
<div className="text-muted">
|
|
23
|
-
{
|
|
25
|
+
{`${words.Showing} `}
|
|
24
26
|
{
|
|
25
|
-
(shown === total) ?
|
|
27
|
+
(shown === total) ? `${words.All} - ` : `${shown} ${words.Of}`
|
|
26
28
|
}
|
|
27
29
|
{` ${getNumberForm(total, one, all)}`}
|
|
28
30
|
</div>
|
package/src/LoadDataItem.jsx
CHANGED
|
@@ -25,12 +25,39 @@ type OwnProps = {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
import { withRouter } from "react-router-dom";
|
|
29
28
|
import { connect } from "react-redux";
|
|
30
29
|
|
|
30
|
+
// import {
|
|
31
|
+
// useLocation,
|
|
32
|
+
// useNavigate,
|
|
33
|
+
// useParams,
|
|
34
|
+
// } from "react-router-dom";
|
|
35
|
+
|
|
36
|
+
// const withRouter = (Component) => {
|
|
37
|
+
// const ComponentWithRouterProp = (props) => {
|
|
38
|
+
// const location = useLocation();
|
|
39
|
+
// const navigate = useNavigate();
|
|
40
|
+
// const params = useParams();
|
|
41
|
+
|
|
42
|
+
// return (
|
|
43
|
+
// <Component
|
|
44
|
+
// {...props}
|
|
45
|
+
// router={{
|
|
46
|
+
// location,
|
|
47
|
+
// navigate,
|
|
48
|
+
// params,
|
|
49
|
+
// }}
|
|
50
|
+
// />
|
|
51
|
+
// );
|
|
52
|
+
// };
|
|
53
|
+
|
|
54
|
+
// return ComponentWithRouterProp;
|
|
55
|
+
// };
|
|
56
|
+
|
|
31
57
|
import { fetchItem as fetchItemAction } from "./actions";
|
|
32
58
|
|
|
33
59
|
import { LargeErrorMessage, LoadingMessage } from "x25/Messages";
|
|
60
|
+
import words from "./words";
|
|
34
61
|
|
|
35
62
|
const
|
|
36
63
|
mapStateToProps = (state : any, { settings : { selectors }, id } : OwnProps) => ({
|
|
@@ -64,14 +91,14 @@ const LoadDataItem = (props : LoadDataItemPropTypes) => {
|
|
|
64
91
|
|
|
65
92
|
if (isFetching) {
|
|
66
93
|
return (
|
|
67
|
-
<LoadingMessage message=
|
|
94
|
+
<LoadingMessage message={words.LoadingData} />
|
|
68
95
|
);
|
|
69
96
|
}
|
|
70
97
|
|
|
71
98
|
if (hasError) {
|
|
72
99
|
return (
|
|
73
100
|
<LargeErrorMessage
|
|
74
|
-
message=
|
|
101
|
+
message={words.ThereWasAProblem}
|
|
75
102
|
onRetry={fetchItem}
|
|
76
103
|
/>
|
|
77
104
|
);
|
|
@@ -86,4 +113,4 @@ const LoadDataItem = (props : LoadDataItemPropTypes) => {
|
|
|
86
113
|
);
|
|
87
114
|
};
|
|
88
115
|
|
|
89
|
-
export default
|
|
116
|
+
export default connect(mapStateToProps, mapDispatchToProps)(LoadDataItem);
|
package/src/LoadPaginator.jsx
CHANGED
|
@@ -47,6 +47,7 @@ import selectors from "./selectors";
|
|
|
47
47
|
import LoadingButton from "./LoadingButton";
|
|
48
48
|
|
|
49
49
|
import { LargeErrorMessage, LoadingMessage } from "x25/Messages";
|
|
50
|
+
import words from "./words";
|
|
50
51
|
|
|
51
52
|
const mapStateToProps = (state, { token, settings } : OwnProps) => {
|
|
52
53
|
|
|
@@ -175,14 +176,14 @@ class LoadPaginator extends Component<LoadPaginatorPropTypes> {
|
|
|
175
176
|
|
|
176
177
|
if (isEmpty && isFetching) {
|
|
177
178
|
return (
|
|
178
|
-
<LoadingMessage message=
|
|
179
|
+
<LoadingMessage message={words.LoadingData} />
|
|
179
180
|
);
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
if (hasProblems && currentPage === 1) {
|
|
183
184
|
return (
|
|
184
185
|
<LargeErrorMessage
|
|
185
|
-
message=
|
|
186
|
+
message={words.ThereWasAProblem}
|
|
186
187
|
onRetry={this.handleLoadMoreClick}
|
|
187
188
|
/>
|
|
188
189
|
);
|
package/src/LoadingButton.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
3
|
import React from "react";
|
|
4
|
+
import { ErrorMessage, LoadingMessage } from "x25/Messages";
|
|
4
5
|
|
|
5
6
|
type LoadingButtonPropTypes = {
|
|
6
7
|
isFetching: bool;
|
|
@@ -9,7 +10,7 @@ type LoadingButtonPropTypes = {
|
|
|
9
10
|
onLoadMoreClick: () => void;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
import
|
|
13
|
+
import words from "./words";
|
|
13
14
|
|
|
14
15
|
class LoadingButton extends React.Component<LoadingButtonPropTypes> {
|
|
15
16
|
props: LoadingButtonPropTypes;
|
|
@@ -30,19 +31,19 @@ class LoadingButton extends React.Component<LoadingButtonPropTypes> {
|
|
|
30
31
|
<div className="text-center my-2">
|
|
31
32
|
{
|
|
32
33
|
hasProblems ? (
|
|
33
|
-
<ErrorMessage message=
|
|
34
|
+
<ErrorMessage message={words.ThereWasAProblem} />
|
|
34
35
|
) : null
|
|
35
36
|
}
|
|
36
37
|
{
|
|
37
38
|
isFetching ? (
|
|
38
|
-
<LoadingMessage message=
|
|
39
|
+
<LoadingMessage message={words.LoadingData} sm />
|
|
39
40
|
) : (
|
|
40
41
|
<button
|
|
41
42
|
className="btn btn-outline-info d-print-none"
|
|
42
43
|
disabled={isFetching}
|
|
43
44
|
onClick={onLoadMoreClick}
|
|
44
45
|
type="button">
|
|
45
|
-
{isFetching ?
|
|
46
|
+
{isFetching ? words.Loading : words.LoadMore}
|
|
46
47
|
</button>
|
|
47
48
|
)
|
|
48
49
|
}
|