@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.
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CAMSConfig } from '@nibssplc/cams-sdk';
|
|
3
|
+
import { UseCAMSAuthReturn, UseCAMSAuthOptions } from '../hooks/useCAMSAuth';
|
|
4
|
+
interface CAMSContextValue extends UseCAMSAuthReturn {
|
|
5
|
+
defaultConfig?: Partial<CAMSConfig>;
|
|
6
|
+
}
|
|
7
|
+
export interface CAMSProviderProps extends UseCAMSAuthOptions {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
defaultConfig?: Partial<CAMSConfig>;
|
|
10
|
+
}
|
|
11
|
+
export declare function CAMSProvider({ children, defaultConfig, ...authOptions }: CAMSProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function useCAMSContext(): CAMSContextValue;
|
|
13
|
+
export {};
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface CAMSContextValue extends UseCAMSAuthReturn {
|
|
5
|
-
defaultConfig?: Partial<CAMSConfig>;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface CAMSProviderProps {
|
|
3
|
+
children: React.ReactNode;
|
|
6
4
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
defaultConfig?: Partial<CAMSConfig>;
|
|
10
|
-
}
|
|
11
|
-
export declare function CAMSProvider(props: CAMSProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export declare function useCAMSContext(): CAMSContextValue;
|
|
13
|
-
export {};
|
|
5
|
+
export declare function CAMSProvider({ children }: CAMSProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function useCAMSContext(): any;
|
package/dist/index.cjs.js
CHANGED
|
@@ -39,29 +39,6 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
39
39
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
var __assign = function() {
|
|
43
|
-
__assign = Object.assign || function __assign(t) {
|
|
44
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
45
|
-
s = arguments[i];
|
|
46
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
47
|
-
}
|
|
48
|
-
return t;
|
|
49
|
-
};
|
|
50
|
-
return __assign.apply(this, arguments);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function __rest(s, e) {
|
|
54
|
-
var t = {};
|
|
55
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
56
|
-
t[p] = s[p];
|
|
57
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
58
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
59
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
60
|
-
t[p[i]] = s[p[i]];
|
|
61
|
-
}
|
|
62
|
-
return t;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
42
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
66
43
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
67
44
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18206,34 +18183,20 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
18206
18183
|
|
|
18207
18184
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
18208
18185
|
|
|
18209
|
-
function
|
|
18210
|
-
var children = _a.children
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
setHasMounted(true);
|
|
18214
|
-
}, []);
|
|
18215
|
-
if (!hasMounted) {
|
|
18216
|
-
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: fallback });
|
|
18186
|
+
function CAMSProvider(_a) {
|
|
18187
|
+
var children = _a.children;
|
|
18188
|
+
if (typeof window === 'undefined') {
|
|
18189
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
18217
18190
|
}
|
|
18218
|
-
|
|
18219
|
-
}
|
|
18220
|
-
|
|
18221
|
-
var CAMSContext = React__default.createContext(null);
|
|
18222
|
-
function CAMSProviderInner(_a) {
|
|
18223
|
-
var children = _a.children, defaultConfig = _a.defaultConfig, authOptions = __rest(_a, ["children", "defaultConfig"]);
|
|
18224
|
-
var auth = useCAMSAuth(authOptions);
|
|
18225
|
-
var value = React__default.useMemo(function () { return (__assign(__assign({}, auth), { defaultConfig: defaultConfig })); }, [auth, defaultConfig]);
|
|
18226
|
-
return (jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children }));
|
|
18227
|
-
}
|
|
18228
|
-
function CAMSProvider(props) {
|
|
18229
|
-
return (jsxRuntimeExports.jsx(ClientOnly, { children: jsxRuntimeExports.jsx(CAMSProviderInner, __assign({}, props)) }));
|
|
18191
|
+
var ClientProvider = require('./CAMSProvider.client').CAMSProvider;
|
|
18192
|
+
return jsxRuntimeExports.jsx(ClientProvider, { children: children });
|
|
18230
18193
|
}
|
|
18231
18194
|
function useCAMSContext() {
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
throw new Error('useCAMSContext must be used within a CAMSProvider');
|
|
18195
|
+
if (typeof window === 'undefined') {
|
|
18196
|
+
throw new Error('useCAMSContext can only be used on the client side');
|
|
18235
18197
|
}
|
|
18236
|
-
|
|
18198
|
+
var useClientContext = require('./CAMSProvider.client').useCAMSContext;
|
|
18199
|
+
return useClientContext();
|
|
18237
18200
|
}
|
|
18238
18201
|
|
|
18239
18202
|
function ProtectedRoute(_a) {
|
|
@@ -18258,6 +18221,18 @@ function CAMSMSALProvider(_a) {
|
|
|
18258
18221
|
return (jsxRuntimeExports.jsx(MsalProvider, { instance: instance, children: children }));
|
|
18259
18222
|
}
|
|
18260
18223
|
|
|
18224
|
+
function ClientOnly(_a) {
|
|
18225
|
+
var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? null : _b;
|
|
18226
|
+
var _c = React__default.useState(false), hasMounted = _c[0], setHasMounted = _c[1];
|
|
18227
|
+
React__default.useEffect(function () {
|
|
18228
|
+
setHasMounted(true);
|
|
18229
|
+
}, []);
|
|
18230
|
+
if (!hasMounted) {
|
|
18231
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: fallback });
|
|
18232
|
+
}
|
|
18233
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
18234
|
+
}
|
|
18235
|
+
|
|
18261
18236
|
exports.CAMSMSALProvider = CAMSMSALProvider;
|
|
18262
18237
|
exports.CAMSProvider = CAMSProvider;
|
|
18263
18238
|
exports.ClientOnly = ClientOnly;
|