@jskit-ai/shell-web 0.2.19 → 0.2.21

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.
@@ -26,7 +26,7 @@ const SHELL_PROBES = Object.freeze([
26
26
  { name: "upButton", selector: "[data-testid=jskit-shell-back]", width: true },
27
27
  { name: "menuButton", selector: "[data-testid=jskit-shell-nav-toggle]", width: true },
28
28
  { name: "navigationBar", selector: "[data-testid=jskit-shell-bottom-nav]", width: true },
29
- { name: "navigationBarIndicator", selector: ".tab-link-item--active .tab-link-item__indicator", width: true },
29
+ { name: "navigationBarIndicator", selector: ".tab-link-item--active .v-icon", width: true },
30
30
  { name: "navigationBarLabel", selector: ".tab-link-item__label" },
31
31
  { name: "rail", selector: "[data-testid=jskit-shell-rail]", width: true },
32
32
  { name: "railIndicator", selector: "[data-testid=jskit-shell-rail] .v-list-item--active .shell-menu-link-item__indicator", width: true },
@@ -83,11 +83,15 @@ test("shell-web shell layout registers navigation at the app layout level", asyn
83
83
  assert.match(layoutSource, /const \{ pageActions \} = useShellAppBar\(\);/u);
84
84
  assert.match(layoutSource, /<ShellUpButton v-if="canGoUp" class="shell-layout__leading" \/>/u);
85
85
  assert.match(layoutSource, /<ShellPageTitle :title="fallbackTitle" \/>/u);
86
+ // Each top-right item renders once, in the bar or teleported into the overflow menu, which keeps it mounted.
86
87
  assert.match(
87
88
  layoutSource,
88
- /<ShellPageActionsTarget>\s*<template v-if="topRightInMenu > 0" #menu>\s*<ShellOutlet target="shell-layout:top-right" :end="topRightInMenu" \/>/u
89
+ /<ShellPageActionsTarget :menu-items="topRightInMenu > 0">\s*<template v-if="topRight\.length > 0 && !slots\['top-right'\]" #menu>\s*<div :id="TOP_RIGHT_MENU_ID"/u
90
+ );
91
+ assert.match(
92
+ layoutSource,
93
+ /<Teleport\s+v-for="\(entry, index\) in topRight"[\s\S]*?:to="`#\$\{TOP_RIGHT_MENU_ID\}`"\s+:disabled="index >= topRightInMenu"\s*>[\s\S]*?<ShellOutlet target="shell-layout:top-right" :start="index" :end="index \+ 1" \/>/u
89
94
  );
90
- assert.match(layoutSource, /<ShellOutlet target="shell-layout:top-right" :start="topRightInMenu" \/>/u);
91
95
  assert.doesNotMatch(layoutSource, /\$arrowBack|PAGE_TITLE_ID|SHELL_PAGE_ACTIONS_ID|attachShell/u);
92
96
 
93
97
  assert.doesNotMatch(source, /<v-layout\b/);
@@ -0,0 +1,31 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { resolveTopRightItemsInMenu } from "../src/client/support/topRightOverflow.js";
4
+
5
+ // A 390dp phone's bar after its padding and Up arrow: 326dp for the title, three 48dp items and the 48dp overflow
6
+ // button that the page's actions already need.
7
+ const PHONE = Object.freeze({ room: 326, items: [48, 48, 48], menuButton: 48, menuShown: true, keepLast: true });
8
+
9
+ test("a compact bar keeps every top-right item that fits beside the whole title", () => {
10
+ assert.equal(resolveTopRightItemsInMenu({ ...PHONE, title: 70 }), 0, "a short title leaves room for all three");
11
+ assert.equal(resolveTopRightItemsInMenu({ ...PHONE, title: 134 }), 0, "a title that fits to the pixel");
12
+ assert.equal(resolveTopRightItemsInMenu({ ...PHONE, title: 135 }), 1, "the item farthest from the corner moves first");
13
+ assert.equal(resolveTopRightItemsInMenu({ ...PHONE, title: 190 }), 2);
14
+ assert.equal(resolveTopRightItemsInMenu({ ...PHONE, title: 400 }), 2, "the avatar stays beside a title too long for the bar");
15
+ });
16
+
17
+ test("the overflow button the items need takes room, and a primary action lets every item go", () => {
18
+ // No page action in the menu: the bar draws no overflow button while every item is in it.
19
+ const ownMenu = { ...PHONE, menuShown: false };
20
+ assert.equal(resolveTopRightItemsInMenu({ ...ownMenu, title: 182 }), 0, "every item fits, with no menu button");
21
+ assert.equal(
22
+ resolveTopRightItemsInMenu({ ...ownMenu, title: 183 }),
23
+ 2,
24
+ "moving one item makes room for the menu button only, so two move"
25
+ );
26
+
27
+ const form = { ...PHONE, keepLast: false };
28
+ assert.equal(resolveTopRightItemsInMenu({ ...form, title: 70 }), 0, "beside Save, whatever fits stays");
29
+ assert.equal(resolveTopRightItemsInMenu({ ...form, title: 400 }), 3, "the avatar goes too when the title needs it");
30
+ assert.equal(resolveTopRightItemsInMenu({ ...PHONE, items: [], title: 400 }), 0);
31
+ });
@@ -163,8 +163,25 @@ test("Escape closes the compact drawer and returns focus to its toggle", async (
163
163
  app.unmount();
164
164
  });
165
165
 
166
- test("the drawer is Material 3's 360dp wide and a modal one leaves 56dp of the page", async (t) => {
167
- const { app, frames, isCompactLayout, result, viewportWidth } = mountDrawer(t);
166
+ test("without a drawerWidth the drawer fits its labels, and a modal one leaves 56dp of the page", async (t) => {
167
+ const { app, frames, isCompactLayout, observers, result, viewportWidth } = mountDrawer(t);
168
+ assert.equal(result.fixedDrawerWidth.value, false);
169
+
170
+ await runFrames(frames);
171
+ const fitted = 16 + LABEL_TEXT_WIDTH + 12 + 1;
172
+ assert.equal(result.resolvedDrawerWidth.value, fitted);
173
+ assert.equal(observers[0].connected, true);
174
+
175
+ isCompactLayout.value = true;
176
+ viewportWidth.value = 390;
177
+ assert.equal(result.resolvedDrawerWidth.value, fitted);
178
+ viewportWidth.value = 200;
179
+ assert.equal(result.resolvedDrawerWidth.value, 200 - 56);
180
+ app.unmount();
181
+ });
182
+
183
+ test("drawerWidth=\"material\" is Material 3's 360dp and a modal one leaves 56dp of the page", async (t) => {
184
+ const { app, frames, isCompactLayout, result, viewportWidth } = mountDrawer(t, { props: { drawerWidth: "material" } });
168
185
  assert.equal(result.fixedDrawerWidth.value, true);
169
186
  assert.equal(result.resolvedDrawerWidth.value, 360);
170
187
  await runFrames(frames);