@hyphen/hyphen-components 2.11.5 → 2.12.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.
@@ -8,7 +8,8 @@ type ThemeProviderProps = {
8
8
  type ThemeProviderState = {
9
9
  theme: Theme;
10
10
  setTheme: (theme: Theme) => void;
11
+ isDarkMode?: boolean;
11
12
  };
13
+ export declare const ThemeProviderContext: React.Context<ThemeProviderState>;
12
14
  export declare function ThemeProvider({ children, defaultTheme, storageKey, ...props }: ThemeProviderProps): React.JSX.Element;
13
- export declare const useTheme: () => ThemeProviderState;
14
15
  export {};
@@ -1,4 +1,5 @@
1
1
  export * from './useBreakpoint/useBreakpoint';
2
+ export * from './useIsomorphicLayoutEffect/useIsomorphicLayouEffect';
2
3
  export * from './useOpenClose/useOpenClose';
4
+ export * from './useTheme/useTheme';
3
5
  export * from './useWindowSize/useWindowSize';
4
- export * from './useIsomorphicLayoutEffect/useIsomorphicLayouEffect';
@@ -0,0 +1,5 @@
1
+ export declare const useTheme: () => {
2
+ theme: import("../../components/ThemeProvider/ThemeProvider").Theme;
3
+ setTheme: (theme: import("../../components/ThemeProvider/ThemeProvider").Theme) => void;
4
+ isDarkMode?: boolean | undefined;
5
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
3
+ import type { Meta } from '@storybook/react';
4
+ declare const meta: Meta<typeof ThemeProvider>;
5
+ export default meta;
6
+ export declare const BasicUsage: () => React.JSX.Element;
@@ -4000,22 +4000,19 @@ function ThemeProvider(_ref) {
4000
4000
  }
4001
4001
  root.classList.add(theme);
4002
4002
  }, [theme]);
4003
+ var isDarkMode = theme === 'dark' || theme === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches;
4003
4004
  var value = {
4004
4005
  theme: theme,
4005
4006
  setTheme: function setTheme(theme) {
4006
4007
  localStorage.setItem(storageKey, theme);
4007
4008
  _setTheme(theme);
4008
- }
4009
+ },
4010
+ isDarkMode: isDarkMode
4009
4011
  };
4010
4012
  return React.createElement(ThemeProviderContext.Provider, _extends({}, props, {
4011
4013
  value: value
4012
4014
  }), children);
4013
4015
  }
4014
- var useTheme = function useTheme() {
4015
- var context = React.useContext(ThemeProviderContext);
4016
- if (context === undefined) throw new Error('useTheme must be used within a ThemeProvider. Be sure your App is wrapped in ThemeProvider.');
4017
- return context;
4018
- };
4019
4016
 
4020
4017
  var styles = {"toast-notification":"ToastNotification-module_toast-notification__2xiTW","toast-error":"ToastNotification-module_toast-error__4ArAY","toast-dismiss":"ToastNotification-module_toast-dismiss__xxmkb","toast-notification-enter-top":"ToastNotification-module_toast-notification-enter-top__ZZDCr","toast-notification-exit-top":"ToastNotification-module_toast-notification-exit-top__fOIkZ","toast-notification-enter-bottom":"ToastNotification-module_toast-notification-enter-bottom__So3w7","toast-notification-exit-bottom":"ToastNotification-module_toast-notification-exit-bottom__DDthi","toast-notification-exit-left":"ToastNotification-module_toast-notification-exit-left__Fh1hC","toast-notification-exit-right":"ToastNotification-module_toast-notification-exit-right__C1jQ9","toast-notification-fade-in":"ToastNotification-module_toast-notification-fade-in__JlSGi","toast-notification-fade-out":"ToastNotification-module_toast-notification-fade-out__r6q4Q"};
4021
4018
 
@@ -4655,6 +4652,12 @@ var useOpenClose = function useOpenClose(props) {
4655
4652
  };
4656
4653
  };
4657
4654
 
4655
+ var useTheme = function useTheme() {
4656
+ var context = React.useContext(ThemeProviderContext);
4657
+ if (context === undefined) throw new Error('useTheme must be used within a ThemeProvider. Be sure your App is wrapped in ThemeProvider.');
4658
+ return context;
4659
+ };
4660
+
4658
4661
  exports.Alert = Alert;
4659
4662
  exports.Badge = Badge;
4660
4663
  exports.Box = Box;
@@ -4702,6 +4705,7 @@ exports.TextInputInset = TextInputInset;
4702
4705
  exports.TextareaInput = TextareaInput;
4703
4706
  exports.TextareaInputInset = TextareaInputInset;
4704
4707
  exports.ThemeProvider = ThemeProvider;
4708
+ exports.ThemeProviderContext = ThemeProviderContext;
4705
4709
  exports.TimePicker = TimePicker;
4706
4710
  exports.TimePickerNative = TimePickerNative;
4707
4711
  exports.ToastContainer = ToastContainer;