@tracktor/shared-module 0.0.1 → 0.0.2
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/CHANGELOG.md +2 -2
- package/README.md +2 -2
- package/dist/{InjectDependenciesProvider-c64526b4.js → InjectDependenciesProvider-3bbc437d.js} +34 -27
- package/dist/{InjectDependenciesProvider-cdf994b6.cjs → InjectDependenciesProvider-40e2c821.cjs} +4 -4
- package/dist/RequireAuth-c1956d94.js +24 -0
- package/dist/RequireAuth-da69fc85.cjs +1 -0
- package/dist/api/hooks/useResponseError.d.ts +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.js +2 -2
- package/dist/auth/components/RequireAuth.d.ts +24 -14
- package/dist/auth.cjs +1 -1
- package/dist/auth.js +2 -2
- package/dist/context/InjectDependenciesProvider.d.ts +16 -20
- package/dist/context.cjs +1 -1
- package/dist/context.js +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +3 -3
- package/dist/useResponseError-51d8f1ab.cjs +1 -0
- package/dist/useResponseError-adb9412c.js +15 -0
- package/package.json +1 -1
- package/dist/RequireAuth-03e1e3fb.js +0 -24
- package/dist/RequireAuth-edc931f8.cjs +0 -1
- package/dist/useResponseError-401ec650.js +0 -15
- package/dist/useResponseError-e4d8f886.cjs +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/dist/{InjectDependenciesProvider-c64526b4.js → InjectDependenciesProvider-3bbc437d.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Oe, { createContext as ir, useMemo as ur } from "react";
|
|
2
2
|
var H = {}, sr = {
|
|
3
3
|
get exports() {
|
|
4
4
|
return H;
|
|
@@ -21,16 +21,16 @@ function fr() {
|
|
|
21
21
|
if (Re)
|
|
22
22
|
return A;
|
|
23
23
|
Re = 1;
|
|
24
|
-
var g =
|
|
25
|
-
function T(
|
|
26
|
-
var d, b = {},
|
|
27
|
-
w !== void 0 && (
|
|
24
|
+
var g = Oe, m = Symbol.for("react.element"), S = Symbol.for("react.fragment"), E = Object.prototype.hasOwnProperty, y = g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, R = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
25
|
+
function T(O, l, w) {
|
|
26
|
+
var d, b = {}, C = null, $ = null;
|
|
27
|
+
w !== void 0 && (C = "" + w), l.key !== void 0 && (C = "" + l.key), l.ref !== void 0 && ($ = l.ref);
|
|
28
28
|
for (d in l)
|
|
29
29
|
E.call(l, d) && !R.hasOwnProperty(d) && (b[d] = l[d]);
|
|
30
|
-
if (
|
|
31
|
-
for (d in l =
|
|
30
|
+
if (O && O.defaultProps)
|
|
31
|
+
for (d in l = O.defaultProps, l)
|
|
32
32
|
b[d] === void 0 && (b[d] = l[d]);
|
|
33
|
-
return { $$typeof: m, type:
|
|
33
|
+
return { $$typeof: m, type: O, key: C, ref: $, props: b, _owner: y.current };
|
|
34
34
|
}
|
|
35
35
|
return A.Fragment = S, A.jsx = T, A.jsxs = T, A;
|
|
36
36
|
}
|
|
@@ -47,11 +47,11 @@ var I = {};
|
|
|
47
47
|
var Te;
|
|
48
48
|
function lr() {
|
|
49
49
|
return Te || (Te = 1, process.env.NODE_ENV !== "production" && function() {
|
|
50
|
-
var g =
|
|
50
|
+
var g = Oe, m = Symbol.for("react.element"), S = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), R = Symbol.for("react.profiler"), T = Symbol.for("react.provider"), O = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), b = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), $ = Symbol.for("react.offscreen"), X = Symbol.iterator, Ce = "@@iterator";
|
|
51
51
|
function Pe(e) {
|
|
52
52
|
if (e === null || typeof e != "object")
|
|
53
53
|
return null;
|
|
54
|
-
var r = X && e[X] || e[
|
|
54
|
+
var r = X && e[X] || e[Ce];
|
|
55
55
|
return typeof r == "function" ? r : null;
|
|
56
56
|
}
|
|
57
57
|
var x = g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
@@ -75,7 +75,7 @@ function lr() {
|
|
|
75
75
|
var we = !1, xe = !1, je = !1, ke = !1, De = !1, Z;
|
|
76
76
|
Z = Symbol.for("react.module.reference");
|
|
77
77
|
function Fe(e) {
|
|
78
|
-
return !!(typeof e == "string" || typeof e == "function" || e === E || e === R || De || e === y || e === w || e === d || ke || e === $ || we || xe || je || typeof e == "object" && e !== null && (e.$$typeof ===
|
|
78
|
+
return !!(typeof e == "string" || typeof e == "function" || e === E || e === R || De || e === y || e === w || e === d || ke || e === $ || we || xe || je || typeof e == "object" && e !== null && (e.$$typeof === C || e.$$typeof === b || e.$$typeof === T || e.$$typeof === O || e.$$typeof === l || // This needs to include all possible module reference object
|
|
79
79
|
// types supported by any Flight configuration anywhere since
|
|
80
80
|
// we don't know which Flight build this will end up being used
|
|
81
81
|
// with.
|
|
@@ -114,7 +114,7 @@ function lr() {
|
|
|
114
114
|
}
|
|
115
115
|
if (typeof e == "object")
|
|
116
116
|
switch (e.$$typeof) {
|
|
117
|
-
case
|
|
117
|
+
case O:
|
|
118
118
|
var r = e;
|
|
119
119
|
return Q(r) + ".Consumer";
|
|
120
120
|
case T:
|
|
@@ -125,7 +125,7 @@ function lr() {
|
|
|
125
125
|
case b:
|
|
126
126
|
var n = e.displayName || null;
|
|
127
127
|
return n !== null ? n : h(e.type) || "Memo";
|
|
128
|
-
case
|
|
128
|
+
case C: {
|
|
129
129
|
var i = e, u = i._payload, o = i._init;
|
|
130
130
|
try {
|
|
131
131
|
return h(o(u));
|
|
@@ -314,7 +314,7 @@ function lr() {
|
|
|
314
314
|
return Ye(e.render);
|
|
315
315
|
case b:
|
|
316
316
|
return L(e.type, r, t);
|
|
317
|
-
case
|
|
317
|
+
case C: {
|
|
318
318
|
var n = e, i = n._payload, u = n._init;
|
|
319
319
|
try {
|
|
320
320
|
return L(u(i), r, t);
|
|
@@ -324,17 +324,17 @@ function lr() {
|
|
|
324
324
|
}
|
|
325
325
|
return "";
|
|
326
326
|
}
|
|
327
|
-
var
|
|
328
|
-
function
|
|
327
|
+
var N = Object.prototype.hasOwnProperty, fe = {}, le = x.ReactDebugCurrentFrame;
|
|
328
|
+
function M(e) {
|
|
329
329
|
if (e) {
|
|
330
330
|
var r = e._owner, t = L(e.type, e._source, r ? r.type : null);
|
|
331
331
|
le.setExtraStackFrame(t);
|
|
332
332
|
} else
|
|
333
333
|
le.setExtraStackFrame(null);
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function Ne(e, r, t, n, i) {
|
|
336
336
|
{
|
|
337
|
-
var u = Function.call.bind(
|
|
337
|
+
var u = Function.call.bind(N);
|
|
338
338
|
for (var o in e)
|
|
339
339
|
if (u(e, o)) {
|
|
340
340
|
var a = void 0;
|
|
@@ -347,13 +347,13 @@ function lr() {
|
|
|
347
347
|
} catch (s) {
|
|
348
348
|
a = s;
|
|
349
349
|
}
|
|
350
|
-
a && !(a instanceof Error) && (
|
|
350
|
+
a && !(a instanceof Error) && (M(i), c("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), M(null)), a instanceof Error && !(a.message in fe) && (fe[a.message] = !0, M(i), c("Failed %s type: %s", t, a.message), M(null));
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
var
|
|
354
|
+
var Me = Array.isArray;
|
|
355
355
|
function q(e) {
|
|
356
|
-
return
|
|
356
|
+
return Me(e);
|
|
357
357
|
}
|
|
358
358
|
function Ve(e) {
|
|
359
359
|
{
|
|
@@ -383,7 +383,7 @@ function lr() {
|
|
|
383
383
|
}, de, pe, J;
|
|
384
384
|
J = {};
|
|
385
385
|
function qe(e) {
|
|
386
|
-
if (
|
|
386
|
+
if (N.call(e, "ref")) {
|
|
387
387
|
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
|
|
388
388
|
if (r && r.isReactWarning)
|
|
389
389
|
return !1;
|
|
@@ -391,7 +391,7 @@ function lr() {
|
|
|
391
391
|
return e.ref !== void 0;
|
|
392
392
|
}
|
|
393
393
|
function Je(e) {
|
|
394
|
-
if (
|
|
394
|
+
if (N.call(e, "key")) {
|
|
395
395
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
396
396
|
if (r && r.isReactWarning)
|
|
397
397
|
return !1;
|
|
@@ -460,7 +460,7 @@ function lr() {
|
|
|
460
460
|
var u, o = {}, a = null, v = null;
|
|
461
461
|
t !== void 0 && (ve(t), a = "" + t), Je(r) && (ve(r.key), a = "" + r.key), qe(r) && (v = r.ref, Ge(r, i));
|
|
462
462
|
for (u in r)
|
|
463
|
-
|
|
463
|
+
N.call(r, u) && !Be.hasOwnProperty(u) && (o[u] = r[u]);
|
|
464
464
|
if (e && e.defaultProps) {
|
|
465
465
|
var s = e.defaultProps;
|
|
466
466
|
for (u in s)
|
|
@@ -570,7 +570,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
570
570
|
return;
|
|
571
571
|
if (t) {
|
|
572
572
|
var n = h(r);
|
|
573
|
-
|
|
573
|
+
Ne(t, e.props, "prop", n, e);
|
|
574
574
|
} else if (r.PropTypes !== void 0 && !z) {
|
|
575
575
|
z = !0;
|
|
576
576
|
var i = h(r);
|
|
@@ -634,12 +634,19 @@ Check the top-level render call using <` + t + ">.");
|
|
|
634
634
|
(function(g) {
|
|
635
635
|
process.env.NODE_ENV === "production" ? g.exports = fr() : g.exports = lr();
|
|
636
636
|
})(sr);
|
|
637
|
-
const cr = H.jsx, vr = ir(
|
|
637
|
+
const cr = H.jsx, vr = ir({
|
|
638
|
+
children: void 0,
|
|
639
|
+
Navigate: void 0,
|
|
640
|
+
Outlet: void 0,
|
|
641
|
+
translate: void 0,
|
|
642
|
+
useAuth: void 0,
|
|
643
|
+
useLocation: void 0
|
|
644
|
+
}), pr = ({ children: g, translate: m, useAuth: S, Outlet: E, Navigate: y, useLocation: R }) => {
|
|
638
645
|
const T = ur(
|
|
639
646
|
() => ({
|
|
640
647
|
Navigate: y,
|
|
641
648
|
Outlet: E,
|
|
642
|
-
|
|
649
|
+
translate: m,
|
|
643
650
|
useAuth: S,
|
|
644
651
|
useLocation: R
|
|
645
652
|
}),
|
package/dist/{InjectDependenciesProvider-cdf994b6.cjs → InjectDependenciesProvider-40e2c821.cjs}
RENAMED
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Ce;function lr(){return Ce||(Ce=1,process.env.NODE_ENV!=="production"&&function(){var g=V,y=Symbol.for("react.element"),S=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),T=Symbol.for("react.provider"),C=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),$=Symbol.for("react.offscreen"),Z=Symbol.iterator,Se="@@iterator";function we(e){if(e===null||typeof e!="object")return null;var r=Z&&e[Z]||e[Se];return typeof r=="function"?r:null}var j=g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function c(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];je("error",e,t)}}function je(e,r,t){{var n=j.ReactDebugCurrentFrame,
|
|
18
|
-
`+q+e}}var B=!1,Y;{var Le=typeof WeakMap=="function"?WeakMap:Map;Y=new Le}function fe(e,r){if(!e||B)return"";{var t=Y.get(e);if(t!==void 0)return t}var n;B=!0;var
|
|
17
|
+
*/var Ce;function lr(){return Ce||(Ce=1,process.env.NODE_ENV!=="production"&&function(){var g=V,y=Symbol.for("react.element"),S=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),T=Symbol.for("react.provider"),C=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),$=Symbol.for("react.offscreen"),Z=Symbol.iterator,Se="@@iterator";function we(e){if(e===null||typeof e!="object")return null;var r=Z&&e[Z]||e[Se];return typeof r=="function"?r:null}var j=g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function c(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];je("error",e,t)}}function je(e,r,t){{var n=j.ReactDebugCurrentFrame,o=n.getStackAddendum();o!==""&&(r+="%s",t=t.concat([o]));var u=t.map(function(i){return String(i)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var xe=!1,ke=!1,De=!1,Fe=!1,Ae=!1,Q;Q=Symbol.for("react.module.reference");function Ie(e){return!!(typeof e=="string"||typeof e=="function"||e===E||e===m||Ae||e===R||e===w||e===v||Fe||e===$||xe||ke||De||typeof e=="object"&&e!==null&&(e.$$typeof===O||e.$$typeof===b||e.$$typeof===T||e.$$typeof===C||e.$$typeof===l||e.$$typeof===Q||e.getModuleId!==void 0))}function $e(e,r,t){var n=e.displayName;if(n)return n;var o=r.displayName||r.name||"";return o!==""?t+"("+o+")":t}function ee(e){return e.displayName||"Context"}function h(e){if(e==null)return null;if(typeof e.tag=="number"&&c("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case S:return"Portal";case m:return"Profiler";case R:return"StrictMode";case w:return"Suspense";case v:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case C:var r=e;return ee(r)+".Consumer";case T:var t=e;return ee(t._context)+".Provider";case l:return $e(e,e.render,"ForwardRef");case b:var n=e.displayName||null;return n!==null?n:h(e.type)||"Memo";case O:{var o=e,u=o._payload,i=o._init;try{return h(i(u))}catch{return null}}}return null}var P=Object.assign,D=0,re,te,ne,ae,ie,oe,ue;function se(){}se.__reactDisabledLog=!0;function We(){{if(D===0){re=console.log,te=console.info,ne=console.warn,ae=console.error,ie=console.group,oe=console.groupCollapsed,ue=console.groupEnd;var e={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}D++}}function Ye(){{if(D--,D===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},e,{value:re}),info:P({},e,{value:te}),warn:P({},e,{value:ne}),error:P({},e,{value:ae}),group:P({},e,{value:ie}),groupCollapsed:P({},e,{value:oe}),groupEnd:P({},e,{value:ue})})}D<0&&c("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var U=j.ReactCurrentDispatcher,q;function W(e,r,t){{if(q===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);q=n&&n[1]||""}return`
|
|
18
|
+
`+q+e}}var B=!1,Y;{var Le=typeof WeakMap=="function"?WeakMap:Map;Y=new Le}function fe(e,r){if(!e||B)return"";{var t=Y.get(e);if(t!==void 0)return t}var n;B=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=U.current,U.current=null,We();try{if(r){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(_){n=_}Reflect.construct(e,[],i)}else{try{i.call()}catch(_){n=_}e.call(i.prototype)}}else{try{throw Error()}catch(_){n=_}e()}}catch(_){if(_&&n&&typeof _.stack=="string"){for(var a=_.stack.split(`
|
|
19
19
|
`),d=n.stack.split(`
|
|
20
20
|
`),s=a.length-1,f=d.length-1;s>=1&&f>=0&&a[s]!==d[f];)f--;for(;s>=1&&f>=0;s--,f--)if(a[s]!==d[f]){if(s!==1||f!==1)do if(s--,f--,f<0||a[s]!==d[f]){var p=`
|
|
21
|
-
`+a[s].replace(" at new "," at ");return e.displayName&&p.includes("<anonymous>")&&(p=p.replace("<anonymous>",e.displayName)),typeof e=="function"&&Y.set(e,p),p}while(s>=1&&f>=0);break}}}finally{B=!1,U.current=u,Ye(),Error.prepareStackTrace=
|
|
21
|
+
`+a[s].replace(" at new "," at ");return e.displayName&&p.includes("<anonymous>")&&(p=p.replace("<anonymous>",e.displayName)),typeof e=="function"&&Y.set(e,p),p}while(s>=1&&f>=0);break}}}finally{B=!1,U.current=u,Ye(),Error.prepareStackTrace=o}var k=e?e.displayName||e.name:"",me=k?W(k):"";return typeof e=="function"&&Y.set(e,me),me}function Ne(e,r,t){return fe(e,!1)}function Me(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function L(e,r,t){if(e==null)return"";if(typeof e=="function")return fe(e,Me(e));if(typeof e=="string")return W(e);switch(e){case w:return W("Suspense");case v:return W("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case l:return Ne(e.render);case b:return L(e.type,r,t);case O:{var n=e,o=n._payload,u=n._init;try{return L(u(o),r,t)}catch{}}}return""}var N=Object.prototype.hasOwnProperty,le={},ce=j.ReactDebugCurrentFrame;function M(e){if(e){var r=e._owner,t=L(e.type,e._source,r?r.type:null);ce.setExtraStackFrame(t)}else ce.setExtraStackFrame(null)}function Ve(e,r,t,n,o){{var u=Function.call.bind(N);for(var i in e)if(u(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var d=Error((n||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw d.name="Invariant Violation",d}a=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(s){a=s}a&&!(a instanceof Error)&&(M(o),c("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,i,typeof a),M(null)),a instanceof Error&&!(a.message in le)&&(le[a.message]=!0,M(o),c("Failed %s type: %s",t,a.message),M(null))}}}var Ue=Array.isArray;function J(e){return Ue(e)}function qe(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Be(e){try{return de(e),!1}catch{return!0}}function de(e){return""+e}function ve(e){if(Be(e))return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",qe(e)),de(e)}var F=j.ReactCurrentOwner,Je={key:!0,ref:!0,__self:!0,__source:!0},pe,ge,G;G={};function Ge(e){if(N.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function ze(e){if(N.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Ke(e,r){if(typeof e.ref=="string"&&F.current&&r&&F.current.stateNode!==r){var t=h(F.current.type);G[t]||(c('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',h(F.current.type),e.ref),G[t]=!0)}}function He(e,r){{var t=function(){pe||(pe=!0,c("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function Xe(e,r){{var t=function(){ge||(ge=!0,c("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var Ze=function(e,r,t,n,o,u,i){var a={$$typeof:y,type:e,key:r,ref:t,props:i,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function Qe(e,r,t,n,o){{var u,i={},a=null,d=null;t!==void 0&&(ve(t),a=""+t),ze(r)&&(ve(r.key),a=""+r.key),Ge(r)&&(d=r.ref,Ke(r,o));for(u in r)N.call(r,u)&&!Je.hasOwnProperty(u)&&(i[u]=r[u]);if(e&&e.defaultProps){var s=e.defaultProps;for(u in s)i[u]===void 0&&(i[u]=s[u])}if(a||d){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&He(i,f),d&&Xe(i,f)}return Ze(e,a,d,o,n,F.current,i)}}var z=j.ReactCurrentOwner,Ee=j.ReactDebugCurrentFrame;function x(e){if(e){var r=e._owner,t=L(e.type,e._source,r?r.type:null);Ee.setExtraStackFrame(t)}else Ee.setExtraStackFrame(null)}var K;K=!1;function H(e){return typeof e=="object"&&e!==null&&e.$$typeof===y}function be(){{if(z.current){var e=h(z.current.type);if(e)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+e+"`."}return""}}function er(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
|
|
24
24
|
|
|
25
25
|
Check your code at `+r+":"+t+"."}return""}}var he={};function rr(e){{var r=be();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+t+">.")}return r}}function _e(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=rr(r);if(he[t])return;he[t]=!0;var n="";e&&e._owner&&e._owner!==z.current&&(n=" It was passed a child from "+h(e._owner.type)+"."),x(e),c('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),x(null)}}function ye(e,r){{if(typeof e!="object")return;if(J(e))for(var t=0;t<e.length;t++){var n=e[t];H(n)&&_e(n,r)}else if(H(e))e._store&&(e._store.validated=!0);else if(e){var
|
|
27
|
+
Check the top-level render call using <`+t+">.")}return r}}function _e(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=rr(r);if(he[t])return;he[t]=!0;var n="";e&&e._owner&&e._owner!==z.current&&(n=" It was passed a child from "+h(e._owner.type)+"."),x(e),c('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),x(null)}}function ye(e,r){{if(typeof e!="object")return;if(J(e))for(var t=0;t<e.length;t++){var n=e[t];H(n)&&_e(n,r)}else if(H(e))e._store&&(e._store.validated=!0);else if(e){var o=we(e);if(typeof o=="function"&&o!==e.entries)for(var u=o.call(e),i;!(i=u.next()).done;)H(i.value)&&_e(i.value,r)}}}function tr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===l||r.$$typeof===b))t=r.propTypes;else return;if(t){var n=h(r);Ve(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!K){K=!0;var o=h(r);c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",o||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&c("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function nr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){x(e),c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),x(null);break}}e.ref!==null&&(x(e),c("Invalid attribute `ref` supplied to `React.Fragment`."),x(null))}}function Re(e,r,t,n,o,u){{var i=Ie(e);if(!i){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var d=er(o);d?a+=d:a+=be();var s;e===null?s="null":J(e)?s="array":e!==void 0&&e.$$typeof===y?(s="<"+(h(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,c("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,a)}var f=Qe(e,r,t,o,u);if(f==null)return f;if(i){var p=r.children;if(p!==void 0)if(n)if(J(p)){for(var k=0;k<p.length;k++)ye(p[k],e);Object.freeze&&Object.freeze(p)}else c("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ye(p,e)}return e===E?nr(f):tr(f),f}}function ar(e,r,t){return Re(e,r,t,!0)}function ir(e,r,t){return Re(e,r,t,!1)}var or=ir,ur=ar;I.Fragment=E,I.jsx=or,I.jsxs=ur}()),I}(function(g){process.env.NODE_ENV==="production"?g.exports=fr():g.exports=lr()})(sr);const Oe=X.jsx,Pe=V.createContext({children:void 0,Navigate:void 0,Outlet:void 0,translate:void 0,useAuth:void 0,useLocation:void 0}),cr=({children:g,translate:y,useAuth:S,Outlet:E,Navigate:R,useLocation:m})=>{const T=V.useMemo(()=>({Navigate:R,Outlet:E,translate:y,useAuth:S,useLocation:m}),[R,E,y,S,m]);return Oe(Pe.Provider,{value:T,children:g})};exports.InjectDependenciesContext=Pe;exports.InjectDependenciesProvider=cr;exports.jsx=Oe;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { a as v, j as r } from "./InjectDependenciesProvider-3bbc437d.js";
|
|
2
|
+
import { useContext as w, Suspense as p } from "react";
|
|
3
|
+
const o = (a) => `RequireAuth require « ${a} » dependency. You can provide with InjectDependenciesProvider or directly in props.`, E = ({ Fallback: a, loginPath: i = "/login", ...t }) => {
|
|
4
|
+
var f, d, h, m;
|
|
5
|
+
const {
|
|
6
|
+
useLocation: s = t.useLocation,
|
|
7
|
+
useAuth: u = t.useAuth,
|
|
8
|
+
Outlet: c = t.Outlet,
|
|
9
|
+
Navigate: n = t.Navigate
|
|
10
|
+
} = w(v);
|
|
11
|
+
if (u === void 0)
|
|
12
|
+
throw new Error(o("useAuth"));
|
|
13
|
+
if (s === void 0)
|
|
14
|
+
throw new Error(o("useLocation"));
|
|
15
|
+
if (c === void 0)
|
|
16
|
+
throw new Error(o("Outlet"));
|
|
17
|
+
if (n === void 0)
|
|
18
|
+
throw new Error(o("Navigate"));
|
|
19
|
+
const { isLogged: l } = u(), e = s();
|
|
20
|
+
return l ? /* @__PURE__ */ r(p, { fallback: a, children: (d = (f = e.state) == null ? void 0 : f.from) != null && d.state && ((m = (h = e.state) == null ? void 0 : h.from) == null ? void 0 : m.pathname) === i ? /* @__PURE__ */ r(n, { to: e.state.from.state.from.pathname + e.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ r(c, {}) }) : /* @__PURE__ */ r(n, { to: i, state: { from: e }, replace: !0 });
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
E as R
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("./InjectDependenciesProvider-40e2c821.cjs"),v=require("react"),o=n=>`RequireAuth require « ${n} » dependency. You can provide with InjectDependenciesProvider or directly in props.`,w=({Fallback:n,loginPath:s="/login",...r})=>{var d,h,f,l;const{useLocation:u=r.useLocation,useAuth:a=r.useAuth,Outlet:c=r.Outlet,Navigate:i=r.Navigate}=v.useContext(t.InjectDependenciesContext);if(a===void 0)throw new Error(o("useAuth"));if(u===void 0)throw new Error(o("useLocation"));if(c===void 0)throw new Error(o("Outlet"));if(i===void 0)throw new Error(o("Navigate"));const{isLogged:m}=a(),e=u();return m?t.jsx(v.Suspense,{fallback:n,children:(h=(d=e.state)==null?void 0:d.from)!=null&&h.state&&((l=(f=e.state)==null?void 0:f.from)==null?void 0:l.pathname)===s?t.jsx(i,{to:e.state.from.state.from.pathname+e.state.from.state.from.search,replace:!0}):t.jsx(c,{})}):t.jsx(i,{to:s,state:{from:e},replace:!0})};exports.RequireAuth=w;
|
|
@@ -4,7 +4,7 @@ export interface useResponseErrorParams {
|
|
|
4
4
|
* Translation function if you want to use your own translation function
|
|
5
5
|
* @param str
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
translate?: (str: string) => string;
|
|
8
8
|
/**
|
|
9
9
|
* Translation key returned for the unknown error
|
|
10
10
|
*/
|
package/dist/api.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useResponseError-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useResponseError-51d8f1ab.cjs");require("react");require("./InjectDependenciesProvider-40e2c821.cjs");exports.useResponseError=e.useResponseError;
|
package/dist/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as s } from "./useResponseError-
|
|
1
|
+
import { u as s } from "./useResponseError-adb9412c.js";
|
|
2
2
|
import "react";
|
|
3
|
-
import "./InjectDependenciesProvider-
|
|
3
|
+
import "./InjectDependenciesProvider-3bbc437d.js";
|
|
4
4
|
export {
|
|
5
5
|
s as useResponseError
|
|
6
6
|
};
|
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
interface NavigateProps {
|
|
3
|
+
to: string;
|
|
4
|
+
replace?: boolean;
|
|
5
|
+
state?: any;
|
|
6
|
+
}
|
|
7
|
+
interface Location {
|
|
8
|
+
state: any;
|
|
9
|
+
}
|
|
10
|
+
interface Auth {
|
|
11
|
+
isLogged: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface OutletProps {
|
|
14
|
+
context?: unknown;
|
|
15
|
+
}
|
|
3
16
|
export interface RequireAuthProps {
|
|
4
|
-
Outlet?:
|
|
5
|
-
Navigate?:
|
|
6
|
-
useLocation?: InjectDependenciesContextProps["useLocation"];
|
|
7
|
-
useAuth?: InjectDependenciesContextProps["useAuth"];
|
|
17
|
+
Outlet?: (props: OutletProps) => ReactElement | null;
|
|
18
|
+
Navigate?: (props: NavigateProps) => null;
|
|
8
19
|
loginPath?: string;
|
|
9
|
-
|
|
20
|
+
Fallback?: ReactNode;
|
|
21
|
+
useLocation?(): Location;
|
|
22
|
+
useAuth?(): Auth;
|
|
10
23
|
}
|
|
11
24
|
/**
|
|
12
|
-
* RequireAuth
|
|
13
|
-
* @param
|
|
14
|
-
* @param useAuth
|
|
15
|
-
* @param useLocation
|
|
16
|
-
* @param Outlet
|
|
17
|
-
* @param Navigate
|
|
25
|
+
* RequireAuth component for protected routing
|
|
26
|
+
* @param Fallback
|
|
18
27
|
* @param loginPath
|
|
28
|
+
* @param props
|
|
19
29
|
* @constructor
|
|
20
30
|
*/
|
|
21
|
-
declare const RequireAuth: ({
|
|
31
|
+
declare const RequireAuth: ({ Fallback, loginPath, ...props }: RequireAuthProps) => JSX.Element;
|
|
22
32
|
export default RequireAuth;
|
package/dist/auth.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./RequireAuth-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./RequireAuth-da69fc85.cjs");require("./InjectDependenciesProvider-40e2c821.cjs");require("react");exports.RequireAuth=e.RequireAuth;
|
package/dist/auth.js
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import type { useResponseErrorParams } from '../api/hooks/useResponseError';
|
|
3
|
+
import type { RequireAuthProps } from '../auth/components/RequireAuth';
|
|
2
4
|
export interface InjectDependenciesContextProps {
|
|
3
5
|
/**
|
|
4
6
|
* Children
|
|
5
7
|
*/
|
|
6
|
-
children
|
|
8
|
+
children?: ReactNode;
|
|
7
9
|
/**
|
|
8
|
-
* Translate function
|
|
10
|
+
* Translate function dependency for useResponseError hook
|
|
9
11
|
* @param str
|
|
10
12
|
*/
|
|
11
|
-
|
|
13
|
+
translate?: useResponseErrorParams["translate"];
|
|
12
14
|
/**
|
|
13
|
-
* Outlet
|
|
14
|
-
* @param props
|
|
15
|
-
* @constructor
|
|
15
|
+
* Outlet dependency for RequireAuth component
|
|
16
16
|
*/
|
|
17
|
-
Outlet
|
|
17
|
+
Outlet?: RequireAuthProps["Outlet"];
|
|
18
18
|
/**
|
|
19
|
-
* Navigate
|
|
20
|
-
* @param props
|
|
21
|
-
* @constructor
|
|
19
|
+
* Navigate dependency for RequireAuth component
|
|
22
20
|
*/
|
|
23
|
-
Navigate
|
|
21
|
+
Navigate?: RequireAuthProps["Navigate"];
|
|
24
22
|
/**
|
|
25
|
-
* useLocation
|
|
23
|
+
* useLocation dependency for RequireAuth component
|
|
26
24
|
*/
|
|
27
|
-
useLocation
|
|
25
|
+
useLocation?: RequireAuthProps["useLocation"];
|
|
28
26
|
/**
|
|
29
|
-
* useAuth
|
|
27
|
+
* useAuth dependency for RequireAuth component
|
|
30
28
|
*/
|
|
31
|
-
useAuth
|
|
32
|
-
isLogged: boolean;
|
|
33
|
-
};
|
|
29
|
+
useAuth?: RequireAuthProps["useAuth"];
|
|
34
30
|
}
|
|
35
|
-
export declare const InjectDependenciesContext: import("react").Context<
|
|
36
|
-
declare const InjectDependenciesProvider: ({ children,
|
|
31
|
+
export declare const InjectDependenciesContext: import("react").Context<InjectDependenciesContextProps>;
|
|
32
|
+
declare const InjectDependenciesProvider: ({ children, translate, useAuth, Outlet, Navigate, useLocation }: InjectDependenciesContextProps) => JSX.Element;
|
|
37
33
|
export default InjectDependenciesProvider;
|
package/dist/context.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./InjectDependenciesProvider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./InjectDependenciesProvider-40e2c821.cjs");require("react");exports.InjectDependenciesContext=e.InjectDependenciesContext;exports.InjectDependenciesProvider=e.InjectDependenciesProvider;
|
package/dist/context.js
CHANGED
package/dist/main.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./useResponseError-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./useResponseError-51d8f1ab.cjs"),n=require("./RequireAuth-da69fc85.cjs"),e=require("./InjectDependenciesProvider-40e2c821.cjs");require("react");exports.useResponseError=r.useResponseError;exports.RequireAuth=n.RequireAuth;exports.InjectDependenciesContext=e.InjectDependenciesContext;exports.InjectDependenciesProvider=e.InjectDependenciesProvider;
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as s } from "./useResponseError-
|
|
2
|
-
import { R as n } from "./RequireAuth-
|
|
3
|
-
import { a, I as i } from "./InjectDependenciesProvider-
|
|
1
|
+
import { u as s } from "./useResponseError-adb9412c.js";
|
|
2
|
+
import { R as n } from "./RequireAuth-c1956d94.js";
|
|
3
|
+
import { a, I as i } from "./InjectDependenciesProvider-3bbc437d.js";
|
|
4
4
|
import "react";
|
|
5
5
|
export {
|
|
6
6
|
a as InjectDependenciesContext,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const y=require("react"),q=require("./InjectDependenciesProvider-40e2c821.cjs"),w=a=>{const{unknownErrorTranslationKey:r="error.unknownError"}=a||{},{translate:i=a==null?void 0:a.translate}=y.useContext(q.InjectDependenciesContext);return{printError:y.useCallback(t=>{var d,u,c,l,n,g,E,f,k;return(d=t==null?void 0:t.data)!=null&&d.reason?String(t.data.reason):(u=t==null?void 0:t.data)!=null&&u.message?String(t.data.message):(l=(c=t==null?void 0:t.data)==null?void 0:c.detail)!=null&&l.length&&Array.isArray((n=t==null?void 0:t.data)==null?void 0:n.detail)&&((E=(g=t==null?void 0:t.data)==null?void 0:g.detail[0])!=null&&E.msg)&&typeof((k=(f=t==null?void 0:t.data)==null?void 0:f.detail[0])==null?void 0:k.msg)=="string"?String(t.data.detail[0].msg):i?i(r):"Unknown error"},[i,r])}};exports.useResponseError=w;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useContext as m, useCallback as y } from "react";
|
|
2
|
+
import { a as w } from "./InjectDependenciesProvider-3bbc437d.js";
|
|
3
|
+
const A = (a) => {
|
|
4
|
+
const { unknownErrorTranslationKey: d = "error.unknownError" } = a || {}, { translate: i = a == null ? void 0 : a.translate } = m(w);
|
|
5
|
+
return { printError: y(
|
|
6
|
+
(t) => {
|
|
7
|
+
var r, l, u, g, c, f, n, E, k;
|
|
8
|
+
return (r = t == null ? void 0 : t.data) != null && r.reason ? String(t.data.reason) : (l = t == null ? void 0 : t.data) != null && l.message ? String(t.data.message) : (g = (u = t == null ? void 0 : t.data) == null ? void 0 : u.detail) != null && g.length && Array.isArray((c = t == null ? void 0 : t.data) == null ? void 0 : c.detail) && ((n = (f = t == null ? void 0 : t.data) == null ? void 0 : f.detail[0]) != null && n.msg) && typeof ((k = (E = t == null ? void 0 : t.data) == null ? void 0 : E.detail[0]) == null ? void 0 : k.msg) == "string" ? String(t.data.detail[0].msg) : i ? i(d) : "Unknown error";
|
|
9
|
+
},
|
|
10
|
+
[i, d]
|
|
11
|
+
) };
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
A as u
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { a as l, j as r } from "./InjectDependenciesProvider-c64526b4.js";
|
|
2
|
-
import { useContext as m, Suspense as w } from "react";
|
|
3
|
-
const L = ({ fallback: c, useAuth: o, useLocation: n, Outlet: s, Navigate: a, loginPath: d = "/login" }) => {
|
|
4
|
-
var u, h, f, v;
|
|
5
|
-
const e = m(l);
|
|
6
|
-
if (o === void 0 && (e == null ? void 0 : e.useAuth) === void 0)
|
|
7
|
-
throw new Error("useAuth is not defined or injected not with the InjectDependenciesProvider");
|
|
8
|
-
if (n === void 0 && (e == null ? void 0 : e.useLocation) === void 0)
|
|
9
|
-
throw new Error("useLocation is not defined or not injected with the InjectDependenciesProvider");
|
|
10
|
-
if (s === void 0 && (e == null ? void 0 : e.Outlet) === void 0)
|
|
11
|
-
throw new Error("Outlet is not defined or not injected with the InjectDependenciesProvider");
|
|
12
|
-
if (a === void 0 && (e == null ? void 0 : e.Navigate) === void 0)
|
|
13
|
-
throw new Error("Navigate is not defined or not injected with the InjectDependenciesProvider");
|
|
14
|
-
const t = {
|
|
15
|
-
Navigate: a || (e == null ? void 0 : e.Navigate) || (() => null),
|
|
16
|
-
Outlet: s || (e == null ? void 0 : e.Outlet) || (() => null),
|
|
17
|
-
useAuth: o || (e == null ? void 0 : e.useAuth) || (() => ({ isLogged: !1 })),
|
|
18
|
-
useLocation: n || (e == null ? void 0 : e.useLocation) || (() => ({}))
|
|
19
|
-
}, { isLogged: p } = t.useAuth(), i = t.useLocation();
|
|
20
|
-
return p ? /* @__PURE__ */ r(w, { fallback: c, children: (h = (u = i.state) == null ? void 0 : u.from) != null && h.state && ((v = (f = i.state) == null ? void 0 : f.from) == null ? void 0 : v.pathname) === d ? /* @__PURE__ */ r(t.Navigate, { to: i.state.from.state.from.pathname + i.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ r(t.Outlet, {}) }) : /* @__PURE__ */ r(t.Navigate, { to: d, state: { from: i }, replace: !0 });
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
L as R
|
|
24
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("./InjectDependenciesProvider-cdf994b6.cjs"),f=require("react"),p=({fallback:j,useAuth:o,useLocation:n,Outlet:s,Navigate:d,loginPath:u="/login"})=>{var a,h,c,v;const e=f.useContext(r.InjectDependenciesContext);if(o===void 0&&(e==null?void 0:e.useAuth)===void 0)throw new Error("useAuth is not defined or injected not with the InjectDependenciesProvider");if(n===void 0&&(e==null?void 0:e.useLocation)===void 0)throw new Error("useLocation is not defined or not injected with the InjectDependenciesProvider");if(s===void 0&&(e==null?void 0:e.Outlet)===void 0)throw new Error("Outlet is not defined or not injected with the InjectDependenciesProvider");if(d===void 0&&(e==null?void 0:e.Navigate)===void 0)throw new Error("Navigate is not defined or not injected with the InjectDependenciesProvider");const i={Navigate:d||(e==null?void 0:e.Navigate)||(()=>null),Outlet:s||(e==null?void 0:e.Outlet)||(()=>null),useAuth:o||(e==null?void 0:e.useAuth)||(()=>({isLogged:!1})),useLocation:n||(e==null?void 0:e.useLocation)||(()=>({}))},{isLogged:l}=i.useAuth(),t=i.useLocation();return l?r.jsx(f.Suspense,{fallback:j,children:(h=(a=t.state)==null?void 0:a.from)!=null&&h.state&&((v=(c=t.state)==null?void 0:c.from)==null?void 0:v.pathname)===u?r.jsx(i.Navigate,{to:t.state.from.state.from.pathname+t.state.from.state.from.search,replace:!0}):r.jsx(i.Outlet,{})}):r.jsx(i.Navigate,{to:u,state:{from:t},replace:!0})};exports.RequireAuth=p;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useContext as w, useCallback as C } from "react";
|
|
2
|
-
import { a as S } from "./InjectDependenciesProvider-c64526b4.js";
|
|
3
|
-
const h = (r) => {
|
|
4
|
-
const { t: y } = r || {}, { unknownErrorTranslationKey: d = "error.unknownError" } = r || {}, a = w(S), i = y || (a == null ? void 0 : a.t);
|
|
5
|
-
return { printError: C(
|
|
6
|
-
(t) => {
|
|
7
|
-
var u, g, l, c, m, n, f, E, k;
|
|
8
|
-
return (u = t == null ? void 0 : t.data) != null && u.reason ? String(t.data.reason) : (g = t == null ? void 0 : t.data) != null && g.message ? String(t.data.message) : (c = (l = t == null ? void 0 : t.data) == null ? void 0 : l.detail) != null && c.length && Array.isArray((m = t == null ? void 0 : t.data) == null ? void 0 : m.detail) && ((f = (n = t == null ? void 0 : t.data) == null ? void 0 : n.detail[0]) != null && f.msg) && typeof ((k = (E = t == null ? void 0 : t.data) == null ? void 0 : E.detail[0]) == null ? void 0 : k.msg) == "string" ? String(t.data.detail[0].msg) : i ? i(d) : "Unknown error";
|
|
9
|
-
},
|
|
10
|
-
[i, d]
|
|
11
|
-
) };
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
h as u
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const y=require("react"),w=require("./InjectDependenciesProvider-cdf994b6.cjs"),C=r=>{const{t:q}=r||{},{unknownErrorTranslationKey:d="error.unknownError"}=r||{},a=y.useContext(w.InjectDependenciesContext),i=q||(a==null?void 0:a.t);return{printError:y.useCallback(t=>{var u,c,n,g,l,E,f,k,m;return(u=t==null?void 0:t.data)!=null&&u.reason?String(t.data.reason):(c=t==null?void 0:t.data)!=null&&c.message?String(t.data.message):(g=(n=t==null?void 0:t.data)==null?void 0:n.detail)!=null&&g.length&&Array.isArray((l=t==null?void 0:t.data)==null?void 0:l.detail)&&((f=(E=t==null?void 0:t.data)==null?void 0:E.detail[0])!=null&&f.msg)&&typeof((m=(k=t==null?void 0:t.data)==null?void 0:k.detail[0])==null?void 0:m.msg)=="string"?String(t.data.detail[0].msg):i?i(d):"Unknown error"},[i,d])}};exports.useResponseError=C;
|