@nibssplc/cams-sdk-react 0.0.1-beta.14 → 0.0.1-beta.15

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,6 +8,6 @@ export interface CAMSProviderProps extends UseCAMSAuthOptions {
8
8
  children: ReactNode;
9
9
  defaultConfig?: Partial<CAMSConfig>;
10
10
  }
11
- export declare function CAMSProvider({ children, defaultConfig, ...authOptions }: CAMSProviderProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function CAMSProvider(props: CAMSProviderProps): import("react/jsx-runtime").JSX.Element;
12
12
  export declare function useCAMSContext(): CAMSContextValue;
13
13
  export {};
@@ -0,0 +1,6 @@
1
+ interface ClientOnlyProps {
2
+ children: React.ReactNode;
3
+ fallback?: React.ReactNode;
4
+ }
5
+ export declare function ClientOnly({ children, fallback }: ClientOnlyProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
package/dist/index.cjs.js CHANGED
@@ -18206,13 +18206,28 @@ if (process.env.NODE_ENV === 'production') {
18206
18206
 
18207
18207
  var jsxRuntimeExports = jsxRuntime.exports;
18208
18208
 
18209
+ function ClientOnly(_a) {
18210
+ var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? null : _b;
18211
+ var _c = React__default.useState(false), hasMounted = _c[0], setHasMounted = _c[1];
18212
+ React__default.useEffect(function () {
18213
+ setHasMounted(true);
18214
+ }, []);
18215
+ if (!hasMounted) {
18216
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: fallback });
18217
+ }
18218
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
18219
+ }
18220
+
18209
18221
  var CAMSContext = React__default.createContext(null);
18210
- function CAMSProvider(_a) {
18222
+ function CAMSProviderInner(_a) {
18211
18223
  var children = _a.children, defaultConfig = _a.defaultConfig, authOptions = __rest(_a, ["children", "defaultConfig"]);
18212
18224
  var auth = useCAMSAuth(authOptions);
18213
18225
  var value = React__default.useMemo(function () { return (__assign(__assign({}, auth), { defaultConfig: defaultConfig })); }, [auth, defaultConfig]);
18214
18226
  return (jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children }));
18215
18227
  }
18228
+ function CAMSProvider(props) {
18229
+ return (jsxRuntimeExports.jsx(ClientOnly, { children: jsxRuntimeExports.jsx(CAMSProviderInner, __assign({}, props)) }));
18230
+ }
18216
18231
  function useCAMSContext() {
18217
18232
  var context = React__default.useContext(CAMSContext);
18218
18233
  if (!context) {
@@ -18245,6 +18260,7 @@ function CAMSMSALProvider(_a) {
18245
18260
 
18246
18261
  exports.CAMSMSALProvider = CAMSMSALProvider;
18247
18262
  exports.CAMSProvider = CAMSProvider;
18263
+ exports.ClientOnly = ClientOnly;
18248
18264
  exports.ProtectedRoute = ProtectedRoute;
18249
18265
  exports.useCAMSAuth = useCAMSAuth;
18250
18266
  exports.useCAMSContext = useCAMSContext;