@jskit-ai/shell-web 0.2.11 → 0.2.13
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 +5 -0
- package/fixtures/adaptive-shell/src/App.vue +11 -3
- package/fixtures/adaptive-shell/src/ButtonsPage.vue +31 -0
- package/fixtures/adaptive-shell/src/OwnBarLayout.vue +36 -0
- package/fixtures/adaptive-shell/src/StudioPage.vue +26 -0
- package/fixtures/adaptive-shell/src/main.js +101 -37
- package/package.json +7 -2
- package/src/client/components/ShellLayout.vue +38 -66
- package/src/client/components/ShellOutlet.vue +2 -50
- package/src/client/components/ShellPageActions.vue +2 -2
- package/src/client/components/ShellPageActionsTarget.vue +24 -0
- package/src/client/components/ShellPageTitle.vue +52 -0
- package/src/client/components/ShellUpButton.vue +29 -0
- package/src/client/composables/useShellAppBar.js +27 -0
- package/src/client/composables/useShellOutletPlacements.js +49 -0
- package/src/client/index.js +4 -0
- package/src/client/navigation/documentNavigation.js +6 -3
- package/src/client/navigation/linkResolver.js +22 -11
- package/src/client/support/drawerPresentation.js +13 -1
- package/test/adaptiveShell.browser.test.js +178 -0
- package/test/documentNavigation.test.js +44 -0
- package/test/drawerPresentation.test.js +13 -1
- package/test/linkResolver.test.js +50 -1
- package/test/settingsPlacementContract.test.js +19 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
- The application-shell pattern's not-found view renders in the shell, so the top app bar carries its title and the navigation leads back into the app; the shell foundation has it too.
|
|
8
8
|
- `ShellListDetail` lays out list-detail pages such as settings: the list beside the open detail on expanded windows (with the landing child as the empty detail), one pane at a time on narrower ones. The foundation and shell patterns' settings pages use it instead of redirecting their landing page to the first section.
|
|
9
9
|
- The drawer is 360dp wide by default; `drawerWidth="content"` fits it to its labels. A modal drawer (compact and medium windows) opens over the app bar and closes from its scrim or Escape. The drawer's divider shows only between primary and secondary destinations. The `--shell-chrome-*` custom properties, the rail and drawer item tooltips and `@mdi/js` are gone.
|
|
10
|
+
- A surface draws only the navigation it has: no navigation bar without bar destinations, and no rail, drawer or menu control without menu destinations, as on an account surface whose shell exists for the app bar's title, Up and actions. The surface identity (a workspace switcher) keeps the drawer only beside other navigation, as on a phone whose destinations are all in the navigation bar; a phone surface with neither identity nor secondary destinations loses its empty drawer and menu control.
|
|
11
|
+
- `usePaths().page()`, and every shell link, fills a path's `:name` segments from the current route's params (or the `params` given), so a declared parent such as `/books/:bookId` takes the id on a direct visit to `/books/7/edit` and Up goes to `/books/7`; a missing param throws as a missing surface param does, and Up then goes to the surface's root.
|
|
12
|
+
- `leaveApp(url, { replace: true })` leaves in place of the current history entry, for a hand-off page that only forwards (to an OAuth provider's consent screen), so Back from the site doesn't rerun it; `leaveApp(url)` still pushes.
|
|
13
|
+
- `ShellPageTitle`'s default slot, given `{ title }`, replaces the text inside the h1, so a title that is also a switcher (a project menu) can be the menu's activator and stay the page's one h1, with its id and focus.
|
|
14
|
+
- A layout that draws its own top app bar builds it from the pieces of `ShellLayout`'s bar: `ShellUpButton` (the Up arrow, shown only on inner pages), `ShellPageTitle` (the page's one `h1`) and `ShellPageActionsTarget`, with `useShellAppBar()` once in the layout so its pages enter the trail and their `ShellPageActions` show in its bar. `ShellLayout` is built from the same pieces and looks and behaves as before.
|
|
10
15
|
- Upgrading: see the guide's [Move an app to the Material 3 defaults](https://mobily-enterprises.github.io/jskit-ai/guide/app-setup/material-3-migration).
|
|
11
16
|
|
|
12
17
|
## 0.2.0 - 2026-10-29
|
|
@@ -4,19 +4,24 @@ import { RouterView, useRoute } from "vue-router";
|
|
|
4
4
|
import { useTheme } from "vuetify";
|
|
5
5
|
import ShellLayout from "@jskit-ai/shell-web/client/components/ShellLayout";
|
|
6
6
|
import ShellErrorHost from "@jskit-ai/shell-web/client/components/ShellErrorHost";
|
|
7
|
+
import OwnBarLayout from "./OwnBarLayout.vue";
|
|
7
8
|
|
|
8
9
|
const route = useRoute();
|
|
9
10
|
const theme = useTheme();
|
|
10
11
|
const bare = computed(() => route.meta.bare === true);
|
|
11
|
-
const
|
|
12
|
-
const
|
|
12
|
+
const ownBar = computed(() => route.meta.ownBar === true);
|
|
13
|
+
const surface = computed(() => {
|
|
14
|
+
if (route.path.startsWith("/w/")) return "admin";
|
|
15
|
+
return route.path.startsWith("/account") ? "account" : "home";
|
|
16
|
+
});
|
|
17
|
+
const surfaceLabel = computed(() => ({ admin: "Admin", account: "Account" })[surface.value] || "Home");
|
|
13
18
|
const themeMode = computed(() => route.query.theme === "dark" ? "dark" : "light");
|
|
14
19
|
const railWidth = computed(() => Number(route.query.railWidth) || undefined);
|
|
15
20
|
const navigationItemSpacing = computed(() => Number(route.query.navigationItemSpacing) || undefined);
|
|
16
21
|
const drawerWidth = computed(() => (route.query.drawerWidth === "content" ? "content" : undefined));
|
|
17
22
|
|
|
18
23
|
watchEffect(function applyFixtureTheme() {
|
|
19
|
-
const themeName = `${surface.value}-${themeMode.value}`;
|
|
24
|
+
const themeName = `${surface.value === "admin" ? "admin" : "home"}-${themeMode.value}`;
|
|
20
25
|
theme.change(themeName);
|
|
21
26
|
document.body.dataset.surface = surface.value;
|
|
22
27
|
document.body.dataset.theme = themeMode.value;
|
|
@@ -26,6 +31,9 @@ watchEffect(function applyFixtureTheme() {
|
|
|
26
31
|
<template>
|
|
27
32
|
<v-app>
|
|
28
33
|
<RouterView v-if="bare" />
|
|
34
|
+
<OwnBarLayout v-else-if="ownBar">
|
|
35
|
+
<RouterView />
|
|
36
|
+
</OwnBarLayout>
|
|
29
37
|
<ShellLayout
|
|
30
38
|
v-else
|
|
31
39
|
:surface="surface"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// Every button size with its 48dp touch target, a label longer than its button, a small button in the corner of a
|
|
3
|
+
// scroll container, the FAB sizes and cards by variant.
|
|
4
|
+
const sizes = ["x-small", "small", "default", "large"];
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<section class="d-flex flex-column align-start ga-8 pa-6">
|
|
9
|
+
<template v-for="size in sizes" :key="size">
|
|
10
|
+
<v-btn :size="size" variant="tonal" :data-testid="`fixture-button-${size}`">Size {{ size }}</v-btn>
|
|
11
|
+
<v-btn :size="size" icon="$close" :aria-label="`Close ${size}`" :data-testid="`fixture-icon-button-${size}`" />
|
|
12
|
+
</template>
|
|
13
|
+
<div :style="{ width: '160px' }">
|
|
14
|
+
<v-btn variant="tonal" data-testid="fixture-long-label">A label far longer than the room it has</v-btn>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="d-flex align-end justify-end" :style="{ width: '160px', height: '32px', overflow: 'auto' }" data-testid="fixture-button-corner">
|
|
17
|
+
<v-btn size="x-small" icon="$close" aria-label="Close corner" />
|
|
18
|
+
</div>
|
|
19
|
+
<div class="d-flex align-center ga-4">
|
|
20
|
+
<v-fab icon="$add" aria-label="Add" data-testid="fixture-fab" />
|
|
21
|
+
<v-fab icon="$add" size="small" aria-label="Add small" data-testid="fixture-fab-small" />
|
|
22
|
+
<v-fab icon="$add" size="large" aria-label="Add large" data-testid="fixture-fab-large" />
|
|
23
|
+
<v-fab extended prepend-icon="$add" text="New" data-testid="fixture-fab-extended" />
|
|
24
|
+
</div>
|
|
25
|
+
<div class="d-flex ga-4">
|
|
26
|
+
<v-card v-for="variant in ['elevated', 'flat', 'tonal']" :key="variant" :variant="variant" :data-testid="`fixture-card-${variant}`">
|
|
27
|
+
<v-card-text>{{ variant }}</v-card-text>
|
|
28
|
+
</v-card>
|
|
29
|
+
</div>
|
|
30
|
+
</section>
|
|
31
|
+
</template>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import ShellPageActionsTarget from "@jskit-ai/shell-web/client/components/ShellPageActionsTarget";
|
|
3
|
+
import ShellPageTitle from "@jskit-ai/shell-web/client/components/ShellPageTitle";
|
|
4
|
+
import ShellUpButton from "@jskit-ai/shell-web/client/components/ShellUpButton";
|
|
5
|
+
import { useShellAppBar } from "@jskit-ai/shell-web/client/composables/useShellAppBar";
|
|
6
|
+
|
|
7
|
+
// A layout that draws its own top app bar, as a workspace bar with the app's own controls does, from the shell's
|
|
8
|
+
// pieces: Up, the page title and the page's actions.
|
|
9
|
+
useShellAppBar();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<v-app-bar color="surface" flat :height="64" data-testid="fixture-own-bar">
|
|
14
|
+
<ShellUpButton />
|
|
15
|
+
<div class="flex-grow-1 px-3 text-truncate">
|
|
16
|
+
<ShellPageTitle title="Studio">
|
|
17
|
+
<template #default="{ title }">
|
|
18
|
+
<!-- A title that is also a switcher: the menu activator sits inside the one h1. -->
|
|
19
|
+
<v-menu>
|
|
20
|
+
<template #activator="{ props: menu }">
|
|
21
|
+
<v-btn variant="text" append-icon="$dropdown" class="text-title-large" v-bind="menu">{{ title }}</v-btn>
|
|
22
|
+
</template>
|
|
23
|
+
<v-list>
|
|
24
|
+
<v-list-item title="Other studio" />
|
|
25
|
+
</v-list>
|
|
26
|
+
</v-menu>
|
|
27
|
+
</template>
|
|
28
|
+
</ShellPageTitle>
|
|
29
|
+
</div>
|
|
30
|
+
<ShellPageActionsTarget />
|
|
31
|
+
<v-btn variant="text" data-testid="fixture-workspace-control">Workspace</v-btn>
|
|
32
|
+
</v-app-bar>
|
|
33
|
+
<v-main class="bg-background">
|
|
34
|
+
<slot />
|
|
35
|
+
</v-main>
|
|
36
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { RouterLink, useRoute } from "vue-router";
|
|
4
|
+
import ShellPageAction from "../../../src/client/components/ShellPageAction.vue";
|
|
5
|
+
import ShellPageActions from "../../../src/client/components/ShellPageActions.vue";
|
|
6
|
+
import { useShellPageTitle } from "../../../src/client/composables/useShellPageTitle.js";
|
|
7
|
+
import { usePaths } from "../../../src/client/navigation/usePaths.js";
|
|
8
|
+
import { records } from "./records.js";
|
|
9
|
+
|
|
10
|
+
const route = useRoute();
|
|
11
|
+
const paths = usePaths();
|
|
12
|
+
const record = computed(() => records.contacts.find((item) => item.id === route.params.id) || null);
|
|
13
|
+
|
|
14
|
+
useShellPageTitle(() => (route.params.id ? record.value?.name || "Not found" : ""));
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<section>
|
|
19
|
+
<ShellPageActions v-if="record">
|
|
20
|
+
<ShellPageAction label="Run" primary />
|
|
21
|
+
</ShellPageActions>
|
|
22
|
+
<p v-else>
|
|
23
|
+
<RouterLink :to="paths.page('/studio/ada')">Ada Lovelace</RouterLink>
|
|
24
|
+
</p>
|
|
25
|
+
</section>
|
|
26
|
+
</template>
|
|
@@ -9,10 +9,12 @@ import "@jskit-ai/material-web/client/material.css";
|
|
|
9
9
|
import { materialThemes, createMaterialVuetifyOptions } from "@jskit-ai/material-web/client";
|
|
10
10
|
import { shellScrollBehavior } from "@jskit-ai/kernel/client";
|
|
11
11
|
import App from "./App.vue";
|
|
12
|
+
import ButtonsPage from "./ButtonsPage.vue";
|
|
12
13
|
import { adminTheme, theme } from "./theme/index.js";
|
|
13
14
|
import RecordListPage from "./RecordListPage.vue";
|
|
14
15
|
import RecordPage from "./RecordPage.vue";
|
|
15
16
|
import ScreenPage from "./ScreenPage.vue";
|
|
17
|
+
import StudioPage from "./StudioPage.vue";
|
|
16
18
|
import SettingsPage from "./SettingsPage.vue";
|
|
17
19
|
import ShellMenuLinkItem from "@jskit-ai/shell-web/client/components/ShellMenuLinkItem";
|
|
18
20
|
import ShellSurfaceAwareMenuLinkItem from "@jskit-ai/shell-web/client/components/ShellSurfaceAwareMenuLinkItem";
|
|
@@ -38,48 +40,94 @@ const COMPONENTS = new Map([
|
|
|
38
40
|
["fixture.tab-link", ShellTabLinkItem]
|
|
39
41
|
]);
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
// Main navigation as literal data, one placement per destination, as jskit check reads it.
|
|
44
|
+
const placements = [
|
|
45
|
+
{
|
|
46
|
+
id: "fixture.home.home",
|
|
44
47
|
target: "shell.primary-nav",
|
|
45
48
|
kind: "link",
|
|
46
|
-
surfaces: [
|
|
47
|
-
order,
|
|
48
|
-
props: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
49
|
+
surfaces: ["home"],
|
|
50
|
+
order: 10,
|
|
51
|
+
props: { label: "Home", surface: "home", scopedSuffix: "/", unscopedSuffix: "/", exact: true }
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "fixture.home.settings",
|
|
55
|
+
target: "shell.primary-nav",
|
|
56
|
+
kind: "link",
|
|
57
|
+
surfaces: ["home"],
|
|
58
|
+
order: 20,
|
|
59
|
+
props: { label: "Settings", surface: "home", scopedSuffix: "/settings", unscopedSuffix: "/settings" }
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "fixture.home.contacts",
|
|
63
|
+
target: "shell.primary-nav",
|
|
64
|
+
kind: "link",
|
|
65
|
+
surfaces: ["home"],
|
|
66
|
+
order: 30,
|
|
67
|
+
props: { label: "Contacts", surface: "home", scopedSuffix: "/contacts", unscopedSuffix: "/contacts" }
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "fixture.home.suppliers",
|
|
71
|
+
target: "shell.primary-nav",
|
|
72
|
+
kind: "link",
|
|
73
|
+
surfaces: ["home"],
|
|
74
|
+
order: 40,
|
|
75
|
+
props: { label: "Suppliers", surface: "home", scopedSuffix: "/suppliers", unscopedSuffix: "/suppliers" }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "fixture.home.bookings",
|
|
79
|
+
target: "shell.primary-nav",
|
|
80
|
+
kind: "link",
|
|
81
|
+
surfaces: ["home"],
|
|
82
|
+
order: 50,
|
|
83
|
+
props: { label: "Bookings", surface: "home", scopedSuffix: "/bookings", unscopedSuffix: "/bookings" }
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "fixture.admin.home",
|
|
87
|
+
target: "shell.primary-nav",
|
|
88
|
+
kind: "link",
|
|
89
|
+
surfaces: ["admin"],
|
|
90
|
+
order: 10,
|
|
91
|
+
props: { label: "Home", surface: "admin", scopedSuffix: "/", unscopedSuffix: "/", exact: true }
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "fixture.admin.assistant",
|
|
95
|
+
target: "shell.primary-nav",
|
|
96
|
+
kind: "link",
|
|
97
|
+
surfaces: ["admin"],
|
|
98
|
+
order: 20,
|
|
99
|
+
props: { label: "Assistant", surface: "admin", scopedSuffix: "/assistant", unscopedSuffix: "/assistant" }
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: "fixture.admin.contacts",
|
|
103
|
+
target: "shell.primary-nav",
|
|
104
|
+
kind: "link",
|
|
105
|
+
surfaces: ["admin"],
|
|
106
|
+
order: 30,
|
|
107
|
+
props: { label: "Contacts", surface: "admin", scopedSuffix: "/contacts", unscopedSuffix: "/contacts" }
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "fixture.admin.bookings",
|
|
111
|
+
target: "shell.primary-nav",
|
|
112
|
+
kind: "link",
|
|
113
|
+
surfaces: ["admin"],
|
|
114
|
+
order: 40,
|
|
115
|
+
props: { label: "Bookings", surface: "admin", scopedSuffix: "/bookings", unscopedSuffix: "/bookings" }
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: "fixture.admin.rostering",
|
|
119
|
+
target: "shell.primary-nav",
|
|
120
|
+
kind: "link",
|
|
121
|
+
surfaces: ["admin"],
|
|
122
|
+
order: 50,
|
|
123
|
+
props: { label: "Rostering", surface: "admin", scopedSuffix: "/rostering", unscopedSuffix: "/rostering" }
|
|
124
|
+
},
|
|
77
125
|
{
|
|
78
126
|
id: "fixture.help",
|
|
79
127
|
target: "shell.secondary-nav",
|
|
80
128
|
kind: "link",
|
|
81
129
|
componentToken: "fixture.menu-link",
|
|
82
|
-
surfaces: ["
|
|
130
|
+
surfaces: ["home", "admin"],
|
|
83
131
|
order: 100,
|
|
84
132
|
props: {
|
|
85
133
|
label: "Help and support",
|
|
@@ -119,10 +167,12 @@ placementRuntime.setContext({
|
|
|
119
167
|
surfaceConfig: {
|
|
120
168
|
tenancyMode: "path",
|
|
121
169
|
defaultSurfaceId: "home",
|
|
122
|
-
enabledSurfaceIds: ["home", "admin"],
|
|
170
|
+
enabledSurfaceIds: ["home", "admin", "account"],
|
|
123
171
|
surfacesById: {
|
|
124
172
|
home: { id: "home", routeBase: "/home", enabled: true },
|
|
125
|
-
admin: { id: "admin", routeBase: "/w/:workspaceSlug/admin", enabled: true }
|
|
173
|
+
admin: { id: "admin", routeBase: "/w/:workspaceSlug/admin", enabled: true },
|
|
174
|
+
// A surface whose shell has no navigation, as an account page's.
|
|
175
|
+
account: { id: "account", routeBase: "/account", enabled: true }
|
|
126
176
|
}
|
|
127
177
|
}
|
|
128
178
|
});
|
|
@@ -154,6 +204,11 @@ const routes = [
|
|
|
154
204
|
beforeEnter: refuseBlockedRecord,
|
|
155
205
|
meta: { kind: "contacts", jskit: { parent: "/contacts" } }
|
|
156
206
|
},
|
|
207
|
+
{
|
|
208
|
+
path: "/home/contacts/:id/edit",
|
|
209
|
+
component: ScreenPage,
|
|
210
|
+
meta: { title: "Edit contact", jskit: { title: "Edit contact", parent: "/contacts/:id" } }
|
|
211
|
+
},
|
|
157
212
|
{ path: "/home/suppliers", component: RecordListPage, meta: { kind: "suppliers", jskit: { title: "Suppliers" } } },
|
|
158
213
|
{
|
|
159
214
|
path: "/home/suppliers/:id",
|
|
@@ -161,9 +216,18 @@ const routes = [
|
|
|
161
216
|
beforeEnter: refuseBlockedRecord,
|
|
162
217
|
meta: { kind: "suppliers", jskit: { parent: "/suppliers" } }
|
|
163
218
|
},
|
|
219
|
+
{ path: "/home/buttons", component: ButtonsPage, meta: { jskit: { title: "Buttons" } } },
|
|
220
|
+
// A layout that draws its own top app bar from the shell's pieces.
|
|
221
|
+
{ path: "/home/studio", component: StudioPage, meta: { ownBar: true, jskit: { title: "Studio" } } },
|
|
222
|
+
{ path: "/home/studio/:id", component: StudioPage, meta: { ownBar: true, jskit: { parent: "/studio" } } },
|
|
164
223
|
{ path: "/home/:section?", component: ScreenPage, meta: { title: "Home surface" } },
|
|
165
224
|
{ path: "/w/:workspaceSlug/admin/:section?", component: ScreenPage, meta: { title: "Admin surface" } },
|
|
166
225
|
{ path: "/help", component: ScreenPage, meta: { title: "Help and support" } },
|
|
226
|
+
{
|
|
227
|
+
path: "/account",
|
|
228
|
+
component: ScreenPage,
|
|
229
|
+
meta: { title: "Account", jskit: { title: "Account", parent: { surface: "home", path: "/" } } }
|
|
230
|
+
},
|
|
167
231
|
{ path: "/sign-in", component: ScreenPage, meta: { title: "Sign in", bare: true } }
|
|
168
232
|
];
|
|
169
233
|
const router = createRouter({ history: createWebHistory(), routes, scrollBehavior: shellScrollBehavior });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/shell-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test --test-concurrency=1"
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"./client/components/ShellPageActions": "./src/client/components/ShellPageActions.vue",
|
|
29
29
|
"./client/components/ShellPageAction": "./src/client/components/ShellPageAction.vue",
|
|
30
30
|
"./client/components/ShellListDetail": "./src/client/components/ShellListDetail.vue",
|
|
31
|
+
"./client/components/ShellUpButton": "./src/client/components/ShellUpButton.vue",
|
|
32
|
+
"./client/components/ShellPageTitle": "./src/client/components/ShellPageTitle.vue",
|
|
33
|
+
"./client/components/ShellPageActionsTarget": "./src/client/components/ShellPageActionsTarget.vue",
|
|
34
|
+
"./client/composables/useShellAppBar": "./src/client/composables/useShellAppBar.js",
|
|
31
35
|
"./client/composables/useShellLayoutState": "./src/client/composables/useShellLayoutState.js",
|
|
32
36
|
"./client/composables/useShellPageTitle": "./src/client/composables/useShellPageTitle.js",
|
|
33
37
|
"./client/composables/useShellWindowSizeClass": "./src/client/composables/useShellWindowSizeClass.js",
|
|
@@ -42,7 +46,7 @@
|
|
|
42
46
|
"@jskit-ai/architecture-inspector": "0.1.8"
|
|
43
47
|
},
|
|
44
48
|
"devDependencies": {
|
|
45
|
-
"@jskit-ai/material-web": "0.1.
|
|
49
|
+
"@jskit-ai/material-web": "0.1.2",
|
|
46
50
|
"@vue/compiler-sfc": "3.5.44"
|
|
47
51
|
},
|
|
48
52
|
"peerDependencies": {
|
|
@@ -88,6 +92,7 @@
|
|
|
88
92
|
"@jskit-ai/shell-web/client/navigation/useSurfaceRouteContext",
|
|
89
93
|
"@jskit-ai/shell-web/client/navigation/useShellNavigation",
|
|
90
94
|
"@jskit-ai/shell-web/client/navigation/documentNavigation",
|
|
95
|
+
"@jskit-ai/shell-web/client/composables/useShellAppBar",
|
|
91
96
|
"@jskit-ai/shell-web/client/composables/useShellLayoutState",
|
|
92
97
|
"@jskit-ai/shell-web/client/composables/useShellPageTitle",
|
|
93
98
|
"@jskit-ai/shell-web/client/composables/useShellWindowSizeClass",
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, inject, onBeforeUnmount, onMounted,
|
|
3
|
-
import { useRoute } from "vue-router";
|
|
2
|
+
import { computed, inject, onBeforeUnmount, onMounted, ref, useSlots } from "vue";
|
|
4
3
|
import { useDisplay } from "vuetify";
|
|
4
|
+
import { useShellAppBar } from "../composables/useShellAppBar.js";
|
|
5
5
|
import { useShellDrawer } from "../composables/useShellDrawer.js";
|
|
6
|
+
import { useShellOutletPlacements } from "../composables/useShellOutletPlacements.js";
|
|
6
7
|
import { useShellLayoutState } from "../composables/useShellLayoutState.js";
|
|
7
8
|
import { useShellPullToRefresh } from "../composables/useShellPullToRefresh.js";
|
|
8
9
|
import {
|
|
9
10
|
DEFAULT_SHELL_NAVIGATION_ITEM_SPACING,
|
|
10
11
|
DEFAULT_SHELL_RAIL_WIDTH
|
|
11
12
|
} from "../support/drawerWidth.js";
|
|
12
|
-
import { normalizeDesktopDrawerClosedMode } from "../support/drawerPresentation.js";
|
|
13
|
-
import { SHELL_PAGE_ACTIONS_ID, SHELL_PAGE_ACTIONS_TARGET_KEY } from "../support/navigationPresentation.js";
|
|
13
|
+
import { normalizeDesktopDrawerClosedMode, shellLayoutHasDrawer } from "../support/drawerPresentation.js";
|
|
14
14
|
import { resolveShellLayoutClass } from "../support/shellLayoutClass.js";
|
|
15
15
|
import { resolveWindowSizeClass } from "../support/windowSizeClass.js";
|
|
16
16
|
import { NO_SHELL_WEB_REFRESH_RUNTIME, SHELL_WEB_REFRESH_RUNTIME_KEY } from "../runtime/refreshRuntime.js";
|
|
17
|
-
import {
|
|
18
|
-
import { useShellNavigation, useShellNavigationRuntime } from "../navigation/useShellNavigation.js";
|
|
17
|
+
import { useShellNavigation } from "../navigation/useShellNavigation.js";
|
|
19
18
|
import ShellNavigationScope from "./ShellNavigationScope.vue";
|
|
20
19
|
import ShellOutlet from "./ShellOutlet.vue";
|
|
20
|
+
import ShellPageActionsTarget from "./ShellPageActionsTarget.vue";
|
|
21
|
+
import ShellPageTitle from "./ShellPageTitle.vue";
|
|
21
22
|
import ShellRouteTransition from "./ShellRouteTransition.vue";
|
|
23
|
+
import ShellUpButton from "./ShellUpButton.vue";
|
|
22
24
|
import { useJskitText } from "../i18n.js";
|
|
23
25
|
|
|
24
26
|
const { t, text } = useJskitText();
|
|
@@ -72,14 +74,11 @@ const {
|
|
|
72
74
|
resolvedSurfaceLabel
|
|
73
75
|
} = layoutState;
|
|
74
76
|
const display = useDisplay();
|
|
75
|
-
const route = useRoute();
|
|
76
77
|
/** @type {import("../types.js").ShellRefreshRuntime} */
|
|
77
78
|
const refreshRuntime = inject(SHELL_WEB_REFRESH_RUNTIME_KEY, NO_SHELL_WEB_REFRESH_RUNTIME);
|
|
78
|
-
const
|
|
79
|
-
const { canGoUp, up } = useShellNavigation();
|
|
79
|
+
const { canGoUp } = useShellNavigation();
|
|
80
80
|
const navigationToggle = ref(null);
|
|
81
81
|
const scrolled = ref(false);
|
|
82
|
-
let releaseShell = null;
|
|
83
82
|
|
|
84
83
|
const viewportWidth = computed(() => display.width.value);
|
|
85
84
|
const sizeClass = computed(() => resolveWindowSizeClass(display.width.value));
|
|
@@ -87,8 +86,27 @@ const layoutClass = computed(() => resolveShellLayoutClass(display.width.value))
|
|
|
87
86
|
const isCompactLayout = computed(() => layoutClass.value === "compact");
|
|
88
87
|
// Compact and medium windows open the drawer over the page; a medium window keeps a navigation rail beside it.
|
|
89
88
|
const modalLayout = computed(() => layoutClass.value !== "expanded");
|
|
89
|
+
// A surface draws only the navigation it has: no navigation bar without bar destinations, and no rail or drawer (nor
|
|
90
|
+
// its menu control) without menu destinations, as on an account surface whose shell has no navigation. The surface
|
|
91
|
+
// identity (a workspace switcher) keeps the drawer beside other navigation, as on a phone.
|
|
92
|
+
const slots = useSlots();
|
|
93
|
+
const primaryMenu = useShellOutletPlacements("shell-layout:primary-menu");
|
|
94
|
+
const secondaryMenu = useShellOutletPlacements("shell-layout:secondary-menu");
|
|
95
|
+
const identity = useShellOutletPlacements("shell-layout:top-left");
|
|
96
|
+
const bottomNavigation = useShellOutletPlacements("shell-layout:primary-bottom-nav");
|
|
97
|
+
const hasDrawer = computed(() =>
|
|
98
|
+
shellLayoutHasDrawer({
|
|
99
|
+
menuSlot: Boolean(slots.menu),
|
|
100
|
+
menuCount: primaryMenu.value.length + secondaryMenu.value.length,
|
|
101
|
+
identityCount: slots["top-left"] ? 1 : identity.value.length,
|
|
102
|
+
bottomNavigationCount: bottomNavigation.value.length
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
const showsBottomNavigation = computed(() => isCompactLayout.value && bottomNavigation.value.length > 0);
|
|
90
106
|
const showsMediumRail = computed(() =>
|
|
91
|
-
|
|
107
|
+
hasDrawer.value &&
|
|
108
|
+
layoutClass.value === "medium" &&
|
|
109
|
+
normalizeDesktopDrawerClosedMode(props.desktopDrawerClosedMode) === "rail"
|
|
92
110
|
);
|
|
93
111
|
const {
|
|
94
112
|
pullRefreshing,
|
|
@@ -107,43 +125,28 @@ const {
|
|
|
107
125
|
resolvedRailWidth
|
|
108
126
|
} = useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, layoutState });
|
|
109
127
|
|
|
110
|
-
const standardDrawerVisible = computed(() => !modalLayout.value && drawerPresentation.value.visible);
|
|
128
|
+
const standardDrawerVisible = computed(() => hasDrawer.value && !modalLayout.value && drawerPresentation.value.visible);
|
|
111
129
|
// The menu control sits in the rail or drawer header when one shows, otherwise first in the app bar of a top-level
|
|
112
130
|
// page; an inner page's leading slot is its Up arrow.
|
|
113
|
-
const toggleInAppBar = computed(() => !showsMediumRail.value && !standardDrawerVisible.value);
|
|
114
|
-
const
|
|
115
|
-
const source = navigationRuntime.pageTitleSource.value;
|
|
116
|
-
const runtimeTitle = typeof source === "function" ? source() : "";
|
|
117
|
-
return (
|
|
118
|
-
text(runtimeTitle) ||
|
|
119
|
-
text(resolvePageTitle(route.matched)) ||
|
|
120
|
-
text(props.title) ||
|
|
121
|
-
resolvedSurfaceLabel.value
|
|
122
|
-
);
|
|
123
|
-
});
|
|
131
|
+
const toggleInAppBar = computed(() => hasDrawer.value && !showsMediumRail.value && !standardDrawerVisible.value);
|
|
132
|
+
const fallbackTitle = computed(() => text(props.title) || resolvedSurfaceLabel.value);
|
|
124
133
|
const navigationStyle = computed(() => ({
|
|
125
134
|
"--shell-navigation-item-spacing": `${resolvedNavigationItemSpacing.value}px`,
|
|
126
135
|
"--shell-navigation-rail-width": `${resolvedRailWidth.value}px`
|
|
127
136
|
}));
|
|
128
137
|
|
|
129
|
-
|
|
138
|
+
useShellAppBar();
|
|
130
139
|
|
|
131
140
|
function updateScrolled() {
|
|
132
141
|
scrolled.value = window.scrollY > 0;
|
|
133
142
|
}
|
|
134
143
|
|
|
135
|
-
function goUp() {
|
|
136
|
-
void up();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
144
|
onMounted(() => {
|
|
140
|
-
releaseShell = navigationRuntime.attachShell();
|
|
141
145
|
window.addEventListener("scroll", updateScrolled, { passive: true });
|
|
142
146
|
updateScrolled();
|
|
143
147
|
});
|
|
144
148
|
|
|
145
149
|
onBeforeUnmount(() => {
|
|
146
|
-
releaseShell?.();
|
|
147
150
|
window.removeEventListener("scroll", updateScrolled);
|
|
148
151
|
});
|
|
149
152
|
</script>
|
|
@@ -159,19 +162,7 @@ onBeforeUnmount(() => {
|
|
|
159
162
|
:data-size-class="sizeClass"
|
|
160
163
|
>
|
|
161
164
|
<div class="shell-layout__app-bar-row">
|
|
162
|
-
<v-
|
|
163
|
-
v-if="canGoUp"
|
|
164
|
-
class="shell-layout__leading"
|
|
165
|
-
icon
|
|
166
|
-
variant="text"
|
|
167
|
-
color="on-surface"
|
|
168
|
-
data-testid="jskit-shell-back"
|
|
169
|
-
:aria-label="t('jskit.shell.actions.back')"
|
|
170
|
-
@click="goUp"
|
|
171
|
-
>
|
|
172
|
-
<v-icon icon="$arrowBack" />
|
|
173
|
-
<v-tooltip activator="parent" location="bottom" :text="t('jskit.shell.actions.back')" />
|
|
174
|
-
</v-btn>
|
|
165
|
+
<ShellUpButton v-if="canGoUp" class="shell-layout__leading" />
|
|
175
166
|
<v-btn
|
|
176
167
|
v-else-if="toggleInAppBar"
|
|
177
168
|
ref="navigationToggle"
|
|
@@ -187,13 +178,11 @@ onBeforeUnmount(() => {
|
|
|
187
178
|
/>
|
|
188
179
|
|
|
189
180
|
<div class="shell-layout__headline" :class="{ 'shell-layout__headline--leading': canGoUp || toggleInAppBar }">
|
|
190
|
-
<
|
|
191
|
-
{{ pageTitle }}
|
|
192
|
-
</h1>
|
|
181
|
+
<ShellPageTitle :title="fallbackTitle" />
|
|
193
182
|
<p v-if="props.subtitle" class="shell-layout__page-subtitle">{{ text(props.subtitle) }}</p>
|
|
194
183
|
</div>
|
|
195
184
|
|
|
196
|
-
<
|
|
185
|
+
<ShellPageActionsTarget />
|
|
197
186
|
|
|
198
187
|
<slot name="top-right" :surface="resolvedSurface">
|
|
199
188
|
<div class="shell-layout__top-right">
|
|
@@ -255,6 +244,7 @@ onBeforeUnmount(() => {
|
|
|
255
244
|
|
|
256
245
|
<!-- A modal drawer is the outermost layout item, so it opens from the window's edge over the rail and app bar. -->
|
|
257
246
|
<v-navigation-drawer
|
|
247
|
+
v-if="hasDrawer"
|
|
258
248
|
id="jskit-shell-drawer"
|
|
259
249
|
:model-value="drawerPresentation.visible"
|
|
260
250
|
class="shell-layout__drawer"
|
|
@@ -322,7 +312,7 @@ onBeforeUnmount(() => {
|
|
|
322
312
|
</v-main>
|
|
323
313
|
|
|
324
314
|
<v-bottom-navigation
|
|
325
|
-
v-if="
|
|
315
|
+
v-if="showsBottomNavigation"
|
|
326
316
|
class="shell-layout__bottom-nav"
|
|
327
317
|
data-testid="jskit-shell-bottom-nav"
|
|
328
318
|
bg-color="surface-container"
|
|
@@ -403,19 +393,6 @@ onBeforeUnmount(() => {
|
|
|
403
393
|
padding-inline-start: 4px;
|
|
404
394
|
}
|
|
405
395
|
|
|
406
|
-
.shell-layout__page-title {
|
|
407
|
-
color: rgb(var(--v-theme-on-surface));
|
|
408
|
-
font-size: 1.375rem;
|
|
409
|
-
font-weight: 400;
|
|
410
|
-
letter-spacing: 0;
|
|
411
|
-
line-height: 1.75rem;
|
|
412
|
-
margin: 0;
|
|
413
|
-
outline: none;
|
|
414
|
-
overflow: hidden;
|
|
415
|
-
text-overflow: ellipsis;
|
|
416
|
-
white-space: nowrap;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
396
|
.shell-layout__page-subtitle {
|
|
420
397
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
421
398
|
font-size: 0.75rem;
|
|
@@ -428,7 +405,6 @@ onBeforeUnmount(() => {
|
|
|
428
405
|
white-space: nowrap;
|
|
429
406
|
}
|
|
430
407
|
|
|
431
|
-
.shell-layout__page-actions,
|
|
432
408
|
.shell-layout__top-right {
|
|
433
409
|
align-items: center;
|
|
434
410
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
@@ -437,10 +413,6 @@ onBeforeUnmount(() => {
|
|
|
437
413
|
min-width: 0;
|
|
438
414
|
}
|
|
439
415
|
|
|
440
|
-
.shell-layout__page-actions:empty {
|
|
441
|
-
display: none;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
416
|
/* Navigation rail (medium windows, and expanded ones with the drawer collapsed): 80dp, menu control on top. */
|
|
445
417
|
.shell-layout__rail,
|
|
446
418
|
.shell-layout__drawer {
|