mithril-materialized 3.14.4 → 3.15.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/dist/index.esm.js CHANGED
@@ -4584,6 +4584,7 @@ const DataTable = () => {
4584
4584
  style: {
4585
4585
  maxHeight: height ? `${height}px` : undefined,
4586
4586
  overflowY: height ? 'auto' : undefined,
4587
+ overflowX: responsive ? 'auto' : undefined,
4587
4588
  },
4588
4589
  }, processedData.length === 0
4589
4590
  ? m('.datatable-empty', emptyMessage || (i18n === null || i18n === void 0 ? void 0 : i18n.noDataAvailable) || 'No data available')
@@ -8869,10 +8870,26 @@ const defaultI18n$1 = {
8869
8870
  * Theme switching utilities and component
8870
8871
  */
8871
8872
  class ThemeManager {
8873
+ /**
8874
+ * Configure whether ThemeManager should use localStorage for persistence.
8875
+ * When disabled, you can manage theme state externally and pass it via component attrs.
8876
+ * @param enabled - Whether to use localStorage (default: true)
8877
+ */
8878
+ static setUseLocalStorage(enabled) {
8879
+ this.useLocalStorage = enabled;
8880
+ }
8881
+ /**
8882
+ * Check if localStorage persistence is enabled
8883
+ */
8884
+ static isUsingLocalStorage() {
8885
+ return this.useLocalStorage;
8886
+ }
8872
8887
  /**
8873
8888
  * Set the theme for the entire application
8889
+ * @param theme - The theme to set
8890
+ * @param persist - Override localStorage behavior for this call (optional)
8874
8891
  */
8875
- static setTheme(theme) {
8892
+ static setTheme(theme, persist) {
8876
8893
  this.currentTheme = theme;
8877
8894
  const root = document.documentElement;
8878
8895
  if (theme === 'auto') {
@@ -8883,12 +8900,15 @@ class ThemeManager {
8883
8900
  // Set explicit theme
8884
8901
  root.setAttribute('data-theme', theme);
8885
8902
  }
8886
- // Store preference in localStorage
8887
- try {
8888
- localStorage.setItem('mm-theme', theme);
8889
- }
8890
- catch (e) {
8891
- // localStorage might not be available
8903
+ // Store preference in localStorage if enabled
8904
+ const shouldPersist = persist !== null && persist !== void 0 ? persist : this.useLocalStorage;
8905
+ if (shouldPersist) {
8906
+ try {
8907
+ localStorage.setItem('mm-theme', theme);
8908
+ }
8909
+ catch (e) {
8910
+ // localStorage might not be available
8911
+ }
8892
8912
  }
8893
8913
  }
8894
8914
  /**
@@ -8911,18 +8931,22 @@ class ThemeManager {
8911
8931
  return 'light';
8912
8932
  }
8913
8933
  /**
8914
- * Initialize theme from localStorage or system preference
8934
+ * Initialize theme from localStorage or system preference.
8935
+ * If localStorage is disabled, initializes to the provided default or 'auto'.
8936
+ * @param defaultTheme - Default theme to use when localStorage is disabled or empty
8915
8937
  */
8916
- static initialize() {
8917
- let savedTheme = 'auto';
8918
- try {
8919
- const stored = localStorage.getItem('mm-theme');
8920
- if (stored && ['light', 'dark', 'auto'].includes(stored)) {
8921
- savedTheme = stored;
8938
+ static initialize(defaultTheme = 'auto') {
8939
+ let savedTheme = defaultTheme;
8940
+ if (this.useLocalStorage) {
8941
+ try {
8942
+ const stored = localStorage.getItem('mm-theme');
8943
+ if (stored && ['light', 'dark', 'auto'].includes(stored)) {
8944
+ savedTheme = stored;
8945
+ }
8946
+ }
8947
+ catch (e) {
8948
+ // localStorage might not be available
8922
8949
  }
8923
- }
8924
- catch (e) {
8925
- // localStorage might not be available
8926
8950
  }
8927
8951
  this.setTheme(savedTheme);
8928
8952
  }
@@ -8933,8 +8957,20 @@ class ThemeManager {
8933
8957
  const current = this.getEffectiveTheme();
8934
8958
  this.setTheme(current === 'light' ? 'dark' : 'light');
8935
8959
  }
8960
+ /**
8961
+ * Clear the stored theme from localStorage
8962
+ */
8963
+ static clearStoredTheme() {
8964
+ try {
8965
+ localStorage.removeItem('mm-theme');
8966
+ }
8967
+ catch (e) {
8968
+ // localStorage might not be available
8969
+ }
8970
+ }
8936
8971
  }
8937
8972
  ThemeManager.currentTheme = 'auto';
8973
+ ThemeManager.useLocalStorage = true;
8938
8974
  /**
8939
8975
  * Theme Switcher Component
8940
8976
  * Provides UI controls for changing themes
package/dist/index.js CHANGED
@@ -4586,6 +4586,7 @@ const DataTable = () => {
4586
4586
  style: {
4587
4587
  maxHeight: height ? `${height}px` : undefined,
4588
4588
  overflowY: height ? 'auto' : undefined,
4589
+ overflowX: responsive ? 'auto' : undefined,
4589
4590
  },
4590
4591
  }, processedData.length === 0
4591
4592
  ? m('.datatable-empty', emptyMessage || (i18n === null || i18n === void 0 ? void 0 : i18n.noDataAvailable) || 'No data available')
@@ -8871,10 +8872,26 @@ const defaultI18n$1 = {
8871
8872
  * Theme switching utilities and component
8872
8873
  */
8873
8874
  class ThemeManager {
8875
+ /**
8876
+ * Configure whether ThemeManager should use localStorage for persistence.
8877
+ * When disabled, you can manage theme state externally and pass it via component attrs.
8878
+ * @param enabled - Whether to use localStorage (default: true)
8879
+ */
8880
+ static setUseLocalStorage(enabled) {
8881
+ this.useLocalStorage = enabled;
8882
+ }
8883
+ /**
8884
+ * Check if localStorage persistence is enabled
8885
+ */
8886
+ static isUsingLocalStorage() {
8887
+ return this.useLocalStorage;
8888
+ }
8874
8889
  /**
8875
8890
  * Set the theme for the entire application
8891
+ * @param theme - The theme to set
8892
+ * @param persist - Override localStorage behavior for this call (optional)
8876
8893
  */
8877
- static setTheme(theme) {
8894
+ static setTheme(theme, persist) {
8878
8895
  this.currentTheme = theme;
8879
8896
  const root = document.documentElement;
8880
8897
  if (theme === 'auto') {
@@ -8885,12 +8902,15 @@ class ThemeManager {
8885
8902
  // Set explicit theme
8886
8903
  root.setAttribute('data-theme', theme);
8887
8904
  }
8888
- // Store preference in localStorage
8889
- try {
8890
- localStorage.setItem('mm-theme', theme);
8891
- }
8892
- catch (e) {
8893
- // localStorage might not be available
8905
+ // Store preference in localStorage if enabled
8906
+ const shouldPersist = persist !== null && persist !== void 0 ? persist : this.useLocalStorage;
8907
+ if (shouldPersist) {
8908
+ try {
8909
+ localStorage.setItem('mm-theme', theme);
8910
+ }
8911
+ catch (e) {
8912
+ // localStorage might not be available
8913
+ }
8894
8914
  }
8895
8915
  }
8896
8916
  /**
@@ -8913,18 +8933,22 @@ class ThemeManager {
8913
8933
  return 'light';
8914
8934
  }
8915
8935
  /**
8916
- * Initialize theme from localStorage or system preference
8936
+ * Initialize theme from localStorage or system preference.
8937
+ * If localStorage is disabled, initializes to the provided default or 'auto'.
8938
+ * @param defaultTheme - Default theme to use when localStorage is disabled or empty
8917
8939
  */
8918
- static initialize() {
8919
- let savedTheme = 'auto';
8920
- try {
8921
- const stored = localStorage.getItem('mm-theme');
8922
- if (stored && ['light', 'dark', 'auto'].includes(stored)) {
8923
- savedTheme = stored;
8940
+ static initialize(defaultTheme = 'auto') {
8941
+ let savedTheme = defaultTheme;
8942
+ if (this.useLocalStorage) {
8943
+ try {
8944
+ const stored = localStorage.getItem('mm-theme');
8945
+ if (stored && ['light', 'dark', 'auto'].includes(stored)) {
8946
+ savedTheme = stored;
8947
+ }
8948
+ }
8949
+ catch (e) {
8950
+ // localStorage might not be available
8924
8951
  }
8925
- }
8926
- catch (e) {
8927
- // localStorage might not be available
8928
8952
  }
8929
8953
  this.setTheme(savedTheme);
8930
8954
  }
@@ -8935,8 +8959,20 @@ class ThemeManager {
8935
8959
  const current = this.getEffectiveTheme();
8936
8960
  this.setTheme(current === 'light' ? 'dark' : 'light');
8937
8961
  }
8962
+ /**
8963
+ * Clear the stored theme from localStorage
8964
+ */
8965
+ static clearStoredTheme() {
8966
+ try {
8967
+ localStorage.removeItem('mm-theme');
8968
+ }
8969
+ catch (e) {
8970
+ // localStorage might not be available
8971
+ }
8972
+ }
8938
8973
  }
8939
8974
  ThemeManager.currentTheme = 'auto';
8975
+ ThemeManager.useLocalStorage = true;
8940
8976
  /**
8941
8977
  * Theme Switcher Component
8942
8978
  * Provides UI controls for changing themes
package/dist/index.umd.js CHANGED
@@ -4588,6 +4588,7 @@
4588
4588
  style: {
4589
4589
  maxHeight: height ? `${height}px` : undefined,
4590
4590
  overflowY: height ? 'auto' : undefined,
4591
+ overflowX: responsive ? 'auto' : undefined,
4591
4592
  },
4592
4593
  }, processedData.length === 0
4593
4594
  ? m('.datatable-empty', emptyMessage || (i18n === null || i18n === void 0 ? void 0 : i18n.noDataAvailable) || 'No data available')
@@ -8873,10 +8874,26 @@
8873
8874
  * Theme switching utilities and component
8874
8875
  */
8875
8876
  class ThemeManager {
8877
+ /**
8878
+ * Configure whether ThemeManager should use localStorage for persistence.
8879
+ * When disabled, you can manage theme state externally and pass it via component attrs.
8880
+ * @param enabled - Whether to use localStorage (default: true)
8881
+ */
8882
+ static setUseLocalStorage(enabled) {
8883
+ this.useLocalStorage = enabled;
8884
+ }
8885
+ /**
8886
+ * Check if localStorage persistence is enabled
8887
+ */
8888
+ static isUsingLocalStorage() {
8889
+ return this.useLocalStorage;
8890
+ }
8876
8891
  /**
8877
8892
  * Set the theme for the entire application
8893
+ * @param theme - The theme to set
8894
+ * @param persist - Override localStorage behavior for this call (optional)
8878
8895
  */
8879
- static setTheme(theme) {
8896
+ static setTheme(theme, persist) {
8880
8897
  this.currentTheme = theme;
8881
8898
  const root = document.documentElement;
8882
8899
  if (theme === 'auto') {
@@ -8887,12 +8904,15 @@
8887
8904
  // Set explicit theme
8888
8905
  root.setAttribute('data-theme', theme);
8889
8906
  }
8890
- // Store preference in localStorage
8891
- try {
8892
- localStorage.setItem('mm-theme', theme);
8893
- }
8894
- catch (e) {
8895
- // localStorage might not be available
8907
+ // Store preference in localStorage if enabled
8908
+ const shouldPersist = persist !== null && persist !== void 0 ? persist : this.useLocalStorage;
8909
+ if (shouldPersist) {
8910
+ try {
8911
+ localStorage.setItem('mm-theme', theme);
8912
+ }
8913
+ catch (e) {
8914
+ // localStorage might not be available
8915
+ }
8896
8916
  }
8897
8917
  }
8898
8918
  /**
@@ -8915,18 +8935,22 @@
8915
8935
  return 'light';
8916
8936
  }
8917
8937
  /**
8918
- * Initialize theme from localStorage or system preference
8938
+ * Initialize theme from localStorage or system preference.
8939
+ * If localStorage is disabled, initializes to the provided default or 'auto'.
8940
+ * @param defaultTheme - Default theme to use when localStorage is disabled or empty
8919
8941
  */
8920
- static initialize() {
8921
- let savedTheme = 'auto';
8922
- try {
8923
- const stored = localStorage.getItem('mm-theme');
8924
- if (stored && ['light', 'dark', 'auto'].includes(stored)) {
8925
- savedTheme = stored;
8942
+ static initialize(defaultTheme = 'auto') {
8943
+ let savedTheme = defaultTheme;
8944
+ if (this.useLocalStorage) {
8945
+ try {
8946
+ const stored = localStorage.getItem('mm-theme');
8947
+ if (stored && ['light', 'dark', 'auto'].includes(stored)) {
8948
+ savedTheme = stored;
8949
+ }
8950
+ }
8951
+ catch (e) {
8952
+ // localStorage might not be available
8926
8953
  }
8927
- }
8928
- catch (e) {
8929
- // localStorage might not be available
8930
8954
  }
8931
8955
  this.setTheme(savedTheme);
8932
8956
  }
@@ -8937,8 +8961,20 @@
8937
8961
  const current = this.getEffectiveTheme();
8938
8962
  this.setTheme(current === 'light' ? 'dark' : 'light');
8939
8963
  }
8964
+ /**
8965
+ * Clear the stored theme from localStorage
8966
+ */
8967
+ static clearStoredTheme() {
8968
+ try {
8969
+ localStorage.removeItem('mm-theme');
8970
+ }
8971
+ catch (e) {
8972
+ // localStorage might not be available
8973
+ }
8974
+ }
8940
8975
  }
8941
8976
  ThemeManager.currentTheme = 'auto';
8977
+ ThemeManager.useLocalStorage = true;
8942
8978
  /**
8943
8979
  * Theme Switcher Component
8944
8980
  * Provides UI controls for changing themes
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mithril-materialized",
3
- "version": "3.14.4",
3
+ "version": "3.15.0",
4
4
  "description": "A materialize library for mithril.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -74,26 +74,26 @@
74
74
  "mithril": "^2.3.8"
75
75
  },
76
76
  "devDependencies": {
77
- "@playwright/test": "^1.57.0",
77
+ "@playwright/test": "^1.58.2",
78
78
  "@rollup/plugin-typescript": "^12.3.0",
79
79
  "@testing-library/dom": "^10.4.1",
80
80
  "@testing-library/jest-dom": "^6.9.1",
81
81
  "@testing-library/user-event": "^14.6.1",
82
82
  "@types/jest": "^30.0.0",
83
- "@types/mithril": "^2.2.7",
84
- "autoprefixer": "^10.4.23",
83
+ "@types/mithril": "^2.2.8",
84
+ "autoprefixer": "^10.4.27",
85
85
  "concurrently": "^9.2.1",
86
86
  "identity-obj-proxy": "^3.0.0",
87
- "jest": "^30.2.0",
88
- "jest-environment-jsdom": "^30.2.0",
87
+ "jest": "^30.3.0",
88
+ "jest-environment-jsdom": "^30.3.0",
89
89
  "js-yaml": "^4.1.1",
90
- "rimraf": "^6.1.2",
91
- "rollup": "^4.54.0",
90
+ "rimraf": "^6.1.3",
91
+ "rollup": "^4.59.0",
92
92
  "rollup-plugin-postcss": "^4.0.2",
93
- "sass": "^1.97.1",
93
+ "sass": "^1.98.0",
94
94
  "ts-jest": "^29.4.6",
95
95
  "tslib": "^2.8.1",
96
- "typedoc": "^0.28.15",
96
+ "typedoc": "^0.28.17",
97
97
  "typescript": "^5.9.3"
98
98
  }
99
99
  }