@revenexx/cover 0.2.16 → 0.2.18
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/app/components/account/address/AccountAddressView.vue +433 -0
- package/app/components/account/dashboard/AccountDashboard.vue +10 -330
- package/app/components/account/dashboard/AccountDashboardBudgets.vue +71 -0
- package/app/components/account/dashboard/AccountDashboardGreeting.vue +17 -0
- package/app/components/account/dashboard/AccountDashboardKpis.vue +71 -0
- package/app/components/account/dashboard/AccountDashboardQuickActions.vue +36 -0
- package/app/components/account/dashboard/AccountDashboardRecentOrders.vue +70 -0
- package/app/components/account/dashboard/AccountDashboardRequisitions.vue +60 -0
- package/app/components/account/profile/AccountPasswordForm.vue +155 -0
- package/app/components/account/profile/AccountProfileForm.vue +159 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationActions.vue +52 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationHero.vue +41 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationNextSteps.vue +60 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationOrderRecap.vue +102 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationView.vue +30 -265
- package/app/components/listing/ListingActiveFilters.vue +59 -0
- package/app/components/listing/ListingFilterBar.vue +24 -0
- package/app/components/listing/ListingFilterDrawer.vue +72 -0
- package/app/components/listing/ListingFilterRail.vue +23 -0
- package/app/components/listing/ListingResults.vue +88 -0
- package/app/components/listing/ListingToolbar.vue +46 -0
- package/app/components/listing/ListingView.vue +14 -204
- package/app/components/product/detail/ProductDetailIdentity.vue +44 -0
- package/app/components/product/detail/ProductDetailPrice.vue +39 -0
- package/app/components/search/filter/SearchFacets.vue +12 -102
- package/app/components/search/filter/SearchFacetsBar.vue +161 -0
- package/app/composables/useAccountDashboard.ts +112 -0
- package/app/composables/useCartStore.ts +23 -12
- package/app/composables/useCategoryListing.ts +92 -0
- package/app/composables/useCheckoutConfirmation.ts +63 -0
- package/app/composables/useFacetFilters.ts +122 -0
- package/app/composables/useSearchListing.ts +71 -0
- package/app/interfaces/checkout.ts +27 -0
- package/i18n/locales/de/editor.json +33 -0
- package/i18n/locales/en/editor.json +33 -0
- package/package.json +1 -1
|
@@ -1,227 +1,37 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import SearchFacets from "../search/filter/SearchFacets.vue";
|
|
3
2
|
import type { ProductListing } from "../../composables/useProductListing";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
|
-
* The shared product listing composition for search and category pages
|
|
7
|
-
*
|
|
8
|
-
* rail
|
|
9
|
-
*
|
|
5
|
+
* The shared product listing composition for search and category pages,
|
|
6
|
+
* assembled from the semantic listing sub-components (toolbar, desktop facet
|
|
7
|
+
* rail, active-filter chips, results and the mobile filter drawer). Pages
|
|
8
|
+
* provide their own header above and may override the empty state via #empty.
|
|
10
9
|
*/
|
|
11
10
|
const props = defineProps<{
|
|
12
11
|
listing: ProductListing;
|
|
13
12
|
}>();
|
|
14
13
|
|
|
15
|
-
const { icon } = useIcons();
|
|
16
|
-
const { t } = useI18n();
|
|
17
|
-
const { viewMode } = useViewMode();
|
|
18
|
-
|
|
19
|
-
const drawerOpen = ref(false);
|
|
20
|
-
|
|
21
|
-
const FACET_VALUE_LABELS: Record<string, Record<string, string>> = {
|
|
22
|
-
available: { true: "search.filters.values.inStock", false: "search.filters.values.outOfStock" },
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
function chipLabel(field: string, value: string): string {
|
|
26
|
-
const key = FACET_VALUE_LABELS[field]?.[value];
|
|
27
|
-
return key ? t(key) : value;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
14
|
const listing = props.listing;
|
|
31
|
-
|
|
32
|
-
const gridClasses = computed(() => viewMode.value === "grid"
|
|
33
|
-
? "grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-4"
|
|
34
|
-
: "flex flex-col gap-4");
|
|
35
|
-
|
|
36
|
-
const listView = resolveComponent("CategoryViewListView");
|
|
37
|
-
const gridView = resolveComponent("CategoryViewGridView");
|
|
38
|
-
const productComponent = computed(() => viewMode.value === "list" ? listView : gridView);
|
|
39
15
|
</script>
|
|
40
16
|
|
|
41
17
|
<template>
|
|
42
18
|
<div>
|
|
43
|
-
|
|
44
|
-
<div
|
|
45
|
-
class="flex flex-wrap items-center justify-between gap-3 border-b border-(--ui-border)
|
|
46
|
-
pb-4"
|
|
47
|
-
>
|
|
48
|
-
<p
|
|
49
|
-
class="text-sm text-muted tabular-nums"
|
|
50
|
-
aria-live="polite"
|
|
51
|
-
>
|
|
52
|
-
<template v-if="listing.pending.value && !listing.data.value">
|
|
53
|
-
|
|
54
|
-
</template>
|
|
55
|
-
<template v-else>
|
|
56
|
-
{{ t('search.results.count', listing.found.value, { count: listing.found.value }) }}
|
|
57
|
-
</template>
|
|
58
|
-
</p>
|
|
59
|
-
<div class="flex items-center gap-2">
|
|
60
|
-
<UButton
|
|
61
|
-
color="neutral"
|
|
62
|
-
variant="outline"
|
|
63
|
-
size="sm"
|
|
64
|
-
tabindex="0"
|
|
65
|
-
class="lg:hidden"
|
|
66
|
-
:icon="icon('filters')"
|
|
67
|
-
:label="t('search.filters.title')"
|
|
68
|
-
@click="drawerOpen = true"
|
|
69
|
-
>
|
|
70
|
-
<template
|
|
71
|
-
v-if="listing.activeFilterCount.value"
|
|
72
|
-
#trailing
|
|
73
|
-
>
|
|
74
|
-
<UBadge
|
|
75
|
-
color="primary"
|
|
76
|
-
variant="solid"
|
|
77
|
-
size="sm"
|
|
78
|
-
:label="String(listing.activeFilterCount.value)"
|
|
79
|
-
/>
|
|
80
|
-
</template>
|
|
81
|
-
</UButton>
|
|
82
|
-
<USelect
|
|
83
|
-
v-model="listing.sort.value"
|
|
84
|
-
:items="listing.sortOptions.value"
|
|
85
|
-
value-key="value"
|
|
86
|
-
size="sm"
|
|
87
|
-
class="w-44"
|
|
88
|
-
:aria-label="t('search.sort.label')"
|
|
89
|
-
/>
|
|
90
|
-
<CategoryViewToggle class="max-sm:hidden" />
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
19
|
+
<ListingToolbar :listing="listing" />
|
|
93
20
|
|
|
94
21
|
<div class="flex gap-8 items-start pt-6">
|
|
95
|
-
|
|
96
|
-
<div class="hidden lg:block w-60 shrink-0 sticky top-(--ui-header-height) pt-1">
|
|
97
|
-
<SearchFacets
|
|
98
|
-
v-model="listing.activeFilters.value"
|
|
99
|
-
v-model:price-range="listing.priceRange.value"
|
|
100
|
-
:facets="listing.facets.value"
|
|
101
|
-
/>
|
|
102
|
-
</div>
|
|
22
|
+
<ListingFilterRail :listing="listing" />
|
|
103
23
|
|
|
104
24
|
<div class="flex-1 min-w-0">
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
<button
|
|
111
|
-
v-for="chip in listing.chips.value"
|
|
112
|
-
:key="`${chip.field}:${chip.value}`"
|
|
113
|
-
type="button"
|
|
114
|
-
tabindex="0"
|
|
115
|
-
class="inline-flex items-center gap-1.5 ps-3 pe-2 py-1 rounded-full text-xs
|
|
116
|
-
font-medium bg-elevated text-highlighted border border-(--ui-border)
|
|
117
|
-
hover:border-(--ui-primary) transition-colors cursor-pointer"
|
|
118
|
-
:aria-label="t('search.filters.removeFilter', { value: chipLabel(chip.field, chip.value) })"
|
|
119
|
-
@click="listing.removeChip(chip.field, chip.value)"
|
|
120
|
-
>
|
|
121
|
-
{{ chipLabel(chip.field, chip.value) }}
|
|
122
|
-
<UIcon
|
|
123
|
-
:name="icon('close')"
|
|
124
|
-
class="size-3.5 text-muted"
|
|
125
|
-
/>
|
|
126
|
-
</button>
|
|
127
|
-
<button
|
|
128
|
-
type="button"
|
|
129
|
-
tabindex="0"
|
|
130
|
-
class="text-xs text-muted hover:text-highlighted underline underline-offset-4
|
|
131
|
-
decoration-2 transition-colors cursor-pointer"
|
|
132
|
-
@click="listing.clearFilters()"
|
|
133
|
-
>
|
|
134
|
-
{{ t('search.filters.clearAll') }}
|
|
135
|
-
</button>
|
|
136
|
-
</div>
|
|
137
|
-
|
|
138
|
-
<!-- Loading skeleton -->
|
|
139
|
-
<div
|
|
140
|
-
v-if="listing.pending.value && !listing.data.value"
|
|
141
|
-
:class="gridClasses"
|
|
142
|
-
>
|
|
143
|
-
<div
|
|
144
|
-
v-for="n in 8"
|
|
145
|
-
:key="n"
|
|
146
|
-
class="space-y-3"
|
|
147
|
-
>
|
|
148
|
-
<USkeleton class="h-44 w-full rounded-lg" />
|
|
149
|
-
<USkeleton class="h-4 w-3/4" />
|
|
150
|
-
<USkeleton class="h-4 w-1/2" />
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
|
|
154
|
-
<UiFeedbackErrorBoundary
|
|
155
|
-
v-else-if="listing.error.value"
|
|
156
|
-
:title="t('search.results.error')"
|
|
157
|
-
@retry="listing.execute"
|
|
158
|
-
/>
|
|
159
|
-
|
|
160
|
-
<!-- Results -->
|
|
161
|
-
<template v-else-if="listing.products.value.length">
|
|
162
|
-
<div
|
|
163
|
-
:class="[gridClasses, listing.pending.value ? 'opacity-60 transition-opacity' : '']"
|
|
164
|
-
>
|
|
165
|
-
<component
|
|
166
|
-
:is="productComponent"
|
|
167
|
-
v-for="product in listing.products.value"
|
|
168
|
-
:key="product.id"
|
|
169
|
-
:product="product"
|
|
170
|
-
/>
|
|
171
|
-
</div>
|
|
172
|
-
|
|
173
|
-
<div
|
|
174
|
-
v-if="listing.totalPages.value > 1"
|
|
175
|
-
class="mt-8 flex flex-col items-center gap-2"
|
|
25
|
+
<ListingActiveFilters :listing="listing" />
|
|
26
|
+
<ListingResults :listing="listing">
|
|
27
|
+
<template
|
|
28
|
+
v-if="$slots.empty"
|
|
29
|
+
#empty
|
|
176
30
|
>
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
:items-per-page="listing.perPage"
|
|
181
|
-
/>
|
|
182
|
-
</div>
|
|
183
|
-
</template>
|
|
184
|
-
|
|
185
|
-
<!-- Empty -->
|
|
186
|
-
<slot
|
|
187
|
-
v-else-if="listing.isEmpty.value"
|
|
188
|
-
name="empty"
|
|
189
|
-
>
|
|
190
|
-
<UiFeedbackEmptyState
|
|
191
|
-
icon="no-results"
|
|
192
|
-
:title="t('search.results.emptyTitle')"
|
|
193
|
-
:description="t('search.results.emptyDescription')"
|
|
194
|
-
/>
|
|
195
|
-
</slot>
|
|
31
|
+
<slot name="empty" />
|
|
32
|
+
</template>
|
|
33
|
+
</ListingResults>
|
|
196
34
|
</div>
|
|
197
35
|
</div>
|
|
198
|
-
|
|
199
|
-
<!-- Mobile filter drawer -->
|
|
200
|
-
<UDrawer
|
|
201
|
-
v-model:open="drawerOpen"
|
|
202
|
-
direction="left"
|
|
203
|
-
:ui="{ content: 'w-80 max-w-[85vw] h-full' }"
|
|
204
|
-
>
|
|
205
|
-
<template #content>
|
|
206
|
-
<div class="flex h-full flex-col">
|
|
207
|
-
<div class="flex-1 overflow-y-auto p-4">
|
|
208
|
-
<SearchFacets
|
|
209
|
-
v-model="listing.activeFilters.value"
|
|
210
|
-
v-model:price-range="listing.priceRange.value"
|
|
211
|
-
:facets="listing.facets.value"
|
|
212
|
-
/>
|
|
213
|
-
</div>
|
|
214
|
-
<div class="border-t border-(--ui-border) p-4">
|
|
215
|
-
<UButton
|
|
216
|
-
block
|
|
217
|
-
color="primary"
|
|
218
|
-
tabindex="0"
|
|
219
|
-
:label="t('search.filters.showResults', listing.found.value, { count: listing.found.value })"
|
|
220
|
-
@click="drawerOpen = false"
|
|
221
|
-
/>
|
|
222
|
-
</div>
|
|
223
|
-
</div>
|
|
224
|
-
</template>
|
|
225
|
-
</UDrawer>
|
|
226
36
|
</div>
|
|
227
37
|
</template>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Product identity block: manufacturer, name and a copy-to-clipboard SKU.
|
|
4
|
+
*/
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
manufacturer: string;
|
|
7
|
+
name: string;
|
|
8
|
+
sku: string;
|
|
9
|
+
}>();
|
|
10
|
+
|
|
11
|
+
const { icon } = useIcons();
|
|
12
|
+
const { t } = useI18n();
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
|
|
15
|
+
async function copySku(): Promise<void> {
|
|
16
|
+
await navigator.clipboard.writeText(props.sku);
|
|
17
|
+
toast.add({ title: t("product.detail.skuCopied"), duration: 1200, icon: icon("copy-check") });
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<div>
|
|
23
|
+
<p class="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
24
|
+
{{ manufacturer }}
|
|
25
|
+
</p>
|
|
26
|
+
<h1 class="mt-1 text-3xl font-semibold tracking-tight text-highlighted">
|
|
27
|
+
{{ name }}
|
|
28
|
+
</h1>
|
|
29
|
+
<button
|
|
30
|
+
type="button"
|
|
31
|
+
tabindex="0"
|
|
32
|
+
class="mt-2 inline-flex items-center gap-1.5 text-sm text-muted
|
|
33
|
+
hover:text-highlighted transition-colors cursor-pointer"
|
|
34
|
+
:title="t('product.detail.copySku')"
|
|
35
|
+
@click="copySku"
|
|
36
|
+
>
|
|
37
|
+
{{ t('product.detail.sku') }}: {{ sku }}
|
|
38
|
+
<UIcon
|
|
39
|
+
:name="icon('copy')"
|
|
40
|
+
class="size-3.5"
|
|
41
|
+
/>
|
|
42
|
+
</button>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Product price block: the base price with tax note, a loading skeleton while
|
|
4
|
+
* the offer domain hydrates, and a "price on request" fallback when the buyer
|
|
5
|
+
* context has no price.
|
|
6
|
+
*/
|
|
7
|
+
defineProps<{
|
|
8
|
+
offerPending: boolean;
|
|
9
|
+
hasPrice: boolean;
|
|
10
|
+
priceCents: number;
|
|
11
|
+
formatPrice: (cents: number) => string;
|
|
12
|
+
}>();
|
|
13
|
+
|
|
14
|
+
const { t } = useI18n();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<USkeleton
|
|
19
|
+
v-if="offerPending"
|
|
20
|
+
class="h-9 w-44"
|
|
21
|
+
/>
|
|
22
|
+
<div
|
|
23
|
+
v-else-if="hasPrice"
|
|
24
|
+
class="flex items-baseline gap-3"
|
|
25
|
+
>
|
|
26
|
+
<span class="text-3xl font-semibold text-highlighted tabular-nums">
|
|
27
|
+
{{ formatPrice(priceCents) }}
|
|
28
|
+
</span>
|
|
29
|
+
<span class="text-sm text-muted">
|
|
30
|
+
{{ t('product.detail.priceNote') }}
|
|
31
|
+
</span>
|
|
32
|
+
</div>
|
|
33
|
+
<div
|
|
34
|
+
v-else
|
|
35
|
+
class="text-2xl font-semibold text-muted"
|
|
36
|
+
>
|
|
37
|
+
{{ t('product.price.onRequest') }}
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useDebounceFn } from "@vueuse/core";
|
|
3
|
-
|
|
4
2
|
import type { PriceRange, SearchFacet } from "../../../interfaces/search-facets";
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Facet filter panel: collapsible groups with value counts and a price
|
|
8
|
-
* range. Used as the desktop rail and inside the mobile filter drawer.
|
|
6
|
+
* range. Used as the desktop rail and inside the mobile filter drawer. The
|
|
7
|
+
* shared facet logic (toggling, labels, debounced price) lives in
|
|
8
|
+
* useFacetFilters; this component owns the vertical accordion presentation.
|
|
9
9
|
*/
|
|
10
10
|
const props = defineProps<{
|
|
11
11
|
facets: SearchFacet[];
|
|
@@ -20,22 +20,16 @@ const emit = defineEmits<{
|
|
|
20
20
|
|
|
21
21
|
const { icon } = useIcons();
|
|
22
22
|
const { t } = useI18n();
|
|
23
|
-
const facetMeta = useFacetMeta();
|
|
24
|
-
|
|
25
|
-
const FACET_VALUE_KEY_MAP: Record<string, Record<string, string>> = {
|
|
26
|
-
available: {
|
|
27
|
-
true: "search.filters.values.inStock",
|
|
28
|
-
false: "search.filters.values.outOfStock",
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const visibleFacets = computed(() => props.facets.filter(f => f.counts.length > 0));
|
|
33
23
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const {
|
|
25
|
+
visibleFacets, hasActiveFilters,
|
|
26
|
+
activeCount, isChecked, toggle,
|
|
27
|
+
facetLabel, facetValueLabel,
|
|
28
|
+
localPriceMin, localPriceMax, onPriceChange, priceActive,
|
|
29
|
+
} = useFacetFilters(props, {
|
|
30
|
+
setFilters: value => emit("update:modelValue", value),
|
|
31
|
+
setPriceRange: value => emit("update:priceRange", value),
|
|
32
|
+
});
|
|
39
33
|
|
|
40
34
|
const openGroups = ref<Record<string, boolean>>({});
|
|
41
35
|
|
|
@@ -46,80 +40,6 @@ function isOpen(field: string): boolean {
|
|
|
46
40
|
function toggleGroup(field: string): void {
|
|
47
41
|
openGroups.value = { ...openGroups.value, [field]: !isOpen(field) };
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
function activeCount(field: string): number {
|
|
51
|
-
return props.modelValue[field]?.length ?? 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function isChecked(field: string, value: string): boolean {
|
|
55
|
-
return props.modelValue[field]?.includes(value) ?? false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function toggle(field: string, value: string) {
|
|
59
|
-
const current = props.modelValue[field] ?? [];
|
|
60
|
-
const next = current.includes(value)
|
|
61
|
-
? current.filter(v => v !== value)
|
|
62
|
-
: [...current, value];
|
|
63
|
-
emit("update:modelValue", { ...props.modelValue, [field]: next });
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function clearAll() {
|
|
67
|
-
emit("update:modelValue", {});
|
|
68
|
-
emit("update:priceRange", {});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function facetLabel(fieldName: string): string {
|
|
72
|
-
// Per-tenant dynamic facets come from the Products app's
|
|
73
|
-
// is_filterable attributes — labels live in the attribute meta,
|
|
74
|
-
// not the i18n bundle. Spine facets keep the i18n key path.
|
|
75
|
-
if (fieldName.startsWith("attrs.")) {
|
|
76
|
-
return facetMeta.label(fieldName.slice(6));
|
|
77
|
-
}
|
|
78
|
-
return t(`search.filters.facets.${fieldName}`, fieldName);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function facetValueLabel(fieldName: string, value: string): string {
|
|
82
|
-
// Dynamic facet values: select-attribute options carry their own
|
|
83
|
-
// labels map (de/en); the doc stores the raw option code. Look up
|
|
84
|
-
// the localized label via the meta cache.
|
|
85
|
-
if (fieldName.startsWith("attrs.")) {
|
|
86
|
-
return facetMeta.valueLabel(fieldName.slice(6), value);
|
|
87
|
-
}
|
|
88
|
-
const key = FACET_VALUE_KEY_MAP[fieldName]?.[value];
|
|
89
|
-
return key ? t(key) : value;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/* ---- price range (euros, debounced) ------------------------------- */
|
|
93
|
-
const localPriceMin = ref<number | undefined>(props.priceRange.min);
|
|
94
|
-
const localPriceMax = ref<number | undefined>(props.priceRange.max);
|
|
95
|
-
|
|
96
|
-
watch(
|
|
97
|
-
() => props.priceRange,
|
|
98
|
-
(val) => {
|
|
99
|
-
localPriceMin.value = val.min;
|
|
100
|
-
localPriceMax.value = val.max;
|
|
101
|
-
},
|
|
102
|
-
{ deep: true },
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const emitPrice = useDebounceFn(() => {
|
|
106
|
-
emit("update:priceRange", {
|
|
107
|
-
min: typeof localPriceMin.value === "number" && !isNaN(localPriceMin.value)
|
|
108
|
-
? localPriceMin.value
|
|
109
|
-
: undefined,
|
|
110
|
-
max: typeof localPriceMax.value === "number" && !isNaN(localPriceMax.value)
|
|
111
|
-
? localPriceMax.value
|
|
112
|
-
: undefined,
|
|
113
|
-
});
|
|
114
|
-
}, 400);
|
|
115
|
-
|
|
116
|
-
function onPriceChange() {
|
|
117
|
-
void emitPrice();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const priceActive = computed(() =>
|
|
121
|
-
props.priceRange.min !== undefined || props.priceRange.max !== undefined,
|
|
122
|
-
);
|
|
123
43
|
</script>
|
|
124
44
|
|
|
125
45
|
<template>
|
|
@@ -128,16 +48,6 @@ const priceActive = computed(() =>
|
|
|
128
48
|
<h2 class="text-sm font-semibold text-highlighted">
|
|
129
49
|
{{ t('search.filters.title') }}
|
|
130
50
|
</h2>
|
|
131
|
-
<button
|
|
132
|
-
v-if="hasActiveFilters"
|
|
133
|
-
type="button"
|
|
134
|
-
tabindex="0"
|
|
135
|
-
class="text-xs text-muted hover:text-highlighted underline underline-offset-4
|
|
136
|
-
decoration-2 transition-colors cursor-pointer"
|
|
137
|
-
@click="clearAll"
|
|
138
|
-
>
|
|
139
|
-
{{ t('search.filters.clearAll') }}
|
|
140
|
-
</button>
|
|
141
51
|
</div>
|
|
142
52
|
|
|
143
53
|
<div class="divide-y divide-(--ui-border) border-y border-(--ui-border)">
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PriceRange, SearchFacet } from "../../../interfaces/search-facets";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Horizontal facet filter bar: one popover dropdown per facet (value counts) and
|
|
6
|
+
* a price popover, laid out in a row so it can sit above the results. Shares its
|
|
7
|
+
* logic with the vertical SearchFacets via useFacetFilters; only the popover
|
|
8
|
+
* presentation differs.
|
|
9
|
+
*/
|
|
10
|
+
const props = defineProps<{
|
|
11
|
+
facets: SearchFacet[];
|
|
12
|
+
modelValue: Record<string, string[]>;
|
|
13
|
+
priceRange: PriceRange;
|
|
14
|
+
}>();
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits<{
|
|
17
|
+
"update:modelValue": [value: Record<string, string[]>];
|
|
18
|
+
"update:priceRange": [value: PriceRange];
|
|
19
|
+
}>();
|
|
20
|
+
|
|
21
|
+
const { icon } = useIcons();
|
|
22
|
+
const { t } = useI18n();
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
visibleFacets,
|
|
26
|
+
activeCount, isChecked, toggle,
|
|
27
|
+
facetLabel, facetValueLabel,
|
|
28
|
+
localPriceMin, localPriceMax, onPriceChange, priceActive,
|
|
29
|
+
} = useFacetFilters(props, {
|
|
30
|
+
setFilters: value => emit("update:modelValue", value),
|
|
31
|
+
setPriceRange: value => emit("update:priceRange", value),
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<div
|
|
37
|
+
class="flex flex-wrap items-center gap-2"
|
|
38
|
+
:aria-label="t('search.filters.title')"
|
|
39
|
+
>
|
|
40
|
+
<span class="text-sm font-semibold text-highlighted">
|
|
41
|
+
{{ t('search.filters.title') }}
|
|
42
|
+
</span>
|
|
43
|
+
|
|
44
|
+
<!-- Facet dropdowns -->
|
|
45
|
+
<UPopover
|
|
46
|
+
v-for="facet in visibleFacets"
|
|
47
|
+
:key="facet.fieldName"
|
|
48
|
+
>
|
|
49
|
+
<UButton
|
|
50
|
+
color="neutral"
|
|
51
|
+
variant="outline"
|
|
52
|
+
size="sm"
|
|
53
|
+
tabindex="0"
|
|
54
|
+
:trailing-icon="icon('chevron-down')"
|
|
55
|
+
>
|
|
56
|
+
{{ facetLabel(facet.fieldName) }}
|
|
57
|
+
<template
|
|
58
|
+
v-if="activeCount(facet.fieldName)"
|
|
59
|
+
#leading
|
|
60
|
+
>
|
|
61
|
+
<UBadge
|
|
62
|
+
color="primary"
|
|
63
|
+
variant="subtle"
|
|
64
|
+
size="sm"
|
|
65
|
+
:label="String(activeCount(facet.fieldName))"
|
|
66
|
+
/>
|
|
67
|
+
</template>
|
|
68
|
+
</UButton>
|
|
69
|
+
|
|
70
|
+
<template #content>
|
|
71
|
+
<ul class="max-h-80 overflow-y-auto p-3 space-y-2 min-w-56">
|
|
72
|
+
<li
|
|
73
|
+
v-for="item in facet.counts"
|
|
74
|
+
:key="item.value"
|
|
75
|
+
>
|
|
76
|
+
<label class="flex items-center gap-2.5 cursor-pointer group/row">
|
|
77
|
+
<UCheckbox
|
|
78
|
+
:model-value="isChecked(facet.fieldName, item.value)"
|
|
79
|
+
tabindex="0"
|
|
80
|
+
:aria-label="facetValueLabel(facet.fieldName, item.value)"
|
|
81
|
+
@update:model-value="toggle(facet.fieldName, item.value)"
|
|
82
|
+
/>
|
|
83
|
+
<span
|
|
84
|
+
class="text-sm flex-1 text-muted group-hover/row:text-highlighted
|
|
85
|
+
transition-colors"
|
|
86
|
+
>
|
|
87
|
+
{{ facetValueLabel(facet.fieldName, item.value) }}
|
|
88
|
+
</span>
|
|
89
|
+
<span class="text-xs text-dimmed tabular-nums">{{ item.count }}</span>
|
|
90
|
+
</label>
|
|
91
|
+
</li>
|
|
92
|
+
</ul>
|
|
93
|
+
</template>
|
|
94
|
+
</UPopover>
|
|
95
|
+
|
|
96
|
+
<!-- Price -->
|
|
97
|
+
<UPopover>
|
|
98
|
+
<UButton
|
|
99
|
+
color="neutral"
|
|
100
|
+
variant="outline"
|
|
101
|
+
size="sm"
|
|
102
|
+
tabindex="0"
|
|
103
|
+
:trailing-icon="icon('chevron-down')"
|
|
104
|
+
>
|
|
105
|
+
{{ t('search.filters.price.label') }}
|
|
106
|
+
<template
|
|
107
|
+
v-if="priceActive"
|
|
108
|
+
#leading
|
|
109
|
+
>
|
|
110
|
+
<UBadge
|
|
111
|
+
color="primary"
|
|
112
|
+
variant="subtle"
|
|
113
|
+
size="sm"
|
|
114
|
+
label="1"
|
|
115
|
+
/>
|
|
116
|
+
</template>
|
|
117
|
+
</UButton>
|
|
118
|
+
|
|
119
|
+
<template #content>
|
|
120
|
+
<div class="p-3 flex items-center gap-2 min-w-64">
|
|
121
|
+
<UInput
|
|
122
|
+
v-model.number="localPriceMin"
|
|
123
|
+
type="number"
|
|
124
|
+
:placeholder="t('search.filters.price.min')"
|
|
125
|
+
size="sm"
|
|
126
|
+
min="0"
|
|
127
|
+
class="w-full"
|
|
128
|
+
:aria-label="t('search.filters.price.min')"
|
|
129
|
+
@input="onPriceChange"
|
|
130
|
+
>
|
|
131
|
+
<template #trailing>
|
|
132
|
+
<span class="text-xs text-dimmed">€</span>
|
|
133
|
+
</template>
|
|
134
|
+
</UInput>
|
|
135
|
+
<span class="text-dimmed shrink-0">–</span>
|
|
136
|
+
<UInput
|
|
137
|
+
v-model.number="localPriceMax"
|
|
138
|
+
type="number"
|
|
139
|
+
:placeholder="t('search.filters.price.max')"
|
|
140
|
+
size="sm"
|
|
141
|
+
min="0"
|
|
142
|
+
class="w-full"
|
|
143
|
+
:aria-label="t('search.filters.price.max')"
|
|
144
|
+
@input="onPriceChange"
|
|
145
|
+
>
|
|
146
|
+
<template #trailing>
|
|
147
|
+
<span class="text-xs text-dimmed">€</span>
|
|
148
|
+
</template>
|
|
149
|
+
</UInput>
|
|
150
|
+
</div>
|
|
151
|
+
</template>
|
|
152
|
+
</UPopover>
|
|
153
|
+
|
|
154
|
+
<p
|
|
155
|
+
v-if="visibleFacets.length === 0"
|
|
156
|
+
class="text-xs text-muted"
|
|
157
|
+
>
|
|
158
|
+
{{ t('search.filters.noFilters') }}
|
|
159
|
+
</p>
|
|
160
|
+
</div>
|
|
161
|
+
</template>
|