redux-paginator-immutable 17.0.18 → 17.0.19

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 (70) hide show
  1. package/lib/Info.d.ts +9 -0
  2. package/lib/Info.js +19 -0
  3. package/lib/Info.js.map +1 -0
  4. package/lib/LoadDataItem.d.ts +23 -0
  5. package/lib/LoadDataItem.js +59 -0
  6. package/lib/LoadDataItem.js.map +1 -0
  7. package/lib/LoadPaginator.d.ts +41 -0
  8. package/lib/LoadPaginator.js +109 -0
  9. package/lib/LoadPaginator.js.map +1 -0
  10. package/lib/LoadingButton.d.ts +11 -0
  11. package/lib/LoadingButton.js +22 -0
  12. package/lib/LoadingButton.js.map +1 -0
  13. package/lib/actionTypes.d.ts +9 -0
  14. package/lib/actionTypes.js +13 -0
  15. package/lib/actionTypes.js.map +1 -0
  16. package/lib/actions.d.ts +42 -0
  17. package/lib/actions.js +82 -0
  18. package/lib/actions.js.map +1 -0
  19. package/lib/agent.d.ts +8 -0
  20. package/lib/agent.js +37 -0
  21. package/lib/agent.js.map +1 -0
  22. package/lib/createDataReducer.d.ts +36 -0
  23. package/lib/createDataReducer.js +79 -0
  24. package/lib/createDataReducer.js.map +1 -0
  25. package/lib/createItemReducer.d.ts +11 -0
  26. package/lib/createItemReducer.js +18 -0
  27. package/lib/createItemReducer.js.map +1 -0
  28. package/lib/createPaginator.d.ts +14 -0
  29. package/lib/createPaginator.js +84 -0
  30. package/lib/createPaginator.js.map +1 -0
  31. package/lib/index.d.ts +11 -0
  32. package/lib/index.js +30 -0
  33. package/lib/index.js.map +1 -0
  34. package/lib/paginatorMiddleware.d.ts +5 -0
  35. package/lib/paginatorMiddleware.js +68 -0
  36. package/lib/paginatorMiddleware.js.map +1 -0
  37. package/lib/reducerItemData.d.ts +18 -0
  38. package/lib/reducerItemData.js +56 -0
  39. package/lib/reducerItemData.js.map +1 -0
  40. package/lib/reducerOperations.d.ts +3 -0
  41. package/lib/reducerOperations.js +69 -0
  42. package/lib/reducerOperations.js.map +1 -0
  43. package/lib/reducers.d.ts +4 -0
  44. package/lib/reducers.js +75 -0
  45. package/lib/reducers.js.map +1 -0
  46. package/lib/selectors.d.ts +58 -0
  47. package/lib/selectors.js +79 -0
  48. package/lib/selectors.js.map +1 -0
  49. package/lib/types/actions.d.ts +85 -0
  50. package/lib/types/actions.js +3 -0
  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 -0
  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 -0
  57. package/lib/types/state.js.map +1 -0
  58. package/lib/util.d.ts +9 -0
  59. package/lib/util.js +49 -0
  60. package/lib/util.js.map +1 -0
  61. package/lib/words.d.ts +9 -0
  62. package/lib/words.js +12 -0
  63. package/lib/words.js.map +1 -0
  64. package/package.json +24 -17
  65. package/lib/__tests__/actions.spec.js +0 -117
  66. package/lib/__tests__/agent.spec.js +0 -32
  67. package/lib/__tests__/createPaginator.spec.js +0 -39
  68. package/lib/__tests__/reducers.spec.js +0 -125
  69. package/lib/__tests__/selectors.spec.js +0 -160
  70. package/lib/__tests__/setup.js +0 -3
@@ -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;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ const Immutable = __importStar(require("immutable"));
23
+ const reselect_1 = require("reselect");
24
+ const pagesSelector = (state) => state, rowsPerPage = 50, pageSelector = (0, reselect_1.createSelector)(pagesSelector, (_state, token) => token, (pages, token) => pages.get(token)), getAllResults = (0, reselect_1.createSelector)(pageSelector, (_state, _token, items) => items, (page, items) => {
25
+ if (typeof page === "undefined") {
26
+ return Immutable.List();
27
+ }
28
+ return page.get("ids").map((id) => items.get(String(id)));
29
+ }), getResultsUpToPage = (0, reselect_1.createSelector)(pageSelector, (_state, _token, items) => items, (_state, _token, _items, target) => target, (_state, _token, _items, _target, perPage) => (perPage || rowsPerPage), (page, items, target, perPage) => {
30
+ if (typeof page === "undefined") {
31
+ return Immutable.List();
32
+ }
33
+ const ids = page.get("ids").slice(0, perPage * target);
34
+ return ids.map((id) => items.get(String(id)));
35
+ }), getCurrentTotalResultsCount = (0, reselect_1.createSelector)(pageSelector, (page) => {
36
+ if (typeof page === "undefined") {
37
+ return 0;
38
+ }
39
+ return page.get("total");
40
+ }), isPageFetching = (0, reselect_1.createSelector)(pageSelector, (_state, _token, target) => target, (page, target) => {
41
+ if (typeof page === "undefined") {
42
+ return false;
43
+ }
44
+ return page.get("fetching") && target === page.get("page");
45
+ }), isPageFetched = (0, reselect_1.createSelector)(pageSelector, (_state, _token, target) => target, (page, target) => {
46
+ if (typeof page === "undefined") {
47
+ return false;
48
+ }
49
+ return page.get("fetched") && target <= page.get("page");
50
+ }), hasPageProblems = (0, reselect_1.createSelector)(pageSelector, (page) => {
51
+ if (typeof page === "undefined") {
52
+ return false;
53
+ }
54
+ return page.get("error");
55
+ }), getCurrentView = (0, reselect_1.createSelector)(pageSelector, (page) => {
56
+ if (typeof page === "undefined") {
57
+ return 1;
58
+ }
59
+ return page.get("view");
60
+ }),
61
+ // these selectors are used for the entire app
62
+ getPaginatorPaginations = (state, name) => state.getIn(["paginations", name]), getPaginatorEntities = (state, name) => state.getIn(["entities", name]), getPaginators = (0, reselect_1.createSelector)(getPaginatorPaginations, getPaginatorEntities, (list, entities) => ({
63
+ list,
64
+ entities,
65
+ }));
66
+ exports.default = {
67
+ getAllResults,
68
+ getCurrentTotalResultsCount,
69
+ getResultsUpToPage,
70
+ isPageFetching,
71
+ isPageFetched,
72
+ hasPageProblems,
73
+ getCurrentView,
74
+ // for state
75
+ getPaginatorPaginations,
76
+ getPaginatorEntities,
77
+ getPaginators,
78
+ };
79
+ //# sourceMappingURL=selectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,uCAA0C;AAG1C,MACE,aAAa,GAAG,CAAC,KAAY,EAAE,EAAE,CAAC,KAAK,EAEvC,WAAW,GAAG,EAAE,EAChB,YAAY,GAAG,IAAA,yBAAc,EAC3B,aAAa,EACb,CAAC,MAAa,EAAE,KAAa,EAAE,EAAE,CAAC,KAAK,EACvC,CAAC,KAAiB,EAAE,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CACvD,EACD,aAAa,GAAG,IAAA,yBAAc,EAC5B,YAAY,EACZ,CAAC,MAAc,EAAE,MAAe,EAAE,KAAW,EAAE,EAAE,CAAC,KAAK,EACvD,CAAC,IAAU,EAAE,KAAW,EAAE,EAAE;IAC1B,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;QAC/B,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC;KACzB;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,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AAC,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;
@@ -0,0 +1,3 @@
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
+ dataItemURL: string;
15
+ normalizeDataItem: any;
16
+ rowsPerLoad?: number;
17
+ manipulateItems?: (items: any) => any;
18
+ totalKey?: string;
19
+ pageArgName?: string;
20
+ idKey?: string;
21
+ };
@@ -0,0 +1,16 @@
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
+ };
@@ -0,0 +1,3 @@
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 };
package/lib/util.js ADDED
@@ -0,0 +1,49 @@
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.manageEntity = exports.manipulateItems = exports.manipulateDataItems = exports.manageDataEntity = void 0;
23
+ const Immutable = __importStar(require("immutable"));
24
+ const reselect_1 = require("reselect");
25
+ // simple item
26
+ const manageEntity = (normalizrEntity) => ((item, state, keyID) => {
27
+ // prevent rewrite
28
+ const old = state.get(String(item[keyID]));
29
+ if (typeof old === "undefined") {
30
+ return Immutable.Map(normalizrEntity(item));
31
+ }
32
+ return old;
33
+ }), manipulateItems = (sortKey = "ID") => (0, reselect_1.createSelector)((data) => data, (data) => data.sortBy((current) => -current.get(sortKey))),
34
+ // data item
35
+ manageDataEntity = (normalizrEntity) => ((item, state, keyID) => {
36
+ // prevent rewrite
37
+ const old = state.get(String(item[keyID]));
38
+ if (typeof old === "undefined") {
39
+ return Immutable.Map({
40
+ Data: normalizrEntity(item),
41
+ });
42
+ }
43
+ return old;
44
+ }), manipulateDataItems = (sortKey = "ID") => ((0, reselect_1.createSelector)((data) => data, (data) => data.sortBy((current) => -current.getIn(["Data", sortKey]))));
45
+ exports.manageEntity = manageEntity;
46
+ exports.manipulateItems = manipulateItems;
47
+ exports.manageDataEntity = manageDataEntity;
48
+ exports.manipulateDataItems = manipulateDataItems;
49
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
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/lib/words.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ declare const words: {
2
+ ThereWasAProblem: string;
3
+ Showing: string;
4
+ All: string;
5
+ Of: string;
6
+ LoadingData: string;
7
+ LoadMore: string;
8
+ };
9
+ export default words;
package/lib/words.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const words = {
4
+ ThereWasAProblem: "There was a problem. Try again",
5
+ Showing: "Showing",
6
+ All: "all",
7
+ Of: "of",
8
+ LoadingData: "Loading data...",
9
+ LoadMore: "Load more",
10
+ };
11
+ exports.default = words;
12
+ //# sourceMappingURL=words.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words.js","sourceRoot":"","sources":["../src/words.ts"],"names":[],"mappings":";;AAAA,MAAM,KAAK,GAAG;IACZ,gBAAgB,EAAG,gCAAgC;IACnD,OAAO,EAAY,SAAS;IAC5B,GAAG,EAAgB,KAAK;IACxB,EAAE,EAAiB,IAAI;IACvB,WAAW,EAAQ,iBAAiB;IACpC,QAAQ,EAAW,WAAW;CAC/B,CAAC;AAEF,kBAAe,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,25 +1,30 @@
1
1
  {
2
2
  "name": "redux-paginator-immutable",
3
- "version": "17.0.18",
3
+ "version": "17.0.19",
4
+ "types": "./lib/types/index.d.ts",
4
5
  "description": "redux-paginator-immutable helps you deal with paginated API by composing your existing reducers",
5
6
  "main": "./lib/index.js",
6
7
  "babel": {
8
+ "ignore": [
9
+ "**/__tests__",
10
+ "**/types"
11
+ ],
7
12
  "presets": [
8
- "env",
9
- "stage-0",
10
- "react"
13
+ "@babel/env",
14
+ "@babel/preset-typescript",
15
+ "@babel/preset-react"
11
16
  ],
12
17
  "env": {
13
18
  "production": {
14
19
  "plugins": [
15
20
  "@babel/plugin-syntax-dynamic-import",
16
- "transform-decorators-legacy",
17
- "react-html-attrs",
18
- "transform-class-properties",
19
- "transform-react-constant-elements",
20
- "transform-react-inline-elements",
21
- "transform-react-remove-prop-types",
22
- "transform-flow-strip-types"
21
+ "@babel/plugin-proposal-class-properties",
22
+ "@babel/plugin-proposal-export-default-from",
23
+ "@babel/plugin-transform-modules-commonjs",
24
+ "@babel/plugin-transform-react-constant-elements",
25
+ "@babel/plugin-transform-react-inline-elements",
26
+ "@babel/plugin-transform-typescript",
27
+ "transform-react-remove-prop-types"
23
28
  ]
24
29
  },
25
30
  "developmentTime": {
@@ -31,19 +36,19 @@
31
36
  }
32
37
  },
33
38
  "scripts": {
34
- "build:lib": "babel src --out-dir lib",
39
+ "build:lib": "@babel src --extensions .ts,.tsx --out-dir lib",
35
40
  "build:umd": "cross-env NODE_ENV=development webpack src/index.js dist/redux-paginator-immutable.js",
36
41
  "build:umd:min": "cross-env NODE_ENV=production webpack src/index.js dist/redux-paginator-immutable.min.js",
37
42
  "build": "npm run build:lib",
38
43
  "clean": "rimraf dist lib",
39
44
  "check": "npm-check -u -i babel-jest -i jest --specials=bin,eslint,babel,webpack",
40
45
  "eslint": "eslint --ext .jsx,.js,.ts,.tsx src --fix",
41
- "load": "npm run test && npm run ts && npm run eslint && npm run clean && npm run build && npm publish",
46
+ "load": "npm run test && npm run clean && npm run eslint && npm run ts && npm publish",
42
47
  "test": "ts-mocha src/__tests__/*.spec.js",
43
48
  "test:watch": "npm test -- --watch",
44
49
  "test:cov": "babel-node ./node_modules/isparta/bin/isparta cover ./node_modules/mocha/bin/_mocha -- --recursive \"src/**/__tests__/*\" --require src/__tests__/setup.js",
45
50
  "test:codecov": "cat ./coverage/coverage.json | ./node_modules/.bin/codecov",
46
- "ts": "tsc --build --clean"
51
+ "ts": "tsc --declaration"
47
52
  },
48
53
  "repository": {
49
54
  "type": "git",
@@ -71,10 +76,12 @@
71
76
  },
72
77
  "homepage": "https://github.com/cristian-sima/redux-paginator-immutable#readme",
73
78
  "devDependencies": {
79
+ "@babel/cli": "^7.17.0",
80
+ "@babel/preset-env": "^7.16.11",
81
+ "@babel/preset-typescript": "^7.16.7",
74
82
  "@types/superagent": "^4.1.15",
75
83
  "@typescript-eslint/eslint-plugin": "^5.10.2",
76
84
  "@typescript-eslint/parser": "^5.10.2",
77
- "babel-cli": "^6.26.0",
78
85
  "babel-eslint": "^10.1.0",
79
86
  "babel-plugin-transform-decorators-legacy": "^1.3.5",
80
87
  "babel-plugin-transform-flow-strip-types": "^6.22.0",
@@ -99,7 +106,7 @@
99
106
  "rimraf": "^3.0.2",
100
107
  "ts-mocha": "^9.0.2",
101
108
  "typescript": "^4.5.5",
102
- "webpack": "^4.41.2"
109
+ "webpack": "^5.68.0"
103
110
  },
104
111
  "dependencies": {
105
112
  "create-subscription": "^17.0.0",
@@ -110,6 +117,6 @@
110
117
  "redux": "^4.1.2",
111
118
  "reselect": "^4.1.5",
112
119
  "superagent": "^7.1.1",
113
- "x25": "^17.0.16"
120
+ "x25": "^17.0.17"
114
121
  }
115
122
  }
@@ -1,117 +0,0 @@
1
- "use strict";
2
-
3
- var _expect = require("expect");
4
-
5
- var _expect2 = _interopRequireDefault(_expect);
6
-
7
- var _fluxStandardAction = require("flux-standard-action");
8
-
9
- var _actions = require("../actions");
10
-
11
- var _actions2 = _interopRequireDefault(_actions);
12
-
13
- var _actionTypes = require("../actionTypes");
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
- var receivePage = _actions2.default.receivePage,
18
- requestPage = _actions2.default.requestPage,
19
- resetView = _actions2.default.resetView,
20
- changeView = _actions2.default.changeView; /* eslint-disable no-undefined, max-lines-per-function, no-magic-numbers */
21
-
22
- describe("actions", function () {
23
-
24
- it("should create receive page action", function () {
25
- var action = receivePage({
26
- endpoint: "some/api/endpoint/",
27
- pageArgName: "p",
28
- idKey: "id",
29
- page: 2,
30
- token: "foo=bar",
31
- items: ["foo", "bar", "baz"],
32
- total: 42
33
- });
34
-
35
- (0, _expect2.default)(action).toEqual({
36
- type: _actionTypes.RECEIVE_PAGE,
37
- meta: {
38
- endpoint: "some/api/endpoint/",
39
- pageArgName: "p",
40
- idKey: "id"
41
- },
42
- payload: {
43
- token: "foo=bar",
44
- page: 2,
45
- items: ["foo", "bar", "baz"],
46
- total: 42
47
- }
48
- });
49
-
50
- (0, _expect2.default)((0, _fluxStandardAction.isFSA)(action)).toEqual(true);
51
- });
52
-
53
- it("should create request page action", function () {
54
- var action = requestPage({
55
- endpoint: "some/api/endpoint/",
56
- resultsKey: "results",
57
- totalKey: "total",
58
- pageArgName: "p",
59
- idKey: "id",
60
- page: 2,
61
- token: "foo=bar"
62
- });
63
-
64
- (0, _expect2.default)(action).toEqual({
65
- type: _actionTypes.REQUEST_PAGE,
66
- meta: {
67
- endpoint: "some/api/endpoint/",
68
- resultsKey: "results",
69
- totalKey: "total",
70
- pageArgName: "p",
71
- idKey: "id"
72
- },
73
- payload: {
74
- token: "foo=bar",
75
- page: 2
76
- }
77
- });
78
-
79
- (0, _expect2.default)((0, _fluxStandardAction.isFSA)(action)).toEqual(true);
80
- });
81
-
82
- it("should create reset view action", function () {
83
- var action = resetView("some/api/endpoint/", "name");
84
-
85
- (0, _expect2.default)(action).toEqual({
86
- type: _actionTypes.RESET_VIEW,
87
- meta: {
88
- endpoint: "some/api/endpoint/"
89
- },
90
- payload: {
91
- token: "name"
92
- }
93
- });
94
-
95
- (0, _expect2.default)((0, _fluxStandardAction.isFSA)(action)).toEqual(true);
96
- });
97
-
98
- it("should create change view action", function () {
99
- var action = changeView("some/api/endpoint/", {
100
- token: "name",
101
- view: 2
102
- });
103
-
104
- (0, _expect2.default)(action).toEqual({
105
- type: _actionTypes.CHANGE_VIEW,
106
- meta: {
107
- endpoint: "some/api/endpoint/"
108
- },
109
- payload: {
110
- view: 2,
111
- token: "name"
112
- }
113
- });
114
-
115
- (0, _expect2.default)((0, _fluxStandardAction.isFSA)(action)).toEqual(true);
116
- });
117
- });
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- var _expect = require("expect");
4
-
5
- var _expect2 = _interopRequireDefault(_expect);
6
-
7
- var _agent = require("../agent");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- describe("buildSuffix", function () {
12
-
13
- it("should correctly build the url suffix when simple params are provided", function () {
14
- (0, _expect2.default)((0, _agent.buildSuffix)("p", 1, "foo=bar")).toEqual("?foo=bar&p=1");
15
- });
16
-
17
- it("should correctly build the url suffix when less simple params are provided", function () {
18
- (0, _expect2.default)((0, _agent.buildSuffix)("p", 1, "foo=bar&baz=foo")).toEqual("?baz=foo&foo=bar&p=1");
19
- });
20
-
21
- it("should correctly build the url suffix when params contains no extractable query params", function () {
22
- (0, _expect2.default)((0, _agent.buildSuffix)("p", 1, "foo/bar")).toEqual("foo/bar?p=1");
23
- });
24
-
25
- it('should correctly build the url suffix when "params" is not provided', function () {
26
- (0, _expect2.default)((0, _agent.buildSuffix)("p", 1, "")).toEqual("?p=1");
27
- });
28
-
29
- it("should correctly build the url suffix when complex params are provided", function () {
30
- (0, _expect2.default)((0, _agent.buildSuffix)("p", 1, "foo/bar?bar=biz&baz=foo")).toEqual("foo/bar?baz=foo&bar=biz&p=1");
31
- });
32
- });