@jskit-ai/http-web 0.2.14 → 0.2.16

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 (40) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/fixtures/crud-list-date-filters/App.vue +3 -3
  3. package/fixtures/crud-list-date-filters/main.js +3 -9
  4. package/fixtures/crud-screens/App.vue +14 -0
  5. package/fixtures/crud-screens/index.html +12 -0
  6. package/fixtures/crud-screens/main.js +114 -0
  7. package/fixtures/crud-screens/vite.config.mjs +24 -0
  8. package/fixtures/select-field/main.js +3 -9
  9. package/locales/en.json +1 -2
  10. package/package.json +10 -8
  11. package/patterns/crud-screen-set/PATTERN.md +13 -0
  12. package/patterns/crud-screen-set/example/books/BookEditPage.vue +2 -0
  13. package/patterns/crud-screen-set/example/books/BookFormFields.vue +0 -6
  14. package/patterns/crud-screen-set/example/books/BookListPage.vue +5 -2
  15. package/patterns/crud-screen-set/example/books/BookNewPage.vue +2 -0
  16. package/patterns/crud-screen-set/example/books/BookViewPage.vue +5 -9
  17. package/src/client/components/CrudAddEditScreen.vue +70 -75
  18. package/src/client/components/CrudDeleteAction.vue +26 -14
  19. package/src/client/components/CrudListBulkActionSurface.vue +25 -20
  20. package/src/client/components/CrudListCreateAction.vue +38 -0
  21. package/src/client/components/CrudListDateFilterControl.vue +0 -1
  22. package/src/client/components/CrudListFilterControls.vue +0 -11
  23. package/src/client/components/CrudListFilterSheet.vue +59 -0
  24. package/src/client/components/CrudListFilterSurface.vue +58 -84
  25. package/src/client/components/CrudListRecordActionMenu.vue +14 -18
  26. package/src/client/components/CrudListScreen.vue +305 -245
  27. package/src/client/components/CrudViewScreen.vue +84 -99
  28. package/src/client/composables/records/useCrudAddEdit.js +6 -4
  29. package/src/client/composables/records/useView.js +1 -0
  30. package/src/client/composables/runtime/useViewCore.js +4 -4
  31. package/src/client/composables/useCrudDeleteAction.js +4 -3
  32. package/src/client/types.js +0 -1
  33. package/test/crudAddEditActions.test.js +19 -2
  34. package/test/crudListBulkActionSurface.test.js +3 -2
  35. package/test/crudListDateFilterSurface.browser.test.js +23 -14
  36. package/test/crudListFilterSurface.test.js +11 -7
  37. package/test/crudScreenComponents.test.js +89 -16
  38. package/test/crudScreenPattern.test.js +3 -0
  39. package/test/crudScreensMaterialBaselines.browser.test.js +170 -0
  40. package/test/translation.test.js +6 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - The CRUD screens are exact Material 3. The list is a search bar and one row of filter chips (the Filters chip opens every control in a bottom sheet on compact windows and a dialog on wider ones), then cards or, when the list is at least 720px wide, a table; cards and rows open their record when tapped and keep their other actions in a trailing overflow menu (a table row's Open is a trailing chevron, its Edit a pencil); cards no longer show the record's id; the create action is an extended FAB on compact and medium windows and the app bar's primary action on wider ones; empty and error states have an icon. The view is a header and value-first details, its Edit and Delete in the app bar; new and edit pages have Cancel and Save in the app bar.
6
+ - Save, Cancel and delete replace the form's history entry through shell-web's `useShellNavigation().finish()`, so Back no longer reopens a finished form; `useCrudDeleteAction()` no longer takes `router`. A view whose record is not found, or whose load is refused with 403, tells the shell (`pageUnavailable()`), so Up returning to it goes on to its parent. `useView()` (and `useViewCore()`) expose the failed load's HTTP status as `errorStatus`.
7
+ - `CrudViewScreen` no longer takes `resourcePluralTitle` and its "Back to" button is gone; `CrudListRecordActionMenu` takes the record's `title` instead of `buttonLabel`, `buttonVariant` and `buttonSize`. Message keys: `jskit.http.actions.actions` and `jskit.http.crud.view.backTo` are removed, `jskit.http.crud.list.recordActions` ("Actions for {title}") is new. `@mdi/js` is gone; icons are `$aliases`.
8
+ - The crud-screen-set pattern's pages declare their titles and parents in `definePage()`.
9
+ - Upgrading: see the guide's [Move an app to the Material 3 defaults](https://mobily-enterprises.github.io/jskit-ai/guide/app-setup/material-3-migration).
5
10
  - CRUD list filters show the presence choices and the default filter chips through the app's translator, from resource-crud-core's new catalog (registered with http-web's own). The English is unchanged.
6
11
 
7
12
  ## 0.2.0 - 2026-10-29
@@ -66,9 +66,9 @@ const contractSnapshot = computed(() => JSON.stringify({
66
66
  <v-main>
67
67
  <v-container class="date-filter-fixture py-8">
68
68
  <div class="mb-6">
69
- <div class="text-overline text-primary">JSKIT http-web</div>
70
- <h1 class="text-h4 mb-2">Date filter controls</h1>
71
- <p class="text-body-1 text-medium-emphasis mb-0">
69
+ <div class="text-label-small text-primary">JSKIT http-web</div>
70
+ <h1 class="text-headline-large mb-2">Date filter controls</h1>
71
+ <p class="text-body-large on-surface-variant mb-0">
72
72
  Date and date-range filters beside ordinary Vuetify selects.
73
73
  </p>
74
74
  </div>
@@ -1,22 +1,16 @@
1
1
  import { createApp } from "vue";
2
2
  import "vuetify/styles";
3
+ import "@jskit-ai/material-web/client/material.css";
3
4
  import { createVuetify } from "vuetify";
4
5
  import * as components from "vuetify/components";
5
6
  import * as directives from "vuetify/directives";
6
- import { aliases as mdiAliases, mdi } from "vuetify/iconsets/mdi-svg";
7
+ import { createMaterialVuetifyOptions } from "@jskit-ai/material-web/client";
7
8
  import App from "./App.vue";
8
9
 
9
10
  const vuetify = createVuetify({
10
11
  components,
11
12
  directives,
12
- theme: {
13
- defaultTheme: "light"
14
- },
15
- icons: {
16
- defaultSet: "mdi",
17
- aliases: mdiAliases,
18
- sets: { mdi }
19
- }
13
+ ...createMaterialVuetifyOptions()
20
14
  });
21
15
 
22
16
  createApp(App)
@@ -0,0 +1,14 @@
1
+ <script setup>
2
+ import { RouterView } from "vue-router";
3
+ import ShellErrorHost from "@jskit-ai/shell-web/client/components/ShellErrorHost";
4
+ import ShellLayout from "@jskit-ai/shell-web/client/components/ShellLayout";
5
+ </script>
6
+
7
+ <template>
8
+ <v-app>
9
+ <ShellLayout surface="app" surface-label="Library">
10
+ <RouterView />
11
+ </ShellLayout>
12
+ <ShellErrorHost />
13
+ </v-app>
14
+ </template>
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>CRUD screens Material 3 baselines</title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/main.js"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,114 @@
1
+ import { createApp } from "vue";
2
+ import { createPinia } from "pinia";
3
+ import { createRouter, createWebHistory } from "vue-router";
4
+ import { VueQueryPlugin } from "@tanstack/vue-query";
5
+ import { createVuetify } from "vuetify";
6
+ import * as components from "vuetify/components";
7
+ import * as directives from "vuetify/directives";
8
+ import "vuetify/styles";
9
+ import "@jskit-ai/material-web/client/material.css";
10
+ import { createMaterialVuetifyOptions } from "@jskit-ai/material-web/client";
11
+ import { shellScrollBehavior } from "@jskit-ai/kernel/client";
12
+ import { silentLogger } from "@jskit-ai/kernel/shared/support/silentLogger";
13
+ import ShellSurfaceAwareMenuLinkItem from "@jskit-ai/shell-web/client/components/ShellSurfaceAwareMenuLinkItem";
14
+ import ShellTabLinkItem from "@jskit-ai/shell-web/client/components/ShellTabLinkItem";
15
+ import { useShellErrorPresentationStore } from "../../../shell-web/src/client/stores/useShellErrorPresentationStore.js";
16
+ import { createWebPlacementRuntime } from "../../../shell-web/src/client/placement/runtime.js";
17
+ import { SHELL_WEB_PLACEMENT_RUNTIME_KEY } from "../../../shell-web/src/client/placement/inject.js";
18
+ import { SHELL_WEB_ERROR_RUNTIME_KEY } from "../../../shell-web/src/client/error/inject.js";
19
+ import { createErrorRuntime } from "../../../shell-web/src/client/error/runtime.js";
20
+ import { createDefaultMaterialErrorPresenters } from "../../../shell-web/src/client/error/presenters.js";
21
+ import { createErrorPresentationStore } from "../../../shell-web/src/client/error/store.js";
22
+ import {
23
+ SHELL_NAVIGATION_RUNTIME_KEY,
24
+ createShellNavigationRuntime
25
+ } from "../../../shell-web/src/client/navigation/shellNavigationRuntime.js";
26
+ import App from "./App.vue";
27
+ import BookEditPage from "../../patterns/crud-screen-set/example/books/BookEditPage.vue";
28
+ import BookListPage from "../../patterns/crud-screen-set/example/books/BookListPage.vue";
29
+ import BookNewPage from "../../patterns/crud-screen-set/example/books/BookNewPage.vue";
30
+ import BookViewPage from "../../patterns/crud-screen-set/example/books/BookViewPage.vue";
31
+
32
+ // The crud-screen-set pattern's pages in the real shell, as an application generated from it renders them. The
33
+ // file-based router's definePage() macro is a no-op here; each route carries the meta the page declares.
34
+ globalThis.definePage = () => {};
35
+
36
+ function destination(order, label, suffix, icon) {
37
+ return {
38
+ id: `fixture.${label.toLowerCase()}`,
39
+ target: "shell.primary-nav",
40
+ kind: "link",
41
+ surfaces: ["app"],
42
+ order,
43
+ props: { label, icon, surface: "app", scopedSuffix: suffix, unscopedSuffix: suffix, exact: suffix === "/" }
44
+ };
45
+ }
46
+
47
+ const menuRenderers = Object.freeze({ link: "fixture.surface-menu-link" });
48
+ const placementRuntime = createWebPlacementRuntime({
49
+ components: new Map([
50
+ ["fixture.surface-menu-link", ShellSurfaceAwareMenuLinkItem],
51
+ ["fixture.tab-link", ShellTabLinkItem]
52
+ ]),
53
+ logger: silentLogger
54
+ });
55
+ placementRuntime.replacePlacements([
56
+ destination(10, "Home", "/", "$home"),
57
+ destination(20, "Books", "/books", "$description"),
58
+ destination(30, "Settings", "/settings", "$settings")
59
+ ]);
60
+ placementRuntime.replacePlacementTopology([
61
+ {
62
+ id: "shell.primary-nav",
63
+ surfaces: ["*"],
64
+ default: true,
65
+ variants: {
66
+ compact: { outlet: "shell-layout:primary-bottom-nav", renderers: { link: "fixture.tab-link" } },
67
+ medium: { outlet: "shell-layout:primary-menu", renderers: menuRenderers },
68
+ expanded: { outlet: "shell-layout:primary-menu", renderers: menuRenderers }
69
+ }
70
+ }
71
+ ]);
72
+ placementRuntime.setContext({
73
+ surfaceConfig: {
74
+ defaultSurfaceId: "app",
75
+ enabledSurfaceIds: ["app"],
76
+ surfacesById: { app: { id: "app", routeBase: "/", pagesRoot: "", enabled: true, requiresWorkspace: false } }
77
+ }
78
+ });
79
+
80
+ const routes = [
81
+ { path: "/", component: { render: () => null }, meta: { jskit: { title: "Home" } } },
82
+ { path: "/settings", component: { render: () => null }, meta: { jskit: { title: "Settings" } } },
83
+ { path: "/books", component: BookListPage, meta: { jskit: { title: "Books" } } },
84
+ { path: "/books/new", component: BookNewPage, meta: { jskit: { title: "New book", parent: "/books" } } },
85
+ { path: "/books/:bookId", component: BookViewPage, meta: { jskit: { title: "Book", parent: "/books" } } },
86
+ {
87
+ path: "/books/:bookId/edit",
88
+ component: BookEditPage,
89
+ meta: { jskit: { title: "Edit book", parent: "/books/:bookId" } }
90
+ }
91
+ ];
92
+ const router = createRouter({ history: createWebHistory(), routes, scrollBehavior: shellScrollBehavior });
93
+ const navigationRuntime = createShellNavigationRuntime({ router });
94
+ navigationRuntime.install();
95
+
96
+ const pinia = createPinia();
97
+ const errorStore = createErrorPresentationStore();
98
+ const errorRuntime = createErrorRuntime({
99
+ presenters: createDefaultMaterialErrorPresenters({ store: errorStore }),
100
+ defaultPresenterId: "material.snackbar",
101
+ logger: silentLogger
102
+ });
103
+
104
+ const app = createApp(App);
105
+ app.use(pinia);
106
+ app.use(router);
107
+ app.use(VueQueryPlugin, { queryClientConfig: { defaultOptions: { queries: { retry: false } } } });
108
+ app.use(createVuetify({ components, directives, ...createMaterialVuetifyOptions() }));
109
+ app.provide(SHELL_WEB_PLACEMENT_RUNTIME_KEY, placementRuntime);
110
+ app.provide(SHELL_NAVIGATION_RUNTIME_KEY, navigationRuntime);
111
+ app.provide(SHELL_WEB_ERROR_RUNTIME_KEY, errorRuntime);
112
+ useShellErrorPresentationStore(pinia).attachRuntimeStore(errorStore);
113
+ await router.isReady();
114
+ app.mount("#app");
@@ -0,0 +1,24 @@
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { defineConfig } from "vite";
4
+ import vue from "@vitejs/plugin-vue";
5
+
6
+ const fixtureRoot = path.dirname(fileURLToPath(import.meta.url));
7
+
8
+ export default defineConfig({
9
+ root: fixtureRoot,
10
+ resolve: {
11
+ alias: {
12
+ // The crud-screen-set pattern's pages import the app's shared book resource from here.
13
+ "@local/books/shared": path.resolve(
14
+ fixtureRoot,
15
+ "../../../resource-crud-core/patterns/resource-contract/example/bookResource.js"
16
+ )
17
+ }
18
+ },
19
+ plugins: [vue()],
20
+ server: {
21
+ host: "127.0.0.1",
22
+ strictPort: true
23
+ }
24
+ });
@@ -1,22 +1,16 @@
1
1
  import { createApp } from "vue";
2
2
  import "vuetify/styles";
3
+ import "@jskit-ai/material-web/client/material.css";
3
4
  import { createVuetify } from "vuetify";
4
5
  import * as components from "vuetify/components";
5
6
  import * as directives from "vuetify/directives";
6
- import { aliases as mdiAliases, mdi } from "vuetify/iconsets/mdi-svg";
7
+ import { createMaterialVuetifyOptions } from "@jskit-ai/material-web/client";
7
8
  import App from "./App.vue";
8
9
 
9
10
  const vuetify = createVuetify({
10
11
  components,
11
12
  directives,
12
- theme: {
13
- defaultTheme: "light"
14
- },
15
- icons: {
16
- defaultSet: "mdi",
17
- aliases: mdiAliases,
18
- sets: { mdi }
19
- }
13
+ ...createMaterialVuetifyOptions()
20
14
  });
21
15
 
22
16
  createApp(App)
package/locales/en.json CHANGED
@@ -6,7 +6,6 @@
6
6
  "routeParamsRequired": "Route parameters {params} are required for surface \"{surface}\"."
7
7
  },
8
8
  "actions": {
9
- "actions": "Actions",
10
9
  "apply": "Apply",
11
10
  "cancel": "Cancel",
12
11
  "clear": "Clear",
@@ -66,6 +65,7 @@
66
65
  "loadErrorBody": "Check the connection and try again.",
67
66
  "loadFailed": "Unable to load records.",
68
67
  "newRecord": "New record",
68
+ "recordActions": "Actions for {title}",
69
69
  "selectRecord": "Select {title}",
70
70
  "selectVisibleRows": "Select visible rows"
71
71
  },
@@ -82,7 +82,6 @@
82
82
  "recordNotFound": "Record not found.",
83
83
  "records": "Records",
84
84
  "view": {
85
- "backTo": "Back to {resources}",
86
85
  "loadFailed": "Unable to load record.",
87
86
  "notFound": "This {resource} could not be found."
88
87
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/http-web",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test --test-concurrency=1"
@@ -47,18 +47,20 @@
47
47
  "./locales/en.json": "./locales/en.json"
48
48
  },
49
49
  "dependencies": {
50
- "@jskit-ai/resource-crud-core": "0.1.199",
51
- "@mdi/js": "^7.4.47"
50
+ "@jskit-ai/resource-crud-core": "0.1.201"
52
51
  },
53
52
  "peerDependencies": {
54
- "@jskit-ai/http-runtime": "0.2.8",
55
- "@jskit-ai/kernel": "0.2.8",
56
- "@jskit-ai/realtime": "0.2.12",
57
- "@jskit-ai/shell-web": "0.2.9",
53
+ "@jskit-ai/http-runtime": "0.2.10",
54
+ "@jskit-ai/kernel": "0.2.10",
55
+ "@jskit-ai/realtime": "0.2.14",
56
+ "@jskit-ai/shell-web": "0.2.11",
58
57
  "@tanstack/vue-query": "^5.90.5",
59
58
  "vue": "^3.5.13",
60
59
  "vue-router": "^5.0.4",
61
- "vuetify": "^4.0.0"
60
+ "vuetify": "^4.3.0"
61
+ },
62
+ "devDependencies": {
63
+ "@jskit-ai/material-web": "0.1.0"
62
64
  },
63
65
  "description": "Neutral Vue request, command, resource, and CRUD UI runtime for JSKIT web applications.",
64
66
  "jskit": {
@@ -35,7 +35,20 @@ questionnaire.
35
35
 
36
36
  - Route pages stay thin and use `useCrudListScreen()`, `useCrudViewScreen()`,
37
37
  or `useCrudAddEditScreen()`.
38
+ - Each route page declares its app bar title and its parent with
39
+ `definePage({ meta: { jskit: { title, parent } } })`. The list is a main
40
+ menu destination with a title only; the view and new pages name the list as
41
+ their parent, and the edit page names the view. The shell's Up arrow follows
42
+ the parent, so screens and pages add no Back links.
38
43
  - Route pages do not add a page header or standalone heading by default.
44
+ - The shared screens put their actions in the top app bar: Refresh on the list,
45
+ Edit and the `actions` slot (such as `CrudDeleteAction`) on the view, and
46
+ Cancel and Save on a form. The list's create action is an extended FAB on
47
+ compact and medium windows and the app bar's primary button on wider ones.
48
+ - Save, Cancel and a completed delete replace the form's or the deleted record's
49
+ history entry, so neither Up nor Back reopens it.
50
+ - View fields are two-line list items with the value first:
51
+ `<v-list-item :title="record.author" subtitle="Author" />`.
39
52
  - Transport and validators come from the shared resource contract.
40
53
  - Initial visible loading uses structure-matching skeletons; pending buttons use
41
54
  stable disabled labels, never spinners.
@@ -7,6 +7,8 @@ import { bookResource } from "@local/books/shared";
7
7
  import BookFormFields from "./BookFormFields.vue";
8
8
  import { bookFormFields } from "./formFields.js";
9
9
 
10
+ definePage({ meta: { jskit: { title: "Edit book", parent: "/books/:bookId" } } });
11
+
10
12
  const route = useRoute();
11
13
  const routeRecordId = computed(() => String(route.params.bookId || "").trim());
12
14
 
@@ -20,8 +20,6 @@ defineProps({
20
20
  <v-text-field
21
21
  v-model="title"
22
22
  label="Title"
23
- variant="outlined"
24
- density="comfortable"
25
23
  maxlength="255"
26
24
  :readonly="readonly"
27
25
  :error-messages="resolveFieldErrors('title')"
@@ -31,8 +29,6 @@ defineProps({
31
29
  <v-text-field
32
30
  v-model="author"
33
31
  label="Author"
34
- variant="outlined"
35
- density="comfortable"
36
32
  maxlength="255"
37
33
  :readonly="readonly"
38
34
  :error-messages="resolveFieldErrors('author')"
@@ -42,8 +38,6 @@ defineProps({
42
38
  <v-textarea
43
39
  v-model="notes"
44
40
  label="Notes"
45
- variant="outlined"
46
- density="comfortable"
47
41
  auto-grow
48
42
  :readonly="readonly"
49
43
  :error-messages="resolveFieldErrors('notes')"
@@ -4,6 +4,9 @@ import { useCrudListScreen } from "@jskit-ai/http-web/client/composables/useCrud
4
4
  import { bookResource } from "@local/books/shared";
5
5
  import { listBulkActions, listFilters, listRowActions } from "./listExtensions.js";
6
6
 
7
+ // A main menu destination: the app bar shows its title and no Up arrow.
8
+ definePage({ meta: { jskit: { title: "Books" } } });
9
+
7
10
  const screen = useCrudListScreen({
8
11
  resource: bookResource,
9
12
  resourceNamespace: "books",
@@ -31,8 +34,8 @@ const screen = useCrudListScreen({
31
34
  <template #card-fields="{ record, formatListCardValue }">
32
35
  <dl class="d-grid ga-2 mb-0">
33
36
  <div>
34
- <dt class="text-caption text-medium-emphasis">Author</dt>
35
- <dd class="text-body-2 mb-0">{{ formatListCardValue(record.author) }}</dd>
37
+ <dt class="text-body-small on-surface-variant">Author</dt>
38
+ <dd class="text-body-medium ma-0">{{ formatListCardValue(record.author) }}</dd>
36
39
  </div>
37
40
  </dl>
38
41
  </template>
@@ -5,6 +5,8 @@ import { bookResource } from "@local/books/shared";
5
5
  import BookFormFields from "./BookFormFields.vue";
6
6
  import { bookFormFields } from "./formFields.js";
7
7
 
8
+ definePage({ meta: { jskit: { title: "New book", parent: "/books" } } });
9
+
8
10
  const screen = useCrudAddEditScreen({
9
11
  mode: "new",
10
12
  saveLabel: "Save book",
@@ -5,6 +5,9 @@ import { useCrudDeleteAction } from "@jskit-ai/http-web/client/composables/useCr
5
5
  import { useCrudViewScreen } from "@jskit-ai/http-web/client/composables/useCrudViewScreen";
6
6
  import { bookResource } from "@local/books/shared";
7
7
 
8
+ // Up returns to the page the book was opened from, or else to the list.
9
+ definePage({ meta: { jskit: { title: "Book", parent: "/books" } } });
10
+
8
11
  const screen = useCrudViewScreen({
9
12
  resource: bookResource,
10
13
  resourceNamespace: "books",
@@ -29,21 +32,14 @@ const deleteAction = useCrudDeleteAction({
29
32
  <CrudViewScreen
30
33
  :screen="screen"
31
34
  resource-singular-title="Book"
32
- resource-plural-title="Books"
33
35
  >
34
36
  <template #actions>
35
37
  <CrudDeleteAction :action="deleteAction" resource-singular-title="Book" />
36
38
  </template>
37
39
 
38
40
  <template #fields="{ view }">
39
- <v-col cols="12" md="6">
40
- <div class="text-caption text-medium-emphasis">Author</div>
41
- <div class="text-body-1">{{ view.record?.author }}</div>
42
- </v-col>
43
- <v-col cols="12">
44
- <div class="text-caption text-medium-emphasis">Notes</div>
45
- <div class="text-body-1 text-pre-wrap">{{ view.record?.notes || "No notes" }}</div>
46
- </v-col>
41
+ <v-list-item :title="view.record?.author" subtitle="Author" />
42
+ <v-list-item :title="view.record?.notes || 'No notes'" subtitle="Notes" />
47
43
  </template>
48
44
  </CrudViewScreen>
49
45
  </template>
@@ -1,7 +1,13 @@
1
1
  <script setup>
2
2
  import { computed, unref } from "vue";
3
+ import ShellPageAction from "@jskit-ai/shell-web/client/components/ShellPageAction";
4
+ import ShellPageActions from "@jskit-ai/shell-web/client/components/ShellPageActions";
5
+ import { useShellNavigation } from "@jskit-ai/shell-web/client/navigation/useShellNavigation";
3
6
  import { useJskitText } from "../i18n.js";
4
7
 
8
+ // A new or edit page as Material 3 lays it out: Cancel and Save in the top app bar, Save its one primary action, and
9
+ // the form's fields below on the page.
10
+
5
11
  const props = defineProps({
6
12
  screen: {
7
13
  type: /** @type {import("vue").PropType<import("../types.js").CrudAddEditScreen>} */ (Object),
@@ -46,11 +52,20 @@ function resolveFieldErrors(fieldKey) {
46
52
  function resolveCancelTo(target = cancelTo.value) {
47
53
  return props.screen.resolveCancelTo(target);
48
54
  }
55
+
56
+ // Cancel leaves the form the way it came, or to its cancel route when it was opened directly, replacing the form's
57
+ // history entry so neither Up nor Back reopens it.
58
+ const navigation = useShellNavigation();
59
+ const canCancel = computed(() => Boolean(cancelTo.value || navigation.upTarget.value));
60
+
61
+ function cancel() {
62
+ return navigation.upTarget.value ? navigation.finish() : navigation.finish(resolveCancelTo(cancelTo.value));
63
+ }
49
64
  </script>
50
65
 
51
66
  <template>
52
- <section class="crud-screen crud-screen--operator crud-add-edit-form d-flex flex-column ga-4">
53
- <div class="crud-add-edit-form__actions">
67
+ <section class="crud-screen crud-add-edit-form">
68
+ <ShellPageActions>
54
69
  <slot
55
70
  name="actions"
56
71
  :screen="screen"
@@ -62,95 +77,75 @@ function resolveCancelTo(target = cancelTo.value) {
62
77
  :cancel-to="resolveCancelTo()"
63
78
  :submit="addEdit.submit"
64
79
  >
65
- <v-btn v-if="cancelTo" color="primary" variant="outlined" :to="resolveCancelTo(cancelTo)">
66
- {{ t("jskit.http.actions.cancel") }}
67
- </v-btn>
68
- <v-btn
69
- color="primary"
70
- variant="flat"
80
+ <ShellPageAction
81
+ v-if="canCancel"
82
+ icon="$close"
83
+ :label="t('jskit.http.actions.cancel')"
84
+ @click="cancel"
85
+ />
86
+ <ShellPageAction
87
+ primary
88
+ :label="addEdit.isSaving ? t('jskit.http.actions.saving') : saveLabel"
71
89
  :disabled="addEdit.isSubmitDisabled"
72
90
  @click="addEdit.submit"
73
- >
74
- {{ addEdit.isSaving ? t("jskit.http.actions.saving") : saveLabel }}
75
- </v-btn>
91
+ />
76
92
  </slot>
77
- </div>
93
+ </ShellPageActions>
78
94
 
79
- <v-sheet rounded="lg" border class="crud-add-edit-form__panel">
80
- <div v-if="addEdit.loadError" class="crud-add-edit-form__state">
81
- <p class="text-body-2 text-medium-emphasis mb-4">
82
- {{ addEdit.loadError }}
83
- </p>
84
- <v-btn
85
- v-if="addEdit.canRetryLoad"
86
- color="primary"
87
- variant="tonal"
88
- :disabled="addEdit.isFetching"
89
- @click="addEdit.refresh"
90
- >
91
- {{ addEdit.isFetching ? t("jskit.http.actions.retrying") : t("jskit.http.actions.retry") }}
92
- </v-btn>
93
- </div>
94
- <template v-else-if="formRuntime.showFormSkeleton">
95
- <div class="pa-4">
96
- <v-skeleton-loader type="text@2, article" />
97
- </div>
98
- </template>
99
- <v-form v-else class="pa-4" @submit.prevent="addEdit.submit" novalidate>
100
- <v-row class="crud-add-edit-form__fields">
101
- <slot
102
- name="fields"
103
- :mode="mode"
104
- :form-runtime="formRuntime"
105
- :form-state="formState"
106
- :add-edit="addEdit"
107
- :resolve-field-errors="resolveFieldErrors"
108
- :resolve-lookup-items="resolveLookupItems"
109
- :resolve-lookup-loading="resolveLookupLoading"
110
- :resolve-lookup-search="resolveLookupSearch"
111
- :set-lookup-search="setLookupSearch"
112
- />
113
- </v-row>
114
- </v-form>
115
- </v-sheet>
95
+ <div v-if="addEdit.loadError" class="crud-add-edit-form__state">
96
+ <v-icon icon="$cloudOff" size="48" />
97
+ <p class="text-body-large">{{ addEdit.loadError }}</p>
98
+ <v-btn
99
+ v-if="addEdit.canRetryLoad"
100
+ color="secondary-container"
101
+ prepend-icon="$refresh"
102
+ :disabled="addEdit.isFetching"
103
+ @click="addEdit.refresh"
104
+ >
105
+ {{ addEdit.isFetching ? t("jskit.http.actions.retrying") : t("jskit.http.actions.retry") }}
106
+ </v-btn>
107
+ </div>
108
+ <v-skeleton-loader v-else-if="formRuntime.showFormSkeleton" type="text@2, article" />
109
+ <v-form v-else @submit.prevent="addEdit.submit" novalidate>
110
+ <v-row class="crud-add-edit-form__fields">
111
+ <slot
112
+ name="fields"
113
+ :mode="mode"
114
+ :form-runtime="formRuntime"
115
+ :form-state="formState"
116
+ :add-edit="addEdit"
117
+ :resolve-field-errors="resolveFieldErrors"
118
+ :resolve-lookup-items="resolveLookupItems"
119
+ :resolve-lookup-loading="resolveLookupLoading"
120
+ :resolve-lookup-search="resolveLookupSearch"
121
+ :set-lookup-search="setLookupSearch"
122
+ />
123
+ </v-row>
124
+ </v-form>
116
125
  </section>
117
126
  </template>
118
127
 
119
128
  <style scoped>
120
- .crud-add-edit-form__actions {
121
- display: flex;
122
- flex-wrap: wrap;
123
- gap: 0.5rem;
124
- justify-content: flex-end;
125
- }
126
-
127
- .crud-add-edit-form__panel {
128
- overflow: hidden;
129
+ .crud-add-edit-form {
130
+ margin-inline: auto;
131
+ max-width: 840px;
132
+ min-width: 0;
133
+ width: 100%;
129
134
  }
130
135
 
131
136
  .crud-add-edit-form__state {
137
+ align-items: center;
138
+ color: rgb(var(--v-theme-on-surface-variant));
139
+ display: flex;
140
+ flex-direction: column;
141
+ gap: 16px;
132
142
  margin-inline: auto;
133
- max-width: 30rem;
134
- padding: 2rem 1rem;
143
+ max-width: 480px;
144
+ padding: 48px 16px;
135
145
  text-align: center;
136
146
  }
137
147
 
138
148
  .crud-add-edit-form__fields :deep(.v-col) {
139
149
  min-width: 0;
140
150
  }
141
-
142
- @media (max-width: 960px) {
143
- .crud-add-edit-form__actions {
144
- width: 100%;
145
- }
146
-
147
- .crud-add-edit-form__actions :deep(.v-btn) {
148
- min-height: 48px;
149
- flex: 1 1 10rem;
150
- }
151
-
152
- .crud-add-edit-form__state :deep(.v-btn) {
153
- min-height: 48px;
154
- }
155
- }
156
151
  </style>