redux-paginator-immutable 17.0.16 → 17.0.21
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 +9 -0
- package/lib/Info.js +19 -41
- package/lib/Info.js.map +1 -0
- package/lib/LoadDataItem.d.ts +23 -0
- package/lib/LoadDataItem.js +59 -110
- package/lib/LoadDataItem.js.map +1 -0
- package/lib/LoadPaginator.d.ts +41 -0
- package/lib/LoadPaginator.js +109 -216
- package/lib/LoadPaginator.js.map +1 -0
- package/lib/LoadingButton.d.ts +11 -0
- package/lib/LoadingButton.js +22 -75
- package/lib/LoadingButton.js.map +1 -0
- package/lib/actionTypes.d.ts +9 -0
- package/lib/actionTypes.js +13 -16
- package/lib/actionTypes.js.map +1 -0
- package/lib/actions.d.ts +42 -0
- package/lib/actions.js +82 -136
- package/lib/actions.js.map +1 -0
- package/lib/agent.d.ts +8 -0
- package/lib/agent.js +37 -86
- package/lib/agent.js.map +1 -0
- package/lib/createDataReducer.d.ts +14 -0
- package/lib/createDataReducer.js +60 -79
- package/lib/createDataReducer.js.map +1 -0
- package/lib/createItemReducer.d.ts +9 -0
- package/lib/createItemReducer.js +14 -32
- package/lib/createItemReducer.js.map +1 -0
- package/lib/createPaginator.d.ts +14 -0
- package/lib/createPaginator.js +83 -140
- package/lib/createPaginator.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +30 -58
- package/lib/index.js.map +1 -0
- package/lib/paginatorMiddleware.d.ts +5 -0
- package/lib/paginatorMiddleware.js +68 -102
- package/lib/paginatorMiddleware.js.map +1 -0
- package/lib/reducerItemData.d.ts +18 -0
- package/lib/reducerItemData.js +56 -63
- package/lib/reducerItemData.js.map +1 -0
- package/lib/reducerOperations.d.ts +3 -0
- package/lib/reducerOperations.js +69 -114
- package/lib/reducerOperations.js.map +1 -0
- package/lib/reducers.d.ts +4 -0
- package/lib/reducers.js +75 -87
- package/lib/reducers.js.map +1 -0
- package/lib/selectors.d.ts +58 -0
- package/lib/selectors.js +79 -129
- package/lib/selectors.js.map +1 -0
- package/lib/types/actions.d.ts +85 -0
- package/lib/types/actions.js +3 -1
- package/lib/types/actions.js.map +1 -0
- package/lib/types/index.d.ts +21 -0
- package/lib/types/index.js +16 -29
- package/lib/types/index.js.map +1 -0
- package/lib/types/state.d.ts +6 -0
- package/lib/types/state.js +3 -1
- package/lib/types/state.js.map +1 -0
- package/lib/util.d.ts +9 -0
- package/lib/util.js +49 -73
- package/lib/util.js.map +1 -0
- package/lib/words.d.ts +9 -0
- package/lib/words.js +12 -15
- package/lib/words.js.map +1 -0
- package/package.json +35 -21
- package/src/Info.tsx +29 -0
- package/src/LoadDataItem.tsx +84 -0
- package/src/{LoadPaginator.jsx → LoadPaginator.tsx} +77 -94
- package/src/LoadingButton.tsx +40 -0
- package/src/__tests__/createPaginator.spec.js +6 -6
- package/src/__tests__/reducers.spec.js +28 -28
- package/src/__tests__/selectors.spec.js +80 -81
- package/src/{actionTypes.js → actionTypes.ts} +0 -4
- package/src/actions.ts +157 -0
- package/src/agent.ts +62 -0
- package/src/createDataReducer.ts +91 -0
- package/src/{createItemReducer.js → createItemReducer.ts} +7 -13
- package/src/createPaginator.ts +107 -0
- package/src/{index.js → index.ts} +0 -13
- package/src/paginatorMiddleware.ts +93 -0
- package/src/reducerItemData.ts +74 -0
- package/src/reducerOperations.ts +101 -0
- package/src/{reducers.js → reducers.ts} +9 -18
- package/src/selectors.ts +113 -0
- package/src/types/{actions.js → actions.ts} +27 -39
- package/src/types/{index.js → index.ts} +6 -13
- package/src/types/{state.js → state.ts} +3 -6
- package/src/util.ts +51 -0
- package/src/{words.js → words.ts} +0 -2
- package/lib/__tests__/actions.spec.js +0 -117
- package/lib/__tests__/agent.spec.js +0 -32
- package/lib/__tests__/createPaginator.spec.js +0 -39
- package/lib/__tests__/reducers.spec.js +0 -126
- package/lib/__tests__/selectors.spec.js +0 -162
- package/lib/__tests__/setup.js +0 -3
- package/src/Info.jsx +0 -34
- package/src/LoadDataItem.jsx +0 -116
- package/src/LoadingButton.jsx +0 -55
- package/src/actions.js +0 -153
- package/src/agent.js +0 -55
- package/src/createDataReducer.js +0 -94
- package/src/createPaginator.js +0 -131
- package/src/paginatorMiddleware.js +0 -94
- package/src/reducerItemData.jsx +0 -64
- package/src/reducerOperations.jsx +0 -112
- package/src/selectors.js +0 -143
- package/src/util.js +0 -71
package/lib/reducers.js
CHANGED
|
@@ -1,87 +1,75 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
case _actionTypes.FETCH_ITEM_DATA_REJECTED:
|
|
77
|
-
return reducerItemData.fetchItemDataRejected(state, action);
|
|
78
|
-
case _actionTypes.FETCH_ITEM_DATA_FULFILLED:
|
|
79
|
-
return reducerItemData.fetchItemDataFulFilled(state, action);
|
|
80
|
-
|
|
81
|
-
case _actionTypes.FETCH_CURRENT_COMPANY_INFO_PENDING:
|
|
82
|
-
case _actionTypes.CLEAR_DATA:
|
|
83
|
-
return state.clear();
|
|
84
|
-
default:
|
|
85
|
-
return state;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.dataItems = exports.items = exports.pages = void 0;
|
|
23
|
+
const Immutable = __importStar(require("immutable"));
|
|
24
|
+
const actionTypes_1 = require("./actionTypes");
|
|
25
|
+
const reducerItemData = __importStar(require("./reducerItemData"));
|
|
26
|
+
const reducerOperations = __importStar(require("./reducerOperations"));
|
|
27
|
+
const pages = (state = Immutable.Map(), action) => {
|
|
28
|
+
switch (action.type) {
|
|
29
|
+
case actionTypes_1.REQUEST_PAGE:
|
|
30
|
+
return reducerOperations.requestPage(state, action);
|
|
31
|
+
case actionTypes_1.RECEIVE_PAGE:
|
|
32
|
+
return reducerOperations.receivePage(state, action);
|
|
33
|
+
case actionTypes_1.RESET_VIEW:
|
|
34
|
+
return reducerOperations.resetView(state, action);
|
|
35
|
+
case actionTypes_1.CHANGE_VIEW:
|
|
36
|
+
return reducerOperations.changeView(state, action);
|
|
37
|
+
case actionTypes_1.FETCH_CURRENT_COMPANY_INFO_PENDING:
|
|
38
|
+
case actionTypes_1.CLEAR_DATA:
|
|
39
|
+
return state.clear();
|
|
40
|
+
default:
|
|
41
|
+
return state;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.pages = pages;
|
|
45
|
+
const items = (state = Immutable.Map(), action) => {
|
|
46
|
+
switch (action.type) {
|
|
47
|
+
case actionTypes_1.RECEIVE_PAGE:
|
|
48
|
+
return reducerOperations.receivePageItems(state, action);
|
|
49
|
+
case actionTypes_1.FETCH_CURRENT_COMPANY_INFO_PENDING:
|
|
50
|
+
case actionTypes_1.CLEAR_DATA:
|
|
51
|
+
return state.clear();
|
|
52
|
+
default:
|
|
53
|
+
return state;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.items = items;
|
|
57
|
+
const dataItems = (state = Immutable.Map(), action) => {
|
|
58
|
+
switch (action.type) {
|
|
59
|
+
case actionTypes_1.RECEIVE_PAGE:
|
|
60
|
+
return reducerOperations.receivePageItems(state, action);
|
|
61
|
+
case actionTypes_1.FETCH_ITEM_DATA_PENDING:
|
|
62
|
+
return reducerItemData.fetchItemDataPending(state, action);
|
|
63
|
+
case actionTypes_1.FETCH_ITEM_DATA_REJECTED:
|
|
64
|
+
return reducerItemData.fetchItemDataRejected(state, action);
|
|
65
|
+
case actionTypes_1.FETCH_ITEM_DATA_FULFILLED:
|
|
66
|
+
return reducerItemData.fetchItemDataFulFilled(state, action);
|
|
67
|
+
case actionTypes_1.FETCH_CURRENT_COMPANY_INFO_PENDING:
|
|
68
|
+
case actionTypes_1.CLEAR_DATA:
|
|
69
|
+
return state.clear();
|
|
70
|
+
default:
|
|
71
|
+
return state;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.dataItems = dataItems;
|
|
75
|
+
//# sourceMappingURL=reducers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducers.js","sourceRoot":"","sources":["../src/reducers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,+CAUuB;AAEvB,mEAAqD;AACrD,uEAAyD;AAElD,MAAM,KAAK,GAAG,CAAC,QAAoB,SAAS,CAAC,GAAG,EAAE,EAAE,MAAc,EAAE,EAAE;IAC3E,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,0BAAY;YACf,OAAO,iBAAiB,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAEtD,KAAK,0BAAY;YACf,OAAO,iBAAiB,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAEtD,KAAK,wBAAU;YACb,OAAO,iBAAiB,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAEpD,KAAK,yBAAW;YACd,OAAO,iBAAiB,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAErD,KAAK,gDAAkC,CAAC;QACxC,KAAK,wBAAU;YACb,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC;QAEvB;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC,CAAC;AArBW,QAAA,KAAK,SAqBhB;AACK,MAAM,KAAK,GAAG,CAAC,QAAoB,SAAS,CAAC,GAAG,EAAE,EAAE,MAAc,EAAE,EAAE;IAC3E,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,0BAAY;YACf,OAAO,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAE3D,KAAK,gDAAkC,CAAC;QACxC,KAAK,wBAAU;YACb,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC;QAEvB;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC,CAAC;AAZW,QAAA,KAAK,SAYhB;AACK,MAAM,SAAS,GAAG,CAAC,QAAoB,SAAS,CAAC,GAAG,EAAE,EAAE,MAAc,EAAE,EAAE;IAC/E,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,0BAAY;YACf,OAAO,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAE3D,KAAK,qCAAuB;YAC1B,OAAO,eAAe,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAE7D,KAAK,sCAAwB;YAC3B,OAAO,eAAe,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAE9D,KAAK,uCAAyB;YAC5B,OAAO,eAAe,CAAC,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAE/D,KAAK,gDAAkC,CAAC;QACxC,KAAK,wBAAU;YACb,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC;QAEvB;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC,CAAC;AArBW,QAAA,SAAS,aAqBpB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
getAllResults: ((state: {
|
|
3
|
+
readonly pages: any;
|
|
4
|
+
readonly itemsReducer: any;
|
|
5
|
+
}, params_0: string, params_1: {}) => any) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any) => any> & {
|
|
6
|
+
clearCache: () => void;
|
|
7
|
+
};
|
|
8
|
+
getCurrentTotalResultsCount: ((state: {
|
|
9
|
+
readonly pages: any;
|
|
10
|
+
readonly itemsReducer: any;
|
|
11
|
+
}, params_0: string) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
|
|
12
|
+
clearCache: () => void;
|
|
13
|
+
};
|
|
14
|
+
getResultsUpToPage: ((state: {
|
|
15
|
+
readonly pages: any;
|
|
16
|
+
readonly itemsReducer: any;
|
|
17
|
+
}, params_0: string, params_1: {}, params_2: {}, params_3: number) => any) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any, args_2: any, args_3: number) => any> & {
|
|
18
|
+
clearCache: () => void;
|
|
19
|
+
};
|
|
20
|
+
isPageFetching: ((state: {
|
|
21
|
+
readonly pages: any;
|
|
22
|
+
readonly itemsReducer: any;
|
|
23
|
+
}, params_0: string, params_1: {}) => any) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any) => any> & {
|
|
24
|
+
clearCache: () => void;
|
|
25
|
+
};
|
|
26
|
+
isPageFetched: ((state: {
|
|
27
|
+
readonly pages: any;
|
|
28
|
+
readonly itemsReducer: any;
|
|
29
|
+
}, params_0: string, params_1: {}) => any) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any) => any> & {
|
|
30
|
+
clearCache: () => void;
|
|
31
|
+
};
|
|
32
|
+
hasPageProblems: ((state: {
|
|
33
|
+
readonly pages: any;
|
|
34
|
+
readonly itemsReducer: any;
|
|
35
|
+
}, params_0: string) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
|
|
36
|
+
clearCache: () => void;
|
|
37
|
+
};
|
|
38
|
+
getCurrentView: ((state: {
|
|
39
|
+
readonly pages: any;
|
|
40
|
+
readonly itemsReducer: any;
|
|
41
|
+
}, params_0: string) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
|
|
42
|
+
clearCache: () => void;
|
|
43
|
+
};
|
|
44
|
+
getPaginatorPaginations: (state: any, name: string) => any;
|
|
45
|
+
getPaginatorEntities: (state: any, name: string) => any;
|
|
46
|
+
getPaginators: ((state: {}, params_0: string) => {
|
|
47
|
+
list: any;
|
|
48
|
+
entities: any;
|
|
49
|
+
}) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any) => {
|
|
50
|
+
list: any;
|
|
51
|
+
entities: any;
|
|
52
|
+
} & {
|
|
53
|
+
clearCache: () => void;
|
|
54
|
+
}> & {
|
|
55
|
+
clearCache: () => void;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export default _default;
|
package/lib/selectors.js
CHANGED
|
@@ -1,129 +1,79 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return page.get("fetched") && target <= page.get("page");
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
var hasPageProblems = (0, _reselect.createSelector)(pageSelector, function (page) {
|
|
87
|
-
if (typeof page === "undefined") {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return page.get("error");
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
var getCurrentView = (0, _reselect.createSelector)(pageSelector, function (page) {
|
|
95
|
-
if (typeof page === "undefined") {
|
|
96
|
-
return 1;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return page.get("view");
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// these selectors are used for the entire app
|
|
103
|
-
var getPaginatorPaginations = function getPaginatorPaginations(state, name) {
|
|
104
|
-
return state.getIn(["paginations", name]);
|
|
105
|
-
},
|
|
106
|
-
getPaginatorEntities = function getPaginatorEntities(state, name) {
|
|
107
|
-
return state.getIn(["entities", name]);
|
|
108
|
-
},
|
|
109
|
-
getPaginators = (0, _reselect.createSelector)(getPaginatorPaginations, getPaginatorEntities, function (list, entities) {
|
|
110
|
-
return {
|
|
111
|
-
list: list,
|
|
112
|
-
entities: entities
|
|
113
|
-
};
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
exports.default = {
|
|
117
|
-
getAllResults: getAllResults,
|
|
118
|
-
getCurrentTotalResultsCount: getCurrentTotalResultsCount,
|
|
119
|
-
getResultsUpToPage: getResultsUpToPage,
|
|
120
|
-
isPageFetching: isPageFetching,
|
|
121
|
-
isPageFetched: isPageFetched,
|
|
122
|
-
hasPageProblems: hasPageProblems,
|
|
123
|
-
getCurrentView: getCurrentView,
|
|
124
|
-
|
|
125
|
-
// for state
|
|
126
|
-
getPaginatorPaginations: getPaginatorPaginations,
|
|
127
|
-
getPaginatorEntities: getPaginatorEntities,
|
|
128
|
-
getPaginators: getPaginators
|
|
129
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const Immutable = __importStar(require("immutable"));
|
|
23
|
+
const reselect_1 = require("reselect");
|
|
24
|
+
const pagesSelector = (state) => state, rowsPerPage = 50, pageSelector = (0, reselect_1.createSelector)(pagesSelector, (_state, token) => token, (pages, token) => pages.get(token)), getAllResults = (0, reselect_1.createSelector)(pageSelector, (_state, _token, items) => items, (page, items) => {
|
|
25
|
+
if (typeof page === "undefined") {
|
|
26
|
+
return Immutable.List();
|
|
27
|
+
}
|
|
28
|
+
return page.get("ids").map((id) => items.get(String(id)));
|
|
29
|
+
}), getResultsUpToPage = (0, reselect_1.createSelector)(pageSelector, (_state, _token, items) => items, (_state, _token, _items, target) => target, (_state, _token, _items, _target, perPage) => (perPage || rowsPerPage), (page, items, target, perPage) => {
|
|
30
|
+
if (typeof page === "undefined") {
|
|
31
|
+
return Immutable.List();
|
|
32
|
+
}
|
|
33
|
+
const ids = page.get("ids").slice(0, perPage * target);
|
|
34
|
+
return ids.map((id) => items.get(String(id)));
|
|
35
|
+
}), getCurrentTotalResultsCount = (0, reselect_1.createSelector)(pageSelector, (page) => {
|
|
36
|
+
if (typeof page === "undefined") {
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
return page.get("total");
|
|
40
|
+
}), isPageFetching = (0, reselect_1.createSelector)(pageSelector, (_state, _token, target) => target, (page, target) => {
|
|
41
|
+
if (typeof page === "undefined") {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return page.get("fetching") && target === page.get("page");
|
|
45
|
+
}), isPageFetched = (0, reselect_1.createSelector)(pageSelector, (_state, _token, target) => target, (page, target) => {
|
|
46
|
+
if (typeof page === "undefined") {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return page.get("fetched") && target <= page.get("page");
|
|
50
|
+
}), hasPageProblems = (0, reselect_1.createSelector)(pageSelector, (page) => {
|
|
51
|
+
if (typeof page === "undefined") {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return page.get("error");
|
|
55
|
+
}), getCurrentView = (0, reselect_1.createSelector)(pageSelector, (page) => {
|
|
56
|
+
if (typeof page === "undefined") {
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
return page.get("view");
|
|
60
|
+
}),
|
|
61
|
+
// these selectors are used for the entire app
|
|
62
|
+
getPaginatorPaginations = (state, name) => state.getIn(["paginations", name]), getPaginatorEntities = (state, name) => state.getIn(["entities", name]), getPaginators = (0, reselect_1.createSelector)(getPaginatorPaginations, getPaginatorEntities, (list, entities) => ({
|
|
63
|
+
list,
|
|
64
|
+
entities,
|
|
65
|
+
}));
|
|
66
|
+
exports.default = {
|
|
67
|
+
getAllResults,
|
|
68
|
+
getCurrentTotalResultsCount,
|
|
69
|
+
getResultsUpToPage,
|
|
70
|
+
isPageFetching,
|
|
71
|
+
isPageFetched,
|
|
72
|
+
hasPageProblems,
|
|
73
|
+
getCurrentView,
|
|
74
|
+
// for state
|
|
75
|
+
getPaginatorPaginations,
|
|
76
|
+
getPaginatorEntities,
|
|
77
|
+
getPaginators,
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,uCAA0C;AAG1C,MACE,aAAa,GAAG,CAAC,KAAY,EAAE,EAAE,CAAC,KAAK,EAEvC,WAAW,GAAG,EAAE,EAChB,YAAY,GAAG,IAAA,yBAAc,EAC3B,aAAa,EACb,CAAC,MAAa,EAAE,KAAa,EAAE,EAAE,CAAC,KAAK,EACvC,CAAC,KAAiB,EAAE,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CACvD,EACD,aAAa,GAAG,IAAA,yBAAc,EAC5B,YAAY,EACZ,CAAC,MAAc,EAAE,MAAe,EAAE,KAAW,EAAE,EAAE,CAAC,KAAK,EACvD,CAAC,IAAU,EAAE,KAAW,EAAE,EAAE;IAC1B,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;QAC/B,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC;KACzB;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAW,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC,CACF,EACD,kBAAkB,GAAG,IAAA,yBAAc,EACjC,YAAY,EACZ,CAAC,MAAc,EAAE,MAAe,EAAE,KAAW,EAAE,EAAE,CAAC,KAAK,EACvD,CAAC,MAAc,EAAE,MAAe,EAAE,MAAW,EAAE,MA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AY;IACZ,uBAAuB;IACvB,oBAAoB;IACpB,aAAa;CACd,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { EndPointCb } from "./index";
|
|
2
|
+
export declare type RequestPageAction = {
|
|
3
|
+
type: "@@redux-paginator-immutable/REQUEST_PAGE";
|
|
4
|
+
meta: {
|
|
5
|
+
endpoint: string;
|
|
6
|
+
endpointCb: EndPointCb;
|
|
7
|
+
manageEntity: any;
|
|
8
|
+
resultsKey: string;
|
|
9
|
+
totalKey: string;
|
|
10
|
+
pageArgName: string;
|
|
11
|
+
idKey: string;
|
|
12
|
+
};
|
|
13
|
+
payload: {
|
|
14
|
+
page: number;
|
|
15
|
+
token: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type ReceivePageAction = {
|
|
19
|
+
type: "@@redux-paginator-immutable/RECEIVE_PAGE";
|
|
20
|
+
meta: {
|
|
21
|
+
endpoint: string;
|
|
22
|
+
endpointCb: EndPointCb;
|
|
23
|
+
manageEntity: any;
|
|
24
|
+
pageArgName: string;
|
|
25
|
+
idKey: string;
|
|
26
|
+
};
|
|
27
|
+
payload: {
|
|
28
|
+
page: number;
|
|
29
|
+
token: string;
|
|
30
|
+
items: Array<any>;
|
|
31
|
+
total: number;
|
|
32
|
+
error: boolean;
|
|
33
|
+
raw?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare type ChangeViewAction = {
|
|
37
|
+
type: "@@redux-paginator-immutable/CHANGE_VIEW";
|
|
38
|
+
meta: {
|
|
39
|
+
endpoint: string;
|
|
40
|
+
};
|
|
41
|
+
payload: {
|
|
42
|
+
view: number;
|
|
43
|
+
token: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export declare type ResetViewAction = {
|
|
47
|
+
type: "@@redux-paginator-immutable/RESET_VIEW";
|
|
48
|
+
meta: {
|
|
49
|
+
endpoint: string;
|
|
50
|
+
};
|
|
51
|
+
payload: {
|
|
52
|
+
token: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export declare type ClearDataAction = {
|
|
56
|
+
type: "@@redux-paginator-immutable/CLEAR_DATA";
|
|
57
|
+
meta: {
|
|
58
|
+
endpoint: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare type FetchCurrentCompanyInfoPending = {
|
|
62
|
+
type: "FETCH_CURRENT_COMPANY_INFO_PENDING";
|
|
63
|
+
};
|
|
64
|
+
export declare type FetchItemDataPending = {
|
|
65
|
+
type: "@@redux-paginator-immutable/FETCH_ITEM_DATA_PENDING";
|
|
66
|
+
meta: {
|
|
67
|
+
id: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export declare type FetchItemDataRejected = {
|
|
71
|
+
type: "@@redux-paginator-immutable/FETCH_ITEM_DATA_REJECTED";
|
|
72
|
+
meta: {
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export declare type FetchItemDataFulFilled = {
|
|
77
|
+
type: "@@redux-paginator-immutable/FETCH_ITEM_DATA_FULFILLED";
|
|
78
|
+
payload: {
|
|
79
|
+
Data: any;
|
|
80
|
+
};
|
|
81
|
+
meta: {
|
|
82
|
+
id: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export declare type Action = RequestPageAction | ReceivePageAction | ResetViewAction | ChangeViewAction | ClearDataAction | FetchCurrentCompanyInfoPending | FetchItemDataPending | FetchItemDataRejected | FetchItemDataFulFilled;
|
package/lib/types/actions.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/types/actions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from "./actions";
|
|
2
|
+
export * from "./state";
|
|
3
|
+
import type { State } from "./state";
|
|
4
|
+
import type { Action } from "./actions";
|
|
5
|
+
export declare type GetState = () => State;
|
|
6
|
+
export declare type PromiseAction = Promise<Action>;
|
|
7
|
+
export declare type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;
|
|
8
|
+
export declare type Dispatch = (action: Action | ThunkAction | PromiseAction | Array<Action>) => any;
|
|
9
|
+
export declare type EndPointCb = ((token?: string) => string) | null;
|
|
10
|
+
export declare type PaginatorSettings = {
|
|
11
|
+
key: string;
|
|
12
|
+
manageEntity: any;
|
|
13
|
+
resultsKey: string;
|
|
14
|
+
rowsPerLoad?: number;
|
|
15
|
+
manipulateItems?: (items: any) => any;
|
|
16
|
+
totalKey?: string;
|
|
17
|
+
pageArgName?: string;
|
|
18
|
+
idKey?: string;
|
|
19
|
+
dataItemURL?: string;
|
|
20
|
+
normalizeDataItem?: any;
|
|
21
|
+
};
|
package/lib/types/index.js
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _state = require("./state");
|
|
20
|
-
|
|
21
|
-
Object.keys(_state).forEach(function (key) {
|
|
22
|
-
if (key === "default" || key === "__esModule") return;
|
|
23
|
-
Object.defineProperty(exports, key, {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function get() {
|
|
26
|
-
return _state[key];
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
/* eslint-disable no-use-before-define */
|
|
14
|
+
__exportStar(require("./actions"), exports);
|
|
15
|
+
__exportStar(require("./state"), exports);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAyC;AACzC,4CAA0B;AAC1B,0CAAwB"}
|
package/lib/types/state.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/types/state.ts"],"names":[],"mappings":""}
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare type NormalizrEntity = (data: any) => any;
|
|
2
|
+
import type { Map as ImmutableMap } from "immutable";
|
|
3
|
+
declare type ManageDataEntity = ImmutableMap<string, any>;
|
|
4
|
+
declare const manageEntity: (normalizrEntity: NormalizrEntity) => (item: any, state: any, keyID: string) => ManageDataEntity, manipulateItems: (sortKey?: string) => ((state: {}) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
|
|
5
|
+
clearCache: () => void;
|
|
6
|
+
}, manageDataEntity: (normalizrEntity: NormalizrEntity) => (item: any, state: any, keyID: string) => ManageDataEntity, manipulateDataItems: (sortKey?: string) => ((state: {}) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
|
|
7
|
+
clearCache: () => void;
|
|
8
|
+
};
|
|
9
|
+
export { manageDataEntity, manipulateDataItems, manipulateItems, manageEntity };
|