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.
Files changed (106) hide show
  1. package/lib/Info.d.ts +9 -0
  2. package/lib/Info.js +19 -41
  3. package/lib/Info.js.map +1 -0
  4. package/lib/LoadDataItem.d.ts +23 -0
  5. package/lib/LoadDataItem.js +59 -110
  6. package/lib/LoadDataItem.js.map +1 -0
  7. package/lib/LoadPaginator.d.ts +41 -0
  8. package/lib/LoadPaginator.js +109 -216
  9. package/lib/LoadPaginator.js.map +1 -0
  10. package/lib/LoadingButton.d.ts +11 -0
  11. package/lib/LoadingButton.js +22 -75
  12. package/lib/LoadingButton.js.map +1 -0
  13. package/lib/actionTypes.d.ts +9 -0
  14. package/lib/actionTypes.js +13 -16
  15. package/lib/actionTypes.js.map +1 -0
  16. package/lib/actions.d.ts +42 -0
  17. package/lib/actions.js +82 -136
  18. package/lib/actions.js.map +1 -0
  19. package/lib/agent.d.ts +8 -0
  20. package/lib/agent.js +37 -86
  21. package/lib/agent.js.map +1 -0
  22. package/lib/createDataReducer.d.ts +14 -0
  23. package/lib/createDataReducer.js +60 -79
  24. package/lib/createDataReducer.js.map +1 -0
  25. package/lib/createItemReducer.d.ts +9 -0
  26. package/lib/createItemReducer.js +14 -32
  27. package/lib/createItemReducer.js.map +1 -0
  28. package/lib/createPaginator.d.ts +14 -0
  29. package/lib/createPaginator.js +83 -140
  30. package/lib/createPaginator.js.map +1 -0
  31. package/lib/index.d.ts +11 -0
  32. package/lib/index.js +30 -58
  33. package/lib/index.js.map +1 -0
  34. package/lib/paginatorMiddleware.d.ts +5 -0
  35. package/lib/paginatorMiddleware.js +68 -102
  36. package/lib/paginatorMiddleware.js.map +1 -0
  37. package/lib/reducerItemData.d.ts +18 -0
  38. package/lib/reducerItemData.js +56 -63
  39. package/lib/reducerItemData.js.map +1 -0
  40. package/lib/reducerOperations.d.ts +3 -0
  41. package/lib/reducerOperations.js +69 -114
  42. package/lib/reducerOperations.js.map +1 -0
  43. package/lib/reducers.d.ts +4 -0
  44. package/lib/reducers.js +75 -87
  45. package/lib/reducers.js.map +1 -0
  46. package/lib/selectors.d.ts +58 -0
  47. package/lib/selectors.js +79 -129
  48. package/lib/selectors.js.map +1 -0
  49. package/lib/types/actions.d.ts +85 -0
  50. package/lib/types/actions.js +3 -1
  51. package/lib/types/actions.js.map +1 -0
  52. package/lib/types/index.d.ts +21 -0
  53. package/lib/types/index.js +16 -29
  54. package/lib/types/index.js.map +1 -0
  55. package/lib/types/state.d.ts +6 -0
  56. package/lib/types/state.js +3 -1
  57. package/lib/types/state.js.map +1 -0
  58. package/lib/util.d.ts +9 -0
  59. package/lib/util.js +49 -73
  60. package/lib/util.js.map +1 -0
  61. package/lib/words.d.ts +9 -0
  62. package/lib/words.js +12 -15
  63. package/lib/words.js.map +1 -0
  64. package/package.json +35 -21
  65. package/src/Info.tsx +29 -0
  66. package/src/LoadDataItem.tsx +84 -0
  67. package/src/{LoadPaginator.jsx → LoadPaginator.tsx} +77 -94
  68. package/src/LoadingButton.tsx +40 -0
  69. package/src/__tests__/createPaginator.spec.js +6 -6
  70. package/src/__tests__/reducers.spec.js +28 -28
  71. package/src/__tests__/selectors.spec.js +80 -81
  72. package/src/{actionTypes.js → actionTypes.ts} +0 -4
  73. package/src/actions.ts +157 -0
  74. package/src/agent.ts +62 -0
  75. package/src/createDataReducer.ts +91 -0
  76. package/src/{createItemReducer.js → createItemReducer.ts} +7 -13
  77. package/src/createPaginator.ts +107 -0
  78. package/src/{index.js → index.ts} +0 -13
  79. package/src/paginatorMiddleware.ts +93 -0
  80. package/src/reducerItemData.ts +74 -0
  81. package/src/reducerOperations.ts +101 -0
  82. package/src/{reducers.js → reducers.ts} +9 -18
  83. package/src/selectors.ts +113 -0
  84. package/src/types/{actions.js → actions.ts} +27 -39
  85. package/src/types/{index.js → index.ts} +6 -13
  86. package/src/types/{state.js → state.ts} +3 -6
  87. package/src/util.ts +51 -0
  88. package/src/{words.js → words.ts} +0 -2
  89. package/lib/__tests__/actions.spec.js +0 -117
  90. package/lib/__tests__/agent.spec.js +0 -32
  91. package/lib/__tests__/createPaginator.spec.js +0 -39
  92. package/lib/__tests__/reducers.spec.js +0 -126
  93. package/lib/__tests__/selectors.spec.js +0 -162
  94. package/lib/__tests__/setup.js +0 -3
  95. package/src/Info.jsx +0 -34
  96. package/src/LoadDataItem.jsx +0 -116
  97. package/src/LoadingButton.jsx +0 -55
  98. package/src/actions.js +0 -153
  99. package/src/agent.js +0 -55
  100. package/src/createDataReducer.js +0 -94
  101. package/src/createPaginator.js +0 -131
  102. package/src/paginatorMiddleware.js +0 -94
  103. package/src/reducerItemData.jsx +0 -64
  104. package/src/reducerOperations.jsx +0 -112
  105. package/src/selectors.js +0 -143
  106. package/src/util.js +0 -71
package/lib/reducers.js CHANGED
@@ -1,87 +1,75 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.dataItems = exports.items = exports.pages = undefined;
7
-
8
- var _actionTypes = require("./actionTypes");
9
-
10
- var _immutable = require("immutable");
11
-
12
- var Immutable = _interopRequireWildcard(_immutable);
13
-
14
- var _reducerItemData = require("./reducerItemData");
15
-
16
- var reducerItemData = _interopRequireWildcard(_reducerItemData);
17
-
18
- var _reducerOperations = require("./reducerOperations");
19
-
20
- var reducerOperations = _interopRequireWildcard(_reducerOperations);
21
-
22
- 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; } }
23
-
24
- var pages = exports.pages = function pages() {
25
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Immutable.Map();
26
- var action = arguments[1];
27
-
28
- switch (action.type) {
29
- case _actionTypes.REQUEST_PAGE:
30
- return reducerOperations.requestPage(state, action);
31
-
32
- case _actionTypes.RECEIVE_PAGE:
33
- return reducerOperations.receivePage(state, action);
34
-
35
- case _actionTypes.RESET_VIEW:
36
- return reducerOperations.resetView(state, action);
37
-
38
- case _actionTypes.CHANGE_VIEW:
39
- return reducerOperations.changeView(state, action);
40
-
41
- case _actionTypes.FETCH_CURRENT_COMPANY_INFO_PENDING:
42
- case _actionTypes.CLEAR_DATA:
43
- return state.clear();
44
-
45
- default:
46
- return state;
47
- }
48
- };
49
-
50
- var items = exports.items = function items() {
51
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Immutable.Map();
52
- var action = arguments[1];
53
-
54
- switch (action.type) {
55
- case _actionTypes.RECEIVE_PAGE:
56
- return reducerOperations.receivePageItems(state, action);
57
-
58
- case _actionTypes.FETCH_CURRENT_COMPANY_INFO_PENDING:
59
- case _actionTypes.CLEAR_DATA:
60
- return state.clear();
61
- default:
62
- return state;
63
- }
64
- };
65
-
66
- var dataItems = exports.dataItems = function dataItems() {
67
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Immutable.Map();
68
- var action = arguments[1];
69
-
70
- switch (action.type) {
71
- case _actionTypes.RECEIVE_PAGE:
72
- return reducerOperations.receivePageItems(state, action);
73
-
74
- case _actionTypes.FETCH_ITEM_DATA_PENDING:
75
- return reducerItemData.fetchItemDataPending(state, action);
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
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _immutable = require("immutable");
8
-
9
- var Immutable = _interopRequireWildcard(_immutable);
10
-
11
- var _reselect = require("reselect");
12
-
13
- 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; } }
14
-
15
- var pagesSelector = function pagesSelector(state) {
16
- return state;
17
- };
18
- /* eslint-disable no-undefined */
19
-
20
- var rowsPerPage = 50;
21
-
22
- var pageSelector = (0, _reselect.createSelector)(pagesSelector, function (state, token) {
23
- return token;
24
- }, function (pages, token) {
25
- return pages.get(token);
26
- });
27
-
28
- var getAllResults = (0, _reselect.createSelector)(pageSelector, function (state, token, items) {
29
- return items;
30
- }, function (page, items) {
31
- if (typeof page === "undefined") {
32
- return Immutable.List();
33
- }
34
-
35
- return page.get("ids").map(function (id) {
36
- return items.get(String(id));
37
- });
38
- });
39
-
40
- var getResultsUpToPage = (0, _reselect.createSelector)(pageSelector, function (state, token, items) {
41
- return items;
42
- }, function (state, token, items, target) {
43
- return target;
44
- }, function (state, token, items, target, perPage) {
45
- return perPage || rowsPerPage;
46
- }, function (page, items, target, perPage) {
47
- if (typeof page === "undefined") {
48
- return Immutable.List();
49
- }
50
-
51
- var ids = page.get("ids").slice(0, perPage * target);
52
-
53
- return ids.map(function (id) {
54
- return items.get(String(id));
55
- });
56
- });
57
-
58
- var getCurrentTotalResultsCount = (0, _reselect.createSelector)(pageSelector, function (page) {
59
- if (typeof page === "undefined") {
60
- return 0;
61
- }
62
-
63
- return page.get("total");
64
- });
65
-
66
- var isPageFetching = (0, _reselect.createSelector)(pageSelector, function (state, token, target) {
67
- return target;
68
- }, function (page, target) {
69
- if (typeof page === "undefined") {
70
- return false;
71
- }
72
-
73
- return page.get("fetching") && target === page.get("page");
74
- });
75
-
76
- var isPageFetched = (0, _reselect.createSelector)(pageSelector, function (state, token, target) {
77
- return target;
78
- }, function (page, target) {
79
- if (typeof page === "undefined") {
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,C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AC,KAAK,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,EACpF,aAAa,GAAG,IAAA,yBAAc,EAC5B,uBAAuB,EACvB,oBAAoB,EACpB,CAAC,IAAU,EAAE,QAAc,EAAE,EAAE,CAAC,CAAC;IAC/B,IAAI;IACJ,QAAQ;CACT,CAAC,CACH,CAAC;AAEJ,kBAAe;IACb,aAAa;IACb,2BAA2B;IAC3B,kBAAkB;IAClB,cAAc;IACd,aAAa;IACb,eAAe;IACf,cAAc;IACd,YAAY;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;
@@ -1 +1,3 @@
1
- "use strict";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=actions.js.map
@@ -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
+ };
@@ -1,29 +1,16 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _actions = require("./actions");
8
-
9
- Object.keys(_actions).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- Object.defineProperty(exports, key, {
12
- enumerable: true,
13
- get: function get() {
14
- return _actions[key];
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"}
@@ -0,0 +1,6 @@
1
+ export declare type PagesState = any;
2
+ export declare type ItemsState = any;
3
+ export declare type State = {
4
+ readonly pages: PagesState;
5
+ readonly itemsReducer: ItemsState;
6
+ };
@@ -1 +1,3 @@
1
- "use strict";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=state.js.map
@@ -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 };