@tracktor/shared-module 2.1.7 → 2.1.9

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 CHANGED
@@ -1,4 +1,4 @@
1
1
  # [Versions](https://github.com/Tracktor/shared-module/releases)
2
2
 
3
- ## v2.1.7
3
+ ## v2.1.9
4
4
  - **[fix]** - dayjs load locale
package/dist/main.js CHANGED
@@ -745,10 +745,7 @@ const A = dt({}), Ot = ({ children: t, apiURL: n, libraries: i }) => {
745
745
  if (!c)
746
746
  throw new Error("Mapbox is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
747
747
  return t && (c.accessToken = t), null;
748
- };
749
- import("dayjs/locale/en");
750
- import("dayjs/locale/fr");
751
- const Nt = ({ language: t, ...n }) => {
748
+ }, Nt = ({ language: t, ...n }) => {
752
749
  const { libraries: i } = k(A), c = (n == null ? void 0 : n.dayjs) || (i == null ? void 0 : i.dayjs), a = (n == null ? void 0 : n.plugin) || (i == null ? void 0 : i.dayjsPlugin);
753
750
  if (!c)
754
751
  throw new Error(
@@ -758,9 +755,9 @@ const Nt = ({ language: t, ...n }) => {
758
755
  (async () => {
759
756
  var d;
760
757
  const v = t || ((d = navigator.language) == null ? void 0 : d.slice(0, 2)) || "en";
761
- c.locale(v), a && a.forEach((s) => {
758
+ a && a.forEach((s) => {
762
759
  s && c.extend(s);
763
- });
760
+ }), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), c.locale(v);
764
761
  })().then();
765
762
  }, [c, a, t]), null;
766
763
  }, Et = (t) => t && typeof t == "function", pt = (t) => t && typeof t == "function", Wt = ({
package/dist/main.umd.cjs CHANGED
@@ -22,4 +22,4 @@
22
22
 
23
23
  Check the render method of \``+e+"`."}return""}}function xt(e){return""}var De={};function Ot(e){{var r=Ie();if(!r){var o=typeof e=="string"?e:e.displayName||e.name;o&&(r=`
24
24
 
25
- Check the top-level render call using <`+o+">.")}return r}}function ke(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var o=Ot(r);if(De[o])return;De[o]=!0;var f="";e&&e._owner&&e._owner!==ae.current&&(f=" It was passed a child from "+Y(e._owner.type)+"."),V(e),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',o,f),V(null)}}function Fe(e,r){{if(typeof e!="object")return;if(oe(e))for(var o=0;o<e.length;o++){var f=e[o];se(f)&&ke(f,r)}else if(se(e))e._store&&(e._store.validated=!0);else if(e){var E=x(e);if(typeof E=="function"&&E!==e.entries)for(var p=E.call(e),y;!(y=p.next()).done;)se(y.value)&&ke(y.value,r)}}}function At(e){{var r=e.type;if(r==null||typeof r=="string")return;var o;if(typeof r=="function")o=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===u||r.$$typeof===_))o=r.propTypes;else return;if(o){var f=Y(r);ht(o,e.props,"prop",f,e)}else if(r.PropTypes!==void 0&&!ce){ce=!0;var E=Y(r);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function It(e){{for(var r=Object.keys(e.props),o=0;o<r.length;o++){var f=r[o];if(f!=="children"&&f!=="key"){V(e),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",f),V(null);break}}e.ref!==null&&(V(e),b("Invalid attribute `ref` supplied to `React.Fragment`."),V(null))}}function Ye(e,r,o,f,E,p){{var y=lt(e);if(!y){var g="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(g+=" 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 O=xt();O?g+=O:g+=Ie();var P;e===null?P="null":oe(e)?P="array":e!==void 0&&e.$$typeof===n?(P="<"+(Y(e.type)||"Unknown")+" />",g=" Did you accidentally export a JSX literal instead of a component?"):P=typeof e,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",P,g)}var T=St(e,r,o,E,p);if(T==null)return T;if(y){var D=r.children;if(D!==void 0)if(f)if(oe(D)){for(var U=0;U<D.length;U++)Fe(D[U],e);Object.freeze&&Object.freeze(D)}else b("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 Fe(D,e)}return e===s?It(T):At(T),T}}function Dt(e,r,o){return Ye(e,r,o,!0)}function kt(e,r,o){return Ye(e,r,o,!1)}var Ft=kt,Yt=Dt;G.Fragment=s,G.jsx=Ft,G.jsxs=Yt}()),G}process.env.NODE_ENV==="production"?ee.exports=Ne():ee.exports=Le();var F=ee.exports;const A=h.createContext({}),Me=({children:t,apiURL:n,libraries:i})=>{const s=h.useMemo(()=>({apiURL:n,libraries:i}),[n,i]);return F.jsx(A.Provider,{value:s,children:t})},ze=({Fallback:t,isLogged:n,loginPath:i="/login",localStorageKey:s="user",redirect401Path:a="/login",...l})=>{var b,N,L,M;const{libraries:v}=h.useContext(A),d=(l==null?void 0:l.reactRouter)||(v==null?void 0:v.reactRouter),u=(l==null?void 0:l.axios)||(v==null?void 0:v.axios);if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[m,R]=h.useState(null),{useLocation:_,Navigate:C,Outlet:c}=d,S=_(),I=h.useRef(!1),x=typeof n=="function"?n():!!n,k=typeof x=="boolean"?x:x==null?void 0:x.isLogged;return h.useEffect(()=>{I.current||(I.current=!0,u.interceptors.response.use(j=>j,async j=>{var Q;return typeof j=="object"&&j&&"response"in j&&j.response&&typeof j.response=="object"&&"status"in j.response&&j.response&&typeof j.response=="object"&&"status"in j.response&&((Q=j==null?void 0:j.response)==null?void 0:Q.status)===401&&(u.defaults.headers.common.Authorization=null,localStorage.removeItem(s),R(a)),Promise.reject(j)}))},[u.defaults.headers.common,u.interceptors.response,s,a]),k&&!m?F.jsx(h.Suspense,{fallback:t,children:(N=(b=S.state)==null?void 0:b.from)!=null&&N.state&&((M=(L=S.state)==null?void 0:L.from)==null?void 0:M.pathname)===i?F.jsx(C,{to:S.state.from.state.from.pathname+S.state.from.state.from.search,replace:!0}):F.jsx(c,{})}):F.jsx(C,{to:i,state:{from:S},replace:!0})},Ve=({...t})=>{const{libraries:n}=h.useContext(A),i=(t==null?void 0:t.reactRouter)||(n==null?void 0:n.reactRouter),s=(t==null?void 0:t.gtm)||(n==null?void 0:n.gtm);if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!s)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:a}=s,{useLocation:l,Outlet:v}=i,{pathname:d}=l(),{sendEvent:u}=a();return h.useEffect(()=>{u({event:"pageView",pathname:d})},[d,u]),F.jsx(v,{})},Ue=({tokenTypeKey:t="tokenType",userLocalStorageKey:n="user",tokenKey:i="accessToken",postContentType:s="application/json",...a})=>{const{apiURL:l=a.apiURL,libraries:v}=h.useContext(A),d=(a==null?void 0:a.axios)||(v==null?void 0:v.axios);if(!d)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!(d!=null&&d.defaults))return null;const u=localStorage.getItem(n),m=u?JSON.parse(u):null,R=m!=null&&m[t]?m[t]:null,_=m!=null&&m[i]?m[i]:null,C=u?`${R} ${_}`:null;return d.defaults.baseURL=l,d.defaults.headers.post["Content-Type"]=s,C&&(d.defaults.headers.common.Authorization=C),null},Be=({debug:t,resources:n,...i})=>{const{libraries:s}=h.useContext(A),a=(i==null?void 0:i.i18)||(s==null?void 0:s.i18),{i18next:l,initReactI18next:v,languageDetector:d}=a||{};if(!a)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(v).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},Ge=({dsn:t,integrations:n,tracesSampleRate:i,replaysSessionSampleRate:s,replaysOnErrorSampleRate:a,tracePropagationTargets:l,ignoreErrors:v,debug:d,environment:u,...m})=>{const{libraries:R}=h.useContext(A),_=(m==null?void 0:m.sentry)||(R==null?void 0:R.sentry),C=(m==null?void 0:m.reactRouter)||(R==null?void 0:R.reactRouter);if(!_)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!C)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(_.isInitialized())return null;const{createRoutesFromChildren:c,matchRoutes:S,useLocation:I,useNavigationType:x}=C;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&_.init({debug:d,dsn:t,environment:u||"production",ignoreErrors:[...v||[],/dynamically imported module/],integrations:[_.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:c,matchRoutes:S,useEffect:h.useEffect,useLocation:I,useNavigationType:x}),...n||[]],replaysOnErrorSampleRate:a||1,replaysSessionSampleRate:s||.1,tracePropagationTargets:l,tracesSampleRate:i||1}),null},Qe=({IMaskMixin:t,...n})=>{const i=h.useMemo(()=>t(({TextField:s,...a})=>F.jsx(s,{...a})),[t]);return F.jsx(i,{...n})},Je=({accessToken:t,...n})=>{const{libraries:i}=h.useContext(A),s=(n==null?void 0:n.mapbox)||(i==null?void 0:i.mapbox);if(!s)throw new Error("Mapbox is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return t&&(s.accessToken=t),null};import("dayjs/locale/en"),import("dayjs/locale/fr");const Xe=({language:t,...n})=>{const{libraries:i}=h.useContext(A),s=(n==null?void 0:n.dayjs)||(i==null?void 0:i.dayjs),a=(n==null?void 0:n.plugin)||(i==null?void 0:i.dayjsPlugin);if(!s)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 v=t||((d=navigator.language)==null?void 0:d.slice(0,2))||"en";s.locale(v),a&&a.forEach(u=>{u&&s.extend(u)})})().then()},[s,a,t]),null},He=t=>t&&typeof t=="function",Ke=t=>t&&typeof t=="function",Ze=({children:t,defaultQueriesOptions:n,defaultMutationsOptions:i,...s})=>{var u,m;const{libraries:a}=h.useContext(A),l=(s==null?void 0:s.QueryClient)||((u=a==null?void 0:a.reactQuery)==null?void 0:u.QueryClient),v=(s==null?void 0:s.QueryClientProvider)||((m=a==null?void 0:a.reactQuery)==null?void 0:m.QueryClientProvider);if(!l)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!v)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!He(v))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ke(l))throw new Error("Provided QueryClient dependencies are not valid.");const d=new l({defaultOptions:{mutations:{...i},queries:{getNextPageParam:(R,_,C)=>R.length+(C||0),refetchOnWindowFocus:!1,retry:3,...n}}});return F.jsx(v,{client:d,children:t})},$e=t=>{var m,R,_;const{libraries:n}=h.useContext(A),i=(t==null?void 0:t.i18)||(n==null?void 0:n.i18),s=((m=t==null?void 0:t.i18)==null?void 0:m.translateFunction)||((R=n==null?void 0:n.i18)==null?void 0:R.translateFunction),a=((_=i==null?void 0:i.i18next)==null?void 0:_.t)||s||(C=>C),{unknownErrorTranslationKey:l="error.unknownError"}=t||{},v=a(l),d=h.useCallback(C=>{var S,I,x,k,b,N,L,M,j;const{response:c}=C||{};return c!=null&&c.reason?String(c.reason):(S=c==null?void 0:c.data)!=null&&S.reason?String(c.data.reason):(I=c==null?void 0:c.data)!=null&&I.message?String(c.data.message):(k=(x=c==null?void 0:c.data)==null?void 0:x.detail)!=null&&k.length&&Array.isArray((b=c==null?void 0:c.data)==null?void 0:b.detail)&&((L=(N=c==null?void 0:c.data)==null?void 0:N.detail[0])!=null&&L.msg)&&typeof((j=(M=c==null?void 0:c.data)==null?void 0:M.detail[0])==null?void 0:j.msg)=="string"?String(c.data.detail[0].msg):v},[v]);return{getErrorCode:h.useCallback(C=>{var S,I,x;const{response:c}=C||{};return c!=null&&c.error_code?String(c==null?void 0:c.error_code):(S=c==null?void 0:c.data)!=null&&S.error_code?String((I=c==null?void 0:c.data)==null?void 0:I.error_code):c!=null&&c.error_code?String(c==null?void 0:c.error_code):(x=c==null?void 0:c.data)!=null&&x.error_code?String(c.data.error_code):"unknown_error_code"},[]),printError:d}},qe=({data:t,fetchNextPage:n,isFetchingNextPage:i,isInitialLoading:s,isLoading:a,enabled:l=!0})=>{const v=h.useCallback(async u=>{i||!l||await n({pageParam:(u==null?void 0:u.pageParam)||u.visibleRowsCount})},[l,n,i]),d=h.useMemo(()=>{if(t)return t.pages.reduce((u,m)=>[...u,...m],[])},[t]);return{fetchNextPageOnRowsScrollEnd:v,isLoading:i||a,loadingVariant:s?"skeleton":"linear",rows:d}},et=t=>{const{libraries:n}=h.useContext(A),i=(t==null?void 0:t.axios)||(n==null?void 0:n.axios);if(!i)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");return{clearAuthenticationToken:()=>{i.defaults.headers.common.Authorization=null},setAuthenticationToken:({tokenType:l,accessToken:v})=>{i.defaults.headers.common.Authorization=`${l} ${v}`}}},fe=({library:t,date:n,format:i="ll"})=>t(n).format(i),de=(t,n="km")=>{const i=Number(t);return Number.isNaN(i)?`0 ${n}`:`${i.toFixed(2)} ${n}`},tt=t=>t!=null&&t.startsWith("/")?t!=null&&t.startsWith("/files")?t:`/files${t}`:t!=null&&t.startsWith("files")?`/${t}`:t!=null&&t.startsWith("files")?`/${t}`:`/files/${t}`,rt=({path:t,size:n,apiURL:i})=>{if(!t)return"";const s=tt(t),a=`${i}${s}`,l=a.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof n=="number"&&l?`${a.replace("/files",`/thumbs/${n}`)}`:a},nt=t=>{const{apiURL:n,libraries:i}=h.useContext(A),s=(t==null?void 0:t.dayjs)||(i==null?void 0:i.dayjs);return{dateAdapter:(v,d)=>{if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return fe({date:v,format:d,library:s})},distanceAdapter:de,filePathAdapter:(v,d)=>{if(!n)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return rt({apiURL:n,path:v,size:d})}}},ot=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),it=t=>{const s=t.split("/").filter(a=>a.length>0).map(a=>a.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return s.charAt(0).toLowerCase()+s.slice(1)},at=t=>(t.split("/").pop()||t).replace(/\.json$/,"").replace(/^openapi\./,""),ct=(t,n,i)=>{const s=it(n),a=ot(i);return`${s}${a}`},st=t=>{if(t)return(t==null?void 0:t.reduce((n,i)=>(n[i]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}},n),{}))||{}},ut=t=>(Array.isArray(t)?t:[t]).reduce((i,s)=>{const{output:a,operationsToGenerateInfiniteQueryHook:l,input:v="./openapi.json"}=s||{},d=at(v);return{...i,[d]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:v,output:{baseUrl:a==null?void 0:a.baseUrl,client:"react-query",mode:"tags-split",override:{...(l==null?void 0:l.length)&&{operations:st(l)},header:u=>["Generated by orval 🍺",...u.title?[u.title]:[],...u.description?[u.description]:[]],mutator:{name:"axiosCustomInstance",path:`${__dirname}/axiosCustomInstance.ts`},operationName:ct,query:{useQuery:!0}},schemas:(a==null?void 0:a.schemas)||`src/api/${d}/model`,target:(a==null?void 0:a.target)||`src/api/${d}/services/api.ts`,...a}}}},{});w.GTMSendPageView=Ve,w.InitializeAxiosConfig=Ue,w.InitializeDaysJSConfig=Xe,w.InitializeI18nConfig=Be,w.InitializeMapBoxConfig=Je,w.InitializeSentryConfig=Ge,w.InjectDependenciesContext=A,w.InjectDependenciesProvider=Me,w.MaskTextField=Qe,w.QueryClientProviderWithConfig=Ze,w.RequireAuth=ze,w.dateAdapter=fe,w.distanceAdapter=de,w.getOrvalConfig=ut,w.useAdapter=nt,w.useAuth=et,w.useInfiniteDataGrid=qe,w.useResponseError=$e,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
25
+ Check the top-level render call using <`+o+">.")}return r}}function ke(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var o=Ot(r);if(De[o])return;De[o]=!0;var f="";e&&e._owner&&e._owner!==ae.current&&(f=" It was passed a child from "+Y(e._owner.type)+"."),V(e),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',o,f),V(null)}}function Fe(e,r){{if(typeof e!="object")return;if(oe(e))for(var o=0;o<e.length;o++){var f=e[o];se(f)&&ke(f,r)}else if(se(e))e._store&&(e._store.validated=!0);else if(e){var E=x(e);if(typeof E=="function"&&E!==e.entries)for(var p=E.call(e),y;!(y=p.next()).done;)se(y.value)&&ke(y.value,r)}}}function At(e){{var r=e.type;if(r==null||typeof r=="string")return;var o;if(typeof r=="function")o=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===u||r.$$typeof===_))o=r.propTypes;else return;if(o){var f=Y(r);ht(o,e.props,"prop",f,e)}else if(r.PropTypes!==void 0&&!ce){ce=!0;var E=Y(r);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function It(e){{for(var r=Object.keys(e.props),o=0;o<r.length;o++){var f=r[o];if(f!=="children"&&f!=="key"){V(e),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",f),V(null);break}}e.ref!==null&&(V(e),b("Invalid attribute `ref` supplied to `React.Fragment`."),V(null))}}function Ye(e,r,o,f,E,p){{var y=lt(e);if(!y){var g="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(g+=" 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 O=xt();O?g+=O:g+=Ie();var P;e===null?P="null":oe(e)?P="array":e!==void 0&&e.$$typeof===n?(P="<"+(Y(e.type)||"Unknown")+" />",g=" Did you accidentally export a JSX literal instead of a component?"):P=typeof e,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",P,g)}var T=St(e,r,o,E,p);if(T==null)return T;if(y){var D=r.children;if(D!==void 0)if(f)if(oe(D)){for(var U=0;U<D.length;U++)Fe(D[U],e);Object.freeze&&Object.freeze(D)}else b("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 Fe(D,e)}return e===s?It(T):At(T),T}}function Dt(e,r,o){return Ye(e,r,o,!0)}function kt(e,r,o){return Ye(e,r,o,!1)}var Ft=kt,Yt=Dt;G.Fragment=s,G.jsx=Ft,G.jsxs=Yt}()),G}process.env.NODE_ENV==="production"?ee.exports=Ne():ee.exports=Le();var F=ee.exports;const A=h.createContext({}),Me=({children:t,apiURL:n,libraries:i})=>{const s=h.useMemo(()=>({apiURL:n,libraries:i}),[n,i]);return F.jsx(A.Provider,{value:s,children:t})},ze=({Fallback:t,isLogged:n,loginPath:i="/login",localStorageKey:s="user",redirect401Path:a="/login",...l})=>{var b,N,L,M;const{libraries:v}=h.useContext(A),d=(l==null?void 0:l.reactRouter)||(v==null?void 0:v.reactRouter),u=(l==null?void 0:l.axios)||(v==null?void 0:v.axios);if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[m,R]=h.useState(null),{useLocation:_,Navigate:C,Outlet:c}=d,S=_(),I=h.useRef(!1),x=typeof n=="function"?n():!!n,k=typeof x=="boolean"?x:x==null?void 0:x.isLogged;return h.useEffect(()=>{I.current||(I.current=!0,u.interceptors.response.use(j=>j,async j=>{var Q;return typeof j=="object"&&j&&"response"in j&&j.response&&typeof j.response=="object"&&"status"in j.response&&j.response&&typeof j.response=="object"&&"status"in j.response&&((Q=j==null?void 0:j.response)==null?void 0:Q.status)===401&&(u.defaults.headers.common.Authorization=null,localStorage.removeItem(s),R(a)),Promise.reject(j)}))},[u.defaults.headers.common,u.interceptors.response,s,a]),k&&!m?F.jsx(h.Suspense,{fallback:t,children:(N=(b=S.state)==null?void 0:b.from)!=null&&N.state&&((M=(L=S.state)==null?void 0:L.from)==null?void 0:M.pathname)===i?F.jsx(C,{to:S.state.from.state.from.pathname+S.state.from.state.from.search,replace:!0}):F.jsx(c,{})}):F.jsx(C,{to:i,state:{from:S},replace:!0})},Ve=({...t})=>{const{libraries:n}=h.useContext(A),i=(t==null?void 0:t.reactRouter)||(n==null?void 0:n.reactRouter),s=(t==null?void 0:t.gtm)||(n==null?void 0:n.gtm);if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!s)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:a}=s,{useLocation:l,Outlet:v}=i,{pathname:d}=l(),{sendEvent:u}=a();return h.useEffect(()=>{u({event:"pageView",pathname:d})},[d,u]),F.jsx(v,{})},Ue=({tokenTypeKey:t="tokenType",userLocalStorageKey:n="user",tokenKey:i="accessToken",postContentType:s="application/json",...a})=>{const{apiURL:l=a.apiURL,libraries:v}=h.useContext(A),d=(a==null?void 0:a.axios)||(v==null?void 0:v.axios);if(!d)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!(d!=null&&d.defaults))return null;const u=localStorage.getItem(n),m=u?JSON.parse(u):null,R=m!=null&&m[t]?m[t]:null,_=m!=null&&m[i]?m[i]:null,C=u?`${R} ${_}`:null;return d.defaults.baseURL=l,d.defaults.headers.post["Content-Type"]=s,C&&(d.defaults.headers.common.Authorization=C),null},Be=({debug:t,resources:n,...i})=>{const{libraries:s}=h.useContext(A),a=(i==null?void 0:i.i18)||(s==null?void 0:s.i18),{i18next:l,initReactI18next:v,languageDetector:d}=a||{};if(!a)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(v).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},Ge=({dsn:t,integrations:n,tracesSampleRate:i,replaysSessionSampleRate:s,replaysOnErrorSampleRate:a,tracePropagationTargets:l,ignoreErrors:v,debug:d,environment:u,...m})=>{const{libraries:R}=h.useContext(A),_=(m==null?void 0:m.sentry)||(R==null?void 0:R.sentry),C=(m==null?void 0:m.reactRouter)||(R==null?void 0:R.reactRouter);if(!_)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!C)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(_.isInitialized())return null;const{createRoutesFromChildren:c,matchRoutes:S,useLocation:I,useNavigationType:x}=C;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&_.init({debug:d,dsn:t,environment:u||"production",ignoreErrors:[...v||[],/dynamically imported module/],integrations:[_.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:c,matchRoutes:S,useEffect:h.useEffect,useLocation:I,useNavigationType:x}),...n||[]],replaysOnErrorSampleRate:a||1,replaysSessionSampleRate:s||.1,tracePropagationTargets:l,tracesSampleRate:i||1}),null},Qe=({IMaskMixin:t,...n})=>{const i=h.useMemo(()=>t(({TextField:s,...a})=>F.jsx(s,{...a})),[t]);return F.jsx(i,{...n})},Je=({accessToken:t,...n})=>{const{libraries:i}=h.useContext(A),s=(n==null?void 0:n.mapbox)||(i==null?void 0:i.mapbox);if(!s)throw new Error("Mapbox is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return t&&(s.accessToken=t),null},Xe=({language:t,...n})=>{const{libraries:i}=h.useContext(A),s=(n==null?void 0:n.dayjs)||(i==null?void 0:i.dayjs),a=(n==null?void 0:n.plugin)||(i==null?void 0:i.dayjsPlugin);if(!s)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 v=t||((d=navigator.language)==null?void 0:d.slice(0,2))||"en";a&&a.forEach(u=>{u&&s.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),s.locale(v)})().then()},[s,a,t]),null},He=t=>t&&typeof t=="function",Ke=t=>t&&typeof t=="function",Ze=({children:t,defaultQueriesOptions:n,defaultMutationsOptions:i,...s})=>{var u,m;const{libraries:a}=h.useContext(A),l=(s==null?void 0:s.QueryClient)||((u=a==null?void 0:a.reactQuery)==null?void 0:u.QueryClient),v=(s==null?void 0:s.QueryClientProvider)||((m=a==null?void 0:a.reactQuery)==null?void 0:m.QueryClientProvider);if(!l)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!v)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!He(v))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ke(l))throw new Error("Provided QueryClient dependencies are not valid.");const d=new l({defaultOptions:{mutations:{...i},queries:{getNextPageParam:(R,_,C)=>R.length+(C||0),refetchOnWindowFocus:!1,retry:3,...n}}});return F.jsx(v,{client:d,children:t})},$e=t=>{var m,R,_;const{libraries:n}=h.useContext(A),i=(t==null?void 0:t.i18)||(n==null?void 0:n.i18),s=((m=t==null?void 0:t.i18)==null?void 0:m.translateFunction)||((R=n==null?void 0:n.i18)==null?void 0:R.translateFunction),a=((_=i==null?void 0:i.i18next)==null?void 0:_.t)||s||(C=>C),{unknownErrorTranslationKey:l="error.unknownError"}=t||{},v=a(l),d=h.useCallback(C=>{var S,I,x,k,b,N,L,M,j;const{response:c}=C||{};return c!=null&&c.reason?String(c.reason):(S=c==null?void 0:c.data)!=null&&S.reason?String(c.data.reason):(I=c==null?void 0:c.data)!=null&&I.message?String(c.data.message):(k=(x=c==null?void 0:c.data)==null?void 0:x.detail)!=null&&k.length&&Array.isArray((b=c==null?void 0:c.data)==null?void 0:b.detail)&&((L=(N=c==null?void 0:c.data)==null?void 0:N.detail[0])!=null&&L.msg)&&typeof((j=(M=c==null?void 0:c.data)==null?void 0:M.detail[0])==null?void 0:j.msg)=="string"?String(c.data.detail[0].msg):v},[v]);return{getErrorCode:h.useCallback(C=>{var S,I,x;const{response:c}=C||{};return c!=null&&c.error_code?String(c==null?void 0:c.error_code):(S=c==null?void 0:c.data)!=null&&S.error_code?String((I=c==null?void 0:c.data)==null?void 0:I.error_code):c!=null&&c.error_code?String(c==null?void 0:c.error_code):(x=c==null?void 0:c.data)!=null&&x.error_code?String(c.data.error_code):"unknown_error_code"},[]),printError:d}},qe=({data:t,fetchNextPage:n,isFetchingNextPage:i,isInitialLoading:s,isLoading:a,enabled:l=!0})=>{const v=h.useCallback(async u=>{i||!l||await n({pageParam:(u==null?void 0:u.pageParam)||u.visibleRowsCount})},[l,n,i]),d=h.useMemo(()=>{if(t)return t.pages.reduce((u,m)=>[...u,...m],[])},[t]);return{fetchNextPageOnRowsScrollEnd:v,isLoading:i||a,loadingVariant:s?"skeleton":"linear",rows:d}},et=t=>{const{libraries:n}=h.useContext(A),i=(t==null?void 0:t.axios)||(n==null?void 0:n.axios);if(!i)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");return{clearAuthenticationToken:()=>{i.defaults.headers.common.Authorization=null},setAuthenticationToken:({tokenType:l,accessToken:v})=>{i.defaults.headers.common.Authorization=`${l} ${v}`}}},fe=({library:t,date:n,format:i="ll"})=>t(n).format(i),de=(t,n="km")=>{const i=Number(t);return Number.isNaN(i)?`0 ${n}`:`${i.toFixed(2)} ${n}`},tt=t=>t!=null&&t.startsWith("/")?t!=null&&t.startsWith("/files")?t:`/files${t}`:t!=null&&t.startsWith("files")?`/${t}`:t!=null&&t.startsWith("files")?`/${t}`:`/files/${t}`,rt=({path:t,size:n,apiURL:i})=>{if(!t)return"";const s=tt(t),a=`${i}${s}`,l=a.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof n=="number"&&l?`${a.replace("/files",`/thumbs/${n}`)}`:a},nt=t=>{const{apiURL:n,libraries:i}=h.useContext(A),s=(t==null?void 0:t.dayjs)||(i==null?void 0:i.dayjs);return{dateAdapter:(v,d)=>{if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return fe({date:v,format:d,library:s})},distanceAdapter:de,filePathAdapter:(v,d)=>{if(!n)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return rt({apiURL:n,path:v,size:d})}}},ot=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),it=t=>{const s=t.split("/").filter(a=>a.length>0).map(a=>a.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return s.charAt(0).toLowerCase()+s.slice(1)},at=t=>(t.split("/").pop()||t).replace(/\.json$/,"").replace(/^openapi\./,""),ct=(t,n,i)=>{const s=it(n),a=ot(i);return`${s}${a}`},st=t=>{if(t)return(t==null?void 0:t.reduce((n,i)=>(n[i]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}},n),{}))||{}},ut=t=>(Array.isArray(t)?t:[t]).reduce((i,s)=>{const{output:a,operationsToGenerateInfiniteQueryHook:l,input:v="./openapi.json"}=s||{},d=at(v);return{...i,[d]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:v,output:{baseUrl:a==null?void 0:a.baseUrl,client:"react-query",mode:"tags-split",override:{...(l==null?void 0:l.length)&&{operations:st(l)},header:u=>["Generated by orval 🍺",...u.title?[u.title]:[],...u.description?[u.description]:[]],mutator:{name:"axiosCustomInstance",path:`${__dirname}/axiosCustomInstance.ts`},operationName:ct,query:{useQuery:!0}},schemas:(a==null?void 0:a.schemas)||`src/api/${d}/model`,target:(a==null?void 0:a.target)||`src/api/${d}/services/api.ts`,...a}}}},{});w.GTMSendPageView=Ve,w.InitializeAxiosConfig=Ue,w.InitializeDaysJSConfig=Xe,w.InitializeI18nConfig=Be,w.InitializeMapBoxConfig=Je,w.InitializeSentryConfig=Ge,w.InjectDependenciesContext=A,w.InjectDependenciesProvider=Me,w.MaskTextField=Qe,w.QueryClientProviderWithConfig=Ze,w.RequireAuth=ze,w.dateAdapter=fe,w.distanceAdapter=de,w.getOrvalConfig=ut,w.useAdapter=nt,w.useAuth=et,w.useInfiniteDataGrid=qe,w.useResponseError=$e,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tracktor/shared-module",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "types": "./dist/main.d.ts",