@tracktor/shared-module 2.14.4 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -3
- package/dist/hooks/useAdapter.d.ts +1 -1
- package/dist/hooks/useInfiniteDataGrid.d.ts +1 -1
- package/dist/main.cjs +3 -3
- package/dist/main.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -15,7 +15,7 @@ export declare const useAdapter: (params?: useAdapterParams) => {
|
|
|
15
15
|
fractionDigits?: number;
|
|
16
16
|
metric?: string;
|
|
17
17
|
}) => string;
|
|
18
|
-
filePathAdapter: (path?: string | null, size?: number | "full") => string;
|
|
18
|
+
filePathAdapter: (path?: string | null, size?: number | "full") => string | null | undefined;
|
|
19
19
|
worksiteNameAdapter: (name: unknown) => string;
|
|
20
20
|
};
|
|
21
21
|
export default useAdapter;
|
|
@@ -24,7 +24,7 @@ interface GridRowScrollEndParams {
|
|
|
24
24
|
declare const useInfiniteDataGrid: <T>({ data, fetchNextPage, isFetchingNextPage, isInitialLoading, isLoading, enabled, }: useInfiniteDataGridParams<T>) => {
|
|
25
25
|
fetchNextPageOnRowsScrollEnd: (params: GridRowScrollEndParams) => Promise<void>;
|
|
26
26
|
isLoading: boolean;
|
|
27
|
-
loadingVariant: "skeleton" | "linear";
|
|
27
|
+
loadingVariant: "skeleton" | "linear-progress";
|
|
28
28
|
rows: T | undefined;
|
|
29
29
|
};
|
|
30
30
|
export default useInfiniteDataGrid;
|
package/dist/main.cjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var H;function he(){if(H)return k;H=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(a,n,
|
|
9
|
+
*/var H;function he(){if(H)return k;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 k.Fragment=r,k.jsx=o,k.jsxs=o,k}var I={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Z;function ve(){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
|
|
17
|
+
*/var Z;function ve(){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,C,$,Y){return h=C.ref,t={$$typeof:y,type:t,key:f,props:C,_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,C,$,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
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
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,C,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"),ie=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),se=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,i)(),q=D(a(i)),K={};I.Fragment=p,I.jsx=function(t,f,h,w,P){var C=1e4>F.recentlyCreatedOwnerStacks++;return s(t,f,h,!1,w,P,C?Error("react-stack-top-frame"):J,C?D(a(t)):q)},I.jsxs=function(t,f,h,w,P){var C=1e4>F.recentlyCreatedOwnerStacks++;return s(t,f,h,!0,w,P,C?Error("react-stack-top-frame"):J,C?D(a(t)):q)}}()),I}var ee;function Ee(){return ee||(ee=1,process.env.NODE_ENV==="production"?N.exports=he():N.exports=ve()),N.exports}var _=Ee();const j=g.createContext({}),we=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=g.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return _.jsx(j.Provider,{value:n,children:e})},be="user",Re=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:i,localStorageKeys:c}=g.useContext(j),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,d=n?.localStorageKey||c?.user||be;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,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&&!s?_.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})},Se=({data:e,...r})=>{const{libraries:o}=g.useContext(j),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:i}=n,{useLocation:c,Outlet:u}=a,{pathname:l}=c(),{sendEvent:d}=i();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}})(),Ae="user",je=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:i,localStorageKeys:c}=g.useContext(j),u=a?.userLocalStorageKey||c?.user||Ae,l=a?.axios||i?.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),s=d?JSON.parse(d):null,v=s?.[e]?s[e]:null,m=s?.[r]?s[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},Ce=({debug:e,resources:r,...o})=>{const{libraries:a}=g.useContext(j),n=o?.i18||a?.i18,{i18next:i,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 i?.isInitialized||(i.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!==i.resolvedLanguage&&i.resolvedLanguage&&document.documentElement.setAttribute("lang",i.resolvedLanguage)}),i.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},_e=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:d,...s})=>{const{libraries:v}=g.useContext(j),m=s?.sentry||v?.sentry,y=s?.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:i,tracesSampleRate:o||1}),null},Pe=({IMaskMixin:e,...r})=>{const o=g.useMemo(()=>e(({TextField:a,...n})=>_.jsx(a,{...n})),[e]);return _.jsx(o,{...r})},Te=({language:e,...r})=>{const{libraries:o}=g.useContext(j),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},xe=()=>(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",Ie=e=>e&&typeof e=="function",Oe=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=g.useContext(j),i=a?.QueryClient||n?.reactQuery?.QueryClient,c=a?.QueryClientProvider||n?.reactQuery?.QueryClientProvider;if(!i)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(!Ie(i))throw new Error("Provided QueryClient dependencies are not valid.");const u=new i({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,d,s)=>l.length+(s||0),refetchOnWindowFocus:!1,retry:3,...r}}});return _.jsx(c,{client:u,children:e})},Ne=e=>{const{libraries:r}=g.useContext(j),o=e?.i18||r?.i18,a=e?.i18?.translateFunction||r?.i18?.translateFunction,n=o?.i18next?.t||a||(d=>d),{unknownErrorTranslationKey:i="error.unknownError"}=e||{},c=n(i),u=g.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:s}=d||{};if(s&&typeof s=="object"&&"reason"in s)return String(s.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"reason"in s.data)return String(s.data.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"message"in s.data)return String(s.data.message);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"detail"in s.data){const{detail:v}=s.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:s}=d||{};return s?.error_code?String(s?.error_code):s?.data?.error_code?String(s?.data?.error_code):s?.error_code?String(s?.error_code):s?.data?.error_code?String(s.data.error_code):"unknown_error_code"},[]),printError:u}},Le=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:i=!0})=>{const c=g.useCallback(async l=>{o||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,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",rows:u}},Fe=e=>{const{libraries:r}=g.useContext(j),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]),i=()=>{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:s}=JSON.parse(u);n({accessToken:d,tokenType:s})}catch(d){console.error("Failed to parse newValue from localStorage:",d)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,n]),{clearAuthenticationToken:i,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(" "),De=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,$e=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=De(e),n=`${o}${a}`,i=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&i?`${n.replace("/files",`/thumbs/${r}`)}`:n},Ye=e=>{const{apiURL:r,libraries:o}=g.useContext(j),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 $e({apiURL:r,path:c,size:u})},worksiteNameAdapter:oe}},L=(e,r)=>r==="short"?e.split("-")[0]:e,ze=(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=i=>{a(L(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Ue="tracktor.filter",Me={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},te=(e,r,o)=>`${o}_${e}=>${r}`,We=e=>{const{libraries:r,localStorageKeys:o}=g.useContext(j),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[i,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],u=o?.filter||Ue;if(O)return Me;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){i.delete(m),c(i),localStorage.removeItem(p);return}R&&y&&localStorage.setItem(p,JSON.stringify({...i,[m]:y})),y&&(i.set(m,JSON.stringify(y)),c(i))};return{getFilter:(m,y)=>{const R=i.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(i.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}},Qe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Ve=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)},Ge=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Je=(e,r,o,a)=>{const n=Ve(r),i=Qe(o),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},qe=(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},Ke=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json"}=a||{},l=Ge(u);return{...o,[l]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:qe(i,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,s,v)=>Je(d,s,v,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${l}/model`,target:n?.target||`src/api/${l}/services/api.ts`,...n}}}},{});exports.GTMSendPageView=Se;exports.InitializeAxiosConfig=je;exports.InitializeDaysJSConfig=Te;exports.InitializeI18nConfig=Ce;exports.InitializeSentryConfig=_e;exports.InjectDependenciesContext=j;exports.InjectDependenciesProvider=we;exports.MaskTextField=Pe;exports.PreloadErrorHandler=xe;exports.QueryClientProviderWithConfig=Oe;exports.RequireAuth=Re;exports.dateAdapter=re;exports.distanceAdapter=ne;exports.getOrvalConfig=Ke;exports.useAdapter=Ye;exports.useAuth=Fe;exports.useCurrentLanguage=ze;exports.useFilters=We;exports.useInfiniteDataGrid=Le;exports.useResponseError=Ne;exports.worksiteNameAdapter=oe;
|
|
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,C,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={};I.Fragment=p,I.jsx=function(t,f,h,w,P){var C=1e4>F.recentlyCreatedOwnerStacks++;return i(t,f,h,!1,w,P,C?Error("react-stack-top-frame"):J,C?D(a(t)):q)},I.jsxs=function(t,f,h,w,P){var C=1e4>F.recentlyCreatedOwnerStacks++;return i(t,f,h,!0,w,P,C?Error("react-stack-top-frame"):J,C?D(a(t)):q)}}()),I}var ee;function Ee(){return ee||(ee=1,process.env.NODE_ENV==="production"?N.exports=he():N.exports=ve()),N.exports}var _=Ee();const j=g.createContext({}),we=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=g.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return _.jsx(j.Provider,{value:n,children:e})},be="user",Re=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:s,localStorageKeys:c}=g.useContext(j),u=n?.reactRouter||s?.reactRouter,l=n?.axios||s?.axios,d=n?.localStorageKey||c?.user||be;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})},Se=({data:e,...r})=>{const{libraries:o}=g.useContext(j),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}})(),Ae="user",je=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:s,localStorageKeys:c}=g.useContext(j),u=a?.userLocalStorageKey||c?.user||Ae,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},Ce=({debug:e,resources:r,...o})=>{const{libraries:a}=g.useContext(j),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},_e=({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(j),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},Pe=({IMaskMixin:e,...r})=>{const o=g.useMemo(()=>e(({TextField:a,...n})=>_.jsx(a,{...n})),[e]);return _.jsx(o,{...r})},Te=({language:e,...r})=>{const{libraries:o}=g.useContext(j),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},xe=()=>(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",Ie=e=>e&&typeof e=="function",Oe=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=g.useContext(j),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(!Ie(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})},Ne=e=>{const{libraries:r}=g.useContext(j),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}},Le=({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}},Fe=e=>{const{libraries:r}=g.useContext(j),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(" "),De=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,$e=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=De(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},Ye=e=>{const{apiURL:r,libraries:o}=g.useContext(j),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/^https?:\/\//.test(String(c))?c:$e({apiURL:r,path:c,size:u})},worksiteNameAdapter:oe}},L=(e,r)=>r==="short"?e.split("-")[0]:e,ze=(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},Ue="tracktor.filter",Me={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},te=(e,r,o)=>`${o}_${e}=>${r}`,We=e=>{const{libraries:r,localStorageKeys:o}=g.useContext(j),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[s,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],u=o?.filter||Ue;if(O)return Me;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}},Qe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Ve=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)},Ge=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Je=(e,r,o,a)=>{const n=Ve(r),s=Qe(o),c=`${n}${s}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},qe=(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},Ke=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:s,useQueryIds:c,input:u="./openapi.json"}=a||{},l=Ge(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:qe(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)=>Je(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.GTMSendPageView=Se;exports.InitializeAxiosConfig=je;exports.InitializeDaysJSConfig=Te;exports.InitializeI18nConfig=Ce;exports.InitializeSentryConfig=_e;exports.InjectDependenciesContext=j;exports.InjectDependenciesProvider=we;exports.MaskTextField=Pe;exports.PreloadErrorHandler=xe;exports.QueryClientProviderWithConfig=Oe;exports.RequireAuth=Re;exports.dateAdapter=re;exports.distanceAdapter=ne;exports.getOrvalConfig=Ke;exports.useAdapter=Ye;exports.useAuth=Fe;exports.useCurrentLanguage=ze;exports.useFilters=We;exports.useInfiniteDataGrid=Le;exports.useResponseError=Ne;exports.worksiteNameAdapter=oe;
|
package/dist/main.js
CHANGED
|
@@ -524,7 +524,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
524
524
|
return {
|
|
525
525
|
fetchNextPageOnRowsScrollEnd: c,
|
|
526
526
|
isLoading: o || r,
|
|
527
|
-
loadingVariant: a ? "skeleton" : "linear",
|
|
527
|
+
loadingVariant: a ? "skeleton" : "linear-progress",
|
|
528
528
|
rows: u
|
|
529
529
|
};
|
|
530
530
|
}, Ge = (e) => {
|
|
@@ -584,7 +584,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
584
584
|
throw new Error(
|
|
585
585
|
"API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
|
|
586
586
|
);
|
|
587
|
-
return je({
|
|
587
|
+
return /^https?:\/\//.test(String(c)) ? c : je({
|
|
588
588
|
apiURL: n,
|
|
589
589
|
path: c,
|
|
590
590
|
size: u
|