@jskit-ai/shell-web 0.2.55 → 0.2.57

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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - A medium or expanded top app bar folds the page actions it has no room for into its "More actions" menu, the last first, so the menu button and the bar's own items after the actions (the account menu, `shell-layout:top-right`) always stay on screen. Medium and wider bars showed every page action whatever its width, and the actions' box never shrank, so a record page with long labels pushed the rest of the bar out of the window: mobilynet's hosted service page at 768 px (Change size, Restart, "Restore into a new hosted service", Add tags) left the title no room and put More actions, with Delete and Update tooling, and the account button past the window's edge, where nobody could reach them. `ShellPageActionsTarget` now measures its bar's row as drawn and keeps the actions that fit beside the page title's whole width, after the bar's other items, as a compact bar already does for its top-right items; the others go into the menu in bar order, before its `overflow` actions. The primary action never folds, and the title is clipped only once nothing more can. It measures again when the bar is resized, its content changes (a title, an action's label, a page's actions) or fonts load, and a bar that widens shows its folded actions again. Until a fit, the actions' box clips the actions rather than push the items after it, and `ShellLayout`'s title box gives up its room first. A page whose actions fit beside its title, at 1280 px nearly every one, keeps them all in the bar. Where a title was clipped beside actions that still fitted, the title is now whole and the actions it needs the room of fold, the last first: a long title at 1280 px, or a record page with a long name at 768 px. A layout that draws its own top app bar with `useShellAppBar()` gets the same fold when `ShellPageActionsTarget` is an item of its bar's row; the room its title needs is read from the title's text, and an empty item that grows, such as a `v-spacer`, counts as room. Compact bars keep their rule: every action but the primary one is in the menu.
6
+ - `ShellLayout`'s drawer, rail and navigation bar no longer arrive under the page as it opens. An app whose navigation waits for context it loads after the page opens, such as its own session's permissions (mobilynet's console), had the drawer, the rail, the navigation bar and the app bar's menu control drawn when that arrived, so the content, the title and the FAB moved under a person's pointer: in the adaptive shell fixture, a page's button moved from x=24 to x=272 (x=104 beside the rail) and a click made where it showed landed on the drawer's or the rail's Machines link, and on a phone the FAB rose 80px and the click landed on the bar's Alerts tab. The placement context now says which part is still loading: `mergeContext(value, source, { pending: true })` (and `replaceContext`, and the runtime's `setContext(value, { source, pending })`), set before `ShellLayout` mounts and ended by the source's next call without `pending`, on success or failure; the runtime's `isContextPending()` reads it. Meanwhile `ShellLayout` lays its parts out unseen and untouchable, its main `aria-busy`, and then shows them all at once, where they stay, with nothing sliding or fading in. It waits once, as it mounts; with nothing pending it shows the page right after the render that mounts it, as before. A content-fitted drawer is fitted before the page first shows, once the page's fonts have arrived or after at most 100 ms, the longest block period the CSS Fonts spec recommends for `font-display: swap` (a page whose navigation was ready slid 61px as the drawer opened at 248px and was fitted a frame later, then 2px more when Roboto Flex replaced the fallback font). A font slower than that leaves the page shown in the fallback font and refits the drawer when it comes, as swap does; material-web now asks for its typefaces as the app boots, so they are usually in before the shell mounts, and a drawer that arrives after the shell mounted is watched and fitted as one drawn from the start. A placement runtime an app writes itself, such as a test double that mounts `ShellLayout`, needs `isContextPending()`.
5
7
  - **Breaking for apps' smoke checks:** a navigation bar destination takes `shortLabel`, the label a phone's bar shows (each destination there has about 68px); menus, the rail and the drawer keep `label`. A bar label wider than its slot now ends in an ellipsis inside it: the label could be 88px (5.5rem) wide in a 68px slot, so the centred button cut both its ends (mobilynet's "Metal servers" read "etal server"). The ellipsis is a fallback, not a pass: `runAdaptiveShellSmoke` and `runAdaptiveShellSmokeCase` now fail on any bar label that is cut or ends in an ellipsis, naming it, and `expectWholeNavigationBarLabels(bottomNavigation, expect)` (`@jskit-ai/shell-web/test/adaptiveShellSmoke`) runs the same check on any page. **An app whose bar labels run long must give those placements a `shortLabel` when it takes this JSKIT**, or its adaptive shell smoke fails. An app's own tab link wrapper that lists its props passes `shortLabel` on, as the application-shell pattern's `TabLinkItem` now does.
6
8
  - A UI kit, `@jskit-ai/shell-web/client/ui`, through which an application gives JSKIT's views its own design system's button, dialog frame and text classes: `provideShellUi(vueApp, { Button, Dialog, text })`, once before it mounts, and `useShellUi()` in a view, which returns them. `Button` takes `emphasis` (`high`, `medium`, `subtle`, `low`), `tone` (`accent`, `neutral`, `danger`), `size` (`default`, `large`), `type`, `disabled`, `pending`, `block`, `href` and `icon`, with its label in the default slot; `Dialog` takes `open` and `title`, emits `close`, and has a default slot for its body and an `actions` slot; `text` maps the text roles `title`, `heading`, `subheading`, `strong`, `lead`, `body` and `caption` to class names. A kit is partial: the roles and text roles it leaves out are Material 3's, `ShellUiButton` (a Vuetify button: flat, tonal, outlined and text, in primary, secondary and error) and `ShellUiDialog` (a 440 px `v-dialog` named by its title), and Material's type scale (`MATERIAL_TEXT`); an unknown role or text role, a role that is not a component and a class that is not a string throw. It exports Vue components, so shell-web's `optimizeDeps.exclude` names `@jskit-ai/shell-web/client/ui` and a dependency scan leaves it source, as it leaves `@jskit-ai/shell-web/client`.
7
9
  - `ShellErrorHost`'s banners no longer cover the page below a top app bar. They floated there over the top of the content, fixed and up to 1,120 px wide, and reserved no room, so on every page with an app bar a request recovery banner hid the content's first lines and took their clicks (Playwright: `.shell-error-host__banner` intercepts pointer events). They are now a top Vuetify layout item (`v-layout-item`) of their own measured height, placed after the app bar and the navigation, so `v-main` starts the content below them as it starts it below the app bar, and gives the room back when they close; content scrolled under them passes under them as under the app bar. On a surface without an app bar (sign-in) they still join the page flow above the content and publish `--shell-error-banners-inline-height`, as before. They keep their z-index (2600) and their look. An app that draws its own layout around `v-main` gets the same room, since Vuetify's layout reserves it.
@@ -4,18 +4,40 @@ 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 { useWebPlacementContext } from "@jskit-ai/shell-web/client/placement";
7
8
  import OwnBarLayout from "./OwnBarLayout.vue";
8
9
 
9
10
  const route = useRoute();
10
11
  const theme = useTheme();
12
+ const { mergeContext } = useWebPlacementContext();
11
13
  const bare = computed(() => route.meta.bare === true);
12
14
  const ownBar = computed(() => route.meta.ownBar === true);
13
15
  const surface = computed(() => {
14
16
  if (route.path.startsWith("/w/")) return "admin";
15
17
  if (route.path.startsWith("/solo")) return "solo";
18
+ if (route.path.startsWith("/console")) return "console";
16
19
  return route.path.startsWith("/account") ? "account" : "home";
17
20
  });
18
- const surfaceLabel = computed(() => ({ admin: "Admin", account: "Account" })[surface.value] || "Home");
21
+ const surfaceLabel = computed(() => ({ admin: "Admin", account: "Account", console: "Console" })[surface.value] || "Home");
22
+
23
+ // The console's destinations depend on its session's permissions (consolePermissions), which load after the page
24
+ // opens, as an app's own session does (mobilynet's console): the context says they are pending until they arrive, or
25
+ // until the request fails, when the console has none.
26
+ async function loadConsoleSession() {
27
+ let permissions = [];
28
+ try {
29
+ const response = await fetch("/api/fixture/console-session", { headers: { accept: "application/json" } });
30
+ permissions = response.ok ? (await response.json()).permissions : [];
31
+ } catch {
32
+ permissions = [];
33
+ }
34
+ mergeContext({ consolePermissions: permissions }, "fixture.console-session");
35
+ }
36
+
37
+ if (route.path.startsWith("/console")) {
38
+ mergeContext({ consolePermissions: [] }, "fixture.console-session", { pending: true });
39
+ void loadConsoleSession();
40
+ }
19
41
  const themeMode = computed(() => route.query.theme === "dark" ? "dark" : "light");
20
42
  const railWidth = computed(() => Number(route.query.railWidth) || undefined);
21
43
  const navigationItemSpacing = computed(() => Number(route.query.navigationItemSpacing) || undefined);
@@ -0,0 +1,17 @@
1
+ <script setup>
2
+ import ShellPrimaryAction from "../../../src/client/components/ShellPrimaryAction.vue";
3
+
4
+ // A console page, whose navigation waits for the console session's permissions (App.vue). Its Builds button and its
5
+ // New build action are what a person reaches for as the page opens; each press is listed in window.__fixtureConsolePresses.
6
+ function press(name) {
7
+ window.__fixtureConsolePresses = [...(window.__fixtureConsolePresses || []), name];
8
+ }
9
+ </script>
10
+
11
+ <template>
12
+ <section>
13
+ <p>Builds run on the console's machines.</p>
14
+ <v-btn data-testid="fixture-console-builds" variant="tonal" @click="press('builds')">Builds</v-btn>
15
+ <ShellPrimaryAction label="New build" data-testid="fixture-console-new-build" @click="press('new-build')" />
16
+ </section>
17
+ </template>
@@ -0,0 +1,41 @@
1
+ <script setup>
2
+ import { ref } from "vue";
3
+ import { 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
+
8
+ // A record page whose labelled actions take most of a medium window's bar, as mobilynet's hosted service page does,
9
+ // then two actions of the overflow menu's own. `?title=` sets the page's title.
10
+ const route = useRoute();
11
+ const log = ref([]);
12
+
13
+ useShellPageTitle(() => String(route.query.title || "Hosted service"));
14
+ </script>
15
+
16
+ <template>
17
+ <section class="pa-4">
18
+ <ShellPageActions>
19
+ <ShellPageAction icon="$tune" label="Change size" data-testid="fixture-long-action-size" @click="log.push('size')" />
20
+ <ShellPageAction icon="$refresh" label="Restart" data-testid="fixture-long-action-restart" @click="log.push('restart')" />
21
+ <ShellPageAction
22
+ icon="$history"
23
+ label="Restore into a new hosted service"
24
+ data-testid="fixture-long-action-restore"
25
+ @click="log.push('restore')"
26
+ />
27
+ <ShellPageAction icon="$edit" label="Add tags" data-testid="fixture-long-action-tags" @click="log.push('tags')" />
28
+ <ShellPageAction
29
+ overflow
30
+ icon="$delete"
31
+ label="Delete"
32
+ color="error"
33
+ data-testid="fixture-long-action-delete"
34
+ @click="log.push('delete')"
35
+ />
36
+ <ShellPageAction overflow icon="$refresh" label="Update tooling" data-testid="fixture-long-action-tooling" @click="log.push('tooling')" />
37
+ </ShellPageActions>
38
+
39
+ <p data-testid="fixture-action-log">{{ log.join(",") }}</p>
40
+ </section>
41
+ </template>
@@ -15,10 +15,12 @@ import ButtonContrastPage from "./ButtonContrastPage.vue";
15
15
  import ButtonStatesPage from "./ButtonStatesPage.vue";
16
16
  import ButtonsPage from "./ButtonsPage.vue";
17
17
  import ComponentsPage from "./ComponentsPage.vue";
18
+ import ConsolePage from "./ConsolePage.vue";
18
19
  import { adminTheme, theme } from "./theme/index.js";
19
20
  import RecordListPage from "./RecordListPage.vue";
20
21
  import RecordPage from "./RecordPage.vue";
21
22
  import FeedbackPage from "./FeedbackPage.vue";
23
+ import LongActionsPage from "./LongActionsPage.vue";
22
24
  import NotesPage from "./NotesPage.vue";
23
25
  import PendingActionsPage from "./PendingActionsPage.vue";
24
26
  import DialogFeedbackPage from "./DialogFeedbackPage.vue";
@@ -197,6 +199,43 @@ const placements = [
197
199
  order: 10,
198
200
  props: { label: "Home", surface: "solo", scopedSuffix: "/", unscopedSuffix: "/", exact: true }
199
201
  },
202
+ // The console: its Console entry is everyone's, and each other destination needs a permission of the console
203
+ // session, which loads after the page opens (App.vue).
204
+ {
205
+ id: "fixture.console.entry",
206
+ target: "shell.secondary-nav",
207
+ kind: "link",
208
+ surfaces: ["console"],
209
+ order: 100,
210
+ props: { label: "Console", surface: "console", scopedSuffix: "/", unscopedSuffix: "/", exact: true }
211
+ },
212
+ {
213
+ id: "fixture.console.builds",
214
+ target: "shell.primary-nav",
215
+ kind: "link",
216
+ surfaces: ["console"],
217
+ order: 10,
218
+ when: ({ consolePermissions = [] }) => consolePermissions.includes("builds.read"),
219
+ props: { label: "Builds", surface: "console", scopedSuffix: "/builds", unscopedSuffix: "/builds" }
220
+ },
221
+ {
222
+ id: "fixture.console.machines",
223
+ target: "shell.primary-nav",
224
+ kind: "link",
225
+ surfaces: ["console"],
226
+ order: 20,
227
+ when: ({ consolePermissions = [] }) => consolePermissions.includes("machines.read"),
228
+ props: { label: "Machines", surface: "console", scopedSuffix: "/machines", unscopedSuffix: "/machines" }
229
+ },
230
+ {
231
+ id: "fixture.console.alerts",
232
+ target: "shell.primary-nav",
233
+ kind: "link",
234
+ surfaces: ["console"],
235
+ order: 30,
236
+ when: ({ consolePermissions = [] }) => consolePermissions.includes("alerts.read"),
237
+ props: { label: "Alerts", surface: "console", scopedSuffix: "/alerts", unscopedSuffix: "/alerts" }
238
+ },
200
239
  {
201
240
  id: "fixture.help",
202
241
  target: "shell.secondary-nav",
@@ -299,13 +338,14 @@ placementRuntime.setContext({
299
338
  surfaceConfig: {
300
339
  tenancyMode: "path",
301
340
  defaultSurfaceId: "home",
302
- enabledSurfaceIds: ["home", "admin", "account", "solo"],
341
+ enabledSurfaceIds: ["home", "admin", "account", "solo", "console"],
303
342
  surfacesById: {
304
343
  home: { id: "home", routeBase: "/home", enabled: true },
305
344
  admin: { id: "admin", routeBase: "/w/:workspaceSlug/admin", enabled: true },
306
345
  // A surface whose shell has no navigation, as an account page's.
307
346
  account: { id: "account", routeBase: "/account", enabled: true },
308
- solo: { id: "solo", routeBase: "/solo", enabled: true }
347
+ solo: { id: "solo", routeBase: "/solo", enabled: true },
348
+ console: { id: "console", routeBase: "/console", enabled: true }
309
349
  }
310
350
  }
311
351
  });
@@ -355,6 +395,8 @@ const routes = [
355
395
  { path: "/home/components", component: ComponentsPage, meta: { jskit: { title: "Components" } } },
356
396
  { path: "/home/actions", component: ActionsPage, meta: { jskit: { title: "Actions" } } },
357
397
  { path: "/home/actions/new", component: ActionsFormPage, meta: { jskit: { title: "New entry", parent: "/actions" } } },
398
+ // Labelled actions wider than a medium window's bar holds beside the title.
399
+ { path: "/home/long-actions", component: LongActionsPage, meta: { jskit: { title: "Hosted service" } } },
358
400
  // Actions whose work the test holds, to check they keep keyboard focus while it runs.
359
401
  { path: "/home/pending", component: PendingActionsPage, meta: { jskit: { title: "Pending actions" } } },
360
402
  { path: "/home/pending-dialog", component: () => import("./PendingDialogPage.vue"), meta: { jskit: { title: "Invites" } } },
@@ -362,10 +404,12 @@ const routes = [
362
404
  { path: "/home/notes", component: NotesPage, meta: { jskit: { title: "Notes" } } },
363
405
  { path: "/home/studio", component: StudioPage, meta: { ownBar: true, jskit: { title: "Studio" } } },
364
406
  { path: "/home/studio/:id", component: StudioPage, meta: { ownBar: true, jskit: { parent: "/studio" } } },
407
+ { path: "/home/studio-actions", component: LongActionsPage, meta: { ownBar: true, jskit: { title: "Hosted service" } } },
365
408
  { path: "/home/:section?", component: ScreenPage, meta: { title: "Home surface" } },
366
409
  { path: "/w/:workspaceSlug/admin/:section?", component: ScreenPage, meta: { title: "Admin surface" } },
367
410
  { path: "/help", component: ScreenPage, meta: { title: "Help and support" } },
368
411
  { path: "/solo", component: ScreenPage, meta: { title: "Solo", jskit: { title: "Solo" } } },
412
+ { path: "/console/:section?", component: ConsolePage, meta: { jskit: { title: "Builds" } } },
369
413
  { path: "/solo/settings", component: DialogFeedbackPage, meta: { jskit: { title: "Settings", parent: "/" } } },
370
414
  { path: "/home/reports", redirect: "/home/reports/overview" },
371
415
  { path: "/home/reports/:section", component: ReportsPage, meta: { jskit: { title: "Reports" } } },
@@ -424,5 +468,18 @@ app.provide(SHELL_WEB_REFRESH_RUNTIME_KEY, {
424
468
  }
425
469
  });
426
470
  useShellLayoutStore(pinia).setDrawerDefaultOpen(true);
471
+ // Opens the layout's supporting content (the side panel beside a medium or wider page) with `title`, as a page does.
472
+ window.__shellFixtureOpenSupportingContent = (title) => useShellLayoutStore(pinia).openSupportingContent({ title });
427
473
  await router.isReady();
474
+ // The fixture boots as an app does. An app makes its Vuetify options (createMaterialVuetifyOptions) before its shell
475
+ // bootstrap, whose bootstrapClientShellApp awaits bootClientModules, onAfterModulesBootstrapped and router.isReady
476
+ // before app.mount (kernel/client/shellBootstrap.js), and the requests the page has started go out while it waits.
477
+ // This one awaited boot request stands for those awaits; any answer will do.
478
+ await fetch("/api/fixture/boot").catch(() => null);
479
+ // The moment the shell mounts, and where the page's Roboto Flex faces stand then, which the late-navigation test
480
+ // compares with the font file's request.
481
+ window.__fixtureMount = {
482
+ at: performance.now(),
483
+ robotoFlex: [...document.fonts].filter((face) => face.family.includes("Roboto Flex")).map((face) => face.status)
484
+ };
428
485
  app.mount("#app");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/shell-web",
3
- "version": "0.2.55",
3
+ "version": "0.2.57",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -51,7 +51,7 @@
51
51
  "@jskit-ai/architecture-inspector": "0.1.34"
52
52
  },
53
53
  "devDependencies": {
54
- "@jskit-ai/material-web": "0.1.14",
54
+ "@jskit-ai/material-web": "0.1.16",
55
55
  "@vue/compiler-sfc": "3.5.44"
56
56
  },
57
57
  "peerDependencies": {
@@ -7,6 +7,7 @@ import { useShellInertBehindDialog } from "../composables/useShellInertBehindDia
7
7
  import { useShellOutletPlacements } from "../composables/useShellOutletPlacements.js";
8
8
  import { useShellLayoutState } from "../composables/useShellLayoutState.js";
9
9
  import { useShellPullToRefresh } from "../composables/useShellPullToRefresh.js";
10
+ import { useShellSettled } from "../composables/useShellSettled.js";
10
11
  import { useShellTopRightOverflow } from "../composables/useShellTopRightOverflow.js";
11
12
  import {
12
13
  DEFAULT_SHELL_NAVIGATION_ITEM_SPACING,
@@ -135,8 +136,11 @@ const {
135
136
  handleDrawerVisibilityChange,
136
137
  resolvedDrawerWidth,
137
138
  resolvedNavigationItemSpacing,
138
- resolvedRailWidth
139
- } = useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, layoutState });
139
+ resolvedRailWidth,
140
+ settleDrawerWidth
141
+ } = useShellDrawer({ props, hasDrawer, modalLayout, viewportWidth, navigationToggle, layoutState });
142
+ // Each part shows only once the placement context its navigation reads has arrived, its drawer fitted, where it stays.
143
+ const { settlingClass, waiting } = useShellSettled({ settleNavigation: settleDrawerWidth });
140
144
 
141
145
  const standardDrawerVisible = computed(() => hasDrawer.value && !modalLayout.value && drawerPresentation.value.visible);
142
146
  // The menu control sits in the rail or drawer header when one shows, otherwise first in the app bar of a top-level
@@ -193,7 +197,7 @@ onBeforeUnmount(() => {
193
197
  flat
194
198
  :height="64"
195
199
  class="shell-layout__app-bar"
196
- :class="`shell-layout--size-${sizeClass}`"
200
+ :class="[`shell-layout--size-${sizeClass}`, settlingClass]"
197
201
  data-shell-page
198
202
  data-testid="jskit-shell-app-bar"
199
203
  :data-size-class="sizeClass"
@@ -272,6 +276,7 @@ onBeforeUnmount(() => {
272
276
  <v-navigation-drawer
273
277
  v-if="showsMediumRail"
274
278
  class="shell-layout__rail"
279
+ :class="settlingClass"
275
280
  data-shell-page
276
281
  data-testid="jskit-shell-rail"
277
282
  data-presentation="rail"
@@ -308,6 +313,7 @@ onBeforeUnmount(() => {
308
313
  id="jskit-shell-drawer"
309
314
  :model-value="drawerPresentation.visible"
310
315
  class="shell-layout__drawer"
316
+ :class="settlingClass"
311
317
  data-shell-page
312
318
  data-testid="jskit-shell-drawer"
313
319
  :data-layout="layoutClass"
@@ -367,7 +373,7 @@ onBeforeUnmount(() => {
367
373
  </slot>
368
374
  </v-navigation-drawer>
369
375
 
370
- <v-main class="bg-background" data-shell-page>
376
+ <v-main class="bg-background" :class="settlingClass" :aria-busy="waiting ? 'true' : undefined" data-shell-page>
371
377
  <div class="shell-layout__content" :class="{ 'shell-layout__content--compact': isCompactLayout }">
372
378
  <ShellRouteTransition>
373
379
  <slot />
@@ -378,6 +384,7 @@ onBeforeUnmount(() => {
378
384
  <v-bottom-navigation
379
385
  v-if="showsBottomNavigation"
380
386
  class="shell-layout__bottom-nav"
387
+ :class="settlingClass"
381
388
  data-shell-page
382
389
  data-testid="jskit-shell-bottom-nav"
383
390
  bg-color="surface-container"
@@ -451,8 +458,9 @@ onBeforeUnmount(() => {
451
458
  flex: 0 0 auto;
452
459
  }
453
460
 
461
+ /* The title's box takes the room the bar's items leave, and gives it up before the page actions are clipped. */
454
462
  .shell-layout__headline {
455
- flex: 1 1 auto;
463
+ flex: 1 1 0;
456
464
  min-width: 0;
457
465
  padding-inline: 12px 4px;
458
466
  }
@@ -699,4 +707,23 @@ onBeforeUnmount(() => {
699
707
  line-height: 1rem;
700
708
  white-space: nowrap;
701
709
  }
710
+
711
+ /* While the shell waits for the context its navigation reads (useShellSettled), its parts are laid out unseen and
712
+ untouchable, and nothing in them animates into place, nor in the pass that shows them. Last, to hold over each
713
+ part's own rules. */
714
+ .shell-layout--waiting {
715
+ opacity: 0;
716
+ }
717
+
718
+ .shell-layout--waiting,
719
+ .shell-layout--waiting :deep(*) {
720
+ pointer-events: none;
721
+ }
722
+
723
+ .shell-layout--waiting,
724
+ .shell-layout--waiting :deep(*),
725
+ .shell-layout--placing,
726
+ .shell-layout--placing :deep(*) {
727
+ transition: none;
728
+ }
702
729
  </style>
@@ -8,7 +8,8 @@ import { NO_SHELL_PAGE_ACTIONS_REGISTRY, SHELL_PAGE_ACTIONS_REGISTRY_KEY } from
8
8
  // One page action in the top app bar. On compact windows a secondary action shows as an icon button named by its
9
9
  // label; the page's primary action (`primary`, at most one) keeps its label as a filled button. In a bar that owns its
10
10
  // actions (ShellLayout, or a layout that calls useShellAppBar()), an `overflow` action is an item of the bar's
11
- // overflow menu, and on compact windows every action but the primary one joins it.
11
+ // overflow menu; on compact windows every action but the primary one joins it, and on wider ones the last of those
12
+ // that don't fit beside the whole title.
12
13
  // Attributes such as `type="submit"` and `form` (so an app bar Save can submit the page's form), `target`,
13
14
  // `data-testid` or `aria-*` land on the button, or on the menu item, in every form.
14
15
  // While its action runs (`pending`, or `loading` with Vuetify's progress indicator in place of the label) the button
@@ -1,14 +1,19 @@
1
1
  <script setup>
2
2
  import { computed, inject, mergeProps, ref, useSlots, watch } from "vue";
3
+ import { useShellPageActionsFold } from "../composables/useShellPageActionsFold.js";
4
+ import { useShellWindowSizeClass } from "../composables/useShellWindowSizeClass.js";
3
5
  import { useJskitText } from "../i18n.js";
4
6
  import { SHELL_PAGE_ACTIONS_ID } from "../support/navigationPresentation.js";
5
7
  import { NO_SHELL_PAGE_ACTIONS_REGISTRY, SHELL_PAGE_ACTIONS_REGISTRY_KEY } from "../support/pageActions.js";
6
8
 
7
9
  // Where the current page's ShellPageActions show: after the page title in the top app bar, followed by the bar's
8
- // overflow menu (Material 3's trailing "More actions" menu) when an action goes there. Its `menu` slot adds the
9
- // bar's own items that don't fit (on a phone, ShellLayout's top-right items) below the actions. The menu keeps the slot
10
- // mounted while it is closed, so an item there that does more than draw a button keeps working. ShellLayout's bar has
11
- // it; a layout that draws its own top app bar renders it once there and calls useShellAppBar().
10
+ // overflow menu (Material 3's trailing "More actions" menu) when an action goes there. On medium and expanded windows
11
+ // the actions that don't fit beside the whole title go there, the last first (useShellPageActionsFold), and until
12
+ // they have the actions' box clips them, so the menu button and the bar's items after it stay on screen. Its `menu`
13
+ // slot adds the bar's own items that don't fit (on a phone, ShellLayout's top-right items) below the actions. The menu
14
+ // keeps the slot mounted while it is closed, so an item there that does more than draw a button keeps working.
15
+ // ShellLayout's bar has it; a layout that draws its own top app bar renders it once there, as an item of the bar's
16
+ // row, and calls useShellAppBar().
12
17
  const props = defineProps({
13
18
  // Whether the `menu` slot holds items now. A layout that moves its items in and out of the slot keeps it and says
14
19
  // when it holds any: with none, the menu shows only the page's actions, or no menu button without them.
@@ -25,12 +30,17 @@ const menuEntries = registry.menuEntries;
25
30
  const moreLabel = computed(() => t("jskit.shell.actions.more"));
26
31
  const slots = useSlots();
27
32
  const menuOpen = ref(false);
33
+ const actionsBox = ref(null);
34
+ const { isCompact } = useShellWindowSizeClass();
35
+ const folds = computed(() => !isCompact.value);
28
36
 
29
37
  // Read as the menu renders, since slots are not reactive.
30
38
  function showsItems() {
31
39
  return props.menuItems && Boolean(slots.menu);
32
40
  }
33
41
 
42
+ useShellPageActionsFold({ enabled: folds, registry, target: actionsBox, ownMenu: showsItems });
43
+
34
44
  function showsMenu() {
35
45
  return menuEntries.value.length > 0 || showsItems();
36
46
  }
@@ -61,7 +71,12 @@ function itemProps(entry) {
61
71
  </script>
62
72
 
63
73
  <template>
64
- <div :id="SHELL_PAGE_ACTIONS_ID" class="shell-page-actions-target" />
74
+ <div
75
+ :id="SHELL_PAGE_ACTIONS_ID"
76
+ ref="actionsBox"
77
+ class="shell-page-actions-target"
78
+ :class="{ 'shell-page-actions-target--folds': folds }"
79
+ />
65
80
  <v-menu v-if="menuEntries.length > 0 || slots.menu" v-model="menuOpen" location="bottom end" :eager="Boolean(slots.menu)">
66
81
  <template #activator="{ props: menuProps }">
67
82
  <v-tooltip v-if="showsMenu()" :text="moreLabel" location="bottom">
@@ -114,6 +129,12 @@ function itemProps(entry) {
114
129
  min-width: 0;
115
130
  }
116
131
 
132
+ /* Beside a title that leaves too little room, the actions that don't fit yet are clipped, not the items after them. */
133
+ .shell-page-actions-target--folds {
134
+ flex: 0 1 auto;
135
+ overflow-x: clip;
136
+ }
137
+
117
138
  .shell-page-actions-target:empty {
118
139
  display: none;
119
140
  }
@@ -19,6 +19,11 @@ import {
19
19
  resolveMaterialDrawerWidth
20
20
  } from "../support/drawerWidth.js";
21
21
 
22
+ // How long the drawer waits for the page's fonts as the shell settles, before it fits in the fallback font: the longest
23
+ // block period the CSS Fonts spec recommends for font-display: swap (Chromium's is none). material-web asks for its
24
+ // typefaces as the app boots, so they are usually in by then.
25
+ const FONT_WAIT_MS = 100;
26
+
22
27
  // VNavigationDrawer has no root element of its own to reach through a template ref.
23
28
  function navigationDrawerElement() {
24
29
  return document.getElementById("jskit-shell-drawer");
@@ -31,12 +36,14 @@ function navigationDrawerElement() {
31
36
  * "material" (Material 3's full width) or a number, which fixes it.
32
37
  * @param {object} options
33
38
  * @param {{ desktopDrawerClosedMode: string, drawerWidth: number | string | null, railWidth: number, navigationItemSpacing: number }} options.props
39
+ * @param {import("vue").Ref<boolean>} options.hasDrawer Whether the shell draws the drawer, which can arrive after it
40
+ * mounted, with its destinations.
34
41
  * @param {import("vue").Ref<boolean>} options.modalLayout
35
42
  * @param {import("vue").Ref<number>} options.viewportWidth
36
43
  * @param {import("vue").Ref<{ $el: HTMLElement } | null>} options.navigationToggle
37
44
  * @param {ReturnType<typeof import("./useShellLayoutState.js").useShellLayoutState>} options.layoutState
38
45
  */
39
- function useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, layoutState }) {
46
+ function useShellDrawer({ props, hasDrawer, modalLayout, viewportWidth, navigationToggle, layoutState }) {
40
47
  const {
41
48
  drawerDefaultOpen,
42
49
  drawerOpen,
@@ -47,6 +54,8 @@ function useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, l
47
54
  const measuredDrawerWidth = ref(DEFAULT_SHELL_DRAWER_WIDTH);
48
55
  let drawerContentObserver = null;
49
56
  let drawerMeasurementFrame = null;
57
+ // Ends the settle's wait for the page's fonts while it lasts.
58
+ let endFontWait = null;
50
59
  let shellMounted = false;
51
60
 
52
61
  const drawerPresentation = computed(() => resolveShellDrawerPresentation({
@@ -87,6 +96,8 @@ function useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, l
87
96
  watch(drawerPresentation, scheduleDrawerWidthMeasurement, { flush: "post" });
88
97
  watch(resolvedSurface, scheduleDrawerWidthMeasurement, { flush: "post" });
89
98
  watch(resolvedNavigationItemSpacing, scheduleDrawerWidthMeasurement, { flush: "post" });
99
+ // A drawer that arrives after the shell mounted is watched and fitted as one drawn from the start is.
100
+ watch(hasDrawer, initializeDrawerMeasurement, { flush: "post" });
90
101
 
91
102
  onMounted(attachShellListeners);
92
103
  onBeforeUnmount(detachShellListeners);
@@ -108,9 +119,9 @@ function useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, l
108
119
  document.fonts.removeEventListener("loadingdone", scheduleDrawerWidthMeasurement);
109
120
  drawerContentObserver?.disconnect();
110
121
  drawerContentObserver = null;
111
- if (drawerMeasurementFrame !== null) {
112
- window.cancelAnimationFrame(drawerMeasurementFrame);
113
- drawerMeasurementFrame = null;
122
+ cancelDrawerWidthMeasurement();
123
+ if (endFontWait) {
124
+ endFontWait();
114
125
  }
115
126
  }
116
127
 
@@ -144,35 +155,86 @@ function useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, l
144
155
  }
145
156
 
146
157
  function initializeDrawerMeasurement() {
147
- const drawerElement = navigationDrawerElement();
148
- if (drawerElement) {
149
- drawerContentObserver?.disconnect();
150
- drawerContentObserver = new MutationObserver(scheduleDrawerWidthMeasurement);
151
- drawerContentObserver.observe(drawerElement.querySelector(".v-navigation-drawer__content") || drawerElement, {
152
- childList: true,
153
- characterData: true,
154
- subtree: true
155
- });
156
- }
158
+ observeDrawerContent();
157
159
  scheduleDrawerWidthMeasurement();
158
160
  }
159
161
 
160
- function scheduleDrawerWidthMeasurement() {
161
- if (
162
- !shellMounted ||
163
- fixedDrawerWidth.value ||
164
- !drawerPresentation.value.visible ||
165
- drawerPresentation.value.rail
166
- ) {
162
+ function observeDrawerContent() {
163
+ drawerContentObserver?.disconnect();
164
+ drawerContentObserver = null;
165
+ const drawerElement = navigationDrawerElement();
166
+ if (!shellMounted || !drawerElement) {
167
167
  return;
168
168
  }
169
+ drawerContentObserver = new MutationObserver(scheduleDrawerWidthMeasurement);
170
+ drawerContentObserver.observe(drawerElement.querySelector(".v-navigation-drawer__content") || drawerElement, {
171
+ childList: true,
172
+ characterData: true,
173
+ subtree: true
174
+ });
175
+ }
176
+
177
+ // Only an open drawer that fits its content is measured: a fixed width, a closed drawer and the rail are not.
178
+ function drawerFitsContentNow() {
179
+ return shellMounted &&
180
+ !fixedDrawerWidth.value &&
181
+ drawerPresentation.value.visible &&
182
+ !drawerPresentation.value.rail;
183
+ }
169
184
 
185
+ function cancelDrawerWidthMeasurement() {
170
186
  if (drawerMeasurementFrame !== null) {
171
187
  window.cancelAnimationFrame(drawerMeasurementFrame);
188
+ drawerMeasurementFrame = null;
189
+ }
190
+ }
191
+
192
+ function scheduleDrawerWidthMeasurement() {
193
+ if (!drawerFitsContentNow()) {
194
+ return;
172
195
  }
196
+
197
+ cancelDrawerWidthMeasurement();
173
198
  drawerMeasurementFrame = window.requestAnimationFrame(updateMeasuredDrawerWidth);
174
199
  }
175
200
 
201
+ /**
202
+ * Fits the drawer to its content now, as the shell settles (useShellSettled), instead of at the next frame, so the
203
+ * page first shows beside the drawer's final width rather than sliding to it. It measures once the fonts the page is
204
+ * loading have arrived, or after FONT_WAIT_MS in the fallback font: labels measured in the fallback would refit the
205
+ * drawer, and move the page, when the font came, and a slow font must not keep the page unseen.
206
+ */
207
+ async function settleDrawerWidth() {
208
+ observeDrawerContent();
209
+ if (!drawerFitsContentNow()) {
210
+ return;
211
+ }
212
+ // Laying the page out asks for the fonts its text uses, so `ready` waits for them.
213
+ navigationDrawerElement()?.getBoundingClientRect();
214
+ await fontsOrFontWait();
215
+ if (!drawerFitsContentNow()) {
216
+ return;
217
+ }
218
+ cancelDrawerWidthMeasurement();
219
+ updateMeasuredDrawerWidth();
220
+ }
221
+
222
+ // Resolves when the page's fonts are in, after FONT_WAIT_MS, or when the shell unmounts, whichever comes first.
223
+ function fontsOrFontWait() {
224
+ return new Promise((resolve) => {
225
+ const timer = window.setTimeout(end, FONT_WAIT_MS);
226
+ function end() {
227
+ window.clearTimeout(timer);
228
+ if (endFontWait === end) {
229
+ endFontWait = null;
230
+ }
231
+ resolve();
232
+ }
233
+ endFontWait = end;
234
+ void document.fonts.ready.then(end);
235
+ });
236
+ }
237
+
176
238
  function updateMeasuredDrawerWidth() {
177
239
  drawerMeasurementFrame = null;
178
240
  const drawerElement = navigationDrawerElement();
@@ -199,7 +261,8 @@ function useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, l
199
261
  handleDrawerVisibilityChange,
200
262
  resolvedDrawerWidth,
201
263
  resolvedNavigationItemSpacing,
202
- resolvedRailWidth
264
+ resolvedRailWidth,
265
+ settleDrawerWidth
203
266
  };
204
267
  }
205
268