@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.
- package/CHANGELOG.md +5 -0
- package/fixtures/crud-list-date-filters/App.vue +3 -3
- package/fixtures/crud-list-date-filters/main.js +3 -9
- package/fixtures/crud-screens/App.vue +14 -0
- package/fixtures/crud-screens/index.html +12 -0
- package/fixtures/crud-screens/main.js +114 -0
- package/fixtures/crud-screens/vite.config.mjs +24 -0
- package/fixtures/select-field/main.js +3 -9
- package/locales/en.json +1 -2
- package/package.json +10 -8
- package/patterns/crud-screen-set/PATTERN.md +13 -0
- package/patterns/crud-screen-set/example/books/BookEditPage.vue +2 -0
- package/patterns/crud-screen-set/example/books/BookFormFields.vue +0 -6
- package/patterns/crud-screen-set/example/books/BookListPage.vue +5 -2
- package/patterns/crud-screen-set/example/books/BookNewPage.vue +2 -0
- package/patterns/crud-screen-set/example/books/BookViewPage.vue +5 -9
- package/src/client/components/CrudAddEditScreen.vue +70 -75
- package/src/client/components/CrudDeleteAction.vue +26 -14
- package/src/client/components/CrudListBulkActionSurface.vue +25 -20
- package/src/client/components/CrudListCreateAction.vue +38 -0
- package/src/client/components/CrudListDateFilterControl.vue +0 -1
- package/src/client/components/CrudListFilterControls.vue +0 -11
- package/src/client/components/CrudListFilterSheet.vue +59 -0
- package/src/client/components/CrudListFilterSurface.vue +58 -84
- package/src/client/components/CrudListRecordActionMenu.vue +14 -18
- package/src/client/components/CrudListScreen.vue +305 -245
- package/src/client/components/CrudViewScreen.vue +84 -99
- package/src/client/composables/records/useCrudAddEdit.js +6 -4
- package/src/client/composables/records/useView.js +1 -0
- package/src/client/composables/runtime/useViewCore.js +4 -4
- package/src/client/composables/useCrudDeleteAction.js +4 -3
- package/src/client/types.js +0 -1
- package/test/crudAddEditActions.test.js +19 -2
- package/test/crudListBulkActionSurface.test.js +3 -2
- package/test/crudListDateFilterSurface.browser.test.js +23 -14
- package/test/crudListFilterSurface.test.js +11 -7
- package/test/crudScreenComponents.test.js +89 -16
- package/test/crudScreenPattern.test.js +3 -0
- package/test/crudScreensMaterialBaselines.browser.test.js +170 -0
- package/test/translation.test.js +6 -2
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, unref } from "vue";
|
|
2
|
+
import { computed, unref, watch } 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 record page as Material 3 lays it out: Edit and the page's own actions in the top app bar, a header naming the
|
|
9
|
+
// record, then its values as a two-line list, each value above its label. Up (the app bar's arrow) leaves the page.
|
|
5
10
|
// Unset titles come from the catalog; passed titles may be message keys.
|
|
6
11
|
const props = defineProps({
|
|
7
12
|
screen: {
|
|
@@ -11,10 +16,6 @@ const props = defineProps({
|
|
|
11
16
|
resourceSingularTitle: {
|
|
12
17
|
type: String,
|
|
13
18
|
default: undefined
|
|
14
|
-
},
|
|
15
|
-
resourcePluralTitle: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: undefined
|
|
18
19
|
}
|
|
19
20
|
});
|
|
20
21
|
|
|
@@ -22,79 +23,69 @@ const { t, text } = useJskitText();
|
|
|
22
23
|
const singularTitle = computed(() =>
|
|
23
24
|
props.resourceSingularTitle === undefined ? t("jskit.http.crud.record") : text(props.resourceSingularTitle)
|
|
24
25
|
);
|
|
25
|
-
const pluralTitle = computed(() =>
|
|
26
|
-
props.resourcePluralTitle === undefined ? t("jskit.http.crud.records") : text(props.resourcePluralTitle)
|
|
27
|
-
);
|
|
28
26
|
|
|
29
27
|
const view = computed(() => props.screen.view);
|
|
30
|
-
const listLocation = computed(() => unref(props.screen.listLocation) || null);
|
|
31
28
|
const editLocation = computed(() => unref(props.screen.editLocation) || null);
|
|
29
|
+
const recordTitle = computed(() => String(unref(props.screen.recordTitle) || ""));
|
|
30
|
+
const isNotFound = computed(() => Boolean(unref(view.value.isNotFound)));
|
|
31
|
+
// Gone (not found) or no longer the reader's to see (403).
|
|
32
|
+
const isUnavailable = computed(() => isNotFound.value || Number(unref(view.value.errorStatus)) === 403);
|
|
33
|
+
|
|
34
|
+
// A record that is unavailable when Up returns here sends the reader on to this page's parent instead.
|
|
35
|
+
const { pageUnavailable } = useShellNavigation();
|
|
36
|
+
watch(isUnavailable, (unavailable) => {
|
|
37
|
+
if (unavailable) {
|
|
38
|
+
pageUnavailable();
|
|
39
|
+
}
|
|
40
|
+
}, { immediate: true });
|
|
32
41
|
</script>
|
|
33
42
|
|
|
34
43
|
<template>
|
|
35
|
-
<section class="crud-screen crud-
|
|
36
|
-
<
|
|
37
|
-
<v-btn
|
|
38
|
-
v-if="listLocation"
|
|
39
|
-
color="primary"
|
|
40
|
-
variant="outlined"
|
|
41
|
-
:to="listLocation"
|
|
42
|
-
>
|
|
43
|
-
{{ t("jskit.http.crud.view.backTo", { resources: pluralTitle }) }}
|
|
44
|
-
</v-btn>
|
|
44
|
+
<section class="crud-screen crud-view">
|
|
45
|
+
<ShellPageActions>
|
|
45
46
|
<slot name="actions" :screen="screen" :view="view" />
|
|
46
|
-
<
|
|
47
|
-
v-if="editLocation"
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
<ShellPageAction
|
|
48
|
+
v-if="editLocation && !isNotFound"
|
|
49
|
+
icon="$edit"
|
|
50
|
+
:label="t('jskit.http.actions.edit')"
|
|
50
51
|
:to="editLocation"
|
|
52
|
+
/>
|
|
53
|
+
</ShellPageActions>
|
|
54
|
+
|
|
55
|
+
<div v-if="view.loadError" class="crud-view-state">
|
|
56
|
+
<v-icon icon="$cloudOff" size="48" />
|
|
57
|
+
<p class="text-body-large">{{ view.loadError }}</p>
|
|
58
|
+
<v-btn
|
|
59
|
+
color="secondary-container"
|
|
60
|
+
prepend-icon="$refresh"
|
|
61
|
+
:disabled="view.isFetching"
|
|
62
|
+
@click="view.refresh"
|
|
51
63
|
>
|
|
52
|
-
{{ t("jskit.http.actions.
|
|
64
|
+
{{ view.isFetching ? t("jskit.http.actions.retrying") : t("jskit.http.actions.retry") }}
|
|
53
65
|
</v-btn>
|
|
54
66
|
</div>
|
|
55
67
|
|
|
56
|
-
<v-
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
{{ t("jskit.http.crud.view.backTo", { resources: pluralTitle }) }}
|
|
78
|
-
</v-btn>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<template v-else-if="view.isLoading">
|
|
83
|
-
<div class="pa-4">
|
|
84
|
-
<v-skeleton-loader type="text@2, list-item-two-line@5" />
|
|
85
|
-
</div>
|
|
86
|
-
</template>
|
|
87
|
-
|
|
88
|
-
<template v-else>
|
|
89
|
-
<div class="pa-4">
|
|
90
|
-
<slot name="before-fields" :view="view" />
|
|
91
|
-
<v-row class="crud-view-fields">
|
|
92
|
-
<slot name="fields" :view="view" />
|
|
93
|
-
</v-row>
|
|
94
|
-
<slot name="after-fields" :view="view" />
|
|
95
|
-
</div>
|
|
96
|
-
</template>
|
|
97
|
-
</v-sheet>
|
|
68
|
+
<div v-else-if="isNotFound" class="crud-view-state">
|
|
69
|
+
<v-icon icon="$searchOff" size="48" />
|
|
70
|
+
<p class="text-body-large">{{ t("jskit.http.crud.view.notFound", { resource: singularTitle }) }}</p>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<v-card v-else-if="view.isLoading" class="crud-view-panel">
|
|
74
|
+
<v-skeleton-loader type="heading, list-item-two-line@4" />
|
|
75
|
+
</v-card>
|
|
76
|
+
|
|
77
|
+
<template v-else>
|
|
78
|
+
<header v-if="recordTitle" class="crud-view-header">
|
|
79
|
+
<h2 class="text-headline-small">{{ recordTitle }}</h2>
|
|
80
|
+
</header>
|
|
81
|
+
<slot name="before-fields" :view="view" />
|
|
82
|
+
<v-card class="crud-view-panel">
|
|
83
|
+
<v-list class="crud-view-fields" lines="two">
|
|
84
|
+
<slot name="fields" :view="view" />
|
|
85
|
+
</v-list>
|
|
86
|
+
</v-card>
|
|
87
|
+
<slot name="after-fields" :view="view" />
|
|
88
|
+
</template>
|
|
98
89
|
|
|
99
90
|
<div v-if="$slots['supporting-content']" class="crud-view-supporting-content">
|
|
100
91
|
<slot name="supporting-content" :view="view" />
|
|
@@ -103,51 +94,45 @@ const editLocation = computed(() => unref(props.screen.editLocation) || null);
|
|
|
103
94
|
</template>
|
|
104
95
|
|
|
105
96
|
<style scoped>
|
|
106
|
-
.crud-view
|
|
97
|
+
.crud-view {
|
|
107
98
|
display: flex;
|
|
108
|
-
flex-
|
|
109
|
-
gap:
|
|
110
|
-
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
gap: 16px;
|
|
101
|
+
margin-inline: auto;
|
|
102
|
+
max-width: 840px;
|
|
103
|
+
min-width: 0;
|
|
104
|
+
width: 100%;
|
|
111
105
|
}
|
|
112
106
|
|
|
113
|
-
.crud-view-
|
|
114
|
-
|
|
107
|
+
.crud-view-header h2 {
|
|
108
|
+
color: rgb(var(--v-theme-on-surface));
|
|
109
|
+
font-weight: 400;
|
|
110
|
+
margin: 0;
|
|
111
|
+
overflow-wrap: anywhere;
|
|
115
112
|
}
|
|
116
113
|
|
|
117
|
-
.crud-view-
|
|
118
|
-
|
|
119
|
-
max-width: 30rem;
|
|
120
|
-
padding: 2rem 1rem;
|
|
121
|
-
text-align: center;
|
|
114
|
+
.crud-view-panel {
|
|
115
|
+
min-width: 0;
|
|
122
116
|
}
|
|
123
117
|
|
|
124
|
-
.crud-view-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
gap: 0.5rem;
|
|
128
|
-
justify-content: center;
|
|
118
|
+
.crud-view-fields :deep(.v-list-item-title) {
|
|
119
|
+
overflow-wrap: anywhere;
|
|
120
|
+
white-space: normal;
|
|
129
121
|
}
|
|
130
122
|
|
|
131
|
-
.crud-view-
|
|
132
|
-
|
|
123
|
+
.crud-view-state {
|
|
124
|
+
align-items: center;
|
|
125
|
+
color: rgb(var(--v-theme-on-surface-variant));
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
gap: 16px;
|
|
129
|
+
margin-inline: auto;
|
|
130
|
+
max-width: 480px;
|
|
131
|
+
padding: 48px 16px;
|
|
132
|
+
text-align: center;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
.crud-view-supporting-content {
|
|
136
136
|
min-width: 0;
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
@media (max-width: 960px) {
|
|
140
|
-
.crud-view-actions {
|
|
141
|
-
width: 100%;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.crud-view-actions :deep(.v-btn) {
|
|
145
|
-
min-height: 48px;
|
|
146
|
-
flex: 1 1 10rem;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.crud-view-state__actions :deep(.v-btn) {
|
|
150
|
-
min-height: 48px;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
138
|
</style>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed, proxyRefs, reactive, watch } from "vue";
|
|
2
|
-
import { useRoute
|
|
2
|
+
import { useRoute } from "vue-router";
|
|
3
|
+
import { useShellNavigation } from "@jskit-ai/shell-web/client/navigation/useShellNavigation";
|
|
3
4
|
import { asPlainObject } from "../support/scopeHelpers.js";
|
|
4
5
|
import { resolveCrudJsonApiTransport } from "../crud/crudJsonApiTransportSupport.js";
|
|
5
6
|
import { resolveCrudHttpClient } from "../crud/crudHttpClientSupport.js";
|
|
@@ -117,7 +118,8 @@ function useCrudAddEdit({
|
|
|
117
118
|
mapPayloadToModel,
|
|
118
119
|
input
|
|
119
120
|
}) {
|
|
120
|
-
|
|
121
|
+
// Saving leaves the form by replacing its history entry, so neither Up nor Back reopens it.
|
|
122
|
+
const navigation = useShellNavigation();
|
|
121
123
|
const route = useRoute();
|
|
122
124
|
const normalizedFields = normalizeCrudFormFields(formFields);
|
|
123
125
|
const normalizedAddEditOptions = asPlainObject(addEditOptions);
|
|
@@ -209,7 +211,7 @@ function useCrudAddEdit({
|
|
|
209
211
|
const viewUrl = addEdit.resolveSavedViewUrl(payload) ||
|
|
210
212
|
addEdit.resolveViewUrl(addEdit.recordId);
|
|
211
213
|
if (viewUrl) {
|
|
212
|
-
await
|
|
214
|
+
await navigation.finish(viewUrl);
|
|
213
215
|
return;
|
|
214
216
|
}
|
|
215
217
|
}
|
|
@@ -220,7 +222,7 @@ function useCrudAddEdit({
|
|
|
220
222
|
|
|
221
223
|
const listUrl = addEdit.resolveParams(saveSuccessOptions.listUrlTemplate);
|
|
222
224
|
if (listUrl) {
|
|
223
|
-
await
|
|
225
|
+
await navigation.finish(listUrl);
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
|
|
@@ -38,10 +38,9 @@ function useViewCore({
|
|
|
38
38
|
const isFetching = computed(() => Boolean(resource.isFetching.value));
|
|
39
39
|
const error = computed(() => resource.query.error.value || null);
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
41
|
+
// The HTTP status of the failed load, or 0.
|
|
42
|
+
const errorStatus = computed(() => Number(error.value?.status || 0));
|
|
43
|
+
const isNotFound = computed(() => statusList.includes(errorStatus.value));
|
|
45
44
|
|
|
46
45
|
const notFoundError = computed(() => {
|
|
47
46
|
if (!isNotFound.value) {
|
|
@@ -75,6 +74,7 @@ function useViewCore({
|
|
|
75
74
|
record,
|
|
76
75
|
isLoading,
|
|
77
76
|
isFetching,
|
|
77
|
+
errorStatus,
|
|
78
78
|
isNotFound,
|
|
79
79
|
notFoundError,
|
|
80
80
|
loadError,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, nextTick, proxyRefs, ref, unref } from "vue";
|
|
2
|
-
import { useRouter } from "vue-router";
|
|
3
2
|
import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
3
|
+
import { useShellNavigation } from "@jskit-ai/shell-web/client/navigation/useShellNavigation";
|
|
4
4
|
import { resolveCrudJsonApiTransport } from "./crud/crudJsonApiTransportSupport.js";
|
|
5
5
|
import { resolveCrudHttpClient } from "./crud/crudHttpClientSupport.js";
|
|
6
6
|
import { toQueryErrorMessage } from "./support/errorMessageHelpers.js";
|
|
@@ -37,7 +37,6 @@ function useCrudDeleteAction({
|
|
|
37
37
|
apiUrlTemplate = "",
|
|
38
38
|
access = "auto",
|
|
39
39
|
client,
|
|
40
|
-
router = useRouter(),
|
|
41
40
|
fallbackDeleteError = t("jskit.http.crud.delete.failed")
|
|
42
41
|
}) {
|
|
43
42
|
const deleteOperation = requireCrudDeleteOperation(resource);
|
|
@@ -48,6 +47,7 @@ function useCrudDeleteAction({
|
|
|
48
47
|
throw new TypeError("useCrudDeleteAction requires resourceNamespace or resource.namespace.");
|
|
49
48
|
}
|
|
50
49
|
|
|
50
|
+
const navigation = useShellNavigation();
|
|
51
51
|
const isOpen = ref(false);
|
|
52
52
|
const error = ref("");
|
|
53
53
|
const deleteApiSuffix = computed(() => resolveDeleteApiSuffix(screen, apiUrlTemplate));
|
|
@@ -61,7 +61,8 @@ function useCrudDeleteAction({
|
|
|
61
61
|
isOpen.value = false;
|
|
62
62
|
// Leave the deleted record's view before invalidating: while its view query is
|
|
63
63
|
// still observed, invalidation would refetch it and report "Record not found.".
|
|
64
|
-
|
|
64
|
+
// The list replaces the record's history entry, so neither Up nor Back reopens it.
|
|
65
|
+
await navigation.finish(listLocation);
|
|
65
66
|
await nextTick();
|
|
66
67
|
await context.queryClient.invalidateQueries({
|
|
67
68
|
queryKey: ["crud", namespace]
|
package/src/client/types.js
CHANGED
|
@@ -496,7 +496,6 @@
|
|
|
496
496
|
* @property {import("vue").MaybeRef<string>} [apiUrlTemplate]
|
|
497
497
|
* @property {string} [access]
|
|
498
498
|
* @property {HttpClient} [client]
|
|
499
|
-
* @property {Pick<import("vue-router").Router, "push">} [router]
|
|
500
499
|
* @property {string} [fallbackDeleteError]
|
|
501
500
|
*/
|
|
502
501
|
|
|
@@ -11,8 +11,17 @@ import { SHELL_WEB_PLACEMENT_RUNTIME_KEY } from "@jskit-ai/shell-web/client/plac
|
|
|
11
11
|
import { useCrudAddEditScreen } from "../src/client/composables/useCrudAddEditScreen.js";
|
|
12
12
|
|
|
13
13
|
const componentUrl = new URL("../src/client/components/CrudAddEditScreen.vue", import.meta.url).href;
|
|
14
|
+
// The shell's app bar actions render in place as buttons; to, disabled and the click handler fall through to them.
|
|
15
|
+
const SHELL_PAGE_ACTION_STUBS = {
|
|
16
|
+
"/ShellPageActions.vue":
|
|
17
|
+
'import { defineComponent, h } from "vue"; export default defineComponent({ setup: (_props, { slots }) => () => h("div", {}, slots.default?.()) });',
|
|
18
|
+
"/ShellPageAction.vue":
|
|
19
|
+
'import { defineComponent, h } from "vue"; export default defineComponent({ props: { label: [String, Object], icon: String, primary: Boolean }, setup: (props) => () => h("button", {}, String(props.label)) });'
|
|
20
|
+
};
|
|
14
21
|
const hooks = registerHooks({
|
|
15
22
|
load(url, context, nextLoad) {
|
|
23
|
+
const stub = Object.entries(SHELL_PAGE_ACTION_STUBS).find(([suffix]) => url.endsWith(suffix));
|
|
24
|
+
if (stub) return { format: "module", shortCircuit: true, source: stub[1] };
|
|
16
25
|
if (url !== componentUrl) return nextLoad(url, context);
|
|
17
26
|
const { descriptor } = parse(readFileSync(new URL(url), "utf8"));
|
|
18
27
|
return {
|
|
@@ -142,9 +151,17 @@ async function fixture(t, { actions, onSaveSuccess, request, screenResource = nu
|
|
|
142
151
|
}
|
|
143
152
|
|
|
144
153
|
test("default form actions retain Cancel, Save, validation feedback, and keyboard submission", async (t) => {
|
|
145
|
-
const { screen, reports, calls, all, button } = await fixture(t);
|
|
154
|
+
const { screen, reports, calls, all, button, router } = await fixture(t);
|
|
146
155
|
const { addEdit, formState } = screen;
|
|
147
|
-
|
|
156
|
+
// Cancel leaves for its cancel route by replacing the form's history entry.
|
|
157
|
+
const replaced = [];
|
|
158
|
+
const replace = router.replace.bind(router);
|
|
159
|
+
router.replace = (to) => {
|
|
160
|
+
replaced.push(to);
|
|
161
|
+
return replace(to);
|
|
162
|
+
};
|
|
163
|
+
await button("Cancel").props.onClick();
|
|
164
|
+
assert.deepEqual(replaced, [{ path: "/books/new", query: { source: "list" } }]);
|
|
148
165
|
assert.equal(button("Save book").props.disabled, false);
|
|
149
166
|
assert.equal(addEdit.validationAttempted, false);
|
|
150
167
|
assert.deepEqual(addEdit.validationErrors, {});
|
|
@@ -14,14 +14,15 @@ test("CrudListBulkActionSurface stays adaptive and runtime-owned", async () => {
|
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
assert.match(source, /defineProps/);
|
|
17
|
-
assert.match(source, /
|
|
17
|
+
assert.match(source, /useShellWindowSizeClass/);
|
|
18
18
|
assert.match(source, /v-if="shouldRender"/);
|
|
19
19
|
assert.match(source, /selectedCount/);
|
|
20
20
|
assert.match(source, /hasActions/);
|
|
21
21
|
assert.match(source, /hasSelection/);
|
|
22
22
|
assert.match(source, /v-menu/);
|
|
23
23
|
assert.match(source, /jskit\.http\.crud\.bulk\.actions/);
|
|
24
|
-
assert.match(source, /
|
|
24
|
+
assert.match(source, /background: rgb\(var\(--v-theme-secondary-container\)\);/);
|
|
25
|
+
assert.doesNotMatch(source, /\bborder(?:-block|-inline)?\s*:|min-height:\s*48px/u);
|
|
25
26
|
assert.doesNotMatch(source, /useCrudList\(/);
|
|
26
27
|
assert.doesNotMatch(source, /apiSuffix|repository|server/);
|
|
27
28
|
});
|
|
@@ -21,12 +21,12 @@ async function readContract(page) {
|
|
|
21
21
|
return JSON.parse(await page.getByTestId("date-filter-contract").textContent());
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
// Every filter control lives behind the Filters chip: a bottom sheet on compact windows, a dialog on wider ones.
|
|
25
|
+
async function openFilters(page) {
|
|
26
|
+
await page.getByRole("button", { name: /^Filters/u }).click();
|
|
27
|
+
const sheet = page.getByRole("dialog");
|
|
28
|
+
await sheet.waitFor({ state: "visible" });
|
|
29
|
+
return sheet;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
async function assertResponsiveDateControls(page, width) {
|
|
@@ -34,7 +34,7 @@ async function assertResponsiveDateControls(page, width) {
|
|
|
34
34
|
await page.goto(`/${QUERY}`, {
|
|
35
35
|
waitUntil: "networkidle"
|
|
36
36
|
});
|
|
37
|
-
await
|
|
37
|
+
await openFilters(page);
|
|
38
38
|
|
|
39
39
|
for (const name of ["Submitted date", "Arrival from", "Arrival to"]) {
|
|
40
40
|
const field = page.getByLabel(name, { exact: true });
|
|
@@ -110,6 +110,7 @@ test("CRUD date filters render and operate without clipping across responsive la
|
|
|
110
110
|
});
|
|
111
111
|
await page.getByText("Submitted date: Apr 18, 2026", { exact: true }).waitFor();
|
|
112
112
|
await page.getByText("Arrival: May 4, 2026 to May 10, 2026", { exact: true }).waitFor();
|
|
113
|
+
const filterSheet = await openFilters(page);
|
|
113
114
|
|
|
114
115
|
const submittedField = page.getByLabel("Submitted date", { exact: true });
|
|
115
116
|
await submittedField.focus();
|
|
@@ -154,7 +155,7 @@ test("CRUD date filters render and operate without clipping across responsive la
|
|
|
154
155
|
await page.keyboard.press("Escape");
|
|
155
156
|
assert.equal(await arrivalFromField.evaluate((element) => element === document.activeElement), true);
|
|
156
157
|
|
|
157
|
-
const clearAll =
|
|
158
|
+
const clearAll = filterSheet.getByRole("button", { name: "Clear all", exact: true });
|
|
158
159
|
await clearAll.focus();
|
|
159
160
|
await clearAll.press("Space");
|
|
160
161
|
assert.deepEqual((await readContract(page)).values, {
|
|
@@ -164,14 +165,22 @@ test("CRUD date filters render and operate without clipping across responsive la
|
|
|
164
165
|
|
|
165
166
|
await page.setViewportSize({ width: 375, height: 812 });
|
|
166
167
|
await page.reload({ waitUntil: "networkidle" });
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
assert.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
const filtersChip = page.getByRole("button", { name: /^Filters/u });
|
|
169
|
+
const filtersChipBox = await filtersChip.boundingBox();
|
|
170
|
+
assert.equal(filtersChipBox?.height, 32, "The Filters chip is Material 3's 32dp chip.");
|
|
171
|
+
assert.equal(
|
|
172
|
+
await filtersChip.evaluate((chip) => getComputedStyle(chip, "::after").height),
|
|
173
|
+
"48px",
|
|
174
|
+
"The Filters chip has a 48dp touch target."
|
|
175
|
+
);
|
|
176
|
+
const mobileSheet = await openFilters(page);
|
|
173
177
|
const mobileSheetBox = await mobileSheet.boundingBox();
|
|
174
178
|
assert.ok(mobileSheetBox && mobileSheetBox.width <= 375);
|
|
179
|
+
assert.equal(
|
|
180
|
+
await page.locator(".v-bottom-sheet").count(),
|
|
181
|
+
1,
|
|
182
|
+
"Compact windows show the filters in a bottom sheet."
|
|
183
|
+
);
|
|
175
184
|
await page.getByLabel("Arrival from", { exact: true }).waitFor({ state: "visible" });
|
|
176
185
|
} finally {
|
|
177
186
|
if (browser) {
|
|
@@ -25,28 +25,32 @@ test("http-web exposes client-side CRUD list filter definition helpers", async (
|
|
|
25
25
|
assert.equal(filters.status.options[0].label, "Active");
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
test("CrudListFilterSurface
|
|
28
|
+
test("CrudListFilterSurface is one Material 3 chip row over a filter sheet, without owning server semantics", async () => {
|
|
29
29
|
const componentsDir = path.join(PACKAGE_DIR, "src", "client", "components");
|
|
30
30
|
const surfaceSource = await readFile(path.join(componentsDir, "CrudListFilterSurface.vue"), "utf8");
|
|
31
|
+
const sheetSource = await readFile(path.join(componentsDir, "CrudListFilterSheet.vue"), "utf8");
|
|
31
32
|
const controlsSource = await readFile(path.join(componentsDir, "CrudListFilterControls.vue"), "utf8");
|
|
32
|
-
const source = `${surfaceSource}\n${controlsSource}`;
|
|
33
|
+
const source = `${surfaceSource}\n${sheetSource}\n${controlsSource}`;
|
|
33
34
|
|
|
34
|
-
assert.match(
|
|
35
|
-
assert.match(surfaceSource, /<
|
|
35
|
+
assert.match(sheetSource, /<CrudListFilterControls[^>]*:runtime="props\.runtime"[^>]*\bstacked\b[^>]*\/>/);
|
|
36
|
+
assert.match(surfaceSource, /<v-bottom-sheet v-if="isCompact" v-model="sheetOpen">\s*<CrudListFilterSheet/);
|
|
37
|
+
assert.match(surfaceSource, /<v-dialog v-else v-model="sheetOpen" max-width="560">\s*<CrudListFilterSheet/);
|
|
38
|
+
assert.match(surfaceSource, /useShellWindowSizeClass/);
|
|
39
|
+
assert.match(surfaceSource, /prepend-icon="\$tune"/);
|
|
40
|
+
assert.match(surfaceSource, /v-for="filter in flagFilters"[\s\S]*:aria-pressed=/);
|
|
41
|
+
assert.match(surfaceSource, /v-for="chip in valueChips"[\s\S]*closable/);
|
|
36
42
|
|
|
37
43
|
assert.match(source, /defineProps/);
|
|
38
|
-
assert.match(source, /useDisplay/);
|
|
39
44
|
assert.match(source, /v-if="shouldRender"/);
|
|
40
45
|
assert.match(source, /filterEntries/);
|
|
41
46
|
assert.match(source, /runtimeValues\[filter\.key\]/);
|
|
42
47
|
assert.match(source, /activeChips/);
|
|
43
48
|
assert.match(source, /clearChip/);
|
|
44
49
|
assert.match(source, /clearFilters/);
|
|
45
|
-
assert.match(source, /v-dialog/);
|
|
46
|
-
assert.match(source, /min-height:\s*48px/);
|
|
47
50
|
assert.match(source, /CrudListDateFilterControl/);
|
|
48
51
|
assert.match(source, /crud-list-filter-surface__range--date/);
|
|
49
52
|
assert.match(source, /grid-column:\s*span 2/);
|
|
53
|
+
assert.doesNotMatch(`${surfaceSource}\n${sheetSource}`, /@media|<v-sheet|\sborder(?=[\s>])|\bborder\s*:|min-height:\s*48px/u);
|
|
50
54
|
assert.doesNotMatch(source, /type="date"/);
|
|
51
55
|
assert.doesNotMatch(source, /useCrudList\(/);
|
|
52
56
|
assert.doesNotMatch(source, /apiSuffix|server|repository/);
|