@jskit-ai/shell-web 0.2.10 → 0.2.11
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/CHANGELOG.md +9 -0
- package/fixtures/adaptive-shell/src/App.vue +2 -0
- package/fixtures/adaptive-shell/src/RecordListPage.vue +22 -0
- package/fixtures/adaptive-shell/src/RecordPage.vue +30 -0
- package/fixtures/adaptive-shell/src/ScreenPage.vue +7 -3
- package/fixtures/adaptive-shell/src/SettingsPage.vue +24 -0
- package/fixtures/adaptive-shell/src/main.js +60 -55
- package/fixtures/adaptive-shell/src/records.js +13 -0
- package/fixtures/adaptive-shell/src/theme/index.js +3 -0
- package/locales/en.json +1 -0
- package/package.json +17 -5
- package/patterns/application-shell/PATTERN.md +3 -1
- package/patterns/application-shell/example/expected-existing/src/pages/home/index.vue +5 -18
- package/patterns/application-shell/example/expected-existing/src/views/NotFound.vue +14 -0
- package/patterns/application-shell/example/src/pages/home/index.vue +21 -57
- package/patterns/application-shell/example/src/pages/home/settings/general/index.vue +24 -19
- package/patterns/application-shell/example/src/pages/home/settings.vue +27 -84
- package/patterns/application-shell/example/src/views/NotFound.vue +15 -0
- package/patterns/page-and-placement/example/src/components/SyncStatusElement.vue +2 -2
- package/patterns/page-and-placement/example/src/pages/home/reports/activity.vue +1 -1
- package/patterns/page-and-placement/example/src/pages/home/reports/overview.vue +1 -1
- package/patterns/page-and-placement/example/src/pages/home/reports.vue +6 -3
- package/patterns/page-and-placement/example/src/placement.js +1 -1
- package/src/client/components/ShellErrorHost.vue +13 -15
- package/src/client/components/ShellLayout.vue +388 -186
- package/src/client/components/ShellListDetail.vue +77 -0
- package/src/client/components/ShellMenuLinkItem.vue +10 -24
- package/src/client/components/ShellNavigationItem.vue +175 -0
- package/src/client/components/ShellNavigationScope.vue +18 -0
- package/src/client/components/ShellOutlet.vue +1 -1
- package/src/client/components/ShellOutletMenuWidget.vue +2 -2
- package/src/client/components/ShellPageAction.vue +91 -0
- package/src/client/components/ShellPageActions.vue +32 -0
- package/src/client/components/ShellSurfaceAwareMenuLinkItem.vue +10 -24
- package/src/client/components/ShellTabLinkItem.vue +77 -3
- package/src/client/composables/useShellDrawer.js +28 -18
- package/src/client/composables/useShellPageTitle.js +15 -0
- package/src/client/composables/useShellRouteTransition.js +1 -1
- package/src/client/composables/useShellWindowSizeClass.js +21 -0
- package/src/client/error/presentation.js +3 -5
- package/src/client/index.js +7 -0
- package/src/client/lib/menuIcons.js +21 -65
- package/src/client/navigation/documentNavigation.js +38 -0
- package/src/client/navigation/shellNavigationRuntime.js +480 -0
- package/src/client/navigation/useShellNavigation.js +94 -0
- package/src/client/providers/ShellWebClientProvider.js +11 -0
- package/src/client/support/drawerPresentation.js +9 -4
- package/src/client/support/drawerWidth.js +18 -1
- package/src/client/support/navigationPresentation.js +40 -0
- package/src/client/support/shellLayoutClass.js +6 -25
- package/src/client/support/windowSizeClass.js +29 -0
- package/src/test/adaptiveShellSmoke.js +43 -16
- package/src/test/shellNavigation.js +32 -0
- package/test/adaptiveShell.browser.test.js +207 -111
- package/test/clientUpdate.test.js +6 -1
- package/test/drawerPresentation.test.js +7 -7
- package/test/errorPresentation.test.js +4 -5
- package/test/materialBaselines.browser.test.js +96 -0
- package/test/menuIcons.test.js +14 -22
- package/test/outletMenuWidgetContract.test.js +2 -3
- package/test/playwrightContract.test.js +3 -1
- package/test/provider.test.js +9 -1
- package/test/settingsPlacementContract.test.js +33 -28
- package/test/shellGestureSupport.test.js +21 -9
- package/test/translation.test.js +2 -2
- package/test/useShellDrawer.test.js +20 -5
- package/test/useShellRouteTransition.test.js +3 -3
- package/patterns/application-shell/example/src/pages/home/settings/index.vue +0 -7
- package/src/client/components/ShellNavigationTooltip.vue +0 -39
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
measureDrawerContentWidth,
|
|
16
16
|
normalizeShellDrawerWidth,
|
|
17
17
|
normalizeShellNavigationItemSpacing,
|
|
18
|
-
normalizeShellRailWidth
|
|
18
|
+
normalizeShellRailWidth,
|
|
19
|
+
resolveMaterialDrawerWidth
|
|
19
20
|
} from "../support/drawerWidth.js";
|
|
20
21
|
|
|
21
22
|
// VNavigationDrawer has no root element of its own to reach through a template ref.
|
|
@@ -24,14 +25,17 @@ function navigationDrawerElement() {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
|
-
* The shell's navigation drawer: what opens it on each layout, how it presents, and
|
|
28
|
+
* The shell's navigation drawer: what opens it on each layout, how it presents, and how wide it is. The drawer is
|
|
29
|
+
* modal on compact and medium windows and a standard drawer, collapsing to a rail, on expanded ones. It is Material 3's
|
|
30
|
+
* 360dp wide unless `drawerWidth` fixes a width or is "content", which fits the drawer to its labels.
|
|
28
31
|
* @param {object} options
|
|
29
|
-
* @param {{ desktopDrawerClosedMode: string, drawerWidth: number | null, railWidth: number, navigationItemSpacing: number }} options.props
|
|
30
|
-
* @param {import("vue").Ref<boolean>} options.
|
|
32
|
+
* @param {{ desktopDrawerClosedMode: string, drawerWidth: number | string | null, railWidth: number, navigationItemSpacing: number }} options.props
|
|
33
|
+
* @param {import("vue").Ref<boolean>} options.modalLayout
|
|
34
|
+
* @param {import("vue").Ref<number>} options.viewportWidth
|
|
31
35
|
* @param {import("vue").Ref<{ $el: HTMLElement } | null>} options.navigationToggle
|
|
32
36
|
* @param {ReturnType<typeof import("./useShellLayoutState.js").useShellLayoutState>} options.layoutState
|
|
33
37
|
*/
|
|
34
|
-
function useShellDrawer({ props,
|
|
38
|
+
function useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, layoutState }) {
|
|
35
39
|
const {
|
|
36
40
|
drawerDefaultOpen,
|
|
37
41
|
drawerOpen,
|
|
@@ -45,18 +49,24 @@ function useShellDrawer({ props, isCompactLayout, navigationToggle, layoutState
|
|
|
45
49
|
let shellMounted = false;
|
|
46
50
|
|
|
47
51
|
const drawerPresentation = computed(() => resolveShellDrawerPresentation({
|
|
48
|
-
|
|
52
|
+
modal: modalLayout.value,
|
|
49
53
|
open: drawerOpen.value,
|
|
50
54
|
desktopClosedMode: props.desktopDrawerClosedMode
|
|
51
55
|
}));
|
|
52
56
|
const drawerToggleLabel = computed(() => resolveShellDrawerToggleLabel({
|
|
53
|
-
|
|
57
|
+
modal: modalLayout.value,
|
|
54
58
|
open: drawerOpen.value
|
|
55
59
|
}));
|
|
56
|
-
const fixedDrawerWidth = computed(() => props.drawerWidth !==
|
|
57
|
-
const resolvedDrawerWidth = computed(() =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
const fixedDrawerWidth = computed(() => props.drawerWidth !== "content");
|
|
61
|
+
const resolvedDrawerWidth = computed(() => {
|
|
62
|
+
if (!fixedDrawerWidth.value) {
|
|
63
|
+
return normalizeShellDrawerWidth(measuredDrawerWidth.value);
|
|
64
|
+
}
|
|
65
|
+
if (props.drawerWidth === null || props.drawerWidth === undefined) {
|
|
66
|
+
return resolveMaterialDrawerWidth({ modal: modalLayout.value, viewportWidth: viewportWidth.value });
|
|
67
|
+
}
|
|
68
|
+
return normalizeShellDrawerWidth(props.drawerWidth);
|
|
69
|
+
});
|
|
60
70
|
const resolvedRailWidth = computed(() => normalizeShellRailWidth(props.railWidth));
|
|
61
71
|
const resolvedNavigationItemSpacing = computed(() =>
|
|
62
72
|
normalizeShellNavigationItemSpacing(props.navigationItemSpacing)
|
|
@@ -67,7 +77,7 @@ function useShellDrawer({ props, isCompactLayout, navigationToggle, layoutState
|
|
|
67
77
|
);
|
|
68
78
|
|
|
69
79
|
watch(
|
|
70
|
-
|
|
80
|
+
modalLayout,
|
|
71
81
|
handleLayoutClassChange,
|
|
72
82
|
{ immediate: true }
|
|
73
83
|
);
|
|
@@ -103,20 +113,20 @@ function useShellDrawer({ props, isCompactLayout, navigationToggle, layoutState
|
|
|
103
113
|
}
|
|
104
114
|
|
|
105
115
|
function handleDrawerOpenChange(open) {
|
|
106
|
-
if (!
|
|
116
|
+
if (!modalLayout.value) {
|
|
107
117
|
wideDrawerOpen.value = Boolean(open);
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
120
|
|
|
111
|
-
function handleLayoutClassChange(
|
|
112
|
-
setDrawerOpen(
|
|
121
|
+
function handleLayoutClassChange(modal) {
|
|
122
|
+
setDrawerOpen(modal ? false : wideDrawerOpen.value);
|
|
113
123
|
}
|
|
114
124
|
|
|
115
125
|
function handleShellKeydown(event) {
|
|
116
126
|
if (
|
|
117
127
|
event.defaultPrevented ||
|
|
118
128
|
event.key !== "Escape" ||
|
|
119
|
-
!
|
|
129
|
+
!modalLayout.value ||
|
|
120
130
|
!drawerOpen.value
|
|
121
131
|
) {
|
|
122
132
|
return;
|
|
@@ -128,7 +138,7 @@ function useShellDrawer({ props, isCompactLayout, navigationToggle, layoutState
|
|
|
128
138
|
}
|
|
129
139
|
|
|
130
140
|
function focusNavigationToggle() {
|
|
131
|
-
navigationToggle.value
|
|
141
|
+
navigationToggle.value?.$el?.focus({ preventScroll: true });
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
function initializeDrawerMeasurement() {
|
|
@@ -175,7 +185,7 @@ function useShellDrawer({ props, isCompactLayout, navigationToggle, layoutState
|
|
|
175
185
|
}
|
|
176
186
|
|
|
177
187
|
function handleDrawerVisibilityChange(open) {
|
|
178
|
-
if (
|
|
188
|
+
if (modalLayout.value || drawerPresentation.value.closedMode === "hidden" || open === false) {
|
|
179
189
|
setDrawerOpen(open);
|
|
180
190
|
}
|
|
181
191
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { onScopeDispose, toValue } from "vue";
|
|
2
|
+
import { useShellNavigationRuntime } from "../navigation/useShellNavigation.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shows `title` as the app bar's page title while the calling component lives, over the route's `meta.jskit.title`.
|
|
6
|
+
* For a title known only at runtime, such as a record's name. The title may be a message key or plain text.
|
|
7
|
+
* @param {import("vue").MaybeRefOrGetter<string>} title
|
|
8
|
+
*/
|
|
9
|
+
function useShellPageTitle(title) {
|
|
10
|
+
const runtime = useShellNavigationRuntime();
|
|
11
|
+
const release = runtime.setPageTitle(() => String(toValue(title) || ""));
|
|
12
|
+
onScopeDispose(release);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useShellPageTitle };
|
|
@@ -73,7 +73,7 @@ function useShellRouteTransition(props) {
|
|
|
73
73
|
window.removeEventListener("pointercancel", handlePointerCancel, { capture: true });
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
const resolvedLayoutClass = computed(() => resolveShellLayoutClass(display.
|
|
76
|
+
const resolvedLayoutClass = computed(() => resolveShellLayoutClass(display.width.value));
|
|
77
77
|
|
|
78
78
|
const currentPathname = computed(() => normalizeComparablePathname(resolveRuntimePathname(route.path)));
|
|
79
79
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useDisplay } from "vuetify";
|
|
3
|
+
import { resolveWindowSizeClass } from "../support/windowSizeClass.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The Material 3 window size class of the current window: "compact" (under 600dp), "medium" (600-839), "expanded"
|
|
7
|
+
* (840-1199) or "large" (1200 and wider), with a boolean for each.
|
|
8
|
+
*/
|
|
9
|
+
function useShellWindowSizeClass() {
|
|
10
|
+
const display = useDisplay();
|
|
11
|
+
const sizeClass = computed(() => resolveWindowSizeClass(display.width.value));
|
|
12
|
+
return {
|
|
13
|
+
sizeClass,
|
|
14
|
+
isCompact: computed(() => sizeClass.value === "compact"),
|
|
15
|
+
isMedium: computed(() => sizeClass.value === "medium"),
|
|
16
|
+
isExpanded: computed(() => sizeClass.value === "expanded"),
|
|
17
|
+
isLarge: computed(() => sizeClass.value === "large")
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { useShellWindowSizeClass };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { mdiAlertOutline, mdiCheckCircleOutline, mdiInformationOutline } from "@mdi/js";
|
|
2
|
-
|
|
3
1
|
function resolveSeverityColor(severity = "error") {
|
|
4
2
|
const normalized = String(severity || "error").trim().toLowerCase();
|
|
5
3
|
if (normalized === "info") {
|
|
@@ -17,12 +15,12 @@ function resolveSeverityColor(severity = "error") {
|
|
|
17
15
|
function resolveSeverityIcon(severity = "error") {
|
|
18
16
|
const normalized = String(severity || "error").trim().toLowerCase();
|
|
19
17
|
if (normalized === "info") {
|
|
20
|
-
return
|
|
18
|
+
return "$info";
|
|
21
19
|
}
|
|
22
20
|
if (normalized === "success") {
|
|
23
|
-
return
|
|
21
|
+
return "$success";
|
|
24
22
|
}
|
|
25
|
-
return
|
|
23
|
+
return "$warning";
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
function resolveTimeout(entry) {
|
package/src/client/index.js
CHANGED
|
@@ -10,7 +10,14 @@ export { default as ShellErrorHost } from "./components/ShellErrorHost.vue";
|
|
|
10
10
|
export { default as ShellMenuLinkItem } from "./components/ShellMenuLinkItem.vue";
|
|
11
11
|
export { default as ShellSurfaceAwareMenuLinkItem } from "./components/ShellSurfaceAwareMenuLinkItem.vue";
|
|
12
12
|
export { default as ShellTabLinkItem } from "./components/ShellTabLinkItem.vue";
|
|
13
|
+
export { default as ShellPageActions } from "./components/ShellPageActions.vue";
|
|
14
|
+
export { default as ShellPageAction } from "./components/ShellPageAction.vue";
|
|
15
|
+
export { default as ShellListDetail } from "./components/ShellListDetail.vue";
|
|
13
16
|
export { useShellLayoutState } from "./composables/useShellLayoutState.js";
|
|
17
|
+
export { useShellPageTitle } from "./composables/useShellPageTitle.js";
|
|
18
|
+
export { useShellWindowSizeClass } from "./composables/useShellWindowSizeClass.js";
|
|
19
|
+
export { useShellNavigation } from "./navigation/useShellNavigation.js";
|
|
20
|
+
export { leaveApp, reloadAppPage } from "./navigation/documentNavigation.js";
|
|
14
21
|
export { useShellLayoutStore } from "./stores/useShellLayoutStore.js";
|
|
15
22
|
export { useShellErrorPresentationStore } from "./stores/useShellErrorPresentationStore.js";
|
|
16
23
|
export {
|
|
@@ -1,61 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
mdiAccountCircleOutline,
|
|
3
|
-
mdiAccountCogOutline,
|
|
4
|
-
mdiAccountGroupOutline,
|
|
5
|
-
mdiArrowRightCircleOutline,
|
|
6
|
-
mdiClipboardListOutline,
|
|
7
|
-
mdiCogOutline,
|
|
8
|
-
mdiConsoleNetworkOutline,
|
|
9
|
-
mdiFolderOutline,
|
|
10
|
-
mdiHomeVariantOutline,
|
|
11
|
-
mdiLogin,
|
|
12
|
-
mdiLogout,
|
|
13
|
-
mdiRobotOutline,
|
|
14
|
-
mdiShieldCrownOutline,
|
|
15
|
-
mdiViewDashboardOutline,
|
|
16
|
-
mdiViewListOutline
|
|
17
|
-
} from "@mdi/js";
|
|
18
1
|
import { isExternalLinkTarget, splitPathQueryHash } from "@jskit-ai/kernel/shared/support/linkPath";
|
|
19
2
|
import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
20
3
|
import { normalizePathname as normalizeKernelPathname } from "@jskit-ai/kernel/shared/surface/paths";
|
|
21
4
|
|
|
5
|
+
// Navigation icons are Vuetify icon aliases, which @jskit-ai/material-web maps to Material Symbols Rounded.
|
|
22
6
|
const SURFACE_SWITCH_ICON_BY_ID = Object.freeze({
|
|
23
|
-
home:
|
|
24
|
-
app:
|
|
25
|
-
admin:
|
|
26
|
-
console:
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const SUPPORTED_EXPLICIT_MDI_ICON_BY_NAME = Object.freeze({
|
|
30
|
-
"mdi-account-circle-outline": mdiAccountCircleOutline,
|
|
31
|
-
"mdi-account-cog-outline": mdiAccountCogOutline,
|
|
32
|
-
"mdi-account-group-outline": mdiAccountGroupOutline,
|
|
33
|
-
"mdi-arrow-right-circle-outline": mdiArrowRightCircleOutline,
|
|
34
|
-
"mdi-clipboard-list-outline": mdiClipboardListOutline,
|
|
35
|
-
"mdi-cog-outline": mdiCogOutline,
|
|
36
|
-
"mdi-console-network-outline": mdiConsoleNetworkOutline,
|
|
37
|
-
"mdi-folder-outline": mdiFolderOutline,
|
|
38
|
-
"mdi-home-variant-outline": mdiHomeVariantOutline,
|
|
39
|
-
"mdi-login": mdiLogin,
|
|
40
|
-
"mdi-logout": mdiLogout,
|
|
41
|
-
"mdi-robot-outline": mdiRobotOutline,
|
|
42
|
-
"mdi-shield-crown-outline": mdiShieldCrownOutline,
|
|
43
|
-
"mdi-view-dashboard-outline": mdiViewDashboardOutline,
|
|
44
|
-
"mdi-view-list-outline": mdiViewListOutline
|
|
7
|
+
home: "$home",
|
|
8
|
+
app: "$dashboard",
|
|
9
|
+
admin: "$adminPanelSettings",
|
|
10
|
+
console: "$terminal"
|
|
45
11
|
});
|
|
46
12
|
|
|
47
13
|
function resolveExplicitIconValue(explicitIcon = "") {
|
|
48
|
-
|
|
49
|
-
if (!normalizedExplicitIcon) {
|
|
50
|
-
return "";
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!normalizedExplicitIcon.startsWith("mdi-")) {
|
|
54
|
-
return normalizedExplicitIcon;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const resolvedIcon = SUPPORTED_EXPLICIT_MDI_ICON_BY_NAME[normalizedExplicitIcon];
|
|
58
|
-
return typeof resolvedIcon === "string" && resolvedIcon ? resolvedIcon : normalizedExplicitIcon;
|
|
14
|
+
return normalizeText(explicitIcon);
|
|
59
15
|
}
|
|
60
16
|
|
|
61
17
|
function normalizePathname(value = "") {
|
|
@@ -108,7 +64,7 @@ function resolveSurfaceSwitchIcon(surfaceId = "", explicitIcon = "") {
|
|
|
108
64
|
}
|
|
109
65
|
|
|
110
66
|
const normalizedSurfaceId = normalizeText(surfaceId).toLowerCase();
|
|
111
|
-
return SURFACE_SWITCH_ICON_BY_ID[normalizedSurfaceId] ||
|
|
67
|
+
return SURFACE_SWITCH_ICON_BY_ID[normalizedSurfaceId] || "$arrowCircleRight";
|
|
112
68
|
}
|
|
113
69
|
|
|
114
70
|
function resolveMenuLinkIcon({ icon = "", label = "", to = "" } = {}) {
|
|
@@ -132,14 +88,14 @@ function resolveMenuLinkIcon({ icon = "", label = "", to = "" } = {}) {
|
|
|
132
88
|
normalizedLabel.includes("sign in") ||
|
|
133
89
|
normalizedPathname.includes("/auth/login")
|
|
134
90
|
) {
|
|
135
|
-
return
|
|
91
|
+
return "$login";
|
|
136
92
|
}
|
|
137
93
|
|
|
138
94
|
if (
|
|
139
95
|
normalizedLabel.includes("sign out") ||
|
|
140
96
|
normalizedPathname.includes("/auth/signout")
|
|
141
97
|
) {
|
|
142
|
-
return
|
|
98
|
+
return "$logout";
|
|
143
99
|
}
|
|
144
100
|
|
|
145
101
|
if (
|
|
@@ -151,9 +107,9 @@ function resolveMenuLinkIcon({ icon = "", label = "", to = "" } = {}) {
|
|
|
151
107
|
normalizedPathname.includes("/settings") ||
|
|
152
108
|
normalizedPathname === "/account"
|
|
153
109
|
) {
|
|
154
|
-
return
|
|
110
|
+
return "$manageAccounts";
|
|
155
111
|
}
|
|
156
|
-
return
|
|
112
|
+
return "$accountCircle";
|
|
157
113
|
}
|
|
158
114
|
|
|
159
115
|
if (
|
|
@@ -161,36 +117,36 @@ function resolveMenuLinkIcon({ icon = "", label = "", to = "" } = {}) {
|
|
|
161
117
|
normalizedLabel.includes("team") ||
|
|
162
118
|
normalizedPathname.includes("/members")
|
|
163
119
|
) {
|
|
164
|
-
return
|
|
120
|
+
return "$group";
|
|
165
121
|
}
|
|
166
122
|
|
|
167
123
|
if (normalizedLabel.includes("assistant") || normalizedPathname.includes("/assistant")) {
|
|
168
|
-
return
|
|
124
|
+
return "$smartToy";
|
|
169
125
|
}
|
|
170
126
|
|
|
171
127
|
if (
|
|
172
128
|
normalizedLabel.includes("console") ||
|
|
173
129
|
normalizedPathname.startsWith("/console")
|
|
174
130
|
) {
|
|
175
|
-
return
|
|
131
|
+
return "$terminal";
|
|
176
132
|
}
|
|
177
133
|
|
|
178
134
|
if (
|
|
179
135
|
normalizedLabel.includes("admin") ||
|
|
180
136
|
normalizedPathname.includes("/admin")
|
|
181
137
|
) {
|
|
182
|
-
return
|
|
138
|
+
return "$adminPanelSettings";
|
|
183
139
|
}
|
|
184
140
|
|
|
185
141
|
if (normalizedLabel.includes("settings") || normalizedPathname.includes("/settings")) {
|
|
186
|
-
return
|
|
142
|
+
return "$settings";
|
|
187
143
|
}
|
|
188
144
|
|
|
189
145
|
if (
|
|
190
146
|
normalizedLabel.includes("home") ||
|
|
191
147
|
normalizedPathname === "/"
|
|
192
148
|
) {
|
|
193
|
-
return
|
|
149
|
+
return "$home";
|
|
194
150
|
}
|
|
195
151
|
|
|
196
152
|
if (
|
|
@@ -198,21 +154,21 @@ function resolveMenuLinkIcon({ icon = "", label = "", to = "" } = {}) {
|
|
|
198
154
|
normalizedLabel.includes("dashboard") ||
|
|
199
155
|
normalizedPathname.includes("/w/")
|
|
200
156
|
) {
|
|
201
|
-
return
|
|
157
|
+
return "$dashboard";
|
|
202
158
|
}
|
|
203
159
|
|
|
204
160
|
if (normalizedPathname) {
|
|
205
161
|
const segments = normalizedPathname.split("/").filter(Boolean);
|
|
206
162
|
if (segments.length === 1) {
|
|
207
|
-
return
|
|
163
|
+
return "$folder";
|
|
208
164
|
}
|
|
209
165
|
}
|
|
210
166
|
|
|
211
167
|
if (normalizedLabel.includes("list")) {
|
|
212
|
-
return
|
|
168
|
+
return "$assignment";
|
|
213
169
|
}
|
|
214
170
|
|
|
215
|
-
return
|
|
171
|
+
return "$viewList";
|
|
216
172
|
}
|
|
217
173
|
|
|
218
174
|
export {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isExternalLinkTarget } from "@jskit-ai/kernel/shared/support/linkPath";
|
|
2
|
+
import { pageWindow } from "../browser.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Loads an in-app page as a new document in place of the current history entry, rebuilding all client state: after
|
|
6
|
+
* signing in, or switching user. The tab's trail starts again, as on a pasted link. Use router navigation for
|
|
7
|
+
* everything else.
|
|
8
|
+
* @param {string} target An in-app path, such as one from `usePaths().page()`.
|
|
9
|
+
*/
|
|
10
|
+
function reloadAppPage(target) {
|
|
11
|
+
const path = String(target || "").trim();
|
|
12
|
+
if (!path.startsWith("/") || path.startsWith("//") || isExternalLinkTarget(path)) {
|
|
13
|
+
throw new TypeError(`reloadAppPage() takes an in-app path, not "${path}"; use leaveApp() for another site.`);
|
|
14
|
+
}
|
|
15
|
+
pageWindow()?.location.replace(path);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Leaves the app for another site in the same tab, such as a payment provider's checkout. External pages never enter
|
|
20
|
+
* the trail.
|
|
21
|
+
* @param {string} url An absolute http(s) URL on another origin.
|
|
22
|
+
*/
|
|
23
|
+
function leaveApp(url) {
|
|
24
|
+
const windowRef = pageWindow();
|
|
25
|
+
const target = String(url || "").trim();
|
|
26
|
+
let parsed = null;
|
|
27
|
+
try {
|
|
28
|
+
parsed = new URL(target);
|
|
29
|
+
} catch {
|
|
30
|
+
parsed = null;
|
|
31
|
+
}
|
|
32
|
+
if (!parsed || !/^https?:$/u.test(parsed.protocol) || (windowRef && parsed.origin === windowRef.location.origin)) {
|
|
33
|
+
throw new TypeError(`leaveApp() takes another site's http(s) URL, not "${target}"; navigate in-app pages with the router.`);
|
|
34
|
+
}
|
|
35
|
+
windowRef?.location.assign(parsed.href);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { leaveApp, reloadAppPage };
|