@ecodev/natural 45.2.0 → 45.4.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/esm2020/lib/modules/table-button/table-button.component.mjs +14 -7
- package/esm2020/lib/services/persistence.service.mjs +26 -18
- package/esm2020/public-api.mjs +2 -2
- package/fesm2015/ecodev-natural.mjs +39 -23
- package/fesm2015/ecodev-natural.mjs.map +1 -1
- package/fesm2020/ecodev-natural.mjs +38 -23
- package/fesm2020/ecodev-natural.mjs.map +1 -1
- package/lib/modules/table-button/table-button.component.d.ts +8 -6
- package/lib/services/persistence.service.d.ts +17 -5
- package/package.json +1 -1
- package/public-api.d.ts +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { OnChanges, SimpleChanges } from '@angular/core';
|
|
1
|
+
import { EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
|
2
2
|
import { Params, QueryParamsHandling, RouterLink } from '@angular/router';
|
|
3
3
|
import { ThemePalette } from '@angular/material/core';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
/**
|
|
6
6
|
* Button that fits well in a `<mat-table>` and support either
|
|
7
|
-
* route navigation via `navigate
|
|
7
|
+
* route navigation via `navigate`, or external URL via `href`,
|
|
8
|
+
* or callback via `buttonClick`.
|
|
8
9
|
*
|
|
9
|
-
* If neither `navigate` nor `href`
|
|
10
|
-
* it will show the icon and/or label in `<span>` instead of a button
|
|
10
|
+
* If neither `navigate` nor `href` nor `buttonClick` have a meaningful value, then
|
|
11
|
+
* it will show the icon and/or label in a `<span>` instead of a button.
|
|
11
12
|
*
|
|
12
13
|
* External URL will always be opened in new tab.
|
|
13
14
|
*/
|
|
@@ -22,8 +23,9 @@ export declare class NaturalTableButtonComponent implements OnChanges {
|
|
|
22
23
|
preserveFragment: boolean;
|
|
23
24
|
raised: boolean;
|
|
24
25
|
color: ThemePalette;
|
|
25
|
-
|
|
26
|
+
readonly buttonClick: EventEmitter<MouseEvent>;
|
|
27
|
+
type: 'routerLink' | 'href' | 'click' | 'none';
|
|
26
28
|
ngOnChanges(changes: SimpleChanges): void;
|
|
27
29
|
static ɵfac: i0.ɵɵFactoryDeclaration<NaturalTableButtonComponent, never>;
|
|
28
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<NaturalTableButtonComponent, "natural-table-button", never, { "queryParams": "queryParams"; "queryParamsHandling": "queryParamsHandling"; "label": "label"; "icon": "icon"; "href": "href"; "navigate": "navigate"; "fragment": "fragment"; "preserveFragment": "preserveFragment"; "raised": "raised"; "color": "color"; }, {}, never, never, false>;
|
|
30
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NaturalTableButtonComponent, "natural-table-button", never, { "queryParams": "queryParams"; "queryParamsHandling": "queryParamsHandling"; "label": "label"; "icon": "icon"; "href": "href"; "navigate": "navigate"; "fragment": "fragment"; "preserveFragment": "preserveFragment"; "raised": "raised"; "color": "color"; }, { "buttonClick": "buttonClick"; }, never, never, false>;
|
|
29
31
|
}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
1
2
|
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
|
|
2
3
|
import { NaturalStorage } from '../modules/common/services/memory-storage';
|
|
3
4
|
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Validator for persisted values retrieved from NaturalPersistenceService. If returns false, the persisted value
|
|
7
|
+
* will be ignored, and instead `null` will be returned.
|
|
8
|
+
*
|
|
9
|
+
* `storageKey` is only given if the value is coming from session storage (and not from URL).
|
|
10
|
+
*/
|
|
11
|
+
declare type PersistenceValidator = (key: string, storageKey: string | null, value: unknown) => boolean;
|
|
12
|
+
export declare const PERSISTENCE_VALIDATOR: InjectionToken<PersistenceValidator>;
|
|
4
13
|
export declare class NaturalPersistenceService {
|
|
5
14
|
private readonly router;
|
|
6
15
|
private readonly sessionStorage;
|
|
7
|
-
|
|
16
|
+
private readonly isValid;
|
|
17
|
+
constructor(router: Router, sessionStorage: NaturalStorage, isValid: PersistenceValidator);
|
|
8
18
|
/**
|
|
9
19
|
* Persist in url and local storage the given value with the given key.
|
|
10
20
|
* When stored in storage, we need more "key" to identify the controller.
|
|
11
21
|
*/
|
|
12
|
-
persist(key: string, value:
|
|
22
|
+
persist(key: string, value: unknown, route: ActivatedRoute, storageKey: string, navigationExtras?: NavigationExtras): Promise<boolean>;
|
|
13
23
|
/**
|
|
14
24
|
* Return object with persisted data in url or in session storage
|
|
15
25
|
* Url has priority over session storage because of url sharing. When url is provided, session storage is ignored.
|
|
@@ -27,15 +37,17 @@ export declare class NaturalPersistenceService {
|
|
|
27
37
|
* Always JSON.stringify() the given value
|
|
28
38
|
* If the value is falsey, the pair key-value is removed from the url.
|
|
29
39
|
*/
|
|
30
|
-
persistInUrl(key: string, value:
|
|
40
|
+
persistInUrl(key: string, value: unknown, route: ActivatedRoute, navigationExtras?: NavigationExtras): Promise<boolean>;
|
|
31
41
|
getFromStorage(key: string, storageKey: string): any | null;
|
|
32
42
|
/**
|
|
33
43
|
* Store value in session storage.
|
|
34
44
|
* If value is falsy, the entry is removed
|
|
35
45
|
*/
|
|
36
|
-
persistInStorage(key: string, value:
|
|
46
|
+
persistInStorage(key: string, value: unknown, storageKey: string): void;
|
|
37
47
|
private getStorageKey;
|
|
38
48
|
private isFalseyValue;
|
|
39
|
-
|
|
49
|
+
private deserialize;
|
|
50
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NaturalPersistenceService, [null, null, { optional: true; }]>;
|
|
40
51
|
static ɵprov: i0.ɵɵInjectableDeclaration<NaturalPersistenceService>;
|
|
41
52
|
}
|
|
53
|
+
export {};
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export * from './lib/services/abstract-model.service';
|
|
|
15
15
|
export { NaturalDebounceService } from './lib/services/debounce.service';
|
|
16
16
|
export * from './lib/services/enum.service';
|
|
17
17
|
export * from './lib/services/link-mutation.service';
|
|
18
|
-
export
|
|
18
|
+
export { NaturalPersistenceService, PERSISTENCE_VALIDATOR } from './lib/services/persistence.service';
|
|
19
19
|
export * from './lib/services/swiss-parsing-date-adapter.service';
|
|
20
20
|
export * from './lib/types/types';
|
|
21
21
|
export * from './lib/modules/alert/public-api';
|