@genesislcap/foundation-react-utils 14.489.1-alpha-2e2874541.0 → 14.489.1-alpha-0babe6c0f.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,6 +15,12 @@ export interface AppRouteConfig {
|
|
|
15
15
|
noLayout?: boolean;
|
|
16
16
|
/** Permission code handed to the guard's optional permission check. */
|
|
17
17
|
permissionCode?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Nested child routes rendered inside this route's `element` (which must
|
|
20
|
+
* render an `<Outlet />`). Children use paths relative to this route and
|
|
21
|
+
* inherit its guard — they are rendered as plain routes, not re-guarded.
|
|
22
|
+
*/
|
|
23
|
+
children?: AppRouteConfig[];
|
|
18
24
|
/** Arbitrary metadata preserved for other consumers (nav items, PBC info, ...). */
|
|
19
25
|
data?: Record<string, any>;
|
|
20
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-routes.d.ts","sourceRoot":"","sources":["../../../src/router/app-routes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,SAAS,CAAC;IACnB,wEAAwE;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM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5B;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,6DAA6D;IAC7D,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB;;;OAGG;IACH,cAAc,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;IACxD;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,wDAAwD;IACxD,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,OAAO,EAAE,SAAS,CAAA;KAAE,CAAC;CAC3E;AAKD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,cAAc,EACd,MAAM,EACN,SAAc,EACd,QAAQ,EACR,eAAe,GAChB,EAAE,sBAAsB,GAAG,YAAY,CA6DvC"}
|
|
@@ -17,6 +17,16 @@ export function renderAppRoutes({ routes, ProtectedRoute, layout, redirects = []
|
|
|
17
17
|
const guarded = routes.filter((r) => !r.public);
|
|
18
18
|
const inLayout = guarded.filter((r) => !r.noLayout);
|
|
19
19
|
const topLevelGuarded = guarded.filter((r) => r.noLayout);
|
|
20
|
-
|
|
20
|
+
// Nested children render as plain relative routes inside the parent's
|
|
21
|
+
// `<Outlet />`; they inherit the parent's guard, so they are not re-wrapped.
|
|
22
|
+
const renderChild = (c) => {
|
|
23
|
+
var _a;
|
|
24
|
+
return ((_a = c.children) === null || _a === void 0 ? void 0 : _a.length) ? (_jsx(Route, { path: c.path, element: c.element, children: c.children.map(renderChild) }, c.path)) : (_jsx(Route, { path: c.path, element: c.element }, c.path));
|
|
25
|
+
};
|
|
26
|
+
const renderGuarded = (r) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const element = (_jsx(ProtectedRoute, { permissionCode: resolvePermissionCode(r), children: r.element }));
|
|
29
|
+
return ((_a = r.children) === null || _a === void 0 ? void 0 : _a.length) ? (_jsx(Route, { path: r.path, element: element, children: r.children.map(renderChild) }, r.path)) : (_jsx(Route, { path: r.path, element: element }, r.path));
|
|
30
|
+
};
|
|
21
31
|
return (_jsxs(Routes, { children: [redirects.map((r) => (_jsx(Route, { path: r.from, element: _jsx(Navigate, { to: r.to, replace: true }) }, `redirect:${r.from}`))), publicRoutes.map((r) => (_jsx(Route, { path: r.path, element: r.element }, r.path))), topLevelGuarded.map(renderGuarded), layout ? (_jsx(Route, { element: layout, children: inLayout.map(renderGuarded) })) : (inLayout.map(renderGuarded)), notFound ? _jsx(Route, { path: "*", element: notFound }) : null] }));
|
|
22
32
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-react-utils",
|
|
3
3
|
"description": "Genesis Foundation React Utils",
|
|
4
|
-
"version": "14.489.1-alpha-
|
|
4
|
+
"version": "14.489.1-alpha-0babe6c0f.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@genesislcap/foundation-testing": "14.489.1-alpha-
|
|
51
|
-
"@genesislcap/genx": "14.489.1-alpha-
|
|
52
|
-
"@genesislcap/rollup-builder": "14.489.1-alpha-
|
|
53
|
-
"@genesislcap/ts-builder": "14.489.1-alpha-
|
|
54
|
-
"@genesislcap/uvu-playwright-builder": "14.489.1-alpha-
|
|
55
|
-
"@genesislcap/vite-builder": "14.489.1-alpha-
|
|
56
|
-
"@genesislcap/webpack-builder": "14.489.1-alpha-
|
|
50
|
+
"@genesislcap/foundation-testing": "14.489.1-alpha-0babe6c0f.0",
|
|
51
|
+
"@genesislcap/genx": "14.489.1-alpha-0babe6c0f.0",
|
|
52
|
+
"@genesislcap/rollup-builder": "14.489.1-alpha-0babe6c0f.0",
|
|
53
|
+
"@genesislcap/ts-builder": "14.489.1-alpha-0babe6c0f.0",
|
|
54
|
+
"@genesislcap/uvu-playwright-builder": "14.489.1-alpha-0babe6c0f.0",
|
|
55
|
+
"@genesislcap/vite-builder": "14.489.1-alpha-0babe6c0f.0",
|
|
56
|
+
"@genesislcap/webpack-builder": "14.489.1-alpha-0babe6c0f.0",
|
|
57
57
|
"react-router-dom": "^7.1.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@genesislcap/foundation-forms": "14.489.1-alpha-
|
|
71
|
-
"@genesislcap/foundation-layout": "14.489.1-alpha-
|
|
72
|
-
"@genesislcap/foundation-logger": "14.489.1-alpha-
|
|
73
|
-
"@genesislcap/web-core": "14.489.1-alpha-
|
|
70
|
+
"@genesislcap/foundation-forms": "14.489.1-alpha-0babe6c0f.0",
|
|
71
|
+
"@genesislcap/foundation-layout": "14.489.1-alpha-0babe6c0f.0",
|
|
72
|
+
"@genesislcap/foundation-logger": "14.489.1-alpha-0babe6c0f.0",
|
|
73
|
+
"@genesislcap/web-core": "14.489.1-alpha-0babe6c0f.0",
|
|
74
74
|
"@jsonforms/core": "^3.2.1",
|
|
75
75
|
"@r2wc/react-to-web-component": "^2.0.2"
|
|
76
76
|
},
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
85
|
"customElements": "dist/custom-elements.json",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "ac776b63e71183eeccae92de893cb77797e751c1"
|
|
87
87
|
}
|
|
@@ -17,6 +17,12 @@ export interface AppRouteConfig {
|
|
|
17
17
|
noLayout?: boolean;
|
|
18
18
|
/** Permission code handed to the guard's optional permission check. */
|
|
19
19
|
permissionCode?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Nested child routes rendered inside this route's `element` (which must
|
|
22
|
+
* render an `<Outlet />`). Children use paths relative to this route and
|
|
23
|
+
* inherit its guard — they are rendered as plain routes, not re-guarded.
|
|
24
|
+
*/
|
|
25
|
+
children?: AppRouteConfig[];
|
|
20
26
|
/** Arbitrary metadata preserved for other consumers (nav items, PBC info, ...). */
|
|
21
27
|
data?: Record<string, any>;
|
|
22
28
|
}
|
|
@@ -91,15 +97,29 @@ export function renderAppRoutes({
|
|
|
91
97
|
const inLayout = guarded.filter((r) => !r.noLayout);
|
|
92
98
|
const topLevelGuarded = guarded.filter((r) => r.noLayout);
|
|
93
99
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
element={
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
// Nested children render as plain relative routes inside the parent's
|
|
101
|
+
// `<Outlet />`; they inherit the parent's guard, so they are not re-wrapped.
|
|
102
|
+
const renderChild = (c: AppRouteConfig): ReactElement =>
|
|
103
|
+
c.children?.length ? (
|
|
104
|
+
<Route key={c.path} path={c.path} element={c.element}>
|
|
105
|
+
{c.children.map(renderChild)}
|
|
106
|
+
</Route>
|
|
107
|
+
) : (
|
|
108
|
+
<Route key={c.path} path={c.path} element={c.element} />
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const renderGuarded = (r: AppRouteConfig) => {
|
|
112
|
+
const element = (
|
|
113
|
+
<ProtectedRoute permissionCode={resolvePermissionCode(r)}>{r.element}</ProtectedRoute>
|
|
114
|
+
);
|
|
115
|
+
return r.children?.length ? (
|
|
116
|
+
<Route key={r.path} path={r.path} element={element}>
|
|
117
|
+
{r.children.map(renderChild)}
|
|
118
|
+
</Route>
|
|
119
|
+
) : (
|
|
120
|
+
<Route key={r.path} path={r.path} element={element} />
|
|
121
|
+
);
|
|
122
|
+
};
|
|
103
123
|
|
|
104
124
|
return (
|
|
105
125
|
<Routes>
|