@jskit-ai/shell-web 0.2.37 → 0.2.39
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 +3 -0
- package/fixtures/adaptive-shell/src/PendingActionsPage.vue +51 -0
- package/fixtures/adaptive-shell/src/PendingDialogPage.vue +57 -0
- package/fixtures/adaptive-shell/src/main.js +4 -0
- package/fixtures/{test-copy-banner → app-environment-banner}/index.html +1 -1
- package/fixtures/{test-copy-banner → app-environment-banner}/src/main.js +2 -2
- package/fixtures/app-environment-banner/vite.config.mjs +17 -0
- package/locales/en.json +7 -3
- package/package.json +6 -4
- package/src/client/appEnvironment/appEnvironmentBanner.js +89 -0
- package/src/client/components/ShellLayout.vue +2 -1
- package/src/client/components/ShellNavigationItem.vue +55 -26
- package/src/client/components/ShellPageAction.vue +18 -3
- package/src/client/components/ShellPageActionsTarget.vue +1 -1
- package/src/client/components/ShellPrimaryAction.vue +13 -2
- package/src/client/directives/vPending.js +111 -0
- package/src/client/index.js +1 -0
- package/src/client/providers/ShellWebClientProvider.js +6 -6
- package/src/client/support/navigationPresentation.js +8 -0
- package/src/client/support/pageActions.js +1 -0
- package/test/adaptiveShell.browser.test.js +95 -0
- package/test/{testCopyBanner.browser.test.js → appEnvironmentBanner.browser.test.js} +27 -13
- package/test/appEnvironmentBanner.test.js +71 -0
- package/test/pendingAction.browser.test.js +182 -0
- package/test/provider.test.js +2 -2
- package/test/vPending.test.js +151 -0
- package/fixtures/test-copy-banner/vite.config.mjs +0 -17
- package/src/client/sideEffects/testCopyBanner.js +0 -86
- package/test/testCopyBanner.test.js +0 -64
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- The drawer's and the rail's navigation lists hold only list items (WCAG 1.3.1, axe `aria-required-children`): in a Vuetify list, each `ShellNavigationItem` (a drawer or rail destination, and a `ShellMenuLinkItem` or `ShellSurfaceAwareMenuLinkItem` in an app's own `v-list`, such as a settings section's) is a `role="listitem"` element holding its link, and the drawer's divider between the primary and secondary destinations is `role="presentation"`. Vuetify makes a link item in a list the link itself and draws the divider as an `hr`, a separator, so these lists held links and a separator, which axe reported on every screen. The destinations stay where they were: the list item keeps the 4dp Vuetify sets between a nav list's items, and the rail still spaces its own. Outside a list, as in the navigation bar, an item is its link alone, as before, and attributes given to an item still land on its link.
|
|
6
|
+
- A command button keeps keyboard focus while its action runs. `ShellPageAction` and `ShellPrimaryAction` take `pending` (the action is running; give it a pending label, such as "Saving…"), and `loading` now means the same with Vuetify's progress indicator: the button stays enabled and focused, reads as unavailable (`aria-disabled="true"`) and ignores a click, Enter, Space or a form's implicit submission through it until the action settles, and it is never `disabled` meanwhile, even with `disabled` set too (as `addEdit.isSubmitDisabled` is while a save runs). Any other button, or a component that wraps one such as `v-fab`, takes the new `v-pending` directive (`@jskit-ai/shell-web/client/directives/vPending`, also `vPending` from `@jskit-ai/shell-web/client`). When the action settles with focus still on its button, focus moves to the first field its refusal marked (a Vuetify field in its error state, or one with `aria-invalid="true"`; within it, the first enabled control, so a radio group whose current choice is disabled gets its first enabled one) in the button's form, else its dialog, else the page; with none it stays on the button. Before, a running action's button was `disabled`, and Chromium moves the focus of a button that becomes disabled to the page body, so a keyboard user who pressed Save, Send or "Load more" landed back at the top of the page; a `loading` button kept focus but ran again on a second Enter. The app bar's overflow menu shows a pending action as unavailable, as it showed a loading one.
|
|
7
|
+
- **Breaking:** the shell's banner names the page's environment from the `jskit-app-environment` meta tag: "Development", "Test" or "Staging", and none in production. It replaces the "Test copy" banner; its id and test id are `jskit-app-environment-banner`, and the shell runtime's key is `appEnvironmentBanner`. It is still a note that never takes a click, with the environment's sentence as its description and no label.
|
|
5
8
|
- The navigation rail and the standard drawer run the window's full height beside the top app bar, as Material 3 draws them: their menu control sits in the page title's row and the first destination starts right below it. The app bar spanned the window's width and the rail or drawer started under it, adding a 56dp row of its own for the menu control, so the control sat under the title and the destinations started two rows down. They now come before the app bar in the layout (`order` -1, and -2 for the modal drawer, which still opens from the window's edge over the rail and the app bar), and their header is the app bar's 64dp. An inner page keeps its Up arrow in the app bar beside them. Compact windows are unchanged (navigation bar, modal drawer). `runAdaptiveShellSmokeCase` checks it on medium and expanded windows, and `expectNavigationBesideAppBar(navigation, expect)` is exported for a test of its own.
|
|
6
9
|
- 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.
|
|
7
10
|
- 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).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { reactive } from "vue";
|
|
3
|
+
import ShellPageAction from "../../../src/client/components/ShellPageAction.vue";
|
|
4
|
+
import ShellPageActions from "../../../src/client/components/ShellPageActions.vue";
|
|
5
|
+
import ShellPrimaryAction from "../../../src/client/components/ShellPrimaryAction.vue";
|
|
6
|
+
|
|
7
|
+
// Actions whose work runs until the test settles it: a page action that is `pending`, the primary page action with
|
|
8
|
+
// `loading` (Vuetify's progress indicator) and the screen's primary action (a FAB on compact windows) that is `pending`.
|
|
9
|
+
// Each press is counted, and `globalThis.settleFixtureAction(name)` ends that action's run.
|
|
10
|
+
const running = reactive({ sync: false, save: false, send: false });
|
|
11
|
+
const presses = reactive({ sync: 0, save: 0, send: 0 });
|
|
12
|
+
|
|
13
|
+
function start(name) {
|
|
14
|
+
presses[name] += 1;
|
|
15
|
+
running[name] = true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
globalThis.settleFixtureAction = (name) => {
|
|
19
|
+
running[name] = false;
|
|
20
|
+
};
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<section class="pa-4">
|
|
25
|
+
<ShellPageActions>
|
|
26
|
+
<ShellPageAction
|
|
27
|
+
icon="$refresh"
|
|
28
|
+
:label="running.sync ? 'Syncing…' : 'Sync'"
|
|
29
|
+
:pending="running.sync"
|
|
30
|
+
data-testid="fixture-pending-sync"
|
|
31
|
+
@click="start('sync')"
|
|
32
|
+
/>
|
|
33
|
+
<ShellPageAction
|
|
34
|
+
primary
|
|
35
|
+
icon="$check"
|
|
36
|
+
label="Save"
|
|
37
|
+
:loading="running.save"
|
|
38
|
+
data-testid="fixture-pending-save"
|
|
39
|
+
@click="start('save')"
|
|
40
|
+
/>
|
|
41
|
+
</ShellPageActions>
|
|
42
|
+
<ShellPrimaryAction
|
|
43
|
+
icon="$send"
|
|
44
|
+
:label="running.send ? 'Sending…' : 'Send'"
|
|
45
|
+
:pending="running.send"
|
|
46
|
+
data-testid="fixture-pending-send"
|
|
47
|
+
@click="start('send')"
|
|
48
|
+
/>
|
|
49
|
+
<p data-testid="fixture-pending-presses">sync={{ presses.sync }} save={{ presses.save }} send={{ presses.send }}</p>
|
|
50
|
+
</section>
|
|
51
|
+
</template>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import { vPending } from "../../../src/client/directives/vPending.js";
|
|
4
|
+
|
|
5
|
+
// A dialog's action with v-pending, in the dialog's form: Send invite runs until the test settles it, accepted
|
|
6
|
+
// (`globalThis.settleFixtureInvite()`) or refused with a field marked: Email (`settleFixtureInvite("Already invited.")`)
|
|
7
|
+
// or the Plan radio group, whose first choice, the current plan, is disabled (`settleFixtureInvite(message, "plan")`).
|
|
8
|
+
const dialog = ref(false);
|
|
9
|
+
const sending = ref(false);
|
|
10
|
+
const presses = ref(0);
|
|
11
|
+
const name = ref("");
|
|
12
|
+
const email = ref("");
|
|
13
|
+
const emailError = ref("");
|
|
14
|
+
const plan = ref("current");
|
|
15
|
+
const planError = ref("");
|
|
16
|
+
|
|
17
|
+
function invite() {
|
|
18
|
+
presses.value += 1;
|
|
19
|
+
emailError.value = "";
|
|
20
|
+
planError.value = "";
|
|
21
|
+
sending.value = true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
globalThis.settleFixtureInvite = (refusal = "", field = "email") => {
|
|
25
|
+
emailError.value = field === "email" ? refusal : "";
|
|
26
|
+
planError.value = field === "plan" ? refusal : "";
|
|
27
|
+
sending.value = false;
|
|
28
|
+
};
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<section class="pa-4">
|
|
33
|
+
<v-btn variant="text" data-testid="fixture-open-invite" @click="dialog = true">Invite someone</v-btn>
|
|
34
|
+
<p data-testid="fixture-invite-presses">{{ presses }}</p>
|
|
35
|
+
<v-dialog v-model="dialog" max-width="480">
|
|
36
|
+
<v-card title="Invite someone">
|
|
37
|
+
<v-form @submit.prevent="invite">
|
|
38
|
+
<v-card-text>
|
|
39
|
+
<v-text-field v-model="name" label="Name" />
|
|
40
|
+
<v-text-field v-model="email" label="Email" :error-messages="emailError" />
|
|
41
|
+
<v-radio-group v-model="plan" label="Plan" :error-messages="planError">
|
|
42
|
+
<v-radio label="Current plan" value="current" disabled />
|
|
43
|
+
<v-radio label="Larger plan" value="larger" />
|
|
44
|
+
</v-radio-group>
|
|
45
|
+
</v-card-text>
|
|
46
|
+
<v-card-actions>
|
|
47
|
+
<v-spacer />
|
|
48
|
+
<v-btn variant="text" @click="dialog = false">Cancel</v-btn>
|
|
49
|
+
<v-btn v-pending="sending" type="submit" variant="text" data-testid="fixture-send-invite">
|
|
50
|
+
{{ sending ? "Sending…" : "Send invite" }}
|
|
51
|
+
</v-btn>
|
|
52
|
+
</v-card-actions>
|
|
53
|
+
</v-form>
|
|
54
|
+
</v-card>
|
|
55
|
+
</v-dialog>
|
|
56
|
+
</section>
|
|
57
|
+
</template>
|
|
@@ -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 PendingActionsPage from "./PendingActionsPage.vue";
|
|
21
22
|
import DialogFeedbackPage from "./DialogFeedbackPage.vue";
|
|
22
23
|
import ReportsPage from "./ReportsPage.vue";
|
|
23
24
|
import ScreenPage from "./ScreenPage.vue";
|
|
@@ -341,6 +342,9 @@ const routes = [
|
|
|
341
342
|
{ path: "/home/components", component: ComponentsPage, meta: { jskit: { title: "Components" } } },
|
|
342
343
|
{ path: "/home/actions", component: ActionsPage, meta: { jskit: { title: "Actions" } } },
|
|
343
344
|
{ path: "/home/actions/new", component: ActionsFormPage, meta: { jskit: { title: "New entry", parent: "/actions" } } },
|
|
345
|
+
// Actions whose work the test holds, to check they keep keyboard focus while it runs.
|
|
346
|
+
{ path: "/home/pending", component: PendingActionsPage, meta: { jskit: { title: "Pending actions" } } },
|
|
347
|
+
{ path: "/home/pending-dialog", component: () => import("./PendingDialogPage.vue"), meta: { jskit: { title: "Invites" } } },
|
|
344
348
|
// A layout that draws its own top app bar from the shell's pieces.
|
|
345
349
|
{ path: "/home/studio", component: StudioPage, meta: { ownBar: true, jskit: { title: "Studio" } } },
|
|
346
350
|
{ path: "/home/studio/:id", component: StudioPage, meta: { ownBar: true, jskit: { parent: "/studio" } } },
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>JSKIT
|
|
6
|
+
<title>JSKIT environment banner</title>
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<button id="under-banner" type="button">Pressed 0 times</button>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAppEnvironmentBannerRuntime } from "../../../src/client/appEnvironment/appEnvironmentBanner.js";
|
|
2
2
|
|
|
3
3
|
// A control stretched across the top of the page, where the banner hangs, counts the presses that reach it.
|
|
4
4
|
const button = document.getElementById("under-banner");
|
|
@@ -9,5 +9,5 @@ button.addEventListener("click", () => {
|
|
|
9
9
|
button.textContent = `Pressed ${presses} times`;
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
createAppEnvironmentBannerRuntime().install();
|
|
13
13
|
document.documentElement.dataset.ready = "true";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from "node:url";
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
import { appEnvironment, withAppEnvironmentMeta } from "@jskit-ai/kernel/shared/support/appEnvironment";
|
|
4
|
+
|
|
5
|
+
// The page names the server's APP_ENV as a JSKIT server or development server names it.
|
|
6
|
+
const appEnvironmentPage = {
|
|
7
|
+
name: "fixture-app-environment-page",
|
|
8
|
+
transformIndexHtml: (html) => withAppEnvironmentMeta(html, appEnvironment(process.env))
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
root: fileURLToPath(new URL(".", import.meta.url)),
|
|
13
|
+
plugins: [appEnvironmentPage],
|
|
14
|
+
server: {
|
|
15
|
+
host: "127.0.0.1"
|
|
16
|
+
}
|
|
17
|
+
});
|
package/locales/en.json
CHANGED
|
@@ -46,9 +46,13 @@
|
|
|
46
46
|
"thisAppUpdated": "This app was updated. Reload to get the latest version.",
|
|
47
47
|
"unreachable": "{label} could not reach the server or network. Check the connection and try again."
|
|
48
48
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
49
|
+
"appEnvironment": {
|
|
50
|
+
"development": "Development",
|
|
51
|
+
"developmentDescription": "Development: emails and messages are logged, not sent; payments use the sandbox.",
|
|
52
|
+
"test": "Test",
|
|
53
|
+
"testDescription": "Test: emails and messages are logged, not sent; payments use the sandbox.",
|
|
54
|
+
"staging": "Staging",
|
|
55
|
+
"stagingDescription": "Staging: email and text messages reach only the staging test addresses, other messages are logged and payments use the sandbox."
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
}
|
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.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"./client/composables/useShellPageTitle": "./src/client/composables/useShellPageTitle.js",
|
|
39
39
|
"./client/composables/useShellPageClose": "./src/client/composables/useShellPageClose.js",
|
|
40
40
|
"./client/composables/useShellWindowSizeClass": "./src/client/composables/useShellWindowSizeClass.js",
|
|
41
|
+
"./client/directives/vPending": "./src/client/directives/vPending.js",
|
|
41
42
|
"./client/providers/ShellWebClientProvider": "./src/client/providers/ShellWebClientProvider.js",
|
|
42
43
|
"./client/types": "./src/client/types.js",
|
|
43
44
|
"./test/adaptiveShellSmoke": "./src/test/adaptiveShellSmoke.js",
|
|
@@ -46,14 +47,14 @@
|
|
|
46
47
|
"./locales/en.json": "./locales/en.json"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@jskit-ai/architecture-inspector": "0.1.
|
|
50
|
+
"@jskit-ai/architecture-inspector": "0.1.25"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@jskit-ai/material-web": "0.1.
|
|
53
|
+
"@jskit-ai/material-web": "0.1.9",
|
|
53
54
|
"@vue/compiler-sfc": "3.5.44"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
|
-
"@jskit-ai/kernel": "0.2.
|
|
57
|
+
"@jskit-ai/kernel": "0.2.27",
|
|
57
58
|
"pinia": "^4.0.3",
|
|
58
59
|
"vue": "^3.5.44",
|
|
59
60
|
"vue-router": "^5.3.1",
|
|
@@ -100,6 +101,7 @@
|
|
|
100
101
|
"@jskit-ai/shell-web/client/composables/useShellPageClose",
|
|
101
102
|
"@jskit-ai/shell-web/client/composables/useShellPageTitle",
|
|
102
103
|
"@jskit-ai/shell-web/client/composables/useShellWindowSizeClass",
|
|
104
|
+
"@jskit-ai/shell-web/client/directives/vPending",
|
|
103
105
|
"@jskit-ai/shell-web/client/types"
|
|
104
106
|
],
|
|
105
107
|
"exclude": [
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { pageAppEnvironment } from "@jskit-ai/kernel/shared/support/appEnvironment";
|
|
2
|
+
import { pageDocument } from "../browser.js";
|
|
3
|
+
import { useJskitText } from "../i18n.js";
|
|
4
|
+
|
|
5
|
+
const { t } = useJskitText();
|
|
6
|
+
|
|
7
|
+
const APP_ENVIRONMENT_BANNER_ID = "jskit-app-environment-banner";
|
|
8
|
+
// Every environment but production names itself on the page.
|
|
9
|
+
const BANNERED_ENVIRONMENTS = Object.freeze(["development", "test", "staging"]);
|
|
10
|
+
// Each bannered environment's label and description: `<prefix><environment>` and `<prefix><environment>Description`.
|
|
11
|
+
const BANNER_TEXT_PREFIX = "jskit.shell.appEnvironment.";
|
|
12
|
+
|
|
13
|
+
// A small tab hanging from the top edge, above everything, that never takes a click or a tap: it marks the page
|
|
14
|
+
// without covering a control the person needs. Amber with near-black text reads the same in light and dark themes.
|
|
15
|
+
const APP_ENVIRONMENT_BANNER_STYLE = Object.freeze({
|
|
16
|
+
position: "fixed",
|
|
17
|
+
top: "env(safe-area-inset-top, 0px)",
|
|
18
|
+
left: "50%",
|
|
19
|
+
transform: "translateX(-50%)",
|
|
20
|
+
zIndex: "2147483000",
|
|
21
|
+
pointerEvents: "none",
|
|
22
|
+
userSelect: "none",
|
|
23
|
+
padding: "2px 12px 3px",
|
|
24
|
+
borderRadius: "0 0 8px 8px",
|
|
25
|
+
background: "#ffb300",
|
|
26
|
+
color: "#1f1300",
|
|
27
|
+
font: "600 12px/16px system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif",
|
|
28
|
+
letterSpacing: "0.02em",
|
|
29
|
+
whiteSpace: "nowrap",
|
|
30
|
+
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.3)"
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function removeNothing() {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Shows the page's environment, "Development", "Test" or "Staging", from the page's APP_ENV meta tag, so everyone
|
|
37
|
+
* using a copy that is not production knows what it sends. It needs no application code: the shell adds it to the
|
|
38
|
+
* page's body, outside the application's own layout. A production page, or a page that names no environment, gets
|
|
39
|
+
* none. Returns the function that removes it.
|
|
40
|
+
* @param {object} [options]
|
|
41
|
+
* @param {Document | null} [options.documentObject]
|
|
42
|
+
* @param {"development" | "test" | "staging" | "production" | ""} [options.environment] The page's environment; read
|
|
43
|
+
* from its meta tag when omitted.
|
|
44
|
+
* @returns {() => void}
|
|
45
|
+
*/
|
|
46
|
+
function installAppEnvironmentBanner({ documentObject = pageDocument(), environment = pageAppEnvironment(documentObject) } = {}) {
|
|
47
|
+
if (!BANNERED_ENVIRONMENTS.includes(environment) || !documentObject?.body ||
|
|
48
|
+
documentObject.getElementById(APP_ENVIRONMENT_BANNER_ID)) {
|
|
49
|
+
return removeNothing;
|
|
50
|
+
}
|
|
51
|
+
const banner = documentObject.createElement("div");
|
|
52
|
+
banner.id = APP_ENVIRONMENT_BANNER_ID;
|
|
53
|
+
banner.setAttribute("data-testid", APP_ENVIRONMENT_BANNER_ID);
|
|
54
|
+
// A note read by its visible text, with the full sentence as its description. A label would make it a labelled
|
|
55
|
+
// element, which a browser test's field lookup such as `getByLabel("Email")` would also find.
|
|
56
|
+
banner.setAttribute("role", "note");
|
|
57
|
+
banner.setAttribute("aria-description", t(`${BANNER_TEXT_PREFIX}${environment}Description`));
|
|
58
|
+
banner.textContent = t(`${BANNER_TEXT_PREFIX}${environment}`);
|
|
59
|
+
// Through the style object, not a style attribute, so a strict content policy without inline styles allows it.
|
|
60
|
+
Object.assign(banner.style, APP_ENVIRONMENT_BANNER_STYLE);
|
|
61
|
+
documentObject.body.append(banner);
|
|
62
|
+
return () => banner.remove();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The shell's banner runtime: `install()` shows the banner as the shell boots, `dispose()` removes it as it shuts
|
|
67
|
+
* down.
|
|
68
|
+
* @param {Parameters<typeof installAppEnvironmentBanner>[0]} [options]
|
|
69
|
+
*/
|
|
70
|
+
function createAppEnvironmentBannerRuntime(options) {
|
|
71
|
+
let remove = removeNothing;
|
|
72
|
+
|
|
73
|
+
function install() {
|
|
74
|
+
remove();
|
|
75
|
+
remove = installAppEnvironmentBanner(options);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function dispose() {
|
|
79
|
+
remove();
|
|
80
|
+
remove = removeNothing;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return Object.freeze({
|
|
84
|
+
install,
|
|
85
|
+
dispose
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { APP_ENVIRONMENT_BANNER_ID, createAppEnvironmentBannerRuntime, installAppEnvironmentBanner };
|
|
@@ -351,7 +351,8 @@ onBeforeUnmount(() => {
|
|
|
351
351
|
target="shell-layout:primary-menu"
|
|
352
352
|
default
|
|
353
353
|
/>
|
|
354
|
-
|
|
354
|
+
<!-- A list holds only list items (WCAG 1.3.1), so the divider between the two groups is presentational. -->
|
|
355
|
+
<v-divider class="shell-layout__drawer-divider" role="presentation" />
|
|
355
356
|
<ShellOutlet target="shell-layout:secondary-menu" />
|
|
356
357
|
</v-list>
|
|
357
358
|
</ShellNavigationScope>
|
|
@@ -4,14 +4,20 @@ import { useLink } from "vue-router";
|
|
|
4
4
|
import {
|
|
5
5
|
NO_SHELL_NAVIGATION_PRESENTATION,
|
|
6
6
|
NO_VUETIFY_ICONS,
|
|
7
|
+
NO_VUETIFY_LIST,
|
|
7
8
|
SHELL_NAVIGATION_PRESENTATION_KEY,
|
|
8
9
|
VUETIFY_ICONS_KEY,
|
|
10
|
+
VUETIFY_LIST_KEY,
|
|
9
11
|
filledIconAlias
|
|
10
12
|
} from "../support/navigationPresentation.js";
|
|
11
13
|
import { activateShellNavigationLinkOnSpace } from "../support/navigationLinkKeyboard.js";
|
|
12
14
|
|
|
13
15
|
// One navigation destination as Material 3 draws it where it sits: a drawer item (a 56dp pill), a rail item (icon in a
|
|
14
|
-
// 56x32 indicator with its label below) or a list item. The active destination's icon is filled.
|
|
16
|
+
// 56x32 indicator with its label below) or a list item. The active destination's icon is filled. In a list (the
|
|
17
|
+
// drawer's, the rail's, a settings section's) it is a list item holding its link: Vuetify makes the item itself the
|
|
18
|
+
// link, and a list holds only list items (WCAG 1.3.1). Attributes land on the link.
|
|
19
|
+
defineOptions({ inheritAttrs: false });
|
|
20
|
+
|
|
15
21
|
const props = defineProps({
|
|
16
22
|
label: {
|
|
17
23
|
type: String,
|
|
@@ -49,38 +55,61 @@ const active = computed(() =>
|
|
|
49
55
|
);
|
|
50
56
|
const displayIcon = computed(() => (active.value ? filledIconAlias(props.icon, iconOptions.aliases) : props.icon));
|
|
51
57
|
const rail = computed(() => presentation.value === "rail");
|
|
58
|
+
/** @type {object | null} */
|
|
59
|
+
const list = inject(VUETIFY_LIST_KEY, NO_VUETIFY_LIST);
|
|
60
|
+
// Vuetify gives an item in a list the role "link" when it links somewhere, and "listitem" when it doesn't.
|
|
61
|
+
const listItem = computed(() => Boolean(list && props.href));
|
|
62
|
+
|
|
63
|
+
// What holds an item outside a list: nothing, the link stands alone.
|
|
64
|
+
const Unwrapped = (_props, { slots }) => slots.default();
|
|
65
|
+
Unwrapped.inheritAttrs = false;
|
|
52
66
|
</script>
|
|
53
67
|
|
|
54
68
|
<template>
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
:
|
|
59
|
-
:href="props.sameOrigin ? undefined : props.href"
|
|
60
|
-
:active="active"
|
|
61
|
-
:disabled="props.disabled"
|
|
62
|
-
:ripple="false"
|
|
63
|
-
@keydown.space="activateShellNavigationLinkOnSpace"
|
|
69
|
+
<component
|
|
70
|
+
:is="listItem ? 'div' : Unwrapped"
|
|
71
|
+
:role="listItem ? 'listitem' : undefined"
|
|
72
|
+
:class="listItem ? ['shell-navigation-item', { 'shell-navigation-item--rail': rail }] : undefined"
|
|
64
73
|
>
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
<v-list-item
|
|
75
|
+
v-if="rail"
|
|
76
|
+
class="shell-menu-link-item shell-menu-link-item--rail"
|
|
77
|
+
:to="props.sameOrigin ? props.href : undefined"
|
|
78
|
+
:href="props.sameOrigin ? undefined : props.href"
|
|
79
|
+
:active="active"
|
|
80
|
+
:disabled="props.disabled"
|
|
81
|
+
:ripple="false"
|
|
82
|
+
v-bind="$attrs"
|
|
83
|
+
@keydown.space="activateShellNavigationLinkOnSpace"
|
|
84
|
+
>
|
|
85
|
+
<span class="shell-menu-link-item__indicator">
|
|
86
|
+
<v-icon v-if="displayIcon" :icon="displayIcon" />
|
|
87
|
+
</span>
|
|
88
|
+
<span class="shell-menu-link-item__rail-label">{{ props.label }}</span>
|
|
89
|
+
</v-list-item>
|
|
90
|
+
<v-list-item
|
|
91
|
+
v-else
|
|
92
|
+
class="shell-menu-link-item"
|
|
93
|
+
:title="props.label"
|
|
94
|
+
:to="props.sameOrigin ? props.href : undefined"
|
|
95
|
+
:href="props.sameOrigin ? undefined : props.href"
|
|
96
|
+
:prepend-icon="displayIcon || undefined"
|
|
97
|
+
:active="active"
|
|
98
|
+
:disabled="props.disabled"
|
|
99
|
+
v-bind="$attrs"
|
|
100
|
+
@keydown.space="activateShellNavigationLinkOnSpace"
|
|
101
|
+
/>
|
|
102
|
+
</component>
|
|
81
103
|
</template>
|
|
82
104
|
|
|
83
105
|
<style scoped>
|
|
106
|
+
/* A nav list spaces each item but its first 4dp below the one before (Vuetify's `.v-list--nav
|
|
107
|
+
.v-list-item:not(:first-child)`). In its list item the item is always a first child, so the list item keeps that
|
|
108
|
+
spacing; the rail spaces its destinations itself. */
|
|
109
|
+
.v-list--nav .shell-navigation-item:not(.shell-navigation-item--rail, :first-child) {
|
|
110
|
+
margin-top: 4px;
|
|
111
|
+
}
|
|
112
|
+
|
|
84
113
|
.shell-menu-link-item {
|
|
85
114
|
--v-activated-opacity: 0;
|
|
86
115
|
border-radius: 9999px;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, inject, mergeProps, onBeforeUnmount, onMounted, ref, useAttrs, useId } from "vue";
|
|
3
3
|
import { useShellWindowSizeClass } from "../composables/useShellWindowSizeClass.js";
|
|
4
4
|
import { useJskitText } from "../i18n.js";
|
|
5
|
+
import { vPending } from "../directives/vPending.js";
|
|
5
6
|
import { NO_SHELL_PAGE_ACTIONS_REGISTRY, SHELL_PAGE_ACTIONS_REGISTRY_KEY } from "../support/pageActions.js";
|
|
6
7
|
|
|
7
8
|
// One page action in the top app bar. On compact windows a secondary action shows as an icon button named by its
|
|
@@ -10,6 +11,10 @@ import { NO_SHELL_PAGE_ACTIONS_REGISTRY, SHELL_PAGE_ACTIONS_REGISTRY_KEY } from
|
|
|
10
11
|
// overflow menu, and on compact windows every action but the primary one joins it.
|
|
11
12
|
// Attributes such as `type="submit"` and `form` (so an app bar Save can submit the page's form), `target`,
|
|
12
13
|
// `data-testid` or `aria-*` land on the button, or on the menu item, in every form.
|
|
14
|
+
// While its action runs (`pending`, or `loading` with Vuetify's progress indicator in place of the label) the button
|
|
15
|
+
// keeps keyboard focus: it reads as unavailable and ignores activation until the action settles (v-pending), and it is
|
|
16
|
+
// never `disabled` meanwhile, so a `disabled` that also covers the running state (such as `addEdit.isSubmitDisabled`)
|
|
17
|
+
// keeps focus too.
|
|
13
18
|
defineOptions({ inheritAttrs: false });
|
|
14
19
|
|
|
15
20
|
const props = defineProps({
|
|
@@ -59,6 +64,11 @@ const props = defineProps({
|
|
|
59
64
|
type: Boolean,
|
|
60
65
|
default: false
|
|
61
66
|
},
|
|
67
|
+
// The action is running: give it a pending label, such as "Saving…".
|
|
68
|
+
pending: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: false
|
|
71
|
+
},
|
|
62
72
|
loading: {
|
|
63
73
|
type: Boolean,
|
|
64
74
|
default: false
|
|
@@ -72,6 +82,8 @@ const { isCompact } = useShellWindowSizeClass();
|
|
|
72
82
|
const resolvedLabel = computed(() => text(props.label));
|
|
73
83
|
const iconOnly = computed(() => Boolean(props.icon) && isCompact.value && !props.primary);
|
|
74
84
|
const color = computed(() => props.color || (props.primary ? "primary" : "on-surface-variant"));
|
|
85
|
+
const pending = computed(() => props.pending || props.loading);
|
|
86
|
+
const disabled = computed(() => props.disabled && !pending.value);
|
|
75
87
|
// A boolean `download` is the attribute without a file name.
|
|
76
88
|
const download = computed(() => (props.download === true ? "" : props.download || undefined));
|
|
77
89
|
|
|
@@ -95,7 +107,8 @@ const entry = {
|
|
|
95
107
|
color: props.color,
|
|
96
108
|
primary: props.primary,
|
|
97
109
|
overflow: props.overflow,
|
|
98
|
-
disabled:
|
|
110
|
+
disabled: disabled.value,
|
|
111
|
+
pending: pending.value,
|
|
99
112
|
loading: props.loading
|
|
100
113
|
})),
|
|
101
114
|
attrs,
|
|
@@ -123,6 +136,7 @@ onBeforeUnmount(() => {
|
|
|
123
136
|
<template #activator="{ props: tooltipProps }">
|
|
124
137
|
<v-btn
|
|
125
138
|
v-bind="mergeProps(attrs, tooltipProps)"
|
|
139
|
+
v-pending="pending"
|
|
126
140
|
class="shell-page-action"
|
|
127
141
|
:icon="props.icon"
|
|
128
142
|
variant="text"
|
|
@@ -131,7 +145,7 @@ onBeforeUnmount(() => {
|
|
|
131
145
|
:replace="props.replace"
|
|
132
146
|
:href="props.href"
|
|
133
147
|
:download="download"
|
|
134
|
-
:disabled="
|
|
148
|
+
:disabled="disabled"
|
|
135
149
|
:loading="props.loading"
|
|
136
150
|
:aria-label="resolvedLabel"
|
|
137
151
|
@click="handleClick"
|
|
@@ -141,6 +155,7 @@ onBeforeUnmount(() => {
|
|
|
141
155
|
<v-btn
|
|
142
156
|
v-else
|
|
143
157
|
v-bind="attrs"
|
|
158
|
+
v-pending="pending"
|
|
144
159
|
class="shell-page-action shell-page-action--labelled"
|
|
145
160
|
:variant="props.primary ? 'flat' : 'text'"
|
|
146
161
|
:color="color"
|
|
@@ -149,7 +164,7 @@ onBeforeUnmount(() => {
|
|
|
149
164
|
:replace="props.replace"
|
|
150
165
|
:href="props.href"
|
|
151
166
|
:download="download"
|
|
152
|
-
:disabled="
|
|
167
|
+
:disabled="disabled"
|
|
153
168
|
:loading="props.loading"
|
|
154
169
|
@click="handleClick"
|
|
155
170
|
>
|
|
@@ -45,7 +45,7 @@ watch(showsMenu, (shows) => {
|
|
|
45
45
|
// A menu item's props: the action's own attributes, then its label, icon, colour, link or download, and state.
|
|
46
46
|
function itemProps(entry) {
|
|
47
47
|
const state = entry.state.value;
|
|
48
|
-
const unavailable = Boolean(state.disabled || state.
|
|
48
|
+
const unavailable = Boolean(state.disabled || state.pending);
|
|
49
49
|
return mergeProps(entry.attrs, {
|
|
50
50
|
title: state.label,
|
|
51
51
|
prependIcon: state.icon || undefined,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
2
3
|
import { useShellWindowSizeClass } from "../composables/useShellWindowSizeClass.js";
|
|
4
|
+
import { vPending } from "../directives/vPending.js";
|
|
3
5
|
import { useJskitText } from "../i18n.js";
|
|
4
6
|
import ShellPageAction from "./ShellPageAction.vue";
|
|
5
7
|
import ShellPageActions from "./ShellPageActions.vue";
|
|
@@ -9,7 +11,8 @@ import ShellPageActions from "./ShellPageActions.vue";
|
|
|
9
11
|
// ones. It goes to `to`, or runs its click handler (a "New" that opens a dialog). Its layout order puts the FAB inside
|
|
10
12
|
// the shell's navigation bar, so it sits above the bar instead of over it, and it takes layout room (`layout`), so the
|
|
11
13
|
// shell's snackbar shows above it and the screen's last card scrolls clear of it. Attributes and the click handler land on
|
|
12
|
-
// the FAB, or on the bar's button.
|
|
14
|
+
// the FAB, or on the bar's button. While its action runs (`pending`, or `loading` with a progress indicator) it keeps
|
|
15
|
+
// keyboard focus and ignores activation, as ShellPageAction does.
|
|
13
16
|
defineOptions({ inheritAttrs: false });
|
|
14
17
|
|
|
15
18
|
const props = defineProps({
|
|
@@ -30,6 +33,11 @@ const props = defineProps({
|
|
|
30
33
|
type: Boolean,
|
|
31
34
|
default: false
|
|
32
35
|
},
|
|
36
|
+
// The action is running: give it a pending label, such as "Sending…".
|
|
37
|
+
pending: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
33
41
|
loading: {
|
|
34
42
|
type: Boolean,
|
|
35
43
|
default: false
|
|
@@ -37,11 +45,13 @@ const props = defineProps({
|
|
|
37
45
|
});
|
|
38
46
|
const { text } = useJskitText();
|
|
39
47
|
const { isCompact, isMedium } = useShellWindowSizeClass();
|
|
48
|
+
const pending = computed(() => props.pending || props.loading);
|
|
40
49
|
</script>
|
|
41
50
|
|
|
42
51
|
<template>
|
|
43
52
|
<v-fab
|
|
44
53
|
v-if="isCompact || isMedium"
|
|
54
|
+
v-pending="pending"
|
|
45
55
|
v-bind="$attrs"
|
|
46
56
|
class="shell-primary-action"
|
|
47
57
|
app
|
|
@@ -52,7 +62,7 @@ const { isCompact, isMedium } = useShellWindowSizeClass();
|
|
|
52
62
|
:prepend-icon="props.icon"
|
|
53
63
|
:text="text(props.label)"
|
|
54
64
|
:to="props.to"
|
|
55
|
-
:disabled="props.disabled"
|
|
65
|
+
:disabled="props.disabled && !pending"
|
|
56
66
|
:loading="props.loading"
|
|
57
67
|
/>
|
|
58
68
|
<ShellPageActions v-else>
|
|
@@ -63,6 +73,7 @@ const { isCompact, isMedium } = useShellWindowSizeClass();
|
|
|
63
73
|
:label="props.label"
|
|
64
74
|
:to="props.to"
|
|
65
75
|
:disabled="props.disabled"
|
|
76
|
+
:pending="props.pending"
|
|
66
77
|
:loading="props.loading"
|
|
67
78
|
/>
|
|
68
79
|
</ShellPageActions>
|