@dotvoid/stacked-router 1.0.0 → 1.1.2
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 +45 -3
- package/dist/components/StackedView.d.ts +1 -1
- package/dist/components/StackedView.d.ts.map +1 -1
- package/dist/contexts/ViewContext.d.ts +1 -1
- package/dist/contexts/ViewContext.d.ts.map +1 -1
- package/dist/contexts/ViewProvider.d.ts +2 -2
- package/dist/contexts/ViewProvider.d.ts.map +1 -1
- package/dist/index.es.js +167 -161
- package/dist/index.umd.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,6 +60,48 @@ Named layouts are named `_layout.name.tsx`.
|
|
|
60
60
|
|
|
61
61
|
Layouts support defining named slots. This allows view components to render content which is automatically rendered inside the layout instead. This allow for styling of for example headers and footers in the layout while still allowing the views to have the logic and decide what should be rendered these slots.
|
|
62
62
|
|
|
63
|
+
### Responsive design
|
|
64
|
+
|
|
65
|
+
Responsive design needs extra care when working with stacked views as you need to account both for screen width and individual view widths. Stacked views already set style and class names to support container queries with vanilla CSS and Tailwind CSS. This allows you to create responsive layouts that adapt to the width of the view.
|
|
66
|
+
|
|
67
|
+
Unless overridden, each individual view in the stack defines a container called `view`. Both as vanilla CSS styles and the tailwind class name `@container/view`.
|
|
68
|
+
|
|
69
|
+
**Usage with vanilla CSS**
|
|
70
|
+
|
|
71
|
+
```css
|
|
72
|
+
.card {
|
|
73
|
+
font-size: 0.875rem;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@container view (min-width: 1024px) {
|
|
77
|
+
.card {
|
|
78
|
+
font-size: 1.125rem;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
return (
|
|
85
|
+
<div className='card'>
|
|
86
|
+
A card
|
|
87
|
+
</div>
|
|
88
|
+
)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
MDN on container queries at [CSS Container Queries](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries)
|
|
92
|
+
|
|
93
|
+
**Usage with Tailwind CSS**
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
return (
|
|
97
|
+
<div className='text-sm @lg/view:text-lg'>
|
|
98
|
+
A card
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Tailwind CSS on container queries at [Responsive Design](https://tailwindcss.com/docs/responsive-design)
|
|
104
|
+
|
|
63
105
|
### Error Boundaries
|
|
64
106
|
|
|
65
107
|
Stacked router includes automatic error boundaries around each view that catch rendering errors and display contextual error components.
|
|
@@ -107,7 +149,7 @@ export function App() {
|
|
|
107
149
|
|
|
108
150
|
**_layout.tsx**
|
|
109
151
|
|
|
110
|
-
Layouts are optional and are automatically wrapped around all views at the same level or below it in the file tree. This layout handles active state and width css using tailwind.
|
|
152
|
+
Layouts are optional and are automatically wrapped around all views at the same level or below it in the file tree. This layout handles active state and view width (vw percentage) css using tailwind.
|
|
111
153
|
|
|
112
154
|
```tsx
|
|
113
155
|
import { type PropsWithChildren } from 'react'
|
|
@@ -118,7 +160,7 @@ import { cn } from '@/lib/cn'
|
|
|
118
160
|
import View from '@/components/View'
|
|
119
161
|
|
|
120
162
|
export default function Layout({ children }: PropsWithChildren) {
|
|
121
|
-
const {
|
|
163
|
+
const { vw, isActive } = useView()
|
|
122
164
|
const stackedView = cva('h-full grow transition-all group/view', {
|
|
123
165
|
variants: {
|
|
124
166
|
isActive: {
|
|
@@ -129,7 +171,7 @@ export default function Layout({ children }: PropsWithChildren) {
|
|
|
129
171
|
})
|
|
130
172
|
|
|
131
173
|
return (
|
|
132
|
-
<StackedView className={cn(stackedView({ isActive }))} style={{ flexBasis: `${
|
|
174
|
+
<StackedView className={cn(stackedView({ isActive }))} style={{ flexBasis: `${vw}vw` }}>
|
|
133
175
|
<View.Root>
|
|
134
176
|
{children}
|
|
135
177
|
</View.Root>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, PropsWithChildren } from 'react';
|
|
2
|
-
export declare function StackedView({ children, style, className }: PropsWithChildren & {
|
|
2
|
+
export declare function StackedView({ children, style: userlandStyle, className: userlandClassName }: PropsWithChildren & {
|
|
3
3
|
className?: string;
|
|
4
4
|
style?: CSSProperties;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackedView.d.ts","sourceRoot":"","sources":["../../lib/components/StackedView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"StackedView.d.ts","sourceRoot":"","sources":["../../lib/components/StackedView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAA8B,MAAM,OAAO,CAAA;AAK9F,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAkB,EAAE,SAAS,EAAE,iBAAiB,EAAE,EAAE,iBAAiB,GAAG;IACrH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB,2CAkDA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewContext.d.ts","sourceRoot":"","sources":["../../lib/contexts/ViewContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;IACjB,
|
|
1
|
+
{"version":3,"file":"ViewContext.d.ts","sourceRoot":"","sources":["../../lib/contexts/ViewContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;IACvD,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAAE,UAAU,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IAClH,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;IACjD,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAAE,UAAU,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5G,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,SAAS,CAAA;CACjB;AAED,eAAO,MAAM,WAAW,0CAUtB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
export declare function ViewProvider({ id: viewId,
|
|
2
|
+
export declare function ViewProvider({ id: viewId, vw, layout, children, params, queryParams, props }: PropsWithChildren & {
|
|
3
3
|
id: string;
|
|
4
|
-
|
|
4
|
+
vw: number;
|
|
5
5
|
layout?: string;
|
|
6
6
|
params?: Record<string, string>;
|
|
7
7
|
queryParams?: Record<string, string | number | boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewProvider.d.ts","sourceRoot":"","sources":["../../lib/contexts/ViewProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAA;AAK9D,wBAAgB,YAAY,CAAC,EAC3B,EAAE,EAAE,MAAM,EACV,
|
|
1
|
+
{"version":3,"file":"ViewProvider.d.ts","sourceRoot":"","sources":["../../lib/contexts/ViewProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAA;AAK9D,wBAAgB,YAAY,CAAC,EAC3B,EAAE,EAAE,MAAM,EACV,EAAE,EACF,MAAM,EACN,QAAQ,EACR,MAAM,EACN,WAAW,EACX,KAAK,EACN,EAAE,iBAAiB,GAAG;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;CAClD,2CAiEA"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Oe, { createContext as X, useMemo as
|
|
1
|
+
import Oe, { createContext as X, useMemo as P, useState as C, useEffect as _, useContext as I, useRef as le, useCallback as ae, Component as Ve } from "react";
|
|
2
2
|
var W = { exports: {} }, V = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -15,16 +15,16 @@ function Ae() {
|
|
|
15
15
|
ie = 1;
|
|
16
16
|
var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
17
17
|
function n(r, o, s) {
|
|
18
|
-
var
|
|
19
|
-
if (s !== void 0 && (
|
|
18
|
+
var c = null;
|
|
19
|
+
if (s !== void 0 && (c = "" + s), o.key !== void 0 && (c = "" + o.key), "key" in o) {
|
|
20
20
|
s = {};
|
|
21
|
-
for (var
|
|
22
|
-
|
|
21
|
+
for (var i in o)
|
|
22
|
+
i !== "key" && (s[i] = o[i]);
|
|
23
23
|
} else s = o;
|
|
24
24
|
return o = s.ref, {
|
|
25
25
|
$$typeof: t,
|
|
26
26
|
type: r,
|
|
27
|
-
key:
|
|
27
|
+
key: c,
|
|
28
28
|
ref: o !== void 0 ? o : null,
|
|
29
29
|
props: s
|
|
30
30
|
};
|
|
@@ -50,7 +50,7 @@ function Ce() {
|
|
|
50
50
|
return a.$$typeof === _e ? null : a.displayName || a.name || null;
|
|
51
51
|
if (typeof a == "string") return a;
|
|
52
52
|
switch (a) {
|
|
53
|
-
case
|
|
53
|
+
case g:
|
|
54
54
|
return "Fragment";
|
|
55
55
|
case S:
|
|
56
56
|
return "Profiler";
|
|
@@ -108,7 +108,7 @@ function Ce() {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function r(a) {
|
|
111
|
-
if (a ===
|
|
111
|
+
if (a === g) return "<>";
|
|
112
112
|
if (typeof a == "object" && a !== null && a.$$typeof === Z)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
@@ -125,14 +125,14 @@ function Ce() {
|
|
|
125
125
|
function s() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function c(a) {
|
|
129
129
|
if (ee.call(a, "key")) {
|
|
130
130
|
var d = Object.getOwnPropertyDescriptor(a, "key").get;
|
|
131
131
|
if (d && d.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return a.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function i(a, d) {
|
|
136
136
|
function m() {
|
|
137
137
|
te || (te = !0, console.error(
|
|
138
138
|
"%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)",
|
|
@@ -197,10 +197,10 @@ function Ce() {
|
|
|
197
197
|
else w(R);
|
|
198
198
|
if (ee.call(d, "key")) {
|
|
199
199
|
R = t(a);
|
|
200
|
-
var
|
|
200
|
+
var j = Object.keys(d).filter(function(Te) {
|
|
201
201
|
return Te !== "key";
|
|
202
202
|
});
|
|
203
|
-
E = 0 <
|
|
203
|
+
E = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", se[R + E] || (j = 0 < j.length ? "{" + j.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
204
|
`A props object containing a "key" prop is being spread into JSX:
|
|
205
205
|
let props = %s;
|
|
206
206
|
<%s {...props} />
|
|
@@ -209,16 +209,16 @@ React keys must be passed directly to JSX without using spread:
|
|
|
209
209
|
<%s key={someKey} {...props} />`,
|
|
210
210
|
E,
|
|
211
211
|
R,
|
|
212
|
-
|
|
212
|
+
j,
|
|
213
213
|
R
|
|
214
214
|
), se[R + E] = !0);
|
|
215
215
|
}
|
|
216
|
-
if (R = null, m !== void 0 && (n(m), R = "" + m),
|
|
216
|
+
if (R = null, m !== void 0 && (n(m), R = "" + m), c(d) && (n(d.key), R = "" + d.key), "key" in d) {
|
|
217
217
|
m = {};
|
|
218
218
|
for (var B in d)
|
|
219
219
|
B !== "key" && (m[B] = d[B]);
|
|
220
220
|
} else m = d;
|
|
221
|
-
return R &&
|
|
221
|
+
return R && i(
|
|
222
222
|
m,
|
|
223
223
|
typeof a == "function" ? a.displayName || a.name || "Unknown" : a
|
|
224
224
|
), l(
|
|
@@ -235,19 +235,19 @@ React keys must be passed directly to JSX without using spread:
|
|
|
235
235
|
function w(a) {
|
|
236
236
|
typeof a == "object" && a !== null && a.$$typeof === h && a._store && (a._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
238
|
+
var y = Oe, h = Symbol.for("react.transitional.element"), x = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), N = Symbol.for("react.consumer"), Ee = Symbol.for("react.context"), Re = Symbol.for("react.forward_ref"), be = Symbol.for("react.suspense"), Se = Symbol.for("react.suspense_list"), ke = Symbol.for("react.memo"), Z = Symbol.for("react.lazy"), Pe = Symbol.for("react.activity"), _e = Symbol.for("react.client.reference"), D = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ee = Object.prototype.hasOwnProperty, je = Array.isArray, M = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
|
-
|
|
241
|
+
y = {
|
|
242
242
|
react_stack_bottom_frame: function(a) {
|
|
243
243
|
return a();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var te, re = {}, ne =
|
|
247
|
-
|
|
246
|
+
var te, re = {}, ne = y.react_stack_bottom_frame.bind(
|
|
247
|
+
y,
|
|
248
248
|
s
|
|
249
249
|
)(), oe = M(r(s)), se = {};
|
|
250
|
-
A.Fragment =
|
|
250
|
+
A.Fragment = g, A.jsx = function(a, d, m, E, k) {
|
|
251
251
|
var b = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
252
252
|
return p(
|
|
253
253
|
a,
|
|
@@ -307,9 +307,9 @@ function K(t = "", e = {}) {
|
|
|
307
307
|
...e
|
|
308
308
|
}, o = new URLSearchParams(
|
|
309
309
|
Object.entries(r).map(([u, l]) => [u, String(l)])
|
|
310
|
-
).toString(),
|
|
310
|
+
).toString(), c = t.startsWith("http://") || t.startsWith("https://") ? n.origin + n.pathname : n.pathname, i = c.endsWith("/") && c.length > 1 ? c.slice(0, -1) : c;
|
|
311
311
|
return {
|
|
312
|
-
url: o ? `${
|
|
312
|
+
url: o ? `${i}?${o}` : i,
|
|
313
313
|
path: n.pathname,
|
|
314
314
|
queryParams: r
|
|
315
315
|
};
|
|
@@ -376,7 +376,7 @@ function Ie(t, e) {
|
|
|
376
376
|
if (o > -1) {
|
|
377
377
|
const s = new URL(window.location.href);
|
|
378
378
|
s.search = new URLSearchParams(
|
|
379
|
-
Object.entries(e).map(([
|
|
379
|
+
Object.entries(e).map(([c, i]) => [c, String(i)])
|
|
380
380
|
).toString(), r.views[o].url = s.toString(), T(s.toString(), r);
|
|
381
381
|
}
|
|
382
382
|
}
|
|
@@ -395,20 +395,20 @@ function De(t, e) {
|
|
|
395
395
|
T(n.at(-1)?.url ?? "", r);
|
|
396
396
|
}
|
|
397
397
|
function Me(t, e, n, r, o, s) {
|
|
398
|
-
const
|
|
398
|
+
const c = [...o.views], i = crypto.randomUUID(), u = t.getFullPath(n), l = new URL(u, window.location.origin);
|
|
399
399
|
Object.entries(r).forEach(([v, S]) => {
|
|
400
400
|
l.searchParams.set(v, String(S));
|
|
401
401
|
});
|
|
402
|
-
const p = l.toString(), w = t.getViewComponentByPath(l.pathname),
|
|
402
|
+
const p = l.toString(), w = t.getViewComponentByPath(l.pathname), y = w?.params || {}, h = c.find((v) => p === v.url);
|
|
403
403
|
if (s.target !== "_top" && !s.append && h?.id === o.id)
|
|
404
404
|
return;
|
|
405
405
|
if (!s.append) {
|
|
406
406
|
if (s.target === "_top") {
|
|
407
407
|
const v = h || {
|
|
408
|
-
id:
|
|
408
|
+
id: i,
|
|
409
409
|
url: p,
|
|
410
410
|
meta: w?.meta ?? void 0,
|
|
411
|
-
params:
|
|
411
|
+
params: y,
|
|
412
412
|
queryParams: r,
|
|
413
413
|
props: s.props,
|
|
414
414
|
target: s?.target,
|
|
@@ -423,40 +423,40 @@ function Me(t, e, n, r, o, s) {
|
|
|
423
423
|
if (!s.append && h) {
|
|
424
424
|
T(p, {
|
|
425
425
|
id: h.id,
|
|
426
|
-
views:
|
|
426
|
+
views: c
|
|
427
427
|
});
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
if (s.append || s.target === "_void") {
|
|
432
|
-
|
|
433
|
-
id:
|
|
432
|
+
c.push({
|
|
433
|
+
id: i,
|
|
434
434
|
url: p,
|
|
435
435
|
meta: w?.meta ?? void 0,
|
|
436
|
-
params:
|
|
436
|
+
params: y,
|
|
437
437
|
queryParams: r,
|
|
438
438
|
props: s.props,
|
|
439
439
|
target: s?.target,
|
|
440
440
|
layout: s?.layout
|
|
441
441
|
}), H(p, {
|
|
442
|
-
id:
|
|
443
|
-
views:
|
|
442
|
+
id: i,
|
|
443
|
+
views: c
|
|
444
444
|
});
|
|
445
445
|
return;
|
|
446
446
|
}
|
|
447
|
-
const x =
|
|
448
|
-
|
|
449
|
-
id:
|
|
447
|
+
const x = c.findIndex((v) => v.id === e), g = c.slice(0, x + 1);
|
|
448
|
+
g.push({
|
|
449
|
+
id: i,
|
|
450
450
|
url: p,
|
|
451
451
|
meta: w?.meta ?? void 0,
|
|
452
|
-
params:
|
|
452
|
+
params: y,
|
|
453
453
|
queryParams: r,
|
|
454
454
|
props: s.props,
|
|
455
455
|
target: s?.target,
|
|
456
456
|
layout: s?.layout
|
|
457
457
|
}), H(p, {
|
|
458
|
-
id:
|
|
459
|
-
views:
|
|
458
|
+
id: i,
|
|
459
|
+
views: g
|
|
460
460
|
});
|
|
461
461
|
}
|
|
462
462
|
function Ye(t) {
|
|
@@ -484,7 +484,7 @@ class ze {
|
|
|
484
484
|
}
|
|
485
485
|
registerRoutes(e, n = !1) {
|
|
486
486
|
e.forEach((r) => {
|
|
487
|
-
const o = [], s = r.path.replace(/\[([^\]]+)\]/g, (
|
|
487
|
+
const o = [], s = r.path.replace(/\[([^\]]+)\]/g, (i, u) => (o.push(u), "([^/]+)")), c = new RegExp(`^${s}$`);
|
|
488
488
|
if (!r.component || !(r.component instanceof Function) || r.path[0] !== "/") {
|
|
489
489
|
if (n)
|
|
490
490
|
throw new Error(`Invalid component for route ${r.path || "undefined path"}`);
|
|
@@ -492,10 +492,10 @@ class ze {
|
|
|
492
492
|
}
|
|
493
493
|
this.#r[r.path] = {
|
|
494
494
|
component: r.component,
|
|
495
|
-
pattern:
|
|
495
|
+
pattern: c,
|
|
496
496
|
paramKeys: o,
|
|
497
497
|
originalPath: r.path,
|
|
498
|
-
layouts: r.layouts?.length ? r.layouts.map((
|
|
498
|
+
layouts: r.layouts?.length ? r.layouts.map((i) => ({ component: i })) : this.#a(r.path),
|
|
499
499
|
// Path found routes
|
|
500
500
|
meta: r.meta || { breakpoints: [] }
|
|
501
501
|
};
|
|
@@ -510,15 +510,15 @@ class ze {
|
|
|
510
510
|
getViewComponentByPath(e) {
|
|
511
511
|
const n = this.#n(e), r = n.length > 1 && n.at(-1) === "/" ? n.substring(0, n.length - 1) : n;
|
|
512
512
|
for (const o in this.#r) {
|
|
513
|
-
const s = this.#r[o],
|
|
514
|
-
if (
|
|
515
|
-
const
|
|
516
|
-
s.paramKeys.map((u, l) => [u,
|
|
513
|
+
const s = this.#r[o], c = r.match(s.pattern);
|
|
514
|
+
if (c) {
|
|
515
|
+
const i = Object.fromEntries(
|
|
516
|
+
s.paramKeys.map((u, l) => [u, c[l + 1]])
|
|
517
517
|
);
|
|
518
518
|
return {
|
|
519
519
|
Component: s.component,
|
|
520
520
|
Layouts: s.layouts,
|
|
521
|
-
params:
|
|
521
|
+
params: i,
|
|
522
522
|
meta: s.meta
|
|
523
523
|
};
|
|
524
524
|
}
|
|
@@ -531,9 +531,9 @@ class ze {
|
|
|
531
531
|
return this.#t[r];
|
|
532
532
|
const o = r.split("/").filter(Boolean);
|
|
533
533
|
for (let s = o.length; s >= 1; s--) {
|
|
534
|
-
const
|
|
535
|
-
if (this.#t[
|
|
536
|
-
return this.#t[
|
|
534
|
+
const c = "/" + o.slice(0, s).join("/");
|
|
535
|
+
if (this.#t[c])
|
|
536
|
+
return this.#t[c];
|
|
537
537
|
}
|
|
538
538
|
return this.#t["/"] ? this.#t["/"] : (console.log("No error component found"), null);
|
|
539
539
|
}
|
|
@@ -562,56 +562,56 @@ class ze {
|
|
|
562
562
|
const n = [], r = ["/", ...e.match(/[^/]+/g) || []];
|
|
563
563
|
let o = r[0];
|
|
564
564
|
for (let s = 0; s < r.length; s++) {
|
|
565
|
-
const
|
|
566
|
-
for (const
|
|
567
|
-
const [u, l] =
|
|
568
|
-
u === o &&
|
|
565
|
+
const c = [];
|
|
566
|
+
for (const i in this.#o) {
|
|
567
|
+
const [u, l] = i.split("#");
|
|
568
|
+
u === o && c.push({
|
|
569
569
|
key: l,
|
|
570
|
-
component: this.#o[
|
|
570
|
+
component: this.#o[i]
|
|
571
571
|
});
|
|
572
572
|
}
|
|
573
|
-
n.push(...
|
|
573
|
+
n.push(...c), o += r[s + 1];
|
|
574
574
|
}
|
|
575
575
|
return n;
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
578
|
function et({ basePath: t, config: e, external: n = [], children: r }) {
|
|
579
|
-
const o =
|
|
580
|
-
return
|
|
581
|
-
for (const
|
|
582
|
-
import(
|
|
579
|
+
const o = P(() => new ze(e, t), [e, t]), [s, c] = C(U("load", o));
|
|
580
|
+
return _(() => {
|
|
581
|
+
for (const i of n ?? [])
|
|
582
|
+
import(i.url).then((u) => {
|
|
583
583
|
if (!Array.isArray(u.routes))
|
|
584
|
-
throw new Error(`Invalid routes in ${
|
|
584
|
+
throw new Error(`Invalid routes in ${i.url}`);
|
|
585
585
|
o.registerRoutes(u.routes, !0);
|
|
586
586
|
}).catch((u) => {
|
|
587
587
|
console.error(u.message);
|
|
588
588
|
});
|
|
589
|
-
}, [n, o]),
|
|
589
|
+
}, [n, o]), _(() => {
|
|
590
590
|
t && t !== "/" && window.location.pathname === "/" && window.history.replaceState(null, "", t);
|
|
591
|
-
}, [t]),
|
|
592
|
-
const
|
|
593
|
-
return $(window, "popstate",
|
|
594
|
-
F(window, "popstate",
|
|
591
|
+
}, [t]), _(() => {
|
|
592
|
+
const i = () => c(U("popstate", o)), u = () => c(U("pushstate", o)), l = () => c(U("replacestate", o));
|
|
593
|
+
return $(window, "popstate", i), $(window, "pushstate", u), $(window, "replacestate", l), () => {
|
|
594
|
+
F(window, "popstate", i), F(window, "pushstate", u), F(window, "replacestate", l);
|
|
595
595
|
};
|
|
596
596
|
}, [o]), /* @__PURE__ */ f.jsx(fe.Provider, { value: { clientRouter: o, ...s }, children: r });
|
|
597
597
|
}
|
|
598
598
|
function U(t, e) {
|
|
599
|
-
const { state: n, length: r } = L(), { hash: o, host: s, hostname:
|
|
599
|
+
const { state: n, length: r } = L(), { hash: o, host: s, hostname: c, href: i, origin: u, pathname: l, port: p, protocol: w, search: y } = window.location;
|
|
600
600
|
return {
|
|
601
601
|
trigger: t,
|
|
602
602
|
state: n,
|
|
603
603
|
length: r,
|
|
604
604
|
hash: o,
|
|
605
605
|
host: s,
|
|
606
|
-
hostname:
|
|
607
|
-
href:
|
|
606
|
+
hostname: c,
|
|
607
|
+
href: i,
|
|
608
608
|
origin: u,
|
|
609
609
|
pathname: l,
|
|
610
610
|
port: p,
|
|
611
611
|
protocol: w,
|
|
612
|
-
search:
|
|
613
|
-
navigate: (h, x,
|
|
614
|
-
Me(e, h, x,
|
|
612
|
+
search: y,
|
|
613
|
+
navigate: (h, x, g, v) => {
|
|
614
|
+
Me(e, h, x, g, n, v);
|
|
615
615
|
},
|
|
616
616
|
close: (h) => {
|
|
617
617
|
De(h, n);
|
|
@@ -651,27 +651,27 @@ function J(t, e) {
|
|
|
651
651
|
}
|
|
652
652
|
function he() {
|
|
653
653
|
const { state: t, clientRouter: e } = O() || {}, n = le(void 0), r = !Be(n.current, t.views);
|
|
654
|
-
return
|
|
655
|
-
const s = [],
|
|
656
|
-
return t.views.forEach((
|
|
657
|
-
const u = new URL(
|
|
658
|
-
view:
|
|
654
|
+
return P(() => {
|
|
655
|
+
const s = [], c = [];
|
|
656
|
+
return t.views.forEach((i) => {
|
|
657
|
+
const u = new URL(i.url, "http://dummy.base"), l = e?.getViewComponentByPath(u.pathname), p = i.params || l?.params || {}, w = i.meta || l?.meta, y = {
|
|
658
|
+
view: i,
|
|
659
659
|
meta: w,
|
|
660
660
|
Component: l?.Component,
|
|
661
661
|
Layouts: l?.Layouts,
|
|
662
662
|
params: p
|
|
663
663
|
};
|
|
664
|
-
|
|
664
|
+
i.target === "_void" ? c.push(y) : s.push(y);
|
|
665
665
|
}), n.current = t.views, {
|
|
666
666
|
viewStack: s,
|
|
667
|
-
voidViews:
|
|
667
|
+
voidViews: c
|
|
668
668
|
};
|
|
669
669
|
}, [r, e]);
|
|
670
670
|
}
|
|
671
671
|
const me = X({
|
|
672
672
|
viewId: "",
|
|
673
673
|
isActive: !1,
|
|
674
|
-
|
|
674
|
+
vw: 0,
|
|
675
675
|
queryParams: {},
|
|
676
676
|
setQueryParams: () => {
|
|
677
677
|
},
|
|
@@ -685,41 +685,41 @@ const me = X({
|
|
|
685
685
|
});
|
|
686
686
|
function we({
|
|
687
687
|
id: t,
|
|
688
|
-
|
|
688
|
+
vw: e,
|
|
689
689
|
layout: n,
|
|
690
690
|
children: r,
|
|
691
691
|
params: o,
|
|
692
692
|
queryParams: s,
|
|
693
|
-
props:
|
|
693
|
+
props: c
|
|
694
694
|
}) {
|
|
695
|
-
const { state:
|
|
696
|
-
return
|
|
697
|
-
p(t ===
|
|
698
|
-
}, [
|
|
695
|
+
const { state: i, close: u } = O(), [l, p] = C(t === i.id), [w, y] = C(c || {});
|
|
696
|
+
return _(() => {
|
|
697
|
+
p(t === i.id);
|
|
698
|
+
}, [i.id, t]), /* @__PURE__ */ f.jsx(me.Provider, { value: {
|
|
699
699
|
viewId: t,
|
|
700
700
|
isActive: l,
|
|
701
|
-
|
|
701
|
+
vw: e,
|
|
702
702
|
params: o,
|
|
703
703
|
queryParams: s,
|
|
704
704
|
props: w,
|
|
705
705
|
layout: n,
|
|
706
|
-
state:
|
|
706
|
+
state: i,
|
|
707
707
|
setProps: (h, x) => {
|
|
708
|
-
const
|
|
709
|
-
for (const v in
|
|
710
|
-
|
|
711
|
-
g
|
|
708
|
+
const g = x ? h || {} : { ...c, ...h };
|
|
709
|
+
for (const v in g)
|
|
710
|
+
g[v] === void 0 && delete g[v];
|
|
711
|
+
y(g), qe(t, g);
|
|
712
712
|
},
|
|
713
713
|
setQueryParams: (h, x) => {
|
|
714
|
-
const
|
|
714
|
+
const g = x !== !0 ? { ...c || {} } : {};
|
|
715
715
|
let v = !1;
|
|
716
716
|
for (const S in h) {
|
|
717
717
|
const N = h[S];
|
|
718
|
-
typeof N < "u" ? (
|
|
718
|
+
typeof N < "u" ? (g[S] = N, v = !0) : Object.prototype.hasOwnProperty.call(g, S) && (delete g[S], v = !0);
|
|
719
719
|
}
|
|
720
|
-
(v || x === !0) && Ie(t,
|
|
720
|
+
(v || x === !0) && Ie(t, g);
|
|
721
721
|
},
|
|
722
|
-
queryParam: (h) =>
|
|
722
|
+
queryParam: (h) => c?.[h],
|
|
723
723
|
close: () => {
|
|
724
724
|
u(t);
|
|
725
725
|
}
|
|
@@ -738,24 +738,24 @@ function He(t, e) {
|
|
|
738
738
|
function Je(t, e) {
|
|
739
739
|
if (e.length === 0)
|
|
740
740
|
return [];
|
|
741
|
-
const r = e.map((
|
|
742
|
-
id:
|
|
743
|
-
minVw: Ge(
|
|
741
|
+
const r = e.map((c) => ({
|
|
742
|
+
id: c.id,
|
|
743
|
+
minVw: Ge(c, t)
|
|
744
744
|
})), o = r.reduce(
|
|
745
|
-
(
|
|
745
|
+
(c, i) => c + i.minVw,
|
|
746
746
|
0
|
|
747
747
|
);
|
|
748
748
|
if (o >= 100)
|
|
749
|
-
return r.map((
|
|
750
|
-
id:
|
|
751
|
-
vw:
|
|
749
|
+
return r.map((c) => ({
|
|
750
|
+
id: c.id,
|
|
751
|
+
vw: c.minVw
|
|
752
752
|
}));
|
|
753
753
|
const s = 100 - o;
|
|
754
|
-
return r.map((
|
|
755
|
-
const
|
|
754
|
+
return r.map((c) => {
|
|
755
|
+
const i = c.minVw / o, u = s * i;
|
|
756
756
|
return {
|
|
757
|
-
id:
|
|
758
|
-
vw: Number((
|
|
757
|
+
id: c.id,
|
|
758
|
+
vw: Number((c.minVw + u).toFixed(0))
|
|
759
759
|
// Round to 0 decimal places
|
|
760
760
|
};
|
|
761
761
|
});
|
|
@@ -764,7 +764,7 @@ function Ge(t, e) {
|
|
|
764
764
|
const r = [...t.breakpoints].sort((o, s) => s.breakpoint - o.breakpoint).find((o) => e >= o.breakpoint);
|
|
765
765
|
return r ? r.minVw : 100;
|
|
766
766
|
}
|
|
767
|
-
function
|
|
767
|
+
function ye({ children: t }) {
|
|
768
768
|
return /* @__PURE__ */ f.jsx(f.Fragment, { children: t });
|
|
769
769
|
}
|
|
770
770
|
const Q = X({
|
|
@@ -772,13 +772,13 @@ const Q = X({
|
|
|
772
772
|
},
|
|
773
773
|
getSlots: () => ({})
|
|
774
774
|
});
|
|
775
|
-
function
|
|
776
|
-
const [e, n] = C({}), r = ae((s,
|
|
775
|
+
function ge({ children: t }) {
|
|
776
|
+
const [e, n] = C({}), r = ae((s, c, i) => {
|
|
777
777
|
n((u) => ({
|
|
778
778
|
...u,
|
|
779
779
|
[s]: {
|
|
780
780
|
...u[s],
|
|
781
|
-
[
|
|
781
|
+
[c]: i
|
|
782
782
|
}
|
|
783
783
|
}));
|
|
784
784
|
}, []), o = ae((s) => e[s] || {}, [e]);
|
|
@@ -791,11 +791,11 @@ function Xe({
|
|
|
791
791
|
errorInfo: r,
|
|
792
792
|
reset: o
|
|
793
793
|
}) {
|
|
794
|
-
const { clientRouter: s } = O(),
|
|
794
|
+
const { clientRouter: s } = O(), c = s?.getErrorComponentByPath(
|
|
795
795
|
s?.getPathFromUrl(t) ?? "/"
|
|
796
796
|
);
|
|
797
|
-
return
|
|
798
|
-
|
|
797
|
+
return c ? /* @__PURE__ */ f.jsx(
|
|
798
|
+
c,
|
|
799
799
|
{
|
|
800
800
|
error: e,
|
|
801
801
|
errorCode: n ?? 0,
|
|
@@ -884,11 +884,11 @@ function tt({
|
|
|
884
884
|
style: e = {}
|
|
885
885
|
}) {
|
|
886
886
|
const { viewStack: n } = he(), [r, o] = C(window.innerWidth);
|
|
887
|
-
|
|
887
|
+
_(() => {
|
|
888
888
|
const u = () => o(window.innerWidth);
|
|
889
889
|
return window.addEventListener("resize", u), () => window.removeEventListener("resize", u);
|
|
890
890
|
}, []);
|
|
891
|
-
const s =
|
|
891
|
+
const s = P(() => He(r, n), [r, n]), c = P(() => {
|
|
892
892
|
let u = 0, l = 0;
|
|
893
893
|
for (let p = n.length - 1; p >= 0; p--)
|
|
894
894
|
if (u += s[p]?.vw || 0, u > 100) {
|
|
@@ -896,15 +896,15 @@ function tt({
|
|
|
896
896
|
break;
|
|
897
897
|
}
|
|
898
898
|
return n.slice(l);
|
|
899
|
-
}, [s, n]),
|
|
900
|
-
const u = n.length -
|
|
901
|
-
return
|
|
902
|
-
}, [s, n.length,
|
|
899
|
+
}, [s, n]), i = P(() => {
|
|
900
|
+
const u = n.length - c.length;
|
|
901
|
+
return c.map((l, p) => s[p + u].vw);
|
|
902
|
+
}, [s, n.length, c]);
|
|
903
903
|
return /* @__PURE__ */ f.jsx(
|
|
904
904
|
Ke,
|
|
905
905
|
{
|
|
906
|
-
views:
|
|
907
|
-
widths:
|
|
906
|
+
views: c,
|
|
907
|
+
widths: i,
|
|
908
908
|
style: e,
|
|
909
909
|
className: t
|
|
910
910
|
}
|
|
@@ -916,8 +916,8 @@ function Ke({
|
|
|
916
916
|
className: n,
|
|
917
917
|
style: r = {}
|
|
918
918
|
}) {
|
|
919
|
-
return /* @__PURE__ */ f.jsx(
|
|
920
|
-
if (!
|
|
919
|
+
return /* @__PURE__ */ f.jsx(ge, { children: /* @__PURE__ */ f.jsx("div", { className: n, style: r, children: t.map(({ view: o, params: s, Layouts: c, Component: i }, u) => {
|
|
920
|
+
if (!i)
|
|
921
921
|
return /* @__PURE__ */ f.jsx(
|
|
922
922
|
G,
|
|
923
923
|
{
|
|
@@ -927,16 +927,16 @@ function Ke({
|
|
|
927
927
|
},
|
|
928
928
|
o.id
|
|
929
929
|
);
|
|
930
|
-
const l =
|
|
930
|
+
const l = c?.length ? c.filter((p) => p.key === o.layout) : [{ component: ye }];
|
|
931
931
|
return /* @__PURE__ */ f.jsx(G, { viewUrl: o.url || "/", children: /* @__PURE__ */ f.jsx(
|
|
932
932
|
we,
|
|
933
933
|
{
|
|
934
934
|
id: o.id,
|
|
935
|
-
|
|
935
|
+
vw: e[u],
|
|
936
936
|
params: s,
|
|
937
937
|
queryParams: o.queryParams,
|
|
938
938
|
props: o.props,
|
|
939
|
-
children: ve(l,
|
|
939
|
+
children: ve(l, i, s)
|
|
940
940
|
},
|
|
941
941
|
o.id
|
|
942
942
|
) }, o.id);
|
|
@@ -960,18 +960,18 @@ function rt({ className: t, style: e = {} }) {
|
|
|
960
960
|
);
|
|
961
961
|
}
|
|
962
962
|
function Qe({ views: t, className: e, style: n = {} }) {
|
|
963
|
-
return /* @__PURE__ */ f.jsx(
|
|
964
|
-
const
|
|
963
|
+
return /* @__PURE__ */ f.jsx(ge, { children: /* @__PURE__ */ f.jsx("div", { className: e, style: n, children: t.map(({ view: r, params: o, Layouts: s, Component: c }) => {
|
|
964
|
+
const i = s?.length ? s.filter((u) => u.key === r.layout) : [{ component: ye }];
|
|
965
965
|
return /* @__PURE__ */ f.jsx(G, { viewUrl: r.url || "/", children: /* @__PURE__ */ f.jsx(
|
|
966
966
|
we,
|
|
967
967
|
{
|
|
968
968
|
id: r.id,
|
|
969
|
-
|
|
969
|
+
vw: 0,
|
|
970
970
|
params: o,
|
|
971
971
|
queryParams: r.queryParams,
|
|
972
972
|
props: r.props,
|
|
973
973
|
layout: r.layout,
|
|
974
|
-
children: xe(
|
|
974
|
+
children: xe(i, c, o)
|
|
975
975
|
},
|
|
976
976
|
r.id
|
|
977
977
|
) }, r.id);
|
|
@@ -990,15 +990,21 @@ function q() {
|
|
|
990
990
|
return t;
|
|
991
991
|
}
|
|
992
992
|
function nt({ children: t, style: e = {}, className: n }) {
|
|
993
|
-
const { viewId: r } = q(), o = le(null)
|
|
994
|
-
|
|
993
|
+
const { viewId: r } = q(), o = le(null), s = P(() => {
|
|
994
|
+
const i = { ...e };
|
|
995
|
+
return i.containerType || (i.containerType = "size"), i.containerName || (i.containerName = "view"), i;
|
|
996
|
+
}, [e]), c = P(() => {
|
|
997
|
+
let i = n ?? "";
|
|
998
|
+
return i.includes("@container") || (i += " @container/view"), i;
|
|
999
|
+
}, [n]);
|
|
1000
|
+
return _(() => {
|
|
995
1001
|
if (!o.current)
|
|
996
1002
|
return;
|
|
997
|
-
const
|
|
1003
|
+
const i = () => {
|
|
998
1004
|
$e(r);
|
|
999
|
-
},
|
|
1000
|
-
return $(
|
|
1001
|
-
}, [r, o]), /* @__PURE__ */ f.jsx("div", { ref: o, style:
|
|
1005
|
+
}, u = o.current;
|
|
1006
|
+
return $(u, "click", i), () => F(u, "click", i);
|
|
1007
|
+
}, [r, o]), /* @__PURE__ */ f.jsx("div", { ref: o, style: s, className: c, children: t });
|
|
1002
1008
|
}
|
|
1003
1009
|
function ot({
|
|
1004
1010
|
href: t,
|
|
@@ -1007,18 +1013,18 @@ function ot({
|
|
|
1007
1013
|
className: r,
|
|
1008
1014
|
target: o = "_self",
|
|
1009
1015
|
onClick: s,
|
|
1010
|
-
props:
|
|
1011
|
-
layout:
|
|
1016
|
+
props: c,
|
|
1017
|
+
layout: i
|
|
1012
1018
|
}) {
|
|
1013
|
-
const { navigate: u } = O(), { url: l, queryParams: p } = K(t, e), { viewId: w } = q(),
|
|
1019
|
+
const { navigate: u } = O(), { url: l, queryParams: p } = K(t, e), { viewId: w } = q(), y = (x) => {
|
|
1014
1020
|
s && (s(x), x.isDefaultPrevented()) || l.startsWith("https://") || l.startsWith("http://") || o === "_blank" || x.metaKey || x.ctrlKey || (x.preventDefault(), u(w, l, p, {
|
|
1015
1021
|
append: x.shiftKey,
|
|
1016
1022
|
target: o,
|
|
1017
|
-
props:
|
|
1018
|
-
layout:
|
|
1023
|
+
props: c,
|
|
1024
|
+
layout: i
|
|
1019
1025
|
}));
|
|
1020
1026
|
}, h = Ue(l) ? "noopener noreferrer" : void 0;
|
|
1021
|
-
return /* @__PURE__ */ f.jsx("a", { rel: h, href: l, onClick:
|
|
1027
|
+
return /* @__PURE__ */ f.jsx("a", { rel: h, href: l, onClick: y, className: r, target: o, children: n });
|
|
1022
1028
|
}
|
|
1023
1029
|
function st({ slot: t }) {
|
|
1024
1030
|
const { viewId: e } = q(), { getSlots: n } = I(Q), r = n(e);
|
|
@@ -1026,7 +1032,7 @@ function st({ slot: t }) {
|
|
|
1026
1032
|
}
|
|
1027
1033
|
function at({ slot: t, children: e }) {
|
|
1028
1034
|
const { viewId: n } = q(), { setSlot: r } = I(Q);
|
|
1029
|
-
return
|
|
1035
|
+
return _(() => (r(n, t, e), () => r(n, t, null)), [n, t, e, r]), null;
|
|
1030
1036
|
}
|
|
1031
1037
|
function it() {
|
|
1032
1038
|
const { navigate: t } = O();
|
|
@@ -1046,13 +1052,13 @@ function ct(t) {
|
|
|
1046
1052
|
}
|
|
1047
1053
|
function ut(t, e) {
|
|
1048
1054
|
const { state: n } = O();
|
|
1049
|
-
return
|
|
1055
|
+
return P(() => {
|
|
1050
1056
|
const o = [];
|
|
1051
1057
|
return n.views.forEach((s) => {
|
|
1052
1058
|
if (s.meta?.type === t) {
|
|
1053
1059
|
if (e) {
|
|
1054
|
-
const
|
|
1055
|
-
if (!Object.entries(e).every(([u, l]) =>
|
|
1060
|
+
const c = s.params || {};
|
|
1061
|
+
if (!Object.entries(e).every(([u, l]) => c[u] === l))
|
|
1056
1062
|
return;
|
|
1057
1063
|
}
|
|
1058
1064
|
o.push({
|
|
@@ -1071,28 +1077,28 @@ function ut(t, e) {
|
|
|
1071
1077
|
}
|
|
1072
1078
|
function lt(t, e = "") {
|
|
1073
1079
|
const n = [], r = {}, o = {};
|
|
1074
|
-
return Object.entries(t).forEach(([s,
|
|
1075
|
-
let
|
|
1076
|
-
|
|
1077
|
-
const u =
|
|
1080
|
+
return Object.entries(t).forEach(([s, c]) => {
|
|
1081
|
+
let i = s.replace(e, "").replace(/\.tsx$/, "").replace(/\/index$/, "").replace(/([A-Z])/g, (p) => `/${p.toLowerCase()}`).replace(/\/\//g, "/").toLowerCase() || "/";
|
|
1082
|
+
i === "" || i === "index" ? i = "/" : i && !i.startsWith("/") && (i = "/" + i);
|
|
1083
|
+
const u = i.match(/^(.*)\/(_error)$/);
|
|
1078
1084
|
if (u) {
|
|
1079
1085
|
const [, p] = u, w = p || "/";
|
|
1080
|
-
o[w] =
|
|
1086
|
+
o[w] = c.default;
|
|
1081
1087
|
return;
|
|
1082
1088
|
}
|
|
1083
|
-
const l =
|
|
1089
|
+
const l = i.match(/^(.*)\/(_layout(?:\.([^/]+))?)$/);
|
|
1084
1090
|
if (l) {
|
|
1085
|
-
const [, p, , w] = l,
|
|
1091
|
+
const [, p, , w] = l, y = p || "/";
|
|
1086
1092
|
if (w) {
|
|
1087
|
-
const h = `${
|
|
1088
|
-
r[h] =
|
|
1093
|
+
const h = `${y}#${w}`;
|
|
1094
|
+
r[h] = c.default;
|
|
1089
1095
|
} else
|
|
1090
|
-
r[
|
|
1091
|
-
} else
|
|
1092
|
-
path:
|
|
1093
|
-
component:
|
|
1096
|
+
r[y] = c.default;
|
|
1097
|
+
} else i.includes("/_") || n.push({
|
|
1098
|
+
path: i,
|
|
1099
|
+
component: c.default,
|
|
1094
1100
|
// @ts-expect-error meta is not defined
|
|
1095
|
-
meta:
|
|
1101
|
+
meta: c.default?.meta || { breakpoints: [] }
|
|
1096
1102
|
});
|
|
1097
1103
|
}), { routes: n, layouts: r, errors: o };
|
|
1098
1104
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Q;function we(){if(Q)return V;Q=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,o,s){var
|
|
9
|
+
*/var Q;function we(){if(Q)return V;Q=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,o,s){var c=null;if(s!==void 0&&(c=""+s),o.key!==void 0&&(c=""+o.key),"key"in o){s={};for(var i in o)i!=="key"&&(s[i]=o[i])}else s=o;return o=s.ref,{$$typeof:t,type:r,key:c,ref:o!==void 0?o:null,props:s}}return V.Fragment=e,V.jsx=n,V.jsxs=n,V}var C={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Z;function
|
|
17
|
+
*/var Z;function ye(){return Z||(Z=1,process.env.NODE_ENV!=="production"&&(function(){function t(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===et?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case v:return"Fragment";case P:return"Profiler";case E:return"StrictMode";case Qe:return"Suspense";case Ze:return"SuspenseList";case $e:return"Activity"}if(typeof a=="object")switch(typeof a.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case R:return"Portal";case Xe:return(a.displayName||"Context")+".Provider";case M:return(a._context.displayName||"Context")+".Consumer";case Ke:var d=a.render;return a=a.displayName,a||(a=d.displayName||d.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case qe:return d=a.displayName||null,d!==null?d:t(a.type)||"Memo";case ue:d=a._payload,a=a._init;try{return t(a(d))}catch{}}return null}function e(a){return""+a}function n(a){try{e(a);var d=!1}catch{d=!0}if(d){d=console;var w=d.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object";return w.call(d,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),e(a)}}function r(a){if(a===v)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===ue)return"<...>";try{var d=t(a);return d?"<"+d+">":"<...>"}catch{return"<...>"}}function o(){var a=H.A;return a===null?null:a.getOwner()}function s(){return Error("react-stack-top-frame")}function c(a){if(le.call(a,"key")){var d=Object.getOwnPropertyDescriptor(a,"key").get;if(d&&d.isReactWarning)return!1}return a.key!==void 0}function i(a,d){function w(){fe||(fe=!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)",d))}w.isReactWarning=!0,Object.defineProperty(a,"key",{get:w,configurable:!0})}function u(){var a=t(this.type);return de[a]||(de[a]=!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.")),a=this.props.ref,a!==void 0?a:null}function l(a,d,w,b,j,k,J,X){return w=k.ref,a={$$typeof:m,type:a,key:d,props:k,_owner:j},(w!==void 0?w:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:u}):Object.defineProperty(a,"ref",{enumerable:!1,value:null}),a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(a,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(a,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(a,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a}function h(a,d,w,b,j,k,J,X){var S=d.children;if(S!==void 0)if(b)if(tt(S)){for(b=0;b<S.length;b++)y(S[b]);Object.freeze&&Object.freeze(S)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(S);if(le.call(d,"key")){S=t(a);var O=Object.keys(d).filter(function(rt){return rt!=="key"});b=0<O.length?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}",me[S+b]||(O=0<O.length?"{"+O.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,S,b,O,b),me[b+S]=!0)}if(b=null,w!==void 0&&(n(w),b=""+w),i(d)&&(n(d.key),b=""+d.key),"key"in d){w={};for(var K in d)K!=="key"&&(w[K]=d[K])}else w=d;return b&&c(w,typeof a=="function"?a.displayName||a.name||"Unknown":a),l(a,b,k,j,o(),w,J,X)}function g(a){typeof a=="object"&&a!==null&&a.$$typeof===m&&a._store&&(a._store.validated=1)}var y=p,m=Symbol.for("react.transitional.element"),R=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),Xe=Symbol.for("react.context"),Ke=Symbol.for("react.forward_ref"),Qe=Symbol.for("react.suspense"),Ze=Symbol.for("react.suspense_list"),qe=Symbol.for("react.memo"),ue=Symbol.for("react.lazy"),$e=Symbol.for("react.activity"),et=Symbol.for("react.client.reference"),H=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le=Object.prototype.hasOwnProperty,tt=Array.isArray,G=console.createTask?console.createTask:function(){return null};y={react_stack_bottom_frame:function(a){return a()}};var fe,de={},pe=y.react_stack_bottom_frame.bind(y,s)(),he=G(r(s)),me={};C.Fragment=v,C.jsx=function(a,d,w,S,j){var k=1e4>H.recentlyCreatedOwnerStacks++;return h(a,d,w,!1,S,j,k?Error("react-stack-top-frame"):pe,k?G(r(a)):he)},C.jsxs=function(a,d,w,S,j){var k=1e4>H.recentlyCreatedOwnerStacks++;return h(a,d,w,!0,S,j,k?Error("react-stack-top-frame"):pe,k?G(r(a)):he)}})()),C}var q;function ye(){return q||(q=1,process.env.NODE_ENV==="production"?N.exports=we():N.exports=ge()),N.exports}var f=ye();const $=p.createContext({trigger:"init",state:{id:"",views:[]},navigate:()=>{},close:()=>{}});function W(t,...e){t&&t.addEventListener&&t.addEventListener(...e)}function U(t,...e){t&&t.removeEventListener&&t.removeEventListener(...e)}function ee(t,e){window.dispatchEvent(new CustomEvent(t,{detail:e}))}function M(t="",e={}){const n=new URL(t,"http://dummy.base"),r={...Object.fromEntries(n.searchParams.entries()),...e},o=new URLSearchParams(Object.entries(r).map(([u,l])=>[u,String(l)])).toString(),i=t.startsWith("http://")||t.startsWith("https://")?n.origin+n.pathname:n.pathname,c=i.endsWith("/")&&i.length>1?i.slice(0,-1):i;return{url:o?`${c}?${o}`:c,path:n.pathname,queryParams:r}}function ve(t){const e={};for(const[n,r]of new URLSearchParams(t))r==="true"?e[n]=!0:r==="false"?e[n]=!1:Ee(r)?e[n]=r.includes(".")?parseFloat(r):parseInt(r,10):e[n]=r;return e}function Ee(t){return isNaN(+t)?!1:parseInt(t).toString()===t||parseFloat(t).toString()===t}const xe=t=>{try{return new URL(t,window.location.origin).origin!==window.location.origin}catch{return!1}};function A(){const{state:t,length:e}=window.history,{href:n}=window.location;return{state:_e(t)?t:Se(n),length:e}}function D(t,e){history.pushState(e,"",t),ee("pushstate",e)}function _(t,e){history.replaceState(e,"",t),ee("replacestate",e)}function Re(t){const{id:e,views:n}=A().state;if(e===t)return;const r=n.find(o=>o.id===t);r&&_(r.url,{id:r.id,views:n})}function Se(t){const e=crypto.randomUUID(),n=new URL(t),r={id:e,views:[{id:e,url:t,queryParams:ve(n.search),props:{}}]};return _(t,r),r}function be(t,e){const{state:n}=A(),r={...n};let o=-1;for(let s=0;s<r.views.length;s++)if(r.views[s].id===t){te(r.views[s].queryParams,e)||(r.views[s].queryParams=e,o=s);break}if(o>-1){const s=new URL(window.location.href);s.search=new URLSearchParams(Object.entries(e).map(([i,c])=>[i,String(c)])).toString(),r.views[o].url=s.toString(),_(s.toString(),r)}}function ke(t,e){const{state:n}=A(),r={...n};let o=-1;for(let s=0;s<r.views.length;s++)if(r.views[s].id===t){te(r.views[s].props,e)||(r.views[s].props=e,o=s);break}o>-1&&_(window.location.href,r)}function Pe(t,e){const n=[...e.views].filter(o=>o.id!==t),r={...e,views:n};_(n.at(-1)?.url??"",r)}function je(t,e,n,r,o,s){const i=[...o.views],c=crypto.randomUUID(),u=t.getFullPath(n),l=new URL(u,window.location.origin);Object.entries(r).forEach(([E,P])=>{l.searchParams.set(E,String(P))});const h=l.toString(),g=t.getViewComponentByPath(l.pathname),y=g?.params||{},m=i.find(E=>h===E.url);if(s.target!=="_top"&&!s.append&&m?.id===o.id)return;if(!s.append){if(s.target==="_top"){const E=m||{id:c,url:h,meta:g?.meta??void 0,params:y,queryParams:r,props:s.props,target:s?.target,layout:s?.layout};D(h,{id:E.id,views:[E]});return}if(!s.append&&m){_(h,{id:m.id,views:i});return}}if(s.append||s.target==="_void"){i.push({id:c,url:h,meta:g?.meta??void 0,params:y,queryParams:r,props:s.props,target:s?.target,layout:s?.layout}),D(h,{id:c,views:i});return}const R=i.findIndex(E=>E.id===e),v=i.slice(0,R+1);v.push({id:c,url:h,meta:g?.meta??void 0,params:y,queryParams:r,props:s.props,target:s?.target,layout:s?.layout}),D(h,{id:c,views:v})}function _e(t){return!t||typeof t!="object"?!1:"id"in t&&"views"in t&&Array.isArray(t.views)}function te(t,e){if(typeof t!=typeof e)return!1;if(typeof t>"u"||typeof e>"u")return!0;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(!(n in e)||t[n]!==e[n]||typeof t[n]!=typeof e[n])return!1;return!0}class Te{#e="/";#r={};#o={};#t={};constructor(e,n){this.#e=n?this.#s(n):"/",this.#o=e.layouts||{},this.#t=e.errors||{},this.registerRoutes(e.routes)}registerRoutes(e,n=!1){e.forEach(r=>{const o=[],s=r.path.replace(/\[([^\]]+)\]/g,(c,u)=>(o.push(u),"([^/]+)")),i=new RegExp(`^${s}$`);if(!r.component||!(r.component instanceof Function)||r.path[0]!=="/"){if(n)throw new Error(`Invalid component for route ${r.path||"undefined path"}`);return}this.#r[r.path]={component:r.component,pattern:i,paramKeys:o,originalPath:r.path,layouts:r.layouts?.length?r.layouts.map(c=>({component:c})):this.#a(r.path),meta:r.meta||{breakpoints:[]}}})}#s(e){return e.startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}#n(e){return this.#e==="/"?e:e.startsWith(this.#e)?e.slice(this.#e.length)||"/":e}getViewComponentByPath(e){const n=this.#n(e),r=n.length>1&&n.at(-1)==="/"?n.substring(0,n.length-1):n;for(const o in this.#r){const s=this.#r[o],i=r.match(s.pattern);if(i){const c=Object.fromEntries(s.paramKeys.map((u,l)=>[u,i[l+1]]));return{Component:s.component,Layouts:s.layouts,params:c,meta:s.meta}}}return null}getErrorComponentByPath(e){const n=this.#n(e),r=n.length>1&&n.at(-1)==="/"?n.substring(0,n.length-1):n;if(this.#t[r])return this.#t[r];const o=r.split("/").filter(Boolean);for(let s=o.length;s>=1;s--){const i="/"+o.slice(0,s).join("/");if(this.#t[i])return this.#t[i]}return this.#t["/"]?this.#t["/"]:(console.log("No error component found"),null)}get basePath(){return this.#e}getFullPath(e){return this.#e==="/"?e:e==="/"?this.#e:e.startsWith(this.#e)?e:this.#e+e}getPathFromUrl(e){try{let r=new URL(e).pathname;return r=this.#n(r),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),r}catch{return this.#n(e)}}getAllViewComponents(){return Object.values(this.#r).map(e=>({Component:e.component,Layouts:e.layouts,meta:e.meta}))}#a(e){const n=[],r=["/",...e.match(/[^/]+/g)||[]];let o=r[0];for(let s=0;s<r.length;s++){const i=[];for(const c in this.#o){const[u,l]=c.split("#");u===o&&i.push({key:l,component:this.#o[c]})}n.push(...i),o+=r[s+1]}return n}}function Oe({basePath:t,config:e,external:n=[],children:r}){const o=p.useMemo(()=>new Te(e,t),[e,t]),[s,i]=p.useState(F("load",o));return p.useEffect(()=>{for(const c of n??[])import(c.url).then(u=>{if(!Array.isArray(u.routes))throw new Error(`Invalid routes in ${c.url}`);o.registerRoutes(u.routes,!0)}).catch(u=>{console.error(u.message)})},[n,o]),p.useEffect(()=>{t&&t!=="/"&&window.location.pathname==="/"&&window.history.replaceState(null,"",t)},[t]),p.useEffect(()=>{const c=()=>i(F("popstate",o)),u=()=>i(F("pushstate",o)),l=()=>i(F("replacestate",o));return W(window,"popstate",c),W(window,"pushstate",u),W(window,"replacestate",l),()=>{U(window,"popstate",c),U(window,"pushstate",u),U(window,"replacestate",l)}},[o]),f.jsx($.Provider,{value:{clientRouter:o,...s},children:r})}function F(t,e){const{state:n,length:r}=A(),{hash:o,host:s,hostname:i,href:c,origin:u,pathname:l,port:h,protocol:g,search:y}=window.location;return{trigger:t,state:n,length:r,hash:o,host:s,hostname:i,href:c,origin:u,pathname:l,port:h,protocol:g,search:y,navigate:(m,R,v,E)=>{je(e,m,R,v,n,E)},close:m=>{Pe(m,n)}}}function T(){const t=p.useContext($);if(t===void 0)throw new Error("useRouter must be used within a RouterProvider");return t}function Ve(t,e){if(!t||!e)return t===e;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){const r=t[n],o=e[n];if(r.id!==o.id||r.url!==o.url||r.layout!==o.layout||r.target!==o.target||!Y(r.params,o.params)||!Y(r.queryParams,o.queryParams)||!Y(r.props,o.props)||r.meta!==o.meta&&(!r.meta||!o.meta||r.meta.type!==o.meta.type))return!1}return!0}function Y(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const o of n)if(t[o]!==e[o])return!1;return!0}function re(){const{state:t,clientRouter:e}=T()||{},n=p.useRef(void 0),r=!Ve(n.current,t.views);return p.useMemo(()=>{const s=[],i=[];return t.views.forEach(c=>{const u=new URL(c.url,"http://dummy.base"),l=e?.getViewComponentByPath(u.pathname),h=c.params||l?.params||{},g=c.meta||l?.meta,y={view:c,meta:g,Component:l?.Component,Layouts:l?.Layouts,params:h};c.target==="_void"?i.push(y):s.push(y)}),n.current=t.views,{viewStack:s,voidViews:i}},[r,e])}const ne=p.createContext({viewId:"",isActive:!1,width:0,queryParams:{},setQueryParams:()=>{},setProps:()=>{},queryParam:()=>{},close:()=>{},state:{id:"",views:[]}});function oe({id:t,width:e,layout:n,children:r,params:o,queryParams:s,props:i}){const{state:c,close:u}=T(),[l,h]=p.useState(t===c.id),[g,y]=p.useState(i||{});return p.useEffect(()=>{h(t===c.id)},[c.id,t]),f.jsx(ne.Provider,{value:{viewId:t,isActive:l,width:e,params:o,queryParams:s,props:g,layout:n,state:c,setProps:(m,R)=>{const v=R?m||{}:{...i,...m};for(const E in v)v[E]===void 0&&delete v[E];y(v),ke(t,v)},setQueryParams:(m,R)=>{const v=R!==!0?{...i||{}}:{};let E=!1;for(const P in m){const I=m[P];typeof I<"u"?(v[P]=I,E=!0):Object.prototype.hasOwnProperty.call(v,P)&&(delete v[P],E=!0)}(E||R===!0)&&be(t,v)},queryParam:m=>i?.[m],close:()=>{u(t)}},children:r})}function Ce(t,e){const n=e.filter(o=>o.view.target!=="_void").map(o=>({id:o.view.id,breakpoints:o.meta?.breakpoints||[]})),r=Ae(t,n);return e.map(({view:o})=>({id:o.id,vw:r.find(s=>s.id===o.id)?.vw||0}))}function Ae(t,e){if(e.length===0)return[];const r=e.map(i=>({id:i.id,minVw:Le(i,t)})),o=r.reduce((i,c)=>i+c.minVw,0);if(o>=100)return r.map(i=>({id:i.id,vw:i.minVw}));const s=100-o;return r.map(i=>{const c=i.minVw/o,u=s*c;return{id:i.id,vw:Number((i.minVw+u).toFixed(0))}})}function Le(t,e){const r=[...t.breakpoints].sort((o,s)=>s.breakpoint-o.breakpoint).find(o=>e>=o.breakpoint);return r?r.minVw:100}function se({children:t}){return f.jsx(f.Fragment,{children:t})}const z=p.createContext({setSlot:()=>{},getSlots:()=>({})});function ae({children:t}){const[e,n]=p.useState({}),r=p.useCallback((s,i,c)=>{n(u=>({...u,[s]:{...u[s],[i]:c}}))},[]),o=p.useCallback(s=>e[s]||{},[e]);return f.jsx(z.Provider,{value:{setSlot:r,getSlots:o},children:t})}function Ne({viewUrl:t,error:e,errorCode:n,errorInfo:r,reset:o}){const{clientRouter:s}=T(),i=s?.getErrorComponentByPath(s?.getPathFromUrl(t)??"/");return i?f.jsx(i,{error:e,errorCode:n??0,errorInfo:r,reset:o}):f.jsxs("div",{style:{margin:"10px",border:"2px solid #ff6b6b",borderRadius:"8px",backgroundColor:"#fff5f5",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",padding:"20px"},children:[f.jsx("h1",{style:{color:"#c92a2a",marginBottom:"10px",fontWeight:"bold"},children:"Unhandled error"}),f.jsx("p",{style:{marginBottom:"15px",textAlign:"center"},children:e.message}),f.jsxs("details",{style:{marginBottom:"15px",width:"100%"},children:[f.jsx("summary",{style:{cursor:"pointer",marginBottom:"10px",textAlign:"center"},children:"Technical details"}),f.jsxs("div",{style:{backgroundColor:"#f8f9fa",padding:"10px",borderRadius:"4px",overflow:"auto",maxHeight:"200px"},children:[f.jsx("h4",{style:{margin:"0 0 10px 0",fontSize:"14px"},children:"Stack Trace:"}),f.jsx("pre",{style:{fontSize:"12px",margin:0,whiteSpace:"pre-wrap"},children:e.stack}),r?.componentStack&&f.jsxs(f.Fragment,{children:[f.jsx("h4",{style:{margin:"15px 0 10px 0",fontSize:"14px"},children:"Component Stack:"}),f.jsx("pre",{style:{fontSize:"12px",margin:0,whiteSpace:"pre-wrap"},children:r.componentStack})]})]})]}),f.jsx("button",{onClick:o,style:{backgroundColor:"#228be6",color:"white",border:"none",padding:"8px 16px",borderRadius:"4px",cursor:"pointer"},children:"Try again"})]})}class B extends p.Component{constructor(e){super(e),this.state={hasError:!!e.error,errorCode:e.errorCode,error:e.error}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error(`Error in view ${this.props.viewUrl}:`,e,n),this.setState({errorInfo:n})}reset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return!this.state.hasError||!this.state.error?this.props.children:f.jsx(Ne,{viewUrl:this.props.viewUrl,error:this.state.error,errorCode:this.state.errorCode,errorInfo:this.state.errorInfo,reset:this.reset})}}function We({className:t,style:e={}}){const{viewStack:n}=re(),[r,o]=p.useState(window.innerWidth);p.useEffect(()=>{const u=()=>o(window.innerWidth);return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]);const s=p.useMemo(()=>Ce(r,n),[r,n]),i=p.useMemo(()=>{let u=0,l=0;for(let h=n.length-1;h>=0;h--)if(u+=s[h]?.vw||0,u>100){l=h+1;break}return n.slice(l)},[s,n]),c=p.useMemo(()=>{const u=n.length-i.length;return i.map((l,h)=>s[h+u].vw)},[s,n.length,i]);return f.jsx(Ue,{views:i,widths:c,style:e,className:t})}function Ue({views:t,widths:e,className:n,style:r={}}){return f.jsx(ae,{children:f.jsx("div",{className:n,style:r,children:t.map(({view:o,params:s,Layouts:i,Component:c},u)=>{if(!c)return f.jsx(B,{viewUrl:o.url,errorCode:404,error:new Error("Not found")},o.id);const l=i?.length?i.filter(h=>h.key===o.layout):[{component:se}];return f.jsx(B,{viewUrl:o.url||"/",children:f.jsx(oe,{id:o.id,width:e[u],params:s,queryParams:o.queryParams,props:o.props,children:ie(l,c,s)},o.id)},o.id)})})})}function ie(t,e,n){if(t.length===0)return f.jsx(e,{...n||{}});const[r,...o]=t,s=r.component;return f.jsx(s,{children:ie(o,e,n)},r.key)}function Fe({className:t,style:e={}}){const{voidViews:n}=re();return f.jsx(Ie,{views:n,style:e,className:t})}function Ie({views:t,className:e,style:n={}}){return f.jsx(ae,{children:f.jsx("div",{className:e,style:n,children:t.map(({view:r,params:o,Layouts:s,Component:i})=>{const c=s?.length?s.filter(u=>u.key===r.layout):[{component:se}];return f.jsx(B,{viewUrl:r.url||"/",children:f.jsx(oe,{id:r.id,width:0,params:o,queryParams:r.queryParams,props:r.props,layout:r.layout,children:ce(c,i,o)},r.id)},r.id)})})})}function ce(t,e,n){if(t.length===0)return e?f.jsx(e,{...n||{}}):null;const[r,...o]=t,s=r.component;return f.jsx(s,{children:ce(o,e,n)},r.key)}function L(){const t=p.useContext(ne);if(t===void 0)throw new Error("useView must be used within a ViewProvider");return t}function Me({children:t,style:e={},className:n}){const{viewId:r}=L(),o=p.useRef(null);return p.useEffect(()=>{if(!o.current)return;const s=()=>{Re(r)},i=o.current;return W(i,"click",s),()=>U(i,"click",s)},[r,o]),f.jsx("div",{ref:o,style:e,className:n,children:t})}function De({href:t,query:e={},children:n,className:r,target:o="_self",onClick:s,props:i,layout:c}){const{navigate:u}=T(),{url:l,queryParams:h}=M(t,e),{viewId:g}=L(),y=R=>{s&&(s(R),R.isDefaultPrevented())||l.startsWith("https://")||l.startsWith("http://")||o==="_blank"||R.metaKey||R.ctrlKey||(R.preventDefault(),u(g,l,h,{append:R.shiftKey,target:o,props:i,layout:c}))},m=xe(l)?"noopener noreferrer":void 0;return f.jsx("a",{rel:m,href:l,onClick:y,className:r,target:o,children:n})}function Ye({slot:t}){const{viewId:e}=L(),{getSlots:n}=p.useContext(z),r=n(e);return f.jsx(f.Fragment,{children:r[t]})}function ze({slot:t,children:e}){const{viewId:n}=L(),{setSlot:r}=p.useContext(z);return p.useEffect(()=>(r(n,t,e),()=>r(n,t,null)),[n,t,e,r]),null}function Be(){const{navigate:t}=T();return(e,n)=>{const{state:r}=A(),{url:o,queryParams:s}=M(e);t(r.id||"",o,s,{append:!1,target:n?.target||"_self",props:n?.props,layout:n?.layout})}}function He(t){const{url:e}=M(t);return e}function Ge(t,e){const{state:n}=T();return p.useMemo(()=>{const o=[];return n.views.forEach(s=>{if(s.meta?.type===t){if(e){const i=s.params||{};if(!Object.entries(e).every(([u,l])=>i[u]===l))return}o.push({id:s.id,url:s.url,params:s.params,queryParams:s.queryParams,props:s.props,layout:s.layout,target:s.target,isActive:s.id===n.id})}}),o},[n.views,n.id,t,e])}function Je(t,e=""){const n=[],r={},o={};return Object.entries(t).forEach(([s,i])=>{let c=s.replace(e,"").replace(/\.tsx$/,"").replace(/\/index$/,"").replace(/([A-Z])/g,h=>`/${h.toLowerCase()}`).replace(/\/\//g,"/").toLowerCase()||"/";c===""||c==="index"?c="/":c&&!c.startsWith("/")&&(c="/"+c);const u=c.match(/^(.*)\/(_error)$/);if(u){const[,h]=u,g=h||"/";o[g]=i.default;return}const l=c.match(/^(.*)\/(_layout(?:\.([^/]+))?)$/);if(l){const[,h,,g]=l,y=h||"/";if(g){const m=`${y}#${g}`;r[m]=i.default}else r[y]=i.default}else c.includes("/_")||n.push({path:c,component:i.default,meta:i.default?.meta||{breakpoints:[]}})}),{routes:n,layouts:r,errors:o}}x.Fill=ze,x.Link=De,x.Outlet=Ye,x.RouterProvider=Oe,x.StackedView=Me,x.StackedViewGroup=We,x.VoidViews=Fe,x.mapRoutes=Je,x.useHref=He,x.useNavigate=Be,x.useOpenViews=Ge,x.useView=L,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})}));
|
|
22
|
+
<%s key={someKey} {...props} />`,b,S,O,S),me[S+b]=!0)}if(S=null,w!==void 0&&(n(w),S=""+w),c(d)&&(n(d.key),S=""+d.key),"key"in d){w={};for(var K in d)K!=="key"&&(w[K]=d[K])}else w=d;return S&&i(w,typeof a=="function"?a.displayName||a.name||"Unknown":a),l(a,S,k,j,o(),w,J,X)}function y(a){typeof a=="object"&&a!==null&&a.$$typeof===m&&a._store&&(a._store.validated=1)}var g=p,m=Symbol.for("react.transitional.element"),R=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),Xe=Symbol.for("react.context"),Ke=Symbol.for("react.forward_ref"),Qe=Symbol.for("react.suspense"),Ze=Symbol.for("react.suspense_list"),qe=Symbol.for("react.memo"),ue=Symbol.for("react.lazy"),$e=Symbol.for("react.activity"),et=Symbol.for("react.client.reference"),H=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le=Object.prototype.hasOwnProperty,tt=Array.isArray,G=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(a){return a()}};var fe,de={},pe=g.react_stack_bottom_frame.bind(g,s)(),he=G(r(s)),me={};C.Fragment=v,C.jsx=function(a,d,w,b,j){var k=1e4>H.recentlyCreatedOwnerStacks++;return h(a,d,w,!1,b,j,k?Error("react-stack-top-frame"):pe,k?G(r(a)):he)},C.jsxs=function(a,d,w,b,j){var k=1e4>H.recentlyCreatedOwnerStacks++;return h(a,d,w,!0,b,j,k?Error("react-stack-top-frame"):pe,k?G(r(a)):he)}})()),C}var q;function ge(){return q||(q=1,process.env.NODE_ENV==="production"?N.exports=we():N.exports=ye()),N.exports}var f=ge();const $=p.createContext({trigger:"init",state:{id:"",views:[]},navigate:()=>{},close:()=>{}});function W(t,...e){t&&t.addEventListener&&t.addEventListener(...e)}function U(t,...e){t&&t.removeEventListener&&t.removeEventListener(...e)}function ee(t,e){window.dispatchEvent(new CustomEvent(t,{detail:e}))}function I(t="",e={}){const n=new URL(t,"http://dummy.base"),r={...Object.fromEntries(n.searchParams.entries()),...e},o=new URLSearchParams(Object.entries(r).map(([u,l])=>[u,String(l)])).toString(),c=t.startsWith("http://")||t.startsWith("https://")?n.origin+n.pathname:n.pathname,i=c.endsWith("/")&&c.length>1?c.slice(0,-1):c;return{url:o?`${i}?${o}`:i,path:n.pathname,queryParams:r}}function ve(t){const e={};for(const[n,r]of new URLSearchParams(t))r==="true"?e[n]=!0:r==="false"?e[n]=!1:Ee(r)?e[n]=r.includes(".")?parseFloat(r):parseInt(r,10):e[n]=r;return e}function Ee(t){return isNaN(+t)?!1:parseInt(t).toString()===t||parseFloat(t).toString()===t}const xe=t=>{try{return new URL(t,window.location.origin).origin!==window.location.origin}catch{return!1}};function A(){const{state:t,length:e}=window.history,{href:n}=window.location;return{state:_e(t)?t:be(n),length:e}}function D(t,e){history.pushState(e,"",t),ee("pushstate",e)}function _(t,e){history.replaceState(e,"",t),ee("replacestate",e)}function Re(t){const{id:e,views:n}=A().state;if(e===t)return;const r=n.find(o=>o.id===t);r&&_(r.url,{id:r.id,views:n})}function be(t){const e=crypto.randomUUID(),n=new URL(t),r={id:e,views:[{id:e,url:t,queryParams:ve(n.search),props:{}}]};return _(t,r),r}function Se(t,e){const{state:n}=A(),r={...n};let o=-1;for(let s=0;s<r.views.length;s++)if(r.views[s].id===t){te(r.views[s].queryParams,e)||(r.views[s].queryParams=e,o=s);break}if(o>-1){const s=new URL(window.location.href);s.search=new URLSearchParams(Object.entries(e).map(([c,i])=>[c,String(i)])).toString(),r.views[o].url=s.toString(),_(s.toString(),r)}}function ke(t,e){const{state:n}=A(),r={...n};let o=-1;for(let s=0;s<r.views.length;s++)if(r.views[s].id===t){te(r.views[s].props,e)||(r.views[s].props=e,o=s);break}o>-1&&_(window.location.href,r)}function Pe(t,e){const n=[...e.views].filter(o=>o.id!==t),r={...e,views:n};_(n.at(-1)?.url??"",r)}function je(t,e,n,r,o,s){const c=[...o.views],i=crypto.randomUUID(),u=t.getFullPath(n),l=new URL(u,window.location.origin);Object.entries(r).forEach(([E,P])=>{l.searchParams.set(E,String(P))});const h=l.toString(),y=t.getViewComponentByPath(l.pathname),g=y?.params||{},m=c.find(E=>h===E.url);if(s.target!=="_top"&&!s.append&&m?.id===o.id)return;if(!s.append){if(s.target==="_top"){const E=m||{id:i,url:h,meta:y?.meta??void 0,params:g,queryParams:r,props:s.props,target:s?.target,layout:s?.layout};D(h,{id:E.id,views:[E]});return}if(!s.append&&m){_(h,{id:m.id,views:c});return}}if(s.append||s.target==="_void"){c.push({id:i,url:h,meta:y?.meta??void 0,params:g,queryParams:r,props:s.props,target:s?.target,layout:s?.layout}),D(h,{id:i,views:c});return}const R=c.findIndex(E=>E.id===e),v=c.slice(0,R+1);v.push({id:i,url:h,meta:y?.meta??void 0,params:g,queryParams:r,props:s.props,target:s?.target,layout:s?.layout}),D(h,{id:i,views:v})}function _e(t){return!t||typeof t!="object"?!1:"id"in t&&"views"in t&&Array.isArray(t.views)}function te(t,e){if(typeof t!=typeof e)return!1;if(typeof t>"u"||typeof e>"u")return!0;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(!(n in e)||t[n]!==e[n]||typeof t[n]!=typeof e[n])return!1;return!0}class Te{#e="/";#r={};#o={};#t={};constructor(e,n){this.#e=n?this.#s(n):"/",this.#o=e.layouts||{},this.#t=e.errors||{},this.registerRoutes(e.routes)}registerRoutes(e,n=!1){e.forEach(r=>{const o=[],s=r.path.replace(/\[([^\]]+)\]/g,(i,u)=>(o.push(u),"([^/]+)")),c=new RegExp(`^${s}$`);if(!r.component||!(r.component instanceof Function)||r.path[0]!=="/"){if(n)throw new Error(`Invalid component for route ${r.path||"undefined path"}`);return}this.#r[r.path]={component:r.component,pattern:c,paramKeys:o,originalPath:r.path,layouts:r.layouts?.length?r.layouts.map(i=>({component:i})):this.#a(r.path),meta:r.meta||{breakpoints:[]}}})}#s(e){return e.startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}#n(e){return this.#e==="/"?e:e.startsWith(this.#e)?e.slice(this.#e.length)||"/":e}getViewComponentByPath(e){const n=this.#n(e),r=n.length>1&&n.at(-1)==="/"?n.substring(0,n.length-1):n;for(const o in this.#r){const s=this.#r[o],c=r.match(s.pattern);if(c){const i=Object.fromEntries(s.paramKeys.map((u,l)=>[u,c[l+1]]));return{Component:s.component,Layouts:s.layouts,params:i,meta:s.meta}}}return null}getErrorComponentByPath(e){const n=this.#n(e),r=n.length>1&&n.at(-1)==="/"?n.substring(0,n.length-1):n;if(this.#t[r])return this.#t[r];const o=r.split("/").filter(Boolean);for(let s=o.length;s>=1;s--){const c="/"+o.slice(0,s).join("/");if(this.#t[c])return this.#t[c]}return this.#t["/"]?this.#t["/"]:(console.log("No error component found"),null)}get basePath(){return this.#e}getFullPath(e){return this.#e==="/"?e:e==="/"?this.#e:e.startsWith(this.#e)?e:this.#e+e}getPathFromUrl(e){try{let r=new URL(e).pathname;return r=this.#n(r),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),r}catch{return this.#n(e)}}getAllViewComponents(){return Object.values(this.#r).map(e=>({Component:e.component,Layouts:e.layouts,meta:e.meta}))}#a(e){const n=[],r=["/",...e.match(/[^/]+/g)||[]];let o=r[0];for(let s=0;s<r.length;s++){const c=[];for(const i in this.#o){const[u,l]=i.split("#");u===o&&c.push({key:l,component:this.#o[i]})}n.push(...c),o+=r[s+1]}return n}}function Oe({basePath:t,config:e,external:n=[],children:r}){const o=p.useMemo(()=>new Te(e,t),[e,t]),[s,c]=p.useState(F("load",o));return p.useEffect(()=>{for(const i of n??[])import(i.url).then(u=>{if(!Array.isArray(u.routes))throw new Error(`Invalid routes in ${i.url}`);o.registerRoutes(u.routes,!0)}).catch(u=>{console.error(u.message)})},[n,o]),p.useEffect(()=>{t&&t!=="/"&&window.location.pathname==="/"&&window.history.replaceState(null,"",t)},[t]),p.useEffect(()=>{const i=()=>c(F("popstate",o)),u=()=>c(F("pushstate",o)),l=()=>c(F("replacestate",o));return W(window,"popstate",i),W(window,"pushstate",u),W(window,"replacestate",l),()=>{U(window,"popstate",i),U(window,"pushstate",u),U(window,"replacestate",l)}},[o]),f.jsx($.Provider,{value:{clientRouter:o,...s},children:r})}function F(t,e){const{state:n,length:r}=A(),{hash:o,host:s,hostname:c,href:i,origin:u,pathname:l,port:h,protocol:y,search:g}=window.location;return{trigger:t,state:n,length:r,hash:o,host:s,hostname:c,href:i,origin:u,pathname:l,port:h,protocol:y,search:g,navigate:(m,R,v,E)=>{je(e,m,R,v,n,E)},close:m=>{Pe(m,n)}}}function T(){const t=p.useContext($);if(t===void 0)throw new Error("useRouter must be used within a RouterProvider");return t}function Ve(t,e){if(!t||!e)return t===e;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){const r=t[n],o=e[n];if(r.id!==o.id||r.url!==o.url||r.layout!==o.layout||r.target!==o.target||!Y(r.params,o.params)||!Y(r.queryParams,o.queryParams)||!Y(r.props,o.props)||r.meta!==o.meta&&(!r.meta||!o.meta||r.meta.type!==o.meta.type))return!1}return!0}function Y(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const o of n)if(t[o]!==e[o])return!1;return!0}function re(){const{state:t,clientRouter:e}=T()||{},n=p.useRef(void 0),r=!Ve(n.current,t.views);return p.useMemo(()=>{const s=[],c=[];return t.views.forEach(i=>{const u=new URL(i.url,"http://dummy.base"),l=e?.getViewComponentByPath(u.pathname),h=i.params||l?.params||{},y=i.meta||l?.meta,g={view:i,meta:y,Component:l?.Component,Layouts:l?.Layouts,params:h};i.target==="_void"?c.push(g):s.push(g)}),n.current=t.views,{viewStack:s,voidViews:c}},[r,e])}const ne=p.createContext({viewId:"",isActive:!1,vw:0,queryParams:{},setQueryParams:()=>{},setProps:()=>{},queryParam:()=>{},close:()=>{},state:{id:"",views:[]}});function oe({id:t,vw:e,layout:n,children:r,params:o,queryParams:s,props:c}){const{state:i,close:u}=T(),[l,h]=p.useState(t===i.id),[y,g]=p.useState(c||{});return p.useEffect(()=>{h(t===i.id)},[i.id,t]),f.jsx(ne.Provider,{value:{viewId:t,isActive:l,vw:e,params:o,queryParams:s,props:y,layout:n,state:i,setProps:(m,R)=>{const v=R?m||{}:{...c,...m};for(const E in v)v[E]===void 0&&delete v[E];g(v),ke(t,v)},setQueryParams:(m,R)=>{const v=R!==!0?{...c||{}}:{};let E=!1;for(const P in m){const M=m[P];typeof M<"u"?(v[P]=M,E=!0):Object.prototype.hasOwnProperty.call(v,P)&&(delete v[P],E=!0)}(E||R===!0)&&Se(t,v)},queryParam:m=>c?.[m],close:()=>{u(t)}},children:r})}function Ce(t,e){const n=e.filter(o=>o.view.target!=="_void").map(o=>({id:o.view.id,breakpoints:o.meta?.breakpoints||[]})),r=Ae(t,n);return e.map(({view:o})=>({id:o.id,vw:r.find(s=>s.id===o.id)?.vw||0}))}function Ae(t,e){if(e.length===0)return[];const r=e.map(c=>({id:c.id,minVw:Le(c,t)})),o=r.reduce((c,i)=>c+i.minVw,0);if(o>=100)return r.map(c=>({id:c.id,vw:c.minVw}));const s=100-o;return r.map(c=>{const i=c.minVw/o,u=s*i;return{id:c.id,vw:Number((c.minVw+u).toFixed(0))}})}function Le(t,e){const r=[...t.breakpoints].sort((o,s)=>s.breakpoint-o.breakpoint).find(o=>e>=o.breakpoint);return r?r.minVw:100}function se({children:t}){return f.jsx(f.Fragment,{children:t})}const z=p.createContext({setSlot:()=>{},getSlots:()=>({})});function ae({children:t}){const[e,n]=p.useState({}),r=p.useCallback((s,c,i)=>{n(u=>({...u,[s]:{...u[s],[c]:i}}))},[]),o=p.useCallback(s=>e[s]||{},[e]);return f.jsx(z.Provider,{value:{setSlot:r,getSlots:o},children:t})}function Ne({viewUrl:t,error:e,errorCode:n,errorInfo:r,reset:o}){const{clientRouter:s}=T(),c=s?.getErrorComponentByPath(s?.getPathFromUrl(t)??"/");return c?f.jsx(c,{error:e,errorCode:n??0,errorInfo:r,reset:o}):f.jsxs("div",{style:{margin:"10px",border:"2px solid #ff6b6b",borderRadius:"8px",backgroundColor:"#fff5f5",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",padding:"20px"},children:[f.jsx("h1",{style:{color:"#c92a2a",marginBottom:"10px",fontWeight:"bold"},children:"Unhandled error"}),f.jsx("p",{style:{marginBottom:"15px",textAlign:"center"},children:e.message}),f.jsxs("details",{style:{marginBottom:"15px",width:"100%"},children:[f.jsx("summary",{style:{cursor:"pointer",marginBottom:"10px",textAlign:"center"},children:"Technical details"}),f.jsxs("div",{style:{backgroundColor:"#f8f9fa",padding:"10px",borderRadius:"4px",overflow:"auto",maxHeight:"200px"},children:[f.jsx("h4",{style:{margin:"0 0 10px 0",fontSize:"14px"},children:"Stack Trace:"}),f.jsx("pre",{style:{fontSize:"12px",margin:0,whiteSpace:"pre-wrap"},children:e.stack}),r?.componentStack&&f.jsxs(f.Fragment,{children:[f.jsx("h4",{style:{margin:"15px 0 10px 0",fontSize:"14px"},children:"Component Stack:"}),f.jsx("pre",{style:{fontSize:"12px",margin:0,whiteSpace:"pre-wrap"},children:r.componentStack})]})]})]}),f.jsx("button",{onClick:o,style:{backgroundColor:"#228be6",color:"white",border:"none",padding:"8px 16px",borderRadius:"4px",cursor:"pointer"},children:"Try again"})]})}class B extends p.Component{constructor(e){super(e),this.state={hasError:!!e.error,errorCode:e.errorCode,error:e.error}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error(`Error in view ${this.props.viewUrl}:`,e,n),this.setState({errorInfo:n})}reset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return!this.state.hasError||!this.state.error?this.props.children:f.jsx(Ne,{viewUrl:this.props.viewUrl,error:this.state.error,errorCode:this.state.errorCode,errorInfo:this.state.errorInfo,reset:this.reset})}}function We({className:t,style:e={}}){const{viewStack:n}=re(),[r,o]=p.useState(window.innerWidth);p.useEffect(()=>{const u=()=>o(window.innerWidth);return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]);const s=p.useMemo(()=>Ce(r,n),[r,n]),c=p.useMemo(()=>{let u=0,l=0;for(let h=n.length-1;h>=0;h--)if(u+=s[h]?.vw||0,u>100){l=h+1;break}return n.slice(l)},[s,n]),i=p.useMemo(()=>{const u=n.length-c.length;return c.map((l,h)=>s[h+u].vw)},[s,n.length,c]);return f.jsx(Ue,{views:c,widths:i,style:e,className:t})}function Ue({views:t,widths:e,className:n,style:r={}}){return f.jsx(ae,{children:f.jsx("div",{className:n,style:r,children:t.map(({view:o,params:s,Layouts:c,Component:i},u)=>{if(!i)return f.jsx(B,{viewUrl:o.url,errorCode:404,error:new Error("Not found")},o.id);const l=c?.length?c.filter(h=>h.key===o.layout):[{component:se}];return f.jsx(B,{viewUrl:o.url||"/",children:f.jsx(oe,{id:o.id,vw:e[u],params:s,queryParams:o.queryParams,props:o.props,children:ie(l,i,s)},o.id)},o.id)})})})}function ie(t,e,n){if(t.length===0)return f.jsx(e,{...n||{}});const[r,...o]=t,s=r.component;return f.jsx(s,{children:ie(o,e,n)},r.key)}function Fe({className:t,style:e={}}){const{voidViews:n}=re();return f.jsx(Me,{views:n,style:e,className:t})}function Me({views:t,className:e,style:n={}}){return f.jsx(ae,{children:f.jsx("div",{className:e,style:n,children:t.map(({view:r,params:o,Layouts:s,Component:c})=>{const i=s?.length?s.filter(u=>u.key===r.layout):[{component:se}];return f.jsx(B,{viewUrl:r.url||"/",children:f.jsx(oe,{id:r.id,vw:0,params:o,queryParams:r.queryParams,props:r.props,layout:r.layout,children:ce(i,c,o)},r.id)},r.id)})})})}function ce(t,e,n){if(t.length===0)return e?f.jsx(e,{...n||{}}):null;const[r,...o]=t,s=r.component;return f.jsx(s,{children:ce(o,e,n)},r.key)}function L(){const t=p.useContext(ne);if(t===void 0)throw new Error("useView must be used within a ViewProvider");return t}function Ie({children:t,style:e={},className:n}){const{viewId:r}=L(),o=p.useRef(null),s=p.useMemo(()=>{const i={...e};return i.containerType||(i.containerType="size"),i.containerName||(i.containerName="view"),i},[e]),c=p.useMemo(()=>{let i=n??"";return i.includes("@container")||(i+=" @container/view"),i},[n]);return p.useEffect(()=>{if(!o.current)return;const i=()=>{Re(r)},u=o.current;return W(u,"click",i),()=>U(u,"click",i)},[r,o]),f.jsx("div",{ref:o,style:s,className:c,children:t})}function De({href:t,query:e={},children:n,className:r,target:o="_self",onClick:s,props:c,layout:i}){const{navigate:u}=T(),{url:l,queryParams:h}=I(t,e),{viewId:y}=L(),g=R=>{s&&(s(R),R.isDefaultPrevented())||l.startsWith("https://")||l.startsWith("http://")||o==="_blank"||R.metaKey||R.ctrlKey||(R.preventDefault(),u(y,l,h,{append:R.shiftKey,target:o,props:c,layout:i}))},m=xe(l)?"noopener noreferrer":void 0;return f.jsx("a",{rel:m,href:l,onClick:g,className:r,target:o,children:n})}function Ye({slot:t}){const{viewId:e}=L(),{getSlots:n}=p.useContext(z),r=n(e);return f.jsx(f.Fragment,{children:r[t]})}function ze({slot:t,children:e}){const{viewId:n}=L(),{setSlot:r}=p.useContext(z);return p.useEffect(()=>(r(n,t,e),()=>r(n,t,null)),[n,t,e,r]),null}function Be(){const{navigate:t}=T();return(e,n)=>{const{state:r}=A(),{url:o,queryParams:s}=I(e);t(r.id||"",o,s,{append:!1,target:n?.target||"_self",props:n?.props,layout:n?.layout})}}function He(t){const{url:e}=I(t);return e}function Ge(t,e){const{state:n}=T();return p.useMemo(()=>{const o=[];return n.views.forEach(s=>{if(s.meta?.type===t){if(e){const c=s.params||{};if(!Object.entries(e).every(([u,l])=>c[u]===l))return}o.push({id:s.id,url:s.url,params:s.params,queryParams:s.queryParams,props:s.props,layout:s.layout,target:s.target,isActive:s.id===n.id})}}),o},[n.views,n.id,t,e])}function Je(t,e=""){const n=[],r={},o={};return Object.entries(t).forEach(([s,c])=>{let i=s.replace(e,"").replace(/\.tsx$/,"").replace(/\/index$/,"").replace(/([A-Z])/g,h=>`/${h.toLowerCase()}`).replace(/\/\//g,"/").toLowerCase()||"/";i===""||i==="index"?i="/":i&&!i.startsWith("/")&&(i="/"+i);const u=i.match(/^(.*)\/(_error)$/);if(u){const[,h]=u,y=h||"/";o[y]=c.default;return}const l=i.match(/^(.*)\/(_layout(?:\.([^/]+))?)$/);if(l){const[,h,,y]=l,g=h||"/";if(y){const m=`${g}#${y}`;r[m]=c.default}else r[g]=c.default}else i.includes("/_")||n.push({path:i,component:c.default,meta:c.default?.meta||{breakpoints:[]}})}),{routes:n,layouts:r,errors:o}}x.Fill=ze,x.Link=De,x.Outlet=Ye,x.RouterProvider=Oe,x.StackedView=Ie,x.StackedViewGroup=We,x.VoidViews=Fe,x.mapRoutes=Je,x.useHref=He,x.useNavigate=Be,x.useOpenViews=Ge,x.useView=L,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})}));
|