@tracktor/shared-module 0.1.0 → 0.2.0
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 +4 -21
- package/dist/components/RequireAuth/index.d.ts +3 -0
- package/dist/context/InjectDependenciesProvider.d.ts +2 -2
- package/dist/hooks/useResponseError/index.d.ts +3 -0
- package/dist/{api/hooks → hooks/useResponseError}/useResponseError.d.ts +15 -3
- package/dist/main.d.ts +6 -3
- package/dist/main.js +688 -8
- package/dist/main.umd.cjs +27 -0
- package/package.json +2 -17
- package/api/index.d.ts +0 -1
- package/auth/index.d.ts +0 -1
- package/context/index.d.ts +0 -1
- package/dist/InjectDependenciesProvider-3bbc437d.js +0 -661
- package/dist/InjectDependenciesProvider-40e2c821.cjs +0 -27
- package/dist/RequireAuth-c1956d94.js +0 -24
- package/dist/RequireAuth-da69fc85.cjs +0 -1
- package/dist/api/main.d.ts +0 -2
- package/dist/api/types/error.d.ts +0 -14
- package/dist/api.cjs +0 -1
- package/dist/api.js +0 -6
- package/dist/auth/main.d.ts +0 -2
- package/dist/auth.cjs +0 -1
- package/dist/auth.js +0 -6
- package/dist/context/main.d.ts +0 -2
- package/dist/context.cjs +0 -1
- package/dist/context.js +0 -6
- package/dist/main.cjs +0 -1
- package/dist/useResponseError-51d8f1ab.cjs +0 -1
- package/dist/useResponseError-adb9412c.js +0 -15
- /package/dist/{auth/components → components/RequireAuth}/RequireAuth.d.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
(function(S,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],_):(S=typeof globalThis<"u"?globalThis:S||self,_(S["@tracktor/shared-module"]={},S.React))})(this,function(S,_){"use strict";var z={},je={get exports(){return z},set exports(d){z=d}},I={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var ne;function xe(){if(ne)return I;ne=1;var d=_,m=Symbol.for("react.element"),g=Symbol.for("react.fragment"),b=Object.prototype.hasOwnProperty,o=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,T={key:!0,ref:!0,__self:!0,__source:!0};function y(w,c,O){var v,h={},R=null,x=null;O!==void 0&&(R=""+O),c.key!==void 0&&(R=""+c.key),c.ref!==void 0&&(x=c.ref);for(v in c)b.call(c,v)&&!T.hasOwnProperty(v)&&(h[v]=c[v]);if(w&&w.defaultProps)for(v in c=w.defaultProps,c)h[v]===void 0&&(h[v]=c[v]);return{$$typeof:m,type:w,key:R,ref:x,props:h,_owner:o.current}}return I.Fragment=g,I.jsx=y,I.jsxs=y,I}var W={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var ae;function ke(){return ae||(ae=1,process.env.NODE_ENV!=="production"&&function(){var d=_,m=Symbol.for("react.element"),g=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),w=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),L=Symbol.iterator,Ie="@@iterator";function We(e){if(e===null||typeof e!="object")return null;var r=L&&e[L]||e[Ie];return typeof r=="function"?r:null}var D=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];Ye("error",e,t)}}function Ye(e,r,t){{var n=D.ReactDebugCurrentFrame,u=n.getStackAddendum();u!==""&&(r+="%s",t=t.concat([u]));var f=t.map(function(i){return String(i)});f.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,f)}}var Le=!1,Ne=!1,Me=!1,Ue=!1,Ve=!1,ie;ie=Symbol.for("react.module.reference");function $e(e){return!!(typeof e=="string"||typeof e=="function"||e===b||e===T||Ve||e===o||e===O||e===v||Ue||e===x||Le||Ne||Me||typeof e=="object"&&e!==null&&(e.$$typeof===R||e.$$typeof===h||e.$$typeof===y||e.$$typeof===w||e.$$typeof===c||e.$$typeof===ie||e.getModuleId!==void 0))}function Be(e,r,t){var n=e.displayName;if(n)return n;var u=r.displayName||r.name||"";return u!==""?t+"("+u+")":t}function oe(e){return e.displayName||"Context"}function P(e){if(e==null)return null;if(typeof e.tag=="number"&&p("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 b:return"Fragment";case g:return"Portal";case T:return"Profiler";case o:return"StrictMode";case O:return"Suspense";case v:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case w:var r=e;return oe(r)+".Consumer";case y:var t=e;return oe(t._context)+".Provider";case c:return Be(e,e.render,"ForwardRef");case h:var n=e.displayName||null;return n!==null?n:P(e.type)||"Memo";case R:{var u=e,f=u._payload,i=u._init;try{return P(i(f))}catch{return null}}}return null}var k=Object.assign,N=0,ue,fe,ce,le,se,de,ve;function ge(){}ge.__reactDisabledLog=!0;function Je(){{if(N===0){ue=console.log,fe=console.info,ce=console.warn,le=console.error,se=console.group,de=console.groupCollapsed,ve=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ge,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}N++}}function Ge(){{if(N--,N===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},e,{value:ue}),info:k({},e,{value:fe}),warn:k({},e,{value:ce}),error:k({},e,{value:le}),group:k({},e,{value:se}),groupCollapsed:k({},e,{value:de}),groupEnd:k({},e,{value:ve})})}N<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var K=D.ReactCurrentDispatcher,H;function $(e,r,t){{if(H===void 0)try{throw Error()}catch(u){var n=u.stack.trim().match(/\n( *(at )?)/);H=n&&n[1]||""}return`
|
|
18
|
+
`+H+e}}var X=!1,B;{var qe=typeof WeakMap=="function"?WeakMap:Map;B=new qe}function he(e,r){if(!e||X)return"";{var t=B.get(e);if(t!==void 0)return t}var n;X=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var f;f=K.current,K.current=null,Je();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(j){n=j}Reflect.construct(e,[],i)}else{try{i.call()}catch(j){n=j}e.call(i.prototype)}}else{try{throw Error()}catch(j){n=j}e()}}catch(j){if(j&&n&&typeof j.stack=="string"){for(var a=j.stack.split(`
|
|
19
|
+
`),E=n.stack.split(`
|
|
20
|
+
`),l=a.length-1,s=E.length-1;l>=1&&s>=0&&a[l]!==E[s];)s--;for(;l>=1&&s>=0;l--,s--)if(a[l]!==E[s]){if(l!==1||s!==1)do if(l--,s--,s<0||a[l]!==E[s]){var C=`
|
|
21
|
+
`+a[l].replace(" at new "," at ");return e.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",e.displayName)),typeof e=="function"&&B.set(e,C),C}while(l>=1&&s>=0);break}}}finally{X=!1,K.current=f,Ge(),Error.prepareStackTrace=u}var F=e?e.displayName||e.name:"",Pe=F?$(F):"";return typeof e=="function"&&B.set(e,Pe),Pe}function ze(e,r,t){return he(e,!1)}function Ke(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function J(e,r,t){if(e==null)return"";if(typeof e=="function")return he(e,Ke(e));if(typeof e=="string")return $(e);switch(e){case O:return $("Suspense");case v:return $("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case c:return ze(e.render);case h:return J(e.type,r,t);case R:{var n=e,u=n._payload,f=n._init;try{return J(f(u),r,t)}catch{}}}return""}var G=Object.prototype.hasOwnProperty,pe={},Ee=D.ReactDebugCurrentFrame;function q(e){if(e){var r=e._owner,t=J(e.type,e._source,r?r.type:null);Ee.setExtraStackFrame(t)}else Ee.setExtraStackFrame(null)}function He(e,r,t,n,u){{var f=Function.call.bind(G);for(var i in e)if(f(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var E=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 E.name="Invariant Violation",E}a=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(l){a=l}a&&!(a instanceof Error)&&(q(u),p("%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),q(null)),a instanceof Error&&!(a.message in pe)&&(pe[a.message]=!0,q(u),p("Failed %s type: %s",t,a.message),q(null))}}}var Xe=Array.isArray;function Z(e){return Xe(e)}function Ze(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Qe(e){try{return me(e),!1}catch{return!0}}function me(e){return""+e}function ye(e){if(Qe(e))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ze(e)),me(e)}var M=D.ReactCurrentOwner,er={key:!0,ref:!0,__self:!0,__source:!0},be,Re,Q;Q={};function rr(e){if(G.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function tr(e){if(G.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function nr(e,r){if(typeof e.ref=="string"&&M.current&&r&&M.current.stateNode!==r){var t=P(M.current.type);Q[t]||(p('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',P(M.current.type),e.ref),Q[t]=!0)}}function ar(e,r){{var t=function(){be||(be=!0,p("%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 ir(e,r){{var t=function(){Re||(Re=!0,p("%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 or=function(e,r,t,n,u,f,i){var a={$$typeof:m,type:e,key:r,ref:t,props:i,_owner:f};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:u}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function ur(e,r,t,n,u){{var f,i={},a=null,E=null;t!==void 0&&(ye(t),a=""+t),tr(r)&&(ye(r.key),a=""+r.key),rr(r)&&(E=r.ref,nr(r,u));for(f in r)G.call(r,f)&&!er.hasOwnProperty(f)&&(i[f]=r[f]);if(e&&e.defaultProps){var l=e.defaultProps;for(f in l)i[f]===void 0&&(i[f]=l[f])}if(a||E){var s=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&ar(i,s),E&&ir(i,s)}return or(e,a,E,u,n,M.current,i)}}var ee=D.ReactCurrentOwner,_e=D.ReactDebugCurrentFrame;function A(e){if(e){var r=e._owner,t=J(e.type,e._source,r?r.type:null);_e.setExtraStackFrame(t)}else _e.setExtraStackFrame(null)}var re;re=!1;function te(e){return typeof e=="object"&&e!==null&&e.$$typeof===m}function Te(){{if(ee.current){var e=P(ee.current.type);if(e)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function fr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
|
|
24
|
+
|
|
25
|
+
Check your code at `+r+":"+t+"."}return""}}var we={};function cr(e){{var r=Te();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
26
|
+
|
|
27
|
+
Check the top-level render call using <`+t+">.")}return r}}function Oe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=cr(r);if(we[t])return;we[t]=!0;var n="";e&&e._owner&&e._owner!==ee.current&&(n=" It was passed a child from "+P(e._owner.type)+"."),A(e),p('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),A(null)}}function Ce(e,r){{if(typeof e!="object")return;if(Z(e))for(var t=0;t<e.length;t++){var n=e[t];te(n)&&Oe(n,r)}else if(te(e))e._store&&(e._store.validated=!0);else if(e){var u=We(e);if(typeof u=="function"&&u!==e.entries)for(var f=u.call(e),i;!(i=f.next()).done;)te(i.value)&&Oe(i.value,r)}}}function lr(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===c||r.$$typeof===h))t=r.propTypes;else return;if(t){var n=P(r);He(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!re){re=!0;var u=P(r);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function sr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){A(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),A(null);break}}e.ref!==null&&(A(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}function Se(e,r,t,n,u,f){{var i=$e(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 E=fr(u);E?a+=E:a+=Te();var l;e===null?l="null":Z(e)?l="array":e!==void 0&&e.$$typeof===m?(l="<"+(P(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):l=typeof e,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",l,a)}var s=ur(e,r,t,u,f);if(s==null)return s;if(i){var C=r.children;if(C!==void 0)if(n)if(Z(C)){for(var F=0;F<C.length;F++)Ce(C[F],e);Object.freeze&&Object.freeze(C)}else p("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 Ce(C,e)}return e===b?sr(s):lr(s),s}}function dr(e,r,t){return Se(e,r,t,!0)}function vr(e,r,t){return Se(e,r,t,!1)}var gr=vr,hr=dr;W.Fragment=b,W.jsx=gr,W.jsxs=hr}()),W}(function(d){process.env.NODE_ENV==="production"?d.exports=xe():d.exports=ke()})(je);const Y=z.jsx,U=_.createContext({children:void 0,Navigate:void 0,Outlet:void 0,translate:void 0,useAuth:void 0,useLocation:void 0}),De=({children:d,translate:m,useAuth:g,Outlet:b,Navigate:o,useLocation:T})=>{const y=_.useMemo(()=>({Navigate:o,Outlet:b,translate:m,useAuth:g,useLocation:T}),[o,b,m,g,T]);return Y(U.Provider,{value:y,children:d})},V=d=>`RequireAuth require « ${d} » dependency. You can provide with InjectDependenciesProvider or directly in props.`,Ae=({Fallback:d,loginPath:m="/login",...g})=>{var O,v,h,R;const{useLocation:b=g.useLocation,useAuth:o=g.useAuth,Outlet:T=g.Outlet,Navigate:y=g.Navigate}=_.useContext(U);if(o===void 0)throw new Error(V("useAuth"));if(b===void 0)throw new Error(V("useLocation"));if(T===void 0)throw new Error(V("Outlet"));if(y===void 0)throw new Error(V("Navigate"));const{isLogged:w}=o(),c=b();return w?Y(_.Suspense,{fallback:d,children:(v=(O=c.state)==null?void 0:O.from)!=null&&v.state&&((R=(h=c.state)==null?void 0:h.from)==null?void 0:R.pathname)===m?Y(y,{to:c.state.from.state.from.pathname+c.state.from.state.from.search,replace:!0}):Y(T,{})}):Y(y,{to:m,state:{from:c},replace:!0})},Fe=d=>{const{unknownErrorTranslationKey:m="error.unknownError"}=d||{},{translate:g=d==null?void 0:d.translate}=_.useContext(U);return{printError:_.useCallback(o=>{var y,w,c,O,v,h,R,x,L;const T=g?g(m):"Unknown error";return(y=o==null?void 0:o.data)!=null&&y.reason?String(o.data.reason):(w=o==null?void 0:o.data)!=null&&w.message?String(o.data.message):(O=(c=o==null?void 0:o.data)==null?void 0:c.detail)!=null&&O.length&&Array.isArray((v=o==null?void 0:o.data)==null?void 0:v.detail)&&((R=(h=o==null?void 0:o.data)==null?void 0:h.detail[0])!=null&&R.msg)&&typeof((L=(x=o==null?void 0:o.data)==null?void 0:x.detail[0])==null?void 0:L.msg)=="string"?String(o.data.detail[0].msg):T},[g,m])}};S.InjectDependenciesContext=U,S.InjectDependenciesProvider=De,S.RequireAuth=Ae,S.useResponseError=Fe,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracktor/shared-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"types": "./dist/main.d.ts",
|
|
7
7
|
"main": "./dist/main.cjs",
|
|
8
8
|
"module": "./dist/main.js",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
11
|
-
"api/index.d.ts",
|
|
12
|
-
"auth/index.d.ts",
|
|
13
|
-
"context/index.d.ts"
|
|
10
|
+
"dist"
|
|
14
11
|
],
|
|
15
12
|
"exports": {
|
|
16
13
|
".": {
|
|
17
14
|
"import": "./dist/main.js",
|
|
18
15
|
"require": "./dist/main.cjs"
|
|
19
|
-
},
|
|
20
|
-
"./api": {
|
|
21
|
-
"import": "./dist/api.js",
|
|
22
|
-
"require": "./dist/api.cjs"
|
|
23
|
-
},
|
|
24
|
-
"./auth": {
|
|
25
|
-
"import": "./dist/auth.js",
|
|
26
|
-
"require": "./dist/auth.cjs"
|
|
27
|
-
},
|
|
28
|
-
"./context": {
|
|
29
|
-
"import": "./dist/context.js",
|
|
30
|
-
"require": "./dist/context.cjs"
|
|
31
16
|
}
|
|
32
17
|
},
|
|
33
18
|
"repository": {
|
package/api/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../dist/api/main";
|
package/auth/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../dist/auth/main";
|
package/context/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../dist/context/main";
|