@herdingbits/trailhead-cloudscape 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shell-app.d.ts.map +1 -1
- package/dist/shell-app.js +3 -4
- package/dist/shell-layout.d.ts +2 -7
- package/dist/shell-layout.d.ts.map +1 -1
- package/dist/shell-layout.js +21 -3
- package/package.json +3 -3
package/dist/shell-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-app.d.ts","sourceRoot":"","sources":["../src/shell-app.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"shell-app.d.ts","sourceRoot":"","sources":["../src/shell-app.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAW,MAAM,6BAA6B,CAAC;AAEtE,UAAU,aAAa;IACrB,KAAK,EAAE,SAAS,CAAC;CAClB;AAiBD,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,aAAa,2CAkNhD"}
|
package/dist/shell-app.js
CHANGED
|
@@ -70,11 +70,10 @@ export function ShellApp({ shell }) {
|
|
|
70
70
|
}
|
|
71
71
|
}, [navigation, currentPath]);
|
|
72
72
|
const handleRoute = (path) => {
|
|
73
|
-
// Normalize path by removing trailing slash for matching
|
|
74
73
|
const normalizedPath = path.endsWith('/') && path !== '/' ? path.slice(0, -1) : path;
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
loadApp(
|
|
74
|
+
const app = shell.getApps().find(entry => normalizedPath.startsWith(entry.basePath));
|
|
75
|
+
if (app && contentRef.current) {
|
|
76
|
+
loadApp(app.src, app.basePath);
|
|
78
77
|
}
|
|
79
78
|
};
|
|
80
79
|
const loadApp = async (appName, appPath) => {
|
package/dist/shell-layout.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
id: string;
|
|
4
|
-
label: string;
|
|
5
|
-
path: string;
|
|
6
|
-
icon?: string;
|
|
7
|
-
}
|
|
2
|
+
import type { NavItem } from '@herdingbits/trailhead-core';
|
|
8
3
|
interface ShellLayoutProps {
|
|
9
|
-
navigation:
|
|
4
|
+
navigation: NavItem[];
|
|
10
5
|
currentPath: string;
|
|
11
6
|
basePath: string;
|
|
12
7
|
onNavigate: (path: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-layout.d.ts","sourceRoot":"","sources":["../src/shell-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"shell-layout.d.ts","sourceRoot":"","sources":["../src/shell-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,6BAA6B,CAAC;AAEpE,UAAU,gBAAgB;IACxB,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,WAAW,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CA+CxG"}
|
package/dist/shell-layout.js
CHANGED
|
@@ -4,11 +4,29 @@ import AppLayout from '@cloudscape-design/components/app-layout';
|
|
|
4
4
|
import SideNavigation from '@cloudscape-design/components/side-navigation';
|
|
5
5
|
export function ShellLayout({ navigation, currentPath, basePath, onNavigate, children }) {
|
|
6
6
|
const [navigationOpen, setNavigationOpen] = useState(true);
|
|
7
|
-
const
|
|
7
|
+
const isExternal = (href) => /^https?:\/\/|^\/\//.test(href);
|
|
8
|
+
const resolveHref = (href) => isExternal(href) ? href : basePath + href + '/';
|
|
9
|
+
const mapLink = (item) => ({
|
|
8
10
|
type: 'link',
|
|
9
11
|
text: item.label,
|
|
10
|
-
href:
|
|
11
|
-
})
|
|
12
|
+
href: resolveHref(item.href),
|
|
13
|
+
});
|
|
14
|
+
const navItems = [...navigation]
|
|
15
|
+
.sort((a, b) => a.order - b.order)
|
|
16
|
+
.map((item) => {
|
|
17
|
+
switch (item.type) {
|
|
18
|
+
case 'link':
|
|
19
|
+
return mapLink(item);
|
|
20
|
+
case 'section':
|
|
21
|
+
return {
|
|
22
|
+
type: 'section',
|
|
23
|
+
text: item.label,
|
|
24
|
+
items: [...item.children].sort((a, b) => a.order - b.order).map(mapLink),
|
|
25
|
+
};
|
|
26
|
+
case 'divider':
|
|
27
|
+
return { type: 'divider' };
|
|
28
|
+
}
|
|
29
|
+
});
|
|
12
30
|
return (_jsx(AppLayout, { navigationOpen: navigationOpen, onNavigationChange: ({ detail }) => setNavigationOpen(detail.open), navigation: _jsx(SideNavigation, { activeHref: basePath + currentPath + (currentPath.endsWith('/') ? '' : '/'), items: navItems, onFollow: (event) => {
|
|
13
31
|
event.preventDefault();
|
|
14
32
|
onNavigate(event.detail.href);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herdingbits/trailhead-cloudscape",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "AWS CloudScape adapter for Trailhead. React-based shell with CloudScape components. Supports React 19.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@cloudscape-design/components": "^3.0.0",
|
|
25
25
|
"@cloudscape-design/global-styles": "^1.0.0",
|
|
26
|
-
"@herdingbits/trailhead-core": "^0.0.
|
|
26
|
+
"@herdingbits/trailhead-core": "^0.0.17",
|
|
27
27
|
"react": "^19.0.0",
|
|
28
28
|
"react-dom": "^19.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@cloudscape-design/components": "^3.0.1297",
|
|
32
32
|
"@cloudscape-design/global-styles": "^1.0.59",
|
|
33
|
-
"@herdingbits/trailhead-types": "^0.0.
|
|
33
|
+
"@herdingbits/trailhead-types": "^0.0.14",
|
|
34
34
|
"@types/react": "^19.2.14",
|
|
35
35
|
"@types/react-dom": "^19.2.3",
|
|
36
36
|
"react": "^19.2.6",
|