@arsedizioni/ars-utils 18.2.283 → 18.2.285
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/definitions.d.ts +6 -0
- package/core/public_api.d.ts +1 -0
- package/core/services/broadcastChannelManager.d.ts +83 -0
- package/core/services/theme.service.d.ts +6 -0
- package/esm2022/clipper.common/common/definitions.mjs +42 -1
- package/esm2022/core/public_api.mjs +2 -1
- package/esm2022/core/services/broadcastChannelManager.mjs +80 -0
- package/esm2022/core/services/theme.service.mjs +18 -8
- package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs +41 -0
- package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-core.mjs +17 -7
- package/fesm2022/arsedizioni-ars-utils-core.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1958,9 +1958,9 @@ class ThemeService {
|
|
|
1958
1958
|
* Tooltip text on toggle
|
|
1959
1959
|
*/
|
|
1960
1960
|
this.toggleTooltip = computed(() => this.themeInfo[this.theme()].tooltip);
|
|
1961
|
-
//
|
|
1961
|
+
// React to current theme
|
|
1962
1962
|
this.prefersColorSchemeMediaQueryList.onchange = (_) => this.auto() ? this.setTheme() : null;
|
|
1963
|
-
//
|
|
1963
|
+
// Support boradcast channel messaging
|
|
1964
1964
|
this.broadcastChannel.subscribe({
|
|
1965
1965
|
messageId: this.broadcastMessage,
|
|
1966
1966
|
action: (bag) => {
|
|
@@ -1969,13 +1969,24 @@ class ThemeService {
|
|
|
1969
1969
|
}
|
|
1970
1970
|
}
|
|
1971
1971
|
});
|
|
1972
|
-
//
|
|
1973
|
-
|
|
1972
|
+
// Initialize
|
|
1973
|
+
let theme = localStorage.getItem("preferred-theme");
|
|
1974
|
+
if (!this.isTheme(theme)) {
|
|
1975
|
+
theme = 'auto';
|
|
1976
|
+
}
|
|
1977
|
+
this.setTheme(theme);
|
|
1974
1978
|
}
|
|
1975
1979
|
ngOnDestroy() {
|
|
1976
|
-
// chiude il canale di comunicazione broadcast
|
|
1977
1980
|
this.broadcastChannel.dispose();
|
|
1978
1981
|
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Check if a value string is a theme type
|
|
1984
|
+
* @param value : th string value
|
|
1985
|
+
* @returns true if the the value is a valid theme type
|
|
1986
|
+
*/
|
|
1987
|
+
isTheme(value) {
|
|
1988
|
+
return ['auto', 'light', 'dark'].includes(value);
|
|
1989
|
+
}
|
|
1979
1990
|
/**
|
|
1980
1991
|
* Set the new theme
|
|
1981
1992
|
* @param theme the new theme
|
|
@@ -1986,7 +1997,6 @@ class ThemeService {
|
|
|
1986
1997
|
this.theme.set(theme);
|
|
1987
1998
|
localStorage.setItem("preferred-theme", this.theme());
|
|
1988
1999
|
this.renderer.addClass(document.body, this.auto() ? (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") : theme);
|
|
1989
|
-
// lancia il messaggio broadcast
|
|
1990
2000
|
this.broadcastChannel.sendMessage(this.broadcastMessage, this.theme());
|
|
1991
2001
|
}
|
|
1992
2002
|
/**
|
|
@@ -2151,5 +2161,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
2151
2161
|
* Generated bundle index. Do not edit.
|
|
2152
2162
|
*/
|
|
2153
2163
|
|
|
2154
|
-
export { ArsCoreModule, ArsDateFnsModule, AutoFocusDirective, BroadcastService, CopyClipboardDirective, DateFnsAdapter, DateFormat, DateInterval, DateIntervalChangeDirective, DeleteModel, EmailsValidatorDirective, EnvironmentService, EqualsValidatorDirective, FileInfo, FileSizeValidatorDirective, FormatPipe, GroupModel, GuidValidatorDirective, IDModel, ImportModel, MAT_DATE_FNS_FORMATS, NotFutureValidatorDirective, PasswordValidatorDirective, QueryModel, RelationModel, ReplacePipe, SafeHtmlPipe, SafeUrlPipe, ScreenService, SearchCallbackPipe, SearchFilterPipe, SelectableModel, SqlDateValidatorDirective, SystemUtils, ThemeService, TimeValidatorDirective, UpdateRelationsModel, UrlValidatorDirective, ValidIfDirective, ValidatorDirective, ValueModel };
|
|
2164
|
+
export { ArsCoreModule, ArsDateFnsModule, AutoFocusDirective, BroadcastChannelManager, BroadcastService, CopyClipboardDirective, DateFnsAdapter, DateFormat, DateInterval, DateIntervalChangeDirective, DeleteModel, EmailsValidatorDirective, EnvironmentService, EqualsValidatorDirective, FileInfo, FileSizeValidatorDirective, FormatPipe, GroupModel, GuidValidatorDirective, IDModel, ImportModel, MAT_DATE_FNS_FORMATS, NotFutureValidatorDirective, PasswordValidatorDirective, QueryModel, RelationModel, ReplacePipe, SafeHtmlPipe, SafeUrlPipe, ScreenService, SearchCallbackPipe, SearchFilterPipe, SelectableModel, SqlDateValidatorDirective, SystemUtils, ThemeService, TimeValidatorDirective, UpdateRelationsModel, UrlValidatorDirective, ValidIfDirective, ValidatorDirective, ValueModel };
|
|
2155
2165
|
//# sourceMappingURL=arsedizioni-ars-utils-core.mjs.map
|