@resistdesign/voltra 3.0.0-alpha.33 → 3.0.0-alpha.35
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/README.md +72 -2
- package/api/index.js +49 -36
- package/app/forms/Engine.d.ts +3 -0
- package/app/forms/UI.d.ts +12 -2
- package/app/forms/core/createAutoField.d.ts +11 -3
- package/app/forms/core/createFormRenderer.d.ts +3 -2
- package/app/forms/core/mergeSuites.d.ts +3 -2
- package/app/forms/core/resolveSuite.d.ts +2 -1
- package/app/forms/core/types.d.ts +20 -9
- package/app/forms/types.d.ts +34 -7
- package/app/index.js +21 -12
- package/app/utils/ApplicationState.d.ts +1 -1
- package/build/index.js +2 -2
- package/{chunk-FQMZMCXU.js → chunk-BKRJZXWX.js} +1 -1
- package/chunk-TJFTWPXQ.js +39 -0
- package/{chunk-LGM75I6P.js → chunk-WTD5BBJP.js} +223 -38
- package/chunk-X3NHBZUT.js +1143 -0
- package/common/Logging/Utils.d.ts +0 -9
- package/common/TypeParsing/TypeInfo.d.ts +20 -0
- package/common/TypeParsing/Validation.d.ts +152 -22
- package/common/index.js +6 -7
- package/iac/packs/auth.d.ts +10 -4
- package/iac-packs/index.d.ts +1 -0
- package/native/forms/UI.d.ts +8 -2
- package/native/forms/createNativeFormRenderer.d.ts +1 -1
- package/native/forms/index.d.ts +16 -0
- package/native/forms/suite.d.ts +1 -1
- package/native/index.js +71 -40
- package/native/testing/react-native.d.ts +33 -15
- package/native/utils/index.d.ts +13 -1
- package/package.json +1 -1
- package/web/forms/UI.d.ts +8 -2
- package/web/forms/createWebFormRenderer.d.ts +1 -1
- package/web/forms/suite.d.ts +1 -1
- package/web/index.js +234 -113
- package/web/utils/Route.d.ts +9 -3
- package/web/utils/index.d.ts +1 -0
- package/chunk-G5CLUK4Y.js +0 -621
- package/chunk-IWRHGGGH.js +0 -10
- package/chunk-WELZGQDJ.js +0 -456
package/web/utils/Route.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
*
|
|
4
|
-
* Web routing
|
|
4
|
+
* Web routing wrapper that preserves the `Route` API while injecting
|
|
5
|
+
* browser-specific mechanics for root route usage.
|
|
5
6
|
*/
|
|
6
7
|
import { PropsWithChildren } from "react";
|
|
8
|
+
import { type RouteProps } from "../../app/utils/Route";
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
10
|
+
* Web Route wrapper.
|
|
11
|
+
*
|
|
12
|
+
* Behavior:
|
|
13
|
+
* - In matcher mode (`path` / `exact` / `onParamsChange`), behaves like core `Route`.
|
|
14
|
+
* - In root/provider mode, auto-injects a browser adapter unless one is supplied.
|
|
9
15
|
*/
|
|
10
|
-
export declare const
|
|
16
|
+
export declare const Route: <ParamsType extends Record<string, any>>(props: PropsWithChildren<RouteProps<ParamsType>>) => import("react/jsx-runtime").JSX.Element;
|
package/web/utils/index.d.ts
CHANGED
package/chunk-G5CLUK4Y.js
DELETED
|
@@ -1,621 +0,0 @@
|
|
|
1
|
-
import { getPathString, mergeStringPaths, getParamsAndTestPath, resolvePath } from './chunk-GYWRAW3Y.js';
|
|
2
|
-
import { createContext, useContext, useState, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
// src/app/utils/easy-layout/computeTracks.ts
|
|
6
|
-
var computeTrackPixels = ({
|
|
7
|
-
tracks,
|
|
8
|
-
totalPx,
|
|
9
|
-
gapPx = 0,
|
|
10
|
-
paddingPx = 0
|
|
11
|
-
}) => {
|
|
12
|
-
if (!tracks.length) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
const gapsPx = Math.max(0, tracks.length - 1) * Math.max(0, gapPx);
|
|
16
|
-
const usablePx = Math.max(0, totalPx - Math.max(0, paddingPx) * 2 - gapsPx);
|
|
17
|
-
let fixedPx = 0;
|
|
18
|
-
let frTotal = 0;
|
|
19
|
-
for (const track of tracks) {
|
|
20
|
-
if (track.kind === "px") {
|
|
21
|
-
fixedPx += track.value;
|
|
22
|
-
} else if (track.kind === "pct") {
|
|
23
|
-
fixedPx += usablePx * track.value / 100;
|
|
24
|
-
} else {
|
|
25
|
-
frTotal += track.value;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const remainderPx = Math.max(0, usablePx - fixedPx);
|
|
29
|
-
return tracks.map((track) => {
|
|
30
|
-
if (track.kind === "px") {
|
|
31
|
-
return track.value;
|
|
32
|
-
}
|
|
33
|
-
if (track.kind === "pct") {
|
|
34
|
-
return usablePx * track.value / 100;
|
|
35
|
-
}
|
|
36
|
-
if (frTotal <= 0) {
|
|
37
|
-
return 0;
|
|
38
|
-
}
|
|
39
|
-
return remainderPx * track.value / frTotal;
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/app/utils/History.ts
|
|
44
|
-
var createHistoryBackHandler = (history) => {
|
|
45
|
-
return {
|
|
46
|
-
/**
|
|
47
|
-
* @returns True when back navigation was handled by history.
|
|
48
|
-
*/
|
|
49
|
-
handle: () => {
|
|
50
|
-
if (history.index > 0) {
|
|
51
|
-
history.back();
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
var ensurePrefix = (value, prefix) => value ? value.startsWith(prefix) ? value : `${prefix}${value}` : "";
|
|
59
|
-
var parseHistoryPath = (inputPath) => {
|
|
60
|
-
const raw = String(inputPath ?? "").trim();
|
|
61
|
-
if (!raw) {
|
|
62
|
-
return { path: "/" };
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
const absoluteUrl = new URL(raw);
|
|
66
|
-
return {
|
|
67
|
-
path: absoluteUrl.pathname || "/",
|
|
68
|
-
...absoluteUrl.search ? { search: absoluteUrl.search } : {},
|
|
69
|
-
...absoluteUrl.hash ? { hash: absoluteUrl.hash } : {}
|
|
70
|
-
};
|
|
71
|
-
} catch (error) {
|
|
72
|
-
let target = raw;
|
|
73
|
-
let hash = "";
|
|
74
|
-
let search = "";
|
|
75
|
-
const hashIndex = target.indexOf("#");
|
|
76
|
-
if (hashIndex >= 0) {
|
|
77
|
-
hash = target.slice(hashIndex);
|
|
78
|
-
target = target.slice(0, hashIndex);
|
|
79
|
-
}
|
|
80
|
-
const searchIndex = target.indexOf("?");
|
|
81
|
-
if (searchIndex >= 0) {
|
|
82
|
-
search = target.slice(searchIndex);
|
|
83
|
-
target = target.slice(0, searchIndex);
|
|
84
|
-
}
|
|
85
|
-
const path = target ? target.startsWith("/") ? target : `/${target}` : "/";
|
|
86
|
-
return {
|
|
87
|
-
path,
|
|
88
|
-
...search && search !== "?" ? { search } : {},
|
|
89
|
-
...hash && hash !== "#" ? { hash } : {}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
var buildHistoryPath = ({
|
|
94
|
-
path,
|
|
95
|
-
search,
|
|
96
|
-
hash
|
|
97
|
-
}) => {
|
|
98
|
-
const normalizedPath = path ? path.startsWith("/") ? path : `/${path}` : "/";
|
|
99
|
-
const normalizedSearch = search ? ensurePrefix(search, "?") : "";
|
|
100
|
-
const normalizedHash = hash ? ensurePrefix(hash, "#") : "";
|
|
101
|
-
return `${normalizedPath}${normalizedSearch}${normalizedHash}`;
|
|
102
|
-
};
|
|
103
|
-
var getHistoryLocation = (inputPath, state, getNextKey, currentLocation, replaceSearch = false) => {
|
|
104
|
-
const parsed = parseHistoryPath(inputPath);
|
|
105
|
-
const nextSearch = typeof parsed.search === "undefined" ? replaceSearch ? void 0 : currentLocation?.search : parsed.search;
|
|
106
|
-
return {
|
|
107
|
-
path: parsed.path,
|
|
108
|
-
...typeof nextSearch !== "undefined" ? { search: nextSearch } : {},
|
|
109
|
-
...parsed.hash ? { hash: parsed.hash } : {},
|
|
110
|
-
...typeof state !== "undefined" ? { state } : {},
|
|
111
|
-
key: getNextKey()
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
var createMemoryHistory = (initialPath = "/") => {
|
|
115
|
-
let keyCounter = 0;
|
|
116
|
-
const getNextKey = () => `h${keyCounter++}`;
|
|
117
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
118
|
-
const entries = [
|
|
119
|
-
{
|
|
120
|
-
location: getHistoryLocation(
|
|
121
|
-
initialPath,
|
|
122
|
-
void 0,
|
|
123
|
-
getNextKey,
|
|
124
|
-
void 0,
|
|
125
|
-
true
|
|
126
|
-
)
|
|
127
|
-
}
|
|
128
|
-
];
|
|
129
|
-
let currentIndex = 0;
|
|
130
|
-
const getCurrentLocation = () => entries[currentIndex].location;
|
|
131
|
-
const notify = () => {
|
|
132
|
-
const location = getCurrentLocation();
|
|
133
|
-
listeners.forEach((listener) => listener(location));
|
|
134
|
-
};
|
|
135
|
-
const push = (path, opts) => {
|
|
136
|
-
const location = getHistoryLocation(
|
|
137
|
-
path,
|
|
138
|
-
opts?.state,
|
|
139
|
-
getNextKey,
|
|
140
|
-
getCurrentLocation(),
|
|
141
|
-
opts?.replaceSearch === true
|
|
142
|
-
);
|
|
143
|
-
if (currentIndex < entries.length - 1) {
|
|
144
|
-
entries.splice(currentIndex + 1);
|
|
145
|
-
}
|
|
146
|
-
entries.push({ location });
|
|
147
|
-
currentIndex = entries.length - 1;
|
|
148
|
-
notify();
|
|
149
|
-
};
|
|
150
|
-
const replace = (path, opts) => {
|
|
151
|
-
const location = getHistoryLocation(
|
|
152
|
-
path,
|
|
153
|
-
opts?.state,
|
|
154
|
-
getNextKey,
|
|
155
|
-
getCurrentLocation(),
|
|
156
|
-
opts?.replaceSearch === true
|
|
157
|
-
);
|
|
158
|
-
entries[currentIndex] = { location };
|
|
159
|
-
notify();
|
|
160
|
-
};
|
|
161
|
-
const go = (delta) => {
|
|
162
|
-
if (!Number.isFinite(delta)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const targetIndex = Math.max(
|
|
166
|
-
0,
|
|
167
|
-
Math.min(entries.length - 1, currentIndex + Math.trunc(delta))
|
|
168
|
-
);
|
|
169
|
-
if (targetIndex === currentIndex) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
currentIndex = targetIndex;
|
|
173
|
-
notify();
|
|
174
|
-
};
|
|
175
|
-
return {
|
|
176
|
-
get location() {
|
|
177
|
-
return getCurrentLocation();
|
|
178
|
-
},
|
|
179
|
-
get length() {
|
|
180
|
-
return entries.length;
|
|
181
|
-
},
|
|
182
|
-
get index() {
|
|
183
|
-
return currentIndex;
|
|
184
|
-
},
|
|
185
|
-
push,
|
|
186
|
-
replace,
|
|
187
|
-
go,
|
|
188
|
-
back: () => go(-1),
|
|
189
|
-
forward: () => go(1),
|
|
190
|
-
listen: (listener) => {
|
|
191
|
-
listeners.add(listener);
|
|
192
|
-
return () => listeners.delete(listener);
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// src/app/utils/RouteHistory.ts
|
|
198
|
-
var createRouteAdapterFromHistory = (history) => {
|
|
199
|
-
return {
|
|
200
|
-
getPath: () => history.location.path,
|
|
201
|
-
subscribe: (listener) => {
|
|
202
|
-
return history.listen((location) => {
|
|
203
|
-
listener(location.path);
|
|
204
|
-
});
|
|
205
|
-
},
|
|
206
|
-
push: (path) => {
|
|
207
|
-
history.push(path, { replaceSearch: true });
|
|
208
|
-
},
|
|
209
|
-
replace: (path) => {
|
|
210
|
-
history.replace(path, { replaceSearch: true });
|
|
211
|
-
},
|
|
212
|
-
back: history.back,
|
|
213
|
-
canGoBack: () => history.index > 0
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
// src/app/utils/UniversalRouteAdapter.ts
|
|
218
|
-
var getWindow = () => {
|
|
219
|
-
if (typeof globalThis === "undefined") {
|
|
220
|
-
return void 0;
|
|
221
|
-
}
|
|
222
|
-
if ("window" in globalThis) {
|
|
223
|
-
return globalThis.window;
|
|
224
|
-
}
|
|
225
|
-
return void 0;
|
|
226
|
-
};
|
|
227
|
-
var canUseBrowserHistory = () => {
|
|
228
|
-
const WINDOW = getWindow();
|
|
229
|
-
return Boolean(
|
|
230
|
-
WINDOW && WINDOW.location && WINDOW.history && typeof WINDOW.history.pushState === "function"
|
|
231
|
-
);
|
|
232
|
-
};
|
|
233
|
-
var createBrowserRouteAdapter = () => {
|
|
234
|
-
const WINDOW = getWindow();
|
|
235
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
236
|
-
const notify = () => {
|
|
237
|
-
const path = WINDOW?.location?.pathname ?? "";
|
|
238
|
-
listeners.forEach((listener) => listener(path));
|
|
239
|
-
};
|
|
240
|
-
const handleHistoryEvent = () => {
|
|
241
|
-
notify();
|
|
242
|
-
};
|
|
243
|
-
return {
|
|
244
|
-
getPath: () => WINDOW?.location?.pathname ?? "",
|
|
245
|
-
subscribe: (listener) => {
|
|
246
|
-
listeners.add(listener);
|
|
247
|
-
if (WINDOW) {
|
|
248
|
-
WINDOW.addEventListener("popstate", handleHistoryEvent);
|
|
249
|
-
WINDOW.addEventListener("statechanged", handleHistoryEvent);
|
|
250
|
-
}
|
|
251
|
-
return () => {
|
|
252
|
-
listeners.delete(listener);
|
|
253
|
-
if (WINDOW) {
|
|
254
|
-
WINDOW.removeEventListener("popstate", handleHistoryEvent);
|
|
255
|
-
WINDOW.removeEventListener("statechanged", handleHistoryEvent);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
},
|
|
259
|
-
push: (path, title = "") => {
|
|
260
|
-
if (!WINDOW?.history) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
const targetPath = parseHistoryPath(path).path;
|
|
264
|
-
if (targetPath === (WINDOW.location?.pathname ?? "")) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
WINDOW.history.pushState({}, title, path);
|
|
268
|
-
notify();
|
|
269
|
-
},
|
|
270
|
-
replace: (path, title = "") => {
|
|
271
|
-
if (!WINDOW?.history?.replaceState) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
const targetPath = parseHistoryPath(path).path;
|
|
275
|
-
if (targetPath === (WINDOW.location?.pathname ?? "")) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
WINDOW.history.replaceState({}, title, path);
|
|
279
|
-
notify();
|
|
280
|
-
},
|
|
281
|
-
back: () => WINDOW?.history?.back(),
|
|
282
|
-
canGoBack: () => (WINDOW?.history?.length ?? 0) > 1
|
|
283
|
-
};
|
|
284
|
-
};
|
|
285
|
-
var createNativeRouteAdapter = (initialPath = "/", ingress) => {
|
|
286
|
-
const mapURLToPath = ingress?.mapURLToPath ?? ((url) => buildHistoryPath(parseHistoryPath(url)));
|
|
287
|
-
const onIncomingURL = ingress?.onIncomingURL ?? "replace";
|
|
288
|
-
const history = createMemoryHistory(initialPath);
|
|
289
|
-
const adapter = createRouteAdapterFromHistory(history);
|
|
290
|
-
let stopIngress;
|
|
291
|
-
let ingressStarted = false;
|
|
292
|
-
let subscribers = 0;
|
|
293
|
-
const applyPath = (path, mode) => {
|
|
294
|
-
const normalizedPath = parseHistoryPath(path).path;
|
|
295
|
-
if (!normalizedPath || normalizedPath === history.location.path) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
if (mode === "push") {
|
|
299
|
-
history.push(normalizedPath, { replaceSearch: true });
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
history.replace(normalizedPath, { replaceSearch: true });
|
|
303
|
-
};
|
|
304
|
-
const startIngress = async () => {
|
|
305
|
-
if (ingressStarted || !ingress) {
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
ingressStarted = true;
|
|
309
|
-
const startKey = history.location.key;
|
|
310
|
-
const startIndex = history.index;
|
|
311
|
-
if (ingress.subscribe) {
|
|
312
|
-
stopIngress = ingress.subscribe((url) => {
|
|
313
|
-
const nextPath = mapURLToPath(url);
|
|
314
|
-
if (!nextPath) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
applyPath(nextPath, onIncomingURL);
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
const initialURL = await ingress.getInitialURL?.();
|
|
321
|
-
const userNavigated = history.location.key !== startKey || history.index !== startIndex;
|
|
322
|
-
if (!userNavigated && initialURL) {
|
|
323
|
-
const nextPath = mapURLToPath(initialURL);
|
|
324
|
-
if (nextPath) {
|
|
325
|
-
applyPath(nextPath, "replace");
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
return {
|
|
330
|
-
...adapter,
|
|
331
|
-
push: (path, title) => {
|
|
332
|
-
if (parseHistoryPath(path).path === history.location.path) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
adapter.push?.(path, title);
|
|
336
|
-
},
|
|
337
|
-
replace: (path, title) => {
|
|
338
|
-
if (parseHistoryPath(path).path === history.location.path) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
adapter.replace?.(path, title);
|
|
342
|
-
},
|
|
343
|
-
subscribe: (listener) => {
|
|
344
|
-
subscribers += 1;
|
|
345
|
-
if (subscribers === 1) {
|
|
346
|
-
void startIngress();
|
|
347
|
-
}
|
|
348
|
-
const unlisten = adapter.subscribe(listener);
|
|
349
|
-
return () => {
|
|
350
|
-
unlisten();
|
|
351
|
-
subscribers = Math.max(0, subscribers - 1);
|
|
352
|
-
if (subscribers === 0) {
|
|
353
|
-
stopIngress?.();
|
|
354
|
-
stopIngress = void 0;
|
|
355
|
-
ingressStarted = false;
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
},
|
|
359
|
-
back: adapter.back,
|
|
360
|
-
canGoBack: adapter.canGoBack
|
|
361
|
-
};
|
|
362
|
-
};
|
|
363
|
-
var createUniversalAdapter = (options = {}) => {
|
|
364
|
-
const { strategy = "auto", initialPath = "/", ingress } = options;
|
|
365
|
-
if (strategy === "web") {
|
|
366
|
-
return createBrowserRouteAdapter();
|
|
367
|
-
}
|
|
368
|
-
if (strategy === "native") {
|
|
369
|
-
return createNativeRouteAdapter(initialPath, ingress);
|
|
370
|
-
}
|
|
371
|
-
return canUseBrowserHistory() ? createBrowserRouteAdapter() : createNativeRouteAdapter(initialPath, ingress);
|
|
372
|
-
};
|
|
373
|
-
var createManualRouteAdapter = (initialPath = "/") => {
|
|
374
|
-
let currentPath = initialPath;
|
|
375
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
376
|
-
const updatePath = (nextPath) => {
|
|
377
|
-
currentPath = nextPath;
|
|
378
|
-
listeners.forEach((listener) => listener(nextPath));
|
|
379
|
-
};
|
|
380
|
-
const adapter = {
|
|
381
|
-
getPath: () => currentPath,
|
|
382
|
-
subscribe: (listener) => {
|
|
383
|
-
listeners.add(listener);
|
|
384
|
-
return () => {
|
|
385
|
-
listeners.delete(listener);
|
|
386
|
-
};
|
|
387
|
-
},
|
|
388
|
-
push: (path) => updatePath(path),
|
|
389
|
-
replace: (path) => updatePath(path)
|
|
390
|
-
};
|
|
391
|
-
return {
|
|
392
|
-
adapter,
|
|
393
|
-
updatePath
|
|
394
|
-
};
|
|
395
|
-
};
|
|
396
|
-
var isDevelopmentMode = () => {
|
|
397
|
-
const env = globalThis?.process?.env?.NODE_ENV;
|
|
398
|
-
return env !== "production";
|
|
399
|
-
};
|
|
400
|
-
var buildQueryString = (query = {}) => {
|
|
401
|
-
const parts = [];
|
|
402
|
-
for (const [key, rawValue] of Object.entries(query)) {
|
|
403
|
-
if (rawValue === void 0) {
|
|
404
|
-
continue;
|
|
405
|
-
}
|
|
406
|
-
const values = Array.isArray(rawValue) ? rawValue : [rawValue];
|
|
407
|
-
for (const value of values) {
|
|
408
|
-
if (value === void 0) {
|
|
409
|
-
continue;
|
|
410
|
-
}
|
|
411
|
-
const encodedKey = encodeURIComponent(key);
|
|
412
|
-
const encodedValue = value === null ? "" : encodeURIComponent(String(value));
|
|
413
|
-
parts.push(`${encodedKey}=${encodedValue}`);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
return parts.join("&");
|
|
417
|
-
};
|
|
418
|
-
var buildRoutePath = (segments, query) => {
|
|
419
|
-
const normalizedSegments = segments.map((segment) => String(segment));
|
|
420
|
-
const basePath = "/" + getPathString(normalizedSegments, "/", true, false, true);
|
|
421
|
-
const queryString = query ? buildQueryString(query) : "";
|
|
422
|
-
return queryString ? `${basePath}?${queryString}` : basePath;
|
|
423
|
-
};
|
|
424
|
-
var RouteContext = createContext({
|
|
425
|
-
currentWindowPath: "",
|
|
426
|
-
parentPath: "",
|
|
427
|
-
params: {},
|
|
428
|
-
isTopLevel: true
|
|
429
|
-
});
|
|
430
|
-
var {
|
|
431
|
-
/**
|
|
432
|
-
* @ignore
|
|
433
|
-
*/
|
|
434
|
-
Provider: RouteContextProvider,
|
|
435
|
-
/**
|
|
436
|
-
* @ignore
|
|
437
|
-
*/
|
|
438
|
-
Consumer: RouteContextConsumer
|
|
439
|
-
} = RouteContext;
|
|
440
|
-
var useRouteContext = () => useContext(RouteContext);
|
|
441
|
-
var getWindow2 = () => {
|
|
442
|
-
if (typeof globalThis === "undefined") {
|
|
443
|
-
return void 0;
|
|
444
|
-
}
|
|
445
|
-
if ("window" in globalThis) {
|
|
446
|
-
return globalThis.window;
|
|
447
|
-
}
|
|
448
|
-
return void 0;
|
|
449
|
-
};
|
|
450
|
-
var useBrowserLinkInterceptor = (adapter) => {
|
|
451
|
-
useEffect(() => {
|
|
452
|
-
const WINDOW = getWindow2();
|
|
453
|
-
if (!WINDOW || !adapter?.push) {
|
|
454
|
-
return void 0;
|
|
455
|
-
}
|
|
456
|
-
const handleAnchorClick = (event) => {
|
|
457
|
-
let target = event.target;
|
|
458
|
-
while (target && target.nodeName !== "A") {
|
|
459
|
-
target = target.parentNode;
|
|
460
|
-
}
|
|
461
|
-
if (!target || target.nodeName !== "A") {
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
const anchor = target;
|
|
465
|
-
const href = anchor.getAttribute("href");
|
|
466
|
-
const title = anchor.getAttribute("title") ?? "";
|
|
467
|
-
if (!href) {
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
try {
|
|
471
|
-
new URL(href);
|
|
472
|
-
return;
|
|
473
|
-
} catch (error) {
|
|
474
|
-
const nextPath = resolvePath(WINDOW.location?.pathname ?? "", href);
|
|
475
|
-
event.preventDefault();
|
|
476
|
-
adapter.push?.(nextPath, title);
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
WINDOW.document?.addEventListener("click", handleAnchorClick);
|
|
480
|
-
return () => {
|
|
481
|
-
WINDOW.document?.removeEventListener("click", handleAnchorClick);
|
|
482
|
-
};
|
|
483
|
-
}, [adapter]);
|
|
484
|
-
};
|
|
485
|
-
var RouteProvider = ({
|
|
486
|
-
adapter,
|
|
487
|
-
initialPath,
|
|
488
|
-
children
|
|
489
|
-
}) => {
|
|
490
|
-
const [currentPath, setCurrentPath] = useState(
|
|
491
|
-
initialPath ?? adapter.getPath()
|
|
492
|
-
);
|
|
493
|
-
useEffect(() => {
|
|
494
|
-
return adapter.subscribe((nextPath) => {
|
|
495
|
-
setCurrentPath(nextPath);
|
|
496
|
-
});
|
|
497
|
-
}, [adapter]);
|
|
498
|
-
const contextValue = useMemo(
|
|
499
|
-
() => ({
|
|
500
|
-
currentWindowPath: currentPath,
|
|
501
|
-
parentPath: "",
|
|
502
|
-
params: {},
|
|
503
|
-
isTopLevel: true,
|
|
504
|
-
adapter
|
|
505
|
-
}),
|
|
506
|
-
[currentPath, adapter]
|
|
507
|
-
);
|
|
508
|
-
return /* @__PURE__ */ jsx(RouteContextProvider, { value: contextValue, children });
|
|
509
|
-
};
|
|
510
|
-
var RouteMatcher = ({
|
|
511
|
-
/**
|
|
512
|
-
* Use `:` as the first character to denote a parameter in the path.
|
|
513
|
-
*/
|
|
514
|
-
path,
|
|
515
|
-
onParamsChange,
|
|
516
|
-
exact = false,
|
|
517
|
-
children
|
|
518
|
-
}) => {
|
|
519
|
-
const {
|
|
520
|
-
currentWindowPath = "",
|
|
521
|
-
parentPath = "",
|
|
522
|
-
params: parentParams = {},
|
|
523
|
-
adapter
|
|
524
|
-
} = useRouteContext();
|
|
525
|
-
const targetCurrentPath = useMemo(
|
|
526
|
-
() => currentWindowPath,
|
|
527
|
-
[currentWindowPath]
|
|
528
|
-
);
|
|
529
|
-
const fullPath = useMemo(
|
|
530
|
-
() => mergeStringPaths(parentPath, path),
|
|
531
|
-
[parentPath, path]
|
|
532
|
-
);
|
|
533
|
-
const newParams = useMemo(
|
|
534
|
-
() => getParamsAndTestPath(targetCurrentPath, fullPath, exact),
|
|
535
|
-
[targetCurrentPath, fullPath, exact]
|
|
536
|
-
);
|
|
537
|
-
const params = useMemo(
|
|
538
|
-
() => ({
|
|
539
|
-
...parentParams,
|
|
540
|
-
...newParams ? newParams : {}
|
|
541
|
-
}),
|
|
542
|
-
[parentParams, newParams]
|
|
543
|
-
);
|
|
544
|
-
const newRouteContext = useMemo(
|
|
545
|
-
() => ({
|
|
546
|
-
currentWindowPath: targetCurrentPath,
|
|
547
|
-
parentPath: fullPath,
|
|
548
|
-
params,
|
|
549
|
-
isTopLevel: false,
|
|
550
|
-
adapter
|
|
551
|
-
}),
|
|
552
|
-
[targetCurrentPath, fullPath, params, adapter]
|
|
553
|
-
);
|
|
554
|
-
useEffect(() => {
|
|
555
|
-
if (onParamsChange) {
|
|
556
|
-
onParamsChange(params);
|
|
557
|
-
}
|
|
558
|
-
}, [params, onParamsChange]);
|
|
559
|
-
return newParams ? /* @__PURE__ */ jsx(RouteContextProvider, { value: newRouteContext, children }) : null;
|
|
560
|
-
};
|
|
561
|
-
var RouteRootProvider = ({
|
|
562
|
-
children,
|
|
563
|
-
adapter,
|
|
564
|
-
initialPath,
|
|
565
|
-
ingress,
|
|
566
|
-
runtimeIntegration
|
|
567
|
-
}) => {
|
|
568
|
-
const routeContext = useRouteContext();
|
|
569
|
-
const autoAdapterRef = useRef(null);
|
|
570
|
-
if (typeof routeContext.adapter !== "undefined" && isDevelopmentMode()) {
|
|
571
|
-
throw new Error(
|
|
572
|
-
"Route provider mode is root-only. Nested Route requires a path."
|
|
573
|
-
);
|
|
574
|
-
}
|
|
575
|
-
if (!autoAdapterRef.current) {
|
|
576
|
-
autoAdapterRef.current = adapter ?? createUniversalAdapter({ initialPath, ingress });
|
|
577
|
-
}
|
|
578
|
-
useBrowserLinkInterceptor(autoAdapterRef.current);
|
|
579
|
-
useEffect(() => {
|
|
580
|
-
if (!runtimeIntegration || !autoAdapterRef.current) {
|
|
581
|
-
return void 0;
|
|
582
|
-
}
|
|
583
|
-
return runtimeIntegration.setup(autoAdapterRef.current);
|
|
584
|
-
}, [runtimeIntegration]);
|
|
585
|
-
return /* @__PURE__ */ jsx(RouteProvider, { adapter: autoAdapterRef.current, initialPath, children });
|
|
586
|
-
};
|
|
587
|
-
var Route = (props) => {
|
|
588
|
-
const hasMatcherProps = typeof props.path !== "undefined" || typeof props.exact !== "undefined" || typeof props.onParamsChange !== "undefined";
|
|
589
|
-
const hasProviderProps = typeof props.initialPath !== "undefined" || typeof props.adapter !== "undefined" || typeof props.ingress !== "undefined" || typeof props.runtimeIntegration !== "undefined";
|
|
590
|
-
if (hasMatcherProps) {
|
|
591
|
-
if (hasProviderProps && isDevelopmentMode()) {
|
|
592
|
-
throw new Error(
|
|
593
|
-
"Route matcher mode does not support provider props. Remove initialPath/adapter/ingress/runtimeIntegration or use a root Route without path."
|
|
594
|
-
);
|
|
595
|
-
}
|
|
596
|
-
return /* @__PURE__ */ jsx(
|
|
597
|
-
RouteMatcher,
|
|
598
|
-
{
|
|
599
|
-
path: props.path ?? "",
|
|
600
|
-
onParamsChange: props.onParamsChange,
|
|
601
|
-
exact: props.exact,
|
|
602
|
-
children: props.children
|
|
603
|
-
}
|
|
604
|
-
);
|
|
605
|
-
}
|
|
606
|
-
if (typeof props.path === "undefined") {
|
|
607
|
-
return /* @__PURE__ */ jsx(
|
|
608
|
-
RouteRootProvider,
|
|
609
|
-
{
|
|
610
|
-
adapter: props.adapter,
|
|
611
|
-
initialPath: props.initialPath,
|
|
612
|
-
ingress: props.ingress,
|
|
613
|
-
runtimeIntegration: props.runtimeIntegration,
|
|
614
|
-
children: props.children
|
|
615
|
-
}
|
|
616
|
-
);
|
|
617
|
-
}
|
|
618
|
-
return null;
|
|
619
|
-
};
|
|
620
|
-
|
|
621
|
-
export { Route, RouteContext, RouteContextConsumer, RouteContextProvider, RouteProvider, buildHistoryPath, buildQueryString, buildRoutePath, canUseBrowserHistory, computeTrackPixels, createBrowserRouteAdapter, createHistoryBackHandler, createManualRouteAdapter, createMemoryHistory, createNativeRouteAdapter, createRouteAdapterFromHistory, createUniversalAdapter, parseHistoryPath, useRouteContext };
|
package/chunk-IWRHGGGH.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// src/common/TypeParsing/TypeInfo.ts
|
|
2
|
-
var TypeOperation = /* @__PURE__ */ ((TypeOperation2) => {
|
|
3
|
-
TypeOperation2["CREATE"] = "CREATE";
|
|
4
|
-
TypeOperation2["READ"] = "READ";
|
|
5
|
-
TypeOperation2["UPDATE"] = "UPDATE";
|
|
6
|
-
TypeOperation2["DELETE"] = "DELETE";
|
|
7
|
-
return TypeOperation2;
|
|
8
|
-
})(TypeOperation || {});
|
|
9
|
-
|
|
10
|
-
export { TypeOperation };
|