@jskit-ai/shell-web 0.2.27 → 0.2.29

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
+ - On a compact window (under 600 px), a message that shows while a dialog, a bottom sheet or a temporary navigation drawer is open sits at the top of the window, clear of the actions it reports on; it keeps that place until it closes. Elsewhere and on wider windows messages stay at the bottom start.
6
+ - A message showing over a dialog no longer takes Escape and the browser's Back from it: the snackbar stays out of Vuetify's overlay stack (`_disable-global-stack`), as Vuetify's tooltips do, so Escape and Back close the dialog under it. This uses a private Vuetify prop until Vuetify leaves snackbars off the stack itself (reported as https://github.com/vuetifyjs/vuetify/issues/23392).
5
7
  - The "Test copy" banner has no accessible label any more: it is a note read by its visible "Test copy", with "Test copy: emails, messages and payments are simulated, not sent." as its `aria-description`. The label made it a labelled element, so an application's browser test looking up its Email field with Playwright's inexact `page.getByLabel("Email")` found the banner too and failed strict mode.
6
8
  - A page whose server simulates side effects (`SIDE_EFFECTS` is not `live`) shows a small amber "Test copy" tab at the top centre, with no application code: the shell adds it at boot from the page's `jskit-side-effects` meta tag and removes it at shutdown. It never takes a click or a tap, reads the same in light and dark themes, and its accessible label says emails, messages and payments are simulated. A live page, or a page that names no setting (a mobile bundle), has none.
7
9
  - Menu and tab links, and the navigation bar's swipe destinations, take the current surface's params from the URL when the route declares none, as on the not-found route that catches any path: on `/w/acme/no-such-page` a link to the workspace surface goes to `/w/acme/...`. They threw "Missing required surface route params" on every render instead, so a workspace surface's not-found page showed that error in an alert, drew its drawer without destinations and logged the error again each time the shell redrew. The route's own params still win, and a link to a surface whose params neither the route nor the URL holds still throws.
@@ -0,0 +1,48 @@
1
+ <script setup>
2
+ import { computed, ref } from "vue";
3
+ import { RouterLink, useRoute } from "vue-router";
4
+ import { useShellWebErrorRuntime } from "@jskit-ai/shell-web/client/error";
5
+
6
+ // A dialog whose Save reports a message that stays until dismissed, with the dialog still open. Its surface draws no
7
+ // navigation bar, so on a phone the dialog's actions sit at the bottom of the window, where a snackbar shows. Next
8
+ // step adds a history entry, so Back has one to return to (Vuetify's overlays ignore a Back to the page's first entry,
9
+ // which the router replaced as it started).
10
+ const errorRuntime = useShellWebErrorRuntime();
11
+ const route = useRoute();
12
+ const dialog = ref(false);
13
+ const nextStep = computed(() => ({ query: { step: String(Number(route.query.step || 0) + 1) } }));
14
+
15
+ function save() {
16
+ errorRuntime.report({
17
+ source: "fixture.dialog-feedback.save",
18
+ message: "Integration settings saved.",
19
+ intent: "action-feedback",
20
+ severity: "success",
21
+ channel: "snackbar",
22
+ persist: true
23
+ });
24
+ }
25
+ </script>
26
+
27
+ <template>
28
+ <section class="d-flex ga-2 pa-4">
29
+ <v-btn variant="text" data-testid="fixture-open-dialog" @click="dialog = true">Edit settings</v-btn>
30
+ <RouterLink :to="nextStep">Next step</RouterLink>
31
+ <v-dialog v-model="dialog" max-width="560" scrollable>
32
+ <v-card title="Integration settings" data-testid="fixture-feedback-dialog">
33
+ <v-card-text class="dialog-feedback-page__text">Settings that fill a phone's height.</v-card-text>
34
+ <v-card-actions>
35
+ <v-spacer />
36
+ <v-btn data-testid="fixture-dialog-close" @click="dialog = false">Close</v-btn>
37
+ <v-btn data-testid="fixture-dialog-save" @click="save">Save</v-btn>
38
+ </v-card-actions>
39
+ </v-card>
40
+ </v-dialog>
41
+ </section>
42
+ </template>
43
+
44
+ <style scoped>
45
+ .dialog-feedback-page__text {
46
+ min-height: 1200px;
47
+ }
48
+ </style>
@@ -18,6 +18,7 @@ import { adminTheme, theme } from "./theme/index.js";
18
18
  import RecordListPage from "./RecordListPage.vue";
19
19
  import RecordPage from "./RecordPage.vue";
20
20
  import FeedbackPage from "./FeedbackPage.vue";
21
+ import DialogFeedbackPage from "./DialogFeedbackPage.vue";
21
22
  import ReportsPage from "./ReportsPage.vue";
22
23
  import ScreenPage from "./ScreenPage.vue";
23
24
  import StudioPage from "./StudioPage.vue";
@@ -347,6 +348,7 @@ const routes = [
347
348
  { path: "/w/:workspaceSlug/admin/:section?", component: ScreenPage, meta: { title: "Admin surface" } },
348
349
  { path: "/help", component: ScreenPage, meta: { title: "Help and support" } },
349
350
  { path: "/solo", component: ScreenPage, meta: { title: "Solo", jskit: { title: "Solo" } } },
351
+ { path: "/solo/settings", component: DialogFeedbackPage, meta: { jskit: { title: "Settings", parent: "/" } } },
350
352
  { path: "/home/reports", redirect: "/home/reports/overview" },
351
353
  { path: "/home/reports/:section", component: ReportsPage, meta: { jskit: { title: "Reports" } } },
352
354
  { path: "/home/feedback", component: FeedbackPage, meta: { jskit: { title: "Integration" } } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/shell-web",
3
- "version": "0.2.27",
3
+ "version": "0.2.29",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -46,14 +46,14 @@
46
46
  "./locales/en.json": "./locales/en.json"
47
47
  },
48
48
  "dependencies": {
49
- "@jskit-ai/architecture-inspector": "0.1.18"
49
+ "@jskit-ai/architecture-inspector": "0.1.19"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jskit-ai/material-web": "0.1.5",
53
53
  "@vue/compiler-sfc": "3.5.44"
54
54
  },
55
55
  "peerDependencies": {
56
- "@jskit-ai/kernel": "0.2.20",
56
+ "@jskit-ai/kernel": "0.2.21",
57
57
  "pinia": "^4.0.3",
58
58
  "vue": "^3.5.44",
59
59
  "vue-router": "^5.3.1",
@@ -22,6 +22,7 @@ const {
22
22
  onSnackbarAfterLeave,
23
23
  onSnackbarModelValue,
24
24
  runAction,
25
+ snackbarLocation,
25
26
  snackbarOpen
26
27
  } = useShellErrorHost();
27
28
  </script>
@@ -75,11 +76,19 @@ const {
75
76
  <!-- Material 3 keeps a snackbar clear of the actions it reports on. Vuetify places it inside the layout, above the
76
77
  navigation bar and a FAB that takes layout room (`<v-fab app layout>`). On a phone it is centred there; on
77
78
  wider windows it starts at the content's start edge and takes at most half its width, clear of end-aligned
78
- FABs and form actions (Save), so a person can press Save again while it shows. -->
79
+ FABs and form actions (Save), so a person can press Save again while it shows. On a phone a message that
80
+ shows while a dialog, a bottom sheet or a temporary drawer is open goes to the top, clear of that surface's
81
+ actions at its bottom.
82
+ `_disable-global-stack` keeps the snackbar out of Vuetify's overlay stack, as VTooltip keeps itself: on the
83
+ stack, a message took the top from the dialog under it, so Escape and the browser's Back no longer closed that
84
+ dialog. It is a private Vuetify prop, kept until Vuetify leaves snackbars off the stack itself; then it goes.
85
+ Since Vuetify 4.1.0 (vuetifyjs/vuetify#22796). Reported upstream:
86
+ https://github.com/vuetifyjs/vuetify/issues/23392; remove the prop once a fixed Vuetify is pinned. -->
79
87
  <v-snackbar
80
88
  :model-value="snackbarOpen"
81
89
  class="shell-error-host__snackbar"
82
- location="bottom start"
90
+ :location="snackbarLocation"
91
+ :_disable-global-stack="true"
83
92
  :timeout="resolveTimeout(displayedSnackbarEntry)"
84
93
  :vertical="actionsFor(displayedSnackbarEntry).length > 1"
85
94
  @update:model-value="onSnackbarModelValue"
@@ -187,7 +196,8 @@ const {
187
196
  }
188
197
 
189
198
  /* The snackbar is teleported out of this component, so its rules are written for its own classes. Compact windows
190
- (below 600dp) centre it; wider ones keep it at the start, at most half the content's width. */
199
+ (below 600dp) centre it, at the bottom or, over a modal surface, at the top; wider ones keep it at the start, at
200
+ most half the content's width. */
191
201
  @media (max-width: 599.98px) {
192
202
  :global(.shell-error-host__snackbar.v-snackbar--start) {
193
203
  justify-content: center;
@@ -4,8 +4,19 @@ import { useShellWebErrorRuntime } from "../error/inject.js";
4
4
  import { resolveBannerPlacement } from "../error/presentation.js";
5
5
  import { useShellErrorPresentationStore } from "../stores/useShellErrorPresentationStore.js";
6
6
  import { useJskitText } from "../i18n.js";
7
+ import { useShellWindowSizeClass } from "./useShellWindowSizeClass.js";
7
8
 
8
9
  const BANNER_INLINE_HEIGHT_PROPERTY = "--shell-error-banners-inline-height";
10
+ // The modal surfaces that keep their actions at their bottom edge on a compact window, where the snackbar shows: an
11
+ // open dialog (a bottom sheet is one) and an open temporary navigation drawer.
12
+ const MODAL_SURFACE_SELECTOR = [
13
+ ".v-dialog.v-overlay--active",
14
+ ".v-navigation-drawer--temporary.v-navigation-drawer--active"
15
+ ].join(", ");
16
+
17
+ function isModalSurfaceOpen() {
18
+ return document.querySelector(MODAL_SURFACE_SELECTOR) !== null;
19
+ }
9
20
 
10
21
  function isSameSnackbarEntry(left = null, right = null) {
11
22
  return Boolean(left?.id && right?.id && left.id === right.id);
@@ -63,6 +74,11 @@ function useShellErrorHost() {
63
74
 
64
75
  onBeforeUnmount(stopObservingBanners);
65
76
  const snackbarOpen = ref(false);
77
+ // Material 3 keeps a snackbar clear of the actions it reports on. A message that shows while a modal surface is
78
+ // open sits at the top of a compact window, clear of the surface's actions, and keeps that place until it leaves.
79
+ const { isCompact } = useShellWindowSizeClass();
80
+ const snackbarOverModalSurface = ref(false);
81
+ const snackbarLocation = computed(() => (isCompact.value && snackbarOverModalSurface.value ? "top" : "bottom start"));
66
82
 
67
83
  function hasSnackbarEntry(entry = null) {
68
84
  if (!entry?.id) {
@@ -80,6 +96,7 @@ function useShellErrorHost() {
80
96
  return;
81
97
  }
82
98
 
99
+ snackbarOverModalSurface.value = isModalSurfaceOpen();
83
100
  displayedSnackbarEntry.value = nextEntry;
84
101
  snackbarOpen.value = true;
85
102
  }
@@ -102,7 +119,10 @@ function useShellErrorHost() {
102
119
  snackbarOpen.value = false;
103
120
  },
104
121
  {
105
- immediate: true
122
+ immediate: true,
123
+ // After the page has rendered, so a dialog that closed with the change that reported the message (a saved
124
+ // form) no longer counts as open.
125
+ flush: "post"
106
126
  }
107
127
  );
108
128
 
@@ -164,6 +184,7 @@ function useShellErrorHost() {
164
184
  onSnackbarAfterLeave,
165
185
  onSnackbarModelValue,
166
186
  runAction,
187
+ snackbarLocation,
167
188
  snackbarOpen
168
189
  };
169
190
  }
@@ -505,6 +505,73 @@ test("a snackbar never covers the FAB, the navigation bar or a form's Save, so S
505
505
  }
506
506
  });
507
507
 
508
+ // A message reported from a dialog that stays open (a Save that keeps editing) shows while the dialog is up. On a
509
+ // phone, on a surface with no navigation bar, the dialog's actions sit at the bottom of the window, where a snackbar
510
+ // shows, so the snackbar goes to the top, clear of them. And the snackbar stays out of Vuetify's overlay stack: on it, the message took the top from the
511
+ // dialog, so Escape and the browser's Back no longer closed the dialog.
512
+ test("a snackbar over a phone's dialog sits clear of its actions, and Escape and Back still close the dialog", {
513
+ skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
514
+ timeout: 120_000
515
+ }, async (t) => {
516
+ const { vite, browser } = await startFixture(t);
517
+ // Closed with the browser, which the fixture's after hook closes however the test ends.
518
+ const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 } });
519
+ const box = (locator) => locator.evaluate((element) => {
520
+ const rect = element.getBoundingClientRect();
521
+ return { top: rect.top, bottom: rect.bottom, left: rect.left, right: rect.right };
522
+ });
523
+ const dialog = page.getByTestId("fixture-feedback-dialog");
524
+ const snackbar = page.locator(".shell-error-host__snackbar .v-snackbar__wrapper");
525
+ const settled = (locator) => locator.evaluate((element) => Promise.all(element.closest(".v-overlay").getAnimations({ subtree: true })
526
+ .filter((animation) => Number.isFinite(animation.effect?.getComputedTiming().endTime ?? Infinity))
527
+ .map((animation) => animation.finished.catch(() => null))));
528
+ async function saveInOpenDialog() {
529
+ await page.getByTestId("fixture-open-dialog").click();
530
+ await expect(dialog).toBeVisible();
531
+ await settled(dialog);
532
+ await page.getByTestId("fixture-dialog-save").click();
533
+ await expect(snackbar).toBeVisible();
534
+ await settled(snackbar);
535
+ }
536
+
537
+ // Two steps into the page, so Back has an entry to return to: Vuetify's overlays ignore a Back to the page's first
538
+ // entry, which the router replaced as it started.
539
+ await page.goto("/solo/settings");
540
+ await expect(page.getByTestId("jskit-shell-bottom-nav")).toHaveCount(0);
541
+ for (const step of ["1", "2"]) {
542
+ await page.getByRole("link", { name: "Next step", exact: true }).click();
543
+ await expect(page).toHaveURL(new RegExp(`/solo/settings\\?step=${step}$`, "u"));
544
+ }
545
+ await saveInOpenDialog();
546
+ const shown = await box(snackbar);
547
+ const actions = await box(dialog.locator(".v-card-actions"));
548
+ assert.ok(actions.bottom > 844 * 0.75, `The dialog's actions sit at the window's bottom: ${JSON.stringify(actions)}`);
549
+ for (const name of ["fixture-dialog-save", "fixture-dialog-close"]) {
550
+ assert.equal(overlaps(shown, await box(page.getByTestId(name))), false, `The snackbar covers ${name}: ${JSON.stringify(shown)}`);
551
+ }
552
+ assert.ok(shown.bottom <= actions.top, `The snackbar sits above the dialog's actions: ${JSON.stringify({ shown, actions })}`);
553
+ // The dialog's Close and the snackbar's Dismiss both answer while the message shows.
554
+ await page.getByTestId("fixture-dialog-close").click();
555
+ await expect(dialog).toBeHidden();
556
+ await snackbar.getByRole("button", { name: "Dismiss", exact: true }).click();
557
+ await expect(snackbar).toBeHidden();
558
+
559
+ // Escape closes the dialog under a message that stays, as it does with none.
560
+ await saveInOpenDialog();
561
+ await page.keyboard.press("Escape");
562
+ await expect(dialog).toBeHidden();
563
+ await expect(snackbar).toBeVisible();
564
+ await snackbar.getByRole("button", { name: "Dismiss", exact: true }).click();
565
+ await expect(snackbar).toBeHidden();
566
+
567
+ // The browser's Back closes the dialog and stays on the page.
568
+ await saveInOpenDialog();
569
+ await page.goBack();
570
+ await expect(dialog).toBeHidden();
571
+ await expect(page).toHaveURL(/\/solo\/settings\?step=2$/u);
572
+ await expect(snackbar).toBeVisible();
573
+ });
574
+
508
575
  // The drawer fits a long name in its identity (a workspace switcher, say) as well as its labels.
509
576
  test("the drawer is wide enough for its identity's name", {
510
577
  skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
@@ -53,7 +53,8 @@ function fixture(t) {
53
53
  useShellErrorPresentationStore(pinia).attachRuntimeStore(store);
54
54
  app.provide(SHELL_WEB_ERROR_RUNTIME_KEY, runtime);
55
55
  app.provide(Symbol.for("vuetify:layout"), { mainRect: shallowRef({ top: 0, left: 0, right: 0, bottom: 0 }) });
56
- globalThis.document = { documentElement: { style: { removeProperty() {} } } };
56
+ app.provide(Symbol.for("vuetify:display"), { width: shallowRef(1280), mobile: shallowRef(false) });
57
+ globalThis.document = { documentElement: { style: { removeProperty() {} } }, querySelector: () => null };
57
58
  for (const name of ["VSnackbar", "VDialog", "VCard", "VCardTitle", "VCardText", "VCardActions", "VSpacer", "VAlert", "VBtn"]) {
58
59
  app.component(name, defineComponent({ setup: (_props, { slots }) => () =>
59
60
  h(name, {}, [slots.default?.(), slots.actions?.()]) }));
@@ -1,6 +1,6 @@
1
1
  import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
- import { markRaw, nextTick, shallowRef } from "vue";
3
+ import { markRaw, nextTick, ref, shallowRef } from "vue";
4
4
  import { createPinia } from "pinia";
5
5
  import { useShellErrorHost } from "../src/client/composables/useShellErrorHost.js";
6
6
  import { SHELL_WEB_ERROR_RUNTIME_KEY } from "../src/client/error/inject.js";
@@ -8,15 +8,18 @@ import { createErrorPresentationStore } from "../src/client/error/store.js";
8
8
  import { useShellErrorPresentationStore } from "../src/client/stores/useShellErrorPresentationStore.js";
9
9
  import { mountComposable } from "./support/mountComposable.js";
10
10
 
11
- function mountHost(t, { top = 0 } = {}) {
11
+ function mountHost(t, { top = 0, width = 1280 } = {}) {
12
12
  const heights = new Map();
13
+ // The open modal surfaces the page holds, by the selector the host looks them up with.
14
+ const openSurfaces = [];
13
15
  globalThis.document = {
14
16
  documentElement: {
15
17
  style: {
16
18
  setProperty: (name, value) => heights.set(name, value),
17
19
  removeProperty: (name) => heights.delete(name)
18
20
  }
19
- }
21
+ },
22
+ querySelector: (selector) => openSurfaces.find((surface) => selector.split(", ").includes(surface)) || null
20
23
  };
21
24
  const observers = [];
22
25
  globalThis.ResizeObserver = class {
@@ -43,14 +46,16 @@ function mountHost(t, { top = 0 } = {}) {
43
46
  useShellErrorPresentationStore(pinia).attachRuntimeStore(store);
44
47
  const reports = [];
45
48
  const layoutRect = shallowRef({ top, left: 0, right: 0, bottom: 0 });
49
+ const windowWidth = ref(width);
46
50
  const { app, result } = mountComposable(useShellErrorHost, {
47
51
  plugins: [pinia],
48
52
  provide: [
49
53
  [SHELL_WEB_ERROR_RUNTIME_KEY, { report: (event) => reports.push(event) }],
50
- [Symbol.for("vuetify:layout"), { mainRect: layoutRect }]
54
+ [Symbol.for("vuetify:layout"), { mainRect: layoutRect }],
55
+ [Symbol.for("vuetify:display"), { width: windowWidth, mobile: ref(false) }]
51
56
  ]
52
57
  });
53
- return { app, heights, host: result, layoutRect, observers, reports, store };
58
+ return { app, heights, host: result, layoutRect, observers, openSurfaces, reports, store, windowWidth };
54
59
  }
55
60
 
56
61
  test("snackbars show one at a time and the next opens after the last one leaves", async (t) => {
@@ -79,6 +84,35 @@ test("snackbars show one at a time and the next opens after the last one leaves"
79
84
  app.unmount();
80
85
  });
81
86
 
87
+ test("a message that shows over an open modal surface sits at the top of a compact window", async (t) => {
88
+ const { app, host, openSurfaces, store, windowWidth } = mountHost(t, { width: 390 });
89
+ store.present("snackbar", { message: "Shown over the page" });
90
+ await nextTick();
91
+ assert.equal(host.snackbarLocation.value, "bottom start");
92
+ host.onSnackbarModelValue(false);
93
+ await nextTick();
94
+ host.onSnackbarAfterLeave();
95
+
96
+ for (const surface of [".v-dialog.v-overlay--active", ".v-navigation-drawer--temporary.v-navigation-drawer--active"]) {
97
+ openSurfaces.splice(0, openSurfaces.length, surface);
98
+ store.present("snackbar", { message: "Shown over a modal surface" });
99
+ await nextTick();
100
+ assert.equal(host.snackbarLocation.value, "top", surface);
101
+ // Wider windows keep it at the bottom start: a centred surface ends above the window's bottom edge.
102
+ windowWidth.value = 1024;
103
+ assert.equal(host.snackbarLocation.value, "bottom start", surface);
104
+ windowWidth.value = 390;
105
+ // It keeps its place while it shows, though the surface closes under it.
106
+ openSurfaces.length = 0;
107
+ await nextTick();
108
+ assert.equal(host.snackbarLocation.value, "top", surface);
109
+ host.onSnackbarModelValue(false);
110
+ await nextTick();
111
+ host.onSnackbarAfterLeave();
112
+ }
113
+ app.unmount();
114
+ });
115
+
82
116
  test("a dialog closes on request unless it persists", async (t) => {
83
117
  const { app, host, store } = mountHost(t);
84
118
  store.present("dialog", { message: "Closable" });