@tracktor/shared-module 2.15.9 → 2.15.11
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 +1 -1
- package/dist/axios/index.d.ts +1 -0
- package/dist/axios.cjs +1 -0
- package/dist/axios.js +4 -0
- package/dist/axiosCustomInstance-D3EHo-4p.cjs +1 -0
- package/dist/axiosCustomInstance-DCYX8iR2.js +14 -0
- package/dist/main.cjs +22 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +78 -76
- package/package.json +6 -6
- package/dist/main.umd.cjs +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { axiosCustomInstance, type ErrorType, type BodyType } from './axiosCustomInstance';
|
package/dist/axios.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./axiosCustomInstance-D3EHo-4p.cjs");exports.axiosCustomInstance=t.axiosCustomInstance;
|
package/dist/axios.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("axios"),a=(s,o)=>{const e=n.CancelToken.source(),c=n({...s,...o,cancelToken:e.token}).then(({data:t})=>t);return c.cancel=()=>{e.cancel("Query was cancelled")},c};exports.axiosCustomInstance=a;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import n from "axios";
|
|
2
|
+
const r = (o, s) => {
|
|
3
|
+
const e = n.CancelToken.source(), c = n({
|
|
4
|
+
...o,
|
|
5
|
+
...s,
|
|
6
|
+
cancelToken: e.token
|
|
7
|
+
}).then(({ data: a }) => a);
|
|
8
|
+
return c.cancel = () => {
|
|
9
|
+
e.cancel("Query was cancelled");
|
|
10
|
+
}, c;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
r as a
|
|
14
|
+
};
|
package/dist/main.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";var de=Object.create;var B=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty;var ye=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of pe(r))!me.call(e,n)&&n!==o&&B(e,n,{get:()=>r[n],enumerable:!(a=fe(r,n))||a.enumerable});return e};var X=(e,r,o)=>(o=e!=null?de(ge(e)):{},ye(r||!e||!e.__esModule?B(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const he=require("./axiosCustomInstance-D3EHo-4p.cjs"),g=require("react");var N={exports:{}},I={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and 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 H;function ve(){if(H)return I;H=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(a,n,s){var c=null;if(s!==void 0&&(c=""+s),n.key!==void 0&&(c=""+n.key),"key"in n){s={};for(var u in n)u!=="key"&&(s[u]=n[u])}else s=n;return n=s.ref,{$$typeof:e,type:a,key:c,ref:n!==void 0?n:null,props:s}}return I.Fragment=r,I.jsx=o,I.jsxs=o,I}var k={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and 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 Z;function Ee(){return Z||(Z=1,process.env.NODE_ENV!=="production"&&function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===ce?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case p:return"Fragment";case A:return"Profiler";case S:return"StrictMode";case M:return"Suspense";case ae:return"SuspenseList";case ie:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case R:return"Portal";case E:return(t.displayName||"Context")+".Provider";case T:return(t._context.displayName||"Context")+".Consumer";case U:var f=t.render;return t=t.displayName,t||(t=f.displayName||f.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case se:return f=t.displayName||null,f!==null?f:e(t.type)||"Memo";case W:f=t._payload,t=t._init;try{return e(t(f))}catch{}}return null}function r(t){return""+t}function o(t){try{r(t);var f=!1}catch{f=!0}if(f){f=console;var h=f.error,w=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return h.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",w),r(t)}}function a(t){if(t===p)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===W)return"<...>";try{var f=e(t);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function n(){var t=F.A;return t===null?null:t.getOwner()}function s(){return Error("react-stack-top-frame")}function c(t){if(Q.call(t,"key")){var f=Object.getOwnPropertyDescriptor(t,"key").get;if(f&&f.isReactWarning)return!1}return t.key!==void 0}function u(t,f){function h(){V||(V=!0,console.error("%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://react.dev/link/special-props)",f))}h.isReactWarning=!0,Object.defineProperty(t,"key",{get:h,configurable:!0})}function l(){var t=e(this.type);return G[t]||(G[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function d(t,f,h,w,P,j,$,Y){return h=j.ref,t={$$typeof:y,type:t,key:f,props:j,_owner:P},(h!==void 0?h:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:l}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:$}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function i(t,f,h,w,P,j,$,Y){var b=f.children;if(b!==void 0)if(w)if(ue(b)){for(w=0;w<b.length;w++)v(b[w]);Object.freeze&&Object.freeze(b)}else console.error("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 v(b);if(Q.call(f,"key")){b=e(t);var x=Object.keys(f).filter(function(le){return le!=="key"});w=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",K[b+w]||(x=0<x.length?"{"+x.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,w,b,x,b),K[b+w]=!0)}if(b=null,h!==void 0&&(o(h),b=""+h),c(f)&&(o(f.key),b=""+f.key),"key"in f){h={};for(var z in f)z!=="key"&&(h[z]=f[z])}else h=f;return b&&u(h,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,b,j,P,n(),h,$,Y)}function v(t){typeof t=="object"&&t!==null&&t.$$typeof===y&&t._store&&(t._store.validated=1)}var m=g,y=Symbol.for("react.transitional.element"),R=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),E=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),F=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=Object.prototype.hasOwnProperty,ue=Array.isArray,D=console.createTask?console.createTask:function(){return null};m={"react-stack-bottom-frame":function(t){return t()}};var V,G={},J=m["react-stack-bottom-frame"].bind(m,s)(),q=D(a(s)),K={};k.Fragment=p,k.jsx=function(t,f,h,w,P){var j=1e4>F.recentlyCreatedOwnerStacks++;return i(t,f,h,!1,w,P,j?Error("react-stack-top-frame"):J,j?D(a(t)):q)},k.jsxs=function(t,f,h,w,P){var j=1e4>F.recentlyCreatedOwnerStacks++;return i(t,f,h,!0,w,P,j?Error("react-stack-top-frame"):J,j?D(a(t)):q)}}()),k}var ee;function we(){return ee||(ee=1,process.env.NODE_ENV==="production"?N.exports=ve():N.exports=Ee()),N.exports}var _=we();const C=g.createContext({}),be=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=g.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return _.jsx(C.Provider,{value:n,children:e})},Re="user",Se=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:s,localStorageKeys:c}=g.useContext(C),u=n?.reactRouter||s?.reactRouter,l=n?.axios||s?.axios,d=n?.localStorageKey||c?.user||Re;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,v]=g.useState(null),{useLocation:m,Navigate:y,Outlet:R}=u,p=m(),S=g.useRef(!1),A=typeof r=="function"?r():!!r,T=typeof A=="boolean"?A:A?.isLogged;return g.useEffect(()=>{S.current||(S.current=!0,l.interceptors.response.use(E=>E,async E=>(typeof E=="object"&&E&&"response"in E&&E.response&&typeof E.response=="object"&&"status"in E.response&&E.response&&typeof E.response=="object"&&"status"in E.response&&E?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),v(a)),Promise.reject(E))))},[l.defaults.headers.common,l.interceptors.response,d,a]),T&&!i?_.jsx(g.Suspense,{fallback:e,children:p.state?.from?.state&&p.state?.from?.pathname===o?_.jsx(y,{to:p.state.from.state.from.pathname+p.state.from.state.from.search,replace:!0}):_.jsx(R,{})}):_.jsx(y,{to:o+p.search,state:{from:p},replace:!0})},Ae=({data:e,...r})=>{const{libraries:o}=g.useContext(C),a=r?.reactRouter||o?.reactRouter,n=r?.gtm||o?.gtm;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!n)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:s}=n,{useLocation:c,Outlet:u}=a,{pathname:l}=c(),{sendEvent:d}=s();return g.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),_.jsx(u,{})},O=(()=>{try{return typeof global=="object"&&global!==null&&("HermesInternal"in global||"__fbBatchedBridge"in global||"__metro"in global)||typeof window>"u"&&typeof global<"u"?!0:typeof navigator<"u"&&navigator.userAgent?/react.native|ReactNative/i.test(navigator.userAgent):!1}catch{return!1}})(),Ce="user",je=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:s,localStorageKeys:c}=g.useContext(C),u=a?.userLocalStorageKey||c?.user||Ce,l=a?.axios||s?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||O)return null;if(typeof window<"u"&&window.localStorage){const d=localStorage.getItem(u),i=d?JSON.parse(d):null,v=i?.[e]?i[e]:null,m=i?.[r]?i[r]:null,y=d?`${v} ${m}`:null;y&&(l.defaults.headers.common.Authorization=y)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=o,null},_e=({debug:e,resources:r,...o})=>{const{libraries:a}=g.useContext(C),n=o?.i18||a?.i18,{i18next:s,initReactI18next:c,languageDetector:u}=n||{};if(O)return null;if(!n)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return s?.isInitialized||(s.use(u).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:r,returnNull:!1}).then(()=>{document.documentElement.lang!==s.resolvedLanguage&&s.resolvedLanguage&&document.documentElement.setAttribute("lang",s.resolvedLanguage)}),s.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},Pe=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:s,ignoreErrors:c,debug:u,environment:l,release:d,...i})=>{const{libraries:v}=g.useContext(C),m=i?.sentry||v?.sentry,y=i?.reactRouter||v?.reactRouter;if(!m)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!y)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(m.isInitialized())return null;const{createRoutesFromChildren:R,matchRoutes:p,useLocation:S,useNavigationType:A}=y;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&m.init({debug:u,dsn:e,environment:l||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[m.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:R,matchRoutes:p,useEffect:g.useEffect,useLocation:S,useNavigationType:A}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:s,tracesSampleRate:o||1}),null},Te=({IMaskMixin:e,...r})=>{const o=g.useMemo(()=>e(({TextField:a,...n})=>_.jsx(a,{...n})),[e]);return _.jsx(o,{...r})},xe=({language:e,...r})=>{const{libraries:o}=g.useContext(C),a=r?.dayjs||o?.dayjs,n=r?.plugin||o?.dayjsPlugin;if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return g.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";n&&n.forEach(u=>{u&&a.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,n,e]),null},Ie=()=>(g.useEffect(()=>{if(O)return;const e=r=>{try{r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),ke=e=>e&&typeof e=="function",Oe=e=>e&&typeof e=="function",Ne=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=g.useContext(C),s=a?.QueryClient||n?.reactQuery?.QueryClient,c=a?.QueryClientProvider||n?.reactQuery?.QueryClientProvider;if(!s)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!ke(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Oe(s))throw new Error("Provided QueryClient dependencies are not valid.");const u=new s({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,d,i)=>l.length+(i||0),refetchOnWindowFocus:!1,retry:3,...r}}});return _.jsx(c,{client:u,children:e})},Le=e=>{const{libraries:r}=g.useContext(C),o=e?.i18||r?.i18,a=e?.i18?.translateFunction||r?.i18?.translateFunction,n=o?.i18next?.t||a||(d=>d),{unknownErrorTranslationKey:s="error.unknownError"}=e||{},c=n(s),u=g.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:i}=d||{};if(i&&typeof i=="object"&&"reason"in i)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:v}=i.data;if(Array.isArray(v)&&v.length>0&&typeof v[0]=="object"&&v[0]!==null&&"msg"in v[0]){const{msg:m}=v[0];if(typeof m=="string")return String(m)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:g.useCallback(d=>{const{response:i}=d||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:u}},Fe=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:s=!0})=>{const c=g.useCallback(async l=>{o||!s||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[s,r,o]),u=g.useMemo(()=>{if(e)return e.pages.reduce((l,d)=>[...l,...d],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||n,loadingVariant:a?"skeleton":"linear-progress",rows:u}},De=e=>{const{libraries:r}=g.useContext(C),o=e?.axios||r?.axios,a=e?.localStorageKey||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const n=g.useCallback(({tokenType:c,accessToken:u})=>{o.defaults.headers.common.Authorization=`${c} ${u}`},[o.defaults.headers.common]),s=()=>{o.defaults.headers.common.Authorization=null};return g.useEffect(()=>{if(O)return;const c=({newValue:u,key:l})=>{if(l===a&&u)try{const{accessToken:d,tokenType:i}=JSON.parse(u);n({accessToken:d,tokenType:i})}catch(d){console.error("Failed to parse newValue from localStorage:",d)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,n]),{clearAuthenticationToken:s,setAuthenticationToken:n}},re=({library:e,date:r,format:o="ll"})=>e(r).format(o),ne=(e,r)=>{const{fractionDigits:o=0,metric:a="km"}=r||{},n=Number(e);return Number.isNaN(n)?`0${a}`:`${n.toFixed(o)}${a}`},oe=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),$e=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ye=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=$e(e),n=`${o}${a}`,s=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&s?`${n.replace("/files",`/thumbs/${r}`)}`:n},ze=e=>{const{apiURL:r,libraries:o}=g.useContext(C),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,u)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return re({date:c,format:u,library:a})},distanceAdapter:ne,filePathAdapter:(c,u)=>{if(!r)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return typeof c=="string"&&/^https?:\/\//.test(c)?c:Ye({apiURL:r,path:c,size:u})},worksiteNameAdapter:oe}},L=(e,r)=>r==="short"?e.split("-")[0]:e,Ue=(e,r="full")=>{const[o,a]=g.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,L(n,r)});return g.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(L(e.language,r));const n=s=>{a(L(s,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Me="tracktor.filter",We={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},te=(e,r,o)=>`${o}_${e}=>${r}`,Qe=e=>{const{libraries:r,localStorageKeys:o}=g.useContext(C),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[s,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],u=o?.filter||Me;if(O)return We;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const l=(m,y,R=!0)=>{const p=te(m,e?.pathname||n,u);if(!y||Array.isArray(y)&&!y.length){s.delete(m),c(s),localStorage.removeItem(p);return}R&&y&&localStorage.setItem(p,JSON.stringify({...s,[m]:y})),y&&(s.set(m,JSON.stringify(y)),c(s))};return{getFilter:(m,y)=>{const R=s.get(m);if(R)try{return JSON.parse(R)}catch{return R}const p=te(m,e?.pathname||n,u),S=localStorage.getItem(p);if(S)try{return JSON.parse(S)[m]}catch{}return y},getFilters:()=>{const m=Object.fromEntries(s.entries()),R=Object.keys(localStorage).filter(p=>p.startsWith(u)&&p.endsWith(e?.pathname||n)).reduce((p,S)=>{const A=localStorage.getItem(S);if(A){const T=JSON.parse(A),E=Object.keys(T)?.[0];p[E]=Object.values(T)?.[0]}return p},{});return{...m,...R}},handleFilter:(m,y)=>(R,p)=>{if(p||Array.isArray(p)&&p.length===0){const S=y||"value",A=typeof p=="object"&&S in p?p[S]:p;l(m,A);return}l(m,void 0)},setFilter:l}},Ve=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Ge=e=>{const a=e.split("/").filter(n=>n.length>0).map(n=>n.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},Je=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),qe=(e,r,o,a)=>{const n=Ge(r),s=Ve(o),c=`${n}${s}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Ke=(e,r)=>{const o={};return e?.forEach(a=>{o[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),r?.filter(a=>!o[a]).forEach(a=>{o[a]={query:{useQuery:!0}}}),Object.keys(o).length?o:void 0},Be=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:s,useQueryIds:c,input:u="./openapi.json"}=a||{},l=Je(u);return{...o,[l]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(s?.length||c?.length)&&{operations:Ke(s,c)},header:d=>["Generated by orval 🍺",...d.title?[d.title]:[],...d.description?[d.description]:[]],mutator:{name:"axiosCustomInstance",path:"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"},operationName:(d,i,v)=>qe(d,i,v,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${l}/model`,target:n?.target||`src/api/${l}/services/api.ts`,...n}}}},{});exports.axiosCustomInstance=he.axiosCustomInstance;exports.GTMSendPageView=Ae;exports.InitializeAxiosConfig=je;exports.InitializeDaysJSConfig=xe;exports.InitializeI18nConfig=_e;exports.InitializeSentryConfig=Pe;exports.InjectDependenciesContext=C;exports.InjectDependenciesProvider=be;exports.MaskTextField=Te;exports.PreloadErrorHandler=Ie;exports.QueryClientProviderWithConfig=Ne;exports.RequireAuth=Se;exports.dateAdapter=re;exports.distanceAdapter=ne;exports.getOrvalConfig=Be;exports.useAdapter=ze;exports.useAuth=De;exports.useCurrentLanguage=Ue;exports.useFilters=Qe;exports.useInfiniteDataGrid=Fe;exports.useResponseError=Le;exports.worksiteNameAdapter=oe;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { axiosCustomInstance, type ErrorType, type BodyType } from './axios/axiosCustomInstance';
|
|
1
2
|
export { default as RequireAuth } from './components/Utils/RequireAuth';
|
|
2
3
|
export * from './components/Utils/RequireAuth';
|
|
3
4
|
export { default as GTMSendPageView } from './components/Utils/GTMSendPageView';
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { a as Ze } from "./axiosCustomInstance-DCYX8iR2.js";
|
|
1
2
|
import le, { createContext as de, useMemo as Q, useContext as j, useState as ne, useRef as fe, useEffect as C, Suspense as pe, useCallback as $ } from "react";
|
|
2
|
-
var L = { exports: {} },
|
|
3
|
+
var L = { exports: {} }, k = {};
|
|
3
4
|
/**
|
|
4
5
|
* @license React
|
|
5
6
|
* react-jsx-runtime.production.js
|
|
@@ -11,25 +12,25 @@ var L = { exports: {} }, x = {};
|
|
|
11
12
|
*/
|
|
12
13
|
var Z;
|
|
13
14
|
function ge() {
|
|
14
|
-
if (Z) return
|
|
15
|
+
if (Z) return k;
|
|
15
16
|
Z = 1;
|
|
16
17
|
var e = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
17
|
-
function o(a, r,
|
|
18
|
+
function o(a, r, s) {
|
|
18
19
|
var c = null;
|
|
19
|
-
if (
|
|
20
|
-
|
|
20
|
+
if (s !== void 0 && (c = "" + s), r.key !== void 0 && (c = "" + r.key), "key" in r) {
|
|
21
|
+
s = {};
|
|
21
22
|
for (var u in r)
|
|
22
|
-
u !== "key" && (
|
|
23
|
-
} else
|
|
24
|
-
return r =
|
|
23
|
+
u !== "key" && (s[u] = r[u]);
|
|
24
|
+
} else s = r;
|
|
25
|
+
return r = s.ref, {
|
|
25
26
|
$$typeof: e,
|
|
26
27
|
type: a,
|
|
27
28
|
key: c,
|
|
28
29
|
ref: r !== void 0 ? r : null,
|
|
29
|
-
props:
|
|
30
|
+
props: s
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
return
|
|
33
|
+
return k.Fragment = n, k.jsx = o, k.jsxs = o, k;
|
|
33
34
|
}
|
|
34
35
|
var I = {};
|
|
35
36
|
/**
|
|
@@ -47,7 +48,7 @@ function me() {
|
|
|
47
48
|
function e(t) {
|
|
48
49
|
if (t == null) return null;
|
|
49
50
|
if (typeof t == "function")
|
|
50
|
-
return t.$$typeof ===
|
|
51
|
+
return t.$$typeof === ie ? null : t.displayName || t.name || null;
|
|
51
52
|
if (typeof t == "string") return t;
|
|
52
53
|
switch (t) {
|
|
53
54
|
case p:
|
|
@@ -60,7 +61,7 @@ function me() {
|
|
|
60
61
|
return "Suspense";
|
|
61
62
|
case oe:
|
|
62
63
|
return "SuspenseList";
|
|
63
|
-
case
|
|
64
|
+
case se:
|
|
64
65
|
return "Activity";
|
|
65
66
|
}
|
|
66
67
|
if (typeof t == "object")
|
|
@@ -122,7 +123,7 @@ function me() {
|
|
|
122
123
|
var t = D.A;
|
|
123
124
|
return t === null ? null : t.getOwner();
|
|
124
125
|
}
|
|
125
|
-
function
|
|
126
|
+
function s() {
|
|
126
127
|
return Error("react-stack-top-frame");
|
|
127
128
|
}
|
|
128
129
|
function c(t) {
|
|
@@ -182,7 +183,7 @@ function me() {
|
|
|
182
183
|
value: U
|
|
183
184
|
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
+
function i(t, f, y, E, T, _, z, U) {
|
|
186
187
|
var w = f.children;
|
|
187
188
|
if (w !== void 0)
|
|
188
189
|
if (E)
|
|
@@ -197,10 +198,10 @@ function me() {
|
|
|
197
198
|
else h(w);
|
|
198
199
|
if (J.call(f, "key")) {
|
|
199
200
|
w = e(t);
|
|
200
|
-
var
|
|
201
|
+
var x = Object.keys(f).filter(function(ue) {
|
|
201
202
|
return ue !== "key";
|
|
202
203
|
});
|
|
203
|
-
E = 0 <
|
|
204
|
+
E = 0 < x.length ? "{key: someKey, " + x.join(": ..., ") + ": ...}" : "{key: someKey}", H[w + E] || (x = 0 < x.length ? "{" + x.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
205
|
`A props object containing a "key" prop is being spread into JSX:
|
|
205
206
|
let props = %s;
|
|
206
207
|
<%s {...props} />
|
|
@@ -209,7 +210,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
209
210
|
<%s key={someKey} {...props} />`,
|
|
210
211
|
E,
|
|
211
212
|
w,
|
|
212
|
-
|
|
213
|
+
x,
|
|
213
214
|
w
|
|
214
215
|
), H[w + E] = !0);
|
|
215
216
|
}
|
|
@@ -235,7 +236,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
235
236
|
function h(t) {
|
|
236
237
|
typeof t == "object" && t !== null && t.$$typeof === m && t._store && (t._store.validated = 1);
|
|
237
238
|
}
|
|
238
|
-
var g = le, m = Symbol.for("react.transitional.element"), b = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), R = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), O = Symbol.for("react.consumer"), v = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), M = Symbol.for("react.suspense"), oe = Symbol.for("react.suspense_list"), ae = Symbol.for("react.memo"), G = Symbol.for("react.lazy"),
|
|
239
|
+
var g = le, m = Symbol.for("react.transitional.element"), b = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), R = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), O = Symbol.for("react.consumer"), v = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), M = Symbol.for("react.suspense"), oe = Symbol.for("react.suspense_list"), ae = Symbol.for("react.memo"), G = Symbol.for("react.lazy"), se = Symbol.for("react.activity"), ie = Symbol.for("react.client.reference"), D = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ce = Array.isArray, Y = console.createTask ? console.createTask : function() {
|
|
239
240
|
return null;
|
|
240
241
|
};
|
|
241
242
|
g = {
|
|
@@ -245,11 +246,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
245
246
|
};
|
|
246
247
|
var K, q = {}, B = g["react-stack-bottom-frame"].bind(
|
|
247
248
|
g,
|
|
248
|
-
|
|
249
|
-
)(), X = Y(a(
|
|
249
|
+
s
|
|
250
|
+
)(), X = Y(a(s)), H = {};
|
|
250
251
|
I.Fragment = p, I.jsx = function(t, f, y, E, T) {
|
|
251
252
|
var _ = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
252
|
-
return
|
|
253
|
+
return i(
|
|
253
254
|
t,
|
|
254
255
|
f,
|
|
255
256
|
y,
|
|
@@ -261,7 +262,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
261
262
|
);
|
|
262
263
|
}, I.jsxs = function(t, f, y, E, T) {
|
|
263
264
|
var _ = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
264
|
-
return
|
|
265
|
+
return i(
|
|
265
266
|
t,
|
|
266
267
|
f,
|
|
267
268
|
y,
|
|
@@ -290,16 +291,16 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
290
291
|
);
|
|
291
292
|
return /* @__PURE__ */ P.jsx(A.Provider, { value: r, children: e });
|
|
292
293
|
}, he = "user", Le = ({ Fallback: e, isLogged: n, loginPath: o = "/login", redirect401Path: a = "/login", ...r }) => {
|
|
293
|
-
const { libraries:
|
|
294
|
+
const { libraries: s, localStorageKeys: c } = j(A), u = r?.reactRouter || s?.reactRouter, l = r?.axios || s?.axios, d = r?.localStorageKey || c?.user || he;
|
|
294
295
|
if (!u)
|
|
295
296
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
296
|
-
const [
|
|
297
|
+
const [i, h] = ne(null), { useLocation: g, Navigate: m, Outlet: b } = u, p = g(), R = fe(!1), S = typeof n == "function" ? n() : !!n, O = typeof S == "boolean" ? S : S?.isLogged;
|
|
297
298
|
return C(() => {
|
|
298
299
|
R.current || (R.current = !0, l.interceptors.response.use(
|
|
299
300
|
(v) => v,
|
|
300
301
|
async (v) => (typeof v == "object" && v && "response" in v && v.response && typeof v.response == "object" && "status" in v.response && v.response && typeof v.response == "object" && "status" in v.response && v?.response?.status === 401 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(d), h(a)), Promise.reject(v))
|
|
301
302
|
));
|
|
302
|
-
}, [l.defaults.headers.common, l.interceptors.response, d, a]), O && !
|
|
303
|
+
}, [l.defaults.headers.common, l.interceptors.response, d, a]), O && !i ? /* @__PURE__ */ P.jsx(pe, { fallback: e, children: p.state?.from?.state && p.state?.from?.pathname === o ? /* @__PURE__ */ P.jsx(m, { to: p.state.from.state.from.pathname + p.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ P.jsx(b, {}) }) : /* @__PURE__ */ P.jsx(m, { to: o + p.search, state: { from: p }, replace: !0 });
|
|
303
304
|
}, Fe = ({ data: e, ...n }) => {
|
|
304
305
|
const { libraries: o } = j(A), a = n?.reactRouter || o?.reactRouter, r = n?.gtm || o?.gtm;
|
|
305
306
|
if (!a)
|
|
@@ -308,7 +309,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
308
309
|
);
|
|
309
310
|
if (!r)
|
|
310
311
|
throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
|
|
311
|
-
const { useGoogleTagManager:
|
|
312
|
+
const { useGoogleTagManager: s } = r, { useLocation: c, Outlet: u } = a, { pathname: l } = c(), { sendEvent: d } = s();
|
|
312
313
|
return C(() => {
|
|
313
314
|
d({
|
|
314
315
|
event: "pageView",
|
|
@@ -330,23 +331,23 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
330
331
|
postContentType: o = "application/json",
|
|
331
332
|
...a
|
|
332
333
|
}) => {
|
|
333
|
-
const { apiURL: r = a.apiURL, libraries:
|
|
334
|
+
const { apiURL: r = a.apiURL, libraries: s, localStorageKeys: c } = j(A), u = a?.userLocalStorageKey || c?.user || ve, l = a?.axios || s?.axios;
|
|
334
335
|
if (!l)
|
|
335
336
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
336
337
|
if (!l?.defaults || N)
|
|
337
338
|
return null;
|
|
338
339
|
if (typeof window < "u" && window.localStorage) {
|
|
339
|
-
const d = localStorage.getItem(u),
|
|
340
|
+
const d = localStorage.getItem(u), i = d ? JSON.parse(d) : null, h = i?.[e] ? i[e] : null, g = i?.[n] ? i[n] : null, m = d ? `${h} ${g}` : null;
|
|
340
341
|
m && (l.defaults.headers.common.Authorization = m);
|
|
341
342
|
}
|
|
342
343
|
return l.defaults.baseURL = r, l.defaults.headers.post["Content-Type"] = o, null;
|
|
343
344
|
}, De = ({ debug: e, resources: n, ...o }) => {
|
|
344
|
-
const { libraries: a } = j(A), r = o?.i18 || a?.i18, { i18next:
|
|
345
|
+
const { libraries: a } = j(A), r = o?.i18 || a?.i18, { i18next: s, initReactI18next: c, languageDetector: u } = r || {};
|
|
345
346
|
if (N)
|
|
346
347
|
return null;
|
|
347
348
|
if (!r)
|
|
348
349
|
throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
349
|
-
return
|
|
350
|
+
return s?.isInitialized || (s.use(u).use(c).init({
|
|
350
351
|
debug: e,
|
|
351
352
|
fallbackLng: "en",
|
|
352
353
|
interpolation: {
|
|
@@ -360,8 +361,8 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
360
361
|
resources: n,
|
|
361
362
|
returnNull: !1
|
|
362
363
|
}).then(() => {
|
|
363
|
-
document.documentElement.lang !==
|
|
364
|
-
}),
|
|
364
|
+
document.documentElement.lang !== s.resolvedLanguage && s.resolvedLanguage && document.documentElement.setAttribute("lang", s.resolvedLanguage);
|
|
365
|
+
}), s.on("languageChanged", (l) => {
|
|
365
366
|
document.documentElement.setAttribute("lang", l);
|
|
366
367
|
})), null;
|
|
367
368
|
}, Ye = ({
|
|
@@ -370,14 +371,14 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
370
371
|
tracesSampleRate: o,
|
|
371
372
|
replaysSessionSampleRate: a,
|
|
372
373
|
replaysOnErrorSampleRate: r,
|
|
373
|
-
tracePropagationTargets:
|
|
374
|
+
tracePropagationTargets: s,
|
|
374
375
|
ignoreErrors: c,
|
|
375
376
|
debug: u,
|
|
376
377
|
environment: l,
|
|
377
378
|
release: d,
|
|
378
|
-
...
|
|
379
|
+
...i
|
|
379
380
|
}) => {
|
|
380
|
-
const { libraries: h } = j(A), g =
|
|
381
|
+
const { libraries: h } = j(A), g = i?.sentry || h?.sentry, m = i?.reactRouter || h?.reactRouter;
|
|
381
382
|
if (!g)
|
|
382
383
|
throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
383
384
|
if (!m)
|
|
@@ -411,7 +412,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
411
412
|
release: d,
|
|
412
413
|
replaysOnErrorSampleRate: r || 1,
|
|
413
414
|
replaysSessionSampleRate: a || 0.1,
|
|
414
|
-
tracePropagationTargets:
|
|
415
|
+
tracePropagationTargets: s,
|
|
415
416
|
tracesSampleRate: o || 1
|
|
416
417
|
}), null;
|
|
417
418
|
}, ze = ({ IMaskMixin: e, ...n }) => {
|
|
@@ -453,22 +454,22 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
453
454
|
defaultMutationsOptions: o,
|
|
454
455
|
...a
|
|
455
456
|
}) => {
|
|
456
|
-
const { libraries: r } = j(A),
|
|
457
|
-
if (!
|
|
457
|
+
const { libraries: r } = j(A), s = a?.QueryClient || r?.reactQuery?.QueryClient, c = a?.QueryClientProvider || r?.reactQuery?.QueryClientProvider;
|
|
458
|
+
if (!s)
|
|
458
459
|
throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
459
460
|
if (!c)
|
|
460
461
|
throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
461
462
|
if (!Ee(c))
|
|
462
463
|
throw new Error("Provided QueryClientProvider dependencies are not valid.");
|
|
463
|
-
if (!we(
|
|
464
|
+
if (!we(s))
|
|
464
465
|
throw new Error("Provided QueryClient dependencies are not valid.");
|
|
465
|
-
const u = new
|
|
466
|
+
const u = new s({
|
|
466
467
|
defaultOptions: {
|
|
467
468
|
mutations: {
|
|
468
469
|
...o
|
|
469
470
|
},
|
|
470
471
|
queries: {
|
|
471
|
-
getNextPageParam: (l, d,
|
|
472
|
+
getNextPageParam: (l, d, i) => l.length + (i || 0),
|
|
472
473
|
refetchOnWindowFocus: !1,
|
|
473
474
|
retry: 3,
|
|
474
475
|
...n
|
|
@@ -477,18 +478,18 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
477
478
|
});
|
|
478
479
|
return /* @__PURE__ */ P.jsx(c, { client: u, children: e });
|
|
479
480
|
}, Ve = (e) => {
|
|
480
|
-
const { libraries: n } = j(A), o = e?.i18 || n?.i18, a = e?.i18?.translateFunction || n?.i18?.translateFunction, r = o?.i18next?.t || a || ((d) => d), { unknownErrorTranslationKey:
|
|
481
|
+
const { libraries: n } = j(A), o = e?.i18 || n?.i18, a = e?.i18?.translateFunction || n?.i18?.translateFunction, r = o?.i18next?.t || a || ((d) => d), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = r(s), u = $(
|
|
481
482
|
(d) => {
|
|
482
483
|
if (d && typeof d == "object" && "response" in d) {
|
|
483
|
-
const { response:
|
|
484
|
-
if (
|
|
485
|
-
return String(
|
|
486
|
-
if (
|
|
487
|
-
return String(
|
|
488
|
-
if (
|
|
489
|
-
return String(
|
|
490
|
-
if (
|
|
491
|
-
const { detail: h } =
|
|
484
|
+
const { response: i } = d || {};
|
|
485
|
+
if (i && typeof i == "object" && "reason" in i)
|
|
486
|
+
return String(i.reason);
|
|
487
|
+
if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "reason" in i.data)
|
|
488
|
+
return String(i.data.reason);
|
|
489
|
+
if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "message" in i.data)
|
|
490
|
+
return String(i.data.message);
|
|
491
|
+
if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "detail" in i.data) {
|
|
492
|
+
const { detail: h } = i.data;
|
|
492
493
|
if (Array.isArray(h) && h.length > 0 && typeof h[0] == "object" && h[0] !== null && "msg" in h[0]) {
|
|
493
494
|
const { msg: g } = h[0];
|
|
494
495
|
if (typeof g == "string")
|
|
@@ -501,8 +502,8 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
501
502
|
[c]
|
|
502
503
|
);
|
|
503
504
|
return { getErrorCode: $((d) => {
|
|
504
|
-
const { response:
|
|
505
|
-
return
|
|
505
|
+
const { response: i } = d || {};
|
|
506
|
+
return i?.error_code ? String(i?.error_code) : i?.data?.error_code ? String(i?.data?.error_code) : i?.error_code ? String(i?.error_code) : i?.data?.error_code ? String(i.data.error_code) : "unknown_error_code";
|
|
506
507
|
}, []), printError: u };
|
|
507
508
|
}, Me = ({
|
|
508
509
|
data: e,
|
|
@@ -510,13 +511,13 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
510
511
|
isFetchingNextPage: o,
|
|
511
512
|
isInitialLoading: a,
|
|
512
513
|
isLoading: r,
|
|
513
|
-
enabled:
|
|
514
|
+
enabled: s = !0
|
|
514
515
|
}) => {
|
|
515
516
|
const c = $(
|
|
516
517
|
async (l) => {
|
|
517
|
-
o || !
|
|
518
|
+
o || !s || await n({ pageParam: l?.pageParam || l.visibleRowsCount });
|
|
518
519
|
},
|
|
519
|
-
[
|
|
520
|
+
[s, n, o]
|
|
520
521
|
), u = Q(() => {
|
|
521
522
|
if (e)
|
|
522
523
|
return e.pages.reduce((l, d) => [...l, ...d], []);
|
|
@@ -536,7 +537,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
536
537
|
o.defaults.headers.common.Authorization = `${c} ${u}`;
|
|
537
538
|
},
|
|
538
539
|
[o.defaults.headers.common]
|
|
539
|
-
),
|
|
540
|
+
), s = () => {
|
|
540
541
|
o.defaults.headers.common.Authorization = null;
|
|
541
542
|
};
|
|
542
543
|
return C(() => {
|
|
@@ -545,8 +546,8 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
545
546
|
const c = ({ newValue: u, key: l }) => {
|
|
546
547
|
if (l === a && u)
|
|
547
548
|
try {
|
|
548
|
-
const { accessToken: d, tokenType:
|
|
549
|
-
r({ accessToken: d, tokenType:
|
|
549
|
+
const { accessToken: d, tokenType: i } = JSON.parse(u);
|
|
550
|
+
r({ accessToken: d, tokenType: i });
|
|
550
551
|
} catch (d) {
|
|
551
552
|
console.error("Failed to parse newValue from localStorage:", d);
|
|
552
553
|
}
|
|
@@ -555,7 +556,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
555
556
|
window.removeEventListener("storage", c);
|
|
556
557
|
};
|
|
557
558
|
}, [a, r]), {
|
|
558
|
-
clearAuthenticationToken:
|
|
559
|
+
clearAuthenticationToken: s,
|
|
559
560
|
setAuthenticationToken: r
|
|
560
561
|
};
|
|
561
562
|
}, be = ({ library: e, date: n, format: o = "ll" }) => e(n).format(o), Re = (e, n) => {
|
|
@@ -564,8 +565,8 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
564
565
|
}, Se = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "), Ae = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, je = ({ path: e, size: n, apiURL: o }) => {
|
|
565
566
|
if (!e)
|
|
566
567
|
return "";
|
|
567
|
-
const a = Ae(e), r = `${o}${a}`,
|
|
568
|
-
return typeof n == "number" &&
|
|
568
|
+
const a = Ae(e), r = `${o}${a}`, s = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
569
|
+
return typeof n == "number" && s ? `${r.replace("/files", `/thumbs/${n}`)}` : r;
|
|
569
570
|
}, Je = (e) => {
|
|
570
571
|
const { apiURL: n, libraries: o } = j(A), a = e?.dayjs || o?.dayjs;
|
|
571
572
|
return {
|
|
@@ -599,8 +600,8 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
599
600
|
});
|
|
600
601
|
return C(() => {
|
|
601
602
|
e && "isInitialized" in e && e.isInitialized && e.language && a(F(e.language, n));
|
|
602
|
-
const r = (
|
|
603
|
-
a(F(
|
|
603
|
+
const r = (s) => {
|
|
604
|
+
a(F(s, n));
|
|
604
605
|
};
|
|
605
606
|
return e?.on?.("languageChanged", r), () => {
|
|
606
607
|
e?.off?.("languageChanged", r);
|
|
@@ -615,7 +616,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
615
616
|
setFilter: () => {
|
|
616
617
|
}
|
|
617
618
|
}, re = (e, n, o) => `${o}_${e}=>${n}`, qe = (e) => {
|
|
618
|
-
const { libraries: n, localStorageKeys: o } = j(A), a = e?.reactRouter || n?.reactRouter, { pathname: r } = a?.useLocation?.() ?? { pathname: "/" }, [
|
|
619
|
+
const { libraries: n, localStorageKeys: o } = j(A), a = e?.reactRouter || n?.reactRouter, { pathname: r } = a?.useLocation?.() ?? { pathname: "/" }, [s, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
|
|
619
620
|
}], u = o?.filter || _e;
|
|
620
621
|
if (N)
|
|
621
622
|
return Pe;
|
|
@@ -626,14 +627,14 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
626
627
|
const l = (g, m, b = !0) => {
|
|
627
628
|
const p = re(g, e?.pathname || r, u);
|
|
628
629
|
if (!m || Array.isArray(m) && !m.length) {
|
|
629
|
-
|
|
630
|
+
s.delete(g), c(s), localStorage.removeItem(p);
|
|
630
631
|
return;
|
|
631
632
|
}
|
|
632
|
-
b && m && localStorage.setItem(p, JSON.stringify({ ...
|
|
633
|
+
b && m && localStorage.setItem(p, JSON.stringify({ ...s, [g]: m })), m && (s.set(g, JSON.stringify(m)), c(s));
|
|
633
634
|
};
|
|
634
635
|
return {
|
|
635
636
|
getFilter: (g, m) => {
|
|
636
|
-
const b =
|
|
637
|
+
const b = s.get(g);
|
|
637
638
|
if (b)
|
|
638
639
|
try {
|
|
639
640
|
return JSON.parse(b);
|
|
@@ -649,7 +650,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
649
650
|
return m;
|
|
650
651
|
},
|
|
651
652
|
getFilters: () => {
|
|
652
|
-
const g = Object.fromEntries(
|
|
653
|
+
const g = Object.fromEntries(s.entries()), b = Object.keys(localStorage).filter(
|
|
653
654
|
(p) => p.startsWith(u) && p.endsWith(e?.pathname || r)
|
|
654
655
|
).reduce((p, R) => {
|
|
655
656
|
const S = localStorage.getItem(R);
|
|
@@ -677,10 +678,10 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
677
678
|
}, Te = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Ce = (e) => {
|
|
678
679
|
const a = e.split("/").filter((r) => r.length > 0).map((r) => r.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("")).join("");
|
|
679
680
|
return a.charAt(0).toLowerCase() + a.slice(1);
|
|
680
|
-
}, Oe = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""),
|
|
681
|
-
const r = Ce(n),
|
|
681
|
+
}, Oe = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), xe = (e, n, o, a) => {
|
|
682
|
+
const r = Ce(n), s = Te(o), c = `${r}${s}`;
|
|
682
683
|
return e && typeof e == "object" && "operationId" in e && a?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
|
|
683
|
-
},
|
|
684
|
+
}, ke = (e, n) => {
|
|
684
685
|
const o = {};
|
|
685
686
|
return e?.forEach((a) => {
|
|
686
687
|
o[a] = {
|
|
@@ -698,7 +699,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
698
699
|
};
|
|
699
700
|
}), Object.keys(o).length ? o : void 0;
|
|
700
701
|
}, Be = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
|
|
701
|
-
const { output: r, useInfiniteIds:
|
|
702
|
+
const { output: r, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json" } = a || {}, l = Oe(u);
|
|
702
703
|
return {
|
|
703
704
|
...o,
|
|
704
705
|
[l]: {
|
|
@@ -711,8 +712,8 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
711
712
|
client: "react-query",
|
|
712
713
|
mode: "tags-split",
|
|
713
714
|
override: {
|
|
714
|
-
...(
|
|
715
|
-
operations:
|
|
715
|
+
...(s?.length || c?.length) && {
|
|
716
|
+
operations: ke(s, c)
|
|
716
717
|
},
|
|
717
718
|
header: (d) => [
|
|
718
719
|
"Generated by orval 🍺",
|
|
@@ -723,7 +724,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
723
724
|
name: "axiosCustomInstance",
|
|
724
725
|
path: "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"
|
|
725
726
|
},
|
|
726
|
-
operationName: (d,
|
|
727
|
+
operationName: (d, i, h) => xe(d, i, h, c),
|
|
727
728
|
query: {
|
|
728
729
|
useQuery: !0
|
|
729
730
|
}
|
|
@@ -747,6 +748,7 @@ export {
|
|
|
747
748
|
We as PreloadErrorHandler,
|
|
748
749
|
Qe as QueryClientProviderWithConfig,
|
|
749
750
|
Le as RequireAuth,
|
|
751
|
+
Ze as axiosCustomInstance,
|
|
750
752
|
be as dateAdapter,
|
|
751
753
|
Re as distanceAdapter,
|
|
752
754
|
Be as getOrvalConfig,
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracktor/shared-module",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"types": "./dist/main.d.ts",
|
|
7
7
|
"main": "./dist/main.umd.cjs",
|
|
8
8
|
"module": "./dist/main.js",
|
|
9
|
-
"files": [
|
|
10
|
-
"dist"
|
|
11
|
-
],
|
|
9
|
+
"files": ["dist"],
|
|
12
10
|
"exports": {
|
|
13
11
|
".": {
|
|
14
12
|
"types": "./dist/main.d.ts",
|
|
@@ -16,9 +14,11 @@
|
|
|
16
14
|
"import": "./dist/main.js",
|
|
17
15
|
"default": "./dist/main.umd.cjs"
|
|
18
16
|
},
|
|
19
|
-
"./
|
|
17
|
+
"./axios": {
|
|
20
18
|
"types": "./dist/axios/axiosCustomInstance.d.ts",
|
|
21
|
-
"
|
|
19
|
+
"require": "./dist/axios/axios.cjs",
|
|
20
|
+
"import": "./dist/axios/axios.js",
|
|
21
|
+
"default": "./dist/axios/axios.cjs"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
package/dist/main.umd.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
(function(y,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],p):(y=typeof globalThis<"u"?globalThis:y||self,p(y["@tracktor/shared-module"]={},y.React))})(this,function(y,p){"use strict";var L={exports:{}},O={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and 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 W;function oe(){if(W)return O;W=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(a,r,s){var c=null;if(s!==void 0&&(c=""+s),r.key!==void 0&&(c=""+r.key),"key"in r){s={};for(var u in r)u!=="key"&&(s[u]=r[u])}else s=r;return r=s.ref,{$$typeof:e,type:a,key:c,ref:r!==void 0?r:null,props:s}}return O.Fragment=n,O.jsx=o,O.jsxs=o,O}var x={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and 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 Q;function ae(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Ue?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case g:return"Fragment";case j:return"Profiler";case A:return"StrictMode";case H:return"Suspense";case De:return"SuspenseList";case ze:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case S:return"Portal";case w:return(t.displayName||"Context")+".Provider";case k:return(t._context.displayName||"Context")+".Consumer";case X:var f=t.render;return t=t.displayName,t||(t=f.displayName||f.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ye:return f=t.displayName||null,f!==null?f:e(t.type)||"Memo";case Z:f=t._payload,t=t._init;try{return e(t(f))}catch{}}return null}function n(t){return""+t}function o(t){try{n(t);var f=!1}catch{f=!0}if(f){f=console;var v=f.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return v.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),n(t)}}function a(t){if(t===g)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===Z)return"<...>";try{var f=e(t);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function r(){var t=D.A;return t===null?null:t.getOwner()}function s(){return Error("react-stack-top-frame")}function c(t){if(q.call(t,"key")){var f=Object.getOwnPropertyDescriptor(t,"key").get;if(f&&f.isReactWarning)return!1}return t.key!==void 0}function u(t,f){function v(){$||($=!0,console.error("%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://react.dev/link/special-props)",f))}v.isReactWarning=!0,Object.defineProperty(t,"key",{get:v,configurable:!0})}function l(){var t=e(this.type);return ee[t]||(ee[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function d(t,f,v,b,T,_,z,U){return v=_.ref,t={$$typeof:h,type:t,key:f,props:_,_owner:T},(v!==void 0?v:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:l}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:z}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function i(t,f,v,b,T,_,z,U){var R=f.children;if(R!==void 0)if(b)if(Me(R)){for(b=0;b<R.length;b++)E(R[b]);Object.freeze&&Object.freeze(R)}else console.error("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 E(R);if(q.call(f,"key")){R=e(t);var I=Object.keys(f).filter(function(We){return We!=="key"});b=0<I.length?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}",ne[R+b]||(I=0<I.length?"{"+I.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
-
let props = %s;
|
|
19
|
-
<%s {...props} />
|
|
20
|
-
React keys must be passed directly to JSX without using spread:
|
|
21
|
-
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,b,R,I,R),ne[R+b]=!0)}if(R=null,v!==void 0&&(o(v),R=""+v),c(f)&&(o(f.key),R=""+f.key),"key"in f){v={};for(var M in f)M!=="key"&&(v[M]=f[M])}else v=f;return R&&u(v,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,R,_,T,r(),v,z,U)}function E(t){typeof t=="object"&&t!==null&&t.$$typeof===h&&t._store&&(t._store.validated=1)}var m=p,h=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),w=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),De=Symbol.for("react.suspense_list"),Ye=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),ze=Symbol.for("react.activity"),Ue=Symbol.for("react.client.reference"),D=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=Object.prototype.hasOwnProperty,Me=Array.isArray,Y=console.createTask?console.createTask:function(){return null};m={"react-stack-bottom-frame":function(t){return t()}};var $,ee={},te=m["react-stack-bottom-frame"].bind(m,s)(),re=Y(a(s)),ne={};x.Fragment=g,x.jsx=function(t,f,v,b,T){var _=1e4>D.recentlyCreatedOwnerStacks++;return i(t,f,v,!1,b,T,_?Error("react-stack-top-frame"):te,_?Y(a(t)):re)},x.jsxs=function(t,f,v,b,T){var _=1e4>D.recentlyCreatedOwnerStacks++;return i(t,f,v,!0,b,T,_?Error("react-stack-top-frame"):te,_?Y(a(t)):re)}}()),x}var V;function se(){return V||(V=1,process.env.NODE_ENV==="production"?L.exports=oe():L.exports=ae()),L.exports}var P=se();const C=p.createContext({}),ie=({children:e,apiURL:n,libraries:o,localStorageKeys:a})=>{const r=p.useMemo(()=>({apiURL:n,libraries:o,localStorageKeys:a}),[n,o,a]);return P.jsx(C.Provider,{value:r,children:e})},ce="user",ue=({Fallback:e,isLogged:n,loginPath:o="/login",redirect401Path:a="/login",...r})=>{const{libraries:s,localStorageKeys:c}=p.useContext(C),u=r?.reactRouter||s?.reactRouter,l=r?.axios||s?.axios,d=r?.localStorageKey||c?.user||ce;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,E]=p.useState(null),{useLocation:m,Navigate:h,Outlet:S}=u,g=m(),A=p.useRef(!1),j=typeof n=="function"?n():!!n,k=typeof j=="boolean"?j:j?.isLogged;return p.useEffect(()=>{A.current||(A.current=!0,l.interceptors.response.use(w=>w,async w=>(typeof w=="object"&&w&&"response"in w&&w.response&&typeof w.response=="object"&&"status"in w.response&&w.response&&typeof w.response=="object"&&"status"in w.response&&w?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),E(a)),Promise.reject(w))))},[l.defaults.headers.common,l.interceptors.response,d,a]),k&&!i?P.jsx(p.Suspense,{fallback:e,children:g.state?.from?.state&&g.state?.from?.pathname===o?P.jsx(h,{to:g.state.from.state.from.pathname+g.state.from.state.from.search,replace:!0}):P.jsx(S,{})}):P.jsx(h,{to:o+g.search,state:{from:g},replace:!0})},le=({data:e,...n})=>{const{libraries:o}=p.useContext(C),a=n?.reactRouter||o?.reactRouter,r=n?.gtm||o?.gtm;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!r)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:s}=r,{useLocation:c,Outlet:u}=a,{pathname:l}=c(),{sendEvent:d}=s();return p.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),P.jsx(u,{})},N=(()=>{try{return typeof global=="object"&&global!==null&&("HermesInternal"in global||"__fbBatchedBridge"in global||"__metro"in global)||typeof window>"u"&&typeof global<"u"?!0:typeof navigator<"u"&&navigator.userAgent?/react.native|ReactNative/i.test(navigator.userAgent):!1}catch{return!1}})(),de="user",fe=({tokenTypeKey:e="tokenType",tokenKey:n="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:r=a.apiURL,libraries:s,localStorageKeys:c}=p.useContext(C),u=a?.userLocalStorageKey||c?.user||de,l=a?.axios||s?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||N)return null;if(typeof window<"u"&&window.localStorage){const d=localStorage.getItem(u),i=d?JSON.parse(d):null,E=i?.[e]?i[e]:null,m=i?.[n]?i[n]:null,h=d?`${E} ${m}`:null;h&&(l.defaults.headers.common.Authorization=h)}return l.defaults.baseURL=r,l.defaults.headers.post["Content-Type"]=o,null},pe=({debug:e,resources:n,...o})=>{const{libraries:a}=p.useContext(C),r=o?.i18||a?.i18,{i18next:s,initReactI18next:c,languageDetector:u}=r||{};if(N)return null;if(!r)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return s?.isInitialized||(s.use(u).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:n,returnNull:!1}).then(()=>{document.documentElement.lang!==s.resolvedLanguage&&s.resolvedLanguage&&document.documentElement.setAttribute("lang",s.resolvedLanguage)}),s.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},ge=({dsn:e,integrations:n,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:r,tracePropagationTargets:s,ignoreErrors:c,debug:u,environment:l,release:d,...i})=>{const{libraries:E}=p.useContext(C),m=i?.sentry||E?.sentry,h=i?.reactRouter||E?.reactRouter;if(!m)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!h)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(m.isInitialized())return null;const{createRoutesFromChildren:S,matchRoutes:g,useLocation:A,useNavigationType:j}=h;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&m.init({debug:u,dsn:e,environment:l||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[m.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:S,matchRoutes:g,useEffect:p.useEffect,useLocation:A,useNavigationType:j}),...n||[]],release:d,replaysOnErrorSampleRate:r||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:s,tracesSampleRate:o||1}),null},me=({IMaskMixin:e,...n})=>{const o=p.useMemo(()=>e(({TextField:a,...r})=>P.jsx(a,{...r})),[e]);return P.jsx(o,{...n})},ye=({language:e,...n})=>{const{libraries:o}=p.useContext(C),a=n?.dayjs||o?.dayjs,r=n?.plugin||o?.dayjsPlugin;if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return p.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";r&&r.forEach(u=>{u&&a.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,r,e]),null},he=()=>(p.useEffect(()=>{if(N)return;const e=n=>{try{n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),ve=e=>e&&typeof e=="function",Ee=e=>e&&typeof e=="function",we=({children:e,defaultQueriesOptions:n,defaultMutationsOptions:o,...a})=>{const{libraries:r}=p.useContext(C),s=a?.QueryClient||r?.reactQuery?.QueryClient,c=a?.QueryClientProvider||r?.reactQuery?.QueryClientProvider;if(!s)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!ve(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ee(s))throw new Error("Provided QueryClient dependencies are not valid.");const u=new s({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,d,i)=>l.length+(i||0),refetchOnWindowFocus:!1,retry:3,...n}}});return P.jsx(c,{client:u,children:e})},be=e=>{const{libraries:n}=p.useContext(C),o=e?.i18||n?.i18,a=e?.i18?.translateFunction||n?.i18?.translateFunction,r=o?.i18next?.t||a||(d=>d),{unknownErrorTranslationKey:s="error.unknownError"}=e||{},c=r(s),u=p.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:i}=d||{};if(i&&typeof i=="object"&&"reason"in i)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:E}=i.data;if(Array.isArray(E)&&E.length>0&&typeof E[0]=="object"&&E[0]!==null&&"msg"in E[0]){const{msg:m}=E[0];if(typeof m=="string")return String(m)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:p.useCallback(d=>{const{response:i}=d||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:u}},Re=({data:e,fetchNextPage:n,isFetchingNextPage:o,isInitialLoading:a,isLoading:r,enabled:s=!0})=>{const c=p.useCallback(async l=>{o||!s||await n({pageParam:l?.pageParam||l.visibleRowsCount})},[s,n,o]),u=p.useMemo(()=>{if(e)return e.pages.reduce((l,d)=>[...l,...d],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||r,loadingVariant:a?"skeleton":"linear-progress",rows:u}},Se=e=>{const{libraries:n}=p.useContext(C),o=e?.axios||n?.axios,a=e?.localStorageKey||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const r=p.useCallback(({tokenType:c,accessToken:u})=>{o.defaults.headers.common.Authorization=`${c} ${u}`},[o.defaults.headers.common]),s=()=>{o.defaults.headers.common.Authorization=null};return p.useEffect(()=>{if(N)return;const c=({newValue:u,key:l})=>{if(l===a&&u)try{const{accessToken:d,tokenType:i}=JSON.parse(u);r({accessToken:d,tokenType:i})}catch(d){console.error("Failed to parse newValue from localStorage:",d)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,r]),{clearAuthenticationToken:s,setAuthenticationToken:r}},G=({library:e,date:n,format:o="ll"})=>e(n).format(o),J=(e,n)=>{const{fractionDigits:o=0,metric:a="km"}=n||{},r=Number(e);return Number.isNaN(r)?`0${a}`:`${r.toFixed(o)}${a}`},K=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),Ae=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,je=({path:e,size:n,apiURL:o})=>{if(!e)return"";const a=Ae(e),r=`${o}${a}`,s=r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof n=="number"&&s?`${r.replace("/files",`/thumbs/${n}`)}`:r},Ce=e=>{const{apiURL:n,libraries:o}=p.useContext(C),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,u)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return G({date:c,format:u,library:a})},distanceAdapter:J,filePathAdapter:(c,u)=>{if(!n)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return typeof c=="string"&&/^https?:\/\//.test(c)?c:je({apiURL:n,path:c,size:u})},worksiteNameAdapter:K}},F=(e,n)=>n==="short"?e.split("-")[0]:e,_e=(e,n="full")=>{const[o,a]=p.useState(()=>{const r=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,F(r,n)});return p.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(F(e.language,n));const r=s=>{a(F(s,n))};return e?.on?.("languageChanged",r),()=>{e?.off?.("languageChanged",r)}},[e,n]),o},Pe="tracktor.filter",Te={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},B=(e,n,o)=>`${o}_${e}=>${n}`,ke=e=>{const{libraries:n,localStorageKeys:o}=p.useContext(C),a=e?.reactRouter||n?.reactRouter,{pathname:r}=a?.useLocation?.()??{pathname:"/"},[s,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],u=o?.filter||Pe;if(N)return Te;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const l=(m,h,S=!0)=>{const g=B(m,e?.pathname||r,u);if(!h||Array.isArray(h)&&!h.length){s.delete(m),c(s),localStorage.removeItem(g);return}S&&h&&localStorage.setItem(g,JSON.stringify({...s,[m]:h})),h&&(s.set(m,JSON.stringify(h)),c(s))};return{getFilter:(m,h)=>{const S=s.get(m);if(S)try{return JSON.parse(S)}catch{return S}const g=B(m,e?.pathname||r,u),A=localStorage.getItem(g);if(A)try{return JSON.parse(A)[m]}catch{}return h},getFilters:()=>{const m=Object.fromEntries(s.entries()),S=Object.keys(localStorage).filter(g=>g.startsWith(u)&&g.endsWith(e?.pathname||r)).reduce((g,A)=>{const j=localStorage.getItem(A);if(j){const k=JSON.parse(j),w=Object.keys(k)?.[0];g[w]=Object.values(k)?.[0]}return g},{});return{...m,...S}},handleFilter:(m,h)=>(S,g)=>{if(g||Array.isArray(g)&&g.length===0){const A=h||"value",j=typeof g=="object"&&A in g?g[A]:g;l(m,j);return}l(m,void 0)},setFilter:l}},Ie=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Oe=e=>{const a=e.split("/").filter(r=>r.length>0).map(r=>r.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},xe=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Ne=(e,n,o,a)=>{const r=Oe(n),s=Ie(o),c=`${r}${s}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Le=(e,n)=>{const o={};return e?.forEach(a=>{o[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),n?.filter(a=>!o[a]).forEach(a=>{o[a]={query:{useQuery:!0}}}),Object.keys(o).length?o:void 0},Fe=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:r,useInfiniteIds:s,useQueryIds:c,input:u="./openapi.json"}=a||{},l=xe(u);return{...o,[l]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:u,output:{baseUrl:r?.baseUrl,client:"react-query",mode:"tags-split",override:{...(s?.length||c?.length)&&{operations:Le(s,c)},header:d=>["Generated by orval 🍺",...d.title?[d.title]:[],...d.description?[d.description]:[]],mutator:{name:"axiosCustomInstance",path:"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"},operationName:(d,i,E)=>Ne(d,i,E,c),query:{useQuery:!0}},schemas:r?.schemas||`src/api/${l}/model`,target:r?.target||`src/api/${l}/services/api.ts`,...r}}}},{});y.GTMSendPageView=le,y.InitializeAxiosConfig=fe,y.InitializeDaysJSConfig=ye,y.InitializeI18nConfig=pe,y.InitializeSentryConfig=ge,y.InjectDependenciesContext=C,y.InjectDependenciesProvider=ie,y.MaskTextField=me,y.PreloadErrorHandler=he,y.QueryClientProviderWithConfig=we,y.RequireAuth=ue,y.dateAdapter=G,y.distanceAdapter=J,y.getOrvalConfig=Fe,y.useAdapter=Ce,y.useAuth=Se,y.useCurrentLanguage=_e,y.useFilters=ke,y.useInfiniteDataGrid=Re,y.useResponseError=be,y.worksiteNameAdapter=K,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|