@mlw-packages/react-components 1.5.1 → 1.5.2

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.js CHANGED
@@ -4292,9 +4292,7 @@ function ThemeProviderBase({
4292
4292
  storageKey = "app-ui-theme",
4293
4293
  ...props
4294
4294
  }) {
4295
- const [theme, setTheme] = (0, import_react22.useState)(() => {
4296
- return localStorage.getItem(storageKey) || defaultTheme;
4297
- });
4295
+ const [theme, setThemeState] = (0, import_react22.useState)(defaultTheme);
4298
4296
  (0, import_react22.useEffect)(() => {
4299
4297
  const root = window.document.documentElement;
4300
4298
  root.classList.remove(
@@ -4321,13 +4319,17 @@ function ThemeProviderBase({
4321
4319
  document.body.style.color = "";
4322
4320
  }
4323
4321
  }, [theme]);
4324
- const value = {
4325
- theme,
4326
- setTheme: (theme2) => {
4327
- localStorage.setItem(storageKey, theme2);
4328
- setTheme(theme2);
4322
+ (0, import_react22.useEffect)(() => {
4323
+ const stored = localStorage.getItem(storageKey);
4324
+ if (stored) setThemeState(stored);
4325
+ }, [storageKey]);
4326
+ const setTheme = (newTheme) => {
4327
+ if (typeof window !== "undefined") {
4328
+ localStorage.setItem(storageKey, newTheme);
4329
4329
  }
4330
+ setThemeState(newTheme);
4330
4331
  };
4332
+ const value = { theme, setTheme };
4331
4333
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ThemeProviderContext.Provider, { ...props, value, children });
4332
4334
  }
4333
4335
  var useTheme = () => {
package/dist/index.mjs CHANGED
@@ -4083,9 +4083,7 @@ function ThemeProviderBase({
4083
4083
  storageKey = "app-ui-theme",
4084
4084
  ...props
4085
4085
  }) {
4086
- const [theme, setTheme] = useState6(() => {
4087
- return localStorage.getItem(storageKey) || defaultTheme;
4088
- });
4086
+ const [theme, setThemeState] = useState6(defaultTheme);
4089
4087
  useEffect5(() => {
4090
4088
  const root = window.document.documentElement;
4091
4089
  root.classList.remove(
@@ -4112,13 +4110,17 @@ function ThemeProviderBase({
4112
4110
  document.body.style.color = "";
4113
4111
  }
4114
4112
  }, [theme]);
4115
- const value = {
4116
- theme,
4117
- setTheme: (theme2) => {
4118
- localStorage.setItem(storageKey, theme2);
4119
- setTheme(theme2);
4113
+ useEffect5(() => {
4114
+ const stored = localStorage.getItem(storageKey);
4115
+ if (stored) setThemeState(stored);
4116
+ }, [storageKey]);
4117
+ const setTheme = (newTheme) => {
4118
+ if (typeof window !== "undefined") {
4119
+ localStorage.setItem(storageKey, newTheme);
4120
4120
  }
4121
+ setThemeState(newTheme);
4121
4122
  };
4123
+ const value = { theme, setTheme };
4122
4124
  return /* @__PURE__ */ jsx39(ThemeProviderContext.Provider, { ...props, value, children });
4123
4125
  }
4124
4126
  var useTheme = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlw-packages/react-components",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",