@kwantis-id3/frontend-library 0.2.2 → 0.2.4

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/cjs/index.js CHANGED
@@ -4796,6 +4796,41 @@ var useTheme = function useTheme() {
4796
4796
  return reactExports.useContext(ThemeContext);
4797
4797
  };
4798
4798
 
4799
+ var getTheme = function getTheme(outerTheme, theme) {
4800
+ if (typeof theme === 'function') {
4801
+ var mergedTheme = theme(outerTheme);
4802
+
4803
+ if (process.env.NODE_ENV !== 'production' && (mergedTheme == null || typeof mergedTheme !== 'object' || Array.isArray(mergedTheme))) {
4804
+ throw new Error('[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!');
4805
+ }
4806
+
4807
+ return mergedTheme;
4808
+ }
4809
+
4810
+ if (process.env.NODE_ENV !== 'production' && (theme == null || typeof theme !== 'object' || Array.isArray(theme))) {
4811
+ throw new Error('[ThemeProvider] Please make your theme prop a plain object');
4812
+ }
4813
+
4814
+ return _extends({}, outerTheme, theme);
4815
+ };
4816
+
4817
+ var createCacheWithTheme = /* #__PURE__ */weakMemoize(function (outerTheme) {
4818
+ return weakMemoize(function (theme) {
4819
+ return getTheme(outerTheme, theme);
4820
+ });
4821
+ });
4822
+ var ThemeProvider = function ThemeProvider(props) {
4823
+ var theme = reactExports.useContext(ThemeContext);
4824
+
4825
+ if (props.theme !== theme) {
4826
+ theme = createCacheWithTheme(theme)(props.theme);
4827
+ }
4828
+
4829
+ return /*#__PURE__*/reactExports.createElement(ThemeContext.Provider, {
4830
+ value: theme
4831
+ }, props.children);
4832
+ };
4833
+
4799
4834
  var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
4800
4835
  var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
4801
4836
 
@@ -4890,7 +4925,12 @@ const defaultThemeColors = {
4890
4925
  statusCritical: "#FF4040",
4891
4926
  statusNeutral: "#CCCCCC",
4892
4927
  };
4893
- React.createContext(defaultThemeColors);
4928
+ const KwantisThemeContext = React.createContext(defaultThemeColors);
4929
+ const KwantisThemeContextProvider = (props) => {
4930
+ const [themeColors] = reactExports.useState(props.theme || defaultThemeColors);
4931
+ return (React.createElement(KwantisThemeContext.Provider, { value: themeColors },
4932
+ React.createElement(ThemeProvider, { theme: themeColors }, props.children)));
4933
+ };
4894
4934
  const isEmpty = (obj) => {
4895
4935
  return Object.keys(obj).length === 0;
4896
4936
  };
@@ -5114,4 +5154,6 @@ const Button = (props) => {
5114
5154
  };
5115
5155
 
5116
5156
  exports.Button = Button;
5157
+ exports.KwantisThemeContextProvider = KwantisThemeContextProvider;
5158
+ exports.useKwantisThemeContext = useKwantisThemeContext;
5117
5159
  //# sourceMappingURL=index.js.map