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/src/selectors.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import * as Immutable from "immutable";
|
|
2
|
-
import { createSelector } from "reselect";
|
|
3
|
-
import { State, PagesState } from "./types";
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
pagesSelector = (state: State) => state,
|
|
7
|
-
pageSelector = createSelector(
|
|
8
|
-
pagesSelector,
|
|
9
|
-
(_state: State, token: string) => token,
|
|
10
|
-
(pages: PagesState, token: string) => pages.get(token),
|
|
11
|
-
),
|
|
12
|
-
getAllResults = createSelector(
|
|
13
|
-
pageSelector,
|
|
14
|
-
(_state : State, _token : string, items : any) => items,
|
|
15
|
-
(page : any, items : any) => {
|
|
16
|
-
if (typeof page === "undefined") {
|
|
17
|
-
return Immutable.List();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return page.get("ids").map((id : number) => items.get(String(id)));
|
|
21
|
-
},
|
|
22
|
-
),
|
|
23
|
-
getResultsUpToPage = createSelector(
|
|
24
|
-
pageSelector,
|
|
25
|
-
(_state : State, _token : string, items : any) => items,
|
|
26
|
-
(_state : State, _token : string, _items: any, target: any) => target,
|
|
27
|
-
(_state : State, _token : string, _items : any, _target : any, perPage : number) => (
|
|
28
|
-
perPage
|
|
29
|
-
),
|
|
30
|
-
(page : any, items : any, target : any, perPage : any) => {
|
|
31
|
-
if (typeof page === "undefined") {
|
|
32
|
-
return Immutable.List();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const ids = page.get("ids").slice(0, perPage * target);
|
|
36
|
-
|
|
37
|
-
return ids.map((id : number) => items.get(String(id)));
|
|
38
|
-
}),
|
|
39
|
-
getCurrentTotalResultsCount = createSelector(
|
|
40
|
-
pageSelector,
|
|
41
|
-
(page : any) => {
|
|
42
|
-
if (typeof page === "undefined") {
|
|
43
|
-
return 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return page.get("total");
|
|
47
|
-
}),
|
|
48
|
-
isPageFetching = createSelector(
|
|
49
|
-
pageSelector,
|
|
50
|
-
(_state : State, _token : string, target : any) => target,
|
|
51
|
-
(page : any, target : any) => {
|
|
52
|
-
if (typeof page === "undefined") {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return page.get("fetching") && target === page.get("page");
|
|
57
|
-
}),
|
|
58
|
-
isPageFetched = createSelector(
|
|
59
|
-
pageSelector,
|
|
60
|
-
(_state : State, _token : string, target : any) => target,
|
|
61
|
-
(page : any, target : any) => {
|
|
62
|
-
if (typeof page === "undefined") {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return page.get("fetched") && target <= page.get("page");
|
|
67
|
-
}),
|
|
68
|
-
hasPageProblems = createSelector(
|
|
69
|
-
pageSelector,
|
|
70
|
-
(page : any) => {
|
|
71
|
-
if (typeof page === "undefined") {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return page.get("error");
|
|
76
|
-
}),
|
|
77
|
-
getCurrentView = createSelector(
|
|
78
|
-
pageSelector,
|
|
79
|
-
(page : any) => {
|
|
80
|
-
if (typeof page === "undefined") {
|
|
81
|
-
return 1;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return page.get("view");
|
|
85
|
-
}),
|
|
86
|
-
|
|
87
|
-
// these selectors are used for the entire app
|
|
88
|
-
getPaginatorPaginations = (state: any, name: string) => state.getIn(["paginations", name]),
|
|
89
|
-
getPaginatorEntities = (state: any, name: string) => state.getIn(["entities", name]),
|
|
90
|
-
getPaginators = createSelector(
|
|
91
|
-
getPaginatorPaginations,
|
|
92
|
-
getPaginatorEntities,
|
|
93
|
-
(list : any, entities : any) => ({
|
|
94
|
-
list,
|
|
95
|
-
entities,
|
|
96
|
-
}),
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
export default {
|
|
100
|
-
getAllResults,
|
|
101
|
-
getCurrentTotalResultsCount,
|
|
102
|
-
getResultsUpToPage,
|
|
103
|
-
isPageFetching,
|
|
104
|
-
isPageFetched,
|
|
105
|
-
hasPageProblems,
|
|
106
|
-
getCurrentView,
|
|
107
|
-
// for state
|
|
108
|
-
getPaginatorPaginations,
|
|
109
|
-
getPaginatorEntities,
|
|
110
|
-
getPaginators,
|
|
111
|
-
};
|
package/src/types.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
export type PagesState = any;
|
|
2
|
-
export type ItemsState = any;
|
|
3
|
-
export type State = {
|
|
4
|
-
readonly pages: PagesState;
|
|
5
|
-
readonly itemsReducer: ItemsState;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export type GetState = () => State;
|
|
10
|
-
export type PromiseAction = Promise<Action>;
|
|
11
|
-
export type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;
|
|
12
|
-
export type Dispatch = (action: Action | ThunkAction | PromiseAction | Array<Action>) => any;
|
|
13
|
-
export type EndPointCb = ((token?: string) => string) | null;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export type PaginatorSettings = {
|
|
17
|
-
key: string;
|
|
18
|
-
manageEntity: any;
|
|
19
|
-
resultsKey: string;
|
|
20
|
-
// by default 25 per page
|
|
21
|
-
rowsPerLoad?: number;
|
|
22
|
-
// by default "(items) => items"
|
|
23
|
-
manipulateItems?: (items: any) => any;
|
|
24
|
-
// by default "Total"
|
|
25
|
-
totalKey?: string;
|
|
26
|
-
// by default "page"
|
|
27
|
-
pageArgName?: string;
|
|
28
|
-
// default "ID"
|
|
29
|
-
idKey?: string;
|
|
30
|
-
|
|
31
|
-
dataItemURL?: string;
|
|
32
|
-
normalizeDataItem?: any;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// actions
|
|
37
|
-
|
|
38
|
-
export type RequestPageAction = {
|
|
39
|
-
type: "@@redux-paginator-immutable/REQUEST_PAGE";
|
|
40
|
-
meta: {
|
|
41
|
-
endpoint: string;
|
|
42
|
-
endpointCb: EndPointCb;
|
|
43
|
-
manageEntity: any;
|
|
44
|
-
resultsKey: string;
|
|
45
|
-
totalKey: string;
|
|
46
|
-
pageArgName: string;
|
|
47
|
-
idKey: string;
|
|
48
|
-
};
|
|
49
|
-
payload: {
|
|
50
|
-
page: number;
|
|
51
|
-
token: string;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
export type ReceivePageAction = {
|
|
55
|
-
type: "@@redux-paginator-immutable/RECEIVE_PAGE";
|
|
56
|
-
meta: {
|
|
57
|
-
endpoint: string;
|
|
58
|
-
endpointCb: EndPointCb;
|
|
59
|
-
manageEntity: any;
|
|
60
|
-
pageArgName: string;
|
|
61
|
-
idKey: string;
|
|
62
|
-
};
|
|
63
|
-
payload: {
|
|
64
|
-
page: number;
|
|
65
|
-
token: string;
|
|
66
|
-
items: Array<any>;
|
|
67
|
-
total: number;
|
|
68
|
-
error: boolean;
|
|
69
|
-
raw?: string;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
export type ChangeViewAction = {
|
|
73
|
-
type: "@@redux-paginator-immutable/CHANGE_VIEW";
|
|
74
|
-
meta: {
|
|
75
|
-
endpoint: string;
|
|
76
|
-
};
|
|
77
|
-
payload: {
|
|
78
|
-
view: number;
|
|
79
|
-
token: string;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
export type ResetViewAction = {
|
|
83
|
-
type: "@@redux-paginator-immutable/RESET_VIEW";
|
|
84
|
-
meta: {
|
|
85
|
-
endpoint: string;
|
|
86
|
-
};
|
|
87
|
-
payload: {
|
|
88
|
-
token: string;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
export type ClearDataAction = {
|
|
92
|
-
type: "@@redux-paginator-immutable/CLEAR_DATA";
|
|
93
|
-
meta: {
|
|
94
|
-
endpoint: string;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
export type FetchCurrentCompanyInfoPending = {
|
|
98
|
-
type: "FETCH_CURRENT_COMPANY_INFO_PENDING";
|
|
99
|
-
};
|
|
100
|
-
export type FetchItemDataPending = {
|
|
101
|
-
type: "@@redux-paginator-immutable/FETCH_ITEM_DATA_PENDING";
|
|
102
|
-
meta: {
|
|
103
|
-
id: string;
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
export type FetchItemDataRejected = {
|
|
107
|
-
type: "@@redux-paginator-immutable/FETCH_ITEM_DATA_REJECTED";
|
|
108
|
-
meta: {
|
|
109
|
-
id: string;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
export type FetchItemDataFulFilled = {
|
|
113
|
-
type: "@@redux-paginator-immutable/FETCH_ITEM_DATA_FULFILLED";
|
|
114
|
-
payload: {
|
|
115
|
-
Data: any;
|
|
116
|
-
};
|
|
117
|
-
meta: {
|
|
118
|
-
id: string;
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
export type Action =
|
|
122
|
-
RequestPageAction |
|
|
123
|
-
ReceivePageAction |
|
|
124
|
-
ResetViewAction |
|
|
125
|
-
ChangeViewAction |
|
|
126
|
-
ClearDataAction |
|
|
127
|
-
FetchCurrentCompanyInfoPending |
|
|
128
|
-
FetchItemDataPending |
|
|
129
|
-
FetchItemDataRejected |
|
|
130
|
-
FetchItemDataFulFilled;
|
package/src/util.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-duplicate-imports */
|
|
2
|
-
type NormalizrEntity = (data: any) => any;
|
|
3
|
-
|
|
4
|
-
import type { Map as ImmutableMap } from "immutable";
|
|
5
|
-
import * as Immutable from "immutable";
|
|
6
|
-
import { createSelector } from "reselect";
|
|
7
|
-
|
|
8
|
-
type ManageDataEntity = ImmutableMap<string, any>;
|
|
9
|
-
|
|
10
|
-
// simple item
|
|
11
|
-
const
|
|
12
|
-
manageEntity = (normalizrEntity: NormalizrEntity) => (
|
|
13
|
-
(item: any, state: any, keyID: string): ManageDataEntity => {
|
|
14
|
-
// prevent rewrite
|
|
15
|
-
const old = state.get(String(item[keyID]));
|
|
16
|
-
|
|
17
|
-
if (typeof old === "undefined") {
|
|
18
|
-
return Immutable.Map(normalizrEntity(item));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return old;
|
|
22
|
-
}
|
|
23
|
-
),
|
|
24
|
-
manipulateItems = (sortKey = "ID") => createSelector(
|
|
25
|
-
(data : any) => data,
|
|
26
|
-
(data : any) => data.sortBy((current : any) => -current.get(sortKey)),
|
|
27
|
-
),
|
|
28
|
-
|
|
29
|
-
// data item
|
|
30
|
-
manageDataEntity = (normalizrEntity: NormalizrEntity) => (
|
|
31
|
-
(item: any, state: any, keyID: string): ManageDataEntity => {
|
|
32
|
-
// prevent rewrite
|
|
33
|
-
const old = state.get(String(item[keyID]));
|
|
34
|
-
|
|
35
|
-
if (typeof old === "undefined") {
|
|
36
|
-
return Immutable.Map({
|
|
37
|
-
Data: normalizrEntity(item),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return old;
|
|
42
|
-
}
|
|
43
|
-
),
|
|
44
|
-
manipulateDataItems = (sortKey = "ID") => (
|
|
45
|
-
createSelector(
|
|
46
|
-
(data : any) => data,
|
|
47
|
-
(data : any) => data.sortBy((current : any) => -current.getIn(["Data", sortKey])),
|
|
48
|
-
)
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
export { manageDataEntity, manipulateDataItems, manipulateItems, manageEntity };
|