@jskit-ai/shell-web 0.2.13 → 0.2.15

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/fixtures/adaptive-shell/src/ActionsFormPage.vue +22 -0
  3. package/fixtures/adaptive-shell/src/ActionsPage.vue +74 -0
  4. package/fixtures/adaptive-shell/src/App.vue +1 -0
  5. package/fixtures/adaptive-shell/src/ButtonStatesPage.vue +63 -0
  6. package/fixtures/adaptive-shell/src/ButtonsPage.vue +33 -3
  7. package/fixtures/adaptive-shell/src/ComponentsPage.vue +178 -0
  8. package/fixtures/adaptive-shell/src/FeedbackPage.vue +59 -0
  9. package/fixtures/adaptive-shell/src/ReportsPage.vue +29 -0
  10. package/fixtures/adaptive-shell/src/StatusButton.vue +17 -0
  11. package/fixtures/adaptive-shell/src/TitleClaim.vue +17 -0
  12. package/fixtures/adaptive-shell/src/main.js +131 -5
  13. package/fixtures/production-build/index.html +15 -0
  14. package/fixtures/production-build/package.json +5 -0
  15. package/fixtures/production-build/src/App.vue +27 -0
  16. package/fixtures/production-build/src/componentChunk.css +5 -0
  17. package/fixtures/production-build/src/main.js +10 -0
  18. package/fixtures/production-build/vite.config.mjs +12 -0
  19. package/locales/en.json +1 -0
  20. package/package.json +9 -5
  21. package/patterns/application-shell/PATTERN.md +11 -6
  22. package/patterns/application-shell/example/src/components/menus/SectionTabLinkItem.vue +42 -0
  23. package/patterns/application-shell/example/src/pages/home.vue +1 -1
  24. package/patterns/application-shell/example/src/views/NotFound.vue +1 -1
  25. package/patterns/page-and-placement/PATTERN.md +6 -0
  26. package/patterns/page-and-placement/example/src/pages/home/reports.vue +9 -4
  27. package/patterns/page-and-placement/example/src/placementTopology.js +5 -3
  28. package/src/client/components/ShellErrorHost.vue +20 -1
  29. package/src/client/components/ShellLayout.vue +42 -27
  30. package/src/client/components/ShellNavigationItem.vue +8 -3
  31. package/src/client/components/ShellNavigationScope.vue +1 -1
  32. package/src/client/components/ShellOutlet.vue +12 -1
  33. package/src/client/components/ShellPageAction.vue +107 -28
  34. package/src/client/components/ShellPageActionsTarget.vue +81 -2
  35. package/src/client/components/ShellPrimaryAction.vue +69 -0
  36. package/src/client/components/ShellSectionTabLinkItem.vue +104 -0
  37. package/src/client/components/ShellTabLinkItem.vue +18 -3
  38. package/src/client/components/ShellUpButton.vue +13 -8
  39. package/src/client/composables/useShellAppBar.js +10 -1
  40. package/src/client/composables/useShellPageClose.js +18 -0
  41. package/src/client/index.js +3 -0
  42. package/src/client/navigation/shellNavigationRuntime.js +59 -12
  43. package/src/client/navigation/usePaths.js +13 -0
  44. package/src/client/navigation/useShellNavigation.js +2 -0
  45. package/src/client/providers/ShellWebClientProvider.js +25 -9
  46. package/src/client/support/drawerPresentation.js +23 -6
  47. package/src/client/support/navigationPresentation.js +1 -1
  48. package/src/client/support/pageActions.js +126 -0
  49. package/src/test/adaptiveShellSmoke.js +31 -16
  50. package/test/adaptiveShell.browser.test.js +1019 -334
  51. package/test/drawerPresentation.test.js +20 -2
  52. package/test/linkResolver.test.js +4 -0
  53. package/test/materialBaselines.browser.test.js +142 -27
  54. package/test/packageRouteParent.test.js +41 -0
  55. package/test/pageActions.test.js +84 -0
  56. package/test/productionBuild.browser.test.js +98 -0
  57. package/test/settingsPlacementContract.test.js +11 -4
  58. package/test/shellNavigationRuntime.test.js +272 -0
@@ -10,7 +10,11 @@ import {
10
10
  DEFAULT_SHELL_NAVIGATION_ITEM_SPACING,
11
11
  DEFAULT_SHELL_RAIL_WIDTH
12
12
  } from "../support/drawerWidth.js";
13
- import { normalizeDesktopDrawerClosedMode, shellLayoutHasDrawer } from "../support/drawerPresentation.js";
13
+ import {
14
+ normalizeDesktopDrawerClosedMode,
15
+ shellLayoutHasDrawer,
16
+ shellLayoutHasNavigationBar
17
+ } from "../support/drawerPresentation.js";
14
18
  import { resolveShellLayoutClass } from "../support/shellLayoutClass.js";
15
19
  import { resolveWindowSizeClass } from "../support/windowSizeClass.js";
16
20
  import { NO_SHELL_WEB_REFRESH_RUNTIME, SHELL_WEB_REFRESH_RUNTIME_KEY } from "../runtime/refreshRuntime.js";
@@ -86,9 +90,10 @@ const layoutClass = computed(() => resolveShellLayoutClass(display.width.value))
86
90
  const isCompactLayout = computed(() => layoutClass.value === "compact");
87
91
  // Compact and medium windows open the drawer over the page; a medium window keeps a navigation rail beside it.
88
92
  const modalLayout = computed(() => layoutClass.value !== "expanded");
89
- // A surface draws only the navigation it has: no navigation bar without bar destinations, and no rail or drawer (nor
90
- // its menu control) without menu destinations, as on an account surface whose shell has no navigation. The surface
91
- // identity (a workspace switcher) keeps the drawer beside other navigation, as on a phone.
93
+ // A surface draws only the navigation it has: no navigation bar without two bar destinations, and no rail or drawer
94
+ // (nor its menu control) without two menu destinations, as on an account surface whose shell has no navigation or a
95
+ // surface with Home alone. The surface identity (a workspace switcher) keeps the drawer beside other navigation, as on
96
+ // a phone.
92
97
  const slots = useSlots();
93
98
  const primaryMenu = useShellOutletPlacements("shell-layout:primary-menu");
94
99
  const secondaryMenu = useShellOutletPlacements("shell-layout:secondary-menu");
@@ -102,7 +107,12 @@ const hasDrawer = computed(() =>
102
107
  bottomNavigationCount: bottomNavigation.value.length
103
108
  })
104
109
  );
105
- const showsBottomNavigation = computed(() => isCompactLayout.value && bottomNavigation.value.length > 0);
110
+ const showsBottomNavigation = computed(() =>
111
+ isCompactLayout.value && shellLayoutHasNavigationBar({
112
+ bottomNavigationCount: bottomNavigation.value.length,
113
+ menuCount: primaryMenu.value.length + secondaryMenu.value.length
114
+ })
115
+ );
106
116
  const showsMediumRail = computed(() =>
107
117
  hasDrawer.value &&
108
118
  layoutClass.value === "medium" &&
@@ -135,7 +145,17 @@ const navigationStyle = computed(() => ({
135
145
  "--shell-navigation-rail-width": `${resolvedRailWidth.value}px`
136
146
  }));
137
147
 
138
- useShellAppBar();
148
+ // A compact bar keeps one trailing item so the title keeps its room: the page's primary action when it has one (a
149
+ // form's Save), otherwise the top-right item nearest the corner (the account menu). The other top-right items follow
150
+ // the page actions in the overflow menu. A layout's own top-right slot stays as it is.
151
+ const { pageActions } = useShellAppBar();
152
+ const topRight = useShellOutletPlacements("shell-layout:top-right");
153
+ const topRightInMenu = computed(() => {
154
+ if (!isCompactLayout.value || slots["top-right"]) {
155
+ return 0;
156
+ }
157
+ return Math.max(topRight.value.length - (pageActions.hasPrimary.value ? 0 : 1), 0);
158
+ });
139
159
 
140
160
  function updateScrolled() {
141
161
  scrolled.value = window.scrollY > 0;
@@ -182,11 +202,15 @@ onBeforeUnmount(() => {
182
202
  <p v-if="props.subtitle" class="shell-layout__page-subtitle">{{ text(props.subtitle) }}</p>
183
203
  </div>
184
204
 
185
- <ShellPageActionsTarget />
205
+ <ShellPageActionsTarget>
206
+ <template v-if="topRightInMenu > 0" #menu>
207
+ <ShellOutlet target="shell-layout:top-right" :end="topRightInMenu" />
208
+ </template>
209
+ </ShellPageActionsTarget>
186
210
 
187
211
  <slot name="top-right" :surface="resolvedSurface">
188
212
  <div class="shell-layout__top-right">
189
- <ShellOutlet target="shell-layout:top-right" />
213
+ <ShellOutlet target="shell-layout:top-right" :start="topRightInMenu" />
190
214
  </div>
191
215
  </slot>
192
216
  </div>
@@ -265,11 +289,11 @@ onBeforeUnmount(() => {
265
289
  :rail-width="resolvedRailWidth"
266
290
  @update:model-value="handleDrawerVisibilityChange"
267
291
  >
268
- <div class="shell-layout__drawer-header">
292
+ <!-- The menu control alone, its tooltip its label: no text beside it that would read as its label. -->
293
+ <div v-if="standardDrawerVisible" class="shell-layout__drawer-header">
269
294
  <v-btn
270
- v-if="standardDrawerVisible"
271
295
  ref="navigationToggle"
272
- :icon="drawerPresentation.rail ? '$menu' : '$menuOpen'"
296
+ icon
273
297
  variant="text"
274
298
  color="on-surface-variant"
275
299
  data-testid="jskit-shell-nav-toggle"
@@ -277,8 +301,10 @@ onBeforeUnmount(() => {
277
301
  :aria-expanded="drawerOpen"
278
302
  aria-controls="jskit-shell-drawer"
279
303
  @click="toggleDrawer"
280
- />
281
- <span v-if="!drawerPresentation.rail" class="shell-layout__surface-label">{{ resolvedSurfaceLabel }}</span>
304
+ >
305
+ <v-icon :icon="drawerPresentation.rail ? '$menu' : '$menuOpen'" />
306
+ <v-tooltip activator="parent" location="end" :text="drawerToggleLabel" />
307
+ </v-btn>
282
308
  </div>
283
309
  <div v-if="!drawerPresentation.rail" class="shell-layout__identity">
284
310
  <slot name="top-left" :surface="resolvedSurface">
@@ -320,7 +346,9 @@ onBeforeUnmount(() => {
320
346
  :height="80"
321
347
  grow
322
348
  >
323
- <ShellOutlet target="shell-layout:primary-bottom-nav" />
349
+ <ShellNavigationScope presentation="bar">
350
+ <ShellOutlet target="shell-layout:primary-bottom-nav" />
351
+ </ShellNavigationScope>
324
352
  </v-bottom-navigation>
325
353
 
326
354
  <v-bottom-sheet
@@ -441,19 +469,6 @@ onBeforeUnmount(() => {
441
469
  padding-inline-start: max(0px, calc(var(--shell-navigation-rail-width) / 2 - 24px));
442
470
  }
443
471
 
444
- .shell-layout__surface-label {
445
- color: rgb(var(--v-theme-on-surface-variant));
446
- font-size: 0.875rem;
447
- font-weight: 500;
448
- letter-spacing: 0.00625rem;
449
- line-height: 1.25rem;
450
- min-width: 0;
451
- overflow: hidden;
452
- padding-inline-start: 4px;
453
- text-overflow: ellipsis;
454
- white-space: nowrap;
455
- }
456
-
457
472
  .shell-layout__identity {
458
473
  min-width: 0;
459
474
  padding-inline: 12px;
@@ -157,16 +157,21 @@ const rail = computed(() => presentation.value === "rail");
157
157
  color: rgb(var(--v-theme-on-secondary-container));
158
158
  }
159
159
 
160
+ /* A rail label is shown in full: one wider than the rail wraps to a second line, as Material 3's rail labels do,
161
+ and only a label that needs a third line ends the second in an ellipsis. */
160
162
  .shell-menu-link-item__rail-label {
163
+ -webkit-box-orient: vertical;
164
+ -webkit-line-clamp: 2;
165
+ display: -webkit-box;
161
166
  font-size: 0.75rem;
162
167
  font-weight: 500;
163
168
  letter-spacing: 0.03125rem;
164
169
  line-height: 1rem;
165
- max-width: 72px;
170
+ max-width: calc(var(--shell-navigation-rail-width, 80px) - 8px);
166
171
  overflow: hidden;
172
+ overflow-wrap: break-word;
167
173
  text-align: center;
168
- text-overflow: ellipsis;
169
- white-space: nowrap;
174
+ white-space: normal;
170
175
  }
171
176
 
172
177
  .shell-menu-link-item--rail.v-list-item--active .shell-menu-link-item__rail-label {
@@ -2,7 +2,7 @@
2
2
  import { provide, toRef } from "vue";
3
3
  import { SHELL_NAVIGATION_PRESENTATION_KEY } from "../support/navigationPresentation.js";
4
4
 
5
- // Tells the navigation items inside it how to present: as a "rail" or a "drawer".
5
+ // Tells the navigation items inside it how to present: as a "rail", a "drawer" or the navigation "bar".
6
6
  const props = defineProps({
7
7
  presentation: {
8
8
  type: String,
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import { computed } from "vue";
2
3
  import { useShellOutletPlacements } from "../composables/useShellOutletPlacements.js";
3
4
  import { useJskitText } from "../i18n.js";
4
5
 
@@ -14,6 +15,15 @@ const props = defineProps({
14
15
  context: {
15
16
  type: Object,
16
17
  default: () => ({})
18
+ },
19
+ // Renders only the outlet's placements from `start` up to (not including) `end`, as Array.prototype.slice takes them.
20
+ start: {
21
+ type: Number,
22
+ default: 0
23
+ },
24
+ end: {
25
+ type: Number,
26
+ default: undefined
17
27
  }
18
28
  });
19
29
 
@@ -36,7 +46,8 @@ function placementProps(entry) {
36
46
  return translated;
37
47
  }
38
48
 
39
- const placements = useShellOutletPlacements(() => props.target, () => props.context);
49
+ const outletPlacements = useShellOutletPlacements(() => props.target, () => props.context);
50
+ const placements = computed(() => outletPlacements.value.slice(props.start, props.end));
40
51
  </script>
41
52
 
42
53
  <template>
@@ -1,11 +1,17 @@
1
1
  <script setup>
2
- import { computed } from "vue";
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 { NO_SHELL_PAGE_ACTIONS_REGISTRY, SHELL_PAGE_ACTIONS_REGISTRY_KEY } from "../support/pageActions.js";
5
6
 
6
7
  // One page action in the top app bar. On compact windows a secondary action shows as an icon button named by its
7
- // label; the page's primary action (`primary`, at most one) keeps its label as a filled button. Native button
8
- // attributes such as `type="submit"` and `form` pass through, so an app bar Save can submit the page's form.
8
+ // label; the page's primary action (`primary`, at most one) keeps its label as a filled button. In a bar that owns its
9
+ // actions (ShellLayout, or a layout that calls useShellAppBar()), an `overflow` action is an item of the bar's
10
+ // overflow menu, and on compact windows every action but the primary one joins it.
11
+ // Attributes such as `type="submit"` and `form` (so an app bar Save can submit the page's form), `target`,
12
+ // `data-testid` or `aria-*` land on the button, or on the menu item, in every form.
13
+ defineOptions({ inheritAttrs: false });
14
+
9
15
  const props = defineProps({
10
16
  // A message key, { key, fallback } or plain text.
11
17
  label: {
@@ -20,15 +26,35 @@ const props = defineProps({
20
26
  type: [String, Object],
21
27
  default: undefined
22
28
  },
23
- // A link outside the app (another origin); `to` is for the app's own pages.
29
+ // With `to`: replaces the current history entry instead of pushing one.
30
+ replace: {
31
+ type: Boolean,
32
+ default: false
33
+ },
34
+ // A link outside the app (another origin) or to a file; `to` is for the app's own pages.
24
35
  href: {
25
36
  type: String,
26
37
  default: undefined
27
38
  },
39
+ // With `href`: downloads the file instead of opening it, under the given file name when it is a string.
40
+ download: {
41
+ type: [Boolean, String],
42
+ default: undefined
43
+ },
28
44
  primary: {
29
45
  type: Boolean,
30
46
  default: false
31
47
  },
48
+ // A Material 3 colour role, such as "error" for a destructive action.
49
+ color: {
50
+ type: String,
51
+ default: undefined
52
+ },
53
+ // An item of the top app bar's overflow menu, such as a record's secondary actions.
54
+ overflow: {
55
+ type: Boolean,
56
+ default: false
57
+ },
32
58
  disabled: {
33
59
  type: Boolean,
34
60
  default: false
@@ -40,51 +66,104 @@ const props = defineProps({
40
66
  });
41
67
  const emit = defineEmits(["click"]);
42
68
 
69
+ const attrs = useAttrs();
43
70
  const { text } = useJskitText();
44
71
  const { isCompact } = useShellWindowSizeClass();
45
72
  const resolvedLabel = computed(() => text(props.label));
46
73
  const iconOnly = computed(() => Boolean(props.icon) && isCompact.value && !props.primary);
74
+ const color = computed(() => props.color || (props.primary ? "primary" : "on-surface-variant"));
75
+ // A boolean `download` is the attribute without a file name.
76
+ const download = computed(() => (props.download === true ? "" : props.download || undefined));
47
77
 
48
78
  function handleClick(event) {
49
79
  emit("click", event);
50
80
  }
81
+
82
+ const anchor = ref(null);
83
+ /** @type {import("../support/pageActions.js").ShellPageActionsRegistry} */
84
+ const registry = inject(SHELL_PAGE_ACTIONS_REGISTRY_KEY, NO_SHELL_PAGE_ACTIONS_REGISTRY);
85
+ /** @type {import("../support/pageActions.js").ShellPageActionEntry} */
86
+ const entry = {
87
+ id: useId(),
88
+ state: computed(() => ({
89
+ label: resolvedLabel.value,
90
+ icon: props.icon,
91
+ to: props.to,
92
+ href: props.href,
93
+ replace: props.replace,
94
+ download: download.value,
95
+ color: props.color,
96
+ primary: props.primary,
97
+ overflow: props.overflow,
98
+ disabled: props.disabled,
99
+ loading: props.loading
100
+ })),
101
+ attrs,
102
+ activate: handleClick,
103
+ anchor: null
104
+ };
105
+ const registration = registry.register(entry);
106
+ const inMenu = computed(() => registry.inMenu(entry));
107
+
108
+ onMounted(() => {
109
+ entry.anchor = anchor.value;
110
+ registration.placed();
111
+ });
112
+
113
+ onBeforeUnmount(() => {
114
+ registration.release();
115
+ });
51
116
  </script>
52
117
 
53
118
  <template>
54
- <v-tooltip v-if="iconOnly" :text="resolvedLabel" location="bottom">
55
- <template #activator="{ props: tooltipProps }">
119
+ <!-- The action's place in the bar, which orders the overflow menu; it draws nothing itself. -->
120
+ <span ref="anchor" class="shell-page-action-slot">
121
+ <template v-if="!inMenu">
122
+ <v-tooltip v-if="iconOnly" :text="resolvedLabel" location="bottom">
123
+ <template #activator="{ props: tooltipProps }">
124
+ <v-btn
125
+ v-bind="mergeProps(attrs, tooltipProps)"
126
+ class="shell-page-action"
127
+ :icon="props.icon"
128
+ variant="text"
129
+ :color="color"
130
+ :to="props.to"
131
+ :replace="props.replace"
132
+ :href="props.href"
133
+ :download="download"
134
+ :disabled="props.disabled"
135
+ :loading="props.loading"
136
+ :aria-label="resolvedLabel"
137
+ @click="handleClick"
138
+ />
139
+ </template>
140
+ </v-tooltip>
56
141
  <v-btn
57
- v-bind="tooltipProps"
58
- class="shell-page-action"
59
- :icon="props.icon"
60
- variant="text"
61
- color="on-surface-variant"
142
+ v-else
143
+ v-bind="attrs"
144
+ class="shell-page-action shell-page-action--labelled"
145
+ :variant="props.primary ? 'flat' : 'text'"
146
+ :color="color"
147
+ :prepend-icon="props.icon || undefined"
62
148
  :to="props.to"
149
+ :replace="props.replace"
63
150
  :href="props.href"
151
+ :download="download"
64
152
  :disabled="props.disabled"
65
153
  :loading="props.loading"
66
- :aria-label="resolvedLabel"
67
154
  @click="handleClick"
68
- />
155
+ >
156
+ {{ resolvedLabel }}
157
+ </v-btn>
69
158
  </template>
70
- </v-tooltip>
71
- <v-btn
72
- v-else
73
- class="shell-page-action shell-page-action--labelled"
74
- :variant="props.primary ? 'flat' : 'text'"
75
- :color="props.primary ? 'primary' : 'on-surface-variant'"
76
- :prepend-icon="props.icon || undefined"
77
- :to="props.to"
78
- :href="props.href"
79
- :disabled="props.disabled"
80
- :loading="props.loading"
81
- @click="handleClick"
82
- >
83
- {{ resolvedLabel }}
84
- </v-btn>
159
+ </span>
85
160
  </template>
86
161
 
87
162
  <style scoped>
163
+ .shell-page-action-slot {
164
+ display: contents;
165
+ }
166
+
88
167
  .shell-page-action--labelled {
89
168
  margin-inline: 4px;
90
169
  }
@@ -1,12 +1,81 @@
1
1
  <script setup>
2
+ import { computed, inject, mergeProps, useSlots } from "vue";
3
+ import { useJskitText } from "../i18n.js";
2
4
  import { SHELL_PAGE_ACTIONS_ID } from "../support/navigationPresentation.js";
5
+ import { NO_SHELL_PAGE_ACTIONS_REGISTRY, SHELL_PAGE_ACTIONS_REGISTRY_KEY } from "../support/pageActions.js";
3
6
 
4
- // Where the current page's ShellPageActions show: after the page title in the top app bar. ShellLayout's bar has it;
5
- // a layout that draws its own top app bar renders it once there and calls useShellAppBar().
7
+ // Where the current page's ShellPageActions show: after the page title in the top app bar, followed by the bar's
8
+ // overflow menu (Material 3's trailing "More actions" menu) when an action goes there. Its `menu` slot adds the
9
+ // bar's own items that don't fit (on a phone, ShellLayout's top-right items) below the actions. ShellLayout's bar has
10
+ // it; a layout that draws its own top app bar renders it once there and calls useShellAppBar().
11
+ const { t } = useJskitText();
12
+ /** @type {import("../support/pageActions.js").ShellPageActionsRegistry} */
13
+ const registry = inject(SHELL_PAGE_ACTIONS_REGISTRY_KEY, NO_SHELL_PAGE_ACTIONS_REGISTRY);
14
+ const menuEntries = registry.menuEntries;
15
+ const moreLabel = computed(() => t("jskit.shell.actions.more"));
16
+ const slots = useSlots();
17
+
18
+ // A menu item's props: the action's own attributes, then its label, icon, colour, link or download, and state.
19
+ function itemProps(entry) {
20
+ const state = entry.state.value;
21
+ const unavailable = Boolean(state.disabled || state.loading);
22
+ return mergeProps(entry.attrs, {
23
+ title: state.label,
24
+ prependIcon: state.icon || undefined,
25
+ baseColor: state.color,
26
+ to: state.to,
27
+ replace: state.replace,
28
+ href: state.href,
29
+ download: state.download,
30
+ disabled: unavailable,
31
+ "aria-disabled": unavailable ? "true" : undefined
32
+ });
33
+ }
6
34
  </script>
7
35
 
8
36
  <template>
9
37
  <div :id="SHELL_PAGE_ACTIONS_ID" class="shell-page-actions-target" />
38
+ <v-menu v-if="menuEntries.length > 0 || slots.menu" location="bottom end">
39
+ <template #activator="{ props: menuProps }">
40
+ <v-tooltip :text="moreLabel" location="bottom">
41
+ <template #activator="{ props: tooltipProps }">
42
+ <v-btn
43
+ v-bind="mergeProps(menuProps, tooltipProps)"
44
+ class="shell-page-actions-overflow"
45
+ icon="$moreVert"
46
+ variant="text"
47
+ color="on-surface-variant"
48
+ :aria-label="moreLabel"
49
+ data-testid="jskit-shell-page-actions-overflow"
50
+ />
51
+ </template>
52
+ </v-tooltip>
53
+ </template>
54
+ <v-list v-if="!slots.menu" role="menu" min-width="160">
55
+ <v-list-item
56
+ v-for="entry in menuEntries"
57
+ :key="entry.id"
58
+ v-bind="itemProps(entry)"
59
+ role="menuitem"
60
+ @click="entry.activate"
61
+ />
62
+ </v-list>
63
+ <!-- With the bar's own items too, the menu is a panel: the actions' list, then those items. -->
64
+ <v-sheet v-else class="shell-page-actions-target__panel" color="surface-container" elevation="2" rounded="4">
65
+ <v-list v-if="menuEntries.length > 0" role="menu" min-width="160">
66
+ <v-list-item
67
+ v-for="entry in menuEntries"
68
+ :key="entry.id"
69
+ v-bind="itemProps(entry)"
70
+ role="menuitem"
71
+ @click="entry.activate"
72
+ />
73
+ </v-list>
74
+ <div class="shell-page-actions-target__items" data-testid="jskit-shell-page-actions-overflow-items">
75
+ <slot name="menu" />
76
+ </div>
77
+ </v-sheet>
78
+ </v-menu>
10
79
  </template>
11
80
 
12
81
  <style scoped>
@@ -21,4 +90,14 @@ import { SHELL_PAGE_ACTIONS_ID } from "../support/navigationPresentation.js";
21
90
  .shell-page-actions-target:empty {
22
91
  display: none;
23
92
  }
93
+
94
+ .shell-page-actions-target__items {
95
+ align-items: center;
96
+ color: rgb(var(--v-theme-on-surface-variant));
97
+ display: flex;
98
+ flex-wrap: wrap;
99
+ gap: 4px;
100
+ justify-content: flex-end;
101
+ padding: 4px 8px;
102
+ }
24
103
  </style>
@@ -0,0 +1,69 @@
1
+ <script setup>
2
+ import { useShellWindowSizeClass } from "../composables/useShellWindowSizeClass.js";
3
+ import { useJskitText } from "../i18n.js";
4
+ import ShellPageAction from "./ShellPageAction.vue";
5
+ import ShellPageActions from "./ShellPageActions.vue";
6
+
7
+ // A screen's primary action, such as a list's "New", as Material 3 places it: an extended FAB above the navigation
8
+ // bar or beside the rail on compact and medium windows, the app bar's filled primary action on expanded and large
9
+ // ones. It goes to `to`, or runs its click handler (a "New" that opens a dialog). Its layout order puts the FAB inside
10
+ // the shell's navigation bar, so it sits above the bar instead of over it, and it takes layout room (`layout`), so the
11
+ // 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.
13
+ defineOptions({ inheritAttrs: false });
14
+
15
+ const props = defineProps({
16
+ // A message key, { key, fallback } or plain text.
17
+ label: {
18
+ type: [String, Object],
19
+ required: true
20
+ },
21
+ icon: {
22
+ type: String,
23
+ default: "$add"
24
+ },
25
+ to: {
26
+ type: [String, Object],
27
+ default: undefined
28
+ },
29
+ disabled: {
30
+ type: Boolean,
31
+ default: false
32
+ },
33
+ loading: {
34
+ type: Boolean,
35
+ default: false
36
+ }
37
+ });
38
+ const { text } = useJskitText();
39
+ const { isCompact, isMedium } = useShellWindowSizeClass();
40
+ </script>
41
+
42
+ <template>
43
+ <v-fab
44
+ v-if="isCompact || isMedium"
45
+ v-bind="$attrs"
46
+ class="shell-primary-action"
47
+ app
48
+ layout
49
+ extended
50
+ location="bottom end"
51
+ order="1"
52
+ :prepend-icon="props.icon"
53
+ :text="text(props.label)"
54
+ :to="props.to"
55
+ :disabled="props.disabled"
56
+ :loading="props.loading"
57
+ />
58
+ <ShellPageActions v-else>
59
+ <ShellPageAction
60
+ v-bind="$attrs"
61
+ primary
62
+ :icon="props.icon"
63
+ :label="props.label"
64
+ :to="props.to"
65
+ :disabled="props.disabled"
66
+ :loading="props.loading"
67
+ />
68
+ </ShellPageActions>
69
+ </template>
@@ -0,0 +1,104 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import { useLink } from "vue-router";
4
+ import {
5
+ shellNavigationLinkProps,
6
+ useShellNavigationLink
7
+ } from "../composables/useShellNavigationLink.js";
8
+ import { useJskitText } from "../i18n.js";
9
+
10
+ // A Material 3 primary tab that links to a section of a page (page.section-nav): its label in title-small, with the
11
+ // placement's icon above it when it names one, and under the active one's content a 3dp primary indicator with
12
+ // rounded top corners. The tabs sit in the page's own row, which draws the 1dp outline-variant divider under them
13
+ // and scrolls sideways when they don't fit; this is not the navigation bar's destination (ShellTabLinkItem).
14
+ const props = defineProps(shellNavigationLinkProps);
15
+ const { t } = useJskitText();
16
+ const { resolvedLabel, resolvedTarget, resolvedIcon } = useShellNavigationLink(props);
17
+ const link = useLink({ to: computed(() => (resolvedTarget.value.sameOrigin && resolvedTarget.value.href) || "/") });
18
+ const active = computed(() =>
19
+ resolvedTarget.value.sameOrigin && Boolean(props.exact ? link.isExactActive.value : link.isActive.value)
20
+ );
21
+ // Only an icon the placement names: a section tab guesses none from its label.
22
+ const icon = computed(() => (props.icon ? resolvedIcon.value : ""));
23
+ </script>
24
+
25
+ <template>
26
+ <v-btn
27
+ v-if="resolvedTarget.href"
28
+ class="section-tab-link-item text-none"
29
+ :class="{ 'section-tab-link-item--active': active, 'section-tab-link-item--icon': Boolean(icon) }"
30
+ :to="resolvedTarget.sameOrigin ? resolvedTarget.href : undefined"
31
+ :href="resolvedTarget.sameOrigin ? undefined : resolvedTarget.href"
32
+ :active="active"
33
+ :aria-current="active ? 'page' : undefined"
34
+ :disabled="props.disabled"
35
+ :exact="props.exact"
36
+ variant="text"
37
+ rounded="0"
38
+ min-width="0"
39
+ >
40
+ <v-icon v-if="icon" :icon="icon" class="section-tab-link-item__icon" />
41
+ <span class="section-tab-link-item__label">{{ resolvedLabel || t("jskit.shell.layout.tab") }}</span>
42
+ <span class="section-tab-link-item__indicator" aria-hidden="true" />
43
+ </v-btn>
44
+ </template>
45
+
46
+ <style scoped>
47
+ .section-tab-link-item {
48
+ color: rgb(var(--v-theme-on-surface-variant));
49
+ flex: 0 0 auto;
50
+ height: 48px;
51
+ padding-inline: 16px;
52
+ }
53
+
54
+ .section-tab-link-item--icon {
55
+ height: 64px;
56
+ }
57
+
58
+ .section-tab-link-item--active {
59
+ color: rgb(var(--v-theme-primary));
60
+ }
61
+
62
+ .section-tab-link-item :deep(.v-btn__content) {
63
+ align-self: stretch;
64
+ flex-direction: column;
65
+ gap: 2px;
66
+ justify-content: center;
67
+ position: relative;
68
+ }
69
+
70
+ /* The indicator marks the selection; the state layer stays for hover, focus and press. */
71
+ .section-tab-link-item.v-btn--active > :deep(.v-btn__overlay) {
72
+ opacity: 0;
73
+ }
74
+
75
+ .section-tab-link-item.v-btn--active:hover > :deep(.v-btn__overlay) {
76
+ opacity: var(--v-hover-opacity);
77
+ }
78
+
79
+ .section-tab-link-item.v-btn--active:focus-visible > :deep(.v-btn__overlay) {
80
+ opacity: var(--v-focus-opacity);
81
+ }
82
+
83
+ .section-tab-link-item__label {
84
+ font-size: 0.875rem;
85
+ font-weight: 500;
86
+ letter-spacing: 0.00625rem;
87
+ line-height: 1.25rem;
88
+ white-space: nowrap;
89
+ }
90
+
91
+ .section-tab-link-item__indicator {
92
+ background: rgb(var(--v-theme-primary));
93
+ border-radius: 3px 3px 0 0;
94
+ bottom: 0;
95
+ height: 3px;
96
+ inset-inline: 0;
97
+ opacity: 0;
98
+ position: absolute;
99
+ }
100
+
101
+ .section-tab-link-item--active .section-tab-link-item__indicator {
102
+ opacity: 1;
103
+ }
104
+ </style>