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

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/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * from './hooks/useCAMSMSALAuth';
3
3
  export * from './components/CAMSProvider';
4
4
  export * from './components/ProtectedRoute';
5
5
  export * from './components/CAMSMSALProvider';
6
+ export * from './components/ClientOnly';
6
7
  export * from '@nibssplc/cams-sdk';
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React__default from 'react';
2
- import React__default__default, { useState, useRef, useEffect, useCallback, useMemo, useReducer, useContext, createContext } from 'react';
2
+ import React__default__default, { useState, useRef, useEffect, useCallback, useMemo, useReducer, useContext } from 'react';
3
3
  import { CAMSSessionManager, CAMSError, CAMSErrorType } from '@nibssplc/cams-sdk';
4
4
  export * from '@nibssplc/cams-sdk';
5
5
 
@@ -20,29 +20,6 @@ PERFORMANCE OF THIS SOFTWARE.
20
20
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
21
21
 
22
22
 
23
- var __assign = function() {
24
- __assign = Object.assign || function __assign(t) {
25
- for (var s, i = 1, n = arguments.length; i < n; i++) {
26
- s = arguments[i];
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
28
- }
29
- return t;
30
- };
31
- return __assign.apply(this, arguments);
32
- };
33
-
34
- function __rest(s, e) {
35
- var t = {};
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
- t[p] = s[p];
38
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
- t[p[i]] = s[p[i]];
42
- }
43
- return t;
44
- }
45
-
46
23
  function __awaiter(thisArg, _arguments, P, generator) {
47
24
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
48
25
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -18187,19 +18164,20 @@ if (process.env.NODE_ENV === 'production') {
18187
18164
 
18188
18165
  var jsxRuntimeExports = jsxRuntime.exports;
18189
18166
 
18190
- var CAMSContext = createContext(null);
18191
18167
  function CAMSProvider(_a) {
18192
- var children = _a.children, defaultConfig = _a.defaultConfig, authOptions = __rest(_a, ["children", "defaultConfig"]);
18193
- var auth = useCAMSAuth(authOptions);
18194
- var value = useMemo(function () { return (__assign(__assign({}, auth), { defaultConfig: defaultConfig })); }, [auth, defaultConfig]);
18195
- return (jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children }));
18168
+ var children = _a.children;
18169
+ if (typeof window === 'undefined') {
18170
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
18171
+ }
18172
+ var ClientProvider = require('./CAMSProvider.client').CAMSProvider;
18173
+ return jsxRuntimeExports.jsx(ClientProvider, { children: children });
18196
18174
  }
18197
18175
  function useCAMSContext() {
18198
- var context = useContext(CAMSContext);
18199
- if (!context) {
18200
- throw new Error('useCAMSContext must be used within a CAMSProvider');
18176
+ if (typeof window === 'undefined') {
18177
+ throw new Error('useCAMSContext can only be used on the client side');
18201
18178
  }
18202
- return context;
18179
+ var useClientContext = require('./CAMSProvider.client').useCAMSContext;
18180
+ return useClientContext();
18203
18181
  }
18204
18182
 
18205
18183
  function ProtectedRoute(_a) {
@@ -18224,5 +18202,17 @@ function CAMSMSALProvider(_a) {
18224
18202
  return (jsxRuntimeExports.jsx(MsalProvider, { instance: instance, children: children }));
18225
18203
  }
18226
18204
 
18227
- export { CAMSMSALProvider, CAMSProvider, ProtectedRoute, useCAMSAuth, useCAMSContext, useCAMSMSALAuth };
18205
+ function ClientOnly(_a) {
18206
+ var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? null : _b;
18207
+ var _c = useState(false), hasMounted = _c[0], setHasMounted = _c[1];
18208
+ useEffect(function () {
18209
+ setHasMounted(true);
18210
+ }, []);
18211
+ if (!hasMounted) {
18212
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: fallback });
18213
+ }
18214
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
18215
+ }
18216
+
18217
+ export { CAMSMSALProvider, CAMSProvider, ClientOnly, ProtectedRoute, useCAMSAuth, useCAMSContext, useCAMSMSALAuth };
18228
18218
  //# sourceMappingURL=index.esm.js.map