redux-paginator-immutable 17.0.49 → 17.0.51
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/package.json +19 -16
- package/README.md +0 -3
- package/lib/Info.d.ts +0 -9
- package/lib/Info.js +0 -18
- package/lib/Info.js.map +0 -1
- package/lib/LoadDataItem.d.ts +0 -25
- package/lib/LoadDataItem.js +0 -60
- package/lib/LoadDataItem.js.map +0 -1
- package/lib/LoadPaginator.d.ts +0 -4
- package/lib/LoadPaginator.js +0 -79
- package/lib/LoadPaginator.js.map +0 -1
- package/lib/LoadPaginatorTypes.d.ts +0 -29
- package/lib/LoadPaginatorTypes.js +0 -3
- package/lib/LoadPaginatorTypes.js.map +0 -1
- package/lib/LoadingButton.d.ts +0 -8
- package/lib/LoadingButton.js +0 -26
- package/lib/LoadingButton.js.map +0 -1
- package/lib/actionTypes.d.ts +0 -9
- package/lib/actionTypes.js +0 -13
- package/lib/actionTypes.js.map +0 -1
- package/lib/actions.d.ts +0 -42
- package/lib/actions.js +0 -82
- package/lib/actions.js.map +0 -1
- package/lib/agent.d.ts +0 -8
- package/lib/agent.js +0 -37
- package/lib/agent.js.map +0 -1
- package/lib/createDataReducer.d.ts +0 -14
- package/lib/createDataReducer.js +0 -67
- package/lib/createDataReducer.js.map +0 -1
- package/lib/createItemReducer.d.ts +0 -9
- package/lib/createItemReducer.js +0 -18
- package/lib/createItemReducer.js.map +0 -1
- package/lib/createPaginator.d.ts +0 -33
- package/lib/createPaginator.js +0 -87
- package/lib/createPaginator.js.map +0 -1
- package/lib/index.d.ts +0 -11
- package/lib/index.js +0 -30
- package/lib/index.js.map +0 -1
- package/lib/paginatorMiddleware.d.ts +0 -5
- package/lib/paginatorMiddleware.js +0 -69
- package/lib/paginatorMiddleware.js.map +0 -1
- package/lib/reducerItemData.d.ts +0 -18
- package/lib/reducerItemData.js +0 -60
- package/lib/reducerItemData.js.map +0 -1
- package/lib/reducerOperations.d.ts +0 -4
- package/lib/reducerOperations.js +0 -75
- package/lib/reducerOperations.js.map +0 -1
- package/lib/reducers.d.ts +0 -2
- package/lib/reducers.js +0 -75
- package/lib/reducers.js.map +0 -1
- package/lib/selectors.d.ts +0 -38
- package/lib/selectors.js +0 -83
- package/lib/selectors.js.map +0 -1
- package/lib/types.d.ts +0 -107
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
- package/lib/util.d.ts +0 -9
- package/lib/util.js +0 -53
- package/lib/util.js.map +0 -1
- 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
package/lib/createDataReducer.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const reselect_1 = require("reselect");
|
|
27
|
-
const Immutable = __importStar(require("immutable"));
|
|
28
|
-
/*
|
|
29
|
-
Use to create a complex list where you need more information about
|
|
30
|
-
the item. For instance, if you DO need to fetch more data or to
|
|
31
|
-
manipulate it
|
|
32
|
-
*/
|
|
33
|
-
const createDataReducer = ({ key }) => {
|
|
34
|
-
const getItems = (state) => (state.getIn(["entities", key])), getItem = (0, reselect_1.createSelector)(getItems, (_state, id) => id, (data, id) => data.get(id) || Immutable.Map()), getItemsList = (0, reselect_1.createSelector)(getItems, (data) => data.map((current) => current.get("Data")).toList()), getItemData = (0, reselect_1.createSelector)(getItems, (_state, id) => id, (data, id) => {
|
|
35
|
-
if (typeof data === "undefined") {
|
|
36
|
-
return Immutable.Map();
|
|
37
|
-
}
|
|
38
|
-
return data.getIn([id, "Data"]);
|
|
39
|
-
}), getItemHasError = (0, reselect_1.createSelector)(getItem, (data) => {
|
|
40
|
-
if (typeof data === "undefined") {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
return data.get("error") === true;
|
|
44
|
-
}), getIsFetchingItemInfo = (0, reselect_1.createSelector)(getItem, (data) => {
|
|
45
|
-
if (typeof data === "undefined") {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return data.get("fetching");
|
|
49
|
-
}), getItemIsFetched = (0, reselect_1.createSelector)(getItem, (data) => {
|
|
50
|
-
if (typeof data === "undefined") {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
return data.get("fetched");
|
|
54
|
-
}), getShouldFetchItemInfo = (0, reselect_1.createSelector)(getIsFetchingItemInfo, getItemIsFetched, getItemHasError, (isFetching, isFetched, hasError) => (!isFetched && !isFetching && !hasError));
|
|
55
|
-
return {
|
|
56
|
-
getItems,
|
|
57
|
-
getItem,
|
|
58
|
-
getItemsList,
|
|
59
|
-
getItemData,
|
|
60
|
-
getItemHasError,
|
|
61
|
-
getIsFetchingItemInfo,
|
|
62
|
-
getItemIsFetched,
|
|
63
|
-
getShouldFetchItemInfo,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
exports.default = createDataReducer;
|
|
67
|
-
//# sourceMappingURL=createDataReducer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createDataReducer.js","sourceRoot":"","sources":["../src/createDataReducer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA0C;AAC1C,qDAAuC;AAMvC;;;;EAIE;AACF,MACE,iBAAiB,GAAG,CAAC,EAAE,GAAG,EAAqB,EAAE,EAAE;IACjD,MACE,QAAQ,GAAG,CAAC,KAAU,EAAQ,EAAE,CAAC,CAC/B,KAAK,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAC/B,EACD,OAAO,GAAc,IAAA,yBAAc,EACjC,QAAQ,EACR,CAAC,MAAY,EAAE,EAAW,EAAE,EAAE,CAAC,EAAE,EACjC,CAAC,IAAU,EAAE,EAAW,EAAQ,EAAE,CAAC,I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C,CAAC;IAC7B,CAAC,CACF,EACD,sBAAsB,GAAc,IAAA,yBAAc,EAChD,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,CAAC,UAAoB,EAAE,SAAmB,EAAE,QAAkB,EAAY,EAAE,CAAC,CAC3E,CAAC,SAAS,IAAI,CAAC,UAAU,IAAI,CAAC,QAAQ,CACvC,CACF,CAAC;IAEJ,OAAO;QACL,QAAQ;QACR,OAAO;QACP,YAAY;QACZ,WAAW;QACX,eAAe;QACf,qBAAqB;QACrB,gBAAgB;QAChB,sBAAsB;KACvB,CAAC;AACJ,CAAC,CAAC;AAEJ,kBAAe,iBAAiB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PaginatorSettings } from "./types";
|
|
2
|
-
declare const createReducer: ({ key }: PaginatorSettings) => {
|
|
3
|
-
getItems: (state: any) => any;
|
|
4
|
-
getItem: (state: any, id: string) => any;
|
|
5
|
-
getItemsList: ((state: any) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
|
|
6
|
-
clearCache: () => void;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export default createReducer;
|
package/lib/createItemReducer.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const reselect_1 = require("reselect");
|
|
4
|
-
/*
|
|
5
|
-
Use to create a simple list where you do not need more information about
|
|
6
|
-
the item. For instance, if you do NOT need to fetch more data or
|
|
7
|
-
manipulate it
|
|
8
|
-
*/
|
|
9
|
-
const createReducer = ({ key }) => {
|
|
10
|
-
const getItems = (state) => state.getIn(["entities", key]), getItem = (0, reselect_1.createSelector)(getItems, (_state, id) => id, (data, id) => data.get(id)), getItemsList = (0, reselect_1.createSelector)(getItems, (data) => data.toList());
|
|
11
|
-
return {
|
|
12
|
-
getItems,
|
|
13
|
-
getItem,
|
|
14
|
-
getItemsList,
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
exports.default = createReducer;
|
|
18
|
-
//# sourceMappingURL=createItemReducer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createItemReducer.js","sourceRoot":"","sources":["../src/createItemReducer.ts"],"names":[],"mappings":";;AAAA,uCAA0C;AAG1C;;;;EAIE;AACF,MAAM,aAAa,GAAG,CAAC,EAAE,GAAG,EAAqB,EAAE,EAAE;IACnD,MACE,QAAQ,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,EACzD,OAAO,GAAuC,IAAA,yBAAc,EAC1D,QAAQ,EACR,CAAC,MAAY,EAAE,EAAW,EAAE,EAAE,CAAC,EAAE,EACjC,CAAC,IAAU,EAAE,EAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAC1C,EACD,YAAY,GAAG,IAAA,yBAAc,EAC3B,QAAQ,EACR,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAC9B,CAAC;IAEJ,OAAO;QACL,QAAQ;QACR,OAAO;QACP,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
|
package/lib/createPaginator.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as Immutable from "immutable";
|
|
2
|
-
import { PaginatorSettings } from "./types";
|
|
3
|
-
type EndpointData = {
|
|
4
|
-
path: string;
|
|
5
|
-
cb: () => string;
|
|
6
|
-
};
|
|
7
|
-
type Endpoint = EndpointData | string;
|
|
8
|
-
type Action = {
|
|
9
|
-
meta?: {
|
|
10
|
-
endpoint: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export declare const onlyForEndpoint: (endpoint: string, reducer: any) => (state: Immutable.Map<unknown, unknown> | undefined, action: Action) => any, createPaginator: (endpointData: Endpoint, settings: PaginatorSettings) => {
|
|
14
|
-
requestPage: (page: number, token: string) => import("./types").Action;
|
|
15
|
-
resetView(token: any): import("./types").Action;
|
|
16
|
-
changeView({ view, token }: {
|
|
17
|
-
view: number;
|
|
18
|
-
token: string;
|
|
19
|
-
}): import("./types").Action;
|
|
20
|
-
clearData(): import("./types").Action;
|
|
21
|
-
key: string;
|
|
22
|
-
normalizeDataItem: any;
|
|
23
|
-
dataItemURL: string | undefined;
|
|
24
|
-
manipulateItems: (items: any) => any;
|
|
25
|
-
rowsPerLoad: number;
|
|
26
|
-
manageEntity: any;
|
|
27
|
-
resultsKey: string;
|
|
28
|
-
endpoint: string;
|
|
29
|
-
pagesReducer: (state: Immutable.Map<unknown, unknown> | undefined, action: Action) => any;
|
|
30
|
-
itemsReducer: (state: Immutable.Map<unknown, unknown> | undefined, action: Action) => any;
|
|
31
|
-
dataItemsReducer: (state: Immutable.Map<unknown, unknown> | undefined, action: Action) => any;
|
|
32
|
-
};
|
|
33
|
-
export {};
|
package/lib/createPaginator.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createPaginator = exports.onlyForEndpoint = void 0;
|
|
30
|
-
const defaultRowsPerLoad = 25;
|
|
31
|
-
const Immutable = __importStar(require("immutable"));
|
|
32
|
-
const reducers_1 = require("./reducers");
|
|
33
|
-
const actions_1 = __importDefault(require("./actions"));
|
|
34
|
-
const getEndpoint = (data) => {
|
|
35
|
-
if (typeof data === "object") {
|
|
36
|
-
return {
|
|
37
|
-
path: data.path,
|
|
38
|
-
cb: data.cb,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
path: data,
|
|
43
|
-
cb: null,
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
const onlyForEndpoint = (endpoint, reducer) => (state = Immutable.Map(), action) => {
|
|
47
|
-
if (typeof action.meta === "undefined" || action.meta.endpoint !== endpoint) {
|
|
48
|
-
return state;
|
|
49
|
-
}
|
|
50
|
-
return reducer(state, action);
|
|
51
|
-
}, createPaginator = (endpointData, settings) => {
|
|
52
|
-
const { path: endpoint, cb: endpointCb, } = getEndpoint(endpointData), { key, normalizeDataItem, dataItemURL, manageEntity, resultsKey, totalKey = "Total", pageArgName = "page", idKey = "ID", rowsPerLoad = defaultRowsPerLoad, manipulateItems = (items) => items, } = settings, endpointedActions = {
|
|
53
|
-
requestPage: (page, token) => actions_1.default.requestPage({
|
|
54
|
-
endpoint,
|
|
55
|
-
endpointCb,
|
|
56
|
-
manageEntity,
|
|
57
|
-
resultsKey,
|
|
58
|
-
totalKey,
|
|
59
|
-
pageArgName,
|
|
60
|
-
idKey,
|
|
61
|
-
page,
|
|
62
|
-
token,
|
|
63
|
-
}),
|
|
64
|
-
resetView(token) {
|
|
65
|
-
return actions_1.default.resetView(endpoint, token);
|
|
66
|
-
},
|
|
67
|
-
changeView({ view, token }) {
|
|
68
|
-
return actions_1.default.changeView(endpoint, {
|
|
69
|
-
view,
|
|
70
|
-
token,
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
clearData() {
|
|
74
|
-
return actions_1.default.clearData(endpoint);
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
return Object.assign({ key,
|
|
78
|
-
normalizeDataItem,
|
|
79
|
-
dataItemURL,
|
|
80
|
-
manipulateItems,
|
|
81
|
-
rowsPerLoad,
|
|
82
|
-
manageEntity,
|
|
83
|
-
resultsKey,
|
|
84
|
-
endpoint, pagesReducer: (0, exports.onlyForEndpoint)(endpoint, reducers_1.pages), itemsReducer: (0, exports.onlyForEndpoint)(endpoint, reducers_1.items), dataItemsReducer: (0, exports.onlyForEndpoint)(endpoint, reducers_1.dataItems) }, endpointedActions);
|
|
85
|
-
};
|
|
86
|
-
exports.onlyForEndpoint = onlyForEndpoint, exports.createPaginator = createPaginator;
|
|
87
|
-
//# sourceMappingURL=createPaginator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createPaginator.js","sourceRoot":"","sources":["../src/createPaginator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,qDAAuC;AACvC,yCAAyG;AACzG,wDAAgC;AAgBhC,MAAM,WAAW,GAAG,CAAC,IAAc,EAAE,EAAE;IACrC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO;YACL,IAAI,EAAG,IAAI,CAAC,IAA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;YAC3D,OAAO,iBAAO,CAAC,UAAU,CAAC,QAAQ,EAAE;gBAClC,IAAI;gBACJ,KAAK;aACN,CAAC,CAAC;QACL,CAAC;QAED,SAAS;YACP,OAAO,iBAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;IAEJ,uBACE,GAAG;QACH,iBAAiB;QACjB,WAAW;QACX,eAAe;QACf,WAAW;QACX,YAAY;QACZ,UAAU;QACV,QAAQ,EACR,YAAY,EAAO,IAAA,uBAAe,EAAC,QAAQ,EAAE,gBAAY,CAAC,EAC1D,YAAY,EAAO,IAAA,uBAAe,EAAC,QAAQ,EAAE,gBAAY,CAAC,EAC1D,gBAAgB,EAAG,IAAA,uBAAe,EAAC,QAAQ,EAAE,oBAAgB,CAAC,IAC3D,iBAAiB,EACpB;AACJ,CAAC,CAAC;AApEF,QAAA,eAAe,oBAOf,QAAA,eAAe,mBA6Db"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createPaginator } from "./createPaginator";
|
|
2
|
-
import paginatorMiddleware from "./paginatorMiddleware";
|
|
3
|
-
import paginatorSelectors from "./selectors";
|
|
4
|
-
import { manageDataEntity, manipulateDataItems, manipulateItems, manageEntity } from "./util";
|
|
5
|
-
import Info from "./Info";
|
|
6
|
-
import LoadingButton from "./LoadingButton";
|
|
7
|
-
import LoadPaginator from "./LoadPaginator";
|
|
8
|
-
import LoadDataItem from "./LoadDataItem";
|
|
9
|
-
import createDataReducer from "./createDataReducer";
|
|
10
|
-
import createItemReducer from "./createItemReducer";
|
|
11
|
-
export { Info, LoadingButton, LoadPaginator, LoadDataItem, createPaginator, paginatorMiddleware, paginatorSelectors, createDataReducer, manageDataEntity, manipulateDataItems, createItemReducer, manipulateItems, manageEntity, };
|
package/lib/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.manageEntity = exports.manipulateItems = exports.createItemReducer = exports.manipulateDataItems = exports.manageDataEntity = exports.createDataReducer = exports.paginatorSelectors = exports.paginatorMiddleware = exports.createPaginator = exports.LoadDataItem = exports.LoadPaginator = exports.LoadingButton = exports.Info = void 0;
|
|
7
|
-
const createPaginator_1 = require("./createPaginator");
|
|
8
|
-
Object.defineProperty(exports, "createPaginator", { enumerable: true, get: function () { return createPaginator_1.createPaginator; } });
|
|
9
|
-
const paginatorMiddleware_1 = __importDefault(require("./paginatorMiddleware"));
|
|
10
|
-
exports.paginatorMiddleware = paginatorMiddleware_1.default;
|
|
11
|
-
const selectors_1 = __importDefault(require("./selectors"));
|
|
12
|
-
exports.paginatorSelectors = selectors_1.default;
|
|
13
|
-
const util_1 = require("./util");
|
|
14
|
-
Object.defineProperty(exports, "manageDataEntity", { enumerable: true, get: function () { return util_1.manageDataEntity; } });
|
|
15
|
-
Object.defineProperty(exports, "manipulateDataItems", { enumerable: true, get: function () { return util_1.manipulateDataItems; } });
|
|
16
|
-
Object.defineProperty(exports, "manipulateItems", { enumerable: true, get: function () { return util_1.manipulateItems; } });
|
|
17
|
-
Object.defineProperty(exports, "manageEntity", { enumerable: true, get: function () { return util_1.manageEntity; } });
|
|
18
|
-
const Info_1 = __importDefault(require("./Info"));
|
|
19
|
-
exports.Info = Info_1.default;
|
|
20
|
-
const LoadingButton_1 = __importDefault(require("./LoadingButton"));
|
|
21
|
-
exports.LoadingButton = LoadingButton_1.default;
|
|
22
|
-
const LoadPaginator_1 = __importDefault(require("./LoadPaginator"));
|
|
23
|
-
exports.LoadPaginator = LoadPaginator_1.default;
|
|
24
|
-
const LoadDataItem_1 = __importDefault(require("./LoadDataItem"));
|
|
25
|
-
exports.LoadDataItem = LoadDataItem_1.default;
|
|
26
|
-
const createDataReducer_1 = __importDefault(require("./createDataReducer"));
|
|
27
|
-
exports.createDataReducer = createDataReducer_1.default;
|
|
28
|
-
const createItemReducer_1 = __importDefault(require("./createItemReducer"));
|
|
29
|
-
exports.createItemReducer = createItemReducer_1.default;
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAoD;AAgBlD,gGAhBO,iCAAe,OAgBP;AAfjB,gFAAwD;AAgBtD,8BAhBK,6BAAmB,CAgBL;AAfrB,4DAA6C;AAgB3C,6BAhBK,mBAAkB,CAgBL;AAfpB,iCAA8F;AAiB5F,iGAjBO,uBAAgB,OAiBP;AAChB,oGAlByB,0BAAmB,OAkBzB;AAEnB,gGApB8C,sBAAe,OAoB9C;AACf,6FArB+D,mBAAY,OAqB/D;AApBd,kDAA0B;AAQxB,eARK,cAAI,CAQL;AAPN,oEAA4C;AAQ1C,wBARK,uBAAa,CAQL;AAPf,oEAA4C;AAQ1C,wBARK,uBAAa,CAQL;AAPf,kEAA0C;AAQxC,uBARK,sBAAY,CAQL;AAPd,4EAAoD;AAWlD,4BAXK,2BAAiB,CAWL;AAVnB,4EAAoD;AAalD,4BAbK,2BAAiB,CAaL"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable no-console, max-lines-per-function */
|
|
7
|
-
const actionTypes_1 = require("./actionTypes");
|
|
8
|
-
const actions_1 = __importDefault(require("./actions"));
|
|
9
|
-
const agent_1 = require("./agent");
|
|
10
|
-
const { receivePage } = actions_1.default, paginatorMiddleware = ({ dispatch }) => (next) => (action) => {
|
|
11
|
-
if (action.type === actionTypes_1.REQUEST_PAGE) {
|
|
12
|
-
const { meta: { endpoint, endpointCb, manageEntity, resultsKey, totalKey, pageArgName, idKey, }, payload: { page, token, }, } = action;
|
|
13
|
-
dispatch((dispatch2) => {
|
|
14
|
-
const markAsError = () => {
|
|
15
|
-
dispatch2(receivePage({
|
|
16
|
-
endpoint,
|
|
17
|
-
endpointCb,
|
|
18
|
-
manageEntity,
|
|
19
|
-
pageArgName,
|
|
20
|
-
idKey,
|
|
21
|
-
page,
|
|
22
|
-
error: true,
|
|
23
|
-
token,
|
|
24
|
-
items: [],
|
|
25
|
-
total: 0,
|
|
26
|
-
}));
|
|
27
|
-
}, rawPath = typeof endpointCb === "function" ? endpointCb(token) : endpoint, path = rawPath === null ? "" : rawPath;
|
|
28
|
-
try {
|
|
29
|
-
(0, agent_1.fetchPage)({
|
|
30
|
-
endpoint: path,
|
|
31
|
-
pageArgName,
|
|
32
|
-
page,
|
|
33
|
-
token,
|
|
34
|
-
}).then((res) => {
|
|
35
|
-
const { response } = res;
|
|
36
|
-
let results = [], total = 0;
|
|
37
|
-
if (typeof resultsKey === "undefined") {
|
|
38
|
-
results = response;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
results = response[resultsKey];
|
|
42
|
-
total = response[totalKey];
|
|
43
|
-
}
|
|
44
|
-
dispatch2(receivePage({
|
|
45
|
-
endpoint,
|
|
46
|
-
endpointCb,
|
|
47
|
-
manageEntity,
|
|
48
|
-
pageArgName,
|
|
49
|
-
idKey,
|
|
50
|
-
page,
|
|
51
|
-
error: false,
|
|
52
|
-
token,
|
|
53
|
-
items: results,
|
|
54
|
-
total,
|
|
55
|
-
}));
|
|
56
|
-
}).
|
|
57
|
-
catch(() => {
|
|
58
|
-
markAsError();
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
markAsError();
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return next(action);
|
|
67
|
-
};
|
|
68
|
-
exports.default = paginatorMiddleware;
|
|
69
|
-
//# sourceMappingURL=paginatorMiddleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paginatorMiddleware.js","sourceRoot":"","sources":["../src/paginatorMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,uDAAuD;AACvD,+CAA6C;AAC7C,wDAAgC;AAChC,mCAAoC;AAGpC,MACE,EAAE,WAAW,EAAE,GAAG,iBAAO,EAEzB,mBAAmB,GAAG,CAAC,EAAE,QAAQ,EAA0B,EAAE,EAAE,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC,MAAc,EAAE,EAAE;IAChG,IAAI,MAAM,CAAC,IAAI,KAAK,0BAAY,EAAE;QAChC,MAAM,EACJ,IAAI,EAAE,EACJ,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,WAAW,EACX,KAAK,GACN,EACD,OAAO,EAAE,EACP,IAAI,EACJ,KAAK,GACN,GACF,GAAG,MAAM,CAAC;QAEX,QAAQ,CAAC,CAAC,SAAS,EAAE,EAAE;YACrB,MACE,WAAW,GAAG,GAAG,EAAE;gBACjB,SAAS,CAAC,WAAW,CAAC;oBACpB,QAAQ;oBACR,UAAU;oBACV,YAAY;oBACZ,WAAW;oBACX,KAAK;oBACL,IAAI;oBACJ,KAAK,EAAG,IAAI;oBACZ,KAAK;oBACL,KAAK,EAAG,EAAE;oBACV,KAAK,EAAG,CAAC;iBACV,CAAC,CAAC,CAAC;YACN,CAAC,EAED,OAAO,GAAG,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EACzE,IAAI,GAAG,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YAEzC,IAAI;gBACF,IAAA,iBAAS,EAAC;oBACR,QAAQ,EAAE,IAAI;oBACd,WAAW;oBACX,IAAI;oBACJ,KAAK;iBACN,CAAC,CAAC,IAAI,CAAC,CAAC,GAAuB,EAAE,EAAE;oBAClC,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;oBAEzB,IACE,OAAO,GAAG,EAAE,EACZ,KAAK,GAAG,CAAC,CAAC;oBAEZ,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;wBACrC,OAAO,GAAG,QAAQ,CAAC;qBACpB;yBAAM;wBACL,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;wBAC/B,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;qBAC5B;oBAED,SAAS,CAAC,WAAW,CAAC;wBACpB,QAAQ;wBACR,UAAU;wBACV,YAAY;wBACZ,WAAW;wBACX,KAAK;wBACL,IAAI;wBACJ,KAAK,EAAG,KAAK;wBACb,KAAK;wBACL,KAAK,EAAG,OAAO;wBACf,KAAK;qBACN,CAAC,CAAC,CAAC;gBACN,CAAC,CAAC;oBACA,KAAK,CAAC,GAAG,EAAE;oBACT,WAAW,EAAE,CAAC;gBAChB,CAAC,CAAC,CAAC;aACN;YAAC,OAAO,GAAG,EAAE;gBACZ,WAAW,EAAE,CAAC;aACf;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC;AAEJ,kBAAe,mBAAmB,CAAC"}
|
package/lib/reducerItemData.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
type FetchItemDataFulFilledProps = {
|
|
2
|
-
payload: {
|
|
3
|
-
Data: any;
|
|
4
|
-
};
|
|
5
|
-
meta: {
|
|
6
|
-
id: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
declare const fetchItemDataPending: (state: any, { meta: { id, }, }: {
|
|
10
|
-
meta: {
|
|
11
|
-
id: string;
|
|
12
|
-
};
|
|
13
|
-
}) => any, fetchItemDataRejected: (state: any, { meta: { id, }, }: {
|
|
14
|
-
meta: {
|
|
15
|
-
id: string;
|
|
16
|
-
};
|
|
17
|
-
}) => any, fetchItemDataFulFilled: (state: any, { payload: { Data, }, meta: { id, }, }: FetchItemDataFulFilledProps) => any;
|
|
18
|
-
export { fetchItemDataPending, fetchItemDataRejected, fetchItemDataFulFilled };
|
package/lib/reducerItemData.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.fetchItemDataFulFilled = exports.fetchItemDataRejected = exports.fetchItemDataPending = void 0;
|
|
27
|
-
const Immutable = __importStar(require("immutable"));
|
|
28
|
-
const defaultOptions = Immutable.Map({
|
|
29
|
-
fetching: true,
|
|
30
|
-
fetched: false,
|
|
31
|
-
error: false,
|
|
32
|
-
}), fetchItemDataPending = (state, { meta: { id, }, }) => (state.update(id, (current) => {
|
|
33
|
-
if (typeof current === "undefined") {
|
|
34
|
-
return defaultOptions;
|
|
35
|
-
}
|
|
36
|
-
return current.mergeDeep(defaultOptions);
|
|
37
|
-
})), fetchItemDataRejected = (state, { meta: { id, }, }) => state.update(id, (current) => {
|
|
38
|
-
if (typeof current === "undefined") {
|
|
39
|
-
return current;
|
|
40
|
-
}
|
|
41
|
-
return current.mergeDeep(Immutable.Map({
|
|
42
|
-
fetching: false,
|
|
43
|
-
fetched: false,
|
|
44
|
-
error: true,
|
|
45
|
-
}));
|
|
46
|
-
}), fetchItemDataFulFilled = (state, { payload: { Data, }, meta: { id, }, }) => state.update(id, (current) => {
|
|
47
|
-
if (typeof current === "undefined") {
|
|
48
|
-
return current;
|
|
49
|
-
}
|
|
50
|
-
return current.mergeDeep(Immutable.Map({
|
|
51
|
-
Data,
|
|
52
|
-
fetching: false,
|
|
53
|
-
fetched: true,
|
|
54
|
-
error: false,
|
|
55
|
-
}));
|
|
56
|
-
});
|
|
57
|
-
exports.fetchItemDataPending = fetchItemDataPending;
|
|
58
|
-
exports.fetchItemDataRejected = fetchItemDataRejected;
|
|
59
|
-
exports.fetchItemDataFulFilled = fetchItemDataFulFilled;
|
|
60
|
-
//# sourceMappingURL=reducerItemData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reducerItemData.js","sourceRoot":"","sources":["../src/reducerItemData.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,qDAAuC;AAEvC,MACE,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC;IAC7B,QAAQ,EAAG,IAAI;IACf,OAAO,EAAI,KAAK;IAChB,KAAK,EAAM,KAAK;CACjB,CAAC,EAEF,oBAAoB,GAAG,CAAC,KAAU,EAAE,EAClC,IAAI,E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State, RequestPageAction, ReceivePageAction, ChangeViewAction, ItemsState } from "./types";
|
|
3
|
-
declare const requestPage: (state: PagesState, action: RequestPageAction) => any, receivePage: (state: PagesState, action: ReceivePageAction) => any, performChangeView: (state: PagesState, action: any, view: number) => any, changeView: (state: PagesState, action: ChangeViewAction) => any, resetView: (state: PagesState, action: Action) => any, receivePageItems: (state: ItemsState, action: ReceivePageAction) => any;
|
|
4
|
-
export { requestPage, receivePage, performChangeView, changeView, resetView, receivePageItems };
|
package/lib/reducerOperations.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.receivePageItems = exports.resetView = exports.changeView = exports.performChangeView = exports.receivePage = exports.requestPage = void 0;
|
|
27
|
-
const Immutable = __importStar(require("immutable"));
|
|
28
|
-
const requestPage = (state, action) => {
|
|
29
|
-
const { payload: { token, page } } = action,
|
|
30
|
-
// it is the type any because ts apparently has a problem
|
|
31
|
-
elements = Immutable.Map({
|
|
32
|
-
page,
|
|
33
|
-
error: false,
|
|
34
|
-
fetching: true,
|
|
35
|
-
fetched: false,
|
|
36
|
-
});
|
|
37
|
-
if (state.has(token)) {
|
|
38
|
-
return state.update(token, (current) => current.merge(elements));
|
|
39
|
-
}
|
|
40
|
-
const init = elements.merge({
|
|
41
|
-
view: 1,
|
|
42
|
-
token,
|
|
43
|
-
ids: Immutable.List(),
|
|
44
|
-
});
|
|
45
|
-
return state.set(token, init);
|
|
46
|
-
}, receivePage = (state, action) => {
|
|
47
|
-
const { meta: { idKey, }, payload: { token, items, total, error, }, } = action;
|
|
48
|
-
if (state.has(token)) {
|
|
49
|
-
const hasError = error === true;
|
|
50
|
-
return state.update(token, ((current) => current.update((page) => current.merge(Immutable.Map({
|
|
51
|
-
ids: page.get("ids").concat(Immutable.List(items.map((item) => String(item[idKey])))),
|
|
52
|
-
fetching: false,
|
|
53
|
-
error: hasError,
|
|
54
|
-
fetched: true,
|
|
55
|
-
total: hasError ? page.get("total") : total,
|
|
56
|
-
})))));
|
|
57
|
-
}
|
|
58
|
-
return state;
|
|
59
|
-
}, performChangeView = (state, action, view) => {
|
|
60
|
-
const { payload: { token, }, } = action, item = state.get(token);
|
|
61
|
-
if (typeof item === "undefined") {
|
|
62
|
-
return state;
|
|
63
|
-
}
|
|
64
|
-
return state.update(token, (current) => current.set("view", view));
|
|
65
|
-
}, changeView = (state, action) => (performChangeView(state, action, action.payload.view)), resetView = (state, action) => performChangeView(state, action, 1), receivePageItems = (state, action) => {
|
|
66
|
-
const { payload, meta } = action, { items: payloadItems } = payload, { idKey, manageEntity } = meta, manage = typeof manageEntity === "function" ? manageEntity : ((item) => Immutable.Map(item)), newItems = payloadItems.reduce((previous, item) => (previous.set(String(item[idKey]), manage(item, state, idKey))), Immutable.Map());
|
|
67
|
-
return state.merge(newItems);
|
|
68
|
-
};
|
|
69
|
-
exports.requestPage = requestPage;
|
|
70
|
-
exports.receivePage = receivePage;
|
|
71
|
-
exports.performChangeView = performChangeView;
|
|
72
|
-
exports.changeView = changeView;
|
|
73
|
-
exports.resetView = resetView;
|
|
74
|
-
exports.receivePageItems = receivePageItems;
|
|
75
|
-
//# sourceMappingURL=reducerOperations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reducerOperations.js","sourceRoot":"","sources":["../src/reducerOperations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AAIvC,MAAM,WAAW,GAAG,CAAC,KAAiB,EAAE,MAAyB,EAAE,EAAE;IACjE,MACE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM;IACrC,yDAAyD;IACzD,QAAQ,GAAS,SAAS,CAAC,GAAG,CAAC;QAC7B,IAAI;QACJ,KAAK,EAAM,KAAK;QAChB,QAAQ,EAAG,IAAI;QACf,OAAO,EAAI,KAAK;KACjB,CAAC,CAAC;IAEL,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACpB,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,OAAa,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;KACxE;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC;QAC1B,IAAI,EAAG,CAAC;QACR,KAAK;QACL,GAAG,EAAI,SAAS,CAAC,IAAI,EAAE;KACxB,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC,EACD,WAAW,GAAG,CAAC,KAAiB,E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
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.dataItems = exports.items = exports.pages = void 0;
|
|
27
|
-
const Immutable = __importStar(require("immutable"));
|
|
28
|
-
const actionTypes_1 = require("./actionTypes");
|
|
29
|
-
const reducerItemData = __importStar(require("./reducerItemData"));
|
|
30
|
-
const reducerOperations = __importStar(require("./reducerOperations"));
|
|
31
|
-
const pages = (state = Immutable.Map(), action) => {
|
|
32
|
-
switch (action.type) {
|
|
33
|
-
case actionTypes_1.REQUEST_PAGE:
|
|
34
|
-
return reducerOperations.requestPage(state, action);
|
|
35
|
-
case actionTypes_1.RECEIVE_PAGE:
|
|
36
|
-
return reducerOperations.receivePage(state, action);
|
|
37
|
-
case actionTypes_1.RESET_VIEW:
|
|
38
|
-
return reducerOperations.resetView(state, action);
|
|
39
|
-
case actionTypes_1.CHANGE_VIEW:
|
|
40
|
-
return reducerOperations.changeView(state, action);
|
|
41
|
-
case actionTypes_1.FETCH_CURRENT_COMPANY_INFO_PENDING:
|
|
42
|
-
case actionTypes_1.CLEAR_DATA:
|
|
43
|
-
return state.clear();
|
|
44
|
-
default:
|
|
45
|
-
return state;
|
|
46
|
-
}
|
|
47
|
-
}, items = (state = Immutable.Map(), action) => {
|
|
48
|
-
switch (action.type) {
|
|
49
|
-
case actionTypes_1.RECEIVE_PAGE:
|
|
50
|
-
return reducerOperations.receivePageItems(state, action);
|
|
51
|
-
case actionTypes_1.FETCH_CURRENT_COMPANY_INFO_PENDING:
|
|
52
|
-
case actionTypes_1.CLEAR_DATA:
|
|
53
|
-
return state.clear();
|
|
54
|
-
default:
|
|
55
|
-
return state;
|
|
56
|
-
}
|
|
57
|
-
}, 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.pages = pages, exports.items = items, exports.dataItems = dataItems;
|
|
75
|
-
//# sourceMappingURL=reducers.js.map
|
package/lib/reducers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reducers.js","sourceRoot":"","sources":["../src/reducers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AAGvC,+CAUuB;AAEvB,mEAAqD;AACrD,uEAAyD;AAGlD,MACL,KAAK,GAAG,CAAC,QAAoB,SAAS,CAAC,GAAG,EAAE,EAAE,MAAc,EAAE,EAAE;IAC9D,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,EACD,KAAK,GAAG,CAAC,QAAoB,SAAS,CAAC,GAAG,EAAE,EAAE,MAAc,EAAE,EAAE;IAC9D,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,EACD,SAAS,GAAG,CAAC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