@tracktor/shared-module 2.8.0 → 2.9.1
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 +24 -20
- package/dist/hooks/useAdapter.d.ts +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +210 -208
- package/dist/main.umd.cjs +7 -7
- package/dist/utils/adapter/worksiteNameAdapter.d.ts +6 -0
- package/package.json +1 -1
- package/dist/utils/adapter/filePathAdapter.d.ts +0 -13
package/dist/main.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],h):(_=typeof globalThis<"u"?globalThis:_||self,h(_["@tracktor/shared-module"]={},_.React))})(this,function(_,h){"use strict";var re={exports:{}},J={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var de;function
|
|
9
|
+
*/var de;function Ve(){if(de)return J;de=1;var t=h,r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function f(d,u,E){var g,P={},j=null,s=null;E!==void 0&&(j=""+E),u.key!==void 0&&(j=""+u.key),u.ref!==void 0&&(s=u.ref);for(g in u)i.call(u,g)&&!l.hasOwnProperty(g)&&(P[g]=u[g]);if(d&&d.defaultProps)for(g in u=d.defaultProps,u)P[g]===void 0&&(P[g]=u[g]);return{$$typeof:r,type:d,key:j,ref:s,props:P,_owner:o.current}}return J.Fragment=a,J.jsx=f,J.jsxs=f,J}var B={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,12 +14,12 @@
|
|
|
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 ve;function
|
|
18
|
-
`+oe+e}}var ie=!1,$;{var
|
|
17
|
+
*/var ve;function Ue(){return ve||(ve=1,process.env.NODE_ENV!=="production"&&function(){var t=h,r=Symbol.for("react.element"),a=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),f=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),s=Symbol.for("react.offscreen"),b=Symbol.iterator,C="@@iterator";function T(e){if(e===null||typeof e!="object")return null;var n=b&&e[b]||e[C];return typeof n=="function"?n:null}var y=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(e){{for(var n=arguments.length,c=new Array(n>1?n-1:0),v=1;v<n;v++)c[v-1]=arguments[v];D("error",e,c)}}function D(e,n,c){{var v=y.ReactDebugCurrentFrame,R=v.getStackAddendum();R!==""&&(n+="%s",c=c.concat([R]));var S=c.map(function(w){return String(w)});S.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,S)}}var L=!1,N=!1,Y=!1,x=!1,Ee=!1,ne;ne=Symbol.for("react.module.reference");function X(e){return!!(typeof e=="string"||typeof e=="function"||e===i||e===l||Ee||e===o||e===E||e===g||x||e===s||L||N||Y||typeof e=="object"&&e!==null&&(e.$$typeof===j||e.$$typeof===P||e.$$typeof===f||e.$$typeof===d||e.$$typeof===u||e.$$typeof===ne||e.getModuleId!==void 0))}function Rt(e,n,c){var v=e.displayName;if(v)return v;var R=n.displayName||n.name||"";return R!==""?c+"("+R+")":c}function we(e){return e.displayName||"Context"}function z(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 i:return"Fragment";case a:return"Portal";case l:return"Profiler";case o:return"StrictMode";case E:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case d:var n=e;return we(n)+".Consumer";case f:var c=e;return we(c._context)+".Provider";case u:return Rt(e,e.render,"ForwardRef");case P:var v=e.displayName||null;return v!==null?v:z(e.type)||"Memo";case j:{var R=e,S=R._payload,w=R._init;try{return z(w(S))}catch{return null}}}return null}var V=Object.assign,K=0,Re,Ce,_e,pe,Se,be,Pe;function je(){}je.__reactDisabledLog=!0;function Ct(){{if(K===0){Re=console.log,Ce=console.info,_e=console.warn,pe=console.error,Se=console.group,be=console.groupCollapsed,Pe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:je,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}K++}}function _t(){{if(K--,K===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},e,{value:Re}),info:V({},e,{value:Ce}),warn:V({},e,{value:_e}),error:V({},e,{value:pe}),group:V({},e,{value:Se}),groupCollapsed:V({},e,{value:be}),groupEnd:V({},e,{value:Pe})})}K<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=y.ReactCurrentDispatcher,oe;function Z(e,n,c){{if(oe===void 0)try{throw Error()}catch(R){var v=R.stack.trim().match(/\n( *(at )?)/);oe=v&&v[1]||""}return`
|
|
18
|
+
`+oe+e}}var ie=!1,$;{var pt=typeof WeakMap=="function"?WeakMap:Map;$=new pt}function Te(e,n){if(!e||ie)return"";{var c=$.get(e);if(c!==void 0)return c}var v;ie=!0;var R=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var S;S=ae.current,ae.current=null,Ct();try{if(n){var w=function(){throw Error()};if(Object.defineProperty(w.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(w,[])}catch(M){v=M}Reflect.construct(e,[],w)}else{try{w.call()}catch(M){v=M}e.call(w.prototype)}}else{try{throw Error()}catch(M){v=M}e()}}catch(M){if(M&&v&&typeof M.stack=="string"){for(var m=M.stack.split(`
|
|
19
19
|
`),I=v.stack.split(`
|
|
20
20
|
`),O=m.length-1,A=I.length-1;O>=1&&A>=0&&m[O]!==I[A];)A--;for(;O>=1&&A>=0;O--,A--)if(m[O]!==I[A]){if(O!==1||A!==1)do if(O--,A--,A<0||m[O]!==I[A]){var F=`
|
|
21
|
-
`+m[O].replace(" at new "," at ");return e.displayName&&F.includes("<anonymous>")&&(F=F.replace("<anonymous>",e.displayName)),typeof e=="function"&&$.set(e,F),F}while(O>=1&&A>=0);break}}}finally{ie=!1,ae.current=
|
|
21
|
+
`+m[O].replace(" at new "," at ");return e.displayName&&F.includes("<anonymous>")&&(F=F.replace("<anonymous>",e.displayName)),typeof e=="function"&&$.set(e,F),F}while(O>=1&&A>=0);break}}}finally{ie=!1,ae.current=S,_t(),Error.prepareStackTrace=R}var G=e?e.displayName||e.name:"",Me=G?Z(G):"";return typeof e=="function"&&$.set(e,Me),Me}function St(e,n,c){return Te(e,!1)}function bt(e){var n=e.prototype;return!!(n&&n.isReactComponent)}function q(e,n,c){if(e==null)return"";if(typeof e=="function")return Te(e,bt(e));if(typeof e=="string")return Z(e);switch(e){case E:return Z("Suspense");case g:return Z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case u:return St(e.render);case P:return q(e.type,n,c);case j:{var v=e,R=v._payload,S=v._init;try{return q(S(R),n,c)}catch{}}}return""}var ee=Object.prototype.hasOwnProperty,Oe={},Ae=y.ReactDebugCurrentFrame;function te(e){if(e){var n=e._owner,c=q(e.type,e._source,n?n.type:null);Ae.setExtraStackFrame(c)}else Ae.setExtraStackFrame(null)}function Pt(e,n,c,v,R){{var S=Function.call.bind(ee);for(var w in e)if(S(e,w)){var m=void 0;try{if(typeof e[w]!="function"){var I=Error((v||"React class")+": "+c+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw I.name="Invariant Violation",I}m=e[w](n,w,v,c,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(O){m=O}m&&!(m instanceof Error)&&(te(R),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).",v||"React class",c,w,typeof m),te(null)),m instanceof Error&&!(m.message in Oe)&&(Oe[m.message]=!0,te(R),p("Failed %s type: %s",c,m.message),te(null))}}}var jt=Array.isArray;function ce(e){return jt(e)}function Tt(e){{var n=typeof Symbol=="function"&&Symbol.toStringTag,c=n&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c}}function Ot(e){try{return xe(e),!1}catch{return!0}}function xe(e){return""+e}function Ie(e){if(Ot(e))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Tt(e)),xe(e)}var Q=y.ReactCurrentOwner,At={key:!0,ref:!0,__self:!0,__source:!0},ke,De,se;se={};function xt(e){if(ee.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return e.ref!==void 0}function It(e){if(ee.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function kt(e,n){if(typeof e.ref=="string"&&Q.current&&n&&Q.current.stateNode!==n){var c=z(Q.current.type);se[c]||(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',z(Q.current.type),e.ref),se[c]=!0)}}function Dt(e,n){{var c=function(){ke||(ke=!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)",n))};c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}}function Ft(e,n){{var c=function(){De||(De=!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)",n))};c.isReactWarning=!0,Object.defineProperty(e,"ref",{get:c,configurable:!0})}}var Lt=function(e,n,c,v,R,S,w){var m={$$typeof:r,type:e,key:n,ref:c,props:w,_owner:S};return m._store={},Object.defineProperty(m._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(m,"_self",{configurable:!1,enumerable:!1,writable:!1,value:v}),Object.defineProperty(m,"_source",{configurable:!1,enumerable:!1,writable:!1,value:R}),Object.freeze&&(Object.freeze(m.props),Object.freeze(m)),m};function Nt(e,n,c,v,R){{var S,w={},m=null,I=null;c!==void 0&&(Ie(c),m=""+c),It(n)&&(Ie(n.key),m=""+n.key),xt(n)&&(I=n.ref,kt(n,R));for(S in n)ee.call(n,S)&&!At.hasOwnProperty(S)&&(w[S]=n[S]);if(e&&e.defaultProps){var O=e.defaultProps;for(S in O)w[S]===void 0&&(w[S]=O[S])}if(m||I){var A=typeof e=="function"?e.displayName||e.name||"Unknown":e;m&&Dt(w,A),I&&Ft(w,A)}return Lt(e,m,I,R,v,Q.current,w)}}var ue=y.ReactCurrentOwner,Fe=y.ReactDebugCurrentFrame;function U(e){if(e){var n=e._owner,c=q(e.type,e._source,n?n.type:null);Fe.setExtraStackFrame(c)}else Fe.setExtraStackFrame(null)}var le;le=!1;function fe(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function Le(){{if(ue.current){var e=z(ue.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function Yt(e){return""}var Ne={};function Wt(e){{var n=Le();if(!n){var c=typeof e=="string"?e:e.displayName||e.name;c&&(n=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+c+">.")}return r}}function Ne(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=Yt(r);if(Le[c])return;Le[c]=!0;var v="";e&&e._owner&&e._owner!==ue.current&&(v=" It was passed a child from "+z(e._owner.type)+"."),U(e),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',c,v),U(null)}}function Ye(e,r){{if(typeof e!="object")return;if(ce(e))for(var c=0;c<e.length;c++){var v=e[c];fe(v)&&Ne(v,r)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var R=T(e);if(typeof R=="function"&&R!==e.entries)for(var p=R.call(e),w;!(w=p.next()).done;)fe(w.value)&&Ne(w.value,r)}}}function Wt(e){{var r=e.type;if(r==null||typeof r=="string")return;var c;if(typeof r=="function")c=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===u||r.$$typeof===P))c=r.propTypes;else return;if(c){var v=z(r);bt(c,e.props,"prop",v,e)}else if(r.PropTypes!==void 0&&!le){le=!0;var R=z(r);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",R||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function zt(e){{for(var r=Object.keys(e.props),c=0;c<r.length;c++){var v=r[c];if(v!=="children"&&v!=="key"){U(e),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",v),U(null);break}}e.ref!==null&&(U(e),_("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}function We(e,r,c,v,R,p){{var w=X(e);if(!w){var m="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(m+=" 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 I=Nt();I?m+=I:m+=Fe();var O;e===null?O="null":ce(e)?O="array":e!==void 0&&e.$$typeof===n?(O="<"+(z(e.type)||"Unknown")+" />",m=" Did you accidentally export a JSX literal instead of a component?"):O=typeof e,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",O,m)}var A=Lt(e,r,c,R,p);if(A==null)return A;if(w){var F=r.children;if(F!==void 0)if(v)if(ce(F)){for(var G=0;G<F.length;G++)Ye(F[G],e);Object.freeze&&Object.freeze(F)}else _("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(F,e)}return e===i?zt(A):Wt(A),A}}function Mt(e,r,c){return We(e,r,c,!0)}function Vt(e,r,c){return We(e,r,c,!1)}var Ut=Vt,Gt=Mt;B.Fragment=i,B.jsx=Ut,B.jsxs=Gt}()),B}process.env.NODE_ENV==="production"?re.exports=Me():re.exports=Ve();var W=re.exports;const k=h.createContext({}),Ue=({children:t,apiURL:n,libraries:a,localStorageKeys:i})=>{const o=h.useMemo(()=>({apiURL:n,libraries:a,localStorageKeys:i}),[n,a,i]);return W.jsx(k.Provider,{value:o,children:t})},Ge="user",Je=({Fallback:t,isLogged:n,loginPath:a="/login",redirect401Path:i="/login",...o})=>{var D,L,N,Y;const{libraries:l,localStorageKeys:f}=h.useContext(k),d=(o==null?void 0:o.reactRouter)||(l==null?void 0:l.reactRouter),u=(o==null?void 0:o.axios)||(l==null?void 0:l.axios),E=(o==null?void 0:o.localStorageKey)||(f==null?void 0:f.user)||Ge;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[g,P]=h.useState(null),{useLocation:j,Navigate:s,Outlet:b}=d,C=j(),T=h.useRef(!1),y=typeof n=="function"?n():!!n,_=typeof y=="boolean"?y:y==null?void 0:y.isLogged;return h.useEffect(()=>{T.current||(T.current=!0,u.interceptors.response.use(x=>x,async x=>{var X;return typeof x=="object"&&x&&"response"in x&&x.response&&typeof x.response=="object"&&"status"in x.response&&x.response&&typeof x.response=="object"&&"status"in x.response&&((X=x==null?void 0:x.response)==null?void 0:X.status)===401&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(E),P(i)),Promise.reject(x)}))},[u.defaults.headers.common,u.interceptors.response,E,i]),_&&!g?W.jsx(h.Suspense,{fallback:t,children:(L=(D=C.state)==null?void 0:D.from)!=null&&L.state&&((Y=(N=C.state)==null?void 0:N.from)==null?void 0:Y.pathname)===a?W.jsx(s,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):W.jsx(b,{})}):W.jsx(s,{to:a+C.search,state:{from:C},replace:!0})},Be=({data:t,...n})=>{const{libraries:a}=h.useContext(k),i=(n==null?void 0:n.reactRouter)||(a==null?void 0:a.reactRouter),o=(n==null?void 0:n.gtm)||(a==null?void 0:a.gtm);if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:l}=o,{useLocation:f,Outlet:d}=i,{pathname:u}=f(),{sendEvent:E}=l();return h.useEffect(()=>{E({event:"pageView",pathname:u,...t})},[t,u,E]),W.jsx(d,{})},Ke="user",Qe=({tokenTypeKey:t="tokenType",tokenKey:n="accessToken",postContentType:a="application/json",...i})=>{const{apiURL:o=i.apiURL,libraries:l,localStorageKeys:f}=h.useContext(k),d=(i==null?void 0:i.userLocalStorageKey)||(f==null?void 0:f.user)||Ke,u=(i==null?void 0:i.axios)||(l==null?void 0:l.axios);if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!(u!=null&&u.defaults))return null;if(typeof window<"u"&&window.localStorage){const E=localStorage.getItem(d),g=E?JSON.parse(E):null,P=g!=null&&g[t]?g[t]:null,j=g!=null&&g[n]?g[n]:null,s=E?`${P} ${j}`:null;s&&(u.defaults.headers.common.Authorization=s)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=a,null},He=({debug:t,resources:n,...a})=>{const{libraries:i}=h.useContext(k),o=(a==null?void 0:a.i18)||(i==null?void 0:i.i18),{i18next:l,initReactI18next:f,languageDetector:d}=o||{};if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return l!=null&&l.isInitialized||(l.use(d).use(f).init({debug:t,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:n,returnNull:!1}).then(()=>{document.documentElement.lang!==l.resolvedLanguage&&l.resolvedLanguage&&document.documentElement.setAttribute("lang",l.resolvedLanguage)}),l.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Xe=({dsn:t,integrations:n,tracesSampleRate:a,replaysSessionSampleRate:i,replaysOnErrorSampleRate:o,tracePropagationTargets:l,ignoreErrors:f,debug:d,environment:u,release:E,...g})=>{const{libraries:P}=h.useContext(k),j=(g==null?void 0:g.sentry)||(P==null?void 0:P.sentry),s=(g==null?void 0:g.reactRouter)||(P==null?void 0:P.reactRouter);if(!j)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(j.isInitialized())return null;const{createRoutesFromChildren:b,matchRoutes:C,useLocation:T,useNavigationType:y}=s;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&j.init({debug:d,dsn:t,environment:u||"production",ignoreErrors:[...f||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[j.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:b,matchRoutes:C,useEffect:h.useEffect,useLocation:T,useNavigationType:y}),...n||[]],release:E,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:i||.1,tracePropagationTargets:l,tracesSampleRate:a||1}),null},Ze=({IMaskMixin:t,...n})=>{const a=h.useMemo(()=>t(({TextField:i,...o})=>W.jsx(i,{...o})),[t]);return W.jsx(a,{...n})},$e=({accessToken:t,...n})=>{const{libraries:a}=h.useContext(k),i=(n==null?void 0:n.mapbox)||(a==null?void 0:a.mapbox);if(!i)throw new Error("Mapbox is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return t&&(i.accessToken=t),null},qe=({language:t,...n})=>{const{libraries:a}=h.useContext(k),i=(n==null?void 0:n.dayjs)||(a==null?void 0:a.dayjs),o=(n==null?void 0:n.plugin)||(a==null?void 0:a.dayjsPlugin);if(!i)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return h.useEffect(()=>{(async()=>{var d;const f=t||((d=navigator.language)==null?void 0:d.slice(0,2))||"en";o&&o.forEach(u=>{u&&i.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),i.locale(f)})().then()},[i,o,t]),null},et=()=>(h.useEffect(()=>{const t=n=>{try{n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",t),()=>{window.removeEventListener("vite:preloadError",t)}},[]),null),tt=t=>t&&typeof t=="function",rt=t=>t&&typeof t=="function",nt=({children:t,defaultQueriesOptions:n,defaultMutationsOptions:a,...i})=>{var u,E;const{libraries:o}=h.useContext(k),l=(i==null?void 0:i.QueryClient)||((u=o==null?void 0:o.reactQuery)==null?void 0:u.QueryClient),f=(i==null?void 0:i.QueryClientProvider)||((E=o==null?void 0:o.reactQuery)==null?void 0:E.QueryClientProvider);if(!l)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!f)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!tt(f))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!rt(l))throw new Error("Provided QueryClient dependencies are not valid.");const d=new l({defaultOptions:{mutations:{...a},queries:{getNextPageParam:(g,P,j)=>g.length+(j||0),refetchOnWindowFocus:!1,retry:3,...n}}});return W.jsx(f,{client:d,children:t})},at=t=>{var E,g,P;const{libraries:n}=h.useContext(k),a=(t==null?void 0:t.i18)||(n==null?void 0:n.i18),i=((E=t==null?void 0:t.i18)==null?void 0:E.translateFunction)||((g=n==null?void 0:n.i18)==null?void 0:g.translateFunction),o=((P=a==null?void 0:a.i18next)==null?void 0:P.t)||i||(j=>j),{unknownErrorTranslationKey:l="error.unknownError"}=t||{},f=o(l),d=h.useCallback(j=>{var b,C,T,y,_,D,L,N,Y;const{response:s}=j||{};return s!=null&&s.reason?String(s.reason):(b=s==null?void 0:s.data)!=null&&b.reason?String(s.data.reason):(C=s==null?void 0:s.data)!=null&&C.message?String(s.data.message):(y=(T=s==null?void 0:s.data)==null?void 0:T.detail)!=null&&y.length&&Array.isArray((_=s==null?void 0:s.data)==null?void 0:_.detail)&&((L=(D=s==null?void 0:s.data)==null?void 0:D.detail[0])!=null&&L.msg)&&typeof((Y=(N=s==null?void 0:s.data)==null?void 0:N.detail[0])==null?void 0:Y.msg)=="string"?String(s.data.detail[0].msg):f},[f]);return{getErrorCode:h.useCallback(j=>{var b,C,T;const{response:s}=j||{};return s!=null&&s.error_code?String(s==null?void 0:s.error_code):(b=s==null?void 0:s.data)!=null&&b.error_code?String((C=s==null?void 0:s.data)==null?void 0:C.error_code):s!=null&&s.error_code?String(s==null?void 0:s.error_code):(T=s==null?void 0:s.data)!=null&&T.error_code?String(s.data.error_code):"unknown_error_code"},[]),printError:d}},ot=({data:t,fetchNextPage:n,isFetchingNextPage:a,isInitialLoading:i,isLoading:o,enabled:l=!0})=>{const f=h.useCallback(async u=>{a||!l||await n({pageParam:(u==null?void 0:u.pageParam)||u.visibleRowsCount})},[l,n,a]),d=h.useMemo(()=>{if(t)return t.pages.reduce((u,E)=>[...u,...E],[])},[t]);return{fetchNextPageOnRowsScrollEnd:f,isLoading:a||o,loadingVariant:i?"skeleton":"linear",rows:d}},it=t=>{const{libraries:n}=h.useContext(k),a=(t==null?void 0:t.axios)||(n==null?void 0:n.axios),i=(t==null?void 0:t.localStorageKey)||"user";if(!a)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const o=h.useCallback(({tokenType:f,accessToken:d})=>{a.defaults.headers.common.Authorization=`${f} ${d}`},[a.defaults.headers.common]),l=()=>{a.defaults.headers.common.Authorization=null};return h.useEffect(()=>{const f=({newValue:d,key:u})=>{if(u===i&&d)try{const{accessToken:E,tokenType:g}=JSON.parse(d);o({accessToken:E,tokenType:g})}catch(E){console.error("Failed to parse newValue from localStorage:",E)}};return window.addEventListener("storage",f),()=>{window.removeEventListener("storage",f)}},[i,o]),{clearAuthenticationToken:l,setAuthenticationToken:o}},ge=({library:t,date:n,format:a="ll"})=>t(n).format(a),he=(t,n="km")=>{const a=Number(t);return Number.isNaN(a)?`0 ${n}`:`${a.toFixed(2)} ${n}`},ct=t=>t!=null&&t.startsWith("/")?t!=null&&t.startsWith("/files")?t:`/files${t}`:t!=null&&t.startsWith("files")?`/${t}`:`/files/${t}`,st=({path:t,size:n,apiURL:a})=>{if(!t)return"";const i=ct(t),o=`${a}${i}`,l=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof n=="number"&&l?`${o.replace("/files",`/thumbs/${n}`)}`:o},ut=t=>{const{apiURL:n,libraries:a}=h.useContext(k),i=(t==null?void 0:t.dayjs)||(a==null?void 0:a.dayjs);return{dateAdapter:(f,d)=>{if(!i)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return ge({date:f,format:d,library:i})},distanceAdapter:he,filePathAdapter:(f,d)=>{if(!n)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return st({apiURL:n,path:f,size:d})}}},H=(t,n)=>n==="short"?t.split("-")[0]:t,lt=(t,n="full")=>{const[a,i]=h.useState(()=>{const o=(t==null?void 0:t.language)||navigator.language;return t&&"isInitialized"in t&&t.isInitialized,H(o,n)});return h.useEffect(()=>{var l;t&&"isInitialized"in t&&t.isInitialized&&t.language&&i(H(t.language,n));const o=f=>{i(H(f,n))};return(l=t==null?void 0:t.on)==null||l.call(t,"languageChanged",o),()=>{var f;(f=t==null?void 0:t.off)==null||f.call(t,"languageChanged",o)}},[t,n]),a},ft="tracktor.filter",ye=(t,n,a)=>`${a}_${t}=>${n}`,dt=t=>{const{libraries:n,localStorageKeys:a}=h.useContext(k),i=(t==null?void 0:t.reactRouter)||(n==null?void 0:n.reactRouter),{useLocation:o,useSearchParams:l}=i,{pathname:f}=o(),[d,u]=l(),E=(a==null?void 0:a.filter)||ft;if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const g=(b,C,T=!0)=>{const y=ye(b,(t==null?void 0:t.pathname)||f,E);if(!C||Array.isArray(C)&&!C.length){d.delete(b),u(d),localStorage.removeItem(y);return}T&&C&&localStorage.setItem(y,JSON.stringify({...d,[b]:C})),C&&(d.set(b,JSON.stringify(C)),u(d))};return{getFilter:(b,C)=>{const T=d.get(b);if(T)try{return JSON.parse(T)}catch{return T}const y=ye(b,(t==null?void 0:t.pathname)||f,E),_=localStorage.getItem(y);if(_)try{return JSON.parse(_)[b]}catch{}return C},getFilters:()=>{const b=Object.fromEntries(d.entries()),T=Object.keys(localStorage).filter(y=>y.startsWith(E)&&y.endsWith((t==null?void 0:t.pathname)||f)).reduce((y,_)=>{var L,N;const D=localStorage.getItem(_);if(D){const Y=JSON.parse(D),x=(L=Object.keys(Y))==null?void 0:L[0];y[x]=(N=Object.values(Y))==null?void 0:N[0]}return y},{});return{...b,...T}},handleFilter:(b,C)=>(T,y)=>{if(y||Array.isArray(y)&&y.length===0){const _=C||"value",D=typeof y=="object"&&_ in y?y[_||"value"]:y;g(b,D);return}g(b,void 0)},setFilter:g}},vt=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),gt=t=>{const i=t.split("/").filter(o=>o.length>0).map(o=>o.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return i.charAt(0).toLowerCase()+i.slice(1)},ht=t=>(t.split("/").pop()||t).replace(/\.json$/,"").replace(/^openapi\./,""),yt=(t,n,a)=>{const i=gt(n),o=vt(a);return`${i}${o}`},mt=t=>{if(t)return(t==null?void 0:t.reduce((n,a)=>(n[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}},n),{}))||{}},Et=t=>(Array.isArray(t)?t:[t]).reduce((a,i)=>{const{output:o,operationsToGenerateInfiniteQueryHook:l,input:f="./openapi.json"}=i||{},d=ht(f);return{...a,[d]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:f,output:{baseUrl:o==null?void 0:o.baseUrl,client:"react-query",mode:"tags-split",override:{...(l==null?void 0:l.length)&&{operations:mt(l)},header:u=>["Generated by orval 🍺",...u.title?[u.title]:[],...u.description?[u.description]:[]],mutator:{name:"axiosCustomInstance",path:`${__dirname}/axiosCustomInstance.ts`},operationName:yt,query:{useQuery:!0}},schemas:(o==null?void 0:o.schemas)||`src/api/${d}/model`,target:(o==null?void 0:o.target)||`src/api/${d}/services/api.ts`,...o}}}},{});S.GTMSendPageView=Be,S.InitializeAxiosConfig=Qe,S.InitializeDaysJSConfig=qe,S.InitializeI18nConfig=He,S.InitializeMapBoxConfig=$e,S.InitializeSentryConfig=Xe,S.InjectDependenciesContext=k,S.InjectDependenciesProvider=Ue,S.MaskTextField=Ze,S.PreloadErrorHandler=et,S.QueryClientProviderWithConfig=nt,S.RequireAuth=Je,S.dateAdapter=ge,S.distanceAdapter=he,S.getOrvalConfig=Et,S.useAdapter=ut,S.useAuth=it,S.useCurrentLanguage=lt,S.useFilters=dt,S.useInfiniteDataGrid=ot,S.useResponseError=at,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
25
|
+
Check the top-level render call using <`+c+">.")}return n}}function Ye(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=Wt(n);if(Ne[c])return;Ne[c]=!0;var v="";e&&e._owner&&e._owner!==ue.current&&(v=" It was passed a child from "+z(e._owner.type)+"."),U(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.',c,v),U(null)}}function We(e,n){{if(typeof e!="object")return;if(ce(e))for(var c=0;c<e.length;c++){var v=e[c];fe(v)&&Ye(v,n)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var R=T(e);if(typeof R=="function"&&R!==e.entries)for(var S=R.call(e),w;!(w=S.next()).done;)fe(w.value)&&Ye(w.value,n)}}}function zt(e){{var n=e.type;if(n==null||typeof n=="string")return;var c;if(typeof n=="function")c=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===u||n.$$typeof===P))c=n.propTypes;else return;if(c){var v=z(n);Pt(c,e.props,"prop",v,e)}else if(n.PropTypes!==void 0&&!le){le=!0;var R=z(n);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",R||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Mt(e){{for(var n=Object.keys(e.props),c=0;c<n.length;c++){var v=n[c];if(v!=="children"&&v!=="key"){U(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",v),U(null);break}}e.ref!==null&&(U(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}function ze(e,n,c,v,R,S){{var w=X(e);if(!w){var m="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(m+=" 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 I=Yt();I?m+=I:m+=Le();var O;e===null?O="null":ce(e)?O="array":e!==void 0&&e.$$typeof===r?(O="<"+(z(e.type)||"Unknown")+" />",m=" Did you accidentally export a JSX literal instead of a component?"):O=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",O,m)}var A=Nt(e,n,c,R,S);if(A==null)return A;if(w){var F=n.children;if(F!==void 0)if(v)if(ce(F)){for(var G=0;G<F.length;G++)We(F[G],e);Object.freeze&&Object.freeze(F)}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 We(F,e)}return e===i?Mt(A):zt(A),A}}function Vt(e,n,c){return ze(e,n,c,!0)}function Ut(e,n,c){return ze(e,n,c,!1)}var Gt=Ut,Jt=Vt;B.Fragment=i,B.jsx=Gt,B.jsxs=Jt}()),B}process.env.NODE_ENV==="production"?re.exports=Ve():re.exports=Ue();var W=re.exports;const k=h.createContext({}),Ge=({children:t,apiURL:r,libraries:a,localStorageKeys:i})=>{const o=h.useMemo(()=>({apiURL:r,libraries:a,localStorageKeys:i}),[r,a,i]);return W.jsx(k.Provider,{value:o,children:t})},Je="user",Be=({Fallback:t,isLogged:r,loginPath:a="/login",redirect401Path:i="/login",...o})=>{var D,L,N,Y;const{libraries:l,localStorageKeys:f}=h.useContext(k),d=(o==null?void 0:o.reactRouter)||(l==null?void 0:l.reactRouter),u=(o==null?void 0:o.axios)||(l==null?void 0:l.axios),E=(o==null?void 0:o.localStorageKey)||(f==null?void 0:f.user)||Je;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[g,P]=h.useState(null),{useLocation:j,Navigate:s,Outlet:b}=d,C=j(),T=h.useRef(!1),y=typeof r=="function"?r():!!r,p=typeof y=="boolean"?y:y==null?void 0:y.isLogged;return h.useEffect(()=>{T.current||(T.current=!0,u.interceptors.response.use(x=>x,async x=>{var X;return typeof x=="object"&&x&&"response"in x&&x.response&&typeof x.response=="object"&&"status"in x.response&&x.response&&typeof x.response=="object"&&"status"in x.response&&((X=x==null?void 0:x.response)==null?void 0:X.status)===401&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(E),P(i)),Promise.reject(x)}))},[u.defaults.headers.common,u.interceptors.response,E,i]),p&&!g?W.jsx(h.Suspense,{fallback:t,children:(L=(D=C.state)==null?void 0:D.from)!=null&&L.state&&((Y=(N=C.state)==null?void 0:N.from)==null?void 0:Y.pathname)===a?W.jsx(s,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):W.jsx(b,{})}):W.jsx(s,{to:a+C.search,state:{from:C},replace:!0})},Ke=({data:t,...r})=>{const{libraries:a}=h.useContext(k),i=(r==null?void 0:r.reactRouter)||(a==null?void 0:a.reactRouter),o=(r==null?void 0:r.gtm)||(a==null?void 0:a.gtm);if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:l}=o,{useLocation:f,Outlet:d}=i,{pathname:u}=f(),{sendEvent:E}=l();return h.useEffect(()=>{E({event:"pageView",pathname:u,...t})},[t,u,E]),W.jsx(d,{})},Qe="user",He=({tokenTypeKey:t="tokenType",tokenKey:r="accessToken",postContentType:a="application/json",...i})=>{const{apiURL:o=i.apiURL,libraries:l,localStorageKeys:f}=h.useContext(k),d=(i==null?void 0:i.userLocalStorageKey)||(f==null?void 0:f.user)||Qe,u=(i==null?void 0:i.axios)||(l==null?void 0:l.axios);if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!(u!=null&&u.defaults))return null;if(typeof window<"u"&&window.localStorage){const E=localStorage.getItem(d),g=E?JSON.parse(E):null,P=g!=null&&g[t]?g[t]:null,j=g!=null&&g[r]?g[r]:null,s=E?`${P} ${j}`:null;s&&(u.defaults.headers.common.Authorization=s)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=a,null},Xe=({debug:t,resources:r,...a})=>{const{libraries:i}=h.useContext(k),o=(a==null?void 0:a.i18)||(i==null?void 0:i.i18),{i18next:l,initReactI18next:f,languageDetector:d}=o||{};if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return l!=null&&l.isInitialized||(l.use(d).use(f).init({debug:t,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:r,returnNull:!1}).then(()=>{document.documentElement.lang!==l.resolvedLanguage&&l.resolvedLanguage&&document.documentElement.setAttribute("lang",l.resolvedLanguage)}),l.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Ze=({dsn:t,integrations:r,tracesSampleRate:a,replaysSessionSampleRate:i,replaysOnErrorSampleRate:o,tracePropagationTargets:l,ignoreErrors:f,debug:d,environment:u,release:E,...g})=>{const{libraries:P}=h.useContext(k),j=(g==null?void 0:g.sentry)||(P==null?void 0:P.sentry),s=(g==null?void 0:g.reactRouter)||(P==null?void 0:P.reactRouter);if(!j)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(j.isInitialized())return null;const{createRoutesFromChildren:b,matchRoutes:C,useLocation:T,useNavigationType:y}=s;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&j.init({debug:d,dsn:t,environment:u||"production",ignoreErrors:[...f||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[j.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:b,matchRoutes:C,useEffect:h.useEffect,useLocation:T,useNavigationType:y}),...r||[]],release:E,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:i||.1,tracePropagationTargets:l,tracesSampleRate:a||1}),null},$e=({IMaskMixin:t,...r})=>{const a=h.useMemo(()=>t(({TextField:i,...o})=>W.jsx(i,{...o})),[t]);return W.jsx(a,{...r})},qe=({accessToken:t,...r})=>{const{libraries:a}=h.useContext(k),i=(r==null?void 0:r.mapbox)||(a==null?void 0:a.mapbox);if(!i)throw new Error("Mapbox is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return t&&(i.accessToken=t),null},et=({language:t,...r})=>{const{libraries:a}=h.useContext(k),i=(r==null?void 0:r.dayjs)||(a==null?void 0:a.dayjs),o=(r==null?void 0:r.plugin)||(a==null?void 0:a.dayjsPlugin);if(!i)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return h.useEffect(()=>{(async()=>{var d;const f=t||((d=navigator.language)==null?void 0:d.slice(0,2))||"en";o&&o.forEach(u=>{u&&i.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),i.locale(f)})().then()},[i,o,t]),null},tt=()=>(h.useEffect(()=>{const t=r=>{try{r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",t),()=>{window.removeEventListener("vite:preloadError",t)}},[]),null),rt=t=>t&&typeof t=="function",nt=t=>t&&typeof t=="function",at=({children:t,defaultQueriesOptions:r,defaultMutationsOptions:a,...i})=>{var u,E;const{libraries:o}=h.useContext(k),l=(i==null?void 0:i.QueryClient)||((u=o==null?void 0:o.reactQuery)==null?void 0:u.QueryClient),f=(i==null?void 0:i.QueryClientProvider)||((E=o==null?void 0:o.reactQuery)==null?void 0:E.QueryClientProvider);if(!l)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!f)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!rt(f))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!nt(l))throw new Error("Provided QueryClient dependencies are not valid.");const d=new l({defaultOptions:{mutations:{...a},queries:{getNextPageParam:(g,P,j)=>g.length+(j||0),refetchOnWindowFocus:!1,retry:3,...r}}});return W.jsx(f,{client:d,children:t})},ot=t=>{var E,g,P;const{libraries:r}=h.useContext(k),a=(t==null?void 0:t.i18)||(r==null?void 0:r.i18),i=((E=t==null?void 0:t.i18)==null?void 0:E.translateFunction)||((g=r==null?void 0:r.i18)==null?void 0:g.translateFunction),o=((P=a==null?void 0:a.i18next)==null?void 0:P.t)||i||(j=>j),{unknownErrorTranslationKey:l="error.unknownError"}=t||{},f=o(l),d=h.useCallback(j=>{var b,C,T,y,p,D,L,N,Y;const{response:s}=j||{};return s!=null&&s.reason?String(s.reason):(b=s==null?void 0:s.data)!=null&&b.reason?String(s.data.reason):(C=s==null?void 0:s.data)!=null&&C.message?String(s.data.message):(y=(T=s==null?void 0:s.data)==null?void 0:T.detail)!=null&&y.length&&Array.isArray((p=s==null?void 0:s.data)==null?void 0:p.detail)&&((L=(D=s==null?void 0:s.data)==null?void 0:D.detail[0])!=null&&L.msg)&&typeof((Y=(N=s==null?void 0:s.data)==null?void 0:N.detail[0])==null?void 0:Y.msg)=="string"?String(s.data.detail[0].msg):f},[f]);return{getErrorCode:h.useCallback(j=>{var b,C,T;const{response:s}=j||{};return s!=null&&s.error_code?String(s==null?void 0:s.error_code):(b=s==null?void 0:s.data)!=null&&b.error_code?String((C=s==null?void 0:s.data)==null?void 0:C.error_code):s!=null&&s.error_code?String(s==null?void 0:s.error_code):(T=s==null?void 0:s.data)!=null&&T.error_code?String(s.data.error_code):"unknown_error_code"},[]),printError:d}},it=({data:t,fetchNextPage:r,isFetchingNextPage:a,isInitialLoading:i,isLoading:o,enabled:l=!0})=>{const f=h.useCallback(async u=>{a||!l||await r({pageParam:(u==null?void 0:u.pageParam)||u.visibleRowsCount})},[l,r,a]),d=h.useMemo(()=>{if(t)return t.pages.reduce((u,E)=>[...u,...E],[])},[t]);return{fetchNextPageOnRowsScrollEnd:f,isLoading:a||o,loadingVariant:i?"skeleton":"linear",rows:d}},ct=t=>{const{libraries:r}=h.useContext(k),a=(t==null?void 0:t.axios)||(r==null?void 0:r.axios),i=(t==null?void 0:t.localStorageKey)||"user";if(!a)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const o=h.useCallback(({tokenType:f,accessToken:d})=>{a.defaults.headers.common.Authorization=`${f} ${d}`},[a.defaults.headers.common]),l=()=>{a.defaults.headers.common.Authorization=null};return h.useEffect(()=>{const f=({newValue:d,key:u})=>{if(u===i&&d)try{const{accessToken:E,tokenType:g}=JSON.parse(d);o({accessToken:E,tokenType:g})}catch(E){console.error("Failed to parse newValue from localStorage:",E)}};return window.addEventListener("storage",f),()=>{window.removeEventListener("storage",f)}},[i,o]),{clearAuthenticationToken:l,setAuthenticationToken:o}},ge=({library:t,date:r,format:a="ll"})=>t(r).format(a),he=(t,r="km")=>{const a=Number(t);return Number.isNaN(a)?`0 ${r}`:`${a.toFixed(2)} ${r}`},ye=t=>!t||typeof t!="string"?"":t.toLowerCase().replace(/_/g," ").split(" ").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" "),st=t=>t!=null&&t.startsWith("/")?t!=null&&t.startsWith("/files")?t:`/files${t}`:t!=null&&t.startsWith("files")?`/${t}`:`/files/${t}`,ut=({path:t,size:r,apiURL:a})=>{if(!t)return"";const i=st(t),o=`${a}${i}`,l=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&l?`${o.replace("/files",`/thumbs/${r}`)}`:o},lt=t=>{const{apiURL:r,libraries:a}=h.useContext(k),i=(t==null?void 0:t.dayjs)||(a==null?void 0:a.dayjs);return{dateAdapter:(f,d)=>{if(!i)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return ge({date:f,format:d,library:i})},distanceAdapter:he,filePathAdapter:(f,d)=>{if(!r)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return ut({apiURL:r,path:f,size:d})},worksiteNameAdapter:ye}},H=(t,r)=>r==="short"?t.split("-")[0]:t,ft=(t,r="full")=>{const[a,i]=h.useState(()=>{const o=(t==null?void 0:t.language)||navigator.language;return t&&"isInitialized"in t&&t.isInitialized,H(o,r)});return h.useEffect(()=>{var l;t&&"isInitialized"in t&&t.isInitialized&&t.language&&i(H(t.language,r));const o=f=>{i(H(f,r))};return(l=t==null?void 0:t.on)==null||l.call(t,"languageChanged",o),()=>{var f;(f=t==null?void 0:t.off)==null||f.call(t,"languageChanged",o)}},[t,r]),a},dt="tracktor.filter",me=(t,r,a)=>`${a}_${t}=>${r}`,vt=t=>{const{libraries:r,localStorageKeys:a}=h.useContext(k),i=(t==null?void 0:t.reactRouter)||(r==null?void 0:r.reactRouter),{useLocation:o,useSearchParams:l}=i,{pathname:f}=o(),[d,u]=l(),E=(a==null?void 0:a.filter)||dt;if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const g=(b,C,T=!0)=>{const y=me(b,(t==null?void 0:t.pathname)||f,E);if(!C||Array.isArray(C)&&!C.length){d.delete(b),u(d),localStorage.removeItem(y);return}T&&C&&localStorage.setItem(y,JSON.stringify({...d,[b]:C})),C&&(d.set(b,JSON.stringify(C)),u(d))};return{getFilter:(b,C)=>{const T=d.get(b);if(T)try{return JSON.parse(T)}catch{return T}const y=me(b,(t==null?void 0:t.pathname)||f,E),p=localStorage.getItem(y);if(p)try{return JSON.parse(p)[b]}catch{}return C},getFilters:()=>{const b=Object.fromEntries(d.entries()),T=Object.keys(localStorage).filter(y=>y.startsWith(E)&&y.endsWith((t==null?void 0:t.pathname)||f)).reduce((y,p)=>{var L,N;const D=localStorage.getItem(p);if(D){const Y=JSON.parse(D),x=(L=Object.keys(Y))==null?void 0:L[0];y[x]=(N=Object.values(Y))==null?void 0:N[0]}return y},{});return{...b,...T}},handleFilter:(b,C)=>(T,y)=>{if(y||Array.isArray(y)&&y.length===0){const p=C||"value",D=typeof y=="object"&&p in y?y[p||"value"]:y;g(b,D);return}g(b,void 0)},setFilter:g}},gt=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),ht=t=>{const i=t.split("/").filter(o=>o.length>0).map(o=>o.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return i.charAt(0).toLowerCase()+i.slice(1)},yt=t=>(t.split("/").pop()||t).replace(/\.json$/,"").replace(/^openapi\./,""),mt=(t,r,a)=>{const i=ht(r),o=gt(a);return`${i}${o}`},Et=t=>{if(t)return(t==null?void 0:t.reduce((r,a)=>(r[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}},r),{}))||{}},wt=t=>(Array.isArray(t)?t:[t]).reduce((a,i)=>{const{output:o,operationsToGenerateInfiniteQueryHook:l,input:f="./openapi.json"}=i||{},d=yt(f);return{...a,[d]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:f,output:{baseUrl:o==null?void 0:o.baseUrl,client:"react-query",mode:"tags-split",override:{...(l==null?void 0:l.length)&&{operations:Et(l)},header:u=>["Generated by orval 🍺",...u.title?[u.title]:[],...u.description?[u.description]:[]],mutator:{name:"axiosCustomInstance",path:`${__dirname}/axiosCustomInstance.ts`},operationName:mt,query:{useQuery:!0}},schemas:(o==null?void 0:o.schemas)||`src/api/${d}/model`,target:(o==null?void 0:o.target)||`src/api/${d}/services/api.ts`,...o}}}},{});_.GTMSendPageView=Ke,_.InitializeAxiosConfig=He,_.InitializeDaysJSConfig=et,_.InitializeI18nConfig=Xe,_.InitializeMapBoxConfig=qe,_.InitializeSentryConfig=Ze,_.InjectDependenciesContext=k,_.InjectDependenciesProvider=Ge,_.MaskTextField=$e,_.PreloadErrorHandler=tt,_.QueryClientProviderWithConfig=at,_.RequireAuth=Be,_.dateAdapter=ge,_.distanceAdapter=he,_.getOrvalConfig=wt,_.useAdapter=lt,_.useAuth=ct,_.useCurrentLanguage=ft,_.useFilters=vt,_.useInfiniteDataGrid=it,_.useResponseError=ot,_.worksiteNameAdapter=ye,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
interface FilePathAdapterParams {
|
|
2
|
-
path?: string | null;
|
|
3
|
-
size?: number | "full";
|
|
4
|
-
apiURL: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Adapt file path from server to display file on client
|
|
8
|
-
* @param location
|
|
9
|
-
* @param size - full or number for thumbs
|
|
10
|
-
* @param apiURL
|
|
11
|
-
*/
|
|
12
|
-
declare const filePathAdapter: ({ path, size, apiURL }: FilePathAdapterParams) => string;
|
|
13
|
-
export default filePathAdapter;
|