@pagopa/selfcare-common-frontend 1.5.11 → 1.5.12
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 +6 -0
- package/README.md +9 -6
- package/build.info +2 -2
- package/package.json +1 -1
- package/utils/storage-utils.d.ts +6 -6
- package/utils/storage-utils.js +12 -9
- package/utils/storage-utils.js.map +1 -1
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.12](https://github.com/pagopa/selfcare-common-frontend/compare/v1.5.11...v1.5.12)
|
|
8
|
+
|
|
9
|
+
- storage-utils can writes to local storage [`#38`](https://github.com/pagopa/selfcare-common-frontend/pull/38)
|
|
10
|
+
|
|
7
11
|
#### [v1.5.11](https://github.com/pagopa/selfcare-common-frontend/compare/v1.5.10...v1.5.11)
|
|
8
12
|
|
|
13
|
+
> 22 February 2022
|
|
14
|
+
|
|
9
15
|
- SELC-145 track events + selfcare test domainId [`#37`](https://github.com/pagopa/selfcare-common-frontend/pull/37)
|
|
10
16
|
- SELC-145 track events + selfcare test domainId (#37) [`#145`](https://pagopa.atlassian.net/browse/145) [`#144`](https://pagopa.atlassian.net/browse/144)
|
|
11
17
|
|
package/README.md
CHANGED
|
@@ -155,14 +155,17 @@ The short and long labels used for the roles of selfcare's projects
|
|
|
155
155
|
It will resolve the path variables in path using the provided map
|
|
156
156
|
|
|
157
157
|
## storage-utils
|
|
158
|
-
### storageDelete: (key: string) => void
|
|
159
|
-
It will delete a key from the
|
|
158
|
+
### storageDelete: (key: string, local?: boolean) => void
|
|
159
|
+
It will delete a key from the session storage.
|
|
160
|
+
If local is true, it will use the local session storage instead.
|
|
160
161
|
|
|
161
|
-
### storageWrite: (key: string, value: StorageValue, type: StorageValueType) => void
|
|
162
|
-
It will store a key/value pair in the
|
|
162
|
+
### storageWrite: (key: string, value: StorageValue, type: StorageValueType, local?: boolean) => void
|
|
163
|
+
It will store a key/value pair in the session storage.
|
|
164
|
+
If local is true, it will use the local session storage instead.
|
|
163
165
|
|
|
164
|
-
### function storageRead: (key: string, type: StorageValueType) => void
|
|
165
|
-
It will read a key from the
|
|
166
|
+
### function storageRead: (key: string, type: StorageValueType, local?: boolean) => void
|
|
167
|
+
It will read a key from the session storage.
|
|
168
|
+
If local is true, it will use the local session storage instead.
|
|
166
169
|
|
|
167
170
|
## utils
|
|
168
171
|
### formatDateAsLongString: (date: Date) => string
|
package/build.info
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
tags/v1.5.
|
|
1
|
+
20220223.1 - selfcare-common-frontend.deploy(21349)
|
|
2
|
+
tags/v1.5.12^0 7f7fd366bd7b9ff1cfe4f041dfa0382e097dd0b7
|
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.12",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/pagopa/selfcare-common-frontend",
|
|
7
7
|
"author": "https://www.pagopa.gov.it",
|
package/utils/storage-utils.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
declare type StorageValue = string | number | object;
|
|
2
2
|
declare type StorageValueType = 'string' | 'number' | 'object';
|
|
3
|
-
/** It will delete a key from the local session storage */
|
|
4
|
-
export declare function storageDelete(key: string): void;
|
|
5
|
-
/** It will store a key/value pair in the local session storage */
|
|
6
|
-
export declare function storageWrite(key: string, value: StorageValue, type: StorageValueType): void;
|
|
7
|
-
/** It will read a key from the local session storage */
|
|
8
|
-
export declare function storageRead(key: string, type: StorageValueType): any;
|
|
3
|
+
/** It will delete a key from the session storage. If local is true, it will use the local session storage instead. */
|
|
4
|
+
export declare function storageDelete(key: string, local?: boolean): void;
|
|
5
|
+
/** It will store a key/value pair in the session storage. If local is true, it will use the local session storage instead. */
|
|
6
|
+
export declare function storageWrite(key: string, value: StorageValue, type: StorageValueType, local?: boolean): void;
|
|
7
|
+
/** It will read a key from the session storage. If local is true, it will use the local session storage instead. */
|
|
8
|
+
export declare function storageRead(key: string, type: StorageValueType, local?: boolean): any;
|
|
9
9
|
export {};
|
package/utils/storage-utils.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.storageRead = exports.storageWrite = exports.storageDelete = void 0;
|
|
4
|
-
/** It will delete a key from the local session storage */
|
|
5
|
-
function storageDelete(key) {
|
|
6
|
-
window.sessionStorage
|
|
4
|
+
/** It will delete a key from the session storage. If local is true, it will use the local session storage instead. */
|
|
5
|
+
function storageDelete(key, local) {
|
|
6
|
+
const storage = local ? window.localStorage : window.sessionStorage;
|
|
7
|
+
storage.removeItem(key);
|
|
7
8
|
}
|
|
8
9
|
exports.storageDelete = storageDelete;
|
|
9
|
-
/** It will store a key/value pair in the local session storage */
|
|
10
|
-
function storageWrite(key, value, type) {
|
|
10
|
+
/** It will store a key/value pair in the session storage. If local is true, it will use the local session storage instead. */
|
|
11
|
+
function storageWrite(key, value, type, local) {
|
|
11
12
|
const stringifyFn = {
|
|
12
13
|
string: () => value,
|
|
13
14
|
number: () => String(value),
|
|
14
15
|
object: () => JSON.stringify(value),
|
|
15
16
|
};
|
|
16
17
|
const stringified = stringifyFn[type]();
|
|
17
|
-
window.sessionStorage
|
|
18
|
+
const storage = local ? window.localStorage : window.sessionStorage;
|
|
19
|
+
storage.setItem(key, stringified);
|
|
18
20
|
}
|
|
19
21
|
exports.storageWrite = storageWrite;
|
|
20
|
-
/** It will read a key from the local session storage */
|
|
21
|
-
function storageRead(key, type) {
|
|
22
|
-
const
|
|
22
|
+
/** It will read a key from the session storage. If local is true, it will use the local session storage instead. */
|
|
23
|
+
function storageRead(key, type, local) {
|
|
24
|
+
const storage = local ? window.localStorage : window.sessionStorage;
|
|
25
|
+
const value = storage.getItem(key);
|
|
23
26
|
if (value === null) {
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-utils.js","sourceRoot":"","sources":["../../src/lib/utils/storage-utils.ts"],"names":[],"mappings":";;;AAIA,
|
|
1
|
+
{"version":3,"file":"storage-utils.js","sourceRoot":"","sources":["../../src/lib/utils/storage-utils.ts"],"names":[],"mappings":";;;AAIA,sHAAsH;AACtH,SAAgB,aAAa,CAAC,GAAW,EAAE,KAAe;IACxD,MAAM,OAAO,GAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;IAC7E,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC;AAHD,sCAGC;AAED,8HAA8H;AAC9H,SAAgB,YAAY,CAC1B,GAAW,EACX,KAAmB,EACnB,IAAsB,EACtB,KAAe;IAEf,MAAM,WAAW,GAAgD;QAC/D,MAAM,EAAE,GAAG,EAAE,CAAC,KAAe;QAC7B,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;QAC3B,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;KACpC,CAAC;IAEF,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;IAExC,MAAM,OAAO,GAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;IAC7E,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AACpC,CAAC;AAhBD,oCAgBC;AAED,oHAAoH;AACpH,SAAgB,WA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