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.
@@ -7665,14 +7665,21 @@ var darkTheme = _extends({}, theme, darkThemeColors);
7665
7665
 
7666
7666
  var ESewaThemeProvider = function ESewaThemeProvider(_ref) {
7667
7667
  var children = _ref.children;
7668
- var updateDocumentTheme = function updateDocumentTheme(theme) {
7669
- document.documentElement.setAttribute('data-theme', theme);
7670
- };
7671
- var themeType = window.matchMedia('(prefers-color-scheme: dark)').matches ? darkTheme : lightTheme;
7672
- var themeColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
7668
+ var _useState = useState(lightTheme),
7669
+ themeType = _useState[0],
7670
+ setThemeType = _useState[1];
7671
+ var _useState2 = useState('light'),
7672
+ setThemeColor = _useState2[1];
7673
7673
  useEffect(function () {
7674
- updateDocumentTheme(themeColor);
7675
- }, [themeType, themeColor]);
7674
+ if (typeof window !== 'undefined') {
7675
+ var prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
7676
+ var newThemeType = prefersDark ? darkTheme : lightTheme;
7677
+ var newThemeColor = prefersDark ? 'dark' : 'light';
7678
+ setThemeType(newThemeType);
7679
+ setThemeColor(newThemeColor);
7680
+ document.documentElement.setAttribute('data-theme', newThemeColor);
7681
+ }
7682
+ }, []);
7676
7683
  return React__default.createElement(ThemeProvider, {
7677
7684
  theme: themeType
7678
7685
  }, children);