@nibssplc/cams-sdk-react 0.0.1-beta.16 → 0.0.1-beta.17
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 } from 'react';
|
|
2
|
+
import React__default__default, { useState, useRef, useEffect, useCallback, useMemo, useReducer, useContext, createContext } from 'react';
|
|
3
3
|
import { CAMSSessionManager, CAMSError, CAMSErrorType } from '@nibssplc/cams-sdk';
|
|
4
4
|
export * from '@nibssplc/cams-sdk';
|
|
5
5
|
|
|
@@ -20,6 +20,29 @@ 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
|
+
|
|
23
46
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
24
47
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
48
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18164,20 +18187,30 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
18164
18187
|
|
|
18165
18188
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
18166
18189
|
|
|
18190
|
+
var CAMSContext = createContext(null);
|
|
18167
18191
|
function CAMSProvider(_a) {
|
|
18168
|
-
var children = _a.children;
|
|
18169
|
-
|
|
18192
|
+
var children = _a.children, defaultConfig = _a.defaultConfig, authOptions = __rest(_a, ["children", "defaultConfig"]);
|
|
18193
|
+
var _b = useState(false), mounted = _b[0], setMounted = _b[1];
|
|
18194
|
+
useEffect(function () {
|
|
18195
|
+
setMounted(true);
|
|
18196
|
+
}, []);
|
|
18197
|
+
if (!mounted) {
|
|
18170
18198
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
18171
18199
|
}
|
|
18172
|
-
|
|
18173
|
-
|
|
18200
|
+
return jsxRuntimeExports.jsx(CAMSProviderInner, __assign({ defaultConfig: defaultConfig }, authOptions, { children: children }));
|
|
18201
|
+
}
|
|
18202
|
+
function CAMSProviderInner(_a) {
|
|
18203
|
+
var children = _a.children, defaultConfig = _a.defaultConfig, authOptions = __rest(_a, ["children", "defaultConfig"]);
|
|
18204
|
+
var auth = useCAMSAuth(authOptions);
|
|
18205
|
+
var value = useMemo(function () { return (__assign(__assign({}, auth), { defaultConfig: defaultConfig })); }, [auth, defaultConfig]);
|
|
18206
|
+
return (jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children }));
|
|
18174
18207
|
}
|
|
18175
18208
|
function useCAMSContext() {
|
|
18176
|
-
|
|
18177
|
-
|
|
18209
|
+
var context = useContext(CAMSContext);
|
|
18210
|
+
if (!context) {
|
|
18211
|
+
throw new Error('useCAMSContext must be used within a CAMSProvider');
|
|
18178
18212
|
}
|
|
18179
|
-
|
|
18180
|
-
return useClientContext();
|
|
18213
|
+
return context;
|
|
18181
18214
|
}
|
|
18182
18215
|
|
|
18183
18216
|
function ProtectedRoute(_a) {
|