redux-paginator-immutable 2.7.8 → 17.0.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/LoadDataItem.js +26 -75
- package/lib/LoadPaginator.js +1 -1
- package/lib/createDataReducer.js +2 -2
- package/package.json +25 -53
- package/src/LoadDataItem.jsx +23 -47
- package/src/LoadPaginator.jsx +1 -1
- package/src/createDataReducer.js +3 -2
- package/src/reducerItemData.jsx +3 -1
package/lib/LoadDataItem.js
CHANGED
|
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8
|
-
|
|
9
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; };
|
|
10
8
|
|
|
11
9
|
var _react = require("react");
|
|
@@ -22,12 +20,6 @@ var _Messages = require("x25/Messages");
|
|
|
22
20
|
|
|
23
21
|
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; } }
|
|
24
22
|
|
|
25
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
26
|
-
|
|
27
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
28
|
-
|
|
29
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
30
|
-
|
|
31
23
|
var mapStateToProps = function mapStateToProps(state, _ref) {
|
|
32
24
|
var selectors = _ref.settings.selectors,
|
|
33
25
|
id = _ref.id;
|
|
@@ -51,78 +43,37 @@ var mapStateToProps = function mapStateToProps(state, _ref) {
|
|
|
51
43
|
};
|
|
52
44
|
};
|
|
53
45
|
|
|
54
|
-
var LoadDataItem = function (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
_createClass(LoadDataItem, [{
|
|
64
|
-
key: "UNSAFE_componentWillMount",
|
|
65
|
-
value: function UNSAFE_componentWillMount() {
|
|
66
|
-
var _props = this.props,
|
|
67
|
-
shouldFetch = _props.shouldFetch,
|
|
68
|
-
fetchItem = _props.fetchItem;
|
|
46
|
+
var LoadDataItem = function LoadDataItem(props) {
|
|
47
|
+
var children = props.children,
|
|
48
|
+
data = props.data,
|
|
49
|
+
isFetching = props.isFetching,
|
|
50
|
+
shouldFetch = props.shouldFetch,
|
|
51
|
+
hasError = props.hasError,
|
|
52
|
+
fetchItem = props.fetchItem;
|
|
69
53
|
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
55
|
+
React.useEffect(function () {
|
|
56
|
+
if (shouldFetch) {
|
|
57
|
+
fetchItem();
|
|
74
58
|
}
|
|
75
|
-
},
|
|
76
|
-
key: "shouldComponentUpdate",
|
|
77
|
-
value: function shouldComponentUpdate(nextProps) {
|
|
78
|
-
return this.props.data !== nextProps.data || this.props.hasError !== nextProps.hasError || this.props.fetched !== nextProps.fetched || this.props.isFetching !== nextProps.isFetching || this.props.shouldFetch !== nextProps.shouldFetch || this.props.id !== nextProps.id;
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
82
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
83
|
-
var shouldFetch = nextProps.shouldFetch,
|
|
84
|
-
fetchItem = nextProps.fetchItem;
|
|
59
|
+
}, [shouldFetch, isFetching, hasError]);
|
|
85
60
|
|
|
61
|
+
if (isFetching) {
|
|
62
|
+
return React.createElement(_Messages.LoadingMessage, { message: "Preiau datele..." });
|
|
63
|
+
}
|
|
86
64
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
isFetching = _props2.isFetching,
|
|
98
|
-
hasError = _props2.hasError,
|
|
99
|
-
fetchItem = _props2.fetchItem;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (isFetching) {
|
|
103
|
-
return React.createElement(_Messages.LoadingMessage, { message: "Preiau datele..." });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (hasError) {
|
|
107
|
-
return React.createElement(_Messages.LargeErrorMessage, {
|
|
108
|
-
message: "Ceva nu a mers bine",
|
|
109
|
-
onRetry: fetchItem
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (data.size === 0) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return React.createElement(
|
|
118
|
-
React.Fragment,
|
|
119
|
-
null,
|
|
120
|
-
children
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
}]);
|
|
65
|
+
if (hasError) {
|
|
66
|
+
return React.createElement(_Messages.LargeErrorMessage, {
|
|
67
|
+
message: "Nu am putut stabili conexiunea cu server-ul",
|
|
68
|
+
onRetry: fetchItem
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (data.size === 0) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
124
75
|
|
|
125
|
-
return
|
|
126
|
-
}
|
|
76
|
+
return children;
|
|
77
|
+
};
|
|
127
78
|
|
|
128
79
|
exports.default = (0, _reactRouterDom.withRouter)((0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(LoadDataItem));
|
package/lib/LoadPaginator.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8
8
|
|
|
9
9
|
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; };
|
|
10
|
-
|
|
10
|
+
/* eslint-disable */
|
|
11
11
|
|
|
12
12
|
var _react = require("react");
|
|
13
13
|
|
package/lib/createDataReducer.js
CHANGED
|
@@ -63,8 +63,8 @@ var createDataReducer = function createDataReducer(_ref) {
|
|
|
63
63
|
|
|
64
64
|
return data.get("fetched");
|
|
65
65
|
}),
|
|
66
|
-
getShouldFetchItemInfo = (0, _reselect.createSelector)(getIsFetchingItemInfo, getItemIsFetched, function (isFetching, isFetched) {
|
|
67
|
-
return !isFetched && !isFetching;
|
|
66
|
+
getShouldFetchItemInfo = (0, _reselect.createSelector)(getIsFetchingItemInfo, getItemIsFetched, getItemHasError, function (isFetching, isFetched, hasError) {
|
|
67
|
+
return !isFetched && !isFetching && !hasError;
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redux-paginator-immutable",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0",
|
|
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
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"prepublish": "npm run test && npm run eslint && npm run flow && npm run clean && npm run build",
|
|
40
|
+
"eslint": "eslint --ext .jsx,.js src --fix",
|
|
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,65 +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
|
|
76
|
-
"babel-loader": "^8.0.6",
|
|
77
|
-
"babel-plugin-check-es2015-constants": "^6.22.0",
|
|
78
|
-
"babel-plugin-flow-react-proptypes": "^25.1.0",
|
|
79
|
-
"babel-plugin-syntax-flow": "^6.18.0",
|
|
80
|
-
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
74
|
+
"babel-eslint": "^10.1.0",
|
|
81
75
|
"babel-plugin-transform-decorators-legacy": "^1.3.5",
|
|
82
|
-
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
|
|
83
|
-
"babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0",
|
|
84
|
-
"babel-plugin-transform-es2015-block-scoping": "^6.26.0",
|
|
85
|
-
"babel-plugin-transform-es2015-classes": "^6.24.1",
|
|
86
|
-
"babel-plugin-transform-es2015-computed-properties": "^6.24.1",
|
|
87
|
-
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
|
|
88
|
-
"babel-plugin-transform-es2015-for-of": "^6.23.0",
|
|
89
|
-
"babel-plugin-transform-es2015-function-name": "^6.24.1",
|
|
90
|
-
"babel-plugin-transform-es2015-literals": "^6.22.0",
|
|
91
|
-
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
|
92
|
-
"babel-plugin-transform-es2015-object-super": "^6.24.1",
|
|
93
|
-
"babel-plugin-transform-es2015-parameters": "^6.24.1",
|
|
94
|
-
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
|
|
95
|
-
"babel-plugin-transform-es2015-spread": "^6.22.0",
|
|
96
|
-
"babel-plugin-transform-es2015-sticky-regex": "^6.24.1",
|
|
97
76
|
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
|
98
|
-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
|
99
|
-
"babel-plugin-transform-react-display-name": "^6.25.0",
|
|
100
|
-
"babel-plugin-transform-react-jsx": "^6.24.1",
|
|
101
|
-
"babel-plugin-transform-regenerator": "^6.26.0",
|
|
102
77
|
"babel-polyfill": "^6.26.0",
|
|
103
78
|
"babel-preset-env": "^1.7.0",
|
|
104
|
-
"babel-preset-flow": "^6.23.0",
|
|
105
79
|
"babel-preset-react": "^6.24.1",
|
|
106
80
|
"babel-preset-stage-0": "^6.24.1",
|
|
107
|
-
"
|
|
108
|
-
"chai": "^4.2.0",
|
|
81
|
+
"chai": "^4.3.4",
|
|
109
82
|
"chai-immutable": "^2.1.0",
|
|
110
|
-
"codecov": "^3.
|
|
111
|
-
"cross-env": "^
|
|
83
|
+
"codecov": "^3.8.1",
|
|
84
|
+
"cross-env": "^6.0.3",
|
|
112
85
|
"es3ify": "^0.2.2",
|
|
113
|
-
"eslint": "^6.
|
|
114
|
-
"eslint-plugin-react": "^7.
|
|
115
|
-
"expect": "^24.
|
|
116
|
-
"flow-bin": "^0.
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"glob": "^7.1.4",
|
|
86
|
+
"eslint": "^6.7.0",
|
|
87
|
+
"eslint-plugin-react": "^7.23.1",
|
|
88
|
+
"expect": "^24.9.0",
|
|
89
|
+
"flow-bin": "^0.148.0",
|
|
90
|
+
"flux-standard-action": "^2.1.1",
|
|
91
|
+
"glob": "^7.1.6",
|
|
120
92
|
"isparta": "^4.1.1",
|
|
121
|
-
"mocha": "^6.2.
|
|
122
|
-
"npm-check": "^5.9.
|
|
123
|
-
"rimraf": "^
|
|
124
|
-
"webpack": "^4.
|
|
93
|
+
"mocha": "^6.2.2",
|
|
94
|
+
"npm-check": "^5.9.2",
|
|
95
|
+
"rimraf": "^3.0.2",
|
|
96
|
+
"webpack": "^4.41.2"
|
|
125
97
|
},
|
|
126
|
-
"peerDependencies": {},
|
|
127
98
|
"dependencies": {
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
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.0"
|
|
135
107
|
}
|
|
136
108
|
}
|
package/src/LoadDataItem.jsx
CHANGED
|
@@ -49,65 +49,41 @@ const
|
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
props
|
|
54
|
-
|
|
55
|
-
UNSAFE_componentWillMount () {
|
|
56
|
-
const { shouldFetch, fetchItem } = this.props;
|
|
52
|
+
const LoadDataItem = (props : LoadDataItemPropTypes) => {
|
|
53
|
+
const { children, data, isFetching, shouldFetch, hasError, fetchItem } = props;
|
|
57
54
|
|
|
55
|
+
React.useEffect(() => {
|
|
58
56
|
if (shouldFetch) {
|
|
59
57
|
fetchItem();
|
|
60
58
|
}
|
|
61
|
-
}
|
|
59
|
+
}, [
|
|
60
|
+
shouldFetch,
|
|
61
|
+
isFetching,
|
|
62
|
+
hasError,
|
|
63
|
+
]);
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
if (isFetching) {
|
|
64
66
|
return (
|
|
65
|
-
|
|
66
|
-
this.props.hasError !== nextProps.hasError ||
|
|
67
|
-
this.props.fetched !== nextProps.fetched ||
|
|
68
|
-
this.props.isFetching !== nextProps.isFetching ||
|
|
69
|
-
this.props.shouldFetch !== nextProps.shouldFetch ||
|
|
70
|
-
this.props.id !== nextProps.id
|
|
67
|
+
<LoadingMessage message="Preiau datele..." />
|
|
71
68
|
);
|
|
72
69
|
}
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
const { shouldFetch, fetchItem } = nextProps;
|
|
76
|
-
|
|
77
|
-
if (shouldFetch) {
|
|
78
|
-
fetchItem();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
render () {
|
|
83
|
-
const { children, data, isFetching, hasError, fetchItem } = this.props;
|
|
84
|
-
|
|
85
|
-
if (isFetching) {
|
|
86
|
-
return (
|
|
87
|
-
<LoadingMessage message="Preiau datele..." />
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (hasError) {
|
|
92
|
-
return (
|
|
93
|
-
<LargeErrorMessage
|
|
94
|
-
message="Ceva nu a mers bine"
|
|
95
|
-
onRetry={fetchItem}
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (data.size === 0) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
|
|
71
|
+
if (hasError) {
|
|
104
72
|
return (
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
73
|
+
<LargeErrorMessage
|
|
74
|
+
message="Nu am putut stabili conexiunea cu server-ul"
|
|
75
|
+
onRetry={fetchItem}
|
|
76
|
+
/>
|
|
108
77
|
);
|
|
109
78
|
}
|
|
110
|
-
}
|
|
111
79
|
|
|
80
|
+
if (data.size === 0) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
children
|
|
86
|
+
);
|
|
87
|
+
};
|
|
112
88
|
|
|
113
89
|
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(LoadDataItem));
|
package/src/LoadPaginator.jsx
CHANGED
package/src/createDataReducer.js
CHANGED
|
@@ -73,8 +73,9 @@ const createDataReducer = ({ key } : PaginatorSettings) => {
|
|
|
73
73
|
getShouldFetchItemInfo = createSelector(
|
|
74
74
|
getIsFetchingItemInfo,
|
|
75
75
|
getItemIsFetched,
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
getItemHasError,
|
|
77
|
+
(isFetching, isFetched, hasError) => (
|
|
78
|
+
!isFetched && !isFetching && !hasError
|
|
78
79
|
)
|
|
79
80
|
);
|
|
80
81
|
|
package/src/reducerItemData.jsx
CHANGED
|
@@ -40,7 +40,9 @@ const
|
|
|
40
40
|
}));
|
|
41
41
|
})
|
|
42
42
|
),
|
|
43
|
-
fetchItemDataFulFilled = (state : any,
|
|
43
|
+
fetchItemDataFulFilled = (state : any,
|
|
44
|
+
{ payload : { Data }, meta : { id } } : FetchItemDataFulFilledProps
|
|
45
|
+
) => (
|
|
44
46
|
state.update((id), (current) => {
|
|
45
47
|
if (typeof current === "undefined") {
|
|
46
48
|
return current;
|