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.
Files changed (84) hide show
  1. package/package.json +19 -16
  2. package/README.md +0 -3
  3. package/lib/Info.d.ts +0 -9
  4. package/lib/Info.js +0 -18
  5. package/lib/Info.js.map +0 -1
  6. package/lib/LoadDataItem.d.ts +0 -25
  7. package/lib/LoadDataItem.js +0 -60
  8. package/lib/LoadDataItem.js.map +0 -1
  9. package/lib/LoadPaginator.d.ts +0 -4
  10. package/lib/LoadPaginator.js +0 -79
  11. package/lib/LoadPaginator.js.map +0 -1
  12. package/lib/LoadPaginatorTypes.d.ts +0 -29
  13. package/lib/LoadPaginatorTypes.js +0 -3
  14. package/lib/LoadPaginatorTypes.js.map +0 -1
  15. package/lib/LoadingButton.d.ts +0 -8
  16. package/lib/LoadingButton.js +0 -26
  17. package/lib/LoadingButton.js.map +0 -1
  18. package/lib/actionTypes.d.ts +0 -9
  19. package/lib/actionTypes.js +0 -13
  20. package/lib/actionTypes.js.map +0 -1
  21. package/lib/actions.d.ts +0 -42
  22. package/lib/actions.js +0 -82
  23. package/lib/actions.js.map +0 -1
  24. package/lib/agent.d.ts +0 -8
  25. package/lib/agent.js +0 -37
  26. package/lib/agent.js.map +0 -1
  27. package/lib/createDataReducer.d.ts +0 -14
  28. package/lib/createDataReducer.js +0 -67
  29. package/lib/createDataReducer.js.map +0 -1
  30. package/lib/createItemReducer.d.ts +0 -9
  31. package/lib/createItemReducer.js +0 -18
  32. package/lib/createItemReducer.js.map +0 -1
  33. package/lib/createPaginator.d.ts +0 -33
  34. package/lib/createPaginator.js +0 -87
  35. package/lib/createPaginator.js.map +0 -1
  36. package/lib/index.d.ts +0 -11
  37. package/lib/index.js +0 -30
  38. package/lib/index.js.map +0 -1
  39. package/lib/paginatorMiddleware.d.ts +0 -5
  40. package/lib/paginatorMiddleware.js +0 -69
  41. package/lib/paginatorMiddleware.js.map +0 -1
  42. package/lib/reducerItemData.d.ts +0 -18
  43. package/lib/reducerItemData.js +0 -60
  44. package/lib/reducerItemData.js.map +0 -1
  45. package/lib/reducerOperations.d.ts +0 -4
  46. package/lib/reducerOperations.js +0 -75
  47. package/lib/reducerOperations.js.map +0 -1
  48. package/lib/reducers.d.ts +0 -2
  49. package/lib/reducers.js +0 -75
  50. package/lib/reducers.js.map +0 -1
  51. package/lib/selectors.d.ts +0 -38
  52. package/lib/selectors.js +0 -83
  53. package/lib/selectors.js.map +0 -1
  54. package/lib/types.d.ts +0 -107
  55. package/lib/types.js +0 -3
  56. package/lib/types.js.map +0 -1
  57. package/lib/util.d.ts +0 -9
  58. package/lib/util.js +0 -53
  59. package/lib/util.js.map +0 -1
  60. package/src/Info.tsx +0 -28
  61. package/src/LoadDataItem.tsx +0 -84
  62. package/src/LoadPaginator.tsx +0 -104
  63. package/src/LoadPaginatorTypes.ts +0 -31
  64. package/src/LoadingButton.tsx +0 -44
  65. package/src/__tests__/actions.spec.js +0 -130
  66. package/src/__tests__/agent.spec.js +0 -32
  67. package/src/__tests__/createPaginator.spec.js +0 -39
  68. package/src/__tests__/reducers.spec.js +0 -131
  69. package/src/__tests__/selectors.spec.js +0 -180
  70. package/src/__tests__/setup.js +0 -1
  71. package/src/actionTypes.ts +0 -9
  72. package/src/actions.ts +0 -156
  73. package/src/agent.ts +0 -62
  74. package/src/createDataReducer.ts +0 -90
  75. package/src/createItemReducer.ts +0 -29
  76. package/src/createPaginator.ts +0 -104
  77. package/src/index.ts +0 -26
  78. package/src/paginatorMiddleware.ts +0 -93
  79. package/src/reducerItemData.ts +0 -74
  80. package/src/reducerOperations.ts +0 -92
  81. package/src/reducers.ts +0 -77
  82. package/src/selectors.ts +0 -111
  83. package/src/types.ts +0 -130
  84. package/src/util.ts +0 -51
@@ -1,38 +0,0 @@
1
- import { State } from "./types";
2
- declare const _default: {
3
- getAllResults: ((state: State, _token: string, items: any) => any) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any) => any> & {
4
- clearCache: () => void;
5
- };
6
- getCurrentTotalResultsCount: ((state: State, token: string) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
7
- clearCache: () => void;
8
- };
9
- getResultsUpToPage: ((state: State, _token: string, _items: any, _target: any, perPage: number) => any) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any, args_2: any, args_3: number) => any> & {
10
- clearCache: () => void;
11
- };
12
- isPageFetching: ((state: State, _token: string, target: any) => any) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any) => any> & {
13
- clearCache: () => void;
14
- };
15
- isPageFetched: ((state: State, _token: string, target: any) => any) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any) => any> & {
16
- clearCache: () => void;
17
- };
18
- hasPageProblems: ((state: State, token: string) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
19
- clearCache: () => void;
20
- };
21
- getCurrentView: ((state: State, token: string) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
22
- clearCache: () => void;
23
- };
24
- getPaginatorPaginations: (state: any, name: string) => any;
25
- getPaginatorEntities: (state: any, name: string) => any;
26
- getPaginators: ((state: any, name: string) => {
27
- list: any;
28
- entities: any;
29
- }) & import("reselect").OutputSelectorFields<(args_0: any, args_1: any) => {
30
- list: any;
31
- entities: any;
32
- } & {
33
- clearCache: () => void;
34
- }> & {
35
- clearCache: () => void;
36
- };
37
- };
38
- export default _default;
package/lib/selectors.js DELETED
@@ -1,83 +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 Immutable = __importStar(require("immutable"));
27
- const reselect_1 = require("reselect");
28
- const pagesSelector = (state) => state, 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) => {
29
- if (typeof page === "undefined") {
30
- return Immutable.List();
31
- }
32
- return page.get("ids").map((id) => items.get(String(id)));
33
- }), getResultsUpToPage = (0, reselect_1.createSelector)(pageSelector, (_state, _token, items) => items, (_state, _token, _items, target) => target, (_state, _token, _items, _target, perPage) => (perPage), (page, items, target, perPage) => {
34
- if (typeof page === "undefined") {
35
- return Immutable.List();
36
- }
37
- const ids = page.get("ids").slice(0, perPage * target);
38
- return ids.map((id) => items.get(String(id)));
39
- }), getCurrentTotalResultsCount = (0, reselect_1.createSelector)(pageSelector, (page) => {
40
- if (typeof page === "undefined") {
41
- return 0;
42
- }
43
- return page.get("total");
44
- }), isPageFetching = (0, reselect_1.createSelector)(pageSelector, (_state, _token, target) => target, (page, target) => {
45
- if (typeof page === "undefined") {
46
- return false;
47
- }
48
- return page.get("fetching") && target === page.get("page");
49
- }), isPageFetched = (0, reselect_1.createSelector)(pageSelector, (_state, _token, target) => target, (page, target) => {
50
- if (typeof page === "undefined") {
51
- return false;
52
- }
53
- return page.get("fetched") && target <= page.get("page");
54
- }), hasPageProblems = (0, reselect_1.createSelector)(pageSelector, (page) => {
55
- if (typeof page === "undefined") {
56
- return false;
57
- }
58
- return page.get("error");
59
- }), getCurrentView = (0, reselect_1.createSelector)(pageSelector, (page) => {
60
- if (typeof page === "undefined") {
61
- return 1;
62
- }
63
- return page.get("view");
64
- }),
65
- // these selectors are used for the entire app
66
- getPaginatorPaginations = (state, name) => state.getIn(["paginations", name]), getPaginatorEntities = (state, name) => state.getIn(["entities", name]), getPaginators = (0, reselect_1.createSelector)(getPaginatorPaginations, getPaginatorEntities, (list, entities) => ({
67
- list,
68
- entities,
69
- }));
70
- exports.default = {
71
- getAllResults,
72
- getCurrentTotalResultsCount,
73
- getResultsUpToPage,
74
- isPageFetching,
75
- isPageFetched,
76
- hasPageProblems,
77
- getCurrentView,
78
- // for state
79
- getPaginatorPaginations,
80
- getPaginatorEntities,
81
- getPaginators,
82
- };
83
- //# sourceMappingURL=selectors.js.map
@@ -1 +0,0 @@
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,EACvC,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,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AA,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"}
package/lib/types.d.ts DELETED
@@ -1,107 +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
- export type GetState = () => State;
8
- export type PromiseAction = Promise<Action>;
9
- export type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;
10
- export type Dispatch = (action: Action | ThunkAction | PromiseAction | Array<Action>) => any;
11
- export type EndPointCb = ((token?: string) => string) | null;
12
- export type PaginatorSettings = {
13
- key: string;
14
- manageEntity: any;
15
- resultsKey: string;
16
- rowsPerLoad?: number;
17
- manipulateItems?: (items: any) => any;
18
- totalKey?: string;
19
- pageArgName?: string;
20
- idKey?: string;
21
- dataItemURL?: string;
22
- normalizeDataItem?: any;
23
- };
24
- export type RequestPageAction = {
25
- type: "@@redux-paginator-immutable/REQUEST_PAGE";
26
- meta: {
27
- endpoint: string;
28
- endpointCb: EndPointCb;
29
- manageEntity: any;
30
- resultsKey: string;
31
- totalKey: string;
32
- pageArgName: string;
33
- idKey: string;
34
- };
35
- payload: {
36
- page: number;
37
- token: string;
38
- };
39
- };
40
- export type ReceivePageAction = {
41
- type: "@@redux-paginator-immutable/RECEIVE_PAGE";
42
- meta: {
43
- endpoint: string;
44
- endpointCb: EndPointCb;
45
- manageEntity: any;
46
- pageArgName: string;
47
- idKey: string;
48
- };
49
- payload: {
50
- page: number;
51
- token: string;
52
- items: Array<any>;
53
- total: number;
54
- error: boolean;
55
- raw?: string;
56
- };
57
- };
58
- export type ChangeViewAction = {
59
- type: "@@redux-paginator-immutable/CHANGE_VIEW";
60
- meta: {
61
- endpoint: string;
62
- };
63
- payload: {
64
- view: number;
65
- token: string;
66
- };
67
- };
68
- export type ResetViewAction = {
69
- type: "@@redux-paginator-immutable/RESET_VIEW";
70
- meta: {
71
- endpoint: string;
72
- };
73
- payload: {
74
- token: string;
75
- };
76
- };
77
- export type ClearDataAction = {
78
- type: "@@redux-paginator-immutable/CLEAR_DATA";
79
- meta: {
80
- endpoint: string;
81
- };
82
- };
83
- export type FetchCurrentCompanyInfoPending = {
84
- type: "FETCH_CURRENT_COMPANY_INFO_PENDING";
85
- };
86
- export type FetchItemDataPending = {
87
- type: "@@redux-paginator-immutable/FETCH_ITEM_DATA_PENDING";
88
- meta: {
89
- id: string;
90
- };
91
- };
92
- export type FetchItemDataRejected = {
93
- type: "@@redux-paginator-immutable/FETCH_ITEM_DATA_REJECTED";
94
- meta: {
95
- id: string;
96
- };
97
- };
98
- export type FetchItemDataFulFilled = {
99
- type: "@@redux-paginator-immutable/FETCH_ITEM_DATA_FULFILLED";
100
- payload: {
101
- Data: any;
102
- };
103
- meta: {
104
- id: string;
105
- };
106
- };
107
- export type Action = RequestPageAction | ReceivePageAction | ResetViewAction | ChangeViewAction | ClearDataAction | FetchCurrentCompanyInfoPending | FetchItemDataPending | FetchItemDataRejected | FetchItemDataFulFilled;
package/lib/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/lib/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/lib/util.d.ts DELETED
@@ -1,9 +0,0 @@
1
- type NormalizrEntity = (data: any) => any;
2
- import type { Map as ImmutableMap } from "immutable";
3
- type ManageDataEntity = ImmutableMap<string, any>;
4
- declare const manageEntity: (normalizrEntity: NormalizrEntity) => (item: any, state: any, keyID: string) => ManageDataEntity, manipulateItems: (sortKey?: string) => ((state: any) => 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) => any) & import("reselect").OutputSelectorFields<(args_0: any) => any> & {
7
- clearCache: () => void;
8
- };
9
- export { manageDataEntity, manipulateDataItems, manipulateItems, manageEntity };
package/lib/util.js DELETED
@@ -1,53 +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.manageEntity = exports.manipulateItems = exports.manipulateDataItems = exports.manageDataEntity = void 0;
27
- const Immutable = __importStar(require("immutable"));
28
- const reselect_1 = require("reselect");
29
- // simple item
30
- const manageEntity = (normalizrEntity) => ((item, state, keyID) => {
31
- // prevent rewrite
32
- const old = state.get(String(item[keyID]));
33
- if (typeof old === "undefined") {
34
- return Immutable.Map(normalizrEntity(item));
35
- }
36
- return old;
37
- }), manipulateItems = (sortKey = "ID") => (0, reselect_1.createSelector)((data) => data, (data) => data.sortBy((current) => -current.get(sortKey))),
38
- // data item
39
- manageDataEntity = (normalizrEntity) => ((item, state, keyID) => {
40
- // prevent rewrite
41
- const old = state.get(String(item[keyID]));
42
- if (typeof old === "undefined") {
43
- return Immutable.Map({
44
- Data: normalizrEntity(item),
45
- });
46
- }
47
- return old;
48
- }), manipulateDataItems = (sortKey = "ID") => ((0, reselect_1.createSelector)((data) => data, (data) => data.sortBy((current) => -current.getIn(["Data", sortKey]))));
49
- exports.manageEntity = manageEntity;
50
- exports.manipulateItems = manipulateItems;
51
- exports.manageDataEntity = manageDataEntity;
52
- exports.manipulateDataItems = manipulateDataItems;
53
- //# sourceMappingURL=util.js.map
package/lib/util.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,qDAAuC;AACvC,uCAA0C;AAI1C,cAAc;AACd,MACE,YAAY,GAAG,CAAC,eAAgC,EAAE,EAAE,CAAC,CACnD,CAAC,IAAS,EAAE,KAAU,EAAE,KAAa,EAAoB,EAAE;IACzD,kBAAkB;IAClB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3C,IAAI,OAAO,GAAG,KAAK,WAAW,EAAE;QAC9B,OAAO,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;KAC7C;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CACF,EACD,eAAe,GAAG,CAAC,OAAO,GAAG,IAAI,EAAE,EAAE,CAAC,IAAA,yBAAc,EAClD,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,EACpB,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAa,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CACtE;AAED,YAAY;AACZ,gBAAgB,GAAG,CAAC,eAAgC,EAAE,EAAE,CAAC,CACvD,CAAC,IAAS,EAAE,KAAU,EAAE,KAAa,EAAoB,EAAE;IACzD,kBAAkB;IAClB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3C,IAAI,OAAO,GAAG,KAAK,WAAW,EAAE;QAC9B,OAAO,SAAS,CAAC,GAAG,CAAC;YACnB,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;SAC5B,CAAC,CAAC;KACJ;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CACF,EACD,mBAAmB,GAAG,CAAC,OAAO,GAAG,IAAI,EAAE,EAAE,CAAC,CACxC,IAAA,yBAAc,EACZ,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,EACpB,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAa,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAClF,CACF,CAAC;AAE6D,oCAAY;AAA7B,0CAAe;AAAtD,4CAAgB;AAAE,kDAAmB"}
package/src/Info.tsx DELETED
@@ -1,28 +0,0 @@
1
- type InfoPropTypes = {
2
- shown: number;
3
- total: number;
4
- one: string;
5
- all: string;
6
- };
7
-
8
- import React from "react";
9
- import { words } from "x25/utility";
10
-
11
- const
12
- getNumberForm = (value: number, one: string, all: string): string => {
13
- if (value === 1) {
14
- return `1 ${one}`;
15
- }
16
-
17
- return `${words.getNumberTense(value)} ${all}`;
18
- },
19
-
20
- Info = ({ shown, total, one, all }: InfoPropTypes) => (
21
- <div className="text-muted">
22
- {`${words.Showing} `}
23
- {shown === total ? `${words.All} - ` : `${shown} ${words.Of}`}
24
- {` ${getNumberForm(total, one, all)}`}
25
- </div>
26
- );
27
-
28
- export default Info;
@@ -1,84 +0,0 @@
1
- import * as React from "react";
2
-
3
- type LoadDataItemPropTypes = {
4
- isFetching: boolean;
5
- fetched: boolean;
6
- id: string;
7
- hasError: boolean;
8
- data: any;
9
- children: React.ReactNode;
10
- shouldFetch: any;
11
- fetchItem: () => void;
12
- };
13
- type OwnProps = {
14
- id: string;
15
- settings: {
16
- selectors: any;
17
- dataItemURL: string;
18
- endpoint: string;
19
- manageEntity: any;
20
- normalizeDataItem: any;
21
- };
22
- };
23
- import { connect } from "react-redux";
24
- import { LargeErrorMessage, LoadingMessage } from "x25/Messages";
25
- import { words } from "x25/utility";
26
- import { fetchItem as fetchItemAction } from "./actions";
27
-
28
- const
29
- mapStateToProps = (state: any, {
30
- settings: {
31
- selectors,
32
- },
33
- id,
34
- }: OwnProps) => ({
35
- data : selectors.getItem(state, id),
36
- hasError : selectors.getItemHasError(state, id),
37
- fetched : selectors.getItemIsFetched(state, id),
38
- isFetching : selectors.getIsFetchingItemInfo(state, id),
39
- shouldFetch : selectors.getShouldFetchItemInfo(state, id),
40
- }),
41
- mapDispatchToProps = (dispatch: any, {
42
- id,
43
- settings,
44
- }: OwnProps) => ({
45
- fetchItem () {
46
- dispatch(fetchItemAction({
47
- ...settings,
48
- id,
49
- }));
50
- },
51
- }),
52
-
53
- LoadDataItem = (props: LoadDataItemPropTypes) : any => {
54
- const {
55
- children,
56
- data,
57
- isFetching,
58
- shouldFetch,
59
- hasError,
60
- fetchItem,
61
- } = props;
62
-
63
- React.useEffect(() => {
64
- if (shouldFetch) {
65
- fetchItem();
66
- }
67
- }, [shouldFetch, isFetching, hasError]);
68
-
69
- if (isFetching) {
70
- return <LoadingMessage message={words.LoadingData} />;
71
- }
72
-
73
- if (hasError) {
74
- return <LargeErrorMessage message={words.ThereWasAProblem} onRetry={fetchItem} />;
75
- }
76
-
77
- if (data.size === 0) {
78
- return null;
79
- }
80
-
81
- return children;
82
- };
83
-
84
- export default connect(mapStateToProps, mapDispatchToProps)(LoadDataItem);
@@ -1,104 +0,0 @@
1
- import React, { useEffect } from "react";
2
- import * as Immutable from "immutable";
3
- import { useDispatch, useSelector } from "react-redux";
4
- import { LargeErrorMessage, LoadingMessage } from "x25/Messages";
5
- import { words } from "x25/utility";
6
- import selectors from "./selectors";
7
- import LoadingButton from "./LoadingButton";
8
-
9
- import { ChangeView, List, LoadData, LoadPaginatorPropTypes, ResetView } from "./LoadPaginatorTypes";
10
-
11
- const
12
- LoadPaginator = (props : LoadPaginatorPropTypes) => {
13
- const
14
- { token, settings } = props,
15
-
16
- { list, entities } = useSelector((state : never) => (
17
- selectors.getPaginators(state, settings.key)
18
- )),
19
-
20
- currentPage = selectors.getCurrentView(list, token),
21
- isFetching = selectors.isPageFetching(list, token, currentPage),
22
- isFetched = selectors.isPageFetched(list, token, currentPage),
23
- resultsUpTo = (
24
- selectors.getResultsUpToPage(list, token, entities, currentPage, settings.rowsPerLoad)
25
- ),
26
- items = settings.manipulateItems(resultsUpTo),
27
- total = selectors.getCurrentTotalResultsCount(list, token),
28
- hasProblems = selectors.hasPageProblems(list, token),
29
-
30
- paginator = Immutable.Map({
31
- currentPage,
32
- hasProblems,
33
- isFetched,
34
- isFetching,
35
- items,
36
- total,
37
- }),
38
-
39
- dispatch = useDispatch(),
40
- resetView : ResetView = (currentToken) => dispatch(settings.resetView(currentToken)),
41
- changeView : ChangeView = (data) => dispatch(settings.changeView(data)),
42
- loadData : LoadData = (page) => dispatch(settings.requestPage(page, token)),
43
-
44
- showLoading = paginator.get("total") !== items.size,
45
-
46
- shouldFetch = !isFetched && !isFetching,
47
- handleLoadMoreClick = () => {
48
- if (hasProblems) {
49
- loadData(currentPage);
50
- } else {
51
- changeView({
52
- token,
53
- view: currentPage + 1,
54
- });
55
- }
56
- };
57
-
58
- useEffect(() => {
59
- if (shouldFetch) {
60
- loadData(currentPage);
61
- }
62
- }, [shouldFetch]);
63
-
64
- useEffect(() => () => resetView(token), []);
65
-
66
- if (items.size === 0 && isFetching) {
67
- return <LoadingMessage message={words.LoadingData} />;
68
- }
69
-
70
- if (hasProblems && currentPage === 1) {
71
- return (
72
- <LargeErrorMessage
73
- message={words.ThereWasAProblem}
74
- onRetry={handleLoadMoreClick}
75
- />
76
- );
77
- }
78
-
79
- return (
80
- <>
81
- {
82
- React.cloneElement(props.children as React.ReactElement<List>, {
83
- token : props.token,
84
- settings : props.settings,
85
- paginator,
86
- changeView,
87
- resetView,
88
- loadData,
89
- })
90
- }
91
- {
92
- showLoading ? (
93
- <LoadingButton
94
- hasProblems={hasProblems}
95
- isFetching={isFetching}
96
- onLoadMoreClick={handleLoadMoreClick}
97
- />
98
- ) : null
99
- }
100
- </>
101
- );
102
- };
103
-
104
- export default LoadPaginator;
@@ -1,31 +0,0 @@
1
- type Settings = {
2
- key: string;
3
- rowsPerLoad: number;
4
- manipulateItems: (items: any) => any;
5
- resetView: (data: any) => any;
6
- changeView: (data: any) => any;
7
- requestPage: (page: number, token: string) => any;
8
- };
9
- export type LoadPaginatorPropTypes = {
10
- token: string;
11
- settings: Settings;
12
- children: JSX.Element;
13
- };
14
-
15
- export type ChangeView = (info: {
16
- token: string;
17
- view: number;
18
- }) => any;
19
-
20
- export type ResetView = (token: string) => any;
21
-
22
- export type LoadData = (page: number) => any;
23
-
24
- export type List = {
25
- token: string;
26
- settings: Settings;
27
- paginator: any;
28
- changeView: ChangeView;
29
- resetView: ResetView;
30
- loadData: LoadData;
31
- }
@@ -1,44 +0,0 @@
1
- import React from "react";
2
- import { ErrorMessage, LoadingMessage } from "x25/Messages";
3
- import { useInView } from "react-intersection-observer";
4
-
5
- type LoadingButtonPropTypes = {
6
- isFetching: boolean;
7
- hasProblems: boolean;
8
- onLoadMoreClick: () => void;
9
- };
10
- import { words } from "x25/utility";
11
-
12
- const LoadingButton = (props : LoadingButtonPropTypes) => {
13
- const
14
- { isFetching, hasProblems, onLoadMoreClick } = props,
15
- [ref, inView] = useInView({
16
- // /* Optional options */
17
- // triggerOnce: true,
18
- // rootMargin: '0px 0px',
19
- });
20
-
21
- React.useEffect(() => {
22
- if (!isFetching && !hasProblems && inView) {
23
- onLoadMoreClick();
24
- }
25
- }, [isFetching, hasProblems, inView]);
26
-
27
- return (
28
- <div className="text-center my-2">
29
- {hasProblems ? <ErrorMessage message={words.ThereWasAProblem} /> : null}
30
- {isFetching ? <LoadingMessage message={words.LoadingData} sm /> : (
31
- <button
32
- className="btn btn-outline-info d-print-none"
33
- disabled={isFetching}
34
- onClick={onLoadMoreClick}
35
- ref={ref}
36
- type="button">
37
- {isFetching ? words.LoadingData : words.LoadMore}
38
- </button>
39
- )}
40
- </div>
41
- );
42
- };
43
-
44
- export default LoadingButton;