mithril-materialized 3.14.4 → 3.14.5
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/dist/index.esm.js +52 -17
- package/dist/index.js +52 -17
- package/dist/index.umd.js +52 -17
- package/dist/theme-switcher.d.ts +22 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -8869,10 +8869,26 @@ const defaultI18n$1 = {
|
|
|
8869
8869
|
* Theme switching utilities and component
|
|
8870
8870
|
*/
|
|
8871
8871
|
class ThemeManager {
|
|
8872
|
+
/**
|
|
8873
|
+
* Configure whether ThemeManager should use localStorage for persistence.
|
|
8874
|
+
* When disabled, you can manage theme state externally and pass it via component attrs.
|
|
8875
|
+
* @param enabled - Whether to use localStorage (default: true)
|
|
8876
|
+
*/
|
|
8877
|
+
static setUseLocalStorage(enabled) {
|
|
8878
|
+
this.useLocalStorage = enabled;
|
|
8879
|
+
}
|
|
8880
|
+
/**
|
|
8881
|
+
* Check if localStorage persistence is enabled
|
|
8882
|
+
*/
|
|
8883
|
+
static isUsingLocalStorage() {
|
|
8884
|
+
return this.useLocalStorage;
|
|
8885
|
+
}
|
|
8872
8886
|
/**
|
|
8873
8887
|
* Set the theme for the entire application
|
|
8888
|
+
* @param theme - The theme to set
|
|
8889
|
+
* @param persist - Override localStorage behavior for this call (optional)
|
|
8874
8890
|
*/
|
|
8875
|
-
static setTheme(theme) {
|
|
8891
|
+
static setTheme(theme, persist) {
|
|
8876
8892
|
this.currentTheme = theme;
|
|
8877
8893
|
const root = document.documentElement;
|
|
8878
8894
|
if (theme === 'auto') {
|
|
@@ -8883,12 +8899,15 @@ class ThemeManager {
|
|
|
8883
8899
|
// Set explicit theme
|
|
8884
8900
|
root.setAttribute('data-theme', theme);
|
|
8885
8901
|
}
|
|
8886
|
-
// Store preference in localStorage
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8902
|
+
// Store preference in localStorage if enabled
|
|
8903
|
+
const shouldPersist = persist !== null && persist !== void 0 ? persist : this.useLocalStorage;
|
|
8904
|
+
if (shouldPersist) {
|
|
8905
|
+
try {
|
|
8906
|
+
localStorage.setItem('mm-theme', theme);
|
|
8907
|
+
}
|
|
8908
|
+
catch (e) {
|
|
8909
|
+
// localStorage might not be available
|
|
8910
|
+
}
|
|
8892
8911
|
}
|
|
8893
8912
|
}
|
|
8894
8913
|
/**
|
|
@@ -8911,18 +8930,22 @@ class ThemeManager {
|
|
|
8911
8930
|
return 'light';
|
|
8912
8931
|
}
|
|
8913
8932
|
/**
|
|
8914
|
-
* Initialize theme from localStorage or system preference
|
|
8933
|
+
* Initialize theme from localStorage or system preference.
|
|
8934
|
+
* If localStorage is disabled, initializes to the provided default or 'auto'.
|
|
8935
|
+
* @param defaultTheme - Default theme to use when localStorage is disabled or empty
|
|
8915
8936
|
*/
|
|
8916
|
-
static initialize() {
|
|
8917
|
-
let savedTheme =
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8937
|
+
static initialize(defaultTheme = 'auto') {
|
|
8938
|
+
let savedTheme = defaultTheme;
|
|
8939
|
+
if (this.useLocalStorage) {
|
|
8940
|
+
try {
|
|
8941
|
+
const stored = localStorage.getItem('mm-theme');
|
|
8942
|
+
if (stored && ['light', 'dark', 'auto'].includes(stored)) {
|
|
8943
|
+
savedTheme = stored;
|
|
8944
|
+
}
|
|
8945
|
+
}
|
|
8946
|
+
catch (e) {
|
|
8947
|
+
// localStorage might not be available
|
|
8922
8948
|
}
|
|
8923
|
-
}
|
|
8924
|
-
catch (e) {
|
|
8925
|
-
// localStorage might not be available
|
|
8926
8949
|
}
|
|
8927
8950
|
this.setTheme(savedTheme);
|
|
8928
8951
|
}
|
|
@@ -8933,8 +8956,20 @@ class ThemeManager {
|
|
|
8933
8956
|
const current = this.getEffectiveTheme();
|
|
8934
8957
|
this.setTheme(current === 'light' ? 'dark' : 'light');
|
|
8935
8958
|
}
|
|
8959
|
+
/**
|
|
8960
|
+
* Clear the stored theme from localStorage
|
|
8961
|
+
*/
|
|
8962
|
+
static clearStoredTheme() {
|
|
8963
|
+
try {
|
|
8964
|
+
localStorage.removeItem('mm-theme');
|
|
8965
|
+
}
|
|
8966
|
+
catch (e) {
|
|
8967
|
+
// localStorage might not be available
|
|
8968
|
+
}
|
|
8969
|
+
}
|
|
8936
8970
|
}
|
|
8937
8971
|
ThemeManager.currentTheme = 'auto';
|
|
8972
|
+
ThemeManager.useLocalStorage = true;
|
|
8938
8973
|
/**
|
|
8939
8974
|
* Theme Switcher Component
|
|
8940
8975
|
* Provides UI controls for changing themes
|
package/dist/index.js
CHANGED
|
@@ -8871,10 +8871,26 @@ const defaultI18n$1 = {
|
|
|
8871
8871
|
* Theme switching utilities and component
|
|
8872
8872
|
*/
|
|
8873
8873
|
class ThemeManager {
|
|
8874
|
+
/**
|
|
8875
|
+
* Configure whether ThemeManager should use localStorage for persistence.
|
|
8876
|
+
* When disabled, you can manage theme state externally and pass it via component attrs.
|
|
8877
|
+
* @param enabled - Whether to use localStorage (default: true)
|
|
8878
|
+
*/
|
|
8879
|
+
static setUseLocalStorage(enabled) {
|
|
8880
|
+
this.useLocalStorage = enabled;
|
|
8881
|
+
}
|
|
8882
|
+
/**
|
|
8883
|
+
* Check if localStorage persistence is enabled
|
|
8884
|
+
*/
|
|
8885
|
+
static isUsingLocalStorage() {
|
|
8886
|
+
return this.useLocalStorage;
|
|
8887
|
+
}
|
|
8874
8888
|
/**
|
|
8875
8889
|
* Set the theme for the entire application
|
|
8890
|
+
* @param theme - The theme to set
|
|
8891
|
+
* @param persist - Override localStorage behavior for this call (optional)
|
|
8876
8892
|
*/
|
|
8877
|
-
static setTheme(theme) {
|
|
8893
|
+
static setTheme(theme, persist) {
|
|
8878
8894
|
this.currentTheme = theme;
|
|
8879
8895
|
const root = document.documentElement;
|
|
8880
8896
|
if (theme === 'auto') {
|
|
@@ -8885,12 +8901,15 @@ class ThemeManager {
|
|
|
8885
8901
|
// Set explicit theme
|
|
8886
8902
|
root.setAttribute('data-theme', theme);
|
|
8887
8903
|
}
|
|
8888
|
-
// Store preference in localStorage
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8904
|
+
// Store preference in localStorage if enabled
|
|
8905
|
+
const shouldPersist = persist !== null && persist !== void 0 ? persist : this.useLocalStorage;
|
|
8906
|
+
if (shouldPersist) {
|
|
8907
|
+
try {
|
|
8908
|
+
localStorage.setItem('mm-theme', theme);
|
|
8909
|
+
}
|
|
8910
|
+
catch (e) {
|
|
8911
|
+
// localStorage might not be available
|
|
8912
|
+
}
|
|
8894
8913
|
}
|
|
8895
8914
|
}
|
|
8896
8915
|
/**
|
|
@@ -8913,18 +8932,22 @@ class ThemeManager {
|
|
|
8913
8932
|
return 'light';
|
|
8914
8933
|
}
|
|
8915
8934
|
/**
|
|
8916
|
-
* Initialize theme from localStorage or system preference
|
|
8935
|
+
* Initialize theme from localStorage or system preference.
|
|
8936
|
+
* If localStorage is disabled, initializes to the provided default or 'auto'.
|
|
8937
|
+
* @param defaultTheme - Default theme to use when localStorage is disabled or empty
|
|
8917
8938
|
*/
|
|
8918
|
-
static initialize() {
|
|
8919
|
-
let savedTheme =
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8939
|
+
static initialize(defaultTheme = 'auto') {
|
|
8940
|
+
let savedTheme = defaultTheme;
|
|
8941
|
+
if (this.useLocalStorage) {
|
|
8942
|
+
try {
|
|
8943
|
+
const stored = localStorage.getItem('mm-theme');
|
|
8944
|
+
if (stored && ['light', 'dark', 'auto'].includes(stored)) {
|
|
8945
|
+
savedTheme = stored;
|
|
8946
|
+
}
|
|
8947
|
+
}
|
|
8948
|
+
catch (e) {
|
|
8949
|
+
// localStorage might not be available
|
|
8924
8950
|
}
|
|
8925
|
-
}
|
|
8926
|
-
catch (e) {
|
|
8927
|
-
// localStorage might not be available
|
|
8928
8951
|
}
|
|
8929
8952
|
this.setTheme(savedTheme);
|
|
8930
8953
|
}
|
|
@@ -8935,8 +8958,20 @@ class ThemeManager {
|
|
|
8935
8958
|
const current = this.getEffectiveTheme();
|
|
8936
8959
|
this.setTheme(current === 'light' ? 'dark' : 'light');
|
|
8937
8960
|
}
|
|
8961
|
+
/**
|
|
8962
|
+
* Clear the stored theme from localStorage
|
|
8963
|
+
*/
|
|
8964
|
+
static clearStoredTheme() {
|
|
8965
|
+
try {
|
|
8966
|
+
localStorage.removeItem('mm-theme');
|
|
8967
|
+
}
|
|
8968
|
+
catch (e) {
|
|
8969
|
+
// localStorage might not be available
|
|
8970
|
+
}
|
|
8971
|
+
}
|
|
8938
8972
|
}
|
|
8939
8973
|
ThemeManager.currentTheme = 'auto';
|
|
8974
|
+
ThemeManager.useLocalStorage = true;
|
|
8940
8975
|
/**
|
|
8941
8976
|
* Theme Switcher Component
|
|
8942
8977
|
* Provides UI controls for changing themes
|
package/dist/index.umd.js
CHANGED
|
@@ -8873,10 +8873,26 @@
|
|
|
8873
8873
|
* Theme switching utilities and component
|
|
8874
8874
|
*/
|
|
8875
8875
|
class ThemeManager {
|
|
8876
|
+
/**
|
|
8877
|
+
* Configure whether ThemeManager should use localStorage for persistence.
|
|
8878
|
+
* When disabled, you can manage theme state externally and pass it via component attrs.
|
|
8879
|
+
* @param enabled - Whether to use localStorage (default: true)
|
|
8880
|
+
*/
|
|
8881
|
+
static setUseLocalStorage(enabled) {
|
|
8882
|
+
this.useLocalStorage = enabled;
|
|
8883
|
+
}
|
|
8884
|
+
/**
|
|
8885
|
+
* Check if localStorage persistence is enabled
|
|
8886
|
+
*/
|
|
8887
|
+
static isUsingLocalStorage() {
|
|
8888
|
+
return this.useLocalStorage;
|
|
8889
|
+
}
|
|
8876
8890
|
/**
|
|
8877
8891
|
* Set the theme for the entire application
|
|
8892
|
+
* @param theme - The theme to set
|
|
8893
|
+
* @param persist - Override localStorage behavior for this call (optional)
|
|
8878
8894
|
*/
|
|
8879
|
-
static setTheme(theme) {
|
|
8895
|
+
static setTheme(theme, persist) {
|
|
8880
8896
|
this.currentTheme = theme;
|
|
8881
8897
|
const root = document.documentElement;
|
|
8882
8898
|
if (theme === 'auto') {
|
|
@@ -8887,12 +8903,15 @@
|
|
|
8887
8903
|
// Set explicit theme
|
|
8888
8904
|
root.setAttribute('data-theme', theme);
|
|
8889
8905
|
}
|
|
8890
|
-
// Store preference in localStorage
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8906
|
+
// Store preference in localStorage if enabled
|
|
8907
|
+
const shouldPersist = persist !== null && persist !== void 0 ? persist : this.useLocalStorage;
|
|
8908
|
+
if (shouldPersist) {
|
|
8909
|
+
try {
|
|
8910
|
+
localStorage.setItem('mm-theme', theme);
|
|
8911
|
+
}
|
|
8912
|
+
catch (e) {
|
|
8913
|
+
// localStorage might not be available
|
|
8914
|
+
}
|
|
8896
8915
|
}
|
|
8897
8916
|
}
|
|
8898
8917
|
/**
|
|
@@ -8915,18 +8934,22 @@
|
|
|
8915
8934
|
return 'light';
|
|
8916
8935
|
}
|
|
8917
8936
|
/**
|
|
8918
|
-
* Initialize theme from localStorage or system preference
|
|
8937
|
+
* Initialize theme from localStorage or system preference.
|
|
8938
|
+
* If localStorage is disabled, initializes to the provided default or 'auto'.
|
|
8939
|
+
* @param defaultTheme - Default theme to use when localStorage is disabled or empty
|
|
8919
8940
|
*/
|
|
8920
|
-
static initialize() {
|
|
8921
|
-
let savedTheme =
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8941
|
+
static initialize(defaultTheme = 'auto') {
|
|
8942
|
+
let savedTheme = defaultTheme;
|
|
8943
|
+
if (this.useLocalStorage) {
|
|
8944
|
+
try {
|
|
8945
|
+
const stored = localStorage.getItem('mm-theme');
|
|
8946
|
+
if (stored && ['light', 'dark', 'auto'].includes(stored)) {
|
|
8947
|
+
savedTheme = stored;
|
|
8948
|
+
}
|
|
8949
|
+
}
|
|
8950
|
+
catch (e) {
|
|
8951
|
+
// localStorage might not be available
|
|
8926
8952
|
}
|
|
8927
|
-
}
|
|
8928
|
-
catch (e) {
|
|
8929
|
-
// localStorage might not be available
|
|
8930
8953
|
}
|
|
8931
8954
|
this.setTheme(savedTheme);
|
|
8932
8955
|
}
|
|
@@ -8937,8 +8960,20 @@
|
|
|
8937
8960
|
const current = this.getEffectiveTheme();
|
|
8938
8961
|
this.setTheme(current === 'light' ? 'dark' : 'light');
|
|
8939
8962
|
}
|
|
8963
|
+
/**
|
|
8964
|
+
* Clear the stored theme from localStorage
|
|
8965
|
+
*/
|
|
8966
|
+
static clearStoredTheme() {
|
|
8967
|
+
try {
|
|
8968
|
+
localStorage.removeItem('mm-theme');
|
|
8969
|
+
}
|
|
8970
|
+
catch (e) {
|
|
8971
|
+
// localStorage might not be available
|
|
8972
|
+
}
|
|
8973
|
+
}
|
|
8940
8974
|
}
|
|
8941
8975
|
ThemeManager.currentTheme = 'auto';
|
|
8976
|
+
ThemeManager.useLocalStorage = true;
|
|
8942
8977
|
/**
|
|
8943
8978
|
* Theme Switcher Component
|
|
8944
8979
|
* Provides UI controls for changing themes
|
package/dist/theme-switcher.d.ts
CHANGED
|
@@ -37,10 +37,23 @@ export interface ThemeSwitcherAttrs {
|
|
|
37
37
|
*/
|
|
38
38
|
export declare class ThemeManager {
|
|
39
39
|
private static currentTheme;
|
|
40
|
+
private static useLocalStorage;
|
|
41
|
+
/**
|
|
42
|
+
* Configure whether ThemeManager should use localStorage for persistence.
|
|
43
|
+
* When disabled, you can manage theme state externally and pass it via component attrs.
|
|
44
|
+
* @param enabled - Whether to use localStorage (default: true)
|
|
45
|
+
*/
|
|
46
|
+
static setUseLocalStorage(enabled: boolean): void;
|
|
47
|
+
/**
|
|
48
|
+
* Check if localStorage persistence is enabled
|
|
49
|
+
*/
|
|
50
|
+
static isUsingLocalStorage(): boolean;
|
|
40
51
|
/**
|
|
41
52
|
* Set the theme for the entire application
|
|
53
|
+
* @param theme - The theme to set
|
|
54
|
+
* @param persist - Override localStorage behavior for this call (optional)
|
|
42
55
|
*/
|
|
43
|
-
static setTheme(theme: Theme): void;
|
|
56
|
+
static setTheme(theme: Theme, persist?: boolean): void;
|
|
44
57
|
/**
|
|
45
58
|
* Get the current theme
|
|
46
59
|
*/
|
|
@@ -50,13 +63,19 @@ export declare class ThemeManager {
|
|
|
50
63
|
*/
|
|
51
64
|
static getEffectiveTheme(): 'light' | 'dark';
|
|
52
65
|
/**
|
|
53
|
-
* Initialize theme from localStorage or system preference
|
|
66
|
+
* Initialize theme from localStorage or system preference.
|
|
67
|
+
* If localStorage is disabled, initializes to the provided default or 'auto'.
|
|
68
|
+
* @param defaultTheme - Default theme to use when localStorage is disabled or empty
|
|
54
69
|
*/
|
|
55
|
-
static initialize(): void;
|
|
70
|
+
static initialize(defaultTheme?: Theme): void;
|
|
56
71
|
/**
|
|
57
72
|
* Toggle between light and dark themes
|
|
58
73
|
*/
|
|
59
74
|
static toggle(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Clear the stored theme from localStorage
|
|
77
|
+
*/
|
|
78
|
+
static clearStoredTheme(): void;
|
|
60
79
|
}
|
|
61
80
|
/**
|
|
62
81
|
* Theme Switcher Component
|