@tracktor/shared-module 2.18.3 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/dist/axiosCustomInstance.ts +1 -1
- package/dist/main.d.ts +26 -26
- package/dist/main.js +259 -262
- package/dist/main.umd.cjs +2 -2
- package/dist/utils/adapter/dateAdapter.d.ts +3 -5
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
package/dist/main.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
export { axiosCustomInstance, type
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export { default as GTMSendPageView } from './components/Utils/GTMSendPageView';
|
|
1
|
+
export { axiosCustomInstance, type BodyType, type ErrorType } from './axios/axiosCustomInstance';
|
|
2
|
+
export * from './components/Inputs/MaskTextField';
|
|
3
|
+
export { default as MaskTextField } from './components/Inputs/MaskTextField';
|
|
5
4
|
export * from './components/Utils/GTMSendPageView';
|
|
6
|
-
export { default as
|
|
5
|
+
export { default as GTMSendPageView } from './components/Utils/GTMSendPageView';
|
|
7
6
|
export * from './components/Utils/InitializeAxiosConfig';
|
|
8
|
-
export { default as
|
|
7
|
+
export { default as InitializeAxiosConfig } from './components/Utils/InitializeAxiosConfig';
|
|
8
|
+
export * from './components/Utils/InitializeDaysJSConfig';
|
|
9
|
+
export { default as InitializeDaysJSConfig } from './components/Utils/InitializeDaysJSConfig';
|
|
9
10
|
export * from './components/Utils/InitializeI18nConfig';
|
|
10
|
-
export { default as
|
|
11
|
+
export { default as InitializeI18nConfig } from './components/Utils/InitializeI18nConfig';
|
|
11
12
|
export * from './components/Utils/InitializeSentryConfig';
|
|
12
|
-
export { default as
|
|
13
|
-
export * from './components/Inputs/MaskTextField';
|
|
14
|
-
export { default as InitializeDaysJSConfig } from './components/Utils/InitializeDaysJSConfig';
|
|
15
|
-
export * from './components/Utils/InitializeDaysJSConfig';
|
|
16
|
-
export { default as PreloadErrorHandler } from './components/Utils/PreloadErrorHandler';
|
|
13
|
+
export { default as InitializeSentryConfig } from './components/Utils/InitializeSentryConfig';
|
|
17
14
|
export * from './components/Utils/PreloadErrorHandler';
|
|
18
|
-
export { default as
|
|
15
|
+
export { default as PreloadErrorHandler } from './components/Utils/PreloadErrorHandler';
|
|
16
|
+
export * from './components/Utils/RequireAuth';
|
|
17
|
+
export { default as RequireAuth } from './components/Utils/RequireAuth';
|
|
19
18
|
export * from './components/Utils/UpdateNotifier';
|
|
20
|
-
export { default as
|
|
19
|
+
export { default as UpdateNotifier } from './components/Utils/UpdateNotifier';
|
|
20
|
+
export * from './config/orval';
|
|
21
|
+
export { default as getOrvalConfig } from './config/orval';
|
|
21
22
|
export * from './context/InjectDependenciesProvider';
|
|
22
|
-
export { default as
|
|
23
|
+
export { default as InjectDependenciesProvider } from './context/InjectDependenciesProvider';
|
|
23
24
|
export * from './context/QueryClientProviderWithConfig';
|
|
24
|
-
export { default as
|
|
25
|
-
export * from './hooks/useResponseError/useResponseError';
|
|
26
|
-
export { default as useInfiniteDataGrid } from './hooks/useInfiniteDataGrid';
|
|
27
|
-
export * from './hooks/useInfiniteDataGrid';
|
|
28
|
-
export { default as useAuth } from './hooks/useAuth';
|
|
29
|
-
export * from './hooks/useAuth';
|
|
30
|
-
export { default as useAdapter } from './hooks/useAdapter';
|
|
25
|
+
export { default as QueryClientProviderWithConfig } from './context/QueryClientProviderWithConfig';
|
|
31
26
|
export * from './hooks/useAdapter';
|
|
32
|
-
export { default as
|
|
27
|
+
export { default as useAdapter } from './hooks/useAdapter';
|
|
28
|
+
export * from './hooks/useAuth';
|
|
29
|
+
export { default as useAuth } from './hooks/useAuth';
|
|
33
30
|
export * from './hooks/useCurrentLanguage/useCurrentLanguage';
|
|
34
|
-
export { default as
|
|
31
|
+
export { default as useCurrentLanguage } from './hooks/useCurrentLanguage/useCurrentLanguage';
|
|
35
32
|
export * from './hooks/useFilters';
|
|
36
|
-
export { default as
|
|
37
|
-
export * from './
|
|
33
|
+
export { default as useFilters } from './hooks/useFilters';
|
|
34
|
+
export * from './hooks/useInfiniteDataGrid';
|
|
35
|
+
export { default as useInfiniteDataGrid } from './hooks/useInfiniteDataGrid';
|
|
36
|
+
export * from './hooks/useResponseError/useResponseError';
|
|
37
|
+
export { default as useResponseError } from './hooks/useResponseError/useResponseError';
|
|
38
38
|
export { default as dateAdapter } from './utils/adapter/dateAdapter';
|
|
39
39
|
export { default as distanceAdapter } from './utils/adapter/distanceAdapter';
|
|
40
40
|
export { default as worksiteNameAdapter } from './utils/adapter/worksiteNameAdapter/worksiteNameAdapter';
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ee from "axios";
|
|
2
|
-
import fe, {
|
|
2
|
+
import fe, { useMemo as G, createContext as pe, useContext as j, useEffect as k, useState as W, useRef as ae, Suspense as ge, useCallback as N } from "react";
|
|
3
3
|
const Ye = (e, r) => {
|
|
4
4
|
const o = ee.CancelToken.source(), a = ee({
|
|
5
5
|
...e,
|
|
@@ -25,19 +25,19 @@ function me() {
|
|
|
25
25
|
if (te) return L;
|
|
26
26
|
te = 1;
|
|
27
27
|
var e = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
|
|
28
|
-
function o(a, n,
|
|
28
|
+
function o(a, n, i) {
|
|
29
29
|
var c = null;
|
|
30
|
-
if (
|
|
31
|
-
|
|
30
|
+
if (i !== void 0 && (c = "" + i), n.key !== void 0 && (c = "" + n.key), "key" in n) {
|
|
31
|
+
i = {};
|
|
32
32
|
for (var u in n)
|
|
33
|
-
u !== "key" && (
|
|
34
|
-
} else
|
|
35
|
-
return n =
|
|
33
|
+
u !== "key" && (i[u] = n[u]);
|
|
34
|
+
} else i = n;
|
|
35
|
+
return n = i.ref, {
|
|
36
36
|
$$typeof: e,
|
|
37
37
|
type: a,
|
|
38
38
|
key: c,
|
|
39
39
|
ref: n !== void 0 ? n : null,
|
|
40
|
-
props:
|
|
40
|
+
props: i
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
return L.Fragment = r, L.jsx = o, L.jsxs = o, L;
|
|
@@ -69,7 +69,7 @@ function he() {
|
|
|
69
69
|
return "StrictMode";
|
|
70
70
|
case P:
|
|
71
71
|
return "Suspense";
|
|
72
|
-
case
|
|
72
|
+
case se:
|
|
73
73
|
return "SuspenseList";
|
|
74
74
|
case ce:
|
|
75
75
|
return "Activity";
|
|
@@ -87,7 +87,7 @@ function he() {
|
|
|
87
87
|
case w:
|
|
88
88
|
var f = t.render;
|
|
89
89
|
return t = t.displayName, t || (t = f.displayName || f.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
90
|
-
case
|
|
90
|
+
case ie:
|
|
91
91
|
return f = t.displayName || null, f !== null ? f : e(t.type) || "Memo";
|
|
92
92
|
case J:
|
|
93
93
|
f = t._payload, t = t._init;
|
|
@@ -133,7 +133,7 @@ function he() {
|
|
|
133
133
|
var t = z.A;
|
|
134
134
|
return t === null ? null : t.getOwner();
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function i() {
|
|
137
137
|
return Error("react-stack-top-frame");
|
|
138
138
|
}
|
|
139
139
|
function c(t) {
|
|
@@ -193,7 +193,7 @@ function he() {
|
|
|
193
193
|
value: V
|
|
194
194
|
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function s(t, f, v, E, I, T, Q, V) {
|
|
197
197
|
var R = f.children;
|
|
198
198
|
if (R !== void 0)
|
|
199
199
|
if (E)
|
|
@@ -246,7 +246,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
246
246
|
function h(t) {
|
|
247
247
|
typeof t == "object" && t !== null && t.$$typeof === b && t._store && (t._store.validated = 1);
|
|
248
248
|
}
|
|
249
|
-
var p = fe, b = Symbol.for("react.transitional.element"), x = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), g = Symbol.for("react.context"), w = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"),
|
|
249
|
+
var p = fe, b = Symbol.for("react.transitional.element"), x = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), g = Symbol.for("react.context"), w = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), se = Symbol.for("react.suspense_list"), ie = Symbol.for("react.memo"), J = Symbol.for("react.lazy"), ce = Symbol.for("react.activity"), le = Symbol.for("react.client.reference"), z = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = Object.prototype.hasOwnProperty, ue = Array.isArray, U = console.createTask ? console.createTask : function() {
|
|
250
250
|
return null;
|
|
251
251
|
};
|
|
252
252
|
p = {
|
|
@@ -256,11 +256,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
256
256
|
};
|
|
257
257
|
var q, B = {}, H = p["react-stack-bottom-frame"].bind(
|
|
258
258
|
p,
|
|
259
|
-
|
|
260
|
-
)(), X = U(a(
|
|
259
|
+
i
|
|
260
|
+
)(), X = U(a(i)), Z = {};
|
|
261
261
|
F.Fragment = A, F.jsx = function(t, f, v, E, I) {
|
|
262
262
|
var T = 1e4 > z.recentlyCreatedOwnerStacks++;
|
|
263
|
-
return
|
|
263
|
+
return s(
|
|
264
264
|
t,
|
|
265
265
|
f,
|
|
266
266
|
v,
|
|
@@ -272,7 +272,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
272
272
|
);
|
|
273
273
|
}, F.jsxs = function(t, f, v, E, I) {
|
|
274
274
|
var T = 1e4 > z.recentlyCreatedOwnerStacks++;
|
|
275
|
-
return
|
|
275
|
+
return s(
|
|
276
276
|
t,
|
|
277
277
|
f,
|
|
278
278
|
v,
|
|
@@ -290,7 +290,14 @@ function ye() {
|
|
|
290
290
|
return ne || (ne = 1, process.env.NODE_ENV === "production" ? D.exports = me() : D.exports = he()), D.exports;
|
|
291
291
|
}
|
|
292
292
|
var C = ye();
|
|
293
|
-
const
|
|
293
|
+
const We = ({ IMaskMixin: e, ...r }) => {
|
|
294
|
+
const o = G(
|
|
295
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
296
|
+
() => e(({ TextField: a, ...n }) => /* @__PURE__ */ C.jsx(a, { ...n })),
|
|
297
|
+
[e]
|
|
298
|
+
);
|
|
299
|
+
return /* @__PURE__ */ C.jsx(o, { ...r });
|
|
300
|
+
}, S = pe({}), ze = ({ children: e, apiURL: r, libraries: o, localStorageKeys: a }) => {
|
|
294
301
|
const n = G(
|
|
295
302
|
() => ({
|
|
296
303
|
apiURL: r,
|
|
@@ -300,17 +307,6 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
300
307
|
[r, o, a]
|
|
301
308
|
);
|
|
302
309
|
return /* @__PURE__ */ C.jsx(S.Provider, { value: n, children: e });
|
|
303
|
-
}, ve = "user", ze = ({ Fallback: e, isLogged: r, loginPath: o = "/login", redirect401Path: a = "/login", ...n }) => {
|
|
304
|
-
const { libraries: s, localStorageKeys: c } = j(S), u = n?.reactRouter || s?.reactRouter, l = n?.axios || s?.axios, d = n?.localStorageKey || c?.user || ve;
|
|
305
|
-
if (!u)
|
|
306
|
-
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
307
|
-
const [i, h] = W(null), { useLocation: p, Navigate: b, Outlet: x } = u, A = p(), m = ae(!1), y = typeof r == "function" ? r() : !!r, _ = typeof y == "boolean" ? y : y?.isLogged;
|
|
308
|
-
return k(() => {
|
|
309
|
-
m.current || (m.current = !0, l.interceptors.response.use(
|
|
310
|
-
(g) => g,
|
|
311
|
-
async (g) => (typeof g == "object" && g && "response" in g && g.response && typeof g.response == "object" && "status" in g.response && g.response && typeof g.response == "object" && "status" in g.response && g?.response?.status === 401 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(d), h(a)), Promise.reject(g))
|
|
312
|
-
));
|
|
313
|
-
}, [l.defaults.headers.common, l.interceptors.response, d, a]), _ && !i ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: A.state?.from?.state && A.state?.from?.pathname === o ? /* @__PURE__ */ C.jsx(b, { to: A.state.from.state.from.pathname + A.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(x, {}) }) : /* @__PURE__ */ C.jsx(b, { to: o + A.search, state: { from: A }, replace: !0 });
|
|
314
310
|
}, Ue = ({ data: e, ...r }) => {
|
|
315
311
|
const { libraries: o } = j(S), a = r?.reactRouter || o?.reactRouter, n = r?.gtm || o?.gtm;
|
|
316
312
|
if (!a)
|
|
@@ -319,7 +315,7 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
319
315
|
);
|
|
320
316
|
if (!n)
|
|
321
317
|
throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
|
|
322
|
-
const { useGoogleTagManager:
|
|
318
|
+
const { useGoogleTagManager: i } = n, { useLocation: c, Outlet: u } = a, { pathname: l } = c(), { sendEvent: d } = i();
|
|
323
319
|
return k(() => {
|
|
324
320
|
d({
|
|
325
321
|
event: "pageView",
|
|
@@ -335,29 +331,43 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
335
331
|
} catch {
|
|
336
332
|
return !1;
|
|
337
333
|
}
|
|
338
|
-
})(),
|
|
334
|
+
})(), ve = "user", Qe = ({
|
|
339
335
|
tokenTypeKey: e = "tokenType",
|
|
340
336
|
tokenKey: r = "accessToken",
|
|
341
337
|
postContentType: o = "application/json",
|
|
342
338
|
...a
|
|
343
339
|
}) => {
|
|
344
|
-
const { apiURL: n = a.apiURL, libraries:
|
|
340
|
+
const { apiURL: n = a.apiURL, libraries: i, localStorageKeys: c } = j(S), u = a?.userLocalStorageKey || c?.user || ve, l = a?.axios || i?.axios;
|
|
345
341
|
if (!l)
|
|
346
342
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
347
343
|
if (!l?.defaults || $)
|
|
348
344
|
return null;
|
|
349
345
|
if (typeof window < "u" && window.localStorage) {
|
|
350
|
-
const d = localStorage.getItem(u),
|
|
346
|
+
const d = localStorage.getItem(u), s = d ? JSON.parse(d) : null, h = s?.[e] ? s[e] : null, p = s?.[r] ? s[r] : null, b = d ? `${h} ${p}` : null;
|
|
351
347
|
b && (l.defaults.headers.common.Authorization = b);
|
|
352
348
|
}
|
|
353
349
|
return l.defaults.baseURL = n, l.defaults.headers.post["Content-Type"] = o, null;
|
|
354
|
-
}, Ve = ({
|
|
355
|
-
const { libraries:
|
|
350
|
+
}, Ve = ({ language: e, ...r }) => {
|
|
351
|
+
const { libraries: o } = j(S), a = r?.dayjs || o?.dayjs, n = r?.plugin || o?.dayjsPlugin;
|
|
352
|
+
if (!a)
|
|
353
|
+
throw new Error(
|
|
354
|
+
"Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
|
|
355
|
+
);
|
|
356
|
+
return k(() => {
|
|
357
|
+
(async () => {
|
|
358
|
+
const c = e || navigator.language?.slice(0, 2) || "en";
|
|
359
|
+
n && n.forEach((u) => {
|
|
360
|
+
u && a.extend(u);
|
|
361
|
+
}), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), a.locale(c);
|
|
362
|
+
})().then();
|
|
363
|
+
}, [a, n, e]), null;
|
|
364
|
+
}, Me = ({ debug: e, resources: r, ...o }) => {
|
|
365
|
+
const { libraries: a } = j(S), n = o?.i18 || a?.i18, { i18next: i, initReactI18next: c, languageDetector: u } = n || {};
|
|
356
366
|
if ($)
|
|
357
367
|
return null;
|
|
358
368
|
if (!n)
|
|
359
369
|
throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
360
|
-
return
|
|
370
|
+
return i?.isInitialized || (i.use(u).use(c).init({
|
|
361
371
|
debug: e,
|
|
362
372
|
fallbackLng: "en",
|
|
363
373
|
interpolation: {
|
|
@@ -371,24 +381,24 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
371
381
|
resources: r,
|
|
372
382
|
returnNull: !1
|
|
373
383
|
}).then(() => {
|
|
374
|
-
document.documentElement.lang !==
|
|
375
|
-
}),
|
|
384
|
+
document.documentElement.lang !== i.resolvedLanguage && i.resolvedLanguage && document.documentElement.setAttribute("lang", i.resolvedLanguage);
|
|
385
|
+
}), i.on("languageChanged", (l) => {
|
|
376
386
|
document.documentElement.setAttribute("lang", l);
|
|
377
387
|
})), null;
|
|
378
|
-
},
|
|
388
|
+
}, Ge = ({
|
|
379
389
|
dsn: e,
|
|
380
390
|
integrations: r,
|
|
381
391
|
tracesSampleRate: o,
|
|
382
392
|
replaysSessionSampleRate: a,
|
|
383
393
|
replaysOnErrorSampleRate: n,
|
|
384
|
-
tracePropagationTargets:
|
|
394
|
+
tracePropagationTargets: i,
|
|
385
395
|
ignoreErrors: c,
|
|
386
396
|
debug: u,
|
|
387
397
|
environment: l,
|
|
388
398
|
release: d,
|
|
389
|
-
...
|
|
399
|
+
...s
|
|
390
400
|
}) => {
|
|
391
|
-
const { libraries: h } = j(S), p =
|
|
401
|
+
const { libraries: h } = j(S), p = s?.sentry || h?.sentry, b = s?.reactRouter || h?.reactRouter;
|
|
392
402
|
if (!p)
|
|
393
403
|
throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
394
404
|
if (!b)
|
|
@@ -422,31 +432,10 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
422
432
|
release: d,
|
|
423
433
|
replaysOnErrorSampleRate: n || 1,
|
|
424
434
|
replaysSessionSampleRate: a || 0.1,
|
|
425
|
-
tracePropagationTargets:
|
|
435
|
+
tracePropagationTargets: i,
|
|
426
436
|
tracesSampleRate: o || 1
|
|
427
437
|
}), null;
|
|
428
|
-
},
|
|
429
|
-
const o = G(
|
|
430
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
431
|
-
() => e(({ TextField: a, ...n }) => /* @__PURE__ */ C.jsx(a, { ...n })),
|
|
432
|
-
[e]
|
|
433
|
-
);
|
|
434
|
-
return /* @__PURE__ */ C.jsx(o, { ...r });
|
|
435
|
-
}, Je = ({ language: e, ...r }) => {
|
|
436
|
-
const { libraries: o } = j(S), a = r?.dayjs || o?.dayjs, n = r?.plugin || o?.dayjsPlugin;
|
|
437
|
-
if (!a)
|
|
438
|
-
throw new Error(
|
|
439
|
-
"Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
|
|
440
|
-
);
|
|
441
|
-
return k(() => {
|
|
442
|
-
(async () => {
|
|
443
|
-
const c = e || navigator.language?.slice(0, 2) || "en";
|
|
444
|
-
n && n.forEach((u) => {
|
|
445
|
-
u && a.extend(u);
|
|
446
|
-
}), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), a.locale(c);
|
|
447
|
-
})().then();
|
|
448
|
-
}, [a, n, e]), null;
|
|
449
|
-
}, Ke = () => (k(() => {
|
|
438
|
+
}, Je = () => (k(() => {
|
|
450
439
|
if ($)
|
|
451
440
|
return;
|
|
452
441
|
const e = (r) => {
|
|
@@ -458,7 +447,18 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
458
447
|
return window.addEventListener("vite:preloadError", e), () => {
|
|
459
448
|
window.removeEventListener("vite:preloadError", e);
|
|
460
449
|
};
|
|
461
|
-
}, []), null),
|
|
450
|
+
}, []), null), we = "user", Ke = ({ Fallback: e, isLogged: r, loginPath: o = "/login", redirect401Path: a = "/login", ...n }) => {
|
|
451
|
+
const { libraries: i, localStorageKeys: c } = j(S), u = n?.reactRouter || i?.reactRouter, l = n?.axios || i?.axios, d = n?.localStorageKey || c?.user || we;
|
|
452
|
+
if (!u)
|
|
453
|
+
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
454
|
+
const [s, h] = W(null), { useLocation: p, Navigate: b, Outlet: x } = u, A = p(), m = ae(!1), y = typeof r == "function" ? r() : !!r, _ = typeof y == "boolean" ? y : y?.isLogged;
|
|
455
|
+
return k(() => {
|
|
456
|
+
m.current || (m.current = !0, l.interceptors.response.use(
|
|
457
|
+
(g) => g,
|
|
458
|
+
async (g) => (typeof g == "object" && g && "response" in g && g.response && typeof g.response == "object" && "status" in g.response && g.response && typeof g.response == "object" && "status" in g.response && g?.response?.status === 401 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(d), h(a)), Promise.reject(g))
|
|
459
|
+
));
|
|
460
|
+
}, [l.defaults.headers.common, l.interceptors.response, d, a]), _ && !s ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: A.state?.from?.state && A.state?.from?.pathname === o ? /* @__PURE__ */ C.jsx(b, { to: A.state.from.state.from.pathname + A.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(x, {}) }) : /* @__PURE__ */ C.jsx(b, { to: o + A.search, state: { from: A }, replace: !0 });
|
|
461
|
+
}, Ee = async () => {
|
|
462
462
|
if ("caches" in window)
|
|
463
463
|
try {
|
|
464
464
|
const e = await caches.keys();
|
|
@@ -467,7 +467,7 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
467
467
|
console.error("Failed to clear caches:", e);
|
|
468
468
|
}
|
|
469
469
|
}, qe = ({ autoUpdate: e, renderDialog: r, clearCachesOnReload: o }) => {
|
|
470
|
-
const a = ae(null), [n,
|
|
470
|
+
const a = ae(null), [n, i] = W(!1), c = N(async () => {
|
|
471
471
|
a.current && a.current.postMessage({ type: "SKIP_WAITING" }), o && await Ee(), window.location.reload();
|
|
472
472
|
}, [o]), u = N(async () => {
|
|
473
473
|
window.confirm("A new version is available. The app will reload now.") && await c();
|
|
@@ -475,16 +475,16 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
475
475
|
return k(() => {
|
|
476
476
|
if (!("serviceWorker" in navigator)) return;
|
|
477
477
|
let l, d;
|
|
478
|
-
const
|
|
479
|
-
p && navigator.serviceWorker.controller && (a.current = p,
|
|
478
|
+
const s = (p) => {
|
|
479
|
+
p && navigator.serviceWorker.controller && (a.current = p, i(!0));
|
|
480
480
|
}, h = () => {
|
|
481
481
|
const p = l?.installing;
|
|
482
482
|
p && (d = () => {
|
|
483
|
-
p.state === "installed" &&
|
|
483
|
+
p.state === "installed" && s(p);
|
|
484
484
|
}, p.addEventListener("statechange", d));
|
|
485
485
|
};
|
|
486
486
|
return (async () => {
|
|
487
|
-
l = await navigator.serviceWorker.getRegistration(), l && (
|
|
487
|
+
l = await navigator.serviceWorker.getRegistration(), l && (s(l.waiting), l.addEventListener("updatefound", h));
|
|
488
488
|
})().catch(console.error), () => {
|
|
489
489
|
l?.removeEventListener("updatefound", h), d && l?.installing && l.installing.removeEventListener("statechange", d);
|
|
490
490
|
};
|
|
@@ -493,28 +493,88 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
493
493
|
}, [e, n, c]), k(() => {
|
|
494
494
|
n && !e && !r && u().catch(console.error);
|
|
495
495
|
}, [r, u, n, e]), n && !e && r ? r(c) : null;
|
|
496
|
-
}, Re = (e) => e
|
|
496
|
+
}, Re = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), be = (e) => {
|
|
497
|
+
const r = e.split(/[/\\]/).pop() || "";
|
|
498
|
+
return r.substring(0, r.lastIndexOf("."));
|
|
499
|
+
}, Ae = (e) => {
|
|
500
|
+
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("");
|
|
501
|
+
return a.charAt(0).toLowerCase() + a.slice(1);
|
|
502
|
+
}, Se = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), je = (e, r, o, a) => {
|
|
503
|
+
const n = Ae(r), i = Re(o), c = `${n}${i}`;
|
|
504
|
+
return e && typeof e == "object" && "operationId" in e && a?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
|
|
505
|
+
}, _e = (e, r) => {
|
|
506
|
+
const o = {};
|
|
507
|
+
return e?.forEach((a) => {
|
|
508
|
+
o[a] = {
|
|
509
|
+
query: {
|
|
510
|
+
useInfinite: !0,
|
|
511
|
+
useInfiniteQueryParam: "offset",
|
|
512
|
+
useQuery: !0
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
}), r?.filter((a) => !o[a]).forEach((a) => {
|
|
516
|
+
o[a] = {
|
|
517
|
+
query: {
|
|
518
|
+
useQuery: !0
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
}), Object.keys(o).length ? o : void 0;
|
|
522
|
+
}, Be = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
|
|
523
|
+
const { output: n, useInfiniteIds: i, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: d } = a || {}, s = d || Se(u), h = l || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
|
|
524
|
+
return {
|
|
525
|
+
...o,
|
|
526
|
+
[s]: {
|
|
527
|
+
input: u,
|
|
528
|
+
output: {
|
|
529
|
+
baseUrl: n?.baseUrl,
|
|
530
|
+
client: "react-query",
|
|
531
|
+
mode: "tags-split",
|
|
532
|
+
override: {
|
|
533
|
+
...(i?.length || c?.length) && {
|
|
534
|
+
operations: _e(i, c)
|
|
535
|
+
},
|
|
536
|
+
header: (p) => [
|
|
537
|
+
"Generated by orval 🍺",
|
|
538
|
+
...p.title ? [p.title] : [],
|
|
539
|
+
...p.description ? [p.description] : []
|
|
540
|
+
],
|
|
541
|
+
mutator: {
|
|
542
|
+
name: be(h),
|
|
543
|
+
path: h
|
|
544
|
+
},
|
|
545
|
+
operationName: (p, b, x) => je(p, b, x, c),
|
|
546
|
+
query: {
|
|
547
|
+
useQuery: !0
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
schemas: n?.schemas || `src/api/${s}/model`,
|
|
551
|
+
target: n?.target || `src/api/${s}/services/api.ts`,
|
|
552
|
+
...n
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
}, {}), Pe = (e) => e && typeof e == "function", Te = (e) => e && typeof e == "function", He = ({
|
|
497
557
|
children: e,
|
|
498
558
|
defaultQueriesOptions: r,
|
|
499
559
|
defaultMutationsOptions: o,
|
|
500
560
|
...a
|
|
501
561
|
}) => {
|
|
502
|
-
const { libraries: n } = j(S),
|
|
503
|
-
if (!
|
|
562
|
+
const { libraries: n } = j(S), i = a?.QueryClient || n?.reactQuery?.QueryClient, c = a?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
|
|
563
|
+
if (!i)
|
|
504
564
|
throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
505
565
|
if (!c)
|
|
506
566
|
throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
507
|
-
if (!
|
|
567
|
+
if (!Pe(c))
|
|
508
568
|
throw new Error("Provided QueryClientProvider dependencies are not valid.");
|
|
509
|
-
if (!
|
|
569
|
+
if (!Te(i))
|
|
510
570
|
throw new Error("Provided QueryClient dependencies are not valid.");
|
|
511
|
-
const u = new
|
|
571
|
+
const u = new i({
|
|
512
572
|
defaultOptions: {
|
|
513
573
|
mutations: {
|
|
514
574
|
...o
|
|
515
575
|
},
|
|
516
576
|
queries: {
|
|
517
|
-
getNextPageParam: (l, d,
|
|
577
|
+
getNextPageParam: (l, d, s) => l.length + (s || 0),
|
|
518
578
|
refetchOnWindowFocus: !1,
|
|
519
579
|
retry: 3,
|
|
520
580
|
...r
|
|
@@ -522,56 +582,39 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
522
582
|
}
|
|
523
583
|
});
|
|
524
584
|
return /* @__PURE__ */ C.jsx(c, { client: u, children: e });
|
|
525
|
-
},
|
|
526
|
-
const {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
return d instanceof Error ? d.message : c;
|
|
585
|
+
}, ke = ({ library: e, date: r, format: o = "ll" }) => e(r).format(o), Ce = (e, r) => {
|
|
586
|
+
const { fractionDigits: o = 0, metric: a = "km", spacingBetween: n = !0 } = r || {}, i = Number(e), c = n ? " " : "";
|
|
587
|
+
return Number.isNaN(i) ? `0${c}${a}` : `${i.toFixed(o)}${c}${a}`;
|
|
588
|
+
}, xe = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "), Ie = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Oe = ({ path: e, size: r, apiURL: o }) => {
|
|
589
|
+
if (!e)
|
|
590
|
+
return "";
|
|
591
|
+
const a = Ie(e), n = `${o}${a}`, i = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
592
|
+
return typeof r == "number" && i ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
|
|
593
|
+
}, Xe = (e) => {
|
|
594
|
+
const { apiURL: r, libraries: o } = j(S), a = e?.dayjs || o?.dayjs;
|
|
595
|
+
return {
|
|
596
|
+
dateAdapter: (c, u) => {
|
|
597
|
+
if (!a)
|
|
598
|
+
throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
599
|
+
return ke({
|
|
600
|
+
date: c,
|
|
601
|
+
format: u,
|
|
602
|
+
library: a
|
|
603
|
+
});
|
|
546
604
|
},
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
isLoading: n,
|
|
559
|
-
enabled: s = !0
|
|
560
|
-
}) => {
|
|
561
|
-
const c = N(
|
|
562
|
-
async (l) => {
|
|
563
|
-
o || !s || await r({ pageParam: l?.pageParam || l.visibleRowsCount });
|
|
605
|
+
distanceAdapter: Ce,
|
|
606
|
+
filePathAdapter: (c, u) => {
|
|
607
|
+
if (!r)
|
|
608
|
+
throw new Error(
|
|
609
|
+
"API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
|
|
610
|
+
);
|
|
611
|
+
return typeof c == "string" && /^https?:\/\//.test(c) ? c : Oe({
|
|
612
|
+
apiURL: r,
|
|
613
|
+
path: c,
|
|
614
|
+
size: u
|
|
615
|
+
});
|
|
564
616
|
},
|
|
565
|
-
|
|
566
|
-
), u = G(() => {
|
|
567
|
-
if (e)
|
|
568
|
-
return e.pages.reduce((l, d) => [...l, ...d], []);
|
|
569
|
-
}, [e]);
|
|
570
|
-
return {
|
|
571
|
-
fetchNextPageOnRowsScrollEnd: c,
|
|
572
|
-
isLoading: o || n,
|
|
573
|
-
loadingVariant: a ? "skeleton" : "linear-progress",
|
|
574
|
-
rows: u
|
|
617
|
+
worksiteNameAdapter: xe
|
|
575
618
|
};
|
|
576
619
|
}, Ze = (e) => {
|
|
577
620
|
const { libraries: r } = j(S), o = e?.axios || r?.axios, a = e?.localStorageKey || "user";
|
|
@@ -582,7 +625,7 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
582
625
|
o.defaults.headers.common.Authorization = `${c} ${u}`;
|
|
583
626
|
},
|
|
584
627
|
[o.defaults.headers.common]
|
|
585
|
-
),
|
|
628
|
+
), i = () => {
|
|
586
629
|
o.defaults.headers.common.Authorization = null;
|
|
587
630
|
};
|
|
588
631
|
return k(() => {
|
|
@@ -591,8 +634,8 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
591
634
|
const c = ({ newValue: u, key: l }) => {
|
|
592
635
|
if (l === a && u)
|
|
593
636
|
try {
|
|
594
|
-
const { accessToken: d, tokenType:
|
|
595
|
-
n({ accessToken: d, tokenType:
|
|
637
|
+
const { accessToken: d, tokenType: s } = JSON.parse(u);
|
|
638
|
+
n({ accessToken: d, tokenType: s });
|
|
596
639
|
} catch (d) {
|
|
597
640
|
console.error("Failed to parse newValue from localStorage:", d);
|
|
598
641
|
}
|
|
@@ -601,58 +644,24 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
601
644
|
window.removeEventListener("storage", c);
|
|
602
645
|
};
|
|
603
646
|
}, [a, n]), {
|
|
604
|
-
clearAuthenticationToken:
|
|
647
|
+
clearAuthenticationToken: i,
|
|
605
648
|
setAuthenticationToken: n
|
|
606
649
|
};
|
|
607
|
-
},
|
|
608
|
-
const { fractionDigits: o = 0, metric: a = "km", spacingBetween: n = !0 } = r || {}, s = Number(e), c = n ? " " : "";
|
|
609
|
-
return Number.isNaN(s) ? `0${c}${a}` : `${s.toFixed(o)}${c}${a}`;
|
|
610
|
-
}, je = (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}`, Pe = ({ path: e, size: r, apiURL: o }) => {
|
|
611
|
-
if (!e)
|
|
612
|
-
return "";
|
|
613
|
-
const a = _e(e), n = `${o}${a}`, s = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
614
|
-
return typeof r == "number" && s ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
|
|
615
|
-
}, et = (e) => {
|
|
616
|
-
const { apiURL: r, libraries: o } = j(S), a = e?.dayjs || o?.dayjs;
|
|
617
|
-
return {
|
|
618
|
-
dateAdapter: (c, u) => {
|
|
619
|
-
if (!a)
|
|
620
|
-
throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
621
|
-
return Ae({
|
|
622
|
-
date: c,
|
|
623
|
-
format: u,
|
|
624
|
-
library: a
|
|
625
|
-
});
|
|
626
|
-
},
|
|
627
|
-
distanceAdapter: Se,
|
|
628
|
-
filePathAdapter: (c, u) => {
|
|
629
|
-
if (!r)
|
|
630
|
-
throw new Error(
|
|
631
|
-
"API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
|
|
632
|
-
);
|
|
633
|
-
return typeof c == "string" && /^https?:\/\//.test(c) ? c : Pe({
|
|
634
|
-
apiURL: r,
|
|
635
|
-
path: c,
|
|
636
|
-
size: u
|
|
637
|
-
});
|
|
638
|
-
},
|
|
639
|
-
worksiteNameAdapter: je
|
|
640
|
-
};
|
|
641
|
-
}, Y = (e, r) => r === "short" ? e.split("-")[0] : e, tt = (e, r = "full") => {
|
|
650
|
+
}, Y = (e, r) => r === "short" ? e.split("-")[0] : e, et = (e, r = "full") => {
|
|
642
651
|
const [o, a] = W(() => {
|
|
643
652
|
const n = e?.language || navigator.language;
|
|
644
653
|
return e && "isInitialized" in e && e.isInitialized, Y(n, r);
|
|
645
654
|
});
|
|
646
655
|
return k(() => {
|
|
647
656
|
e && "isInitialized" in e && e.isInitialized && e.language && a(Y(e.language, r));
|
|
648
|
-
const n = (
|
|
649
|
-
a(Y(
|
|
657
|
+
const n = (i) => {
|
|
658
|
+
a(Y(i, r));
|
|
650
659
|
};
|
|
651
660
|
return e?.on?.("languageChanged", n), () => {
|
|
652
661
|
e?.off?.("languageChanged", n);
|
|
653
662
|
};
|
|
654
663
|
}, [e, r]), o;
|
|
655
|
-
},
|
|
664
|
+
}, Ne = "tracktor.filter", Le = {
|
|
656
665
|
getFilter: () => {
|
|
657
666
|
},
|
|
658
667
|
getFilters: () => ({}),
|
|
@@ -660,20 +669,20 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
660
669
|
},
|
|
661
670
|
setFilter: () => {
|
|
662
671
|
}
|
|
663
|
-
}, oe = (e, r, o) => `${o}_${e}=>${r}`,
|
|
672
|
+
}, oe = (e, r, o) => `${o}_${e}=>${r}`, Fe = (e) => e.reduce((r, o) => {
|
|
664
673
|
const a = localStorage.getItem(o);
|
|
665
674
|
if (a)
|
|
666
675
|
try {
|
|
667
|
-
const n = JSON.parse(a),
|
|
668
|
-
|
|
676
|
+
const n = JSON.parse(a), i = Object.keys(n)?.[0];
|
|
677
|
+
i && (r[i] = Object.values(n)?.[0]);
|
|
669
678
|
} catch {
|
|
670
679
|
}
|
|
671
680
|
return r;
|
|
672
|
-
}, {}),
|
|
673
|
-
const { libraries: r, localStorageKeys: o } = j(S), a = e?.reactRouter || r?.reactRouter, { pathname: n } = a?.useLocation?.() ?? { pathname: "/" }, [
|
|
674
|
-
}], [u, l] = W({}), d = o?.filter ||
|
|
681
|
+
}, {}), tt = (e) => {
|
|
682
|
+
const { libraries: r, localStorageKeys: o } = j(S), a = e?.reactRouter || r?.reactRouter, { pathname: n } = a?.useLocation?.() ?? { pathname: "/" }, [i, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
|
|
683
|
+
}], [u, l] = W({}), d = o?.filter || Ne, s = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl;
|
|
675
684
|
if ($)
|
|
676
|
-
return
|
|
685
|
+
return Le;
|
|
677
686
|
if (!a)
|
|
678
687
|
throw new Error(
|
|
679
688
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
|
|
@@ -683,23 +692,23 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
683
692
|
), p = (m, y, _ = !0) => {
|
|
684
693
|
const g = oe(m, e?.pathname || n, d);
|
|
685
694
|
if (!y || Array.isArray(y) && !y.length) {
|
|
686
|
-
|
|
695
|
+
s ? (i.delete(m), c(i)) : l((w) => {
|
|
687
696
|
const P = { ...w };
|
|
688
697
|
return delete P[m], P;
|
|
689
698
|
}), localStorage.removeItem(g);
|
|
690
699
|
return;
|
|
691
700
|
}
|
|
692
|
-
_ && y && localStorage.setItem(g, JSON.stringify({ ...
|
|
701
|
+
_ && y && localStorage.setItem(g, JSON.stringify({ ...i, [m]: y })), s && y ? (i.set(m, JSON.stringify(y)), c(i)) : !s && y && l((w) => ({ ...w, [m]: y }));
|
|
693
702
|
};
|
|
694
703
|
return {
|
|
695
704
|
getFilter: (m, y) => {
|
|
696
|
-
if (!
|
|
705
|
+
if (!s) {
|
|
697
706
|
const w = u[m];
|
|
698
707
|
if (w !== void 0)
|
|
699
708
|
return w;
|
|
700
709
|
}
|
|
701
|
-
if (
|
|
702
|
-
const w =
|
|
710
|
+
if (s) {
|
|
711
|
+
const w = i.get(m);
|
|
703
712
|
if (w)
|
|
704
713
|
try {
|
|
705
714
|
return JSON.parse(w);
|
|
@@ -711,15 +720,15 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
711
720
|
if (g)
|
|
712
721
|
try {
|
|
713
722
|
const w = JSON.parse(g)[m];
|
|
714
|
-
return !
|
|
723
|
+
return !s && w !== void 0 && l((P) => ({ ...P, [m]: w })), w;
|
|
715
724
|
} catch {
|
|
716
725
|
}
|
|
717
726
|
return y;
|
|
718
727
|
},
|
|
719
728
|
getFilters: () => {
|
|
720
|
-
const m = h(), y =
|
|
721
|
-
if (
|
|
722
|
-
const _ = Object.fromEntries(
|
|
729
|
+
const m = h(), y = Fe(m);
|
|
730
|
+
if (s) {
|
|
731
|
+
const _ = Object.fromEntries(i.entries());
|
|
723
732
|
return {
|
|
724
733
|
...y,
|
|
725
734
|
..._
|
|
@@ -740,92 +749,80 @@ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys
|
|
|
740
749
|
},
|
|
741
750
|
setFilter: p
|
|
742
751
|
};
|
|
743
|
-
},
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
}), r?.filter((a) => !o[a]).forEach((a) => {
|
|
763
|
-
o[a] = {
|
|
764
|
-
query: {
|
|
765
|
-
useQuery: !0
|
|
766
|
-
}
|
|
767
|
-
};
|
|
768
|
-
}), Object.keys(o).length ? o : void 0;
|
|
769
|
-
}, nt = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
|
|
770
|
-
const { output: n, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: d } = a || {}, i = d || Ne(u), h = l || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
|
|
752
|
+
}, rt = ({
|
|
753
|
+
data: e,
|
|
754
|
+
fetchNextPage: r,
|
|
755
|
+
isFetchingNextPage: o,
|
|
756
|
+
isInitialLoading: a,
|
|
757
|
+
isLoading: n,
|
|
758
|
+
enabled: i = !0
|
|
759
|
+
}) => {
|
|
760
|
+
const c = N(
|
|
761
|
+
async (l) => {
|
|
762
|
+
o || !i || await r({ pageParam: l?.pageParam || l.visibleRowsCount });
|
|
763
|
+
},
|
|
764
|
+
[i, r, o]
|
|
765
|
+
), u = G(() => {
|
|
766
|
+
if (e)
|
|
767
|
+
return e.pages.reduce((l, d) => [...l, ...d], []);
|
|
768
|
+
}, [e]);
|
|
771
769
|
return {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
]
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
},
|
|
795
|
-
operationName: (p, b, x) => Le(p, b, x, c),
|
|
796
|
-
query: {
|
|
797
|
-
useQuery: !0
|
|
770
|
+
fetchNextPageOnRowsScrollEnd: c,
|
|
771
|
+
isLoading: o || n,
|
|
772
|
+
loadingVariant: a ? "skeleton" : "linear-progress",
|
|
773
|
+
rows: u
|
|
774
|
+
};
|
|
775
|
+
}, nt = (e) => {
|
|
776
|
+
const { libraries: r } = j(S), 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 = N(
|
|
777
|
+
(d) => {
|
|
778
|
+
if (d && typeof d == "object" && "response" in d) {
|
|
779
|
+
const { response: s } = d || {};
|
|
780
|
+
if (s && typeof s == "object" && "reason" in s)
|
|
781
|
+
return String(s.reason);
|
|
782
|
+
if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "reason" in s.data)
|
|
783
|
+
return String(s.data.reason);
|
|
784
|
+
if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "message" in s.data)
|
|
785
|
+
return String(s.data.message);
|
|
786
|
+
if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "detail" in s.data) {
|
|
787
|
+
const { detail: h } = s.data;
|
|
788
|
+
if (Array.isArray(h) && h.length > 0 && typeof h[0] == "object" && h[0] !== null && "msg" in h[0]) {
|
|
789
|
+
const { msg: p } = h[0];
|
|
790
|
+
if (typeof p == "string")
|
|
791
|
+
return String(p);
|
|
798
792
|
}
|
|
799
|
-
}
|
|
800
|
-
schemas: n?.schemas || `src/api/${i}/model`,
|
|
801
|
-
target: n?.target || `src/api/${i}/services/api.ts`,
|
|
802
|
-
...n
|
|
793
|
+
}
|
|
803
794
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
795
|
+
return d instanceof Error ? d.message : c;
|
|
796
|
+
},
|
|
797
|
+
[c]
|
|
798
|
+
);
|
|
799
|
+
return { getErrorCode: N((d) => {
|
|
800
|
+
const { response: s } = d || {};
|
|
801
|
+
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";
|
|
802
|
+
}, []), printError: u };
|
|
803
|
+
};
|
|
807
804
|
export {
|
|
808
805
|
Ue as GTMSendPageView,
|
|
809
806
|
Qe as InitializeAxiosConfig,
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
807
|
+
Ve as InitializeDaysJSConfig,
|
|
808
|
+
Me as InitializeI18nConfig,
|
|
809
|
+
Ge as InitializeSentryConfig,
|
|
813
810
|
S as InjectDependenciesContext,
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
811
|
+
ze as InjectDependenciesProvider,
|
|
812
|
+
We as MaskTextField,
|
|
813
|
+
Je as PreloadErrorHandler,
|
|
814
|
+
He as QueryClientProviderWithConfig,
|
|
815
|
+
Ke as RequireAuth,
|
|
819
816
|
qe as UpdateNotifier,
|
|
820
817
|
Ye as axiosCustomInstance,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
818
|
+
ke as dateAdapter,
|
|
819
|
+
Ce as distanceAdapter,
|
|
820
|
+
Be as getOrvalConfig,
|
|
821
|
+
Xe as useAdapter,
|
|
825
822
|
Ze as useAuth,
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
823
|
+
et as useCurrentLanguage,
|
|
824
|
+
tt as useFilters,
|
|
825
|
+
rt as useInfiniteDataGrid,
|
|
826
|
+
nt as useResponseError,
|
|
827
|
+
xe as worksiteNameAdapter
|
|
831
828
|
};
|
package/dist/main.umd.cjs
CHANGED
|
@@ -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 J;function ie(){return J||(J=1,process.env.NODE_ENV!=="production"&&function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Je?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case j:return"Fragment";case E:return"Profiler";case y:return"StrictMode";case _:return"Suspense";case Qe:return"SuspenseList";case Ge: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 I:return"Portal";case h:return(t.displayName||"Context")+".Provider";case P:return(t._context.displayName||"Context")+".Consumer";case b:var p=t.render;return t=t.displayName,t||(t=p.displayName||p.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ve:return p=t.displayName||null,p!==null?p:e(t.type)||"Memo";case q:p=t._payload,t=t._init;try{return e(t(p))}catch{}}return null}function r(t){return""+t}function o(t){try{r(t);var p=!1}catch{p=!0}if(p){p=console;var w=p.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return w.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),r(t)}}function a(t){if(t===j)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===q)return"<...>";try{var p=e(t);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function n(){var t=z.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function c(t){if($.call(t,"key")){var p=Object.getOwnPropertyDescriptor(t,"key").get;if(p&&p.isReactWarning)return!1}return t.key!==void 0}function u(t,p){function w(){ee||(ee=!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)",p))}w.isReactWarning=!0,Object.defineProperty(t,"key",{get:w,configurable:!0})}function l(){var t=e(this.type);return te[t]||(te[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,p,w,R,O,T,M,Q){return w=T.ref,t={$$typeof:
|
|
17
|
+
*/var J;function ie(){return J||(J=1,process.env.NODE_ENV!=="production"&&function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Je?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case j:return"Fragment";case E:return"Profiler";case y:return"StrictMode";case _:return"Suspense";case Qe:return"SuspenseList";case Ge: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 I:return"Portal";case h:return(t.displayName||"Context")+".Provider";case P:return(t._context.displayName||"Context")+".Consumer";case b:var p=t.render;return t=t.displayName,t||(t=p.displayName||p.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ve:return p=t.displayName||null,p!==null?p:e(t.type)||"Memo";case q:p=t._payload,t=t._init;try{return e(t(p))}catch{}}return null}function r(t){return""+t}function o(t){try{r(t);var p=!1}catch{p=!0}if(p){p=console;var w=p.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return w.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),r(t)}}function a(t){if(t===j)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===q)return"<...>";try{var p=e(t);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function n(){var t=z.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function c(t){if($.call(t,"key")){var p=Object.getOwnPropertyDescriptor(t,"key").get;if(p&&p.isReactWarning)return!1}return t.key!==void 0}function u(t,p){function w(){ee||(ee=!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)",p))}w.isReactWarning=!0,Object.defineProperty(t,"key",{get:w,configurable:!0})}function l(){var t=e(this.type);return te[t]||(te[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,p,w,R,O,T,M,Q){return w=T.ref,t={$$typeof:A,type:t,key:p,props:T,_owner:O},(w!==void 0?w: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:M}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function s(t,p,w,R,O,T,M,Q){var S=p.children;if(S!==void 0)if(R)if(Ke(S)){for(R=0;R<S.length;R++)v(S[R]);Object.freeze&&Object.freeze(S)}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(S);if($.call(p,"key")){S=e(t);var N=Object.keys(p).filter(function(Be){return Be!=="key"});R=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",oe[S+R]||(N=0<N.length?"{"+N.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} />`,R,A,N,A),oe[A+R]=!0)}if(A=null,w!==void 0&&(o(w),A=""+w),c(p)&&(o(p.key),A=""+p.key),"key"in p){w={};for(var V in p)V!=="key"&&(w[V]=p[V])}else w=p;return A&&u(w,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,A,T,O,n(),w,M,Q)}function v(t){typeof t=="object"&&t!==null&&t.$$typeof===S&&t._store&&(t._store.validated=1)}var g=f,S=Symbol.for("react.transitional.element"),I=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),h=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),Qe=Symbol.for("react.suspense_list"),Ve=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),Ge=Symbol.for("react.activity"),Je=Symbol.for("react.client.reference"),z=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,Ke=Array.isArray,U=console.createTask?console.createTask:function(){return null};g={"react-stack-bottom-frame":function(t){return t()}};var ee,te={},re=g["react-stack-bottom-frame"].bind(g,i)(),ne=U(a(i)),oe={};F.Fragment=j,F.jsx=function(t,p,w,R,O){var T=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!1,R,O,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)},F.jsxs=function(t,p,w,R,O){var T=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!0,R,O,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)}}()),F}var K;function ce(){return K||(K=1,process.env.NODE_ENV==="production"?Y.exports=se():Y.exports=ie()),Y.exports}var k=ce();const C=f.createContext({}),le=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=f.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return k.jsx(C.Provider,{value:n,children:e})},ue="user",de=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:i,localStorageKeys:c}=f.useContext(C),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,d=n?.localStorageKey||c?.user||ue;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,v]=f.useState(null),{useLocation:g,Navigate:S,Outlet:I}=u,j=g(),y=f.useRef(!1),E=typeof r=="function"?r():!!r,P=typeof E=="boolean"?E:E?.isLogged;return f.useEffect(()=>{y.current||(y.current=!0,l.interceptors.response.use(h=>h,async h=>(typeof h=="object"&&h&&"response"in h&&h.response&&typeof h.response=="object"&&"status"in h.response&&h.response&&typeof h.response=="object"&&"status"in h.response&&h?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),v(a)),Promise.reject(h))))},[l.defaults.headers.common,l.interceptors.response,d,a]),P&&!s?k.jsx(f.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===o?k.jsx(S,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):k.jsx(I,{})}):k.jsx(S,{to:o+j.search,state:{from:j},replace:!0})},fe=({data:e,...r})=>{const{libraries:o}=f.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:i}=n,{useLocation:c,Outlet:u}=a,{pathname:l}=c(),{sendEvent:d}=i();return f.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),k.jsx(u,{})},D=(()=>{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}})(),pe="user",ge=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:i,localStorageKeys:c}=f.useContext(C),u=a?.userLocalStorageKey||c?.user||pe,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||D)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,g=s?.[r]?s[r]:null,S=d?`${v} ${g}`:null;S&&(l.defaults.headers.common.Authorization=S)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=o,null},me=({debug:e,resources:r,...o})=>{const{libraries:a}=f.useContext(C),n=o?.i18||a?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(D)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},he=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:d,...s})=>{const{libraries:v}=f.useContext(C),g=s?.sentry||v?.sentry,S=s?.reactRouter||v?.reactRouter;if(!g)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!S)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(g.isInitialized())return null;const{createRoutesFromChildren:I,matchRoutes:j,useLocation:y,useNavigationType:E}=S;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&g.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:[g.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:I,matchRoutes:j,useEffect:f.useEffect,useLocation:y,useNavigationType:E}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:i,tracesSampleRate:o||1}),null},ye=({IMaskMixin:e,...r})=>{const o=f.useMemo(()=>e(({TextField:a,...n})=>k.jsx(a,{...n})),[e]);return k.jsx(o,{...r})},ve=({language:e,...r})=>{const{libraries:o}=f.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 f.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},Ee=()=>(f.useEffect(()=>{if(D)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),we=async()=>{if("caches"in window)try{const e=await caches.keys();await Promise.all(e.map(r=>caches.delete(r)))}catch(e){console.error("Failed to clear caches:",e)}},be=({autoUpdate:e,renderDialog:r,clearCachesOnReload:o})=>{const a=f.useRef(null),[n,i]=f.useState(!1),c=f.useCallback(async()=>{a.current&&a.current.postMessage({type:"SKIP_WAITING"}),o&&await we(),window.location.reload()},[o]),u=f.useCallback(async()=>{window.confirm("A new version is available. The app will reload now.")&&await c()},[c]);return f.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,d;const s=g=>{g&&navigator.serviceWorker.controller&&(a.current=g,i(!0))},v=()=>{const g=l?.installing;g&&(d=()=>{g.state==="installed"&&s(g)},g.addEventListener("statechange",d))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",v))})().catch(console.error),()=>{l?.removeEventListener("updatefound",v),d&&l?.installing&&l.installing.removeEventListener("statechange",d)}},[]),f.useEffect(()=>{n&&e&&c().catch(console.error)},[e,n,c]),f.useEffect(()=>{n&&!e&&!r&&u().catch(console.error)},[r,u,n,e]),n&&!e&&r?r(c):null},Re=e=>e&&typeof e=="function",Ae=e=>e&&typeof e=="function",Se=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=f.useContext(C),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(!Re(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ae(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 k.jsx(c,{client:u,children:e})},Ce=e=>{const{libraries:r}=f.useContext(C),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=f.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:g}=v[0];if(typeof g=="string")return String(g)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:f.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}},je=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:i=!0})=>{const c=f.useCallback(async l=>{o||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,o]),u=f.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}},Pe=e=>{const{libraries:r}=f.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=f.useCallback(({tokenType:c,accessToken:u})=>{o.defaults.headers.common.Authorization=`${c} ${u}`},[o.defaults.headers.common]),i=()=>{o.defaults.headers.common.Authorization=null};return f.useEffect(()=>{if(D)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}},B=({library:e,date:r,format:o="ll"})=>e(r).format(o),H=(e,r)=>{const{fractionDigits:o=0,metric:a="km",spacingBetween:n=!0}=r||{},i=Number(e),c=n?" ":"";return Number.isNaN(i)?`0${c}${a}`:`${i.toFixed(o)}${c}${a}`},X=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}`,Te=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=_e(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},ke=e=>{const{apiURL:r,libraries:o}=f.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 B({date:c,format:u,library:a})},distanceAdapter:H,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:Te({apiURL:r,path:c,size:u})},worksiteNameAdapter:X}},W=(e,r)=>r==="short"?e.split("-")[0]:e,Ie=(e,r="full")=>{const[o,a]=f.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,W(n,r)});return f.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(W(e.language,r));const n=i=>{a(W(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Oe="tracktor.filter",xe={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},Z=(e,r,o)=>`${o}_${e}=>${r}`,Ne=e=>e.reduce((r,o)=>{const a=localStorage.getItem(o);if(a)try{const n=JSON.parse(a),i=Object.keys(n)?.[0];i&&(r[i]=Object.values(n)?.[0])}catch{}return r},{}),Le=e=>{const{libraries:r,localStorageKeys:o}=f.useContext(C),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[i,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=f.useState({}),d=o?.filter||Oe,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl;if(D)return xe;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const v=()=>Object.keys(localStorage).filter(y=>y.startsWith(d)&&y.endsWith(e?.pathname||n)),g=(y,E,P=!0)=>{const h=Z(y,e?.pathname||n,d);if(!E||Array.isArray(E)&&!E.length){s?(i.delete(y),c(i)):l(b=>{const _={...b};return delete _[y],_}),localStorage.removeItem(h);return}P&&E&&localStorage.setItem(h,JSON.stringify({...i,[y]:E})),s&&E?(i.set(y,JSON.stringify(E)),c(i)):!s&&E&&l(b=>({...b,[y]:E}))};return{getFilter:(y,E)=>{if(!s){const b=u[y];if(b!==void 0)return b}if(s){const b=i.get(y);if(b)try{return JSON.parse(b)}catch{return b}}const P=Z(y,e?.pathname||n,d),h=localStorage.getItem(P);if(h)try{const b=JSON.parse(h)[y];return!s&&b!==void 0&&l(_=>({..._,[y]:b})),b}catch{}return E},getFilters:()=>{const y=v(),E=Ne(y);if(s){const P=Object.fromEntries(i.entries());return{...E,...P}}return{...E,...u}},handleFilter:(y,E)=>(P,h)=>{if(h||Array.isArray(h)&&h.length===0){const b=E||"value",_=typeof h=="object"&&b in h?h[b]:h;g(y,_);return}g(y,void 0)},setFilter:g}},Fe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),De=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},Ye=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)},We=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),ze=(e,r,o,a)=>{const n=Ye(r),i=Fe(o),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Ue=(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},Me=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:l,overrideApiName:d}=a||{},s=d||We(u),v=l||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...o,[s]:{hooks:{afterAllFilesWrite:`prettier src/api/${s} --write`},input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:Ue(i,c)},header:g=>["Generated by orval 🍺",...g.title?[g.title]:[],...g.description?[g.description]:[]],mutator:{name:De(v),path:v},operationName:(g,S,I)=>ze(g,S,I,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{});m.GTMSendPageView=fe,m.InitializeAxiosConfig=ge,m.InitializeDaysJSConfig=ve,m.InitializeI18nConfig=me,m.InitializeSentryConfig=he,m.InjectDependenciesContext=C,m.InjectDependenciesProvider=le,m.MaskTextField=ye,m.PreloadErrorHandler=Ee,m.QueryClientProviderWithConfig=Se,m.RequireAuth=de,m.UpdateNotifier=be,m.axiosCustomInstance=ae,m.dateAdapter=B,m.distanceAdapter=H,m.getOrvalConfig=Me,m.useAdapter=ke,m.useAuth=Pe,m.useCurrentLanguage=Ie,m.useFilters=Le,m.useInfiniteDataGrid=je,m.useResponseError=Ce,m.worksiteNameAdapter=X,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
22
|
+
<%s key={someKey} {...props} />`,R,S,N,S),oe[S+R]=!0)}if(S=null,w!==void 0&&(o(w),S=""+w),c(p)&&(o(p.key),S=""+p.key),"key"in p){w={};for(var V in p)V!=="key"&&(w[V]=p[V])}else w=p;return S&&u(w,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,S,T,O,n(),w,M,Q)}function v(t){typeof t=="object"&&t!==null&&t.$$typeof===A&&t._store&&(t._store.validated=1)}var g=f,A=Symbol.for("react.transitional.element"),I=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),h=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),Qe=Symbol.for("react.suspense_list"),Ve=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),Ge=Symbol.for("react.activity"),Je=Symbol.for("react.client.reference"),z=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,Ke=Array.isArray,U=console.createTask?console.createTask:function(){return null};g={"react-stack-bottom-frame":function(t){return t()}};var ee,te={},re=g["react-stack-bottom-frame"].bind(g,i)(),ne=U(a(i)),oe={};F.Fragment=j,F.jsx=function(t,p,w,R,O){var T=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!1,R,O,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)},F.jsxs=function(t,p,w,R,O){var T=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!0,R,O,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)}}()),F}var K;function ce(){return K||(K=1,process.env.NODE_ENV==="production"?Y.exports=se():Y.exports=ie()),Y.exports}var k=ce();const le=({IMaskMixin:e,...r})=>{const o=f.useMemo(()=>e(({TextField:a,...n})=>k.jsx(a,{...n})),[e]);return k.jsx(o,{...r})},C=f.createContext({}),ue=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=f.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return k.jsx(C.Provider,{value:n,children:e})},de=({data:e,...r})=>{const{libraries:o}=f.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:i}=n,{useLocation:c,Outlet:u}=a,{pathname:l}=c(),{sendEvent:d}=i();return f.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),k.jsx(u,{})},D=(()=>{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}})(),fe="user",pe=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:i,localStorageKeys:c}=f.useContext(C),u=a?.userLocalStorageKey||c?.user||fe,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||D)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,g=s?.[r]?s[r]:null,A=d?`${v} ${g}`:null;A&&(l.defaults.headers.common.Authorization=A)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=o,null},ge=({language:e,...r})=>{const{libraries:o}=f.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 f.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},me=({debug:e,resources:r,...o})=>{const{libraries:a}=f.useContext(C),n=o?.i18||a?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(D)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},he=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:d,...s})=>{const{libraries:v}=f.useContext(C),g=s?.sentry||v?.sentry,A=s?.reactRouter||v?.reactRouter;if(!g)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!A)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(g.isInitialized())return null;const{createRoutesFromChildren:I,matchRoutes:j,useLocation:y,useNavigationType:E}=A;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&g.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:[g.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:I,matchRoutes:j,useEffect:f.useEffect,useLocation:y,useNavigationType:E}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:i,tracesSampleRate:o||1}),null},ye=()=>(f.useEffect(()=>{if(D)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),ve="user",Ee=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:i,localStorageKeys:c}=f.useContext(C),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,d=n?.localStorageKey||c?.user||ve;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,v]=f.useState(null),{useLocation:g,Navigate:A,Outlet:I}=u,j=g(),y=f.useRef(!1),E=typeof r=="function"?r():!!r,P=typeof E=="boolean"?E:E?.isLogged;return f.useEffect(()=>{y.current||(y.current=!0,l.interceptors.response.use(h=>h,async h=>(typeof h=="object"&&h&&"response"in h&&h.response&&typeof h.response=="object"&&"status"in h.response&&h.response&&typeof h.response=="object"&&"status"in h.response&&h?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),v(a)),Promise.reject(h))))},[l.defaults.headers.common,l.interceptors.response,d,a]),P&&!s?k.jsx(f.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===o?k.jsx(A,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):k.jsx(I,{})}):k.jsx(A,{to:o+j.search,state:{from:j},replace:!0})},we=async()=>{if("caches"in window)try{const e=await caches.keys();await Promise.all(e.map(r=>caches.delete(r)))}catch(e){console.error("Failed to clear caches:",e)}},be=({autoUpdate:e,renderDialog:r,clearCachesOnReload:o})=>{const a=f.useRef(null),[n,i]=f.useState(!1),c=f.useCallback(async()=>{a.current&&a.current.postMessage({type:"SKIP_WAITING"}),o&&await we(),window.location.reload()},[o]),u=f.useCallback(async()=>{window.confirm("A new version is available. The app will reload now.")&&await c()},[c]);return f.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,d;const s=g=>{g&&navigator.serviceWorker.controller&&(a.current=g,i(!0))},v=()=>{const g=l?.installing;g&&(d=()=>{g.state==="installed"&&s(g)},g.addEventListener("statechange",d))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",v))})().catch(console.error),()=>{l?.removeEventListener("updatefound",v),d&&l?.installing&&l.installing.removeEventListener("statechange",d)}},[]),f.useEffect(()=>{n&&e&&c().catch(console.error)},[e,n,c]),f.useEffect(()=>{n&&!e&&!r&&u().catch(console.error)},[r,u,n,e]),n&&!e&&r?r(c):null},Re=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Se=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},Ae=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)},Ce=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),je=(e,r,o,a)=>{const n=Ae(r),i=Re(o),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Pe=(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},_e=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:l,overrideApiName:d}=a||{},s=d||Ce(u),v=l||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...o,[s]:{input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:Pe(i,c)},header:g=>["Generated by orval 🍺",...g.title?[g.title]:[],...g.description?[g.description]:[]],mutator:{name:Se(v),path:v},operationName:(g,A,I)=>je(g,A,I,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{}),Te=e=>e&&typeof e=="function",ke=e=>e&&typeof e=="function",Ie=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=f.useContext(C),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(!Te(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!ke(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 k.jsx(c,{client:u,children:e})},B=({library:e,date:r,format:o="ll"})=>e(r).format(o),H=(e,r)=>{const{fractionDigits:o=0,metric:a="km",spacingBetween:n=!0}=r||{},i=Number(e),c=n?" ":"";return Number.isNaN(i)?`0${c}${a}`:`${i.toFixed(o)}${c}${a}`},X=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),Oe=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,xe=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=Oe(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},Ne=e=>{const{apiURL:r,libraries:o}=f.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 B({date:c,format:u,library:a})},distanceAdapter:H,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:xe({apiURL:r,path:c,size:u})},worksiteNameAdapter:X}},Le=e=>{const{libraries:r}=f.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=f.useCallback(({tokenType:c,accessToken:u})=>{o.defaults.headers.common.Authorization=`${c} ${u}`},[o.defaults.headers.common]),i=()=>{o.defaults.headers.common.Authorization=null};return f.useEffect(()=>{if(D)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}},W=(e,r)=>r==="short"?e.split("-")[0]:e,Fe=(e,r="full")=>{const[o,a]=f.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,W(n,r)});return f.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(W(e.language,r));const n=i=>{a(W(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},De="tracktor.filter",Ye={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},Z=(e,r,o)=>`${o}_${e}=>${r}`,We=e=>e.reduce((r,o)=>{const a=localStorage.getItem(o);if(a)try{const n=JSON.parse(a),i=Object.keys(n)?.[0];i&&(r[i]=Object.values(n)?.[0])}catch{}return r},{}),ze=e=>{const{libraries:r,localStorageKeys:o}=f.useContext(C),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[i,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=f.useState({}),d=o?.filter||De,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl;if(D)return Ye;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const v=()=>Object.keys(localStorage).filter(y=>y.startsWith(d)&&y.endsWith(e?.pathname||n)),g=(y,E,P=!0)=>{const h=Z(y,e?.pathname||n,d);if(!E||Array.isArray(E)&&!E.length){s?(i.delete(y),c(i)):l(b=>{const _={...b};return delete _[y],_}),localStorage.removeItem(h);return}P&&E&&localStorage.setItem(h,JSON.stringify({...i,[y]:E})),s&&E?(i.set(y,JSON.stringify(E)),c(i)):!s&&E&&l(b=>({...b,[y]:E}))};return{getFilter:(y,E)=>{if(!s){const b=u[y];if(b!==void 0)return b}if(s){const b=i.get(y);if(b)try{return JSON.parse(b)}catch{return b}}const P=Z(y,e?.pathname||n,d),h=localStorage.getItem(P);if(h)try{const b=JSON.parse(h)[y];return!s&&b!==void 0&&l(_=>({..._,[y]:b})),b}catch{}return E},getFilters:()=>{const y=v(),E=We(y);if(s){const P=Object.fromEntries(i.entries());return{...E,...P}}return{...E,...u}},handleFilter:(y,E)=>(P,h)=>{if(h||Array.isArray(h)&&h.length===0){const b=E||"value",_=typeof h=="object"&&b in h?h[b]:h;g(y,_);return}g(y,void 0)},setFilter:g}},Ue=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:i=!0})=>{const c=f.useCallback(async l=>{o||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,o]),u=f.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}},Me=e=>{const{libraries:r}=f.useContext(C),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=f.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:g}=v[0];if(typeof g=="string")return String(g)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:f.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}};m.GTMSendPageView=de,m.InitializeAxiosConfig=pe,m.InitializeDaysJSConfig=ge,m.InitializeI18nConfig=me,m.InitializeSentryConfig=he,m.InjectDependenciesContext=C,m.InjectDependenciesProvider=ue,m.MaskTextField=le,m.PreloadErrorHandler=ye,m.QueryClientProviderWithConfig=Ie,m.RequireAuth=Ee,m.UpdateNotifier=be,m.axiosCustomInstance=ae,m.dateAdapter=B,m.distanceAdapter=H,m.getOrvalConfig=_e,m.useAdapter=Ne,m.useAuth=Le,m.useCurrentLanguage=Fe,m.useFilters=ze,m.useInfiniteDataGrid=Ue,m.useResponseError=Me,m.worksiteNameAdapter=X,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
type DateType = string | number | Date | null | undefined;
|
|
2
|
-
|
|
3
|
-
(
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
}
|
|
2
|
+
type Library = (date: DateType) => {
|
|
3
|
+
format: (format: string) => string;
|
|
4
|
+
};
|
|
7
5
|
interface DateAdapterParams<T> {
|
|
8
6
|
library: T;
|
|
9
7
|
date: DateType;
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracktor/shared-module",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
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": [
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
10
12
|
"exports": {
|
|
11
13
|
".": {
|
|
12
14
|
"types": "./dist/main.d.ts",
|
|
@@ -26,8 +28,8 @@
|
|
|
26
28
|
"scripts": {
|
|
27
29
|
"dev": "vite",
|
|
28
30
|
"build": "vite build",
|
|
29
|
-
"lint": "
|
|
30
|
-
"lint:fix": "
|
|
31
|
+
"lint": "biome check --diagnostic-level=error . && tsc --noEmit --incremental",
|
|
32
|
+
"lint:fix": "biome check . --write",
|
|
31
33
|
"preview": "vite preview",
|
|
32
34
|
"test": "yarn lint && vitest",
|
|
33
35
|
"prepare": "yarn run build && husky install"
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
"@types/react": "^19.0.0",
|
|
43
45
|
"@types/react-dom": "^19.0.0",
|
|
44
46
|
"@vitejs/plugin-react": "^4.6.0",
|
|
45
|
-
"
|
|
47
|
+
"@tracktor/biome-config-react": "^1.0.5",
|
|
46
48
|
"husky": "^8.0.3",
|
|
47
49
|
"jsdom": "^22.1.0",
|
|
48
50
|
"react": "^19.0.0",
|