@nibssplc/cams-sdk-react 0.0.1-beta.15 → 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.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,34 +18164,20 @@ if (process.env.NODE_ENV === 'production') {
18187
18164
 
18188
18165
  var jsxRuntimeExports = jsxRuntime.exports;
18189
18166
 
18190
- function ClientOnly(_a) {
18191
- var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? null : _b;
18192
- var _c = useState(false), hasMounted = _c[0], setHasMounted = _c[1];
18193
- useEffect(function () {
18194
- setHasMounted(true);
18195
- }, []);
18196
- if (!hasMounted) {
18197
- return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: fallback });
18167
+ function CAMSProvider(_a) {
18168
+ var children = _a.children;
18169
+ if (typeof window === 'undefined') {
18170
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
18198
18171
  }
18199
- return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
18200
- }
18201
-
18202
- var CAMSContext = createContext(null);
18203
- function CAMSProviderInner(_a) {
18204
- var children = _a.children, defaultConfig = _a.defaultConfig, authOptions = __rest(_a, ["children", "defaultConfig"]);
18205
- var auth = useCAMSAuth(authOptions);
18206
- var value = useMemo(function () { return (__assign(__assign({}, auth), { defaultConfig: defaultConfig })); }, [auth, defaultConfig]);
18207
- return (jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children }));
18208
- }
18209
- function CAMSProvider(props) {
18210
- return (jsxRuntimeExports.jsx(ClientOnly, { children: jsxRuntimeExports.jsx(CAMSProviderInner, __assign({}, props)) }));
18172
+ var ClientProvider = require('./CAMSProvider.client').CAMSProvider;
18173
+ return jsxRuntimeExports.jsx(ClientProvider, { children: children });
18211
18174
  }
18212
18175
  function useCAMSContext() {
18213
- var context = useContext(CAMSContext);
18214
- if (!context) {
18215
- 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');
18216
18178
  }
18217
- return context;
18179
+ var useClientContext = require('./CAMSProvider.client').useCAMSContext;
18180
+ return useClientContext();
18218
18181
  }
18219
18182
 
18220
18183
  function ProtectedRoute(_a) {
@@ -18239,5 +18202,17 @@ function CAMSMSALProvider(_a) {
18239
18202
  return (jsxRuntimeExports.jsx(MsalProvider, { instance: instance, children: children }));
18240
18203
  }
18241
18204
 
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
+
18242
18217
  export { CAMSMSALProvider, CAMSProvider, ClientOnly, ProtectedRoute, useCAMSAuth, useCAMSContext, useCAMSMSALAuth };
18243
18218
  //# sourceMappingURL=index.esm.js.map