@jskit-ai/shell-web 0.2.10 → 0.2.12
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 +10 -0
- package/fixtures/adaptive-shell/src/App.vue +7 -0
- package/fixtures/adaptive-shell/src/OwnBarLayout.vue +24 -0
- package/fixtures/adaptive-shell/src/RecordListPage.vue +22 -0
- package/fixtures/adaptive-shell/src/RecordPage.vue +30 -0
- package/fixtures/adaptive-shell/src/ScreenPage.vue +7 -3
- package/fixtures/adaptive-shell/src/SettingsPage.vue +24 -0
- package/fixtures/adaptive-shell/src/StudioPage.vue +26 -0
- package/fixtures/adaptive-shell/src/main.js +64 -55
- package/fixtures/adaptive-shell/src/records.js +13 -0
- package/fixtures/adaptive-shell/src/theme/index.js +3 -0
- package/locales/en.json +1 -0
- package/package.json +22 -5
- package/patterns/application-shell/PATTERN.md +3 -1
- package/patterns/application-shell/example/expected-existing/src/pages/home/index.vue +5 -18
- package/patterns/application-shell/example/expected-existing/src/views/NotFound.vue +14 -0
- package/patterns/application-shell/example/src/pages/home/index.vue +21 -57
- package/patterns/application-shell/example/src/pages/home/settings/general/index.vue +24 -19
- package/patterns/application-shell/example/src/pages/home/settings.vue +27 -84
- package/patterns/application-shell/example/src/views/NotFound.vue +15 -0
- package/patterns/page-and-placement/example/src/components/SyncStatusElement.vue +2 -2
- package/patterns/page-and-placement/example/src/pages/home/reports/activity.vue +1 -1
- package/patterns/page-and-placement/example/src/pages/home/reports/overview.vue +1 -1
- package/patterns/page-and-placement/example/src/pages/home/reports.vue +6 -3
- package/patterns/page-and-placement/example/src/placement.js +1 -1
- package/src/client/components/ShellErrorHost.vue +13 -15
- package/src/client/components/ShellLayout.vue +340 -187
- package/src/client/components/ShellListDetail.vue +77 -0
- package/src/client/components/ShellMenuLinkItem.vue +10 -24
- package/src/client/components/ShellNavigationItem.vue +175 -0
- package/src/client/components/ShellNavigationScope.vue +18 -0
- package/src/client/components/ShellOutlet.vue +1 -1
- package/src/client/components/ShellOutletMenuWidget.vue +2 -2
- package/src/client/components/ShellPageAction.vue +91 -0
- package/src/client/components/ShellPageActions.vue +32 -0
- package/src/client/components/ShellPageActionsTarget.vue +24 -0
- package/src/client/components/ShellPageTitle.vue +49 -0
- package/src/client/components/ShellSurfaceAwareMenuLinkItem.vue +10 -24
- package/src/client/components/ShellTabLinkItem.vue +77 -3
- package/src/client/components/ShellUpButton.vue +29 -0
- package/src/client/composables/useShellAppBar.js +27 -0
- package/src/client/composables/useShellDrawer.js +28 -18
- package/src/client/composables/useShellPageTitle.js +15 -0
- package/src/client/composables/useShellRouteTransition.js +1 -1
- package/src/client/composables/useShellWindowSizeClass.js +21 -0
- package/src/client/error/presentation.js +3 -5
- package/src/client/index.js +11 -0
- package/src/client/lib/menuIcons.js +21 -65
- package/src/client/navigation/documentNavigation.js +38 -0
- package/src/client/navigation/shellNavigationRuntime.js +480 -0
- package/src/client/navigation/useShellNavigation.js +94 -0
- package/src/client/providers/ShellWebClientProvider.js +11 -0
- package/src/client/support/drawerPresentation.js +9 -4
- package/src/client/support/drawerWidth.js +18 -1
- package/src/client/support/navigationPresentation.js +40 -0
- package/src/client/support/shellLayoutClass.js +6 -25
- package/src/client/support/windowSizeClass.js +29 -0
- package/src/test/adaptiveShellSmoke.js +43 -16
- package/src/test/shellNavigation.js +32 -0
- package/test/adaptiveShell.browser.test.js +251 -111
- package/test/clientUpdate.test.js +6 -1
- package/test/drawerPresentation.test.js +7 -7
- package/test/errorPresentation.test.js +4 -5
- package/test/materialBaselines.browser.test.js +96 -0
- package/test/menuIcons.test.js +14 -22
- package/test/outletMenuWidgetContract.test.js +2 -3
- package/test/playwrightContract.test.js +3 -1
- package/test/provider.test.js +9 -1
- package/test/settingsPlacementContract.test.js +49 -28
- package/test/shellGestureSupport.test.js +21 -9
- package/test/translation.test.js +2 -2
- package/test/useShellDrawer.test.js +20 -5
- package/test/useShellRouteTransition.test.js +3 -3
- package/patterns/application-shell/example/src/pages/home/settings/index.vue +0 -7
- package/src/client/components/ShellNavigationTooltip.vue +0 -39
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** How navigation items inside it present: "rail", "drawer" or, outside the shell's navigation, "list". */
|
|
2
|
+
const SHELL_NAVIGATION_PRESENTATION_KEY = "jskit.shell-web.navigation.presentation";
|
|
3
|
+
/** Navigation items outside the shell's drawer and rail, such as a settings section's own menu, present as a list. */
|
|
4
|
+
const NO_SHELL_NAVIGATION_PRESENTATION = Object.freeze({ value: "list" });
|
|
5
|
+
|
|
6
|
+
/** The page actions slot in the shell's app bar, which ShellPageActions renders into. */
|
|
7
|
+
const SHELL_PAGE_ACTIONS_TARGET_KEY = "jskit.shell-web.layout.page-actions-target";
|
|
8
|
+
const SHELL_PAGE_ACTIONS_ID = "jskit-shell-page-actions";
|
|
9
|
+
/** A page outside a ShellLayout has no app bar, so its page actions render in place. */
|
|
10
|
+
const NO_SHELL_PAGE_ACTIONS_TARGET = "";
|
|
11
|
+
|
|
12
|
+
/** Vuetify's icon options, which hold the theme's aliases (Vuetify provides them under this global symbol). */
|
|
13
|
+
const VUETIFY_ICONS_KEY = Symbol.for("vuetify:icons");
|
|
14
|
+
const NO_VUETIFY_ICONS = Object.freeze({ aliases: Object.freeze({}) });
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The filled form of a navigation icon alias for the active destination: Material 3 shows the active destination's
|
|
18
|
+
* icon filled. `$home` becomes `$homeFilled` when the theme defines it; any other icon stays as it is.
|
|
19
|
+
* @param {string} icon
|
|
20
|
+
* @param {Record<string, unknown> | undefined} aliases The Vuetify icon aliases.
|
|
21
|
+
*/
|
|
22
|
+
function filledIconAlias(icon, aliases) {
|
|
23
|
+
const name = String(icon || "");
|
|
24
|
+
if (!name.startsWith("$") || !aliases) {
|
|
25
|
+
return name;
|
|
26
|
+
}
|
|
27
|
+
const filled = `${name.slice(1)}Filled`;
|
|
28
|
+
return Object.hasOwn(aliases, filled) ? `$${filled}` : name;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
NO_SHELL_NAVIGATION_PRESENTATION,
|
|
33
|
+
NO_SHELL_PAGE_ACTIONS_TARGET,
|
|
34
|
+
NO_VUETIFY_ICONS,
|
|
35
|
+
SHELL_NAVIGATION_PRESENTATION_KEY,
|
|
36
|
+
SHELL_PAGE_ACTIONS_ID,
|
|
37
|
+
SHELL_PAGE_ACTIONS_TARGET_KEY,
|
|
38
|
+
VUETIFY_ICONS_KEY,
|
|
39
|
+
filledIconAlias
|
|
40
|
+
};
|
|
@@ -1,30 +1,11 @@
|
|
|
1
1
|
import { pageViewportWidth } from "../browser.js";
|
|
2
|
+
import { resolveWindowSizeClass } from "./windowSizeClass.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function resolveShellLayoutClass(displayName = "", viewportWidth = pageViewportWidth()) {
|
|
9
|
-
const name = String(displayName || "").trim().toLowerCase();
|
|
10
|
-
if (name === "xs" || name === "sm") {
|
|
11
|
-
return "compact";
|
|
12
|
-
}
|
|
13
|
-
if (name === "md") {
|
|
14
|
-
return "medium";
|
|
15
|
-
}
|
|
16
|
-
if (name === "lg" || name === "xl" || name === "xxl") {
|
|
17
|
-
return "expanded";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const width = Number(viewportWidth) || 0;
|
|
21
|
-
if (width > 0 && width < COMPACT_MAX_WIDTH) {
|
|
22
|
-
return "compact";
|
|
23
|
-
}
|
|
24
|
-
if (width > 0 && width < MEDIUM_MAX_WIDTH) {
|
|
25
|
-
return "medium";
|
|
26
|
-
}
|
|
27
|
-
return "expanded";
|
|
4
|
+
// The layout class placement variants are keyed by (compact, medium, expanded): the window size class, with large
|
|
5
|
+
// placed like expanded.
|
|
6
|
+
function resolveShellLayoutClass(viewportWidth = pageViewportWidth()) {
|
|
7
|
+
const sizeClass = resolveWindowSizeClass(viewportWidth);
|
|
8
|
+
return sizeClass === "large" ? "expanded" : sizeClass;
|
|
28
9
|
}
|
|
29
10
|
|
|
30
11
|
export { resolveShellLayoutClass };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Material 3 window size classes by window width in dp: compact below 600, medium below 840, expanded below 1200 and
|
|
2
|
+
// large from 1200 (extra-large folds into large).
|
|
3
|
+
const MEDIUM_MIN_WIDTH = 600;
|
|
4
|
+
const EXPANDED_MIN_WIDTH = 840;
|
|
5
|
+
const LARGE_MIN_WIDTH = 1200;
|
|
6
|
+
const WINDOW_SIZE_CLASSES = Object.freeze(["compact", "medium", "expanded", "large"]);
|
|
7
|
+
|
|
8
|
+
/** @param {number} width */
|
|
9
|
+
function resolveWindowSizeClass(width) {
|
|
10
|
+
const value = Number(width) || 0;
|
|
11
|
+
if (value < MEDIUM_MIN_WIDTH) {
|
|
12
|
+
return "compact";
|
|
13
|
+
}
|
|
14
|
+
if (value < EXPANDED_MIN_WIDTH) {
|
|
15
|
+
return "medium";
|
|
16
|
+
}
|
|
17
|
+
if (value < LARGE_MIN_WIDTH) {
|
|
18
|
+
return "expanded";
|
|
19
|
+
}
|
|
20
|
+
return "large";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
EXPANDED_MIN_WIDTH,
|
|
25
|
+
LARGE_MIN_WIDTH,
|
|
26
|
+
MEDIUM_MIN_WIDTH,
|
|
27
|
+
WINDOW_SIZE_CLASSES,
|
|
28
|
+
resolveWindowSizeClass
|
|
29
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const DEFAULT_SMOKE_PATH = String(process.env.JSKIT_PLAYWRIGHT_SMOKE_PATH || "/home");
|
|
2
2
|
const DEFAULT_VIEWPORTS = Object.freeze([
|
|
3
3
|
Object.freeze({ name: "compact", width: 390, height: 844 }),
|
|
4
|
-
Object.freeze({ name: "medium", width:
|
|
4
|
+
Object.freeze({ name: "medium", width: 768, height: 1024 }),
|
|
5
5
|
Object.freeze({ name: "expanded", width: 1280, height: 900 })
|
|
6
6
|
]);
|
|
7
7
|
|
|
@@ -171,17 +171,30 @@ async function expectContentAwareDrawerFit(drawer, expect) {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
async function readNavigationIconCenters(drawer) {
|
|
174
|
+
async function readNavigationIconCenters(drawer, expect) {
|
|
175
175
|
const icons = drawer.locator("a.shell-menu-link-item[href] .v-icon");
|
|
176
176
|
await icons.first().waitFor({ state: "visible" });
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
177
|
+
// A modal drawer slides in: measure its icons once two reads, each a couple of frames later, agree.
|
|
178
|
+
const readCenters = () => icons.evaluateAll(async (elements) => {
|
|
179
|
+
await new Promise((resolve) => window.requestAnimationFrame(() => window.requestAnimationFrame(resolve)));
|
|
180
|
+
const centers = [];
|
|
181
|
+
for (const element of elements) {
|
|
182
|
+
const box = element.getBoundingClientRect();
|
|
183
|
+
if (!box.width) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
centers.push(box.x + box.width / 2);
|
|
183
187
|
}
|
|
184
|
-
centers
|
|
188
|
+
return centers;
|
|
189
|
+
});
|
|
190
|
+
let centers = await readCenters();
|
|
191
|
+
await expect.poll(async () => {
|
|
192
|
+
const previous = centers;
|
|
193
|
+
centers = await readCenters();
|
|
194
|
+
return JSON.stringify(centers) === JSON.stringify(previous);
|
|
195
|
+
}, { message: "Shell navigation icons did not come to rest." }).toBe(true);
|
|
196
|
+
if (!centers) {
|
|
197
|
+
throw new Error("Shell navigation exposed an unmeasurable icon.");
|
|
185
198
|
}
|
|
186
199
|
return centers;
|
|
187
200
|
}
|
|
@@ -211,7 +224,7 @@ async function expectCentredRailNavigation(page, drawer, expect, expandedIconCen
|
|
|
211
224
|
expect(linkBox).not.toBeNull();
|
|
212
225
|
expect(linkBox.width).toBeGreaterThanOrEqual(48);
|
|
213
226
|
expect(linkBox.height).toBeGreaterThanOrEqual(48);
|
|
214
|
-
const railIconCenters = await readNavigationIconCenters(drawer);
|
|
227
|
+
const railIconCenters = await readNavigationIconCenters(drawer, expect);
|
|
215
228
|
expect(railIconCenters.length).toBe(expandedIconCenters.length);
|
|
216
229
|
for (let index = 0; index < railIconCenters.length; index += 1) {
|
|
217
230
|
expect(Math.abs(
|
|
@@ -291,12 +304,10 @@ async function runAdaptiveShellSmokeCase({
|
|
|
291
304
|
await expect(page.getByTestId("jskit-shell-bottom-nav")).toBeVisible();
|
|
292
305
|
await expectElementVisibility(page, expect, "jskit-shell-drawer", false);
|
|
293
306
|
|
|
307
|
+
// The modal drawer opens over the app bar, as Material 3 draws it; tapping the scrim beside it closes it.
|
|
294
308
|
await openCompactDrawer(page, expect);
|
|
295
|
-
await toggle.
|
|
296
|
-
await
|
|
297
|
-
|
|
298
|
-
await openCompactDrawer(page, expect);
|
|
299
|
-
await page.getByRole("button", { name: "Close navigation menu" }).click();
|
|
309
|
+
await expect(toggle).toHaveAttribute("aria-label", "Close navigation menu");
|
|
310
|
+
await page.mouse.click(viewport.width - 8, Math.round(viewport.height / 2));
|
|
300
311
|
await expectElementVisibility(page, expect, "jskit-shell-drawer", false);
|
|
301
312
|
|
|
302
313
|
await openCompactDrawer(page, expect);
|
|
@@ -314,6 +325,22 @@ async function runAdaptiveShellSmokeCase({
|
|
|
314
325
|
|
|
315
326
|
await pullToRefresh(page, expect);
|
|
316
327
|
await expect.poll(() => bootstrapRequests).toBeGreaterThan(bootstrapRequestsBeforePull);
|
|
328
|
+
} else if (layoutClass === "medium") {
|
|
329
|
+
// Medium windows keep a navigation rail and open the drawer over the page from the rail's menu control.
|
|
330
|
+
const rail = page.getByTestId("jskit-shell-rail");
|
|
331
|
+
await expect(rail).toBeVisible();
|
|
332
|
+
await expectElementVisibility(page, expect, "jskit-shell-drawer", false);
|
|
333
|
+
await expectDrawerWidth(rail, expect, await readConfiguredWidth(drawer, "data-rail-width"));
|
|
334
|
+
await toggle.click();
|
|
335
|
+
await expect(drawer).toHaveAttribute("data-presentation", "modal");
|
|
336
|
+
await expectElementVisibility(page, expect, "jskit-shell-drawer", true);
|
|
337
|
+
await expectDrawerWidth(drawer, expect, await readConfiguredWidth(drawer, "data-drawer-width"));
|
|
338
|
+
const drawerIconCenters = await readNavigationIconCenters(drawer, expect);
|
|
339
|
+
await page.keyboard.press("Escape");
|
|
340
|
+
await expectElementVisibility(page, expect, "jskit-shell-drawer", false);
|
|
341
|
+
await expect(toggle).toBeFocused();
|
|
342
|
+
await expectCentredRailNavigation(page, rail, expect, drawerIconCenters);
|
|
343
|
+
await expectNoHorizontalOverflow(page, expect);
|
|
317
344
|
} else {
|
|
318
345
|
await expect(drawer).toBeVisible();
|
|
319
346
|
if (await drawer.getAttribute("data-presentation") === "rail") {
|
|
@@ -322,7 +349,7 @@ async function runAdaptiveShellSmokeCase({
|
|
|
322
349
|
await expect(drawer).toHaveAttribute("data-presentation", "drawer");
|
|
323
350
|
await expectDrawerWidth(drawer, expect, await readConfiguredWidth(drawer, "data-drawer-width"));
|
|
324
351
|
await expectContentAwareDrawerFit(drawer, expect);
|
|
325
|
-
const expandedIconCenters = await readNavigationIconCenters(drawer);
|
|
352
|
+
const expandedIconCenters = await readNavigationIconCenters(drawer, expect);
|
|
326
353
|
await page.keyboard.press("Escape");
|
|
327
354
|
await expect(drawer).toHaveAttribute("data-presentation", "drawer");
|
|
328
355
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Playwright helpers for the shell's app bar: its Up arrow and page title.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The shell's Up arrow, the leading button of an inner page's app bar.
|
|
5
|
+
* @param {import("@playwright/test").Page} page
|
|
6
|
+
*/
|
|
7
|
+
function shellBackButton(page) {
|
|
8
|
+
return page.getByTestId("jskit-shell-back");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The app bar's page title.
|
|
13
|
+
* @param {import("@playwright/test").Page} page
|
|
14
|
+
*/
|
|
15
|
+
function shellPageTitle(page) {
|
|
16
|
+
return page.getByTestId("jskit-shell-page-title");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Presses the shell's Up arrow and waits for the URL to change. It waits for the arrow first, so a navigation that
|
|
21
|
+
* is still opening the page has finished before the starting URL is read.
|
|
22
|
+
* @param {import("@playwright/test").Page} page
|
|
23
|
+
*/
|
|
24
|
+
async function pressShellBack(page) {
|
|
25
|
+
const button = shellBackButton(page);
|
|
26
|
+
await button.waitFor();
|
|
27
|
+
const before = page.url();
|
|
28
|
+
await button.click();
|
|
29
|
+
await page.waitForURL((url) => url.href !== before);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { pressShellBack, shellBackButton, shellPageTitle };
|