esewa-ui-library 1.0.9 → 1.10.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.js CHANGED
@@ -7654,14 +7654,21 @@ var darkTheme = _extends({}, theme, darkThemeColors);
7654
7654
 
7655
7655
  var ESewaThemeProvider = function ESewaThemeProvider(_ref) {
7656
7656
  var children = _ref.children;
7657
- var updateDocumentTheme = function updateDocumentTheme(theme) {
7658
- document.documentElement.setAttribute('data-theme', theme);
7659
- };
7660
- var themeType = window.matchMedia('(prefers-color-scheme: dark)').matches ? darkTheme : lightTheme;
7661
- var themeColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
7657
+ var _useState = React.useState(lightTheme),
7658
+ themeType = _useState[0],
7659
+ setThemeType = _useState[1];
7660
+ var _useState2 = React.useState('light'),
7661
+ setThemeColor = _useState2[1];
7662
7662
  React.useEffect(function () {
7663
- updateDocumentTheme(themeColor);
7664
- }, [themeType, themeColor]);
7663
+ if (typeof window !== 'undefined') {
7664
+ var prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
7665
+ var newThemeType = prefersDark ? darkTheme : lightTheme;
7666
+ var newThemeColor = prefersDark ? 'dark' : 'light';
7667
+ setThemeType(newThemeType);
7668
+ setThemeColor(newThemeColor);
7669
+ document.documentElement.setAttribute('data-theme', newThemeColor);
7670
+ }
7671
+ }, []);
7665
7672
  return React__default.createElement(styled.ThemeProvider, {
7666
7673
  theme: themeType
7667
7674
  }, children);