@pagopa/selfcare-common-frontend 1.5.13 → 1.5.14
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/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v1.5.14](https://github.com/pagopa/selfcare-common-frontend/compare/v1.5.13...v1.5.14)
|
|
8
|
+
|
|
9
|
+
- Exporting utils fakePagination functions [`#40`](https://github.com/pagopa/selfcare-common-frontend/pull/40)
|
|
10
|
+
|
|
7
11
|
#### [v1.5.13](https://github.com/pagopa/selfcare-common-frontend/compare/v1.5.12...v1.5.13)
|
|
8
12
|
|
|
13
|
+
> 23 February 2022
|
|
14
|
+
|
|
9
15
|
- storageOpsBuilder + token and user storageOps methods [`#39`](https://github.com/pagopa/selfcare-common-frontend/pull/39)
|
|
10
16
|
|
|
11
17
|
#### [v1.5.12](https://github.com/pagopa/selfcare-common-frontend/compare/v1.5.11...v1.5.12)
|
package/build.info
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
20220223.
|
|
2
|
-
tags/v1.5.
|
|
1
|
+
20220223.3 - selfcare-common-frontend.deploy(21453)
|
|
2
|
+
tags/v1.5.14^0 6a9e934b4b811d4098ead465dddb989b864c9a66
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PageRequest } from '../model/PageRequest';
|
|
2
2
|
import { PageResource } from '../model/PageResource';
|
|
3
|
+
export declare const extractPageRequest: <T extends Record<string, any>>(data: T[], pageRequest: PageRequest) => PageResource<T>;
|
|
4
|
+
export declare const applySort: <T extends Record<string, any>>(data: T[], sort: string) => void;
|
|
3
5
|
/**
|
|
4
6
|
* Custom hook used to simulate paginated resources when the external service doesn't implement it, caching values when filter doesn't change and serving them a page at time.
|
|
5
7
|
* Cached values are stored using useRef, so they are local to the component using this hook.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applySort = exports.extractPageRequest = void 0;
|
|
3
4
|
const react_1 = require("react");
|
|
4
5
|
const toPageResource = (content, page, size, totalElements) => ({
|
|
5
6
|
content,
|
|
@@ -16,6 +17,7 @@ const extractPageRequest = (data, pageRequest) => {
|
|
|
16
17
|
? data.slice(firstIndex, firstIndex + pageRequest.size)
|
|
17
18
|
: [], pageRequest.page, pageRequest.size, data.length);
|
|
18
19
|
};
|
|
20
|
+
exports.extractPageRequest = extractPageRequest;
|
|
19
21
|
const applySort = (data, sort) => {
|
|
20
22
|
const sortConfiguration = sort.split(' ').map((order) => {
|
|
21
23
|
const [key, direction] = order.split(',');
|
|
@@ -32,6 +34,7 @@ const applySort = (data, sort) => {
|
|
|
32
34
|
return 0;
|
|
33
35
|
});
|
|
34
36
|
};
|
|
37
|
+
exports.applySort = applySort;
|
|
35
38
|
/**
|
|
36
39
|
* Custom hook used to simulate paginated resources when the external service doesn't implement it, caching values when filter doesn't change and serving them a page at time.
|
|
37
40
|
* Cached values are stored using useRef, so they are local to the component using this hook.
|
|
@@ -42,7 +45,7 @@ const useFakePagination = (fetch) => {
|
|
|
42
45
|
const cachedDataSort = (0, react_1.useRef)();
|
|
43
46
|
const checkAndApplySort = (sort) => {
|
|
44
47
|
if (sort && cachedDataSort.current !== sort) {
|
|
45
|
-
applySort(cachedData.current, sort);
|
|
48
|
+
(0, exports.applySort)(cachedData.current, sort);
|
|
46
49
|
// eslint-disable-next-line functional/immutable-data
|
|
47
50
|
cachedDataSort.current = sort;
|
|
48
51
|
}
|
|
@@ -50,14 +53,14 @@ const useFakePagination = (fetch) => {
|
|
|
50
53
|
return (pageRequest, filterChanged) => {
|
|
51
54
|
if (!filterChanged && cachedData.current) {
|
|
52
55
|
checkAndApplySort(pageRequest.sort);
|
|
53
|
-
return new Promise((resolve) => setTimeout(() => resolve(extractPageRequest(cachedData.current, pageRequest)), 100));
|
|
56
|
+
return new Promise((resolve) => setTimeout(() => resolve((0, exports.extractPageRequest)(cachedData.current, pageRequest)), 100));
|
|
54
57
|
}
|
|
55
58
|
else {
|
|
56
59
|
return fetch().then((results) => {
|
|
57
60
|
// eslint-disable-next-line functional/immutable-data
|
|
58
61
|
cachedData.current = results;
|
|
59
62
|
checkAndApplySort(pageRequest.sort);
|
|
60
|
-
return extractPageRequest(cachedData.current, pageRequest);
|
|
63
|
+
return (0, exports.extractPageRequest)(cachedData.current, pageRequest);
|
|
61
64
|
});
|
|
62
65
|
}
|
|
63
66
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFakePagination.js","sourceRoot":"","sources":["../../src/lib/hooks/useFakePagination.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFakePagination.js","sourceRoot":"","sources":["../../src/lib/hooks/useFakePagination.ts"],"names":[],"mappings":";;;AAAA,iCAA+B;AAI/B,MAAM,cAAc,GAAG,CACrB,OAAiB,EACjB,IAAY,EACZ,IAAY,EACZ,aAAqB,EACJ,EAAE,CAAC,CAAC;IACrB,OAAO;IACP,IAAI,EAAE;QACJ,MAAM,EAAE,IAAI;QACZ,IAAI;QACJ,aAAa;QACb,UAAU,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KAC3D;CACF,CAAC,CAAC;AAEI,MAAM,kBAAkB,GAAG,CAChC,IAAc,EACd,WAAwB,EACP,EAAE;IACnB,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IACvD,OAAO,cAAc,CACnB,UAAU,GAAG,IAAI,CAAC,MAAM,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC;QAC9C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EA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CAAC;IAExC,MAAM,iBAAiB,GAAG,CAAC,IAAa,EAAE,EAAE;QAC1C,IAAI,IAAI,IAAI,cAAc,CAAC,OAAO,KAAK,IAAI,EAAE;YAC3C,IAAA,iBAAS,EAAC,UAAU,CAAC,OAAmB,EAAE,IAAI,CAAC,CAAC;YAChD,qDAAqD;YACrD,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC;SAC/B;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,WAAwB,EAAE,aAAsB,EAA4B,EAAE;QACpF,IAAI,CAAC,aAAa,IAAI,UAAU,CAAC,OAAO,EAAE;YACxC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACpC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC7B,UAAU,CACR,GAAG,EAAE,CAAC,OAAO,CAAC,IAAA,0BAAkB,EAAC,UAAU,CAAC,OAAmB,EAAE,WAAW,CAAC,CAAC,EAC9E,GAAG,CACJ,CACF,CAAC;SACH;aAAM;YACL,OAAO,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC9B,qDAAqD;gBACrD,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;gBAC7B,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACpC,OAAO,IAAA,0BAAkB,EAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/selfcare-common-frontend",
|
|
3
3
|
"description": "Shared React components for the pagopa selfcare project",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/pagopa/selfcare-common-frontend",
|
|
7
7
|
"author": "https://www.pagopa.gov.it",
|