@tracktor/shared-module 2.15.13 → 2.16.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/hooks/useAdapter.d.ts +1 -0
- package/dist/main.js +165 -155
- package/dist/main.umd.cjs +22 -0
- package/dist/utils/adapter/distanceAdapter.d.ts +1 -0
- package/package.json +2 -8
- package/dist/axios.cjs +0 -1
- package/dist/axios.d.ts +0 -1
- package/dist/axios.js +0 -4
- package/dist/axiosCustomInstance-D3EHo-4p.cjs +0 -1
- package/dist/axiosCustomInstance-DCYX8iR2.js +0 -14
- package/dist/main.cjs +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,7 @@ export declare const useAdapter: (params?: useAdapterParams) => {
|
|
|
14
14
|
distanceAdapter: (distance?: string | number | null, options?: {
|
|
15
15
|
fractionDigits?: number;
|
|
16
16
|
metric?: string;
|
|
17
|
+
spacingBetween?: boolean;
|
|
17
18
|
}) => string;
|
|
18
19
|
filePathAdapter: (path?: string | null, size?: number | "full") => string;
|
|
19
20
|
worksiteNameAdapter: (name: unknown) => string;
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import Z from "axios";
|
|
2
|
+
import de, { createContext as fe, useMemo as W, useContext as j, useState as oe, useRef as pe, useEffect as C, Suspense as ge, useCallback as F } from "react";
|
|
3
|
+
const $e = (e, o) => {
|
|
4
|
+
const n = Z.CancelToken.source(), a = Z({
|
|
5
|
+
...e,
|
|
6
|
+
...o,
|
|
7
|
+
cancelToken: n.token
|
|
8
|
+
}).then(({ data: r }) => r);
|
|
9
|
+
return a.cancel = () => {
|
|
10
|
+
n.cancel("Query was cancelled");
|
|
11
|
+
}, a;
|
|
12
|
+
};
|
|
13
|
+
var L = { exports: {} }, x = {};
|
|
4
14
|
/**
|
|
5
15
|
* @license React
|
|
6
16
|
* react-jsx-runtime.production.js
|
|
@@ -10,12 +20,12 @@ var L = { exports: {} }, k = {};
|
|
|
10
20
|
* This source code is licensed under the MIT license found in the
|
|
11
21
|
* LICENSE file in the root directory of this source tree.
|
|
12
22
|
*/
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
var e = Symbol.for("react.transitional.element"),
|
|
18
|
-
function
|
|
23
|
+
var ee;
|
|
24
|
+
function me() {
|
|
25
|
+
if (ee) return x;
|
|
26
|
+
ee = 1;
|
|
27
|
+
var e = Symbol.for("react.transitional.element"), o = Symbol.for("react.fragment");
|
|
28
|
+
function n(a, r, s) {
|
|
19
29
|
var c = null;
|
|
20
30
|
if (s !== void 0 && (c = "" + s), r.key !== void 0 && (c = "" + r.key), "key" in r) {
|
|
21
31
|
s = {};
|
|
@@ -30,7 +40,7 @@ function ge() {
|
|
|
30
40
|
props: s
|
|
31
41
|
};
|
|
32
42
|
}
|
|
33
|
-
return
|
|
43
|
+
return x.Fragment = o, x.jsx = n, x.jsxs = n, x;
|
|
34
44
|
}
|
|
35
45
|
var I = {};
|
|
36
46
|
/**
|
|
@@ -42,13 +52,13 @@ var I = {};
|
|
|
42
52
|
* This source code is licensed under the MIT license found in the
|
|
43
53
|
* LICENSE file in the root directory of this source tree.
|
|
44
54
|
*/
|
|
45
|
-
var
|
|
46
|
-
function
|
|
47
|
-
return
|
|
55
|
+
var te;
|
|
56
|
+
function ye() {
|
|
57
|
+
return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
|
|
48
58
|
function e(t) {
|
|
49
59
|
if (t == null) return null;
|
|
50
60
|
if (typeof t == "function")
|
|
51
|
-
return t.$$typeof ===
|
|
61
|
+
return t.$$typeof === ce ? null : t.displayName || t.name || null;
|
|
52
62
|
if (typeof t == "string") return t;
|
|
53
63
|
switch (t) {
|
|
54
64
|
case p:
|
|
@@ -59,9 +69,9 @@ function me() {
|
|
|
59
69
|
return "StrictMode";
|
|
60
70
|
case M:
|
|
61
71
|
return "Suspense";
|
|
62
|
-
case
|
|
72
|
+
case ae:
|
|
63
73
|
return "SuspenseList";
|
|
64
|
-
case
|
|
74
|
+
case ie:
|
|
65
75
|
return "Activity";
|
|
66
76
|
}
|
|
67
77
|
if (typeof t == "object")
|
|
@@ -72,12 +82,12 @@ function me() {
|
|
|
72
82
|
return "Portal";
|
|
73
83
|
case v:
|
|
74
84
|
return (t.displayName || "Context") + ".Provider";
|
|
75
|
-
case
|
|
85
|
+
case k:
|
|
76
86
|
return (t._context.displayName || "Context") + ".Consumer";
|
|
77
87
|
case V:
|
|
78
88
|
var f = t.render;
|
|
79
89
|
return t = t.displayName, t || (t = f.displayName || f.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
80
|
-
case
|
|
90
|
+
case se:
|
|
81
91
|
return f = t.displayName || null, f !== null ? f : e(t.type) || "Memo";
|
|
82
92
|
case G:
|
|
83
93
|
f = t._payload, t = t._init;
|
|
@@ -88,12 +98,12 @@ function me() {
|
|
|
88
98
|
}
|
|
89
99
|
return null;
|
|
90
100
|
}
|
|
91
|
-
function
|
|
101
|
+
function o(t) {
|
|
92
102
|
return "" + t;
|
|
93
103
|
}
|
|
94
|
-
function
|
|
104
|
+
function n(t) {
|
|
95
105
|
try {
|
|
96
|
-
|
|
106
|
+
o(t);
|
|
97
107
|
var f = !1;
|
|
98
108
|
} catch {
|
|
99
109
|
f = !0;
|
|
@@ -105,7 +115,7 @@ function me() {
|
|
|
105
115
|
f,
|
|
106
116
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
107
117
|
E
|
|
108
|
-
),
|
|
118
|
+
), o(t);
|
|
109
119
|
}
|
|
110
120
|
}
|
|
111
121
|
function a(t) {
|
|
@@ -187,7 +197,7 @@ function me() {
|
|
|
187
197
|
var w = f.children;
|
|
188
198
|
if (w !== void 0)
|
|
189
199
|
if (E)
|
|
190
|
-
if (
|
|
200
|
+
if (ue(w)) {
|
|
191
201
|
for (E = 0; E < w.length; E++)
|
|
192
202
|
h(w[E]);
|
|
193
203
|
Object.freeze && Object.freeze(w);
|
|
@@ -198,10 +208,10 @@ function me() {
|
|
|
198
208
|
else h(w);
|
|
199
209
|
if (J.call(f, "key")) {
|
|
200
210
|
w = e(t);
|
|
201
|
-
var
|
|
202
|
-
return
|
|
211
|
+
var O = Object.keys(f).filter(function(le) {
|
|
212
|
+
return le !== "key";
|
|
203
213
|
});
|
|
204
|
-
E = 0 <
|
|
214
|
+
E = 0 < O.length ? "{key: someKey, " + O.join(": ..., ") + ": ...}" : "{key: someKey}", H[w + E] || (O = 0 < O.length ? "{" + O.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
215
|
`A props object containing a "key" prop is being spread into JSX:
|
|
206
216
|
let props = %s;
|
|
207
217
|
<%s {...props} />
|
|
@@ -210,14 +220,14 @@ React keys must be passed directly to JSX without using spread:
|
|
|
210
220
|
<%s key={someKey} {...props} />`,
|
|
211
221
|
E,
|
|
212
222
|
w,
|
|
213
|
-
|
|
223
|
+
O,
|
|
214
224
|
w
|
|
215
225
|
), H[w + E] = !0);
|
|
216
226
|
}
|
|
217
|
-
if (w = null, y !== void 0 && (
|
|
227
|
+
if (w = null, y !== void 0 && (n(y), w = "" + y), c(f) && (n(f.key), w = "" + f.key), "key" in f) {
|
|
218
228
|
y = {};
|
|
219
|
-
for (var
|
|
220
|
-
|
|
229
|
+
for (var Q in f)
|
|
230
|
+
Q !== "key" && (y[Q] = f[Q]);
|
|
221
231
|
} else y = f;
|
|
222
232
|
return w && u(
|
|
223
233
|
y,
|
|
@@ -236,7 +246,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
236
246
|
function h(t) {
|
|
237
247
|
typeof t == "object" && t !== null && t.$$typeof === m && t._store && (t._store.validated = 1);
|
|
238
248
|
}
|
|
239
|
-
var g =
|
|
249
|
+
var g = de, m = Symbol.for("react.transitional.element"), b = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), R = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), k = Symbol.for("react.consumer"), v = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), M = Symbol.for("react.suspense"), ae = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), G = Symbol.for("react.lazy"), ie = Symbol.for("react.activity"), ce = Symbol.for("react.client.reference"), D = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ue = Array.isArray, Y = console.createTask ? console.createTask : function() {
|
|
240
250
|
return null;
|
|
241
251
|
};
|
|
242
252
|
g = {
|
|
@@ -275,34 +285,34 @@ React keys must be passed directly to JSX without using spread:
|
|
|
275
285
|
};
|
|
276
286
|
}()), I;
|
|
277
287
|
}
|
|
278
|
-
var
|
|
279
|
-
function
|
|
280
|
-
return
|
|
288
|
+
var re;
|
|
289
|
+
function he() {
|
|
290
|
+
return re || (re = 1, process.env.NODE_ENV === "production" ? L.exports = me() : L.exports = ye()), L.exports;
|
|
281
291
|
}
|
|
282
|
-
var P =
|
|
283
|
-
const A =
|
|
284
|
-
const r =
|
|
292
|
+
var P = he();
|
|
293
|
+
const A = fe({}), Fe = ({ children: e, apiURL: o, libraries: n, localStorageKeys: a }) => {
|
|
294
|
+
const r = W(
|
|
285
295
|
() => ({
|
|
286
|
-
apiURL:
|
|
287
|
-
libraries:
|
|
296
|
+
apiURL: o,
|
|
297
|
+
libraries: n,
|
|
288
298
|
localStorageKeys: a
|
|
289
299
|
}),
|
|
290
|
-
[
|
|
300
|
+
[o, n, a]
|
|
291
301
|
);
|
|
292
302
|
return /* @__PURE__ */ P.jsx(A.Provider, { value: r, children: e });
|
|
293
|
-
},
|
|
294
|
-
const { libraries: s, localStorageKeys: c } = j(A), u = r?.reactRouter || s?.reactRouter, l = r?.axios || s?.axios, d = r?.localStorageKey || c?.user ||
|
|
303
|
+
}, ve = "user", De = ({ Fallback: e, isLogged: o, loginPath: n = "/login", redirect401Path: a = "/login", ...r }) => {
|
|
304
|
+
const { libraries: s, localStorageKeys: c } = j(A), u = r?.reactRouter || s?.reactRouter, l = r?.axios || s?.axios, d = r?.localStorageKey || c?.user || ve;
|
|
295
305
|
if (!u)
|
|
296
306
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
297
|
-
const [i, h] =
|
|
307
|
+
const [i, h] = oe(null), { useLocation: g, Navigate: m, Outlet: b } = u, p = g(), R = pe(!1), S = typeof o == "function" ? o() : !!o, k = typeof S == "boolean" ? S : S?.isLogged;
|
|
298
308
|
return C(() => {
|
|
299
309
|
R.current || (R.current = !0, l.interceptors.response.use(
|
|
300
310
|
(v) => v,
|
|
301
311
|
async (v) => (typeof v == "object" && v && "response" in v && v.response && typeof v.response == "object" && "status" in v.response && v.response && typeof v.response == "object" && "status" in v.response && v?.response?.status === 401 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(d), h(a)), Promise.reject(v))
|
|
302
312
|
));
|
|
303
|
-
}, [l.defaults.headers.common, l.interceptors.response, d, a]),
|
|
304
|
-
},
|
|
305
|
-
const { libraries:
|
|
313
|
+
}, [l.defaults.headers.common, l.interceptors.response, d, a]), k && !i ? /* @__PURE__ */ P.jsx(ge, { fallback: e, children: p.state?.from?.state && p.state?.from?.pathname === n ? /* @__PURE__ */ P.jsx(m, { to: p.state.from.state.from.pathname + p.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ P.jsx(b, {}) }) : /* @__PURE__ */ P.jsx(m, { to: n + p.search, state: { from: p }, replace: !0 });
|
|
314
|
+
}, Ye = ({ data: e, ...o }) => {
|
|
315
|
+
const { libraries: n } = j(A), a = o?.reactRouter || n?.reactRouter, r = o?.gtm || n?.gtm;
|
|
306
316
|
if (!a)
|
|
307
317
|
throw new Error(
|
|
308
318
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView."
|
|
@@ -325,24 +335,24 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
325
335
|
} catch {
|
|
326
336
|
return !1;
|
|
327
337
|
}
|
|
328
|
-
})(),
|
|
338
|
+
})(), Ee = "user", ze = ({
|
|
329
339
|
tokenTypeKey: e = "tokenType",
|
|
330
|
-
tokenKey:
|
|
331
|
-
postContentType:
|
|
340
|
+
tokenKey: o = "accessToken",
|
|
341
|
+
postContentType: n = "application/json",
|
|
332
342
|
...a
|
|
333
343
|
}) => {
|
|
334
|
-
const { apiURL: r = a.apiURL, libraries: s, localStorageKeys: c } = j(A), u = a?.userLocalStorageKey || c?.user ||
|
|
344
|
+
const { apiURL: r = a.apiURL, libraries: s, localStorageKeys: c } = j(A), u = a?.userLocalStorageKey || c?.user || Ee, l = a?.axios || s?.axios;
|
|
335
345
|
if (!l)
|
|
336
346
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
337
347
|
if (!l?.defaults || N)
|
|
338
348
|
return null;
|
|
339
349
|
if (typeof window < "u" && window.localStorage) {
|
|
340
|
-
const d = localStorage.getItem(u), i = d ? JSON.parse(d) : null, h = i?.[e] ? i[e] : null, g = i?.[
|
|
350
|
+
const d = localStorage.getItem(u), i = d ? JSON.parse(d) : null, h = i?.[e] ? i[e] : null, g = i?.[o] ? i[o] : null, m = d ? `${h} ${g}` : null;
|
|
341
351
|
m && (l.defaults.headers.common.Authorization = m);
|
|
342
352
|
}
|
|
343
|
-
return l.defaults.baseURL = r, l.defaults.headers.post["Content-Type"] =
|
|
344
|
-
},
|
|
345
|
-
const { libraries: a } = j(A), r =
|
|
353
|
+
return l.defaults.baseURL = r, l.defaults.headers.post["Content-Type"] = n, null;
|
|
354
|
+
}, Ue = ({ debug: e, resources: o, ...n }) => {
|
|
355
|
+
const { libraries: a } = j(A), r = n?.i18 || a?.i18, { i18next: s, initReactI18next: c, languageDetector: u } = r || {};
|
|
346
356
|
if (N)
|
|
347
357
|
return null;
|
|
348
358
|
if (!r)
|
|
@@ -358,17 +368,17 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
358
368
|
bindI18n: "languageChanged loaded",
|
|
359
369
|
useSuspense: !0
|
|
360
370
|
},
|
|
361
|
-
resources:
|
|
371
|
+
resources: o,
|
|
362
372
|
returnNull: !1
|
|
363
373
|
}).then(() => {
|
|
364
374
|
document.documentElement.lang !== s.resolvedLanguage && s.resolvedLanguage && document.documentElement.setAttribute("lang", s.resolvedLanguage);
|
|
365
375
|
}), s.on("languageChanged", (l) => {
|
|
366
376
|
document.documentElement.setAttribute("lang", l);
|
|
367
377
|
})), null;
|
|
368
|
-
},
|
|
378
|
+
}, Qe = ({
|
|
369
379
|
dsn: e,
|
|
370
|
-
integrations:
|
|
371
|
-
tracesSampleRate:
|
|
380
|
+
integrations: o,
|
|
381
|
+
tracesSampleRate: n,
|
|
372
382
|
replaysSessionSampleRate: a,
|
|
373
383
|
replaysOnErrorSampleRate: r,
|
|
374
384
|
tracePropagationTargets: s,
|
|
@@ -407,23 +417,23 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
407
417
|
useLocation: R,
|
|
408
418
|
useNavigationType: S
|
|
409
419
|
}),
|
|
410
|
-
...
|
|
420
|
+
...o || []
|
|
411
421
|
],
|
|
412
422
|
release: d,
|
|
413
423
|
replaysOnErrorSampleRate: r || 1,
|
|
414
424
|
replaysSessionSampleRate: a || 0.1,
|
|
415
425
|
tracePropagationTargets: s,
|
|
416
|
-
tracesSampleRate:
|
|
426
|
+
tracesSampleRate: n || 1
|
|
417
427
|
}), null;
|
|
418
|
-
},
|
|
419
|
-
const
|
|
428
|
+
}, We = ({ IMaskMixin: e, ...o }) => {
|
|
429
|
+
const n = W(
|
|
420
430
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
421
431
|
() => e(({ TextField: a, ...r }) => /* @__PURE__ */ P.jsx(a, { ...r })),
|
|
422
432
|
[e]
|
|
423
433
|
);
|
|
424
|
-
return /* @__PURE__ */ P.jsx(
|
|
425
|
-
},
|
|
426
|
-
const { libraries:
|
|
434
|
+
return /* @__PURE__ */ P.jsx(n, { ...o });
|
|
435
|
+
}, Ve = ({ language: e, ...o }) => {
|
|
436
|
+
const { libraries: n } = j(A), a = o?.dayjs || n?.dayjs, r = o?.plugin || n?.dayjsPlugin;
|
|
427
437
|
if (!a)
|
|
428
438
|
throw new Error(
|
|
429
439
|
"Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
|
|
@@ -436,22 +446,22 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
436
446
|
}), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), a.locale(c);
|
|
437
447
|
})().then();
|
|
438
448
|
}, [a, r, e]), null;
|
|
439
|
-
},
|
|
449
|
+
}, Me = () => (C(() => {
|
|
440
450
|
if (N)
|
|
441
451
|
return;
|
|
442
|
-
const e = (
|
|
452
|
+
const e = (o) => {
|
|
443
453
|
try {
|
|
444
|
-
|
|
454
|
+
o.preventDefault(), o.stopPropagation(), o.stopImmediatePropagation(), window.location.reload();
|
|
445
455
|
} catch {
|
|
446
456
|
}
|
|
447
457
|
};
|
|
448
458
|
return window.addEventListener("vite:preloadError", e), () => {
|
|
449
459
|
window.removeEventListener("vite:preloadError", e);
|
|
450
460
|
};
|
|
451
|
-
}, []), null),
|
|
461
|
+
}, []), null), we = (e) => e && typeof e == "function", be = (e) => e && typeof e == "function", Ge = ({
|
|
452
462
|
children: e,
|
|
453
|
-
defaultQueriesOptions:
|
|
454
|
-
defaultMutationsOptions:
|
|
463
|
+
defaultQueriesOptions: o,
|
|
464
|
+
defaultMutationsOptions: n,
|
|
455
465
|
...a
|
|
456
466
|
}) => {
|
|
457
467
|
const { libraries: r } = j(A), s = a?.QueryClient || r?.reactQuery?.QueryClient, c = a?.QueryClientProvider || r?.reactQuery?.QueryClientProvider;
|
|
@@ -459,26 +469,26 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
459
469
|
throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
460
470
|
if (!c)
|
|
461
471
|
throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
462
|
-
if (!
|
|
472
|
+
if (!we(c))
|
|
463
473
|
throw new Error("Provided QueryClientProvider dependencies are not valid.");
|
|
464
|
-
if (!
|
|
474
|
+
if (!be(s))
|
|
465
475
|
throw new Error("Provided QueryClient dependencies are not valid.");
|
|
466
476
|
const u = new s({
|
|
467
477
|
defaultOptions: {
|
|
468
478
|
mutations: {
|
|
469
|
-
...
|
|
479
|
+
...n
|
|
470
480
|
},
|
|
471
481
|
queries: {
|
|
472
482
|
getNextPageParam: (l, d, i) => l.length + (i || 0),
|
|
473
483
|
refetchOnWindowFocus: !1,
|
|
474
484
|
retry: 3,
|
|
475
|
-
...
|
|
485
|
+
...o
|
|
476
486
|
}
|
|
477
487
|
}
|
|
478
488
|
});
|
|
479
489
|
return /* @__PURE__ */ P.jsx(c, { client: u, children: e });
|
|
480
|
-
},
|
|
481
|
-
const { libraries:
|
|
490
|
+
}, Je = (e) => {
|
|
491
|
+
const { libraries: o } = j(A), n = e?.i18 || o?.i18, a = e?.i18?.translateFunction || o?.i18?.translateFunction, r = n?.i18next?.t || a || ((d) => d), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = r(s), u = F(
|
|
482
492
|
(d) => {
|
|
483
493
|
if (d && typeof d == "object" && "response" in d) {
|
|
484
494
|
const { response: i } = d || {};
|
|
@@ -501,44 +511,44 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
501
511
|
},
|
|
502
512
|
[c]
|
|
503
513
|
);
|
|
504
|
-
return { getErrorCode:
|
|
514
|
+
return { getErrorCode: F((d) => {
|
|
505
515
|
const { response: i } = d || {};
|
|
506
516
|
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";
|
|
507
517
|
}, []), printError: u };
|
|
508
|
-
},
|
|
518
|
+
}, Ke = ({
|
|
509
519
|
data: e,
|
|
510
|
-
fetchNextPage:
|
|
511
|
-
isFetchingNextPage:
|
|
520
|
+
fetchNextPage: o,
|
|
521
|
+
isFetchingNextPage: n,
|
|
512
522
|
isInitialLoading: a,
|
|
513
523
|
isLoading: r,
|
|
514
524
|
enabled: s = !0
|
|
515
525
|
}) => {
|
|
516
|
-
const c =
|
|
526
|
+
const c = F(
|
|
517
527
|
async (l) => {
|
|
518
|
-
|
|
528
|
+
n || !s || await o({ pageParam: l?.pageParam || l.visibleRowsCount });
|
|
519
529
|
},
|
|
520
|
-
[s,
|
|
521
|
-
), u =
|
|
530
|
+
[s, o, n]
|
|
531
|
+
), u = W(() => {
|
|
522
532
|
if (e)
|
|
523
533
|
return e.pages.reduce((l, d) => [...l, ...d], []);
|
|
524
534
|
}, [e]);
|
|
525
535
|
return {
|
|
526
536
|
fetchNextPageOnRowsScrollEnd: c,
|
|
527
|
-
isLoading:
|
|
537
|
+
isLoading: n || r,
|
|
528
538
|
loadingVariant: a ? "skeleton" : "linear-progress",
|
|
529
539
|
rows: u
|
|
530
540
|
};
|
|
531
|
-
},
|
|
532
|
-
const { libraries:
|
|
533
|
-
if (!
|
|
541
|
+
}, qe = (e) => {
|
|
542
|
+
const { libraries: o } = j(A), n = e?.axios || o?.axios, a = e?.localStorageKey || "user";
|
|
543
|
+
if (!n)
|
|
534
544
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
535
|
-
const r =
|
|
545
|
+
const r = F(
|
|
536
546
|
({ tokenType: c, accessToken: u }) => {
|
|
537
|
-
|
|
547
|
+
n.defaults.headers.common.Authorization = `${c} ${u}`;
|
|
538
548
|
},
|
|
539
|
-
[
|
|
549
|
+
[n.defaults.headers.common]
|
|
540
550
|
), s = () => {
|
|
541
|
-
|
|
551
|
+
n.defaults.headers.common.Authorization = null;
|
|
542
552
|
};
|
|
543
553
|
return C(() => {
|
|
544
554
|
if (N)
|
|
@@ -559,55 +569,55 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
559
569
|
clearAuthenticationToken: s,
|
|
560
570
|
setAuthenticationToken: r
|
|
561
571
|
};
|
|
562
|
-
},
|
|
563
|
-
const { fractionDigits:
|
|
564
|
-
return Number.isNaN(
|
|
565
|
-
},
|
|
572
|
+
}, Re = ({ library: e, date: o, format: n = "ll" }) => e(o).format(n), Se = (e, o) => {
|
|
573
|
+
const { fractionDigits: n = 0, metric: a = "km", spacingBetween: r = !0 } = o || {}, s = Number(e), c = r ? " " : "";
|
|
574
|
+
return Number.isNaN(s) ? `0${c}${a}` : `${s.toFixed(n)}${c}${a}`;
|
|
575
|
+
}, Ae = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((n) => n.length > 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n).join(" "), je = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, _e = ({ path: e, size: o, apiURL: n }) => {
|
|
566
576
|
if (!e)
|
|
567
577
|
return "";
|
|
568
|
-
const a =
|
|
569
|
-
return typeof
|
|
570
|
-
},
|
|
571
|
-
const { apiURL:
|
|
578
|
+
const a = je(e), r = `${n}${a}`, s = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
579
|
+
return typeof o == "number" && s ? `${r.replace("/files", `/thumbs/${o}`)}` : r;
|
|
580
|
+
}, Be = (e) => {
|
|
581
|
+
const { apiURL: o, libraries: n } = j(A), a = e?.dayjs || n?.dayjs;
|
|
572
582
|
return {
|
|
573
583
|
dateAdapter: (c, u) => {
|
|
574
584
|
if (!a)
|
|
575
585
|
throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
576
|
-
return
|
|
586
|
+
return Re({
|
|
577
587
|
date: c,
|
|
578
588
|
format: u,
|
|
579
589
|
library: a
|
|
580
590
|
});
|
|
581
591
|
},
|
|
582
|
-
distanceAdapter:
|
|
592
|
+
distanceAdapter: Se,
|
|
583
593
|
filePathAdapter: (c, u) => {
|
|
584
|
-
if (!
|
|
594
|
+
if (!o)
|
|
585
595
|
throw new Error(
|
|
586
596
|
"API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
|
|
587
597
|
);
|
|
588
|
-
return typeof c == "string" && /^https?:\/\//.test(c) ? c :
|
|
589
|
-
apiURL:
|
|
598
|
+
return typeof c == "string" && /^https?:\/\//.test(c) ? c : _e({
|
|
599
|
+
apiURL: o,
|
|
590
600
|
path: c,
|
|
591
601
|
size: u
|
|
592
602
|
});
|
|
593
603
|
},
|
|
594
|
-
worksiteNameAdapter:
|
|
604
|
+
worksiteNameAdapter: Ae
|
|
595
605
|
};
|
|
596
|
-
},
|
|
597
|
-
const [
|
|
606
|
+
}, $ = (e, o) => o === "short" ? e.split("-")[0] : e, Xe = (e, o = "full") => {
|
|
607
|
+
const [n, a] = oe(() => {
|
|
598
608
|
const r = e?.language || navigator.language;
|
|
599
|
-
return e && "isInitialized" in e && e.isInitialized,
|
|
609
|
+
return e && "isInitialized" in e && e.isInitialized, $(r, o);
|
|
600
610
|
});
|
|
601
611
|
return C(() => {
|
|
602
|
-
e && "isInitialized" in e && e.isInitialized && e.language && a(
|
|
612
|
+
e && "isInitialized" in e && e.isInitialized && e.language && a($(e.language, o));
|
|
603
613
|
const r = (s) => {
|
|
604
|
-
a(
|
|
614
|
+
a($(s, o));
|
|
605
615
|
};
|
|
606
616
|
return e?.on?.("languageChanged", r), () => {
|
|
607
617
|
e?.off?.("languageChanged", r);
|
|
608
618
|
};
|
|
609
|
-
}, [e,
|
|
610
|
-
},
|
|
619
|
+
}, [e, o]), n;
|
|
620
|
+
}, Pe = "tracktor.filter", Te = {
|
|
611
621
|
getFilter: () => {
|
|
612
622
|
},
|
|
613
623
|
getFilters: () => ({}),
|
|
@@ -615,17 +625,17 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
615
625
|
},
|
|
616
626
|
setFilter: () => {
|
|
617
627
|
}
|
|
618
|
-
},
|
|
619
|
-
const { libraries:
|
|
620
|
-
}], u =
|
|
628
|
+
}, ne = (e, o, n) => `${n}_${e}=>${o}`, He = (e) => {
|
|
629
|
+
const { libraries: o, localStorageKeys: n } = j(A), a = e?.reactRouter || o?.reactRouter, { pathname: r } = a?.useLocation?.() ?? { pathname: "/" }, [s, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
|
|
630
|
+
}], u = n?.filter || Pe;
|
|
621
631
|
if (N)
|
|
622
|
-
return
|
|
632
|
+
return Te;
|
|
623
633
|
if (!a)
|
|
624
634
|
throw new Error(
|
|
625
635
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView."
|
|
626
636
|
);
|
|
627
637
|
const l = (g, m, b = !0) => {
|
|
628
|
-
const p =
|
|
638
|
+
const p = ne(g, e?.pathname || r, u);
|
|
629
639
|
if (!m || Array.isArray(m) && !m.length) {
|
|
630
640
|
s.delete(g), c(s), localStorage.removeItem(p);
|
|
631
641
|
return;
|
|
@@ -641,7 +651,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
641
651
|
} catch {
|
|
642
652
|
return b;
|
|
643
653
|
}
|
|
644
|
-
const p =
|
|
654
|
+
const p = ne(g, e?.pathname || r, u), R = localStorage.getItem(p);
|
|
645
655
|
if (R)
|
|
646
656
|
try {
|
|
647
657
|
return JSON.parse(R)[g];
|
|
@@ -655,8 +665,8 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
655
665
|
).reduce((p, R) => {
|
|
656
666
|
const S = localStorage.getItem(R);
|
|
657
667
|
if (S) {
|
|
658
|
-
const
|
|
659
|
-
p[v] = Object.values(
|
|
668
|
+
const k = JSON.parse(S), v = Object.keys(k)?.[0];
|
|
669
|
+
p[v] = Object.values(k)?.[0];
|
|
660
670
|
}
|
|
661
671
|
return p;
|
|
662
672
|
}, {});
|
|
@@ -675,33 +685,33 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
675
685
|
},
|
|
676
686
|
setFilter: l
|
|
677
687
|
};
|
|
678
|
-
},
|
|
688
|
+
}, Ce = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), ke = (e) => {
|
|
679
689
|
const a = e.split("/").filter((r) => r.length > 0).map((r) => r.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("")).join("");
|
|
680
690
|
return a.charAt(0).toLowerCase() + a.slice(1);
|
|
681
|
-
}, Oe = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), xe = (e,
|
|
682
|
-
const r =
|
|
691
|
+
}, Oe = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), xe = (e, o, n, a) => {
|
|
692
|
+
const r = ke(o), s = Ce(n), c = `${r}${s}`;
|
|
683
693
|
return e && typeof e == "object" && "operationId" in e && a?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
|
|
684
|
-
},
|
|
685
|
-
const
|
|
694
|
+
}, Ie = (e, o) => {
|
|
695
|
+
const n = {};
|
|
686
696
|
return e?.forEach((a) => {
|
|
687
|
-
|
|
697
|
+
n[a] = {
|
|
688
698
|
query: {
|
|
689
699
|
useInfinite: !0,
|
|
690
700
|
useInfiniteQueryParam: "offset",
|
|
691
701
|
useQuery: !0
|
|
692
702
|
}
|
|
693
703
|
};
|
|
694
|
-
}),
|
|
695
|
-
|
|
704
|
+
}), o?.filter((a) => !n[a]).forEach((a) => {
|
|
705
|
+
n[a] = {
|
|
696
706
|
query: {
|
|
697
707
|
useQuery: !0
|
|
698
708
|
}
|
|
699
709
|
};
|
|
700
|
-
}), Object.keys(
|
|
701
|
-
},
|
|
710
|
+
}), Object.keys(n).length ? n : void 0;
|
|
711
|
+
}, Ze = (e) => (Array.isArray(e) ? e : [e]).reduce((n, a) => {
|
|
702
712
|
const { output: r, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json" } = a || {}, l = Oe(u);
|
|
703
713
|
return {
|
|
704
|
-
...
|
|
714
|
+
...n,
|
|
705
715
|
[l]: {
|
|
706
716
|
hooks: {
|
|
707
717
|
afterAllFilesWrite: "prettier src/api/ --write"
|
|
@@ -713,7 +723,7 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
713
723
|
mode: "tags-split",
|
|
714
724
|
override: {
|
|
715
725
|
...(s?.length || c?.length) && {
|
|
716
|
-
operations:
|
|
726
|
+
operations: Ie(s, c)
|
|
717
727
|
},
|
|
718
728
|
header: (d) => [
|
|
719
729
|
"Generated by orval 🍺",
|
|
@@ -737,26 +747,26 @@ const A = de({}), Ne = ({ children: e, apiURL: n, libraries: o, localStorageKeys
|
|
|
737
747
|
};
|
|
738
748
|
}, {});
|
|
739
749
|
export {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
750
|
+
Ye as GTMSendPageView,
|
|
751
|
+
ze as InitializeAxiosConfig,
|
|
752
|
+
Ve as InitializeDaysJSConfig,
|
|
753
|
+
Ue as InitializeI18nConfig,
|
|
754
|
+
Qe as InitializeSentryConfig,
|
|
745
755
|
A as InjectDependenciesContext,
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
756
|
+
Fe as InjectDependenciesProvider,
|
|
757
|
+
We as MaskTextField,
|
|
758
|
+
Me as PreloadErrorHandler,
|
|
759
|
+
Ge as QueryClientProviderWithConfig,
|
|
760
|
+
De as RequireAuth,
|
|
761
|
+
$e as axiosCustomInstance,
|
|
762
|
+
Re as dateAdapter,
|
|
763
|
+
Se as distanceAdapter,
|
|
764
|
+
Ze as getOrvalConfig,
|
|
765
|
+
Be as useAdapter,
|
|
766
|
+
qe as useAuth,
|
|
767
|
+
Xe as useCurrentLanguage,
|
|
768
|
+
He as useFilters,
|
|
769
|
+
Ke as useInfiniteDataGrid,
|
|
770
|
+
Je as useResponseError,
|
|
771
|
+
Ae as worksiteNameAdapter
|
|
762
772
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(function(y,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],k):(y=typeof globalThis<"u"?globalThis:y||self,k(y["@tracktor/shared-module"]={},y.axios,y.React))})(this,function(y,k,p){"use strict";const ae=(e,o)=>{const n=k.CancelToken.source(),a=k({...e,...o,cancelToken:n.token}).then(({data:r})=>r);return a.cancel=()=>{n.cancel("Query was cancelled")},a};var F={exports:{}},x={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var W;function se(){if(W)return x;W=1;var e=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function n(a,r,s){var c=null;if(s!==void 0&&(c=""+s),r.key!==void 0&&(c=""+r.key),"key"in r){s={};for(var u in r)u!=="key"&&(s[u]=r[u])}else s=r;return r=s.ref,{$$typeof:e,type:a,key:c,ref:r!==void 0?r:null,props:s}}return x.Fragment=o,x.jsx=n,x.jsxs=n,x}var N={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var V;function ie(){return V||(V=1,process.env.NODE_ENV!=="production"&&function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Qe?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case g:return"Fragment";case C:return"Profiler";case A:return"StrictMode";case Z:return"Suspense";case ze:return"SuspenseList";case Me:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case S:return"Portal";case w:return(t.displayName||"Context")+".Provider";case I:return(t._context.displayName||"Context")+".Consumer";case H:var f=t.render;return t=t.displayName,t||(t=f.displayName||f.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ue:return f=t.displayName||null,f!==null?f:e(t.type)||"Memo";case q:f=t._payload,t=t._init;try{return e(t(f))}catch{}}return null}function o(t){return""+t}function n(t){try{o(t);var f=!1}catch{f=!0}if(f){f=console;var v=f.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return v.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),o(t)}}function a(t){if(t===g)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===q)return"<...>";try{var f=e(t);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function r(){var t=Y.A;return t===null?null:t.getOwner()}function s(){return Error("react-stack-top-frame")}function c(t){if($.call(t,"key")){var f=Object.getOwnPropertyDescriptor(t,"key").get;if(f&&f.isReactWarning)return!1}return t.key!==void 0}function u(t,f){function v(){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)",f))}v.isReactWarning=!0,Object.defineProperty(t,"key",{get:v,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,f,v,b,T,_,U,M){return v=_.ref,t={$$typeof:h,type:t,key:f,props:_,_owner:T},(v!==void 0?v:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:l}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function i(t,f,v,b,T,_,U,M){var R=f.children;if(R!==void 0)if(b)if(We(R)){for(b=0;b<R.length;b++)E(R[b]);Object.freeze&&Object.freeze(R)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else E(R);if($.call(f,"key")){R=e(t);var O=Object.keys(f).filter(function(Ve){return Ve!=="key"});b=0<O.length?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}",oe[R+b]||(O=0<O.length?"{"+O.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,b,R,O,R),oe[R+b]=!0)}if(R=null,v!==void 0&&(n(v),R=""+v),c(f)&&(n(f.key),R=""+f.key),"key"in f){v={};for(var Q in f)Q!=="key"&&(v[Q]=f[Q])}else v=f;return R&&u(v,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,R,_,T,r(),v,U,M)}function E(t){typeof t=="object"&&t!==null&&t.$$typeof===h&&t._store&&(t._store.validated=1)}var m=p,h=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),w=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),ze=Symbol.for("react.suspense_list"),Ue=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),Me=Symbol.for("react.activity"),Qe=Symbol.for("react.client.reference"),Y=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,We=Array.isArray,z=console.createTask?console.createTask:function(){return null};m={"react-stack-bottom-frame":function(t){return t()}};var ee,te={},re=m["react-stack-bottom-frame"].bind(m,s)(),ne=z(a(s)),oe={};N.Fragment=g,N.jsx=function(t,f,v,b,T){var _=1e4>Y.recentlyCreatedOwnerStacks++;return i(t,f,v,!1,b,T,_?Error("react-stack-top-frame"):re,_?z(a(t)):ne)},N.jsxs=function(t,f,v,b,T){var _=1e4>Y.recentlyCreatedOwnerStacks++;return i(t,f,v,!0,b,T,_?Error("react-stack-top-frame"):re,_?z(a(t)):ne)}}()),N}var G;function ce(){return G||(G=1,process.env.NODE_ENV==="production"?F.exports=se():F.exports=ie()),F.exports}var P=ce();const j=p.createContext({}),ue=({children:e,apiURL:o,libraries:n,localStorageKeys:a})=>{const r=p.useMemo(()=>({apiURL:o,libraries:n,localStorageKeys:a}),[o,n,a]);return P.jsx(j.Provider,{value:r,children:e})},le="user",de=({Fallback:e,isLogged:o,loginPath:n="/login",redirect401Path:a="/login",...r})=>{const{libraries:s,localStorageKeys:c}=p.useContext(j),u=r?.reactRouter||s?.reactRouter,l=r?.axios||s?.axios,d=r?.localStorageKey||c?.user||le;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,E]=p.useState(null),{useLocation:m,Navigate:h,Outlet:S}=u,g=m(),A=p.useRef(!1),C=typeof o=="function"?o():!!o,I=typeof C=="boolean"?C:C?.isLogged;return p.useEffect(()=>{A.current||(A.current=!0,l.interceptors.response.use(w=>w,async w=>(typeof w=="object"&&w&&"response"in w&&w.response&&typeof w.response=="object"&&"status"in w.response&&w.response&&typeof w.response=="object"&&"status"in w.response&&w?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),E(a)),Promise.reject(w))))},[l.defaults.headers.common,l.interceptors.response,d,a]),I&&!i?P.jsx(p.Suspense,{fallback:e,children:g.state?.from?.state&&g.state?.from?.pathname===n?P.jsx(h,{to:g.state.from.state.from.pathname+g.state.from.state.from.search,replace:!0}):P.jsx(S,{})}):P.jsx(h,{to:n+g.search,state:{from:g},replace:!0})},fe=({data:e,...o})=>{const{libraries:n}=p.useContext(j),a=o?.reactRouter||n?.reactRouter,r=o?.gtm||n?.gtm;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!r)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:s}=r,{useLocation:c,Outlet:u}=a,{pathname:l}=c(),{sendEvent:d}=s();return p.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),P.jsx(u,{})},L=(()=>{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:o="accessToken",postContentType:n="application/json",...a})=>{const{apiURL:r=a.apiURL,libraries:s,localStorageKeys:c}=p.useContext(j),u=a?.userLocalStorageKey||c?.user||pe,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||L)return null;if(typeof window<"u"&&window.localStorage){const d=localStorage.getItem(u),i=d?JSON.parse(d):null,E=i?.[e]?i[e]:null,m=i?.[o]?i[o]:null,h=d?`${E} ${m}`:null;h&&(l.defaults.headers.common.Authorization=h)}return l.defaults.baseURL=r,l.defaults.headers.post["Content-Type"]=n,null},me=({debug:e,resources:o,...n})=>{const{libraries:a}=p.useContext(j),r=n?.i18||a?.i18,{i18next:s,initReactI18next:c,languageDetector:u}=r||{};if(L)return null;if(!r)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return s?.isInitialized||(s.use(u).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:o,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},ye=({dsn:e,integrations:o,tracesSampleRate:n,replaysSessionSampleRate:a,replaysOnErrorSampleRate:r,tracePropagationTargets:s,ignoreErrors:c,debug:u,environment:l,release:d,...i})=>{const{libraries:E}=p.useContext(j),m=i?.sentry||E?.sentry,h=i?.reactRouter||E?.reactRouter;if(!m)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!h)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(m.isInitialized())return null;const{createRoutesFromChildren:S,matchRoutes:g,useLocation:A,useNavigationType:C}=h;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&m.init({debug:u,dsn:e,environment:l||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[m.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:S,matchRoutes:g,useEffect:p.useEffect,useLocation:A,useNavigationType:C}),...o||[]],release:d,replaysOnErrorSampleRate:r||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:s,tracesSampleRate:n||1}),null},he=({IMaskMixin:e,...o})=>{const n=p.useMemo(()=>e(({TextField:a,...r})=>P.jsx(a,{...r})),[e]);return P.jsx(n,{...o})},ve=({language:e,...o})=>{const{libraries:n}=p.useContext(j),a=o?.dayjs||n?.dayjs,r=o?.plugin||n?.dayjsPlugin;if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return p.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";r&&r.forEach(u=>{u&&a.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,r,e]),null},Ee=()=>(p.useEffect(()=>{if(L)return;const e=o=>{try{o.preventDefault(),o.stopPropagation(),o.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),we=e=>e&&typeof e=="function",be=e=>e&&typeof e=="function",Re=({children:e,defaultQueriesOptions:o,defaultMutationsOptions:n,...a})=>{const{libraries:r}=p.useContext(j),s=a?.QueryClient||r?.reactQuery?.QueryClient,c=a?.QueryClientProvider||r?.reactQuery?.QueryClientProvider;if(!s)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!we(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!be(s))throw new Error("Provided QueryClient dependencies are not valid.");const u=new s({defaultOptions:{mutations:{...n},queries:{getNextPageParam:(l,d,i)=>l.length+(i||0),refetchOnWindowFocus:!1,retry:3,...o}}});return P.jsx(c,{client:u,children:e})},Se=e=>{const{libraries:o}=p.useContext(j),n=e?.i18||o?.i18,a=e?.i18?.translateFunction||o?.i18?.translateFunction,r=n?.i18next?.t||a||(d=>d),{unknownErrorTranslationKey:s="error.unknownError"}=e||{},c=r(s),u=p.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:i}=d||{};if(i&&typeof i=="object"&&"reason"in i)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:E}=i.data;if(Array.isArray(E)&&E.length>0&&typeof E[0]=="object"&&E[0]!==null&&"msg"in E[0]){const{msg:m}=E[0];if(typeof m=="string")return String(m)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:p.useCallback(d=>{const{response:i}=d||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:u}},Ae=({data:e,fetchNextPage:o,isFetchingNextPage:n,isInitialLoading:a,isLoading:r,enabled:s=!0})=>{const c=p.useCallback(async l=>{n||!s||await o({pageParam:l?.pageParam||l.visibleRowsCount})},[s,o,n]),u=p.useMemo(()=>{if(e)return e.pages.reduce((l,d)=>[...l,...d],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:n||r,loadingVariant:a?"skeleton":"linear-progress",rows:u}},Ce=e=>{const{libraries:o}=p.useContext(j),n=e?.axios||o?.axios,a=e?.localStorageKey||"user";if(!n)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const r=p.useCallback(({tokenType:c,accessToken:u})=>{n.defaults.headers.common.Authorization=`${c} ${u}`},[n.defaults.headers.common]),s=()=>{n.defaults.headers.common.Authorization=null};return p.useEffect(()=>{if(L)return;const c=({newValue:u,key:l})=>{if(l===a&&u)try{const{accessToken:d,tokenType:i}=JSON.parse(u);r({accessToken:d,tokenType:i})}catch(d){console.error("Failed to parse newValue from localStorage:",d)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,r]),{clearAuthenticationToken:s,setAuthenticationToken:r}},J=({library:e,date:o,format:n="ll"})=>e(o).format(n),K=(e,o)=>{const{fractionDigits:n=0,metric:a="km",spacingBetween:r=!0}=o||{},s=Number(e),c=r?" ":"";return Number.isNaN(s)?`0${c}${a}`:`${s.toFixed(n)}${c}${a}`},B=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(n=>n.length>0?n.charAt(0).toUpperCase()+n.slice(1):n).join(" "),je=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,_e=({path:e,size:o,apiURL:n})=>{if(!e)return"";const a=je(e),r=`${n}${a}`,s=r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof o=="number"&&s?`${r.replace("/files",`/thumbs/${o}`)}`:r},Pe=e=>{const{apiURL:o,libraries:n}=p.useContext(j),a=e?.dayjs||n?.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 J({date:c,format:u,library:a})},distanceAdapter:K,filePathAdapter:(c,u)=>{if(!o)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:_e({apiURL:o,path:c,size:u})},worksiteNameAdapter:B}},D=(e,o)=>o==="short"?e.split("-")[0]:e,Te=(e,o="full")=>{const[n,a]=p.useState(()=>{const r=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,D(r,o)});return p.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(D(e.language,o));const r=s=>{a(D(s,o))};return e?.on?.("languageChanged",r),()=>{e?.off?.("languageChanged",r)}},[e,o]),n},ke="tracktor.filter",Ie={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},X=(e,o,n)=>`${n}_${e}=>${o}`,Oe=e=>{const{libraries:o,localStorageKeys:n}=p.useContext(j),a=e?.reactRouter||o?.reactRouter,{pathname:r}=a?.useLocation?.()??{pathname:"/"},[s,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],u=n?.filter||ke;if(L)return Ie;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const l=(m,h,S=!0)=>{const g=X(m,e?.pathname||r,u);if(!h||Array.isArray(h)&&!h.length){s.delete(m),c(s),localStorage.removeItem(g);return}S&&h&&localStorage.setItem(g,JSON.stringify({...s,[m]:h})),h&&(s.set(m,JSON.stringify(h)),c(s))};return{getFilter:(m,h)=>{const S=s.get(m);if(S)try{return JSON.parse(S)}catch{return S}const g=X(m,e?.pathname||r,u),A=localStorage.getItem(g);if(A)try{return JSON.parse(A)[m]}catch{}return h},getFilters:()=>{const m=Object.fromEntries(s.entries()),S=Object.keys(localStorage).filter(g=>g.startsWith(u)&&g.endsWith(e?.pathname||r)).reduce((g,A)=>{const C=localStorage.getItem(A);if(C){const I=JSON.parse(C),w=Object.keys(I)?.[0];g[w]=Object.values(I)?.[0]}return g},{});return{...m,...S}},handleFilter:(m,h)=>(S,g)=>{if(g||Array.isArray(g)&&g.length===0){const A=h||"value",C=typeof g=="object"&&A in g?g[A]:g;l(m,C);return}l(m,void 0)},setFilter:l}},xe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Ne=e=>{const a=e.split("/").filter(r=>r.length>0).map(r=>r.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},Le=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Fe=(e,o,n,a)=>{const r=Ne(o),s=xe(n),c=`${r}${s}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},De=(e,o)=>{const n={};return e?.forEach(a=>{n[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),o?.filter(a=>!n[a]).forEach(a=>{n[a]={query:{useQuery:!0}}}),Object.keys(n).length?n:void 0},Ye=e=>(Array.isArray(e)?e:[e]).reduce((n,a)=>{const{output:r,useInfiniteIds:s,useQueryIds:c,input:u="./openapi.json"}=a||{},l=Le(u);return{...n,[l]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:u,output:{baseUrl:r?.baseUrl,client:"react-query",mode:"tags-split",override:{...(s?.length||c?.length)&&{operations:De(s,c)},header:d=>["Generated by orval 🍺",...d.title?[d.title]:[],...d.description?[d.description]:[]],mutator:{name:"axiosCustomInstance",path:"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"},operationName:(d,i,E)=>Fe(d,i,E,c),query:{useQuery:!0}},schemas:r?.schemas||`src/api/${l}/model`,target:r?.target||`src/api/${l}/services/api.ts`,...r}}}},{});y.GTMSendPageView=fe,y.InitializeAxiosConfig=ge,y.InitializeDaysJSConfig=ve,y.InitializeI18nConfig=me,y.InitializeSentryConfig=ye,y.InjectDependenciesContext=j,y.InjectDependenciesProvider=ue,y.MaskTextField=he,y.PreloadErrorHandler=Ee,y.QueryClientProviderWithConfig=Re,y.RequireAuth=de,y.axiosCustomInstance=ae,y.dateAdapter=J,y.distanceAdapter=K,y.getOrvalConfig=Ye,y.useAdapter=Pe,y.useAuth=Ce,y.useCurrentLanguage=Te,y.useFilters=Oe,y.useInfiniteDataGrid=Ae,y.useResponseError=Se,y.worksiteNameAdapter=B,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracktor/shared-module",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"types": "./dist/main.d.ts",
|
|
@@ -13,12 +13,6 @@
|
|
|
13
13
|
"require": "./dist/main.umd.cjs",
|
|
14
14
|
"import": "./dist/main.js",
|
|
15
15
|
"default": "./dist/main.umd.cjs"
|
|
16
|
-
},
|
|
17
|
-
"./axios": {
|
|
18
|
-
"types": "./dist/axios.d.ts",
|
|
19
|
-
"require": "./dist/axios.cjs",
|
|
20
|
-
"import": "./dist/axios.js",
|
|
21
|
-
"default": "./dist/axios.cjs"
|
|
22
16
|
}
|
|
23
17
|
},
|
|
24
18
|
"repository": {
|
|
@@ -38,7 +32,7 @@
|
|
|
38
32
|
"prepare": "yarn run build && husky install"
|
|
39
33
|
},
|
|
40
34
|
"dependencies": {
|
|
41
|
-
"axios": "^1.
|
|
35
|
+
"axios": "^1.0.0"
|
|
42
36
|
},
|
|
43
37
|
"devDependencies": {
|
|
44
38
|
"@testing-library/jest-dom": "^5.17.0",
|
package/dist/axios.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./axiosCustomInstance-D3EHo-4p.cjs");exports.axiosCustomInstance=t.axiosCustomInstance;
|
package/dist/axios.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { axiosCustomInstance, type ErrorType, type BodyType } from './axios/axiosCustomInstance';
|
package/dist/axios.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const n=require("axios"),a=(s,o)=>{const e=n.CancelToken.source(),c=n({...s,...o,cancelToken:e.token}).then(({data:t})=>t);return c.cancel=()=>{e.cancel("Query was cancelled")},c};exports.axiosCustomInstance=a;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import n from "axios";
|
|
2
|
-
const r = (o, s) => {
|
|
3
|
-
const e = n.CancelToken.source(), c = n({
|
|
4
|
-
...o,
|
|
5
|
-
...s,
|
|
6
|
-
cancelToken: e.token
|
|
7
|
-
}).then(({ data: a }) => a);
|
|
8
|
-
return c.cancel = () => {
|
|
9
|
-
e.cancel("Query was cancelled");
|
|
10
|
-
}, c;
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
r as a
|
|
14
|
-
};
|
package/dist/main.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";var de=Object.create;var B=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty;var ye=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of pe(r))!me.call(e,n)&&n!==o&&B(e,n,{get:()=>r[n],enumerable:!(a=fe(r,n))||a.enumerable});return e};var X=(e,r,o)=>(o=e!=null?de(ge(e)):{},ye(r||!e||!e.__esModule?B(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const he=require("./axiosCustomInstance-D3EHo-4p.cjs"),g=require("react");var N={exports:{}},I={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var H;function ve(){if(H)return I;H=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(a,n,s){var c=null;if(s!==void 0&&(c=""+s),n.key!==void 0&&(c=""+n.key),"key"in n){s={};for(var u in n)u!=="key"&&(s[u]=n[u])}else s=n;return n=s.ref,{$$typeof:e,type:a,key:c,ref:n!==void 0?n:null,props:s}}return I.Fragment=r,I.jsx=o,I.jsxs=o,I}var k={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Z;function Ee(){return Z||(Z=1,process.env.NODE_ENV!=="production"&&function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===ce?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case p:return"Fragment";case A:return"Profiler";case S:return"StrictMode";case M:return"Suspense";case ae:return"SuspenseList";case ie:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case R:return"Portal";case E:return(t.displayName||"Context")+".Provider";case T:return(t._context.displayName||"Context")+".Consumer";case U:var f=t.render;return t=t.displayName,t||(t=f.displayName||f.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case se:return f=t.displayName||null,f!==null?f:e(t.type)||"Memo";case W:f=t._payload,t=t._init;try{return e(t(f))}catch{}}return null}function r(t){return""+t}function o(t){try{r(t);var f=!1}catch{f=!0}if(f){f=console;var h=f.error,w=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return h.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",w),r(t)}}function a(t){if(t===p)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===W)return"<...>";try{var f=e(t);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function n(){var t=F.A;return t===null?null:t.getOwner()}function s(){return Error("react-stack-top-frame")}function c(t){if(Q.call(t,"key")){var f=Object.getOwnPropertyDescriptor(t,"key").get;if(f&&f.isReactWarning)return!1}return t.key!==void 0}function u(t,f){function h(){V||(V=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",f))}h.isReactWarning=!0,Object.defineProperty(t,"key",{get:h,configurable:!0})}function l(){var t=e(this.type);return G[t]||(G[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function d(t,f,h,w,P,j,$,Y){return h=j.ref,t={$$typeof:y,type:t,key:f,props:j,_owner:P},(h!==void 0?h:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:l}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:$}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function i(t,f,h,w,P,j,$,Y){var b=f.children;if(b!==void 0)if(w)if(ue(b)){for(w=0;w<b.length;w++)v(b[w]);Object.freeze&&Object.freeze(b)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else v(b);if(Q.call(f,"key")){b=e(t);var x=Object.keys(f).filter(function(le){return le!=="key"});w=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",K[b+w]||(x=0<x.length?"{"+x.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
-
let props = %s;
|
|
19
|
-
<%s {...props} />
|
|
20
|
-
React keys must be passed directly to JSX without using spread:
|
|
21
|
-
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,w,b,x,b),K[b+w]=!0)}if(b=null,h!==void 0&&(o(h),b=""+h),c(f)&&(o(f.key),b=""+f.key),"key"in f){h={};for(var z in f)z!=="key"&&(h[z]=f[z])}else h=f;return b&&u(h,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,b,j,P,n(),h,$,Y)}function v(t){typeof t=="object"&&t!==null&&t.$$typeof===y&&t._store&&(t._store.validated=1)}var m=g,y=Symbol.for("react.transitional.element"),R=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),E=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),F=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=Object.prototype.hasOwnProperty,ue=Array.isArray,D=console.createTask?console.createTask:function(){return null};m={"react-stack-bottom-frame":function(t){return t()}};var V,G={},J=m["react-stack-bottom-frame"].bind(m,s)(),q=D(a(s)),K={};k.Fragment=p,k.jsx=function(t,f,h,w,P){var j=1e4>F.recentlyCreatedOwnerStacks++;return i(t,f,h,!1,w,P,j?Error("react-stack-top-frame"):J,j?D(a(t)):q)},k.jsxs=function(t,f,h,w,P){var j=1e4>F.recentlyCreatedOwnerStacks++;return i(t,f,h,!0,w,P,j?Error("react-stack-top-frame"):J,j?D(a(t)):q)}}()),k}var ee;function we(){return ee||(ee=1,process.env.NODE_ENV==="production"?N.exports=ve():N.exports=Ee()),N.exports}var _=we();const C=g.createContext({}),be=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=g.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return _.jsx(C.Provider,{value:n,children:e})},Re="user",Se=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:s,localStorageKeys:c}=g.useContext(C),u=n?.reactRouter||s?.reactRouter,l=n?.axios||s?.axios,d=n?.localStorageKey||c?.user||Re;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,v]=g.useState(null),{useLocation:m,Navigate:y,Outlet:R}=u,p=m(),S=g.useRef(!1),A=typeof r=="function"?r():!!r,T=typeof A=="boolean"?A:A?.isLogged;return g.useEffect(()=>{S.current||(S.current=!0,l.interceptors.response.use(E=>E,async E=>(typeof E=="object"&&E&&"response"in E&&E.response&&typeof E.response=="object"&&"status"in E.response&&E.response&&typeof E.response=="object"&&"status"in E.response&&E?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),v(a)),Promise.reject(E))))},[l.defaults.headers.common,l.interceptors.response,d,a]),T&&!i?_.jsx(g.Suspense,{fallback:e,children:p.state?.from?.state&&p.state?.from?.pathname===o?_.jsx(y,{to:p.state.from.state.from.pathname+p.state.from.state.from.search,replace:!0}):_.jsx(R,{})}):_.jsx(y,{to:o+p.search,state:{from:p},replace:!0})},Ae=({data:e,...r})=>{const{libraries:o}=g.useContext(C),a=r?.reactRouter||o?.reactRouter,n=r?.gtm||o?.gtm;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!n)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:s}=n,{useLocation:c,Outlet:u}=a,{pathname:l}=c(),{sendEvent:d}=s();return g.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),_.jsx(u,{})},O=(()=>{try{return typeof global=="object"&&global!==null&&("HermesInternal"in global||"__fbBatchedBridge"in global||"__metro"in global)||typeof window>"u"&&typeof global<"u"?!0:typeof navigator<"u"&&navigator.userAgent?/react.native|ReactNative/i.test(navigator.userAgent):!1}catch{return!1}})(),Ce="user",je=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:s,localStorageKeys:c}=g.useContext(C),u=a?.userLocalStorageKey||c?.user||Ce,l=a?.axios||s?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||O)return null;if(typeof window<"u"&&window.localStorage){const d=localStorage.getItem(u),i=d?JSON.parse(d):null,v=i?.[e]?i[e]:null,m=i?.[r]?i[r]:null,y=d?`${v} ${m}`:null;y&&(l.defaults.headers.common.Authorization=y)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=o,null},_e=({debug:e,resources:r,...o})=>{const{libraries:a}=g.useContext(C),n=o?.i18||a?.i18,{i18next:s,initReactI18next:c,languageDetector:u}=n||{};if(O)return null;if(!n)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return s?.isInitialized||(s.use(u).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:r,returnNull:!1}).then(()=>{document.documentElement.lang!==s.resolvedLanguage&&s.resolvedLanguage&&document.documentElement.setAttribute("lang",s.resolvedLanguage)}),s.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},Pe=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:s,ignoreErrors:c,debug:u,environment:l,release:d,...i})=>{const{libraries:v}=g.useContext(C),m=i?.sentry||v?.sentry,y=i?.reactRouter||v?.reactRouter;if(!m)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!y)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(m.isInitialized())return null;const{createRoutesFromChildren:R,matchRoutes:p,useLocation:S,useNavigationType:A}=y;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&m.init({debug:u,dsn:e,environment:l||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[m.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:R,matchRoutes:p,useEffect:g.useEffect,useLocation:S,useNavigationType:A}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:s,tracesSampleRate:o||1}),null},Te=({IMaskMixin:e,...r})=>{const o=g.useMemo(()=>e(({TextField:a,...n})=>_.jsx(a,{...n})),[e]);return _.jsx(o,{...r})},xe=({language:e,...r})=>{const{libraries:o}=g.useContext(C),a=r?.dayjs||o?.dayjs,n=r?.plugin||o?.dayjsPlugin;if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return g.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";n&&n.forEach(u=>{u&&a.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,n,e]),null},Ie=()=>(g.useEffect(()=>{if(O)return;const e=r=>{try{r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),ke=e=>e&&typeof e=="function",Oe=e=>e&&typeof e=="function",Ne=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=g.useContext(C),s=a?.QueryClient||n?.reactQuery?.QueryClient,c=a?.QueryClientProvider||n?.reactQuery?.QueryClientProvider;if(!s)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!ke(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Oe(s))throw new Error("Provided QueryClient dependencies are not valid.");const u=new s({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,d,i)=>l.length+(i||0),refetchOnWindowFocus:!1,retry:3,...r}}});return _.jsx(c,{client:u,children:e})},Le=e=>{const{libraries:r}=g.useContext(C),o=e?.i18||r?.i18,a=e?.i18?.translateFunction||r?.i18?.translateFunction,n=o?.i18next?.t||a||(d=>d),{unknownErrorTranslationKey:s="error.unknownError"}=e||{},c=n(s),u=g.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:i}=d||{};if(i&&typeof i=="object"&&"reason"in i)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:v}=i.data;if(Array.isArray(v)&&v.length>0&&typeof v[0]=="object"&&v[0]!==null&&"msg"in v[0]){const{msg:m}=v[0];if(typeof m=="string")return String(m)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:g.useCallback(d=>{const{response:i}=d||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:u}},Fe=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:s=!0})=>{const c=g.useCallback(async l=>{o||!s||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[s,r,o]),u=g.useMemo(()=>{if(e)return e.pages.reduce((l,d)=>[...l,...d],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||n,loadingVariant:a?"skeleton":"linear-progress",rows:u}},De=e=>{const{libraries:r}=g.useContext(C),o=e?.axios||r?.axios,a=e?.localStorageKey||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const n=g.useCallback(({tokenType:c,accessToken:u})=>{o.defaults.headers.common.Authorization=`${c} ${u}`},[o.defaults.headers.common]),s=()=>{o.defaults.headers.common.Authorization=null};return g.useEffect(()=>{if(O)return;const c=({newValue:u,key:l})=>{if(l===a&&u)try{const{accessToken:d,tokenType:i}=JSON.parse(u);n({accessToken:d,tokenType:i})}catch(d){console.error("Failed to parse newValue from localStorage:",d)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,n]),{clearAuthenticationToken:s,setAuthenticationToken:n}},re=({library:e,date:r,format:o="ll"})=>e(r).format(o),ne=(e,r)=>{const{fractionDigits:o=0,metric:a="km"}=r||{},n=Number(e);return Number.isNaN(n)?`0${a}`:`${n.toFixed(o)}${a}`},oe=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),$e=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ye=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=$e(e),n=`${o}${a}`,s=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&s?`${n.replace("/files",`/thumbs/${r}`)}`:n},ze=e=>{const{apiURL:r,libraries:o}=g.useContext(C),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,u)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return re({date:c,format:u,library:a})},distanceAdapter:ne,filePathAdapter:(c,u)=>{if(!r)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return typeof c=="string"&&/^https?:\/\//.test(c)?c:Ye({apiURL:r,path:c,size:u})},worksiteNameAdapter:oe}},L=(e,r)=>r==="short"?e.split("-")[0]:e,Ue=(e,r="full")=>{const[o,a]=g.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,L(n,r)});return g.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(L(e.language,r));const n=s=>{a(L(s,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Me="tracktor.filter",We={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},te=(e,r,o)=>`${o}_${e}=>${r}`,Qe=e=>{const{libraries:r,localStorageKeys:o}=g.useContext(C),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[s,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],u=o?.filter||Me;if(O)return We;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const l=(m,y,R=!0)=>{const p=te(m,e?.pathname||n,u);if(!y||Array.isArray(y)&&!y.length){s.delete(m),c(s),localStorage.removeItem(p);return}R&&y&&localStorage.setItem(p,JSON.stringify({...s,[m]:y})),y&&(s.set(m,JSON.stringify(y)),c(s))};return{getFilter:(m,y)=>{const R=s.get(m);if(R)try{return JSON.parse(R)}catch{return R}const p=te(m,e?.pathname||n,u),S=localStorage.getItem(p);if(S)try{return JSON.parse(S)[m]}catch{}return y},getFilters:()=>{const m=Object.fromEntries(s.entries()),R=Object.keys(localStorage).filter(p=>p.startsWith(u)&&p.endsWith(e?.pathname||n)).reduce((p,S)=>{const A=localStorage.getItem(S);if(A){const T=JSON.parse(A),E=Object.keys(T)?.[0];p[E]=Object.values(T)?.[0]}return p},{});return{...m,...R}},handleFilter:(m,y)=>(R,p)=>{if(p||Array.isArray(p)&&p.length===0){const S=y||"value",A=typeof p=="object"&&S in p?p[S]:p;l(m,A);return}l(m,void 0)},setFilter:l}},Ve=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Ge=e=>{const a=e.split("/").filter(n=>n.length>0).map(n=>n.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},Je=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),qe=(e,r,o,a)=>{const n=Ge(r),s=Ve(o),c=`${n}${s}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Ke=(e,r)=>{const o={};return e?.forEach(a=>{o[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),r?.filter(a=>!o[a]).forEach(a=>{o[a]={query:{useQuery:!0}}}),Object.keys(o).length?o:void 0},Be=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:s,useQueryIds:c,input:u="./openapi.json"}=a||{},l=Je(u);return{...o,[l]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(s?.length||c?.length)&&{operations:Ke(s,c)},header:d=>["Generated by orval 🍺",...d.title?[d.title]:[],...d.description?[d.description]:[]],mutator:{name:"axiosCustomInstance",path:"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"},operationName:(d,i,v)=>qe(d,i,v,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${l}/model`,target:n?.target||`src/api/${l}/services/api.ts`,...n}}}},{});exports.axiosCustomInstance=he.axiosCustomInstance;exports.GTMSendPageView=Ae;exports.InitializeAxiosConfig=je;exports.InitializeDaysJSConfig=xe;exports.InitializeI18nConfig=_e;exports.InitializeSentryConfig=Pe;exports.InjectDependenciesContext=C;exports.InjectDependenciesProvider=be;exports.MaskTextField=Te;exports.PreloadErrorHandler=Ie;exports.QueryClientProviderWithConfig=Ne;exports.RequireAuth=Se;exports.dateAdapter=re;exports.distanceAdapter=ne;exports.getOrvalConfig=Be;exports.useAdapter=ze;exports.useAuth=De;exports.useCurrentLanguage=Ue;exports.useFilters=Qe;exports.useInfiniteDataGrid=Fe;exports.useResponseError=Le;exports.worksiteNameAdapter=oe;
|