@revenexx/cover 0.2.26 → 0.2.27
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/api/brands.ts +5 -0
- package/app/api/categories.ts +1 -0
- package/app/api/product.ts +2 -0
- package/app/app.config.ts +8 -0
- package/app/components/cart/quickadd/CartQuickAdd.vue +110 -34
- package/app/components/category/view/GridView.vue +34 -13
- package/app/components/category/view/ListView.vue +5 -5
- package/app/components/layout/AppLogo.vue +2 -1
- package/app/components/layout/footer/Footer.vue +9 -3
- package/app/components/layout/header/CategoryPanel.vue +92 -0
- package/app/components/layout/header/MainNav.vue +89 -2
- package/app/components/listing/ListingResults.vue +16 -2
- package/app/components/listing/ListingSubcategories.vue +124 -0
- package/app/components/product/card/Compact.vue +144 -0
- package/app/components/product/detail/ProductDetailAssociations.vue +96 -0
- package/app/components/product/detail/ProductDetailIdentity.vue +50 -5
- package/app/components/product/detail/ProductDetailVariantRow.vue +139 -0
- package/app/components/product/detail/ProductDetailVariants.vue +613 -0
- package/app/components/product/media/ProductMediaImage.vue +70 -0
- package/app/components/ui/forms/SearchInput.vue +14 -2
- package/app/components/ui/media/ImageSlider.vue +158 -0
- package/app/composables/useBranding.ts +22 -0
- package/app/composables/useBrands.ts +42 -0
- package/app/composables/useCategories.ts +55 -1
- package/app/composables/useProduct.ts +5 -4
- package/app/composables/useProductAssociations.ts +35 -0
- package/app/composables/useProductImage.ts +35 -2
- package/app/composables/useProductVariants.ts +46 -0
- package/app/composables/useSearchListing.ts +16 -5
- package/app/composables/useSubcategoryTiles.ts +36 -0
- package/app/config/navigation.ts +9 -0
- package/app/config/palette.ts +1 -0
- package/app/config/quickActions.ts +137 -0
- package/app/config/themes.ts +1 -0
- package/app/interfaces/brand.ts +16 -0
- package/app/interfaces/category.ts +45 -0
- package/app/interfaces/image-slider.ts +18 -0
- package/app/interfaces/product-associations.ts +32 -0
- package/app/interfaces/product-detail.ts +6 -0
- package/app/interfaces/product-variants.ts +73 -0
- package/i18n/locales/de/account.json +17 -0
- package/i18n/locales/de/cart.json +5 -1
- package/i18n/locales/de/common.json +42 -2
- package/i18n/locales/de/editor.json +91 -0
- package/i18n/locales/de/product.json +48 -2
- package/i18n/locales/de/search.json +4 -2
- package/i18n/locales/en/account.json +17 -0
- package/i18n/locales/en/cart.json +4 -0
- package/i18n/locales/en/common.json +42 -2
- package/i18n/locales/en/editor.json +91 -0
- package/i18n/locales/en/product.json +47 -1
- package/i18n/locales/en/search.json +3 -1
- package/nuxt.config.ts +10 -0
- package/package.json +3 -1
- package/public/img/brands/revenexx.svg +39 -0
- package/server/api/brands.get.ts +27 -0
- package/server/api/categories/[slug]/subcategories.get.ts +280 -0
- package/server/api/product/[id]/associations.get.ts +27 -0
- package/server/api/product/[id]/variants.get.ts +27 -0
- package/server/api/quick-actions.get.ts +43 -0
- package/server/api/typesense/search.post.ts +116 -13
- package/server/data/categories.json +5 -0
- package/server/data/product-associations.json +44 -0
- package/server/data/product-detail.json +346 -0
- package/server/data/product-list.json +340 -0
- package/server/data/product-variant-models.json +75 -0
- package/server/interfaces/brand.ts +17 -0
- package/server/interfaces/product.ts +14 -0
- package/server/services/ApiBrandService.ts +110 -0
- package/server/services/ApiProductService.ts +43 -9
- package/server/services/LocalFileProductService.ts +200 -6
- package/server/services/MockBrandService.ts +52 -0
- package/server/utils/brandService.ts +24 -0
- package/server/utils/contentTenant.ts +67 -0
- package/server/utils/liveCatalog.ts +744 -46
- package/server/utils/productService.ts +6 -1
- package/server/utils/productsSchema.ts +5 -2
- package/server/utils/revenexxCredentials.ts +258 -0
- package/server/utils/revenexxSdk.ts +38 -47
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The "Variants" section of the product detail page: every sibling article of
|
|
4
|
+
* this product's model, as a table with one column per distinguishing axis.
|
|
5
|
+
*
|
|
6
|
+
* Props-only like its neighbours (ProductDetailSpecifications) — the host
|
|
7
|
+
* fetches via `useProductVariants` and supplies `linkFor`, while the table's
|
|
8
|
+
* own state (article-number search, per-axis filters, availability toggle,
|
|
9
|
+
* sorting) lives here, where that UI is.
|
|
10
|
+
*
|
|
11
|
+
* The table is hand-rolled rather than a UTable: it is dense, its header row is
|
|
12
|
+
* borderless with inline sort buttons, and the axis columns are data-driven.
|
|
13
|
+
* The scaling features a data table owes the reader — search, filter, sort —
|
|
14
|
+
* are all present. The axis dropdown is the same pattern as the listing's
|
|
15
|
+
* SearchFacetsBar, with a per-axis clear added.
|
|
16
|
+
*
|
|
17
|
+
* A chip's absolutely positioned empty span pads its remove button out to a
|
|
18
|
+
* 3rem hit area on coarse pointers only.
|
|
19
|
+
*/
|
|
20
|
+
import type {
|
|
21
|
+
ProductVariant,
|
|
22
|
+
ProductVariantAxis,
|
|
23
|
+
ProductVariantFilterChip,
|
|
24
|
+
ProductVariantModel,
|
|
25
|
+
ProductVariantRow,
|
|
26
|
+
ProductVariantSort,
|
|
27
|
+
} from "../../../interfaces/product-variants";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Below this many articles the filter bar is more chrome than help — the whole
|
|
31
|
+
* table already fits on screen.
|
|
32
|
+
*/
|
|
33
|
+
const FILTER_BAR_MIN_VARIANTS = 4;
|
|
34
|
+
|
|
35
|
+
const props = withDefaults(defineProps<{
|
|
36
|
+
variants: readonly ProductVariant[];
|
|
37
|
+
axes: readonly ProductVariantAxis[];
|
|
38
|
+
model: ProductVariantModel | null;
|
|
39
|
+
/** Catalog tax rate of the page's article — its siblings share the model's. */
|
|
40
|
+
taxRate: number;
|
|
41
|
+
/** Localised route to a variant's own detail page. */
|
|
42
|
+
linkFor: (variant: ProductVariant) => string;
|
|
43
|
+
categorySlug?: string;
|
|
44
|
+
subcategorySlug?: string;
|
|
45
|
+
showFilters?: boolean;
|
|
46
|
+
showOrderButton?: boolean;
|
|
47
|
+
/** Rows before a "show all" expander takes over; 0 = no cap. */
|
|
48
|
+
rowLimit?: number;
|
|
49
|
+
}>(), {
|
|
50
|
+
categorySlug: "",
|
|
51
|
+
showFilters: true,
|
|
52
|
+
showOrderButton: true,
|
|
53
|
+
rowLimit: 0,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const { t } = useI18n();
|
|
57
|
+
const { icon } = useIcons();
|
|
58
|
+
|
|
59
|
+
const skuQuery = ref("");
|
|
60
|
+
/** Axis code → the values the buyer ticked. Empty = axis unfiltered. */
|
|
61
|
+
const axisFilters = ref<Record<string, string[]>>({});
|
|
62
|
+
const availableOnly = ref(false);
|
|
63
|
+
const sort = ref<ProductVariantSort>({ kind: "sku" });
|
|
64
|
+
const isAscending = ref(true);
|
|
65
|
+
/** Set by the "show all" expander when a row cap is in effect. */
|
|
66
|
+
const isExpanded = ref(false);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The words every article name starts with — the model's own name, repeated on
|
|
70
|
+
* each row. Cut at the last shared word boundary so a partial word is never
|
|
71
|
+
* chopped ("Plus 55 Zentralscheibe" and "Plus 55 Zentraldose" keep
|
|
72
|
+
* "Zentral…" intact and only lose "Plus 55 ").
|
|
73
|
+
*/
|
|
74
|
+
const commonNamePrefix = computed(() => {
|
|
75
|
+
const names = props.variants.map(variant => variant.name);
|
|
76
|
+
const first = names[0];
|
|
77
|
+
if (names.length < 2 || !first) {
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let cut = 0;
|
|
82
|
+
for (let index = 0; index < first.length; index++) {
|
|
83
|
+
if (names.some(name => name[index] !== first[index])) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
if (first[index] === " ") {
|
|
87
|
+
cut = index + 1;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return first.slice(0, cut);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const rows = computed<ProductVariantRow[]>(() => props.variants.map(variant => ({
|
|
94
|
+
...variant,
|
|
95
|
+
shortName: variant.name.slice(commonNamePrefix.value.length).trim(),
|
|
96
|
+
})));
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Compare two axis or SKU values the way a buyer reads them: numerically when
|
|
100
|
+
* both carry a number ("2,0m" before "10,0m", "07622000" before "07625000"),
|
|
101
|
+
* alphabetically otherwise.
|
|
102
|
+
*/
|
|
103
|
+
function compareValues(a: string, b: string): number {
|
|
104
|
+
const numericA = Number.parseFloat(String(a).replace(",", ".").replace(/[^\d.,-]/g, ""));
|
|
105
|
+
const numericB = Number.parseFloat(String(b).replace(",", ".").replace(/[^\d.,-]/g, ""));
|
|
106
|
+
if (!Number.isNaN(numericA) && !Number.isNaN(numericB) && numericA !== numericB) {
|
|
107
|
+
return numericA - numericB;
|
|
108
|
+
}
|
|
109
|
+
return String(a).localeCompare(String(b), undefined, { numeric: true });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The values one axis takes, with how many articles carry each. Counted over
|
|
114
|
+
* ALL variants, not the filtered set, so the numbers don't shift as the buyer
|
|
115
|
+
* narrows down.
|
|
116
|
+
*/
|
|
117
|
+
function axisOptions(code: string): { value: string; count: number }[] {
|
|
118
|
+
const counts = new Map<string, number>();
|
|
119
|
+
for (const variant of props.variants) {
|
|
120
|
+
const value = variant.values[code];
|
|
121
|
+
if (value) {
|
|
122
|
+
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return [...counts.entries()]
|
|
126
|
+
.map(([value, count]) => ({ value, count }))
|
|
127
|
+
.sort((a, b) => compareValues(a.value, b.value));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function selectedFor(code: string): string[] {
|
|
131
|
+
return axisFilters.value[code] ?? [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function isSelected(code: string, value: string): boolean {
|
|
135
|
+
return selectedFor(code).includes(value);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function toggleAxisValue(code: string, value: string): void {
|
|
139
|
+
const current = selectedFor(code);
|
|
140
|
+
axisFilters.value = {
|
|
141
|
+
...axisFilters.value,
|
|
142
|
+
[code]: current.includes(value)
|
|
143
|
+
? current.filter(entry => entry !== value)
|
|
144
|
+
: [...current, value],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function clearAxis(code: string): void {
|
|
149
|
+
axisFilters.value = { ...axisFilters.value, [code]: [] };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function resetFilters(): void {
|
|
153
|
+
axisFilters.value = {};
|
|
154
|
+
availableOnly.value = false;
|
|
155
|
+
skuQuery.value = "";
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const filteredRows = computed<ProductVariantRow[]>(() => {
|
|
159
|
+
const needle = skuQuery.value.trim().toLowerCase();
|
|
160
|
+
|
|
161
|
+
return rows.value.filter((row) => {
|
|
162
|
+
if (availableOnly.value && !row.available) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
// The field is labelled by article number but matches the name too — a
|
|
166
|
+
// buyer who remembers the wording and not the number still finds it.
|
|
167
|
+
if (needle
|
|
168
|
+
&& !row.sku.toLowerCase().includes(needle)
|
|
169
|
+
&& !row.name.toLowerCase().includes(needle)) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
for (const [code, values] of Object.entries(axisFilters.value)) {
|
|
173
|
+
if (values.length > 0 && !values.includes(row.values[code] ?? "")) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const chips = computed<ProductVariantFilterChip[]>(() => {
|
|
182
|
+
const list: ProductVariantFilterChip[] = [];
|
|
183
|
+
for (const axis of props.axes) {
|
|
184
|
+
for (const value of selectedFor(axis.code)) {
|
|
185
|
+
list.push({
|
|
186
|
+
key: `${axis.code}:${value}`,
|
|
187
|
+
label: value,
|
|
188
|
+
remove: () => toggleAxisValue(axis.code, value),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (availableOnly.value) {
|
|
193
|
+
list.push({
|
|
194
|
+
key: "available",
|
|
195
|
+
label: t("product.variants.chipAvailable"),
|
|
196
|
+
remove: () => {
|
|
197
|
+
availableOnly.value = false;
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (skuQuery.value.trim()) {
|
|
202
|
+
list.push({
|
|
203
|
+
key: "query",
|
|
204
|
+
label: skuQuery.value.trim(),
|
|
205
|
+
remove: () => {
|
|
206
|
+
skuQuery.value = "";
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return list;
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
function sortId(target: ProductVariantSort): string {
|
|
214
|
+
return target.kind === "axis" ? `axis:${target.code}` : target.kind;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function isActiveSort(target: ProductVariantSort): boolean {
|
|
218
|
+
return sortId(sort.value) === sortId(target);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function toggleSort(target: ProductVariantSort): void {
|
|
222
|
+
if (isActiveSort(target)) {
|
|
223
|
+
isAscending.value = !isAscending.value;
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
sort.value = target;
|
|
227
|
+
isAscending.value = true;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function sortIcon(target: ProductVariantSort): string {
|
|
231
|
+
if (!isActiveSort(target)) {
|
|
232
|
+
return icon("arrow-down");
|
|
233
|
+
}
|
|
234
|
+
return icon(isAscending.value ? "arrow-up" : "arrow-down");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const sortedRows = computed<ProductVariantRow[]>(() => {
|
|
238
|
+
const target = sort.value;
|
|
239
|
+
const direction = isAscending.value ? 1 : -1;
|
|
240
|
+
|
|
241
|
+
return [...filteredRows.value].sort((a, b) => {
|
|
242
|
+
if (target.kind === "sku") {
|
|
243
|
+
return direction * compareValues(a.sku, b.sku);
|
|
244
|
+
}
|
|
245
|
+
if (target.kind === "name") {
|
|
246
|
+
return direction * a.shortName.localeCompare(b.shortName, undefined, { numeric: true });
|
|
247
|
+
}
|
|
248
|
+
const valueA = a.values[target.code];
|
|
249
|
+
const valueB = b.values[target.code];
|
|
250
|
+
// Articles that don't carry this axis sink to the bottom either way —
|
|
251
|
+
// flipping the direction should reorder the values, not surface the gaps.
|
|
252
|
+
if (!valueA && !valueB) {
|
|
253
|
+
return 0;
|
|
254
|
+
}
|
|
255
|
+
if (!valueA) {
|
|
256
|
+
return 1;
|
|
257
|
+
}
|
|
258
|
+
if (!valueB) {
|
|
259
|
+
return -1;
|
|
260
|
+
}
|
|
261
|
+
return direction * compareValues(valueA, valueB);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Rows the table renders. The cap is an editorial choice (a block option), and
|
|
267
|
+
* the current article is always kept: a table that hides the very product you
|
|
268
|
+
* are looking at loses the reader's anchor.
|
|
269
|
+
*/
|
|
270
|
+
const visibleRows = computed<ProductVariantRow[]>(() => {
|
|
271
|
+
const limit = props.rowLimit;
|
|
272
|
+
if (limit <= 0 || isExpanded.value || sortedRows.value.length <= limit) {
|
|
273
|
+
return sortedRows.value;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const head = sortedRows.value.slice(0, limit);
|
|
277
|
+
if (head.some(row => row.isSelf)) {
|
|
278
|
+
return head;
|
|
279
|
+
}
|
|
280
|
+
const self = sortedRows.value.find(row => row.isSelf);
|
|
281
|
+
return self ? [...head.slice(0, limit - 1), self] : head;
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const hiddenCount = computed(() => sortedRows.value.length - visibleRows.value.length);
|
|
285
|
+
|
|
286
|
+
const showFilterBar = computed(() =>
|
|
287
|
+
props.showFilters && props.variants.length >= FILTER_BAR_MIN_VARIANTS);
|
|
288
|
+
|
|
289
|
+
/** The per-unit price header only makes sense when every article agrees on it. */
|
|
290
|
+
const orderUnit = computed<string | null>(() => {
|
|
291
|
+
const units = new Set(props.variants.map(variant => variant.orderUnit).filter(Boolean));
|
|
292
|
+
return units.size === 1 ? [...units][0] ?? null : null;
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
const priceHeader = computed(() => {
|
|
296
|
+
const label = t("product.variants.columns.price");
|
|
297
|
+
return orderUnit.value ? `${label} / ${orderUnit.value}` : label;
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
function axisLabel(axis: ProductVariantAxis): string {
|
|
301
|
+
return axis.unit ? `${axis.label} (${axis.unit})` : axis.label;
|
|
302
|
+
}
|
|
303
|
+
</script>
|
|
304
|
+
|
|
305
|
+
<template>
|
|
306
|
+
<section
|
|
307
|
+
v-if="variants.length"
|
|
308
|
+
class="mt-14 pt-10 border-t border-(--ui-border)"
|
|
309
|
+
>
|
|
310
|
+
<div class="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1">
|
|
311
|
+
<h2 class="text-lg font-semibold tracking-tight text-highlighted">
|
|
312
|
+
{{ t('product.variants.title') }}
|
|
313
|
+
</h2>
|
|
314
|
+
<p class="text-sm text-muted tabular-nums">
|
|
315
|
+
{{ sortedRows.length === variants.length
|
|
316
|
+
? t('product.variants.count', variants.length)
|
|
317
|
+
: t('product.variants.countFiltered', {
|
|
318
|
+
shown: sortedRows.length,
|
|
319
|
+
total: variants.length,
|
|
320
|
+
}) }}
|
|
321
|
+
</p>
|
|
322
|
+
</div>
|
|
323
|
+
<p
|
|
324
|
+
v-if="model"
|
|
325
|
+
class="mt-1 text-sm text-muted"
|
|
326
|
+
>
|
|
327
|
+
{{ model.name }}
|
|
328
|
+
</p>
|
|
329
|
+
|
|
330
|
+
<div
|
|
331
|
+
v-if="showFilterBar"
|
|
332
|
+
class="mt-5 border-b border-(--ui-border) pb-4"
|
|
333
|
+
>
|
|
334
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
335
|
+
<UInput
|
|
336
|
+
v-model="skuQuery"
|
|
337
|
+
name="variant-filter-sku"
|
|
338
|
+
type="search"
|
|
339
|
+
inputmode="numeric"
|
|
340
|
+
size="sm"
|
|
341
|
+
class="w-44"
|
|
342
|
+
:icon="icon('search')"
|
|
343
|
+
:placeholder="t('product.detail.sku')"
|
|
344
|
+
:aria-label="t('product.variants.filterSkuAria')"
|
|
345
|
+
/>
|
|
346
|
+
|
|
347
|
+
<UPopover
|
|
348
|
+
v-for="axis in axes"
|
|
349
|
+
:key="axis.code"
|
|
350
|
+
>
|
|
351
|
+
<UButton
|
|
352
|
+
color="neutral"
|
|
353
|
+
variant="outline"
|
|
354
|
+
size="sm"
|
|
355
|
+
tabindex="0"
|
|
356
|
+
class="cursor-pointer"
|
|
357
|
+
:trailing-icon="icon('chevron-down')"
|
|
358
|
+
>
|
|
359
|
+
{{ axisLabel(axis) }}
|
|
360
|
+
<template
|
|
361
|
+
v-if="selectedFor(axis.code).length"
|
|
362
|
+
#leading
|
|
363
|
+
>
|
|
364
|
+
<UBadge
|
|
365
|
+
color="primary"
|
|
366
|
+
variant="subtle"
|
|
367
|
+
size="sm"
|
|
368
|
+
:label="String(selectedFor(axis.code).length)"
|
|
369
|
+
/>
|
|
370
|
+
</template>
|
|
371
|
+
</UButton>
|
|
372
|
+
|
|
373
|
+
<template #content>
|
|
374
|
+
<div class="min-w-56">
|
|
375
|
+
<ul
|
|
376
|
+
role="list"
|
|
377
|
+
class="max-h-80 space-y-2 overflow-y-auto p-3"
|
|
378
|
+
>
|
|
379
|
+
<li
|
|
380
|
+
v-for="option in axisOptions(axis.code)"
|
|
381
|
+
:key="option.value"
|
|
382
|
+
>
|
|
383
|
+
<label class="group/row flex cursor-pointer items-center gap-2.5">
|
|
384
|
+
<UCheckbox
|
|
385
|
+
:model-value="isSelected(axis.code, option.value)"
|
|
386
|
+
tabindex="0"
|
|
387
|
+
:aria-label="option.value"
|
|
388
|
+
@update:model-value="toggleAxisValue(axis.code, option.value)"
|
|
389
|
+
/>
|
|
390
|
+
<span class="flex-1 text-sm text-muted group-hover/row:text-highlighted">
|
|
391
|
+
{{ option.value }}
|
|
392
|
+
</span>
|
|
393
|
+
<span class="text-sm text-dimmed tabular-nums">{{ option.count }}</span>
|
|
394
|
+
</label>
|
|
395
|
+
</li>
|
|
396
|
+
</ul>
|
|
397
|
+
<div
|
|
398
|
+
v-if="selectedFor(axis.code).length"
|
|
399
|
+
class="border-t border-(--ui-border) p-2"
|
|
400
|
+
>
|
|
401
|
+
<UButton
|
|
402
|
+
color="neutral"
|
|
403
|
+
variant="ghost"
|
|
404
|
+
size="sm"
|
|
405
|
+
block
|
|
406
|
+
class="cursor-pointer"
|
|
407
|
+
@click="clearAxis(axis.code)"
|
|
408
|
+
>
|
|
409
|
+
{{ t('product.variants.clearAxis') }}
|
|
410
|
+
</UButton>
|
|
411
|
+
</div>
|
|
412
|
+
</div>
|
|
413
|
+
</template>
|
|
414
|
+
</UPopover>
|
|
415
|
+
|
|
416
|
+
<UButton
|
|
417
|
+
:color="availableOnly ? 'primary' : 'neutral'"
|
|
418
|
+
:variant="availableOnly ? 'subtle' : 'outline'"
|
|
419
|
+
size="sm"
|
|
420
|
+
tabindex="0"
|
|
421
|
+
class="cursor-pointer"
|
|
422
|
+
:aria-pressed="availableOnly"
|
|
423
|
+
@click="availableOnly = !availableOnly"
|
|
424
|
+
>
|
|
425
|
+
{{ t('product.variants.availableOnly') }}
|
|
426
|
+
</UButton>
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
<div
|
|
430
|
+
v-if="chips.length"
|
|
431
|
+
class="mt-3 flex flex-wrap items-center gap-2"
|
|
432
|
+
>
|
|
433
|
+
<span class="text-sm text-muted">{{ t('search.filters.title') }}</span>
|
|
434
|
+
<span
|
|
435
|
+
v-for="chip in chips"
|
|
436
|
+
:key="chip.key"
|
|
437
|
+
class="inline-flex items-center gap-1 rounded-full py-1 pr-1 pl-2.5 text-sm
|
|
438
|
+
text-highlighted ring-1 ring-(--ui-border)"
|
|
439
|
+
>
|
|
440
|
+
{{ chip.label }}
|
|
441
|
+
<button
|
|
442
|
+
type="button"
|
|
443
|
+
class="relative cursor-pointer rounded-full p-0.5 text-dimmed
|
|
444
|
+
hover:text-highlighted focus-visible:outline-2 focus-visible:outline-offset-2
|
|
445
|
+
focus-visible:outline-(--ui-primary)"
|
|
446
|
+
:aria-label="t('search.filters.removeFilter', { value: chip.label })"
|
|
447
|
+
@click="chip.remove()"
|
|
448
|
+
>
|
|
449
|
+
<span
|
|
450
|
+
class="absolute top-1/2 left-1/2 size-[max(100%,3rem)] -translate-1/2
|
|
451
|
+
pointer-fine:hidden"
|
|
452
|
+
aria-hidden="true"
|
|
453
|
+
/>
|
|
454
|
+
<UIcon
|
|
455
|
+
:name="icon('close')"
|
|
456
|
+
class="size-3.5 shrink-0"
|
|
457
|
+
/>
|
|
458
|
+
</button>
|
|
459
|
+
</span>
|
|
460
|
+
<UButton
|
|
461
|
+
color="neutral"
|
|
462
|
+
variant="ghost"
|
|
463
|
+
size="sm"
|
|
464
|
+
class="cursor-pointer"
|
|
465
|
+
@click="resetFilters"
|
|
466
|
+
>
|
|
467
|
+
{{ t('product.variants.resetAll') }}
|
|
468
|
+
</UButton>
|
|
469
|
+
</div>
|
|
470
|
+
</div>
|
|
471
|
+
|
|
472
|
+
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
|
473
|
+
<div class="inline-block min-w-full px-4 py-2 align-middle sm:px-6 lg:px-8">
|
|
474
|
+
<table class="w-full text-sm">
|
|
475
|
+
<thead>
|
|
476
|
+
<tr class="border-b border-(--ui-border) text-left text-muted">
|
|
477
|
+
<th
|
|
478
|
+
scope="col"
|
|
479
|
+
class="py-2.5 pr-4 font-medium whitespace-nowrap"
|
|
480
|
+
>
|
|
481
|
+
<button
|
|
482
|
+
type="button"
|
|
483
|
+
class="inline-flex items-center gap-1 hover:text-highlighted cursor-pointer"
|
|
484
|
+
@click="toggleSort({ kind: 'sku' })"
|
|
485
|
+
>
|
|
486
|
+
{{ t('product.detail.sku') }}
|
|
487
|
+
<UIcon
|
|
488
|
+
:name="sortIcon({ kind: 'sku' })"
|
|
489
|
+
class="size-3.5"
|
|
490
|
+
:class="isActiveSort({ kind: 'sku' }) ? 'text-primary' : 'opacity-40'"
|
|
491
|
+
/>
|
|
492
|
+
</button>
|
|
493
|
+
</th>
|
|
494
|
+
<th
|
|
495
|
+
v-for="axis in axes"
|
|
496
|
+
:key="axis.code"
|
|
497
|
+
scope="col"
|
|
498
|
+
class="py-2.5 pr-4 font-medium whitespace-nowrap"
|
|
499
|
+
>
|
|
500
|
+
<button
|
|
501
|
+
type="button"
|
|
502
|
+
class="inline-flex items-center gap-1 hover:text-highlighted cursor-pointer"
|
|
503
|
+
@click="toggleSort({ kind: 'axis', code: axis.code })"
|
|
504
|
+
>
|
|
505
|
+
{{ axisLabel(axis) }}
|
|
506
|
+
<UIcon
|
|
507
|
+
:name="sortIcon({ kind: 'axis', code: axis.code })"
|
|
508
|
+
class="size-3.5"
|
|
509
|
+
:class="isActiveSort({ kind: 'axis', code: axis.code })
|
|
510
|
+
? 'text-primary'
|
|
511
|
+
: 'opacity-40'"
|
|
512
|
+
/>
|
|
513
|
+
</button>
|
|
514
|
+
</th>
|
|
515
|
+
<th
|
|
516
|
+
scope="col"
|
|
517
|
+
class="py-2.5 pr-4 font-medium whitespace-nowrap"
|
|
518
|
+
>
|
|
519
|
+
<button
|
|
520
|
+
type="button"
|
|
521
|
+
class="inline-flex items-center gap-1 hover:text-highlighted cursor-pointer"
|
|
522
|
+
@click="toggleSort({ kind: 'name' })"
|
|
523
|
+
>
|
|
524
|
+
{{ t('product.variants.columns.name') }}
|
|
525
|
+
<UIcon
|
|
526
|
+
:name="sortIcon({ kind: 'name' })"
|
|
527
|
+
class="size-3.5"
|
|
528
|
+
:class="isActiveSort({ kind: 'name' }) ? 'text-primary' : 'opacity-40'"
|
|
529
|
+
/>
|
|
530
|
+
</button>
|
|
531
|
+
</th>
|
|
532
|
+
<th
|
|
533
|
+
scope="col"
|
|
534
|
+
class="py-2.5 pr-4 text-right font-medium whitespace-nowrap"
|
|
535
|
+
>
|
|
536
|
+
{{ priceHeader }}
|
|
537
|
+
</th>
|
|
538
|
+
<th
|
|
539
|
+
scope="col"
|
|
540
|
+
class="py-2.5 pr-4 font-medium whitespace-nowrap"
|
|
541
|
+
>
|
|
542
|
+
{{ t('product.variants.columns.availability') }}
|
|
543
|
+
</th>
|
|
544
|
+
<th
|
|
545
|
+
v-if="showOrderButton"
|
|
546
|
+
scope="col"
|
|
547
|
+
class="py-2.5 font-medium"
|
|
548
|
+
>
|
|
549
|
+
<span class="sr-only">{{ t('product.actions.order') }}</span>
|
|
550
|
+
</th>
|
|
551
|
+
</tr>
|
|
552
|
+
</thead>
|
|
553
|
+
<tbody class="divide-y divide-(--ui-border)">
|
|
554
|
+
<ProductDetailVariantRow
|
|
555
|
+
v-for="row in visibleRows"
|
|
556
|
+
:key="row.id"
|
|
557
|
+
:row="row"
|
|
558
|
+
:axes="axes"
|
|
559
|
+
:to="linkFor(row)"
|
|
560
|
+
:tax-rate="taxRate"
|
|
561
|
+
:category-slug="categorySlug"
|
|
562
|
+
:subcategory-slug="subcategorySlug"
|
|
563
|
+
:show-order-button="showOrderButton"
|
|
564
|
+
/>
|
|
565
|
+
</tbody>
|
|
566
|
+
</table>
|
|
567
|
+
|
|
568
|
+
<p
|
|
569
|
+
v-if="!sortedRows.length"
|
|
570
|
+
class="py-8 text-center text-sm text-muted"
|
|
571
|
+
>
|
|
572
|
+
{{ t('product.variants.empty') }}
|
|
573
|
+
<button
|
|
574
|
+
type="button"
|
|
575
|
+
class="text-primary hover:underline cursor-pointer"
|
|
576
|
+
@click="resetFilters"
|
|
577
|
+
>
|
|
578
|
+
{{ t('product.variants.reset') }}
|
|
579
|
+
</button>
|
|
580
|
+
</p>
|
|
581
|
+
</div>
|
|
582
|
+
</div>
|
|
583
|
+
|
|
584
|
+
<div
|
|
585
|
+
v-if="hiddenCount > 0"
|
|
586
|
+
class="mt-4"
|
|
587
|
+
>
|
|
588
|
+
<UButton
|
|
589
|
+
color="neutral"
|
|
590
|
+
variant="outline"
|
|
591
|
+
size="sm"
|
|
592
|
+
class="cursor-pointer"
|
|
593
|
+
:trailing-icon="icon('chevron-down')"
|
|
594
|
+
:label="t('product.variants.showAll', { count: sortedRows.length })"
|
|
595
|
+
@click="isExpanded = true"
|
|
596
|
+
/>
|
|
597
|
+
</div>
|
|
598
|
+
|
|
599
|
+
<p class="mt-3 text-sm text-muted">
|
|
600
|
+
{{ t('product.price.exclTax') }}
|
|
601
|
+
</p>
|
|
602
|
+
</section>
|
|
603
|
+
|
|
604
|
+
<!--
|
|
605
|
+
A product that belongs to no model renders nothing here. The slot lets a
|
|
606
|
+
host (the blokkli block) put a selectable stand-in in its place on the
|
|
607
|
+
editor canvas, where a zero-height block is unreachable.
|
|
608
|
+
-->
|
|
609
|
+
<slot
|
|
610
|
+
v-else
|
|
611
|
+
name="empty"
|
|
612
|
+
/>
|
|
613
|
+
</template>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A product listing image with the catalogue's icon fallback.
|
|
4
|
+
*
|
|
5
|
+
* Not every product carries a picture — the live catalogue's `image` common
|
|
6
|
+
* attribute is optional and a stale CDN key 404s after a PIM re-import. Both
|
|
7
|
+
* cases must land on the same glyph rather than a broken-image icon or an empty
|
|
8
|
+
* box, which is why every product tile (grid card, category grid, category list)
|
|
9
|
+
* renders its image through here instead of a bare `<img>`.
|
|
10
|
+
*
|
|
11
|
+
* The caller owns the box: this component only fills it, so the sizing classes
|
|
12
|
+
* stay with the surrounding layout.
|
|
13
|
+
*/
|
|
14
|
+
const props = withDefaults(defineProps<{
|
|
15
|
+
/** Raw `ProductList.image` value — resolved here, pass it through unchanged. */
|
|
16
|
+
src: string;
|
|
17
|
+
alt: string;
|
|
18
|
+
imageClass?: string;
|
|
19
|
+
iconClass?: string;
|
|
20
|
+
lazy?: boolean;
|
|
21
|
+
}>(), {
|
|
22
|
+
imageClass: "max-h-full max-w-full object-contain",
|
|
23
|
+
iconClass: "size-8 text-muted",
|
|
24
|
+
lazy: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const { icon } = useIcons();
|
|
28
|
+
const { getImage } = useProductImage();
|
|
29
|
+
|
|
30
|
+
const hasFailed = ref(false);
|
|
31
|
+
const image = useTemplateRef<HTMLImageElement>("image");
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* `@error` alone cannot promise the fallback. An SSR-rendered <img> starts
|
|
35
|
+
* loading while the HTML is still parsing and can fail BEFORE Vue hydrates, and
|
|
36
|
+
* the listener attached at hydration never sees an event that already fired — so
|
|
37
|
+
* the tile would keep a broken image in exactly the case the glyph exists for.
|
|
38
|
+
* Check once on mount for an image that is already finished and has no intrinsic
|
|
39
|
+
* width; everything still in flight is `@error`'s job.
|
|
40
|
+
*
|
|
41
|
+
* `currentSrc` is the guard against a false positive: the browser only sets it
|
|
42
|
+
* once it has actually selected a source, so an image that was never fetched — a
|
|
43
|
+
* lazy tile below the fold, or any non-loading environment such as the jsdom
|
|
44
|
+
* test env — is skipped rather than declared broken.
|
|
45
|
+
*/
|
|
46
|
+
onMounted(() => {
|
|
47
|
+
const element = image.value;
|
|
48
|
+
if (element?.complete && element.naturalWidth === 0 && element.currentSrc) {
|
|
49
|
+
hasFailed.value = true;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<img
|
|
56
|
+
v-if="props.src && !hasFailed"
|
|
57
|
+
ref="image"
|
|
58
|
+
:src="getImage(props.src)"
|
|
59
|
+
:alt="props.alt"
|
|
60
|
+
:loading="props.lazy ? 'lazy' : undefined"
|
|
61
|
+
:class="props.imageClass"
|
|
62
|
+
@error="hasFailed = true"
|
|
63
|
+
>
|
|
64
|
+
<UIcon
|
|
65
|
+
v-else
|
|
66
|
+
:name="icon('package')"
|
|
67
|
+
:class="props.iconClass"
|
|
68
|
+
aria-hidden="true"
|
|
69
|
+
/>
|
|
70
|
+
</template>
|
|
@@ -15,7 +15,19 @@ interface Suggestion {
|
|
|
15
15
|
subcategorySlug?: string;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
// Optional override for callers that author their own wording (the search_bar
|
|
19
|
+
// blokkli block lets an editor set one per instance). Unset — the header's two
|
|
20
|
+
// call sites — keeps the translated default.
|
|
21
|
+
const props = withDefaults(defineProps<{
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
}>(), {
|
|
24
|
+
placeholder: undefined,
|
|
25
|
+
});
|
|
26
|
+
|
|
18
27
|
const { t } = useI18n();
|
|
28
|
+
|
|
29
|
+
const placeholder = computed(() => props.placeholder || t("search.input.placeholder"));
|
|
30
|
+
|
|
19
31
|
// The layer ships a `search` default, but a consumer that overrides
|
|
20
32
|
// app.config without it must not crash the header — fall back locally.
|
|
21
33
|
const appConfig = useAppConfig();
|
|
@@ -135,8 +147,8 @@ onUnmounted(() => document.removeEventListener("click", handleClickOutside));
|
|
|
135
147
|
v-model="query"
|
|
136
148
|
name="search"
|
|
137
149
|
:leading-icon="icon('search')"
|
|
138
|
-
:placeholder="
|
|
139
|
-
:aria-label="
|
|
150
|
+
:placeholder="placeholder"
|
|
151
|
+
:aria-label="placeholder"
|
|
140
152
|
size="lg"
|
|
141
153
|
color="primary"
|
|
142
154
|
variant="none"
|