@arsedizioni/ars-utils 18.2.339 → 18.2.341
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/clipper.common/common/interceptors/auth.interceptor.d.ts +1 -1
- package/clipper.common/common/services/clipper.service.d.ts +1 -7
- package/core/services/theme.service.d.ts +19 -3
- package/esm2022/clipper.common/common/interceptors/auth.interceptor.mjs +12 -11
- package/esm2022/clipper.common/common/services/clipper.service.mjs +2 -14
- package/esm2022/core/services/theme.service.mjs +27 -8
- package/esm2022/ui/ui/dialogs/info/info-dialog.component.mjs +1 -1
- package/esm2022/ui/ui/services/dialog.service.mjs +3 -1
- package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs +10 -23
- package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-core.mjs +26 -8
- package/fesm2022/arsedizioni-ars-utils-core.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-ui.mjs +2 -0
- package/fesm2022/arsedizioni-ars-utils-ui.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -7,7 +7,7 @@ import { HttpParams } from '@angular/common/http';
|
|
|
7
7
|
import { fromZonedTime } from 'date-fns-tz';
|
|
8
8
|
import { NG_VALIDATORS } from '@angular/forms';
|
|
9
9
|
import { debounceTime } from 'rxjs/operators';
|
|
10
|
-
import { Subject } from 'rxjs';
|
|
10
|
+
import { Subject, BehaviorSubject } from 'rxjs';
|
|
11
11
|
import { DateAdapter, MAT_DATE_LOCALE, MAT_DATE_FORMATS } from '@angular/material/core';
|
|
12
12
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
13
13
|
|
|
@@ -1928,6 +1928,18 @@ class ThemeService {
|
|
|
1928
1928
|
this.broadcastMessage = '$theme-changed';
|
|
1929
1929
|
// per intercettare il cambio di tema a livello di sistema
|
|
1930
1930
|
this.prefersColorSchemeMediaQueryList = window.matchMedia('(prefers-color-scheme: dark)');
|
|
1931
|
+
/**
|
|
1932
|
+
* Theme changed event.
|
|
1933
|
+
* Notify the consuming component about the incoming theme change.
|
|
1934
|
+
* @example
|
|
1935
|
+
* // React to theme changes
|
|
1936
|
+
* this.themeService.themeChanged
|
|
1937
|
+
* .pipe(takeUntil(this.unsubscribe))
|
|
1938
|
+
* .subscribe((value: ThemeType) => {
|
|
1939
|
+
* // do the job done....
|
|
1940
|
+
* });
|
|
1941
|
+
*/
|
|
1942
|
+
this.themeChanged = new BehaviorSubject('auto');
|
|
1931
1943
|
this.renderFactory2 = inject(RendererFactory2);
|
|
1932
1944
|
this.renderer = this.renderFactory2.createRenderer(null, null);
|
|
1933
1945
|
/**
|
|
@@ -1982,14 +1994,20 @@ class ThemeService {
|
|
|
1982
1994
|
this.broadcastChannel.dispose();
|
|
1983
1995
|
}
|
|
1984
1996
|
/**
|
|
1985
|
-
*
|
|
1997
|
+
* Get the current preferred theme
|
|
1986
1998
|
*/
|
|
1987
|
-
|
|
1999
|
+
getPreferredTheme() {
|
|
1988
2000
|
let theme = localStorage.getItem("preferred-theme");
|
|
1989
2001
|
if (!this.isTheme(theme)) {
|
|
1990
2002
|
theme = 'auto';
|
|
1991
2003
|
}
|
|
1992
|
-
|
|
2004
|
+
return theme;
|
|
2005
|
+
}
|
|
2006
|
+
/**
|
|
2007
|
+
* Load theme
|
|
2008
|
+
*/
|
|
2009
|
+
loadTheme() {
|
|
2010
|
+
this.setTheme(this.getPreferredTheme());
|
|
1993
2011
|
}
|
|
1994
2012
|
/**
|
|
1995
2013
|
* Check if a value string is a theme type
|
|
@@ -2009,6 +2027,8 @@ class ThemeService {
|
|
|
2009
2027
|
this.theme.set(theme);
|
|
2010
2028
|
localStorage.setItem("preferred-theme", this.theme());
|
|
2011
2029
|
this.renderer.addClass(document.body, this.auto() ? (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") : theme);
|
|
2030
|
+
// Notify that current theme has changed
|
|
2031
|
+
this.themeChanged.next(this.getTheme());
|
|
2012
2032
|
this.broadcastChannel.sendMessage(this.broadcastMessage, this.theme());
|
|
2013
2033
|
}
|
|
2014
2034
|
/**
|
|
@@ -2018,14 +2038,12 @@ class ThemeService {
|
|
|
2018
2038
|
this.setTheme(this.themeInfo[this.theme()].next);
|
|
2019
2039
|
}
|
|
2020
2040
|
/**
|
|
2021
|
-
* Get current
|
|
2022
|
-
* // Load current theme
|
|
2041
|
+
* Get current real theme: light or dark
|
|
2023
2042
|
*/
|
|
2024
2043
|
getTheme() {
|
|
2025
|
-
this.loadTheme();
|
|
2026
2044
|
return (this.auto()
|
|
2027
2045
|
? (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light")
|
|
2028
|
-
: this.
|
|
2046
|
+
: this.getPreferredTheme());
|
|
2029
2047
|
}
|
|
2030
2048
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.3", ngImport: i0, type: ThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2031
2049
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.3", ngImport: i0, type: ThemeService, providedIn: "root" }); }
|