@embedreach/components 0.1.19 → 0.1.21

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.
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import React__default, { createContext as createContext$1, Component, useReducer, useMemo, useEffect, useContext as useContext$1, createElement as createElement$1, useRef, useId as useId$2, useInsertionEffect, useCallback, Children, isValidElement, useLayoutEffect, useState, forwardRef, Fragment as Fragment$1 } from "react";
3
+ import React__default, { createContext as createContext$1, Component, useReducer, useMemo, useEffect, createElement as createElement$1, useRef, useId as useId$2, useContext as useContext$1, useInsertionEffect, useCallback, Children, isValidElement, useLayoutEffect, useState, forwardRef, Fragment as Fragment$1 } from "react";
4
4
  import * as ReactDOM from "react-dom";
5
5
  import ReactDOM__default from "react-dom";
6
6
  var Subscribable = class {
@@ -7873,7 +7873,7 @@ const createQueryClient = () => new QueryClient({
7873
7873
  }
7874
7874
  });
7875
7875
  const createDataContext = (reducer, actions, defaultValue, listeners) => {
7876
- const Context2 = React__default.createContext({
7876
+ const Context = React__default.createContext({
7877
7877
  state: defaultValue
7878
7878
  });
7879
7879
  const Provider2 = ({ children: children2 }) => {
@@ -7905,9 +7905,9 @@ const createDataContext = (reducer, actions, defaultValue, listeners) => {
7905
7905
  () => ({ state, ...boundActions }),
7906
7906
  [state, boundActions]
7907
7907
  );
7908
- return /* @__PURE__ */ jsx(Context2.Provider, { value: contextValue, children: children2 });
7908
+ return /* @__PURE__ */ jsx(Context.Provider, { value: contextValue, children: children2 });
7909
7909
  };
7910
- return { Context: Context2, Provider: Provider2 };
7910
+ return { Context, Provider: Provider2 };
7911
7911
  };
7912
7912
  const authReducer = (state, action) => {
7913
7913
  switch (action.type) {
@@ -8104,13 +8104,6 @@ const applyThemeStyles = (styles2) => {
8104
8104
  styleElement.textContent = cssText;
8105
8105
  document.head.appendChild(styleElement);
8106
8106
  };
8107
- const mergeThemeStyles = (themeConfig, overrides) => {
8108
- return {
8109
- ...DEFAULT_THEME_STYLES,
8110
- ...themeConfig?.styles || {},
8111
- ...{}
8112
- };
8113
- };
8114
8107
  const themeReducer = (state, action) => {
8115
8108
  switch (action.type) {
8116
8109
  case "set_theme":
@@ -8141,7 +8134,7 @@ const themeReducer = (state, action) => {
8141
8134
  const setTheme = (dispatch) => (theme2) => dispatch({ type: "set_theme", payload: theme2 });
8142
8135
  const setLoading = (dispatch) => (loading2) => dispatch({ type: "set_loading", payload: loading2 });
8143
8136
  const setError = (dispatch) => (error2) => dispatch({ type: "set_error", payload: error2 });
8144
- const { Context, Provider } = createDataContext(
8137
+ const { Provider } = createDataContext(
8145
8138
  themeReducer,
8146
8139
  {
8147
8140
  setTheme,
@@ -8154,28 +8147,6 @@ const { Context, Provider } = createDataContext(
8154
8147
  error: null
8155
8148
  }
8156
8149
  );
8157
- const useThemeContext = () => {
8158
- const context = useContext$1(Context);
8159
- if (context === void 0) {
8160
- throw new Error("useThemeContext must be used within a ThemeProvider");
8161
- }
8162
- const applyTheme = (themeConfig) => {
8163
- if (!themeConfig) return;
8164
- const mergedStyles = mergeThemeStyles(themeConfig);
8165
- const finalTheme = {
8166
- styles: mergedStyles
8167
- };
8168
- context.setTheme(finalTheme);
8169
- };
8170
- return {
8171
- ...context.state,
8172
- setTheme: context.setTheme,
8173
- setLoading: context.setLoading,
8174
- setError: context.setError,
8175
- // Add the helper function
8176
- applyTheme
8177
- };
8178
- };
8179
8150
  const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
8180
8151
  const htmlEntities = {
8181
8152
  "&": "&",
@@ -11618,7 +11589,6 @@ const I18nProvider = ({ children: children2 }) => {
11618
11589
  const ReachProvider = ({
11619
11590
  authToken: authToken2,
11620
11591
  tenantExternalId,
11621
- theme: theme2,
11622
11592
  children: children2
11623
11593
  }) => {
11624
11594
  const [queryClient] = React__default.useState(() => {
@@ -11627,14 +11597,6 @@ const ReachProvider = ({
11627
11597
  }
11628
11598
  return createQueryClient();
11629
11599
  });
11630
- const themeApplied = useRef(false);
11631
- const { applyTheme } = useThemeContext();
11632
- useEffect(() => {
11633
- if (!themeApplied.current && theme2) {
11634
- applyTheme(theme2);
11635
- themeApplied.current = true;
11636
- }
11637
- }, [applyTheme, theme2]);
11638
11600
  return /* @__PURE__ */ jsxs(QueryClientProvider, { client: queryClient, children: [
11639
11601
  /* @__PURE__ */ jsx(
11640
11602
  D,
@@ -22619,15 +22581,15 @@ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForD
22619
22581
  };
22620
22582
  }
22621
22583
  function createContext2(rootComponentName, defaultContext) {
22622
- const Context2 = React.createContext(defaultContext);
22584
+ const Context = React.createContext(defaultContext);
22623
22585
  const Provider2 = (props) => {
22624
22586
  const { children: children2, ...context } = props;
22625
22587
  const value = React.useMemo(() => context, Object.values(context));
22626
- return /* @__PURE__ */ jsx(Context2.Provider, { value, children: children2 });
22588
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children: children2 });
22627
22589
  };
22628
22590
  Provider2.displayName = rootComponentName + "Provider";
22629
22591
  function useContext2(consumerName) {
22630
- const context = React.useContext(Context2);
22592
+ const context = React.useContext(Context);
22631
22593
  if (context) return context;
22632
22594
  if (defaultContext !== void 0) return defaultContext;
22633
22595
  throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
@@ -22642,14 +22604,14 @@ function createContextScope(scopeName, createContextScopeDeps = []) {
22642
22604
  defaultContexts = [...defaultContexts, defaultContext];
22643
22605
  const Provider2 = (props) => {
22644
22606
  const { scope, children: children2, ...context } = props;
22645
- const Context2 = scope?.[scopeName]?.[index2] || BaseContext;
22607
+ const Context = scope?.[scopeName]?.[index2] || BaseContext;
22646
22608
  const value = React.useMemo(() => context, Object.values(context));
22647
- return /* @__PURE__ */ jsx(Context2.Provider, { value, children: children2 });
22609
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children: children2 });
22648
22610
  };
22649
22611
  Provider2.displayName = rootComponentName + "Provider";
22650
22612
  function useContext2(consumerName, scope) {
22651
- const Context2 = scope?.[scopeName]?.[index2] || BaseContext;
22652
- const context = React.useContext(Context2);
22613
+ const Context = scope?.[scopeName]?.[index2] || BaseContext;
22614
+ const context = React.useContext(Context);
22653
22615
  if (context) return context;
22654
22616
  if (defaultContext !== void 0) return defaultContext;
22655
22617
  throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
package/dist/index.d.ts CHANGED
@@ -56,7 +56,7 @@ export declare interface ReachConfig {
56
56
  /** Event callbacks */
57
57
  callbacks?: SDKCallbacks;
58
58
  /** Initial feature to load */
59
- feature: FeatureKey;
59
+ feature?: FeatureKey;
60
60
  /** Debug configuration */
61
61
  debug?: boolean;
62
62
  }