@geosdi/ngx-utility-service 2.0.1 → 3.0.0
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/README.md
CHANGED
|
@@ -9,10 +9,9 @@ by key. A filter with a value is "live"; a filter without one does not exist.
|
|
|
9
9
|
|
|
10
10
|
Peer dependencies:
|
|
11
11
|
|
|
12
|
-
"@angular/common": ">=
|
|
13
|
-
"@angular/core": ">=
|
|
14
|
-
"lodash": ">=4.17.21"
|
|
15
|
-
"typescript": ">=5.0.0"
|
|
12
|
+
"@angular/common": ">=22.0.0",
|
|
13
|
+
"@angular/core": ">=22.0.0",
|
|
14
|
+
"lodash": ">=4.17.21"
|
|
16
15
|
|
|
17
16
|
## Usage
|
|
18
17
|
|
|
@@ -56,6 +55,24 @@ filters are live. A `null` or `undefined` key is ignored.
|
|
|
56
55
|
The service is a singleton (`providedIn: "root"`): the values are shared by the whole application
|
|
57
56
|
and live as long as the page.
|
|
58
57
|
|
|
58
|
+
## What the code does not show
|
|
59
|
+
|
|
60
|
+
- `saveFilter` has a third parameter, `type`, that the code never reads.
|
|
61
|
+
- `filtersValuesMap` is the live `Map`, not a copy: writing to it bypasses the normalization
|
|
62
|
+
above, so a key set there can hold an empty array or `null`.
|
|
63
|
+
- `getFilter` returns the stored array itself: changing it changes the filter.
|
|
64
|
+
|
|
65
|
+
## Changes in 3.0.0
|
|
66
|
+
|
|
67
|
+
- **A major version** because the peer dependencies now ask for Angular 22: an application on an
|
|
68
|
+
older Angular can no longer install it. The API is unchanged unless a point below says otherwise.
|
|
69
|
+
- `typescript` is no longer a peer dependency: nothing in the package imports it.
|
|
70
|
+
- **The Angular peer dependencies are `>=22.0.0`**: the library is compiled and tested with
|
|
71
|
+
Angular 22 only, so it no longer claims to install on older versions.
|
|
72
|
+
- Compiled with Angular 22. The peer dependencies were already correct and are unchanged.
|
|
73
|
+
- This README: what the code does not show.
|
|
74
|
+
- The code is unchanged.
|
|
75
|
+
|
|
59
76
|
## Changes in 2.0.1
|
|
60
77
|
|
|
61
78
|
- The peer dependencies match the code: `lodash`, which the service imports, is declared;
|
|
@@ -1,108 +1,77 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import { Injectable } from
|
|
3
|
-
import _ from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
clearFilters() {
|
|
76
|
-
this._filtersValuesMap.clear();
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
* @param item
|
|
81
|
-
* @private
|
|
82
|
-
*/
|
|
83
|
-
toCanonical(item) {
|
|
84
|
-
if (_.has(item, "value")) {
|
|
85
|
-
return { name: item.name ?? item.value, value: item.value };
|
|
86
|
-
}
|
|
87
|
-
return { name: item, value: item };
|
|
88
|
-
}
|
|
89
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: NgxFiltersCacheService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
90
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: NgxFiltersCacheService, providedIn: "root" }); }
|
|
91
|
-
}
|
|
92
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: NgxFiltersCacheService, decorators: [{
|
|
93
|
-
type: Injectable,
|
|
94
|
-
args: [{
|
|
95
|
-
providedIn: "root",
|
|
96
|
-
}]
|
|
97
|
-
}] });
|
|
98
|
-
|
|
99
|
-
/*
|
|
100
|
-
* Public API Surface of ngx-utility-service
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Generated bundle index. Do not edit.
|
|
105
|
-
*/
|
|
106
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Injectable } from "@angular/core";
|
|
3
|
+
import _ from "lodash";
|
|
4
|
+
var NgxFiltersCacheService = class NgxFiltersCacheService {
|
|
5
|
+
constructor() {
|
|
6
|
+
this._filtersValuesMap = /* @__PURE__ */ new Map();
|
|
7
|
+
}
|
|
8
|
+
get filtersValuesMap() {
|
|
9
|
+
return this._filtersValuesMap;
|
|
10
|
+
}
|
|
11
|
+
getFilter(key) {
|
|
12
|
+
return this._filtersValuesMap.has(key) ? this._filtersValuesMap.get(key) : null;
|
|
13
|
+
}
|
|
14
|
+
hasFilter(key) {
|
|
15
|
+
return this._filtersValuesMap.has(key);
|
|
16
|
+
}
|
|
17
|
+
saveFilter(key, value, type = false) {
|
|
18
|
+
if (_.isNil(key)) return;
|
|
19
|
+
const cleaned = (_.isArray(value) ? value : _.isNil(value) ? [] : [value]).filter((item) => !_.isNil(_.has(item, "value") ? item.value : item));
|
|
20
|
+
if (cleaned.length === 0) {
|
|
21
|
+
this._filtersValuesMap.delete(key);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this._filtersValuesMap.set(key, cleaned);
|
|
25
|
+
}
|
|
26
|
+
removeFilter(key) {
|
|
27
|
+
if (this._filtersValuesMap.has(key)) this._filtersValuesMap.delete(key);
|
|
28
|
+
}
|
|
29
|
+
filtersSize() {
|
|
30
|
+
return this._filtersValuesMap.size;
|
|
31
|
+
}
|
|
32
|
+
clearFilters() {
|
|
33
|
+
this._filtersValuesMap.clear();
|
|
34
|
+
}
|
|
35
|
+
toCanonical(item) {
|
|
36
|
+
if (_.has(item, "value")) return {
|
|
37
|
+
name: item.name ?? item.value,
|
|
38
|
+
value: item.value
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
name: item,
|
|
42
|
+
value: item
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
static {
|
|
46
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
47
|
+
minVersion: "12.0.0",
|
|
48
|
+
version: "22.2.4",
|
|
49
|
+
ngImport: i0,
|
|
50
|
+
type: NgxFiltersCacheService,
|
|
51
|
+
deps: [],
|
|
52
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
static {
|
|
56
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
57
|
+
minVersion: "12.0.0",
|
|
58
|
+
version: "22.2.4",
|
|
59
|
+
ngImport: i0,
|
|
60
|
+
type: NgxFiltersCacheService,
|
|
61
|
+
providedIn: "root"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
66
|
+
minVersion: "12.0.0",
|
|
67
|
+
version: "22.2.4",
|
|
68
|
+
ngImport: i0,
|
|
69
|
+
type: NgxFiltersCacheService,
|
|
70
|
+
decorators: [{
|
|
71
|
+
type: Injectable,
|
|
72
|
+
args: [{ providedIn: "root" }]
|
|
73
|
+
}]
|
|
74
|
+
});
|
|
107
75
|
export { NgxFiltersCacheService };
|
|
108
|
-
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=geosdi-ngx-utility-service.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geosdi-ngx-utility-service.mjs","sources":["../../../../projects/geosdi/support/ngx-utility-service/src/lib/ngx-filters-cache.service.ts"
|
|
1
|
+
{"version":3,"file":"geosdi-ngx-utility-service.mjs","names":[],"sources":["../../../../projects/geosdi/support/ngx-utility-service/src/lib/ngx-filters-cache.service.ts"],"sourcesContent":["import { Injectable } from \"@angular/core\";\nimport _ from \"lodash\";\n\n/**\n * @author Vito Salvia - CNR IMAA geoSDI Group\n * @email vito.salvia@gmail.com\n */\n@Injectable({\n providedIn: \"root\",\n})\nexport class NgxFiltersCacheService {\n private _filtersValuesMap: Map<string, any> = new Map<string, any>();\n\n /**\n *\n */\n get filtersValuesMap(): Map<string, any> {\n return this._filtersValuesMap;\n }\n\n /**\n *\n * @param key\n */\n getFilter(key: string): any {\n return this._filtersValuesMap.has(key)\n ? this._filtersValuesMap.get(key)\n : null;\n }\n\n /**\n *\n * @param key\n */\n hasFilter(key: string): boolean {\n return this._filtersValuesMap.has(key);\n }\n\n /**\n *\n * @param key\n * @param value\n * @param type\n */\n saveFilter(key: string, value: any, type: boolean = false) {\n if (_.isNil(key)) {\n return;\n }\n const items: any[] = _.isArray(value)\n ? value\n : _.isNil(value)\n ? []\n : [value];\n const cleaned: any[] = items.filter(\n (item: any) => !_.isNil(_.has(item, \"value\") ? item.value : item),\n );\n if (cleaned.length === 0) {\n this._filtersValuesMap.delete(key);\n return;\n }\n this._filtersValuesMap.set(key, cleaned);\n }\n\n /**\n *\n * @param key\n */\n removeFilter(key: string) {\n if (this._filtersValuesMap.has(key)) {\n this._filtersValuesMap.delete(key);\n }\n }\n\n /**\n *\n */\n filtersSize(): number {\n return this._filtersValuesMap.size;\n }\n\n /**\n *\n */\n clearFilters() {\n this._filtersValuesMap.clear();\n }\n\n /**\n *\n * @param item\n * @private\n */\n private toCanonical(item: any): { name: any; value: any } {\n if (_.has(item, \"value\")) {\n return { name: item.name ?? item.value, value: item.value };\n }\n return { name: item, value: item };\n }\n}\n"],"mappings":";;;AAUA,IAAa,yBAAb,MAAa,uBAAsB;CAHnC,cAAA;EAIY,KAAA,oCAAsC,IAAI,IAAG;CAuFxD;CAlFG,IAAI,mBAAgB;EAChB,OAAO,KAAK;CAChB;CAMA,UAAU,KAAW;EACjB,OAAO,KAAK,kBAAkB,IAAI,GAAG,IAC/B,KAAK,kBAAkB,IAAI,GAAG,IAC9B;CACV;CAMA,UAAU,KAAW;EACjB,OAAO,KAAK,kBAAkB,IAAI,GAAG;CACzC;CAQA,WAAW,KAAa,OAAY,OAAgB,OAAK;EACrD,IAAI,EAAE,MAAM,GAAG,GACX;EAOJ,MAAM,WALe,EAAE,QAAQ,KAAK,IAC9B,QACA,EAAE,MAAM,KAAK,IACX,CAAA,IACA,CAAC,KAAK,EACS,CAAM,QACxB,SAAc,CAAC,EAAE,MAAM,EAAE,IAAI,MAAM,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC;EAErE,IAAI,QAAQ,WAAW,GAAG;GACtB,KAAK,kBAAkB,OAAO,GAAG;GACjC;EACJ;EACA,KAAK,kBAAkB,IAAI,KAAK,OAAO;CAC3C;CAMA,aAAa,KAAW;EACpB,IAAI,KAAK,kBAAkB,IAAI,GAAG,GAC9B,KAAK,kBAAkB,OAAO,GAAG;CAEzC;CAKA,cAAW;EACP,OAAO,KAAK,kBAAkB;CAClC;CAKA,eAAY;EACR,KAAK,kBAAkB,MAAK;CAChC;CAOQ,YAAY,MAAS;EACzB,IAAI,EAAE,IAAI,MAAM,OAAO,GACnB,OAAO;GAAE,MAAM,KAAK,QAAQ,KAAK;GAAO,OAAO,KAAK;EAAK;EAE7D,OAAO;GAAE,MAAM;GAAM,OAAO;EAAI;CACpC;CAvFS;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAsB,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAtB;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAsB,YAFnB;EAAM,CAAA;CAAA;;AAET,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAsB,YAAA,CAAA;EAHlC,MAAA;EAAW,MAAA,CAAA,EACR,YAAY,OACf,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geosdi/ngx-utility-service",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Angular service that keeps the values of applied filters",
|
|
5
5
|
"author": "Salvia Vito (vito.salvia@gmail.com)",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"angular",
|
|
@@ -12,10 +12,9 @@
|
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@angular/common": ">=
|
|
16
|
-
"@angular/core": ">=
|
|
17
|
-
"lodash": ">=4.17.21"
|
|
18
|
-
"typescript": ">=5.0.0"
|
|
15
|
+
"@angular/common": ">=22.0.0",
|
|
16
|
+
"@angular/core": ">=22.0.0",
|
|
17
|
+
"lodash": ">=4.17.21"
|
|
19
18
|
},
|
|
20
19
|
"sideEffects": false,
|
|
21
20
|
"module": "fesm2022/geosdi-ngx-utility-service.mjs",
|
|
@@ -1,53 +1,50 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
3
2
|
/**
|
|
4
3
|
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
5
4
|
* @email vito.salvia@gmail.com
|
|
6
5
|
*/
|
|
7
|
-
declare class NgxFiltersCacheService {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { NgxFiltersCacheService };
|
|
6
|
+
export declare class NgxFiltersCacheService {
|
|
7
|
+
private _filtersValuesMap;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
get filtersValuesMap(): Map<string, any>;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param key
|
|
15
|
+
*/
|
|
16
|
+
getFilter(key: string): any;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param key
|
|
20
|
+
*/
|
|
21
|
+
hasFilter(key: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param key
|
|
25
|
+
* @param value
|
|
26
|
+
* @param type
|
|
27
|
+
*/
|
|
28
|
+
saveFilter(key: string, value: any, type?: boolean): void;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param key
|
|
32
|
+
*/
|
|
33
|
+
removeFilter(key: string): void;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
filtersSize(): number;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
clearFilters(): void;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param item
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
private toCanonical;
|
|
48
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxFiltersCacheService, never>;
|
|
49
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
50
|
+
}
|