@jskit-ai/shell-web 0.2.50 → 0.2.52

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
+ - **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
+ - 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`.
5
7
  - `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.
6
8
  - The environment banner of a staging page that real people use (its server has `STAGING_REACHES_REAL_PEOPLE=true`, so the page carries the kernel's `jskit-staging-reaches-real-people` tag) reads "Staging · real people", described as "Staging that real people use: email and text messages reach the people they are for, other messages are logged and payments use the sandbox.", in place of the test-copy wording; `installAppEnvironmentBanner` takes `reachesRealPeople`, read from the page when omitted. New message keys: `jskit.shell.appEnvironment.stagingRealPeople` and `stagingRealPeopleDescription`. Every other page's banner is unchanged.
7
9
  - A navigation rail label never breaks inside a word. A label wider than the rail wraps between its words to a second line, as Material 3's rail labels do, and only a label that needs a third line ends its second in an ellipsis, as before; a single word wider than the rail now ends in an ellipsis too, where it was split across two lines ("Administrati" over "on").
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { ref } from "vue";
3
- import { RouterLink } from "vue-router";
3
+ import { RouterLink, useRoute } from "vue-router";
4
4
  import { useShellWebErrorRuntime } from "@jskit-ai/shell-web/client/error";
5
5
  import ShellPrimaryAction from "../../../src/client/components/ShellPrimaryAction.vue";
6
6
 
@@ -10,8 +10,10 @@ import ShellPrimaryAction from "../../../src/client/components/ShellPrimaryActio
10
10
  // while the dialog is open), "Remove access" (a second dialog over the first) and "Open contacts" (a link that leaves
11
11
  // the page with the dialog open). "Note details" opens a dialog from its activator; "Report a problem" opens the
12
12
  // shell's own error dialog. The note's "Archive note" and the dialog's "Remove access" each have a tooltip and open a
13
- // dialog. Presses of the note's Edit and the dialogs' actions are counted.
13
+ // dialog. Presses of the note's Edit and the dialogs' actions are counted. `?unreadable=1` adds a line of text no one can
14
+ // read (#f2f2f2 on #f9f9ff, 1.07:1), which an accessibility check must fail.
14
15
  const errorRuntime = useShellWebErrorRuntime();
16
+ const unreadable = useRoute().query.unreadable === "1";
15
17
  const invite = ref(false);
16
18
  const removeAccess = ref(false);
17
19
  const archive = ref(false);
@@ -75,6 +77,9 @@ function reportProblem() {
75
77
  <v-btn variant="text" data-testid="fixture-report-problem" @click="reportProblem">Report a problem</v-btn>
76
78
  </div>
77
79
  <p data-testid="fixture-notes-presses">{{ presses.join(",") }}</p>
80
+ <p v-if="unreadable" data-testid="fixture-unreadable" style="background: #f9f9ff; color: #f2f2f2;">
81
+ This line is unreadable on purpose.
82
+ </p>
78
83
 
79
84
  <v-dialog v-model="invite" max-width="480" height="600" aria-label="Invite someone">
80
85
  <v-card title="Invite someone" data-testid="fixture-invite-dialog">
@@ -211,6 +211,16 @@ const placements = [
211
211
  }
212
212
  ];
213
213
 
214
+ // `?barLabel=short` names Suppliers "Supplier directory", too wide for a phone's navigation bar, with "Suppliers" as its
215
+ // label there; `?barLabel=long` gives it the long label alone.
216
+ const barLabel = new URLSearchParams(window.location.search).get("barLabel");
217
+ if (barLabel === "short" || barLabel === "long") {
218
+ Object.assign(placements.find(({ id }) => id === "fixture.home.suppliers").props, {
219
+ label: "Supplier directory",
220
+ ...(barLabel === "short" ? { shortLabel: "Suppliers" } : {})
221
+ });
222
+ }
223
+
214
224
  // `?topRight=3` gives the top app bar three items of its own, as an app's tools, status and avatar; the status draws a
215
225
  // surface of its own on the page too.
216
226
  const statusPlacements = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/shell-web",
3
- "version": "0.2.50",
3
+ "version": "0.2.52",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -39,6 +39,7 @@
39
39
  "./client/composables/useShellPageClose": "./src/client/composables/useShellPageClose.js",
40
40
  "./client/composables/useShellWindowSizeClass": "./src/client/composables/useShellWindowSizeClass.js",
41
41
  "./client/directives/vPending": "./src/client/directives/vPending.js",
42
+ "./client/ui": "./src/client/ui/index.js",
42
43
  "./client/providers/ShellWebClientProvider": "./src/client/providers/ShellWebClientProvider.js",
43
44
  "./client/types": "./src/client/types.js",
44
45
  "./test/adaptiveShellSmoke": "./src/test/adaptiveShellSmoke.js",
@@ -47,14 +48,14 @@
47
48
  "./locales/en.json": "./locales/en.json"
48
49
  },
49
50
  "dependencies": {
50
- "@jskit-ai/architecture-inspector": "0.1.32"
51
+ "@jskit-ai/architecture-inspector": "0.1.34"
51
52
  },
52
53
  "devDependencies": {
53
- "@jskit-ai/material-web": "0.1.10",
54
+ "@jskit-ai/material-web": "0.1.11",
54
55
  "@vue/compiler-sfc": "3.5.44"
55
56
  },
56
57
  "peerDependencies": {
57
- "@jskit-ai/kernel": "0.2.33",
58
+ "@jskit-ai/kernel": "0.2.35",
58
59
  "pinia": "^4.0.3",
59
60
  "vue": "^3.5.44",
60
61
  "vue-router": "^5.3.1",
@@ -105,7 +106,8 @@
105
106
  "@jskit-ai/shell-web/client/types"
106
107
  ],
107
108
  "exclude": [
108
- "@jskit-ai/shell-web/client"
109
+ "@jskit-ai/shell-web/client",
110
+ "@jskit-ai/shell-web/client/ui"
109
111
  ]
110
112
  },
111
113
  "singleton": true
@@ -6,6 +6,11 @@ const props = defineProps({
6
6
  type: String,
7
7
  default: ""
8
8
  },
9
+ // The navigation bar's label when `label` is wider than a phone's slot.
10
+ shortLabel: {
11
+ type: String,
12
+ default: ""
13
+ },
9
14
  to: {
10
15
  type: String,
11
16
  default: ""
@@ -12,6 +12,11 @@ const props = defineProps({
12
12
  type: [String, Object],
13
13
  default: ""
14
14
  },
15
+ // The navigation bar's shorter label for the same destination: a menu shows the whole label.
16
+ shortLabel: {
17
+ type: [String, Object],
18
+ default: ""
19
+ },
15
20
  to: {
16
21
  type: String,
17
22
  default: ""
@@ -17,7 +17,8 @@ import ShellSectionTabLinkItem from "./ShellSectionTabLinkItem.vue";
17
17
 
18
18
  // A Material 3 navigation bar destination: its icon and its label below, which @jskit-ai/material-web's material.css
19
19
  // draws as it draws every v-bottom-navigation's buttons (the icon in its 64x32 indicator); the active one's icon is
20
- // the filled one. It is one only in ShellLayout's navigation bar; placed anywhere else (a page's section tabs), it is
20
+ // the filled one. The label is the destination's shortLabel, else its label: a phone gives each destination about 68px,
21
+ // and a label wider than its slot ends in an ellipsis there, never cut at both ends by the centred button. It is one only in ShellLayout's navigation bar; placed anywhere else (a page's section tabs), it is
21
22
  // a section tab, ShellSectionTabLinkItem, which a page.section-nav names itself. In the bar it is a text button, so
22
23
  // no app's filled-button defaults fill it.
23
24
  const props = defineProps(shellNavigationLinkProps);
@@ -25,7 +26,7 @@ const props = defineProps(shellNavigationLinkProps);
25
26
  const presentation = inject(SHELL_NAVIGATION_PRESENTATION_KEY, NO_SHELL_NAVIGATION_PRESENTATION);
26
27
  const inNavigationBar = computed(() => presentation.value === "bar");
27
28
  const { t } = useJskitText();
28
- const { resolvedLabel, resolvedTarget, resolvedIcon } = useShellNavigationLink(props);
29
+ const { resolvedShortLabel, resolvedTarget, resolvedIcon } = useShellNavigationLink(props);
29
30
  /** @type {{ aliases?: Record<string, unknown> }} */
30
31
  const iconOptions = inject(VUETIFY_ICONS_KEY, NO_VUETIFY_ICONS);
31
32
  const link = useLink({ to: computed(() => (resolvedTarget.value.sameOrigin && resolvedTarget.value.href) || "/") });
@@ -54,7 +55,7 @@ const displayIcon = computed(() =>
54
55
  stacked
55
56
  >
56
57
  <v-icon v-if="displayIcon" :icon="displayIcon" />
57
- <span class="tab-link-item__label">{{ resolvedLabel || t("jskit.shell.layout.tab") }}</span>
58
+ <span class="tab-link-item__label">{{ resolvedShortLabel || t("jskit.shell.layout.tab") }}</span>
58
59
  </v-btn>
59
60
  </template>
60
61
 
@@ -66,8 +67,14 @@ const displayIcon = computed(() =>
66
67
  padding-inline: 0;
67
68
  }
68
69
 
70
+ /* The button's content, which clips, is the slot's width; the label is at most that, so its ellipsis shows. */
71
+ .tab-link-item :deep(.v-btn__content) {
72
+ max-width: 100%;
73
+ min-width: 0;
74
+ }
75
+
69
76
  .tab-link-item__label {
70
- max-width: 5.5rem;
77
+ max-width: 100%;
71
78
  overflow: hidden;
72
79
  text-overflow: ellipsis;
73
80
  white-space: nowrap;
@@ -14,6 +14,12 @@ const shellNavigationLinkProps = Object.freeze({
14
14
  type: [String, Object],
15
15
  default: ""
16
16
  },
17
+ // The label in the navigation bar, where a phone gives each destination about 68px; as `label`, and `label` when
18
+ // empty. Menus, the rail and the drawer show `label`.
19
+ shortLabel: {
20
+ type: [String, Object],
21
+ default: ""
22
+ },
17
23
  to: {
18
24
  type: String,
19
25
  default: ""
@@ -53,6 +59,7 @@ function useShellNavigationLink(props) {
53
59
  const { context: placementContext } = useWebPlacementContext();
54
60
  const { text } = useJskitText();
55
61
  const resolvedLabel = computed(() => text(props.label));
62
+ const resolvedShortLabel = computed(() => text(props.shortLabel) || resolvedLabel.value);
56
63
 
57
64
  const resolvedTo = computed(() => {
58
65
  const currentSurfaceId = resolveSurfaceIdFromPlacementPathname(placementContext.value, route.path);
@@ -81,6 +88,7 @@ function useShellNavigationLink(props) {
81
88
 
82
89
  return {
83
90
  resolvedLabel,
91
+ resolvedShortLabel,
84
92
  resolvedTarget,
85
93
  resolvedIcon
86
94
  };
@@ -28,6 +28,8 @@
28
28
  * The props of a surface-aware menu or tab link.
29
29
  * @typedef {object} ShellNavigationLinkProps
30
30
  * @property {string | { key: string, fallback?: string }} label A message key, `{ key, fallback }` or plain text.
31
+ * @property {string | { key: string, fallback?: string }} [shortLabel] The label in the navigation bar, as `label`;
32
+ * `label` when empty. A phone's bar gives each destination about 68px, and a label wider than that ends in an ellipsis.
31
33
  * @property {string} to
32
34
  * @property {string} icon
33
35
  * @property {string} surface
@@ -35,4 +37,13 @@
35
37
  * @property {string} unscopedSuffix
36
38
  */
37
39
 
40
+ /**
41
+ * The application's design system for JSKIT's views (`@jskit-ai/shell-web/client/ui`): the components a view draws its
42
+ * buttons and dialogs with, and the classes of its text by role. Material 3's unless the application provides its own.
43
+ * @typedef {object} ShellUi
44
+ * @property {import("vue").Component} Button A button: props `emphasis`, `tone`, `size`, `type`, `disabled`, `pending`, `block`, `href`, `icon`; the label in its default slot.
45
+ * @property {import("vue").Component} Dialog A modal dialog: props `open` and `title`, the event `close`; the body in its default slot and the actions in `actions`.
46
+ * @property {Readonly<Record<"title" | "heading" | "subheading" | "strong" | "lead" | "body" | "caption", string>>} text The class names of each text role.
47
+ */
48
+
38
49
  export {};
@@ -0,0 +1,41 @@
1
+ <script setup>
2
+ // The kit's Material button (shell-web's Button role), a Vuetify button: each emphasis is a Material 3 button type and
3
+ // each tone a colour role. A view's other attributes (class, data-testid, form, aria-*) and listeners reach the button.
4
+ // `type` applies to a button, `href` makes it a link.
5
+ const props = defineProps({
6
+ // high: the screen's main action. medium: a secondary action with a fill. subtle: a secondary action drawn with an
7
+ // outline, such as one of several equal choices. low: an action drawn as text alone.
8
+ emphasis: { type: String, default: "medium", validator: (value) => ["high", "medium", "subtle", "low"].includes(value) },
9
+ tone: { type: String, default: "accent", validator: (value) => ["accent", "neutral", "danger"].includes(value) },
10
+ // large: a form's main action, drawn bigger.
11
+ size: { type: String, default: "default", validator: (value) => ["default", "large"].includes(value) },
12
+ type: { type: String, default: "button" },
13
+ disabled: { type: Boolean, default: false },
14
+ // The action is running.
15
+ pending: { type: Boolean, default: false },
16
+ // The button takes the whole width of its container.
17
+ block: { type: Boolean, default: false },
18
+ href: { type: String, default: undefined },
19
+ // A leading icon, as an icon alias ("$google").
20
+ icon: { type: String, default: undefined }
21
+ });
22
+
23
+ const VARIANTS = Object.freeze({ high: "flat", medium: "tonal", subtle: "outlined", low: "text" });
24
+ const COLORS = Object.freeze({ accent: "primary", neutral: "secondary", danger: "error" });
25
+ </script>
26
+
27
+ <template>
28
+ <v-btn
29
+ :variant="VARIANTS[props.emphasis]"
30
+ :color="COLORS[props.tone]"
31
+ :size="props.size"
32
+ :type="props.href ? undefined : props.type"
33
+ :href="props.href"
34
+ :disabled="props.disabled"
35
+ :loading="props.pending"
36
+ :block="props.block"
37
+ :prepend-icon="props.icon"
38
+ >
39
+ <slot />
40
+ </v-btn>
41
+ </template>
@@ -0,0 +1,46 @@
1
+ <script setup>
2
+ import { useShellUiText } from "./shellUi.js";
3
+
4
+ // The kit's Material dialog (shell-web's Dialog role): a Vuetify dialog whose card holds the title, the body and the
5
+ // actions, the main one last. Escape and a click outside ask the view to close it (`close`); the view decides, and
6
+ // gives focus back where it was.
7
+ defineProps({
8
+ open: { type: Boolean, required: true },
9
+ // Names the dialog and heads it.
10
+ title: { type: String, required: true }
11
+ });
12
+ const emit = defineEmits(["close"]);
13
+ const text = useShellUiText();
14
+ </script>
15
+
16
+ <template>
17
+ <v-dialog
18
+ :model-value="open"
19
+ max-width="440"
20
+ :aria-label="title"
21
+ @update:model-value="(shown) => shown || emit('close')"
22
+ >
23
+ <v-card>
24
+ <v-card-text class="shell-ui-dialog">
25
+ <h2 :class="[text.heading, 'mb-2']">{{ title }}</h2>
26
+ <slot />
27
+ <div v-if="$slots.actions" class="shell-ui-dialog__actions">
28
+ <slot name="actions" />
29
+ </div>
30
+ </v-card-text>
31
+ </v-card>
32
+ </v-dialog>
33
+ </template>
34
+
35
+ <style scoped>
36
+ .shell-ui-dialog {
37
+ padding: 24px;
38
+ }
39
+
40
+ .shell-ui-dialog__actions {
41
+ display: flex;
42
+ flex-wrap: wrap;
43
+ justify-content: flex-end;
44
+ gap: 8px;
45
+ }
46
+ </style>
@@ -0,0 +1,9 @@
1
+ import ShellUiButton from "./ShellUiButton.vue";
2
+ import ShellUiDialog from "./ShellUiDialog.vue";
3
+ import { MATERIAL_TEXT, SHELL_UI_KEY, SHELL_UI_ROLES, SHELL_UI_TEXT_ROLES, defineShellUi } from "./shellUi.js";
4
+
5
+ // The application's design system for JSKIT's views: a view draws its buttons with the kit's Button, its dialogs with
6
+ // its Dialog and its text with its text classes. Without a kit, or for a role the kit leaves out, they are Material 3's.
7
+ const { provideShellUi, useShellUi } = defineShellUi({ Button: ShellUiButton, Dialog: ShellUiDialog, text: MATERIAL_TEXT });
8
+
9
+ export { MATERIAL_TEXT, SHELL_UI_KEY, SHELL_UI_ROLES, SHELL_UI_TEXT_ROLES, ShellUiButton, ShellUiDialog, provideShellUi, useShellUi };
@@ -0,0 +1,107 @@
1
+ import { inject } from "vue";
2
+
3
+ const SHELL_UI_KEY = "jskit.shell-web.ui.client";
4
+ // The kit's roles: the button and the dialog a JSKIT view draws, and the classes of its text.
5
+ const SHELL_UI_ROLES = Object.freeze(["Button", "Dialog", "text"]);
6
+ // A view's text by what it is: a page's title (its h1), a heading and a subheading inside a page or a dialog, a short
7
+ // emphasized line, lead text, body text and a caption.
8
+ const SHELL_UI_TEXT_ROLES = Object.freeze(["title", "heading", "subheading", "strong", "lead", "body", "caption"]);
9
+ // Material 3's type scale for each text role, as Vuetify's classes: what a JSKIT view drew before the kit.
10
+ const MATERIAL_TEXT = Object.freeze({
11
+ title: "text-headline-medium",
12
+ heading: "text-title-large",
13
+ subheading: "text-title-medium",
14
+ strong: "text-title-small",
15
+ lead: "text-body-large",
16
+ body: "text-body-medium",
17
+ caption: "text-body-small"
18
+ });
19
+
20
+ function isRecord(value) {
21
+ return value !== null && typeof value === "object" && !Array.isArray(value);
22
+ }
23
+
24
+ function shown(value) {
25
+ return typeof value === "string" ? `"${value}"` : String(value);
26
+ }
27
+
28
+ function component(role, value) {
29
+ if (typeof value !== "function" && !isRecord(value)) {
30
+ throw new TypeError(`Shell UI role "${role}" needs a Vue component, not ${shown(value)}.`);
31
+ }
32
+ return value;
33
+ }
34
+
35
+ function textClasses(text) {
36
+ if (!isRecord(text)) {
37
+ throw new TypeError('Shell UI role "text" needs an object of class names by text role.');
38
+ }
39
+ for (const [role, value] of Object.entries(text)) {
40
+ if (!SHELL_UI_TEXT_ROLES.includes(role)) {
41
+ throw new TypeError(`Shell UI text role "${role}" is not one of ${SHELL_UI_TEXT_ROLES.join(", ")}.`);
42
+ }
43
+ if (typeof value !== "string") {
44
+ throw new TypeError(`Shell UI text role "${role}" needs a class name, not ${shown(value)}.`);
45
+ }
46
+ }
47
+ return text;
48
+ }
49
+
50
+ /**
51
+ * The kit a view reads: the application's roles where it gave them, the defaults for the rest, each checked.
52
+ * @param {unknown} kit
53
+ * @param {import("../types.js").ShellUi} defaults
54
+ * @returns {import("../types.js").ShellUi}
55
+ */
56
+ function resolveShellUi(kit, defaults) {
57
+ if (kit === undefined) {
58
+ return defaults;
59
+ }
60
+ if (!isRecord(kit)) {
61
+ throw new TypeError("provideShellUi needs a kit object: { Button, Dialog, text }, each optional.");
62
+ }
63
+ for (const role of Object.keys(kit)) {
64
+ if (!SHELL_UI_ROLES.includes(role)) {
65
+ throw new TypeError(`Shell UI role "${role}" is not one of ${SHELL_UI_ROLES.join(", ")}.`);
66
+ }
67
+ }
68
+ return Object.freeze({
69
+ Button: Object.hasOwn(kit, "Button") ? component("Button", kit.Button) : defaults.Button,
70
+ Dialog: Object.hasOwn(kit, "Dialog") ? component("Dialog", kit.Dialog) : defaults.Dialog,
71
+ text: Object.freeze({ ...defaults.text, ...(Object.hasOwn(kit, "text") ? textClasses(kit.text) : {}) })
72
+ });
73
+ }
74
+
75
+ /**
76
+ * The kit's two functions over its defaults: `provideShellUi(vueApp, kit)`, which an application calls once, before it
77
+ * mounts, with the roles it draws in its own design system, and `useShellUi()`, which a view calls in its setup.
78
+ * @param {import("../types.js").ShellUi} defaults
79
+ */
80
+ function defineShellUi(defaults) {
81
+ return Object.freeze({
82
+ /**
83
+ * @param {{ provide: (key: string, value: unknown) => unknown }} vueApp
84
+ * @param {Partial<import("../types.js").ShellUi>} [kit]
85
+ */
86
+ provideShellUi(vueApp, kit) {
87
+ vueApp.provide(SHELL_UI_KEY, resolveShellUi(kit, defaults));
88
+ },
89
+ /** @returns {import("../types.js").ShellUi} */
90
+ useShellUi() {
91
+ return inject(SHELL_UI_KEY, defaults);
92
+ }
93
+ });
94
+ }
95
+
96
+ // What the kit's own Material components read where the application provided no kit: Material's text classes.
97
+ const MATERIAL_TEXT_ONLY = Object.freeze({ text: MATERIAL_TEXT });
98
+
99
+ /**
100
+ * The text classes the application provided, or Material's, for the kit's own Material components.
101
+ * @returns {Readonly<Record<string, string>>}
102
+ */
103
+ function useShellUiText() {
104
+ return inject(SHELL_UI_KEY, MATERIAL_TEXT_ONLY).text;
105
+ }
106
+
107
+ export { MATERIAL_TEXT, SHELL_UI_KEY, SHELL_UI_ROLES, SHELL_UI_TEXT_ROLES, defineShellUi, resolveShellUi, useShellUiText };
@@ -210,6 +210,85 @@ async function expectContentAwareDrawerFit(drawer, expect) {
210
210
  }
211
211
  }
212
212
 
213
+ // A phone's navigation bar gives each destination about 68px. Lists each label it does not show whole: one that ends in
214
+ // an ellipsis, and one cut by its destination or by anything in it that clips (a centred label wider than its slot loses
215
+ // both ends: mobilynet's "Metal servers" read "etal server"). Badges, icons and visually hidden text are not labels.
216
+ function readNavigationBarLabelProblems(bottomNavigation) {
217
+ return bottomNavigation.evaluate((bar) => {
218
+ const problems = [];
219
+ const fix = "give its destination a shortLabel that fits";
220
+ const visuallyHidden = (element, destination) => {
221
+ for (let current = element; current && current !== destination; current = current.parentElement) {
222
+ const box = current.getBoundingClientRect();
223
+ const style = window.getComputedStyle(current);
224
+ if (box.width <= 1 || box.height <= 1 || style.visibility === "hidden" || style.clipPath.startsWith("inset(50%")) {
225
+ return true;
226
+ }
227
+ }
228
+ return false;
229
+ };
230
+ for (const destination of bar.querySelectorAll(".v-btn")) {
231
+ const texts = document.createTreeWalker(destination, NodeFilter.SHOW_TEXT, {
232
+ acceptNode: (node) => node.textContent.trim() && !node.parentElement.closest(".v-icon, .v-badge__badge") &&
233
+ !visuallyHidden(node.parentElement, destination)
234
+ ? NodeFilter.FILTER_ACCEPT
235
+ : NodeFilter.FILTER_REJECT
236
+ });
237
+ for (let node = texts.nextNode(); node; node = texts.nextNode()) {
238
+ const label = node.textContent.trim();
239
+ const range = document.createRange();
240
+ range.selectNodeContents(node);
241
+ const text = range.getBoundingClientRect();
242
+ range.detach?.();
243
+ if (text.width === 0) {
244
+ continue;
245
+ }
246
+ // The element that ends the text in an ellipsis, if one does: the text shows to its edges.
247
+ let shortenedBy = null;
248
+ for (let element = node.parentElement; element && destination.contains(element); element = element.parentElement) {
249
+ if (window.getComputedStyle(element).textOverflow === "ellipsis" && element.scrollWidth > element.clientWidth) {
250
+ shortenedBy = element;
251
+ break;
252
+ }
253
+ }
254
+ const shown = shortenedBy ? shortenedBy.getBoundingClientRect() : text;
255
+ let cut = false;
256
+ for (let element = shortenedBy ? shortenedBy.parentElement : node.parentElement;
257
+ element && destination.contains(element);
258
+ element = element.parentElement) {
259
+ if (element !== destination && window.getComputedStyle(element).overflowX === "visible") {
260
+ continue;
261
+ }
262
+ const box = element.getBoundingClientRect();
263
+ cut ||= shown.left < box.left - 0.5 || shown.right > box.right + 0.5;
264
+ }
265
+ const size = `${Math.round(text.width)}px of text in a ${Math.round(destination.getBoundingClientRect().width)}px destination`;
266
+ if (cut) {
267
+ problems.push(`"${label}" is cut in the navigation bar (${size}): ${fix}.`);
268
+ } else if (shortenedBy) {
269
+ problems.push(`"${label}" ends in an ellipsis in the navigation bar (${size}): ${fix}.`);
270
+ }
271
+ }
272
+ }
273
+ return problems;
274
+ });
275
+ }
276
+
277
+ // Every navigation bar label shows whole, once the fonts settle; otherwise fails naming each label and the fix.
278
+ async function expectWholeNavigationBarLabels(bottomNavigation, expect) {
279
+ let problems = [];
280
+ try {
281
+ await expect.poll(async () => {
282
+ problems = await readNavigationBarLabelProblems(bottomNavigation);
283
+ return problems.length;
284
+ }).toBe(0);
285
+ } catch (error) {
286
+ throw new Error(`The navigation bar must show each destination's label whole:\n- ${problems.join("\n- ")}`, {
287
+ cause: error
288
+ });
289
+ }
290
+ }
291
+
213
292
  async function readNavigationIconCenters(drawer, expect) {
214
293
  const icons = drawer.locator("a.shell-menu-link-item[href] .v-icon");
215
294
  await icons.first().waitFor({ state: "visible" });
@@ -424,6 +503,7 @@ async function runAdaptiveShellSmokeCase({
424
503
  for (const height of navButtonHeights) {
425
504
  expect(height).toBeGreaterThanOrEqual(48);
426
505
  }
506
+ await expectWholeNavigationBarLabels(bottomNavigation, expect);
427
507
 
428
508
  await pullToRefresh(page, expect);
429
509
  await expect.poll(() => bootstrapRequests).toBeGreaterThan(bootstrapRequestsBeforePull);
@@ -488,6 +568,7 @@ function runAdaptiveShellSmoke({
488
568
  export {
489
569
  DEFAULT_VIEWPORTS,
490
570
  expectNavigationBesideAppBar,
571
+ expectWholeNavigationBarLabels,
491
572
  isRequestedOrDescendantLocation,
492
573
  runAdaptiveShellSmoke,
493
574
  runAdaptiveShellSmokeCase
@@ -322,6 +322,63 @@ test("the shared smoke case passes a phone shell whose destinations are all in t
322
322
  await page.close();
323
323
  });
324
324
 
325
+ // A phone's navigation bar gives each destination about 68px. mobilynet's "Metal servers" showed there as "etal server" on
326
+ // every console page: the label ran wider than its slot and the centred button cut both its ends. A destination's
327
+ // shortLabel is its label in the bar; a longer label ends in an ellipsis inside its slot; and the shared smoke case,
328
+ // which apps' own checks run, refuses a bar label that is cut or ends in an ellipsis, naming it and the fix.
329
+ test("a navigation bar destination shows its shortLabel, a longer label ends in an ellipsis inside its slot, and the shared smoke case refuses a cut or shortened one", {
330
+ skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
331
+ timeout: 120_000
332
+ }, async (t) => {
333
+ const { vite, browser } = await startFixture(t);
334
+ const compact = DEFAULT_VIEWPORTS.find(({ name }) => name === "compact");
335
+ const expanded = DEFAULT_VIEWPORTS.find(({ name }) => name === "expanded");
336
+ const page = await browser.newPage({ baseURL: vite.baseURL });
337
+ const bar = page.getByTestId("jskit-shell-bottom-nav");
338
+ const fixWords = /give its destination a shortLabel/u;
339
+
340
+ // The short label is the bar's; the shared smoke case passes; the drawer of a wider window shows the whole label.
341
+ await runAdaptiveShellSmokeCase({ page, expect, smokePath: "/home?barLabel=short", viewport: compact });
342
+ await expect(bar.getByRole("link", { name: "Suppliers", exact: true })).toBeVisible();
343
+ await expect(bar.getByText("Supplier directory")).toHaveCount(0);
344
+ await page.setViewportSize({ width: expanded.width, height: expanded.height });
345
+ await expect(page.getByTestId("jskit-shell-drawer").getByRole("link", { name: "Supplier directory", exact: true })).toBeVisible();
346
+
347
+ // The long label alone ends in an ellipsis inside its own slot, and the shared smoke case names it.
348
+ await page.setViewportSize({ width: compact.width, height: compact.height });
349
+ await page.goto("/home?barLabel=long");
350
+ const longLabel = bar.getByRole("link", { name: "Supplier directory", exact: true }).locator(".tab-link-item__label");
351
+ await expect(longLabel).toBeVisible();
352
+ assert.deepEqual(await longLabel.evaluate((label) => {
353
+ const slot = label.closest(".v-btn").getBoundingClientRect();
354
+ const box = label.getBoundingClientRect();
355
+ return {
356
+ insideItsSlot: box.left >= slot.left - 0.5 && box.right <= slot.right + 0.5,
357
+ endsInEllipsis: window.getComputedStyle(label).textOverflow === "ellipsis" && label.scrollWidth > label.clientWidth
358
+ };
359
+ }), { insideItsSlot: true, endsInEllipsis: true });
360
+ await assert.rejects(
361
+ runAdaptiveShellSmokeCase({ page, expect, smokePath: "/home?barLabel=long", viewport: compact }),
362
+ (error) => /"Supplier directory" ends in an ellipsis in the navigation bar/u.test(error.message) && fixWords.test(error.message)
363
+ );
364
+ await page.close();
365
+
366
+ // A label the bar cuts without an ellipsis, as before: the shared smoke case names it too.
367
+ const cutPage = await browser.newPage({ baseURL: vite.baseURL });
368
+ await cutPage.addInitScript(() => {
369
+ document.addEventListener("DOMContentLoaded", () => {
370
+ const style = document.createElement("style");
371
+ style.textContent = ".tab-link-item__label { max-width: 5.5rem !important; text-overflow: clip !important; }";
372
+ document.head.append(style);
373
+ });
374
+ });
375
+ await assert.rejects(
376
+ runAdaptiveShellSmokeCase({ page: cutPage, expect, smokePath: "/home?barLabel=long", viewport: compact }),
377
+ (error) => /"Supplier directory" is cut in the navigation bar/u.test(error.message) && fixWords.test(error.message)
378
+ );
379
+ await cutPage.close();
380
+ });
381
+
325
382
  // Material 3 runs the rail and the standard drawer the window's full height beside the top app bar: their menu control
326
383
  // shares the page title's row, the destinations start right below it, and an inner page keeps its Up arrow in the bar.
327
384
  // A phone keeps its navigation bar and its modal drawer, opened from the app bar over everything.
@@ -0,0 +1,148 @@
1
+ import assert from "node:assert/strict";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import process from "node:process";
5
+ import test from "node:test";
6
+ import { fileURLToPath } from "node:url";
7
+ import { expect } from "@playwright/test";
8
+ import { sharedBrowserFixture } from "../../../tooling/testUtils/browserFixture.mjs";
9
+
10
+ // axe judges the contrast of every text on a shell page. Two things hid every text from it (color-contrast
11
+ // "incomplete", bgOverlap), so even text no one can read passed:
12
+ // - a closed menu that stays mounted, as ShellLayout's overflow menu does to keep the app bar's own items mounted on a
13
+ // phone, kept Vuetify's overlay root over the whole page: an absolute layer the size of the window at z-index 2000;
14
+ // - Vuetify draws a button's, chip's, list item's, card's and avatar's state layer and underlay over its label.
15
+ // material.css takes a closed overlay's root away once its content has gone, and draws the state layers under the
16
+ // content, as Material 3 orders them.
17
+ const SKIP = process.env.JSKIT_SHELL_WEB_BROWSER_INTEGRATION === "1"
18
+ ? false
19
+ : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1 to check axe judges the contrast of a shell page's text";
20
+ const FIXTURE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../fixtures/adaptive-shell");
21
+ const AXE_PATH = createRequire(import.meta.url).resolve("axe-core/axe.min.js");
22
+ const open = sharedBrowserFixture({ fixtureRoot: FIXTURE_ROOT, configFile: "vite.config.mjs" });
23
+ const UNREADABLE = "p[data-testid=\"fixture-unreadable\"]";
24
+
25
+ // What axe may leave unjudged or fail on these pages, each for its reason; anything else fails the test.
26
+ // - emptyValue: an empty field has no text to judge.
27
+ // - shortTextContent: a label of one or two characters (an icon's ligature, a count) is too short for axe to judge.
28
+ // - field outline: an outlined field's text (its value, or its floating label in the outline's notch) lies under the
29
+ // field's own outline, which Vuetify draws as boxes over the field, transparent but for their borders, so the text
30
+ // shows on the field's background (axe-core 4.11 also reports an empty input under its resting label so).
31
+ // - disabled chip: a disabled chip's label is Material 3's disabled colour (on-surface at 38%), which WCAG 1.4.3
32
+ // exempts as part of an inactive control; Vuetify marks the chip disabled only with a `disabled` attribute on a
33
+ // span, which axe does not read as disabled.
34
+ async function contrastResults(page) {
35
+ if (!(await page.evaluate(() => Boolean(globalThis.axe)))) {
36
+ await page.addScriptTag({ path: AXE_PATH });
37
+ }
38
+ return page.evaluate(async () => {
39
+ const results = await globalThis.axe.run(document, { runOnly: { type: "rule", values: ["color-contrast"] } });
40
+ const name = (element) => `${element.tagName.toLowerCase()}${[...element.classList].slice(0, 2).map((c) => `.${c}`).join("")}`;
41
+ const nodes = (outcome) => outcome.flatMap((rule) => rule.nodes).map((node) => ({
42
+ node,
43
+ element: document.querySelector(node.target[0]),
44
+ reason: node.any.map((check) => check.data?.messageKey || check.message).join("|")
45
+ }));
46
+ globalThis.axe.setup(document);
47
+ try {
48
+ const incomplete = nodes(results.incomplete).filter(({ element, reason }) => {
49
+ if (reason === "emptyValue" || reason === "shortTextContent") {
50
+ return false;
51
+ }
52
+ const over = (globalThis.axe.commons.dom.getTextElementStack(element)[0] || [])[0];
53
+ const field = element.closest(".v-field");
54
+ return !(reason === "bgOverlap" && field && over && field.contains(over) &&
55
+ over.closest(".v-field__outline, .v-field-label"));
56
+ }).map(({ node, element, reason }) => {
57
+ const stack = globalThis.axe.commons.dom.getTextElementStack(element)[0] || [];
58
+ const over = stack.indexOf(element) > 0 ? ` under ${name(stack[0])}` : "";
59
+ return `${reason}: ${node.target.join(" ")} "${element.textContent.trim().slice(0, 30)}"${over}`;
60
+ });
61
+ const violations = nodes(results.violations)
62
+ .filter(({ element }) => !element.closest(".v-chip--disabled"))
63
+ .map(({ node }) => `${node.target.join(" ")} ${JSON.stringify(node.any.map((check) => check.data?.contrastRatio))}`);
64
+ return { violations, incomplete };
65
+ } finally {
66
+ globalThis.axe.teardown();
67
+ }
68
+ });
69
+ }
70
+
71
+ async function expectJudged(page, where, violations) {
72
+ const results = await contrastResults(page);
73
+ assert.deepEqual(results.violations.map((violation) => violation.split(" [")[0]), violations,
74
+ `${where}: axe's color-contrast failures (${JSON.stringify(results.violations)})`);
75
+ assert.deepEqual(results.incomplete, [], `${where}: every text axe could not judge, with the element over it`);
76
+ }
77
+
78
+ test("axe judges every text on a shell page: unreadable text fails, and no closed menu or state layer covers a label", {
79
+ skip: SKIP,
80
+ timeout: 120_000
81
+ }, async (t) => {
82
+ const { vite, browser } = await open(t);
83
+
84
+ // A phone with the app bar's own items: ShellLayout mounts its overflow menu for them (closed, as all three fit);
85
+ // text buttons, a card and the FAB.
86
+ const phone = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 }, reducedMotion: "reduce" });
87
+ t.after(() => phone.close());
88
+ await phone.goto("/home/notes?topRight=3&unreadable=1");
89
+ await expect(phone.getByTestId("fixture-unreadable")).toBeVisible();
90
+ await expect(phone.getByTestId("jskit-shell-page-actions-overflow-items")).toBeAttached();
91
+ await expectJudged(phone, "notes at 390 with the overflow menu closed", [UNREADABLE]);
92
+
93
+ // Segmented buttons, filter chips, an active list item and fields; buttons and chips in every variant and state, an
94
+ // avatar and a pagination; cards in each variant; an outlined field with a value.
95
+ for (const route of ["/home/components?topRight=3", "/home/button-states", "/home/buttons", "/home/feedback"]) {
96
+ await phone.goto(route);
97
+ await expect(phone.getByTestId("jskit-shell-page-title")).toBeVisible();
98
+ await expectJudged(phone, `${route} at 390`, []);
99
+ }
100
+
101
+ const desktop = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 1280, height: 900 }, reducedMotion: "reduce" });
102
+ t.after(() => desktop.close());
103
+ await desktop.goto("/home/notes?unreadable=1");
104
+ await expect(desktop.getByTestId("fixture-unreadable")).toBeVisible();
105
+ await expectJudged(desktop, "notes at 1280", [UNREADABLE]);
106
+ });
107
+
108
+ test("a menu mounted while closed covers nothing, and still opens and closes with its animation", {
109
+ skip: SKIP,
110
+ timeout: 60_000
111
+ }, async (t) => {
112
+ const { vite, browser } = await open(t);
113
+ const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 } });
114
+ t.after(() => page.close());
115
+ await page.goto("/home/actions?topRight=3&title=Actions");
116
+ const items = page.getByTestId("jskit-shell-page-actions-overflow-items");
117
+ await expect(items).toBeAttached();
118
+ const root = () => items.evaluate((element) => getComputedStyle(element.closest(".v-overlay")).display);
119
+ assert.equal(await root(), "none", "the closed menu's overlay is not drawn");
120
+
121
+ await page.getByTestId("jskit-shell-page-actions-overflow").click();
122
+ await expect(page.getByRole("menu")).toBeVisible();
123
+ assert.notEqual(await root(), "none", "the open menu's overlay is drawn");
124
+ await items.evaluate((element) => Promise.all(element.closest(".v-overlay__content").getAnimations().map((animation) => animation.finished)));
125
+
126
+ // Frame by frame from Escape until the overlay is gone: its content animates out while the overlay is still drawn.
127
+ const frames = items.evaluate(async (element) => {
128
+ const content = element.closest(".v-overlay__content");
129
+ const overlay = content.parentElement;
130
+ const seen = [];
131
+ const started = performance.now();
132
+ while (performance.now() - started < 3000) {
133
+ const animating = content.getAnimations().some((animation) => animation.playState === "running");
134
+ seen.push({ overlay: getComputedStyle(overlay).display, content: content.style.display || "shown", animating });
135
+ if (seen.at(-1).overlay === "none") {
136
+ break;
137
+ }
138
+ await new Promise((resolve) => requestAnimationFrame(resolve));
139
+ }
140
+ return seen;
141
+ });
142
+ await page.keyboard.press("Escape");
143
+ const seen = await frames;
144
+ assert.ok(seen.some((frame) => frame.overlay !== "none" && frame.content === "shown" && frame.animating),
145
+ `the menu animates out while its overlay is drawn: ${JSON.stringify(seen.filter((_, index) => index % 4 === 0))}`);
146
+ assert.equal(seen.at(-1).overlay, "none", "once closed, the menu's overlay is gone again");
147
+ await expect(items).toBeAttached();
148
+ });
@@ -457,13 +457,21 @@ test("shell-web packageMetadata pre-optimizes package subpaths reached through d
457
457
  ]);
458
458
 
459
459
  assert.deepEqual(packageMetadata?.metadata?.client?.optimizeDeps?.exclude, [
460
- "@jskit-ai/shell-web/client"
460
+ "@jskit-ai/shell-web/client",
461
+ "@jskit-ai/shell-web/client/ui"
461
462
  ]);
462
463
  });
463
464
 
464
465
  test("all public shell JavaScript helpers are ready in a cold dependency scan", async () => {
465
- // The provider loads application-owned /src modules. It and Vue components stay source.
466
- const sourceEntries = new Set(["./client", "./client/providers/ShellWebClientProvider"]);
466
+ // The client entry and the UI kit export Vue components, which a dependency scan cannot prebundle, so each stays
467
+ // source by its own name in the exclude, never through another entry's prefix. The provider loads application-owned
468
+ // /src modules; the client bootstrap keeps it source by its own subpath, as the client entry is.
469
+ const vueEntries = ["./client", "./client/ui"];
470
+ const sourceEntries = new Set([...vueEntries, "./client/providers/ShellWebClientProvider"]);
471
+ for (const entry of vueEntries) {
472
+ assert.ok(packageMetadata.metadata.client.optimizeDeps.exclude.includes(`${packageJson.name}${entry.slice(1)}`),
473
+ `${packageJson.name}${entry.slice(1)} exports Vue components, so it stays source by its own name in the exclude.`);
474
+ }
467
475
  const helpers = Object.entries(packageJson.exports)
468
476
  .filter(([entry, target]) => entry.startsWith("./client/") && target.endsWith(".js") && !sourceEntries.has(entry))
469
477
  .map(([entry]) => `${packageJson.name}${entry.slice(1)}`)
@@ -0,0 +1,99 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFileSync } from "node:fs";
3
+ import test from "node:test";
4
+ import { fileURLToPath } from "node:url";
5
+ import { defineComponent } from "vue";
6
+ import {
7
+ MATERIAL_TEXT,
8
+ SHELL_UI_KEY,
9
+ SHELL_UI_ROLES,
10
+ SHELL_UI_TEXT_ROLES,
11
+ defineShellUi
12
+ } from "../src/client/ui/shellUi.js";
13
+ import { mountComposable } from "./support/mountComposable.js";
14
+
15
+ // Stand-ins for the Material button and dialog, which are Vue files a unit test cannot import.
16
+ const MaterialButton = defineComponent({ name: "MaterialButton", render: () => null });
17
+ const MaterialDialog = defineComponent({ name: "MaterialDialog", render: () => null });
18
+ const { provideShellUi, useShellUi } = defineShellUi({ Button: MaterialButton, Dialog: MaterialDialog, text: MATERIAL_TEXT });
19
+
20
+ function withKit(kit) {
21
+ return mountComposable(useShellUi, { plugins: [{ install: (app) => provideShellUi(app, kit) }] });
22
+ }
23
+
24
+ test("the kit's roles are a button, a dialog and seven text roles, whose Material classes are Material 3's type scale", () => {
25
+ assert.deepEqual(SHELL_UI_ROLES, ["Button", "Dialog", "text"]);
26
+ assert.deepEqual(SHELL_UI_TEXT_ROLES, ["title", "heading", "subheading", "strong", "lead", "body", "caption"]);
27
+ assert.deepEqual(MATERIAL_TEXT, {
28
+ title: "text-headline-medium",
29
+ heading: "text-title-large",
30
+ subheading: "text-title-medium",
31
+ strong: "text-title-small",
32
+ lead: "text-body-large",
33
+ body: "text-body-medium",
34
+ caption: "text-body-small"
35
+ });
36
+ assert.equal(SHELL_UI_KEY, "jskit.shell-web.ui.client");
37
+ });
38
+
39
+ test("an application that provides no kit gets the Material button, dialog and type classes", () => {
40
+ const { app, result } = mountComposable(useShellUi);
41
+ assert.equal(result.Button, MaterialButton);
42
+ assert.equal(result.Dialog, MaterialDialog);
43
+ assert.deepEqual(result.text, MATERIAL_TEXT);
44
+ app.unmount();
45
+ });
46
+
47
+ test("a partial kit replaces only the roles it names, and a partial text map only its own text roles", () => {
48
+ const AppButton = defineComponent({ name: "AppButton", render: () => null });
49
+ const { app, result } = withKit({ Button: AppButton, text: { title: "app-title", body: "app-body" } });
50
+ assert.equal(result.Button, AppButton);
51
+ assert.equal(result.Dialog, MaterialDialog);
52
+ assert.deepEqual(result.text, { ...MATERIAL_TEXT, title: "app-title", body: "app-body" });
53
+ assert.equal(Object.isFrozen(result), true);
54
+ assert.equal(Object.isFrozen(result.text), true);
55
+ app.unmount();
56
+ });
57
+
58
+ test("a functional component is a component, and an empty text class draws the role with no class", () => {
59
+ const AppDialog = () => null;
60
+ const { app, result } = withKit({ Dialog: AppDialog, text: { caption: "" } });
61
+ assert.equal(result.Dialog, AppDialog);
62
+ assert.equal(result.text.caption, "");
63
+ app.unmount();
64
+ });
65
+
66
+ test("a kit with an unknown role, an unknown text role, a role that is not a component or a class that is not a string is refused", () => {
67
+ const app = { provide: () => assert.fail("a refused kit is never provided") };
68
+ assert.throws(() => provideShellUi(app, { Buton: MaterialButton }), /Shell UI role "Buton" is not one of Button, Dialog, text\./u);
69
+ assert.throws(
70
+ () => provideShellUi(app, { text: { headline: "x" } }),
71
+ /Shell UI text role "headline" is not one of title, heading, subheading, strong, lead, body, caption\./u
72
+ );
73
+ assert.throws(() => provideShellUi(app, { Button: "AppButton" }), /Shell UI role "Button" needs a Vue component, not "AppButton"\./u);
74
+ assert.throws(() => provideShellUi(app, { Dialog: null }), /Shell UI role "Dialog" needs a Vue component, not null\./u);
75
+ assert.throws(() => provideShellUi(app, { text: { body: 14 } }), /Shell UI text role "body" needs a class name, not 14\./u);
76
+ assert.throws(() => provideShellUi(app, { text: ["app-title"] }), /Shell UI role "text" needs an object of class names by text role\./u);
77
+ assert.throws(() => provideShellUi(app, "kit"), /provideShellUi needs a kit object/u);
78
+ });
79
+
80
+ test("shell-web exports the kit at ./client/ui, with the Material button and dialog as its defaults", () => {
81
+ const packageJson = JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8"));
82
+ assert.equal(packageJson.exports["./client/ui"], "./src/client/ui/index.js");
83
+ const index = readFileSync(fileURLToPath(new URL("../src/client/ui/index.js", import.meta.url)), "utf8");
84
+ assert.match(index, /import ShellUiButton from "\.\/ShellUiButton\.vue";/u);
85
+ assert.match(index, /import ShellUiDialog from "\.\/ShellUiDialog\.vue";/u);
86
+ assert.match(index, /defineShellUi\(\{ Button: ShellUiButton, Dialog: ShellUiDialog, text: MATERIAL_TEXT \}\)/u);
87
+ assert.match(index, /export \{[^}]*\bprovideShellUi\b[^}]*\buseShellUi\b[^}]*\}/u);
88
+ });
89
+
90
+ test("the Material button draws each emphasis and tone as the Vuetify button the auth screens drew before the kit", () => {
91
+ const button = readFileSync(fileURLToPath(new URL("../src/client/ui/ShellUiButton.vue", import.meta.url)), "utf8");
92
+ assert.match(button, /high: "flat"/u);
93
+ assert.match(button, /medium: "tonal"/u);
94
+ assert.match(button, /subtle: "outlined"/u);
95
+ assert.match(button, /low: "text"/u);
96
+ assert.match(button, /accent: "primary"/u);
97
+ assert.match(button, /neutral: "secondary"/u);
98
+ assert.match(button, /danger: "error"/u);
99
+ });