@tracktor/shared-module 2.19.6 → 2.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useFilters.d.ts +5 -0
- package/dist/main.js +317 -316
- package/dist/main.umd.cjs +2 -2
- package/package.json +4 -2
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fe, { useMemo as
|
|
3
|
-
const
|
|
4
|
-
const o =
|
|
1
|
+
import Z from "axios";
|
|
2
|
+
import fe, { useMemo as G, createContext as pe, useContext as P, useEffect as j, useState as W, Suspense as ge, useRef as me, useCallback as O } from "react";
|
|
3
|
+
const We = (e, r) => {
|
|
4
|
+
const o = Z.CancelToken.source(), a = Z({
|
|
5
5
|
...e,
|
|
6
6
|
...r,
|
|
7
7
|
cancelToken: o.token
|
|
@@ -10,48 +10,48 @@ const Ye = (e, r) => {
|
|
|
10
10
|
o.cancel("Query was cancelled");
|
|
11
11
|
}, a;
|
|
12
12
|
};
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
if (
|
|
17
|
-
|
|
13
|
+
var D = { exports: {} }, L = {};
|
|
14
|
+
var ee;
|
|
15
|
+
function he() {
|
|
16
|
+
if (ee) return L;
|
|
17
|
+
ee = 1;
|
|
18
18
|
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
19
|
-
function o(a, n,
|
|
19
|
+
function o(a, n, s) {
|
|
20
20
|
var c = null;
|
|
21
|
-
if (
|
|
22
|
-
|
|
21
|
+
if (s !== void 0 && (c = "" + s), n.key !== void 0 && (c = "" + n.key), "key" in n) {
|
|
22
|
+
s = {};
|
|
23
23
|
for (var u in n)
|
|
24
|
-
u !== "key" && (
|
|
25
|
-
} else
|
|
26
|
-
return n =
|
|
24
|
+
u !== "key" && (s[u] = n[u]);
|
|
25
|
+
} else s = n;
|
|
26
|
+
return n = s.ref, {
|
|
27
27
|
$$typeof: e,
|
|
28
28
|
type: a,
|
|
29
29
|
key: c,
|
|
30
30
|
ref: n !== void 0 ? n : null,
|
|
31
|
-
props:
|
|
31
|
+
props: s
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return L.Fragment = r, L.jsx = o, L.jsxs = o, L;
|
|
35
35
|
}
|
|
36
36
|
var N = {};
|
|
37
|
-
var
|
|
37
|
+
var te;
|
|
38
38
|
function ye() {
|
|
39
|
-
return
|
|
39
|
+
return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
40
40
|
function e(t) {
|
|
41
41
|
if (t == null) return null;
|
|
42
42
|
if (typeof t == "function")
|
|
43
43
|
return t.$$typeof === le ? null : t.displayName || t.name || null;
|
|
44
44
|
if (typeof t == "string") return t;
|
|
45
45
|
switch (t) {
|
|
46
|
-
case m:
|
|
47
|
-
return "Fragment";
|
|
48
46
|
case T:
|
|
47
|
+
return "Fragment";
|
|
48
|
+
case f:
|
|
49
49
|
return "Profiler";
|
|
50
50
|
case h:
|
|
51
51
|
return "StrictMode";
|
|
52
|
-
case
|
|
52
|
+
case I:
|
|
53
53
|
return "Suspense";
|
|
54
|
-
case
|
|
54
|
+
case ie:
|
|
55
55
|
return "SuspenseList";
|
|
56
56
|
case ce:
|
|
57
57
|
return "Activity";
|
|
@@ -60,21 +60,21 @@ function ye() {
|
|
|
60
60
|
switch (typeof t.tag == "number" && console.error(
|
|
61
61
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
62
62
|
), t.$$typeof) {
|
|
63
|
-
case
|
|
63
|
+
case A:
|
|
64
64
|
return "Portal";
|
|
65
|
-
case
|
|
65
|
+
case R:
|
|
66
66
|
return t.displayName || "Context";
|
|
67
|
-
case
|
|
67
|
+
case b:
|
|
68
68
|
return (t._context.displayName || "Context") + ".Consumer";
|
|
69
|
-
case
|
|
70
|
-
var
|
|
71
|
-
return t = t.displayName, t || (t =
|
|
72
|
-
case
|
|
73
|
-
return
|
|
74
|
-
case
|
|
75
|
-
|
|
69
|
+
case _:
|
|
70
|
+
var p = t.render;
|
|
71
|
+
return t = t.displayName, t || (t = p.displayName || p.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
72
|
+
case se:
|
|
73
|
+
return p = t.displayName || null, p !== null ? p : e(t.type) || "Memo";
|
|
74
|
+
case z:
|
|
75
|
+
p = t._payload, t = t._init;
|
|
76
76
|
try {
|
|
77
|
-
return e(t(
|
|
77
|
+
return e(t(p));
|
|
78
78
|
} catch {
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -86,54 +86,54 @@ function ye() {
|
|
|
86
86
|
function o(t) {
|
|
87
87
|
try {
|
|
88
88
|
r(t);
|
|
89
|
-
var
|
|
89
|
+
var p = !1;
|
|
90
90
|
} catch {
|
|
91
|
-
|
|
91
|
+
p = !0;
|
|
92
92
|
}
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
var
|
|
96
|
-
return
|
|
97
|
-
|
|
93
|
+
if (p) {
|
|
94
|
+
p = console;
|
|
95
|
+
var y = p.error, w = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
96
|
+
return y.call(
|
|
97
|
+
p,
|
|
98
98
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
99
99
|
w
|
|
100
100
|
), r(t);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
function a(t) {
|
|
104
|
-
if (t ===
|
|
105
|
-
if (typeof t == "object" && t !== null && t.$$typeof ===
|
|
104
|
+
if (t === T) return "<>";
|
|
105
|
+
if (typeof t == "object" && t !== null && t.$$typeof === z)
|
|
106
106
|
return "<...>";
|
|
107
107
|
try {
|
|
108
|
-
var
|
|
109
|
-
return
|
|
108
|
+
var p = e(t);
|
|
109
|
+
return p ? "<" + p + ">" : "<...>";
|
|
110
110
|
} catch {
|
|
111
111
|
return "<...>";
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
function n() {
|
|
115
|
-
var t =
|
|
115
|
+
var t = U.A;
|
|
116
116
|
return t === null ? null : t.getOwner();
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function s() {
|
|
119
119
|
return Error("react-stack-top-frame");
|
|
120
120
|
}
|
|
121
121
|
function c(t) {
|
|
122
|
-
if (
|
|
123
|
-
var
|
|
124
|
-
if (
|
|
122
|
+
if (J.call(t, "key")) {
|
|
123
|
+
var p = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
124
|
+
if (p && p.isReactWarning) return !1;
|
|
125
125
|
}
|
|
126
126
|
return t.key !== void 0;
|
|
127
127
|
}
|
|
128
|
-
function u(t,
|
|
129
|
-
function
|
|
130
|
-
|
|
128
|
+
function u(t, p) {
|
|
129
|
+
function y() {
|
|
130
|
+
q || (q = !0, console.error(
|
|
131
131
|
"%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)",
|
|
132
|
-
|
|
132
|
+
p
|
|
133
133
|
));
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
get:
|
|
135
|
+
y.isReactWarning = !0, Object.defineProperty(t, "key", {
|
|
136
|
+
get: y,
|
|
137
137
|
configurable: !0
|
|
138
138
|
});
|
|
139
139
|
}
|
|
@@ -143,15 +143,15 @@ function ye() {
|
|
|
143
143
|
"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."
|
|
144
144
|
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
145
145
|
}
|
|
146
|
-
function d(t,
|
|
147
|
-
var
|
|
146
|
+
function d(t, p, y, w, $, V) {
|
|
147
|
+
var E = y.ref;
|
|
148
148
|
return t = {
|
|
149
149
|
$$typeof: k,
|
|
150
150
|
type: t,
|
|
151
|
-
key:
|
|
152
|
-
props:
|
|
151
|
+
key: p,
|
|
152
|
+
props: y,
|
|
153
153
|
_owner: w
|
|
154
|
-
}, (
|
|
154
|
+
}, (E !== void 0 ? E : null) !== null ? Object.defineProperty(t, "ref", {
|
|
155
155
|
enumerable: !1,
|
|
156
156
|
get: l
|
|
157
157
|
}) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
|
|
@@ -168,33 +168,33 @@ function ye() {
|
|
|
168
168
|
configurable: !1,
|
|
169
169
|
enumerable: !1,
|
|
170
170
|
writable: !0,
|
|
171
|
-
value:
|
|
171
|
+
value: $
|
|
172
172
|
}), Object.defineProperty(t, "_debugTask", {
|
|
173
173
|
configurable: !1,
|
|
174
174
|
enumerable: !1,
|
|
175
175
|
writable: !0,
|
|
176
|
-
value:
|
|
176
|
+
value: V
|
|
177
177
|
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
var
|
|
181
|
-
if (
|
|
179
|
+
function i(t, p, y, w, $, V) {
|
|
180
|
+
var E = p.children;
|
|
181
|
+
if (E !== void 0)
|
|
182
182
|
if (w)
|
|
183
|
-
if (ue(
|
|
184
|
-
for (w = 0; w <
|
|
185
|
-
|
|
186
|
-
Object.freeze && Object.freeze(
|
|
183
|
+
if (ue(E)) {
|
|
184
|
+
for (w = 0; w < E.length; w++)
|
|
185
|
+
m(E[w]);
|
|
186
|
+
Object.freeze && Object.freeze(E);
|
|
187
187
|
} else
|
|
188
188
|
console.error(
|
|
189
189
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
190
190
|
);
|
|
191
|
-
else
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
var
|
|
191
|
+
else m(E);
|
|
192
|
+
if (J.call(p, "key")) {
|
|
193
|
+
E = e(t);
|
|
194
|
+
var x = Object.keys(p).filter(function(de) {
|
|
195
195
|
return de !== "key";
|
|
196
196
|
});
|
|
197
|
-
w = 0 <
|
|
197
|
+
w = 0 < x.length ? "{key: someKey, " + x.join(": ..., ") + ": ...}" : "{key: someKey}", X[E + w] || (x = 0 < x.length ? "{" + x.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
198
198
|
`A props object containing a "key" prop is being spread into JSX:
|
|
199
199
|
let props = %s;
|
|
200
200
|
<%s {...props} />
|
|
@@ -202,83 +202,83 @@ React keys must be passed directly to JSX without using spread:
|
|
|
202
202
|
let props = %s;
|
|
203
203
|
<%s key={someKey} {...props} />`,
|
|
204
204
|
w,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
),
|
|
205
|
+
E,
|
|
206
|
+
x,
|
|
207
|
+
E
|
|
208
|
+
), X[E + w] = !0);
|
|
209
209
|
}
|
|
210
|
-
if (
|
|
211
|
-
|
|
212
|
-
for (var
|
|
213
|
-
|
|
214
|
-
} else
|
|
215
|
-
return
|
|
216
|
-
|
|
210
|
+
if (E = null, y !== void 0 && (o(y), E = "" + y), c(p) && (o(p.key), E = "" + p.key), "key" in p) {
|
|
211
|
+
y = {};
|
|
212
|
+
for (var M in p)
|
|
213
|
+
M !== "key" && (y[M] = p[M]);
|
|
214
|
+
} else y = p;
|
|
215
|
+
return E && u(
|
|
216
|
+
y,
|
|
217
217
|
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
218
218
|
), d(
|
|
219
219
|
t,
|
|
220
|
-
R,
|
|
221
220
|
E,
|
|
221
|
+
y,
|
|
222
222
|
n(),
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
$,
|
|
224
|
+
V
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
|
|
227
|
+
function m(t) {
|
|
228
|
+
g(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === z && (t._payload.status === "fulfilled" ? g(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function g(t) {
|
|
231
231
|
return typeof t == "object" && t !== null && t.$$typeof === k;
|
|
232
232
|
}
|
|
233
|
-
var
|
|
233
|
+
var v = fe, k = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), h = /* @__PURE__ */ Symbol.for("react.strict_mode"), f = /* @__PURE__ */ Symbol.for("react.profiler"), b = /* @__PURE__ */ Symbol.for("react.consumer"), R = /* @__PURE__ */ Symbol.for("react.context"), _ = /* @__PURE__ */ Symbol.for("react.forward_ref"), I = /* @__PURE__ */ Symbol.for("react.suspense"), ie = /* @__PURE__ */ Symbol.for("react.suspense_list"), se = /* @__PURE__ */ Symbol.for("react.memo"), z = /* @__PURE__ */ Symbol.for("react.lazy"), ce = /* @__PURE__ */ Symbol.for("react.activity"), le = /* @__PURE__ */ Symbol.for("react.client.reference"), U = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ue = Array.isArray, Q = console.createTask ? console.createTask : function() {
|
|
234
234
|
return null;
|
|
235
235
|
};
|
|
236
|
-
|
|
236
|
+
v = {
|
|
237
237
|
react_stack_bottom_frame: function(t) {
|
|
238
238
|
return t();
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
|
-
var
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
)(), B =
|
|
245
|
-
N.Fragment =
|
|
246
|
-
var w = 1e4 >
|
|
247
|
-
return
|
|
241
|
+
var q, K = {}, H = v.react_stack_bottom_frame.bind(
|
|
242
|
+
v,
|
|
243
|
+
s
|
|
244
|
+
)(), B = Q(a(s)), X = {};
|
|
245
|
+
N.Fragment = T, N.jsx = function(t, p, y) {
|
|
246
|
+
var w = 1e4 > U.recentlyCreatedOwnerStacks++;
|
|
247
|
+
return i(
|
|
248
248
|
t,
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
p,
|
|
250
|
+
y,
|
|
251
251
|
!1,
|
|
252
|
-
w ? Error("react-stack-top-frame") :
|
|
253
|
-
w ?
|
|
252
|
+
w ? Error("react-stack-top-frame") : H,
|
|
253
|
+
w ? Q(a(t)) : B
|
|
254
254
|
);
|
|
255
|
-
}, N.jsxs = function(t,
|
|
256
|
-
var w = 1e4 >
|
|
257
|
-
return
|
|
255
|
+
}, N.jsxs = function(t, p, y) {
|
|
256
|
+
var w = 1e4 > U.recentlyCreatedOwnerStacks++;
|
|
257
|
+
return i(
|
|
258
258
|
t,
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
p,
|
|
260
|
+
y,
|
|
261
261
|
!0,
|
|
262
|
-
w ? Error("react-stack-top-frame") :
|
|
263
|
-
w ?
|
|
262
|
+
w ? Error("react-stack-top-frame") : H,
|
|
263
|
+
w ? Q(a(t)) : B
|
|
264
264
|
);
|
|
265
265
|
};
|
|
266
266
|
})()), N;
|
|
267
267
|
}
|
|
268
|
-
var
|
|
269
|
-
function
|
|
270
|
-
return
|
|
268
|
+
var re;
|
|
269
|
+
function ve() {
|
|
270
|
+
return re || (re = 1, process.env.NODE_ENV === "production" ? D.exports = he() : D.exports = ye()), D.exports;
|
|
271
271
|
}
|
|
272
|
-
var C =
|
|
273
|
-
const
|
|
274
|
-
const o =
|
|
272
|
+
var C = ve();
|
|
273
|
+
const ze = ({ IMaskMixin: e, ...r }) => {
|
|
274
|
+
const o = G(
|
|
275
275
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
276
276
|
() => e(({ TextField: a, ...n }) => /* @__PURE__ */ C.jsx(a, { ...n })),
|
|
277
277
|
[e]
|
|
278
278
|
);
|
|
279
279
|
return /* @__PURE__ */ C.jsx(o, { ...r });
|
|
280
|
-
},
|
|
281
|
-
const n =
|
|
280
|
+
}, S = pe({}), Ue = ({ children: e, apiURL: r, libraries: o, localStorageKeys: a }) => {
|
|
281
|
+
const n = G(
|
|
282
282
|
() => ({
|
|
283
283
|
apiURL: r,
|
|
284
284
|
libraries: o,
|
|
@@ -286,16 +286,16 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
286
286
|
}),
|
|
287
287
|
[r, o, a]
|
|
288
288
|
);
|
|
289
|
-
return /* @__PURE__ */ C.jsx(
|
|
290
|
-
},
|
|
291
|
-
const { libraries: o } = P(
|
|
289
|
+
return /* @__PURE__ */ C.jsx(S.Provider, { value: n, children: e });
|
|
290
|
+
}, Qe = ({ data: e, ...r }) => {
|
|
291
|
+
const { libraries: o } = P(S), a = r?.reactRouter || o?.reactRouter, n = r?.gtm || o?.gtm;
|
|
292
292
|
if (!a)
|
|
293
293
|
throw new Error(
|
|
294
294
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView."
|
|
295
295
|
);
|
|
296
296
|
if (!n)
|
|
297
297
|
throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
|
|
298
|
-
const { useGoogleTagManager:
|
|
298
|
+
const { useGoogleTagManager: s } = n, { useLocation: c, Outlet: u } = a, { pathname: l } = c(), { sendEvent: d } = s();
|
|
299
299
|
return j(() => {
|
|
300
300
|
d({
|
|
301
301
|
event: "pageView",
|
|
@@ -303,7 +303,7 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
303
303
|
...e
|
|
304
304
|
});
|
|
305
305
|
}, [e, l, d]), /* @__PURE__ */ C.jsx(u, {});
|
|
306
|
-
},
|
|
306
|
+
}, F = (() => {
|
|
307
307
|
try {
|
|
308
308
|
return typeof global == "object" && global !== null && ("HermesInternal" in global || // Hermes JS engine
|
|
309
309
|
"__fbBatchedBridge" in global || // RN Bridge
|
|
@@ -311,24 +311,24 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
311
311
|
} catch {
|
|
312
312
|
return !1;
|
|
313
313
|
}
|
|
314
|
-
})(),
|
|
314
|
+
})(), we = "user", Ve = ({
|
|
315
315
|
tokenTypeKey: e = "tokenType",
|
|
316
316
|
tokenKey: r = "accessToken",
|
|
317
317
|
postContentType: o = "application/json",
|
|
318
318
|
...a
|
|
319
319
|
}) => {
|
|
320
|
-
const { apiURL: n = a.apiURL, libraries:
|
|
320
|
+
const { apiURL: n = a.apiURL, libraries: s, localStorageKeys: c } = P(S), u = a?.userLocalStorageKey || c?.user || we, l = a?.axios || s?.axios;
|
|
321
321
|
if (!l)
|
|
322
322
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
323
|
-
if (!l?.defaults ||
|
|
323
|
+
if (!l?.defaults || F)
|
|
324
324
|
return null;
|
|
325
325
|
if (typeof window < "u" && window.localStorage) {
|
|
326
|
-
const d = localStorage.getItem(u),
|
|
327
|
-
|
|
326
|
+
const d = localStorage.getItem(u), i = d ? JSON.parse(d) : null, m = i?.[e] ? i[e] : null, g = i?.[r] ? i[r] : null, v = d ? `${m} ${g}` : null;
|
|
327
|
+
v && (l.defaults.headers.common.Authorization = v);
|
|
328
328
|
}
|
|
329
329
|
return l.defaults.baseURL = n, l.defaults.headers.post["Content-Type"] = o, null;
|
|
330
|
-
},
|
|
331
|
-
const { libraries: o } = P(
|
|
330
|
+
}, Me = ({ language: e, ...r }) => {
|
|
331
|
+
const { libraries: o } = P(S), a = r?.dayjs || o?.dayjs, n = r?.plugin || o?.dayjsPlugin;
|
|
332
332
|
if (!a)
|
|
333
333
|
throw new Error(
|
|
334
334
|
"Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
|
|
@@ -341,13 +341,13 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
341
341
|
}), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), a.locale(c);
|
|
342
342
|
})().then();
|
|
343
343
|
}, [a, n, e]), null;
|
|
344
|
-
},
|
|
345
|
-
const { libraries: a } = P(
|
|
346
|
-
if (
|
|
344
|
+
}, Ge = ({ debug: e, resources: r, ...o }) => {
|
|
345
|
+
const { libraries: a } = P(S), n = o?.i18 || a?.i18, { i18next: s, initReactI18next: c, languageDetector: u } = n || {};
|
|
346
|
+
if (F)
|
|
347
347
|
return null;
|
|
348
348
|
if (!n)
|
|
349
349
|
throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
350
|
-
return
|
|
350
|
+
return s?.isInitialized || (s.use(u).use(c).init({
|
|
351
351
|
debug: e,
|
|
352
352
|
fallbackLng: "en",
|
|
353
353
|
interpolation: {
|
|
@@ -361,32 +361,32 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
361
361
|
resources: r,
|
|
362
362
|
returnNull: !1
|
|
363
363
|
}).then(() => {
|
|
364
|
-
document.documentElement.lang !==
|
|
365
|
-
}),
|
|
364
|
+
document.documentElement.lang !== s.resolvedLanguage && s.resolvedLanguage && document.documentElement.setAttribute("lang", s.resolvedLanguage);
|
|
365
|
+
}), s.on("languageChanged", (l) => {
|
|
366
366
|
document.documentElement.setAttribute("lang", l);
|
|
367
367
|
})), null;
|
|
368
|
-
},
|
|
368
|
+
}, Je = ({
|
|
369
369
|
dsn: e,
|
|
370
370
|
integrations: r,
|
|
371
371
|
tracesSampleRate: o,
|
|
372
372
|
replaysSessionSampleRate: a,
|
|
373
373
|
replaysOnErrorSampleRate: n,
|
|
374
|
-
tracePropagationTargets:
|
|
374
|
+
tracePropagationTargets: s,
|
|
375
375
|
ignoreErrors: c,
|
|
376
376
|
debug: u,
|
|
377
377
|
environment: l,
|
|
378
378
|
release: d,
|
|
379
|
-
...
|
|
379
|
+
...i
|
|
380
380
|
}) => {
|
|
381
|
-
const { libraries:
|
|
382
|
-
if (!
|
|
381
|
+
const { libraries: m } = P(S), g = i?.sentry || m?.sentry, v = i?.reactRouter || m?.reactRouter;
|
|
382
|
+
if (!g)
|
|
383
383
|
throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
384
|
-
if (!
|
|
384
|
+
if (!v)
|
|
385
385
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
386
|
-
if (
|
|
386
|
+
if (g.isInitialized())
|
|
387
387
|
return null;
|
|
388
|
-
const { createRoutesFromChildren: k, matchRoutes:
|
|
389
|
-
return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") &&
|
|
388
|
+
const { createRoutesFromChildren: k, matchRoutes: A, useLocation: T, useNavigationType: h } = v;
|
|
389
|
+
return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && g.init({
|
|
390
390
|
debug: u,
|
|
391
391
|
dsn: e,
|
|
392
392
|
environment: l || "production",
|
|
@@ -400,11 +400,11 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
400
400
|
/vite:preloadError/
|
|
401
401
|
],
|
|
402
402
|
integrations: [
|
|
403
|
-
|
|
403
|
+
g.reactRouterV6BrowserTracingIntegration({
|
|
404
404
|
createRoutesFromChildren: k,
|
|
405
|
-
matchRoutes:
|
|
405
|
+
matchRoutes: A,
|
|
406
406
|
useEffect: j,
|
|
407
|
-
useLocation:
|
|
407
|
+
useLocation: T,
|
|
408
408
|
useNavigationType: h
|
|
409
409
|
}),
|
|
410
410
|
...r || []
|
|
@@ -412,11 +412,11 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
412
412
|
release: d,
|
|
413
413
|
replaysOnErrorSampleRate: n || 1,
|
|
414
414
|
replaysSessionSampleRate: a || 0.1,
|
|
415
|
-
tracePropagationTargets:
|
|
415
|
+
tracePropagationTargets: s,
|
|
416
416
|
tracesSampleRate: o || 1
|
|
417
417
|
}), null;
|
|
418
|
-
},
|
|
419
|
-
if (
|
|
418
|
+
}, qe = () => (j(() => {
|
|
419
|
+
if (F)
|
|
420
420
|
return;
|
|
421
421
|
const e = (r) => {
|
|
422
422
|
try {
|
|
@@ -427,18 +427,18 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
427
427
|
return window.addEventListener("vite:preloadError", e), () => {
|
|
428
428
|
window.removeEventListener("vite:preloadError", e);
|
|
429
429
|
};
|
|
430
|
-
}, []), null), Ee = "user", Ke = ({ Fallback: e, isLogged: r, loginPath: o = "/login", redirect401Path: a = "/login", ...n }) => {
|
|
431
|
-
const { libraries:
|
|
430
|
+
}, []), null), ne = /* @__PURE__ */ new WeakMap(), Ee = "user", Ke = ({ Fallback: e, isLogged: r, loginPath: o = "/login", redirect401Path: a = "/login", ...n }) => {
|
|
431
|
+
const { libraries: s, localStorageKeys: c } = P(S), u = n?.reactRouter || s?.reactRouter, l = n?.axios || s?.axios, d = n?.localStorageKey || c?.user || Ee;
|
|
432
432
|
if (!u)
|
|
433
433
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
434
|
-
const [
|
|
434
|
+
const [i, m] = W(null), { useLocation: g, Navigate: v, Outlet: k } = u, A = g(), T = typeof r == "function" ? r() : !!r, h = typeof T == "boolean" ? T : T?.isLogged;
|
|
435
435
|
return j(() => {
|
|
436
|
-
|
|
437
|
-
(
|
|
438
|
-
|
|
436
|
+
ne.has(l) || (ne.set(l, !0), l.interceptors.response.use(
|
|
437
|
+
(f) => f,
|
|
438
|
+
(f) => (typeof f == "object" && f && "response" in f && f.response && typeof f.response == "object" && "status" in f.response && f.response && typeof f.response == "object" && "status" in f.response && f?.response?.status === 401 && (typeof f == "object" && f && "config" in f && f.config && typeof f.config == "object" && "headers" in f.config && f.config.headers && typeof f.config.headers == "object" && "Authorization" in f.config.headers && f.config.headers.Authorization && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(d)), m(a)), Promise.reject(f))
|
|
439
439
|
));
|
|
440
|
-
}, [l
|
|
441
|
-
},
|
|
440
|
+
}, [l, d, a]), h && !i ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: A.state?.from?.state && A.state?.from?.pathname === o ? /* @__PURE__ */ C.jsx(v, { to: A.state.from.state.from.pathname + A.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(k, {}) }) : /* @__PURE__ */ C.jsx(v, { to: o + A.search, state: { from: A }, replace: !0 });
|
|
441
|
+
}, Re = async () => {
|
|
442
442
|
if ("caches" in window)
|
|
443
443
|
try {
|
|
444
444
|
const e = await caches.keys();
|
|
@@ -446,48 +446,48 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
446
446
|
} catch (e) {
|
|
447
447
|
console.error("Failed to clear caches:", e);
|
|
448
448
|
}
|
|
449
|
-
},
|
|
450
|
-
const a =
|
|
449
|
+
}, He = ({ autoUpdate: e, renderDialog: r, clearCachesOnReload: o }) => {
|
|
450
|
+
const a = me(null), [n, s] = W(!1), c = O(() => {
|
|
451
451
|
a.current && a.current.postMessage({ type: "SKIP_WAITING" }), o && localStorage.setItem("tracktor_clear_caches", "1"), window.location.reload();
|
|
452
452
|
}, [o]);
|
|
453
453
|
j(() => {
|
|
454
|
-
localStorage.getItem("tracktor_clear_caches") === "1" && (localStorage.removeItem("tracktor_clear_caches"),
|
|
454
|
+
localStorage.getItem("tracktor_clear_caches") === "1" && (localStorage.removeItem("tracktor_clear_caches"), Re().catch(console.error));
|
|
455
455
|
}, []);
|
|
456
|
-
const u =
|
|
456
|
+
const u = O(() => {
|
|
457
457
|
window.confirm("A new version is available. The app will reload now.") && c();
|
|
458
458
|
}, [c]);
|
|
459
459
|
return j(() => {
|
|
460
460
|
if (!("serviceWorker" in navigator))
|
|
461
461
|
return;
|
|
462
462
|
let l, d;
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
},
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
},
|
|
463
|
+
const i = (g) => {
|
|
464
|
+
g && navigator.serviceWorker.controller && (a.current = g, s(!0));
|
|
465
|
+
}, m = () => {
|
|
466
|
+
const g = l?.installing;
|
|
467
|
+
g && (d = () => {
|
|
468
|
+
g.state === "installed" && i(g);
|
|
469
|
+
}, g.addEventListener("statechange", d));
|
|
470
470
|
};
|
|
471
471
|
return (async () => {
|
|
472
|
-
l = await navigator.serviceWorker.getRegistration(), l && (
|
|
472
|
+
l = await navigator.serviceWorker.getRegistration(), l && (i(l.waiting), l.addEventListener("updatefound", m));
|
|
473
473
|
})().catch(console.error), () => {
|
|
474
|
-
l?.removeEventListener("updatefound",
|
|
474
|
+
l?.removeEventListener("updatefound", m), d && l?.installing && l.installing.removeEventListener("statechange", d);
|
|
475
475
|
};
|
|
476
476
|
}, []), j(() => {
|
|
477
477
|
n && e && c();
|
|
478
478
|
}, [e, n, c]), j(() => {
|
|
479
479
|
n && !e && !r && u();
|
|
480
480
|
}, [r, u, n, e]), n && !e && r ? r(c) : null;
|
|
481
|
-
},
|
|
481
|
+
}, be = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), _e = (e) => {
|
|
482
482
|
const r = e.split(/[/\\]/).pop() || "";
|
|
483
483
|
return r.substring(0, r.lastIndexOf("."));
|
|
484
|
-
},
|
|
484
|
+
}, Se = (e) => {
|
|
485
485
|
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("");
|
|
486
486
|
return a.charAt(0).toLowerCase() + a.slice(1);
|
|
487
|
-
},
|
|
488
|
-
const n =
|
|
487
|
+
}, Ae = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), je = (e, r, o, a) => {
|
|
488
|
+
const n = Se(r), s = be(o), c = `${n}${s}`;
|
|
489
489
|
return e && typeof e == "object" && "operationId" in e && a?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
|
|
490
|
-
},
|
|
490
|
+
}, Pe = (e, r) => {
|
|
491
491
|
const o = {};
|
|
492
492
|
return e?.forEach((a) => {
|
|
493
493
|
o[a] = {
|
|
@@ -505,61 +505,61 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
505
505
|
};
|
|
506
506
|
}), Object.keys(o).length ? o : void 0;
|
|
507
507
|
}, Be = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
|
|
508
|
-
const { output: n, useInfiniteIds:
|
|
508
|
+
const { output: n, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: d } = a || {}, i = d || Ae(u), m = l || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
|
|
509
509
|
return {
|
|
510
510
|
...o,
|
|
511
|
-
[
|
|
511
|
+
[i]: {
|
|
512
512
|
input: u,
|
|
513
513
|
output: {
|
|
514
514
|
baseUrl: n?.baseUrl,
|
|
515
515
|
client: "react-query",
|
|
516
516
|
mode: "tags-split",
|
|
517
517
|
override: {
|
|
518
|
-
...(
|
|
519
|
-
operations:
|
|
518
|
+
...(s?.length || c?.length) && {
|
|
519
|
+
operations: Pe(s, c)
|
|
520
520
|
},
|
|
521
|
-
header: (
|
|
521
|
+
header: (g) => [
|
|
522
522
|
"Generated by orval 🍺",
|
|
523
|
-
...
|
|
524
|
-
...
|
|
523
|
+
...g.title ? [g.title] : [],
|
|
524
|
+
...g.description ? [g.description] : []
|
|
525
525
|
],
|
|
526
526
|
mutator: {
|
|
527
|
-
name: _e(
|
|
528
|
-
path:
|
|
527
|
+
name: _e(m),
|
|
528
|
+
path: m
|
|
529
529
|
},
|
|
530
|
-
operationName: (
|
|
530
|
+
operationName: (g, v, k) => je(g, v, k, c),
|
|
531
531
|
query: {
|
|
532
532
|
useQuery: !0
|
|
533
533
|
}
|
|
534
534
|
},
|
|
535
|
-
schemas: n?.schemas || `src/api/${
|
|
536
|
-
target: n?.target || `src/api/${
|
|
535
|
+
schemas: n?.schemas || `src/api/${i}/model`,
|
|
536
|
+
target: n?.target || `src/api/${i}/services/api.ts`,
|
|
537
537
|
...n
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
540
|
};
|
|
541
|
-
}, {}),
|
|
541
|
+
}, {}), Te = (e) => e && typeof e == "function", ke = (e) => e && typeof e == "function", Xe = ({
|
|
542
542
|
children: e,
|
|
543
543
|
defaultQueriesOptions: r,
|
|
544
544
|
defaultMutationsOptions: o,
|
|
545
545
|
...a
|
|
546
546
|
}) => {
|
|
547
|
-
const { libraries: n } = P(
|
|
548
|
-
if (!
|
|
547
|
+
const { libraries: n } = P(S), s = a?.QueryClient || n?.reactQuery?.QueryClient, c = a?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
|
|
548
|
+
if (!s)
|
|
549
549
|
throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
550
550
|
if (!c)
|
|
551
551
|
throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
552
|
-
if (!
|
|
552
|
+
if (!Te(c))
|
|
553
553
|
throw new Error("Provided QueryClientProvider dependencies are not valid.");
|
|
554
|
-
if (!
|
|
554
|
+
if (!ke(s))
|
|
555
555
|
throw new Error("Provided QueryClient dependencies are not valid.");
|
|
556
|
-
const u = new
|
|
556
|
+
const u = new s({
|
|
557
557
|
defaultOptions: {
|
|
558
558
|
mutations: {
|
|
559
559
|
...o
|
|
560
560
|
},
|
|
561
561
|
queries: {
|
|
562
|
-
getNextPageParam: (l, d,
|
|
562
|
+
getNextPageParam: (l, d, i) => l.length + (i || 0),
|
|
563
563
|
refetchOnWindowFocus: !1,
|
|
564
564
|
retry: 3,
|
|
565
565
|
...r
|
|
@@ -567,60 +567,60 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
567
567
|
}
|
|
568
568
|
});
|
|
569
569
|
return /* @__PURE__ */ C.jsx(c, { client: u, children: e });
|
|
570
|
-
},
|
|
571
|
-
const { fractionDigits: o = 0, metric: a = "km", spacingBetween: n = !0 } = r || {},
|
|
572
|
-
return Number.isNaN(
|
|
573
|
-
},
|
|
570
|
+
}, Ce = ({ library: e, date: r, format: o = "ll" }) => e(r).format(o), Ie = (e, r) => {
|
|
571
|
+
const { fractionDigits: o = 0, metric: a = "km", spacingBetween: n = !0 } = r || {}, s = Number(e), c = n ? " " : "";
|
|
572
|
+
return Number.isNaN(s) ? `0${c}${a}` : `${s.toFixed(o)}${c}${a}`;
|
|
573
|
+
}, 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(" "), Oe = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Le = ({ path: e, size: r, apiURL: o }) => {
|
|
574
574
|
if (!e)
|
|
575
575
|
return "";
|
|
576
|
-
const a =
|
|
577
|
-
return typeof r == "number" &&
|
|
578
|
-
},
|
|
579
|
-
const { apiURL: r, libraries: o } = P(
|
|
576
|
+
const a = Oe(e), n = `${o}${a}`, s = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
577
|
+
return typeof r == "number" && s ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
|
|
578
|
+
}, Ze = (e) => {
|
|
579
|
+
const { apiURL: r, libraries: o } = P(S), a = e?.dayjs || o?.dayjs;
|
|
580
580
|
return {
|
|
581
581
|
dateAdapter: (c, u) => {
|
|
582
582
|
if (!a)
|
|
583
583
|
throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
584
|
-
return
|
|
584
|
+
return Ce({
|
|
585
585
|
date: c,
|
|
586
586
|
format: u,
|
|
587
587
|
library: a
|
|
588
588
|
});
|
|
589
589
|
},
|
|
590
|
-
distanceAdapter:
|
|
590
|
+
distanceAdapter: Ie,
|
|
591
591
|
filePathAdapter: (c, u) => {
|
|
592
592
|
if (!r)
|
|
593
593
|
throw new Error(
|
|
594
594
|
"API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
|
|
595
595
|
);
|
|
596
|
-
return typeof c == "string" && /^https?:\/\//.test(c) ? c :
|
|
596
|
+
return typeof c == "string" && /^https?:\/\//.test(c) ? c : Le({
|
|
597
597
|
apiURL: r,
|
|
598
598
|
path: c,
|
|
599
599
|
size: u
|
|
600
600
|
});
|
|
601
601
|
},
|
|
602
|
-
worksiteNameAdapter:
|
|
602
|
+
worksiteNameAdapter: xe
|
|
603
603
|
};
|
|
604
|
-
},
|
|
605
|
-
const { libraries: r } = P(
|
|
604
|
+
}, et = (e) => {
|
|
605
|
+
const { libraries: r } = P(S), o = e?.axios || r?.axios, a = e?.localStorageKey || "user";
|
|
606
606
|
if (!o)
|
|
607
607
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
608
|
-
const n =
|
|
608
|
+
const n = O(
|
|
609
609
|
({ tokenType: c, accessToken: u }) => {
|
|
610
610
|
o.defaults.headers.common.Authorization = `${c} ${u}`;
|
|
611
611
|
},
|
|
612
612
|
[o.defaults.headers.common]
|
|
613
|
-
),
|
|
613
|
+
), s = () => {
|
|
614
614
|
o.defaults.headers.common.Authorization = null;
|
|
615
615
|
};
|
|
616
616
|
return j(() => {
|
|
617
|
-
if (
|
|
617
|
+
if (F)
|
|
618
618
|
return;
|
|
619
619
|
const c = ({ newValue: u, key: l }) => {
|
|
620
620
|
if (l === a && u)
|
|
621
621
|
try {
|
|
622
|
-
const { accessToken: d, tokenType:
|
|
623
|
-
n({ accessToken: d, tokenType:
|
|
622
|
+
const { accessToken: d, tokenType: i } = JSON.parse(u);
|
|
623
|
+
n({ accessToken: d, tokenType: i });
|
|
624
624
|
} catch (d) {
|
|
625
625
|
console.error("Failed to parse newValue from localStorage:", d);
|
|
626
626
|
}
|
|
@@ -629,24 +629,24 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
629
629
|
window.removeEventListener("storage", c);
|
|
630
630
|
};
|
|
631
631
|
}, [a, n]), {
|
|
632
|
-
clearAuthenticationToken:
|
|
632
|
+
clearAuthenticationToken: s,
|
|
633
633
|
setAuthenticationToken: n
|
|
634
634
|
};
|
|
635
|
-
},
|
|
636
|
-
const [o, a] =
|
|
635
|
+
}, Y = (e, r) => r === "short" ? e.split("-")[0] : e, tt = (e, r = "full") => {
|
|
636
|
+
const [o, a] = W(() => {
|
|
637
637
|
const n = e?.language || navigator.language;
|
|
638
|
-
return e && "isInitialized" in e && e.isInitialized,
|
|
638
|
+
return e && "isInitialized" in e && e.isInitialized, Y(n, r);
|
|
639
639
|
});
|
|
640
640
|
return j(() => {
|
|
641
|
-
e && "isInitialized" in e && e.isInitialized && e.language && a(
|
|
642
|
-
const n = (
|
|
643
|
-
a(
|
|
641
|
+
e && "isInitialized" in e && e.isInitialized && e.language && a(Y(e.language, r));
|
|
642
|
+
const n = (s) => {
|
|
643
|
+
a(Y(s, r));
|
|
644
644
|
};
|
|
645
645
|
return e?.on?.("languageChanged", n), () => {
|
|
646
646
|
e?.off?.("languageChanged", n);
|
|
647
647
|
};
|
|
648
648
|
}, [e, r]), o;
|
|
649
|
-
}, Ne = "tracktor.filter",
|
|
649
|
+
}, Ne = "tracktor.filter", Fe = {
|
|
650
650
|
getFilter: () => {
|
|
651
651
|
},
|
|
652
652
|
getFilters: () => ({}),
|
|
@@ -654,71 +654,72 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
654
654
|
},
|
|
655
655
|
setFilter: () => {
|
|
656
656
|
}
|
|
657
|
-
},
|
|
657
|
+
}, oe = (e) => {
|
|
658
658
|
try {
|
|
659
659
|
return JSON.parse(e);
|
|
660
660
|
} catch {
|
|
661
661
|
return e;
|
|
662
662
|
}
|
|
663
|
-
},
|
|
663
|
+
}, ae = (e, r, o) => `${o}_${e}=>${r}`, $e = (e) => e.reduce((r, o) => {
|
|
664
664
|
const a = localStorage.getItem(o);
|
|
665
665
|
if (a)
|
|
666
666
|
try {
|
|
667
|
-
const n = JSON.parse(a),
|
|
668
|
-
|
|
667
|
+
const n = JSON.parse(a), s = Object.keys(n)?.[0];
|
|
668
|
+
s && (r[s] = Object.values(n)?.[0]);
|
|
669
669
|
} catch {
|
|
670
670
|
}
|
|
671
671
|
return r;
|
|
672
|
-
}, {}),
|
|
673
|
-
const { libraries: r, localStorageKeys: o } = P(
|
|
674
|
-
}], [u, l] =
|
|
675
|
-
if (
|
|
676
|
-
return
|
|
672
|
+
}, {}), rt = (e) => {
|
|
673
|
+
const { libraries: r, localStorageKeys: o } = P(S), a = e?.reactRouter || r?.reactRouter, { pathname: n } = a?.useLocation?.() ?? { pathname: "/" }, [s, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
|
|
674
|
+
}], [u, l] = W({}), d = o?.filter || Ne, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, m = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
|
|
675
|
+
if (F)
|
|
676
|
+
return Fe;
|
|
677
677
|
if (!a)
|
|
678
678
|
throw new Error(
|
|
679
679
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
|
|
680
680
|
);
|
|
681
|
-
const
|
|
682
|
-
(
|
|
683
|
-
),
|
|
684
|
-
const
|
|
685
|
-
if (!
|
|
686
|
-
|
|
687
|
-
const
|
|
688
|
-
return delete
|
|
689
|
-
}), localStorage.removeItem(
|
|
681
|
+
const g = () => Object.keys(localStorage).filter(
|
|
682
|
+
(h) => h.startsWith(d) && h.endsWith(e?.pathname || n)
|
|
683
|
+
), v = (h, f, b = !0) => {
|
|
684
|
+
const R = ae(h, e?.pathname || n, d);
|
|
685
|
+
if (!f || Array.isArray(f) && !f.length) {
|
|
686
|
+
i ? (s.delete(h), c(s)) : l((_) => {
|
|
687
|
+
const I = { ..._ };
|
|
688
|
+
return delete I[h], I;
|
|
689
|
+
}), m && localStorage.removeItem(R);
|
|
690
690
|
return;
|
|
691
691
|
}
|
|
692
|
-
|
|
692
|
+
m && b && f && localStorage.setItem(R, JSON.stringify({ ...s, [h]: f })), i && f ? (s.set(h, JSON.stringify(f)), c(s)) : !i && f && l((_) => ({ ..._, [h]: f }));
|
|
693
693
|
};
|
|
694
694
|
return {
|
|
695
|
-
getFilter: (
|
|
696
|
-
if (
|
|
697
|
-
const
|
|
698
|
-
if (
|
|
699
|
-
return
|
|
695
|
+
getFilter: (h, f) => {
|
|
696
|
+
if (i) {
|
|
697
|
+
const b = s.get(h);
|
|
698
|
+
if (b)
|
|
699
|
+
return oe(b);
|
|
700
|
+
} else {
|
|
701
|
+
const b = u[h];
|
|
702
|
+
if (b !== void 0)
|
|
703
|
+
return b;
|
|
700
704
|
}
|
|
701
|
-
if (
|
|
702
|
-
const
|
|
703
|
-
if (
|
|
704
|
-
|
|
705
|
+
if (m) {
|
|
706
|
+
const b = ae(h, e?.pathname || n, d), R = localStorage.getItem(b);
|
|
707
|
+
if (R)
|
|
708
|
+
try {
|
|
709
|
+
const _ = JSON.parse(R)[h];
|
|
710
|
+
return !i && _ !== void 0 && l((I) => ({ ...I, [h]: _ })), _;
|
|
711
|
+
} catch {
|
|
712
|
+
}
|
|
705
713
|
}
|
|
706
|
-
|
|
707
|
-
if (g)
|
|
708
|
-
try {
|
|
709
|
-
const v = JSON.parse(g)[m];
|
|
710
|
-
return !s && v !== void 0 && l((A) => ({ ...A, [m]: v })), v;
|
|
711
|
-
} catch {
|
|
712
|
-
}
|
|
713
|
-
return h;
|
|
714
|
+
return f;
|
|
714
715
|
},
|
|
715
716
|
getFilters: () => {
|
|
716
|
-
const
|
|
717
|
-
if (
|
|
718
|
-
const
|
|
717
|
+
const h = m ? $e(g()) : {};
|
|
718
|
+
if (i) {
|
|
719
|
+
const f = Array.from(s.entries()).reduce((b, [R, _]) => (b[R] = oe(_), b), {});
|
|
719
720
|
return {
|
|
720
721
|
...h,
|
|
721
|
-
...
|
|
722
|
+
...f
|
|
722
723
|
};
|
|
723
724
|
}
|
|
724
725
|
return {
|
|
@@ -726,30 +727,30 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
726
727
|
...u
|
|
727
728
|
};
|
|
728
729
|
},
|
|
729
|
-
handleFilter: (
|
|
730
|
-
if (
|
|
731
|
-
const
|
|
732
|
-
|
|
730
|
+
handleFilter: (h, f) => (b, R) => {
|
|
731
|
+
if (R || Array.isArray(R) && R.length === 0) {
|
|
732
|
+
const _ = f || "value", I = typeof R == "object" && _ in R ? R[_] : R;
|
|
733
|
+
v(h, I);
|
|
733
734
|
return;
|
|
734
735
|
}
|
|
735
|
-
|
|
736
|
+
v(h, void 0);
|
|
736
737
|
},
|
|
737
|
-
setFilter:
|
|
738
|
+
setFilter: v
|
|
738
739
|
};
|
|
739
|
-
},
|
|
740
|
+
}, nt = ({
|
|
740
741
|
data: e,
|
|
741
742
|
fetchNextPage: r,
|
|
742
743
|
isFetchingNextPage: o,
|
|
743
744
|
isInitialLoading: a,
|
|
744
745
|
isLoading: n,
|
|
745
|
-
enabled:
|
|
746
|
+
enabled: s = !0
|
|
746
747
|
}) => {
|
|
747
|
-
const c =
|
|
748
|
+
const c = O(
|
|
748
749
|
async (l) => {
|
|
749
|
-
o || !
|
|
750
|
+
o || !s || await r({ pageParam: l?.pageParam || l.visibleRowsCount });
|
|
750
751
|
},
|
|
751
|
-
[
|
|
752
|
-
), u =
|
|
752
|
+
[s, r, o]
|
|
753
|
+
), u = G(() => {
|
|
753
754
|
if (e)
|
|
754
755
|
return e.pages.reduce((l, d) => [...l, ...d], []);
|
|
755
756
|
}, [e]);
|
|
@@ -759,23 +760,23 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
759
760
|
loadingVariant: a ? "skeleton" : "linear-progress",
|
|
760
761
|
rows: u
|
|
761
762
|
};
|
|
762
|
-
},
|
|
763
|
-
const { libraries: r } = P(
|
|
763
|
+
}, ot = (e) => {
|
|
764
|
+
const { libraries: r } = P(S), 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 = O(
|
|
764
765
|
(d) => {
|
|
765
766
|
if (d && typeof d == "object" && "response" in d) {
|
|
766
|
-
const { response:
|
|
767
|
-
if (
|
|
768
|
-
return String(
|
|
769
|
-
if (
|
|
770
|
-
return String(
|
|
771
|
-
if (
|
|
772
|
-
return String(
|
|
773
|
-
if (
|
|
774
|
-
const { detail:
|
|
775
|
-
if (Array.isArray(
|
|
776
|
-
const { msg:
|
|
777
|
-
if (typeof
|
|
778
|
-
return String(
|
|
767
|
+
const { response: i } = d || {};
|
|
768
|
+
if (i && typeof i == "object" && "reason" in i && i.reason)
|
|
769
|
+
return String(i.reason);
|
|
770
|
+
if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "reason" in i.data && i.data.reason)
|
|
771
|
+
return String(i.data.reason);
|
|
772
|
+
if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "message" in i.data && i.data.message)
|
|
773
|
+
return String(i.data.message);
|
|
774
|
+
if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "detail" in i.data) {
|
|
775
|
+
const { detail: m } = i.data;
|
|
776
|
+
if (Array.isArray(m) && m.length > 0 && typeof m[0] == "object" && m[0] !== null && "msg" in m[0]) {
|
|
777
|
+
const { msg: g } = m[0];
|
|
778
|
+
if (typeof g == "string")
|
|
779
|
+
return String(g);
|
|
779
780
|
}
|
|
780
781
|
}
|
|
781
782
|
}
|
|
@@ -783,33 +784,33 @@ const We = ({ IMaskMixin: e, ...r }) => {
|
|
|
783
784
|
},
|
|
784
785
|
[c]
|
|
785
786
|
);
|
|
786
|
-
return { getErrorCode:
|
|
787
|
-
const { response:
|
|
788
|
-
return
|
|
787
|
+
return { getErrorCode: O((d) => {
|
|
788
|
+
const { response: i } = d || {};
|
|
789
|
+
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";
|
|
789
790
|
}, []), printError: u };
|
|
790
791
|
};
|
|
791
792
|
export {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
793
|
+
Qe as GTMSendPageView,
|
|
794
|
+
Ve as InitializeAxiosConfig,
|
|
795
|
+
Me as InitializeDaysJSConfig,
|
|
796
|
+
Ge as InitializeI18nConfig,
|
|
797
|
+
Je as InitializeSentryConfig,
|
|
798
|
+
S as InjectDependenciesContext,
|
|
799
|
+
Ue as InjectDependenciesProvider,
|
|
800
|
+
ze as MaskTextField,
|
|
801
|
+
qe as PreloadErrorHandler,
|
|
802
|
+
Xe as QueryClientProviderWithConfig,
|
|
802
803
|
Ke as RequireAuth,
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
804
|
+
He as UpdateNotifier,
|
|
805
|
+
We as axiosCustomInstance,
|
|
806
|
+
Ce as dateAdapter,
|
|
807
|
+
Ie as distanceAdapter,
|
|
807
808
|
Be as getOrvalConfig,
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
809
|
+
Ze as useAdapter,
|
|
810
|
+
et as useAuth,
|
|
811
|
+
tt as useCurrentLanguage,
|
|
812
|
+
rt as useFilters,
|
|
813
|
+
nt as useInfiniteDataGrid,
|
|
814
|
+
ot as useResponseError,
|
|
815
|
+
xe as worksiteNameAdapter
|
|
815
816
|
};
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(h,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],O):(h=typeof globalThis<"u"?globalThis:h||self,O(h["@tracktor/shared-module"]={},h.axios,h.React))})(this,(function(h,O,p){"use strict";const se=(e,r)=>{const o=O.CancelToken.source(),a=O({...e,...r,cancelToken:o.token}).then(({data:n})=>n);return a.cancel=()=>{o.cancel("Query was cancelled")},a};var D={exports:{}},N={};var G;function ie(){if(G)return N;G=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(a,n,i){var c=null;if(i!==void 0&&(c=""+i),n.key!==void 0&&(c=""+n.key),"key"in n){i={};for(var u in n)u!=="key"&&(i[u]=n[u])}else i=n;return n=i.ref,{$$typeof:e,type:a,key:c,ref:n!==void 0?n:null,props:i}}return N.Fragment=r,N.jsx=o,N.jsxs=o,N}var L={};var J;function ce(){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===Ke?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case P:return"Fragment";case f:return"Profiler";case v:return"StrictMode";case I:return"Suspense";case Ve:return"SuspenseList";case Je: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 j:return"Portal";case _:return t.displayName||"Context";case S:return(t._context.displayName||"Context")+".Consumer";case A:var g=t.render;return t=t.displayName,t||(t=g.displayName||g.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ge:return g=t.displayName||null,g!==null?g:e(t.type)||"Memo";case W:g=t._payload,t=t._init;try{return e(t(g))}catch{}}return null}function r(t){return""+t}function o(t){try{r(t);var g=!1}catch{g=!0}if(g){g=console;var E=g.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return E.call(g,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),r(t)}}function a(t){if(t===P)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===W)return"<...>";try{var g=e(t);return g?"<"+g+">":"<...>"}catch{return"<...>"}}function n(){var t=U.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function c(t){if(ee.call(t,"key")){var g=Object.getOwnPropertyDescriptor(t,"key").get;if(g&&g.isReactWarning)return!1}return t.key!==void 0}function u(t,g){function E(){te||(te=!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)",g))}E.isReactWarning=!0,Object.defineProperty(t,"key",{get:E,configurable:!0})}function l(){var t=e(this.type);return re[t]||(re[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,g,E,b,z,Q){var R=E.ref;return t={$$typeof:k,type:t,key:g,props:E,_owner:b},(R!==void 0?R:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:l}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:z}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function s(t,g,E,b,z,Q){var R=g.children;if(R!==void 0)if(b)if(He(R)){for(b=0;b<R.length;b++)y(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 y(R);if(ee.call(g,"key")){R=e(t);var x=Object.keys(g).filter(function(Be){return Be!=="key"});b=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",ae[R+b]||(x=0<x.length?"{"+x.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,b,_,O,_),ne[_+b]=!0)}if(_=null,R!==void 0&&(o(R),_=""+R),c(p)&&(o(p.key),_=""+p.key),"key"in p){R={};for(var Q in p)Q!=="key"&&(R[Q]=p[Q])}else R=p;return _&&u(R,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,_,R,n(),Y,M)}function v(t){g(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===W&&(t._payload.status==="fulfilled"?g(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function g(t){return typeof t=="object"&&t!==null&&t.$$typeof===k}var S=f,k=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),w=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),Me=Symbol.for("react.suspense"),Qe=Symbol.for("react.suspense_list"),Ve=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Ge=Symbol.for("react.activity"),Je=Symbol.for("react.client.reference"),z=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=Object.prototype.hasOwnProperty,Ke=Array.isArray,U=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(t){return t()}};var $,ee={},te=S.react_stack_bottom_frame.bind(S,i)(),re=U(a(i)),ne={};N.Fragment=h,N.jsx=function(t,p,R){var b=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,R,!1,b?Error("react-stack-top-frame"):te,b?U(a(t)):re)},N.jsxs=function(t,p,R){var b=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,R,!0,b?Error("react-stack-top-frame"):te,b?U(a(t)):re)}})()),N}var J;function ie(){return J||(J=1,process.env.NODE_ENV==="production"?F.exports=ae():F.exports=se()),F.exports}var T=ie();const ce=({IMaskMixin:e,...r})=>{const o=f.useMemo(()=>e(({TextField:a,...n})=>T.jsx(a,{...n})),[e]);return T.jsx(o,{...r})},A=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 T.jsx(A.Provider,{value:n,children:e})},ue=({data:e,...r})=>{const{libraries:o}=f.useContext(A),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]),T.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}})(),de="user",fe=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:i,localStorageKeys:c}=f.useContext(A),u=a?.userLocalStorageKey||c?.user||de,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||L)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},pe=({language:e,...r})=>{const{libraries:o}=f.useContext(A),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},ge=({debug:e,resources:r,...o})=>{const{libraries:a}=f.useContext(A),n=o?.i18||a?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(L)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},me=({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(A),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:k,matchRoutes:C,useLocation:h,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:k,matchRoutes:C,useEffect:f.useEffect,useLocation:h,useNavigationType:E}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:i,tracesSampleRate:o||1}),null},ye=()=>(f.useEffect(()=>{if(L)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),he="user",ve=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:i,localStorageKeys:c}=f.useContext(A),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,d=n?.localStorageKey||c?.user||he;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:k}=u,C=g(),h=f.useRef(!1),E=typeof r=="function"?r():!!r,P=typeof E=="boolean"?E:E?.isLogged;return f.useEffect(()=>{h.current||(h.current=!0,l.interceptors.response.use(m=>m,async m=>(typeof m=="object"&&m&&"response"in m&&m.response&&typeof m.response=="object"&&"status"in m.response&&m.response&&typeof m.response=="object"&&"status"in m.response&&m?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),v(a)),Promise.reject(m))))},[l.defaults.headers.common,l.interceptors.response,d,a]),P&&!s?T.jsx(f.Suspense,{fallback:e,children:C.state?.from?.state&&C.state?.from?.pathname===o?T.jsx(S,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):T.jsx(k,{})}):T.jsx(S,{to:o+C.search,state:{from:C},replace:!0})},Ee=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)}},we=({autoUpdate:e,renderDialog:r,clearCachesOnReload:o})=>{const a=f.useRef(null),[n,i]=f.useState(!1),c=f.useCallback(()=>{a.current&&a.current.postMessage({type:"SKIP_WAITING"}),o&&localStorage.setItem("tracktor_clear_caches","1"),window.location.reload()},[o]);f.useEffect(()=>{localStorage.getItem("tracktor_clear_caches")==="1"&&(localStorage.removeItem("tracktor_clear_caches"),Ee().catch(console.error))},[]);const u=f.useCallback(()=>{window.confirm("A new version is available. The app will reload now.")&&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()},[e,n,c]),f.useEffect(()=>{n&&!e&&!r&&u()},[r,u,n,e]),n&&!e&&r?r(c):null},Re=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),be=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},_e=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)},Se=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Ae=(e,r,o,a)=>{const n=_e(r),i=Re(o),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Ce=(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},je=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||Se(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:Ce(i,c)},header:g=>["Generated by orval 🍺",...g.title?[g.title]:[],...g.description?[g.description]:[]],mutator:{name:be(v),path:v},operationName:(g,S,k)=>Ae(g,S,k,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{}),Pe=e=>e&&typeof e=="function",Te=e=>e&&typeof e=="function",ke=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=f.useContext(A),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(!Pe(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Te(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 T.jsx(c,{client:u,children:e})},K=({library:e,date:r,format:o="ll"})=>e(r).format(o),B=(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}`},H=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})=>{if(!e)return"";const a=Ie(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},xe=e=>{const{apiURL:r,libraries:o}=f.useContext(A),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 K({date:c,format:u,library:a})},distanceAdapter:B,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:Oe({apiURL:r,path:c,size:u})},worksiteNameAdapter:H}},Ne=e=>{const{libraries:r}=f.useContext(A),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(L)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}},D=(e,r)=>r==="short"?e.split("-")[0]:e,Le=(e,r="full")=>{const[o,a]=f.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,D(n,r)});return f.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(D(e.language,r));const n=i=>{a(D(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Fe="tracktor.filter",De={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},X=e=>{try{return JSON.parse(e)}catch{return e}},Z=(e,r,o)=>`${o}_${e}=>${r}`,Ye=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},{}),We=e=>{const{libraries:r,localStorageKeys:o}=f.useContext(A),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[i,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=f.useState({}),d=o?.filter||Fe,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl;if(L)return De;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(h=>h.startsWith(d)&&h.endsWith(e?.pathname||n)),g=(h,E,P=!0)=>{const m=Z(h,e?.pathname||n,d);if(!E||Array.isArray(E)&&!E.length){s?(i.delete(h),c(i)):l(w=>{const j={...w};return delete j[h],j}),localStorage.removeItem(m);return}P&&E&&localStorage.setItem(m,JSON.stringify({...i,[h]:E})),s&&E?(i.set(h,JSON.stringify(E)),c(i)):!s&&E&&l(w=>({...w,[h]:E}))};return{getFilter:(h,E)=>{if(!s){const w=u[h];if(w!==void 0)return w}if(s){const w=i.get(h);if(w)return X(w)}const P=Z(h,e?.pathname||n,d),m=localStorage.getItem(P);if(m)try{const w=JSON.parse(m)[h];return!s&&w!==void 0&&l(j=>({...j,[h]:w})),w}catch{}return E},getFilters:()=>{const h=v(),E=Ye(h);if(s){const P=Array.from(i.entries()).reduce((m,[w,j])=>(m[w]=X(j),m),{});return{...E,...P}}return{...E,...u}},handleFilter:(h,E)=>(P,m)=>{if(m||Array.isArray(m)&&m.length===0){const w=E||"value",j=typeof m=="object"&&w in m?m[w]:m;g(h,j);return}g(h,void 0)},setFilter:g}},ze=({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}},Ue=e=>{const{libraries:r}=f.useContext(A),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&&s.reason)return String(s.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"reason"in s.data&&s.data.reason)return String(s.data.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"message"in s.data&&s.data.message)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}};y.GTMSendPageView=ue,y.InitializeAxiosConfig=fe,y.InitializeDaysJSConfig=pe,y.InitializeI18nConfig=ge,y.InitializeSentryConfig=me,y.InjectDependenciesContext=A,y.InjectDependenciesProvider=le,y.MaskTextField=ce,y.PreloadErrorHandler=ye,y.QueryClientProviderWithConfig=ke,y.RequireAuth=ve,y.UpdateNotifier=we,y.axiosCustomInstance=oe,y.dateAdapter=K,y.distanceAdapter=B,y.getOrvalConfig=je,y.useAdapter=xe,y.useAuth=Ne,y.useCurrentLanguage=Le,y.useFilters=We,y.useInfiniteDataGrid=ze,y.useResponseError=Ue,y.worksiteNameAdapter=H,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,b,R,x,R),ae[R+b]=!0)}if(R=null,E!==void 0&&(o(E),R=""+E),c(g)&&(o(g.key),R=""+g.key),"key"in g){E={};for(var V in g)V!=="key"&&(E[V]=g[V])}else E=g;return R&&u(E,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,R,E,n(),z,Q)}function y(t){m(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===W&&(t._payload.status==="fulfilled"?m(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function m(t){return typeof t=="object"&&t!==null&&t.$$typeof===k}var w=p,k=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),_=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),Ve=Symbol.for("react.suspense_list"),Ge=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Je=Symbol.for("react.activity"),Ke=Symbol.for("react.client.reference"),U=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,He=Array.isArray,M=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(t){return t()}};var te,re={},ne=w.react_stack_bottom_frame.bind(w,i)(),oe=M(a(i)),ae={};L.Fragment=P,L.jsx=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!1,b?Error("react-stack-top-frame"):ne,b?M(a(t)):oe)},L.jsxs=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!0,b?Error("react-stack-top-frame"):ne,b?M(a(t)):oe)}})()),L}var K;function le(){return K||(K=1,process.env.NODE_ENV==="production"?D.exports=ie():D.exports=ce()),D.exports}var T=le();const ue=({IMaskMixin:e,...r})=>{const o=p.useMemo(()=>e(({TextField:a,...n})=>T.jsx(a,{...n})),[e]);return T.jsx(o,{...r})},C=p.createContext({}),de=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=p.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return T.jsx(C.Provider,{value:n,children:e})},fe=({data:e,...r})=>{const{libraries:o}=p.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 p.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),T.jsx(u,{})},F=(()=>{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}=p.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||F)return null;if(typeof window<"u"&&window.localStorage){const d=localStorage.getItem(u),s=d?JSON.parse(d):null,y=s?.[e]?s[e]:null,m=s?.[r]?s[r]:null,w=d?`${y} ${m}`:null;w&&(l.defaults.headers.common.Authorization=w)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=o,null},me=({language:e,...r})=>{const{libraries:o}=p.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 p.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},he=({debug:e,resources:r,...o})=>{const{libraries:a}=p.useContext(C),n=o?.i18||a?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(F)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},ye=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:d,...s})=>{const{libraries:y}=p.useContext(C),m=s?.sentry||y?.sentry,w=s?.reactRouter||y?.reactRouter;if(!m)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!w)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:k,matchRoutes:j,useLocation:P,useNavigationType:v}=w;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:k,matchRoutes:j,useEffect:p.useEffect,useLocation:P,useNavigationType:v}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:i,tracesSampleRate:o||1}),null},ve=()=>(p.useEffect(()=>{if(F)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),H=new WeakMap,Ee="user",we=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:i,localStorageKeys:c}=p.useContext(C),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,d=n?.localStorageKey||c?.user||Ee;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,y]=p.useState(null),{useLocation:m,Navigate:w,Outlet:k}=u,j=m(),P=typeof r=="function"?r():!!r,v=typeof P=="boolean"?P:P?.isLogged;return p.useEffect(()=>{H.has(l)||(H.set(l,!0),l.interceptors.response.use(f=>f,f=>(typeof f=="object"&&f&&"response"in f&&f.response&&typeof f.response=="object"&&"status"in f.response&&f.response&&typeof f.response=="object"&&"status"in f.response&&f?.response?.status===401&&(typeof f=="object"&&f&&"config"in f&&f.config&&typeof f.config=="object"&&"headers"in f.config&&f.config.headers&&typeof f.config.headers=="object"&&"Authorization"in f.config.headers&&f.config.headers.Authorization&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d)),y(a)),Promise.reject(f))))},[l,d,a]),v&&!s?T.jsx(p.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===o?T.jsx(w,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):T.jsx(k,{})}):T.jsx(w,{to:o+j.search,state:{from:j},replace:!0})},be=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)}},Re=({autoUpdate:e,renderDialog:r,clearCachesOnReload:o})=>{const a=p.useRef(null),[n,i]=p.useState(!1),c=p.useCallback(()=>{a.current&&a.current.postMessage({type:"SKIP_WAITING"}),o&&localStorage.setItem("tracktor_clear_caches","1"),window.location.reload()},[o]);p.useEffect(()=>{localStorage.getItem("tracktor_clear_caches")==="1"&&(localStorage.removeItem("tracktor_clear_caches"),be().catch(console.error))},[]);const u=p.useCallback(()=>{window.confirm("A new version is available. The app will reload now.")&&c()},[c]);return p.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,d;const s=m=>{m&&navigator.serviceWorker.controller&&(a.current=m,i(!0))},y=()=>{const m=l?.installing;m&&(d=()=>{m.state==="installed"&&s(m)},m.addEventListener("statechange",d))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",y))})().catch(console.error),()=>{l?.removeEventListener("updatefound",y),d&&l?.installing&&l.installing.removeEventListener("statechange",d)}},[]),p.useEffect(()=>{n&&e&&c()},[e,n,c]),p.useEffect(()=>{n&&!e&&!r&&u()},[r,u,n,e]),n&&!e&&r?r(c):null},_e=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=_e(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},Te=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),y=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:m=>["Generated by orval 🍺",...m.title?[m.title]:[],...m.description?[m.description]:[]],mutator:{name:Se(y),path:y},operationName:(m,w,k)=>je(m,w,k,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{}),ke=e=>e&&typeof e=="function",Ie=e=>e&&typeof e=="function",Oe=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=p.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(!ke(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ie(i))throw new Error("Provided QueryClient dependencies are not valid.");const u=new i({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,d,s)=>l.length+(s||0),refetchOnWindowFocus:!1,retry:3,...r}}});return T.jsx(c,{client:u,children:e})},B=({library:e,date:r,format:o="ll"})=>e(r).format(o),X=(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}`},Z=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),xe=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ne=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=xe(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},Le=e=>{const{apiURL:r,libraries:o}=p.useContext(C),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,u)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return B({date:c,format:u,library:a})},distanceAdapter:X,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:Ne({apiURL:r,path:c,size:u})},worksiteNameAdapter:Z}},Fe=e=>{const{libraries:r}=p.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=p.useCallback(({tokenType:c,accessToken:u})=>{o.defaults.headers.common.Authorization=`${c} ${u}`},[o.defaults.headers.common]),i=()=>{o.defaults.headers.common.Authorization=null};return p.useEffect(()=>{if(F)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}},Y=(e,r)=>r==="short"?e.split("-")[0]:e,De=(e,r="full")=>{const[o,a]=p.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,Y(n,r)});return p.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(Y(e.language,r));const n=i=>{a(Y(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Ye="tracktor.filter",ze={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},q=e=>{try{return JSON.parse(e)}catch{return e}},$=(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},{}),Ue=e=>{const{libraries:r,localStorageKeys:o}=p.useContext(C),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[i,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=p.useState({}),d=o?.filter||Ye,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,y=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(F)return ze;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const m=()=>Object.keys(localStorage).filter(v=>v.startsWith(d)&&v.endsWith(e?.pathname||n)),w=(v,f,S=!0)=>{const _=$(v,e?.pathname||n,d);if(!f||Array.isArray(f)&&!f.length){s?(i.delete(v),c(i)):l(A=>{const I={...A};return delete I[v],I}),y&&localStorage.removeItem(_);return}y&&S&&f&&localStorage.setItem(_,JSON.stringify({...i,[v]:f})),s&&f?(i.set(v,JSON.stringify(f)),c(i)):!s&&f&&l(A=>({...A,[v]:f}))};return{getFilter:(v,f)=>{if(s){const S=i.get(v);if(S)return q(S)}else{const S=u[v];if(S!==void 0)return S}if(y){const S=$(v,e?.pathname||n,d),_=localStorage.getItem(S);if(_)try{const A=JSON.parse(_)[v];return!s&&A!==void 0&&l(I=>({...I,[v]:A})),A}catch{}}return f},getFilters:()=>{const v=y?We(m()):{};if(s){const f=Array.from(i.entries()).reduce((S,[_,A])=>(S[_]=q(A),S),{});return{...v,...f}}return{...v,...u}},handleFilter:(v,f)=>(S,_)=>{if(_||Array.isArray(_)&&_.length===0){const A=f||"value",I=typeof _=="object"&&A in _?_[A]:_;w(v,I);return}w(v,void 0)},setFilter:w}},Me=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:i=!0})=>{const c=p.useCallback(async l=>{o||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,o]),u=p.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}},Qe=e=>{const{libraries:r}=p.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=p.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:s}=d||{};if(s&&typeof s=="object"&&"reason"in s&&s.reason)return String(s.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"reason"in s.data&&s.data.reason)return String(s.data.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"message"in s.data&&s.data.message)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:y}=s.data;if(Array.isArray(y)&&y.length>0&&typeof y[0]=="object"&&y[0]!==null&&"msg"in y[0]){const{msg:m}=y[0];if(typeof m=="string")return String(m)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:p.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}};h.GTMSendPageView=fe,h.InitializeAxiosConfig=ge,h.InitializeDaysJSConfig=me,h.InitializeI18nConfig=he,h.InitializeSentryConfig=ye,h.InjectDependenciesContext=C,h.InjectDependenciesProvider=de,h.MaskTextField=ue,h.PreloadErrorHandler=ve,h.QueryClientProviderWithConfig=Oe,h.RequireAuth=we,h.UpdateNotifier=Re,h.axiosCustomInstance=se,h.dateAdapter=B,h.distanceAdapter=X,h.getOrvalConfig=Te,h.useAdapter=Le,h.useAuth=Fe,h.useCurrentLanguage=De,h.useFilters=Ue,h.useInfiniteDataGrid=Me,h.useResponseError=Qe,h.worksiteNameAdapter=Z,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracktor/shared-module",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.1",
|
|
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",
|