@revenexx/cover 0.2.26 → 0.2.28

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 (79) hide show
  1. package/app/api/brands.ts +5 -0
  2. package/app/api/categories.ts +1 -0
  3. package/app/api/product.ts +2 -0
  4. package/app/app.config.ts +8 -0
  5. package/app/components/cart/quickadd/CartQuickAdd.vue +110 -34
  6. package/app/components/category/view/GridView.vue +34 -13
  7. package/app/components/category/view/ListView.vue +5 -5
  8. package/app/components/layout/AppLogo.vue +2 -1
  9. package/app/components/layout/footer/Footer.vue +9 -3
  10. package/app/components/layout/header/CategoryPanel.vue +92 -0
  11. package/app/components/layout/header/MainNav.vue +89 -2
  12. package/app/components/listing/ListingResults.vue +16 -2
  13. package/app/components/listing/ListingSubcategories.vue +124 -0
  14. package/app/components/product/card/Compact.vue +144 -0
  15. package/app/components/product/detail/ProductDetailAssociations.vue +96 -0
  16. package/app/components/product/detail/ProductDetailIdentity.vue +50 -5
  17. package/app/components/product/detail/ProductDetailVariantRow.vue +139 -0
  18. package/app/components/product/detail/ProductDetailVariants.vue +613 -0
  19. package/app/components/product/media/ProductMediaImage.vue +70 -0
  20. package/app/components/ui/forms/SearchInput.vue +14 -2
  21. package/app/components/ui/media/ImageSlider.vue +158 -0
  22. package/app/composables/useBranding.ts +22 -0
  23. package/app/composables/useBrands.ts +42 -0
  24. package/app/composables/useCategories.ts +55 -1
  25. package/app/composables/useProduct.ts +5 -4
  26. package/app/composables/useProductAssociations.ts +35 -0
  27. package/app/composables/useProductImage.ts +35 -2
  28. package/app/composables/useProductVariants.ts +46 -0
  29. package/app/composables/useSearchListing.ts +16 -5
  30. package/app/composables/useSubcategoryTiles.ts +36 -0
  31. package/app/config/navigation.ts +9 -0
  32. package/app/config/palette.ts +1 -0
  33. package/app/config/quickActions.ts +137 -0
  34. package/app/config/themes.ts +1 -0
  35. package/app/interfaces/brand.ts +16 -0
  36. package/app/interfaces/category.ts +45 -0
  37. package/app/interfaces/image-slider.ts +18 -0
  38. package/app/interfaces/product-associations.ts +32 -0
  39. package/app/interfaces/product-detail.ts +6 -0
  40. package/app/interfaces/product-variants.ts +73 -0
  41. package/i18n/locales/de/account.json +17 -0
  42. package/i18n/locales/de/cart.json +5 -1
  43. package/i18n/locales/de/common.json +42 -2
  44. package/i18n/locales/de/editor.json +91 -0
  45. package/i18n/locales/de/product.json +48 -2
  46. package/i18n/locales/de/search.json +4 -2
  47. package/i18n/locales/en/account.json +17 -0
  48. package/i18n/locales/en/cart.json +4 -0
  49. package/i18n/locales/en/common.json +42 -2
  50. package/i18n/locales/en/editor.json +91 -0
  51. package/i18n/locales/en/product.json +47 -1
  52. package/i18n/locales/en/search.json +3 -1
  53. package/nuxt.config.ts +10 -0
  54. package/package.json +3 -1
  55. package/public/img/brands/revenexx.svg +39 -0
  56. package/server/api/brands.get.ts +27 -0
  57. package/server/api/categories/[slug]/subcategories.get.ts +280 -0
  58. package/server/api/product/[id]/associations.get.ts +27 -0
  59. package/server/api/product/[id]/variants.get.ts +27 -0
  60. package/server/api/quick-actions.get.ts +43 -0
  61. package/server/api/typesense/search.post.ts +116 -13
  62. package/server/data/categories.json +5 -0
  63. package/server/data/product-associations.json +44 -0
  64. package/server/data/product-detail.json +346 -0
  65. package/server/data/product-list.json +340 -0
  66. package/server/data/product-variant-models.json +75 -0
  67. package/server/interfaces/brand.ts +17 -0
  68. package/server/interfaces/product.ts +14 -0
  69. package/server/services/ApiBrandService.ts +110 -0
  70. package/server/services/ApiProductService.ts +43 -9
  71. package/server/services/LocalFileProductService.ts +200 -6
  72. package/server/services/MockBrandService.ts +52 -0
  73. package/server/utils/brandService.ts +24 -0
  74. package/server/utils/contentTenant.ts +67 -0
  75. package/server/utils/liveCatalog.ts +759 -46
  76. package/server/utils/productService.ts +6 -1
  77. package/server/utils/productsSchema.ts +5 -2
  78. package/server/utils/revenexxCredentials.ts +258 -0
  79. package/server/utils/revenexxSdk.ts +38 -47
@@ -0,0 +1,124 @@
1
+ <script setup lang="ts">
2
+ import type { SubcategoryTile } from "../../interfaces/category";
3
+
4
+ /**
5
+ * The subcategory drill-down on a category page: one card per child category,
6
+ * linking into it. The counterpart of the filter rail's `subcategory` facet —
7
+ * same axis, but as the page's primary navigation rather than a filter.
8
+ *
9
+ * Layout is ported from the eltric reference: a horizontal card with the media
10
+ * in a fixed square on the LEFT and the label above its product count on the
11
+ * right. `object-contain` on a tinted square rather than a cropping cover fill,
12
+ * because these are product photos on transparent backgrounds.
13
+ *
14
+ * `media` picks what fills that square:
15
+ * - `image` — a preview photo from one of the subcategory's products (the BFF
16
+ * picks it; see useSubcategoryTiles).
17
+ * - `icon` — the subcategory's icon token.
18
+ *
19
+ * A tile with no image falls back to the icon in the same square, so a mixed
20
+ * grid keeps one alignment. That is also what an empty subcategory or an
21
+ * unreachable product index produces.
22
+ *
23
+ * Purely presentational: the caller owns the fetch and the decision to render.
24
+ */
25
+ const props = withDefaults(defineProps<{
26
+ tiles: SubcategoryTile[];
27
+ /** Parent slug — the first segment of every card's link. */
28
+ categorySlug: string;
29
+ /** Column count from the `xl` breakpoint up; narrower steps are fixed. */
30
+ perRow?: string;
31
+ media?: "icon" | "image";
32
+ showProductCount?: boolean;
33
+ /** Optional heading above the grid. */
34
+ heading?: string;
35
+ }>(), {
36
+ perRow: "6",
37
+ media: "image",
38
+ showProductCount: true,
39
+ heading: "",
40
+ });
41
+
42
+ const { t } = useI18n();
43
+ const { icon } = useIcons();
44
+ const localePath = useLocalePath();
45
+ const { getImage } = useProductImage();
46
+
47
+ // Static map so Tailwind's JIT emits every utility — deliberately a local
48
+ // literal rather than a shared export: coupling this to the category grid's
49
+ // own map would freeze both layouts together, and they step differently.
50
+ const PER_ROW_CLASS: Record<string, string> = {
51
+ 4: "xl:grid-cols-4",
52
+ 5: "xl:grid-cols-5",
53
+ 6: "xl:grid-cols-6",
54
+ 7: "xl:grid-cols-7",
55
+ 8: "xl:grid-cols-8",
56
+ };
57
+
58
+ const perRowClass = computed(() => PER_ROW_CLASS[props.perRow] ?? PER_ROW_CLASS[6]);
59
+ const isImageMedia = computed(() => props.media === "image");
60
+ </script>
61
+
62
+ <template>
63
+ <nav
64
+ :aria-label="t('search.filters.facets.subcategory')"
65
+ class="py-4"
66
+ >
67
+ <h2
68
+ v-if="props.heading"
69
+ class="mb-4 text-lg font-semibold text-highlighted"
70
+ >
71
+ {{ props.heading }}
72
+ </h2>
73
+
74
+ <ul
75
+ role="list"
76
+ :class="['grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4', perRowClass]"
77
+ >
78
+ <!-- Keyed on the index too: categories.json ships a category whose
79
+ subcategory slugs repeat, and a bare slug would collide. -->
80
+ <li
81
+ v-for="(tile, index) in props.tiles"
82
+ :key="`${index}-${tile.slug}`"
83
+ >
84
+ <NuxtLink
85
+ :to="localePath(`/category/${props.categorySlug}/${tile.slug}`)"
86
+ tabindex="0"
87
+ class="group flex h-full items-center gap-3 rounded-lg p-2 ring-1 ring-(--ui-border)
88
+ transition-colors hover:ring-(--ui-primary)
89
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--ui-primary)"
90
+ >
91
+ <span
92
+ class="flex size-12 shrink-0 items-center justify-center overflow-hidden
93
+ rounded bg-elevated/40"
94
+ >
95
+ <img
96
+ v-if="isImageMedia && tile.image"
97
+ :src="getImage(tile.image)"
98
+ :alt="tile.label"
99
+ loading="lazy"
100
+ class="max-h-full max-w-full object-contain"
101
+ >
102
+ <UIcon
103
+ v-else
104
+ :name="icon(tile.icon)"
105
+ class="size-6 text-(--ui-primary)"
106
+ />
107
+ </span>
108
+
109
+ <span class="min-w-0 flex-1">
110
+ <span class="line-clamp-2 text-sm text-highlighted group-hover:text-(--ui-primary)">
111
+ {{ tile.label }}
112
+ </span>
113
+ <span
114
+ v-if="props.showProductCount"
115
+ class="text-sm text-muted tabular-nums"
116
+ >
117
+ {{ t('search.category.productCount', tile.productCount, { count: tile.productCount }) }}
118
+ </span>
119
+ </span>
120
+ </NuxtLink>
121
+ </li>
122
+ </ul>
123
+ </nav>
124
+ </template>
@@ -0,0 +1,144 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Compact product card for the `product_grid` block — a self-contained bordered
4
+ * tile, deliberately NOT a UCard: UCard's outline variant puts `divide-y` on its
5
+ * root, which draws a line under the image and above the buttons.
6
+ *
7
+ * One button, not two: it is "order" while the product is orderable and falls
8
+ * back to "info" (linking to the detail page) when there is no price or no
9
+ * stock. `CategoryViewGridView` keeps the two-button layout for the category and
10
+ * search pages.
11
+ *
12
+ * The price is rendered here rather than through `CategoryInfoCategoryPrice`,
13
+ * whose typography is shared with the category page and the list view. Only the
14
+ * presentation is local — the tier/tax maths comes from `useProducts`.
15
+ */
16
+ import { getDisplayUnitPrice, getPriceTiers, getPriceWithOptionalTax } from "../../../composables/useProducts";
17
+ import type { ProductList } from "../../../interfaces/product-list";
18
+
19
+ const props = withDefaults(defineProps<{
20
+ product: ProductList;
21
+ /**
22
+ * `order` still falls back to the info link when the product has no price or
23
+ * no stock; `info` always links to the detail page.
24
+ */
25
+ action?: "order" | "info";
26
+ }>(), {
27
+ action: "order",
28
+ });
29
+
30
+ const { t } = useI18n();
31
+ const { icon } = useIcons();
32
+ const { public: { locale, taxIncludedPrices } } = useRuntimeConfig();
33
+ const currency = useDisplayCurrency();
34
+
35
+ const { url } = useProductCard(() => props.product);
36
+ const { isOutOfStock, hasPrice, addToCart } = useProductCardActions(() => props.product);
37
+
38
+ const canOrder = computed(() =>
39
+ props.action === "order" && !isOutOfStock.value && hasPrice.value,
40
+ );
41
+
42
+ // Price is the Offer domain — resolved separately, hydrates after first paint.
43
+ const { offer, pending } = useOffers().useOffer(() => props.product.id);
44
+ const offerPrices = computed(() => offer.value?.prices ?? []);
45
+ const hasTieredPricing = computed(() => getPriceTiers(offerPrices.value).length > 1);
46
+
47
+ const displayPrice = computed<number | null>(() => {
48
+ const basePrice = getDisplayUnitPrice(offerPrices.value);
49
+ if (basePrice === null) {
50
+ return null;
51
+ }
52
+ return getPriceWithOptionalTax(basePrice, props.product.tax.rate, taxIncludedPrices);
53
+ });
54
+
55
+ function formatPrice(price: number): string {
56
+ return price.toLocaleString(locale, { style: "currency", currency: currency.value });
57
+ }
58
+ </script>
59
+
60
+ <template>
61
+ <div class="group flex h-full flex-col rounded-lg border border-(--ui-border) p-3 transition-colors hover:border-primary/60">
62
+ <NuxtLink
63
+ :to="url"
64
+ tabindex="-1"
65
+ aria-hidden="true"
66
+ class="block"
67
+ >
68
+ <!-- The image is sized by `inset-0`, not `max-h-full`: a percentage
69
+ max-height does not resolve for a flex item whose containing block gets
70
+ its height from `aspect-ratio`, so portrait images kept their intrinsic
71
+ height and were clipped. `object-contain` then letterboxes inside the
72
+ box, so the whole picture shows at any aspect ratio. -->
73
+ <div class="relative aspect-square flex items-center justify-center overflow-hidden rounded bg-elevated/40">
74
+ <ProductMediaImage
75
+ :src="props.product.image"
76
+ :alt="props.product.name"
77
+ image-class="absolute inset-0 size-full object-contain"
78
+ icon-class="size-8 text-muted"
79
+ />
80
+ </div>
81
+ </NuxtLink>
82
+
83
+ <NuxtLink
84
+ :to="url"
85
+ class="mt-2 block text-sm leading-snug line-clamp-2 text-highlighted group-hover:text-primary"
86
+ >
87
+ {{ props.product.name }}
88
+ </NuxtLink>
89
+
90
+ <p class="mt-1 text-xs tabular-nums text-muted">
91
+ {{ props.product.sku }}
92
+ </p>
93
+
94
+ <!-- mt-auto pins the facts and the button to the bottom, so cards of
95
+ differing title length still line up across a row. -->
96
+ <div class="mt-auto pt-2 space-y-1">
97
+ <CategoryInfoCategoryStock :product="props.product" />
98
+
99
+ <div>
100
+ <USkeleton
101
+ v-if="pending"
102
+ class="h-6 w-24"
103
+ />
104
+ <div
105
+ v-else-if="displayPrice === null"
106
+ class="text-sm font-medium text-muted"
107
+ >
108
+ {{ t('product.price.onRequest') }}
109
+ </div>
110
+ <template v-else>
111
+ <div class="flex flex-wrap items-baseline gap-x-1.5">
112
+ <span
113
+ v-if="hasTieredPricing"
114
+ class="text-sm text-muted"
115
+ >{{ t('product.price.from') }}</span>
116
+ <span class="font-semibold text-highlighted">{{ formatPrice(displayPrice) }}</span>
117
+ <span class="text-muted">
118
+ {{ taxIncludedPrices ? t('product.price.inclTax') : t('product.price.exclTax') }}
119
+ </span>
120
+ </div>
121
+ <p
122
+ v-if="hasTieredPricing"
123
+ class="text-sm text-primary"
124
+ >
125
+ {{ t('product.price.volume') }}
126
+ </p>
127
+ </template>
128
+ </div>
129
+ </div>
130
+
131
+ <UButton
132
+ :label="canOrder ? t('product.actions.order') : t('product.actions.info')"
133
+ :color="canOrder ? 'primary' : 'neutral'"
134
+ :variant="canOrder ? 'solid' : 'soft'"
135
+ :icon="canOrder ? icon('cart') : undefined"
136
+ :to="canOrder ? undefined : url"
137
+ :aria-label="canOrder ? `${t('product.actions.addToCart')}: ${props.product.name}` : props.product.name"
138
+ size="sm"
139
+ block
140
+ class="mt-2 justify-center cursor-pointer"
141
+ @click="canOrder ? addToCart() : undefined"
142
+ />
143
+ </div>
144
+ </template>
@@ -0,0 +1,96 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The related-article grids of the product detail page: one section per
4
+ * relation type the product has — "Zubehör", "Pflichtzubehör", "Ersatzteile" —
5
+ * each a grid of tiles carrying an image, the article name and its number.
6
+ *
7
+ * Props-only like its neighbours; the host fetches via
8
+ * `useProductAssociations` and supplies `linkFor`. Deliberately no price on a
9
+ * tile: these are a way into the catalogue, not a second buy box, so the
10
+ * section costs no offer request.
11
+ *
12
+ * The tiles run no per-item composable, so they stay an inline `v-for` rather
13
+ * than a component of their own (unlike a variants row, which needs one
14
+ * `useOffer` instance apiece).
15
+ *
16
+ * The tile image box is `relative` with an absolutely positioned image rather
17
+ * than a percentage max-height: that does not resolve for a flex item whose
18
+ * containing block takes its height from `aspect-ratio` (same fix, and the same
19
+ * reason, as ProductCardCompact).
20
+ */
21
+ import type {
22
+ ProductAssociationGroup,
23
+ ProductAssociationItem,
24
+ } from "../../../interfaces/product-associations";
25
+
26
+ defineProps<{
27
+ groups: readonly ProductAssociationGroup[];
28
+ /** Localised route to a related article's own detail page. */
29
+ linkFor: (item: ProductAssociationItem) => string;
30
+ }>();
31
+
32
+ const { t } = useI18n();
33
+ </script>
34
+
35
+ <template>
36
+ <template v-if="groups.length">
37
+ <section
38
+ v-for="group in groups"
39
+ :key="group.code"
40
+ class="mt-14 pt-10 border-t border-(--ui-border)"
41
+ >
42
+ <h2 class="text-lg font-semibold tracking-tight text-highlighted">
43
+ {{ group.label }}
44
+ <span
45
+ v-if="group.isMandatory"
46
+ class="ml-2 align-middle text-xs font-normal text-muted"
47
+ >
48
+ {{ t('product.associations.mandatoryNote') }}
49
+ </span>
50
+ </h2>
51
+
52
+ <ul class="mt-4 grid gap-4 grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6">
53
+ <li
54
+ v-for="item in group.items"
55
+ :key="item.id"
56
+ >
57
+ <NuxtLink
58
+ :to="linkFor(item)"
59
+ class="group block rounded-lg border border-(--ui-border) p-3 h-full
60
+ hover:border-primary/60 transition-colors"
61
+ >
62
+ <div
63
+ class="relative aspect-square flex items-center justify-center
64
+ overflow-hidden rounded bg-elevated/40"
65
+ >
66
+ <ProductMediaImage
67
+ :src="item.image"
68
+ :alt="item.name"
69
+ image-class="absolute inset-0 size-full object-contain"
70
+ />
71
+ </div>
72
+ <p
73
+ class="mt-2 text-sm leading-snug line-clamp-3 text-highlighted
74
+ group-hover:text-primary"
75
+ >
76
+ {{ item.name }}
77
+ </p>
78
+ <p class="mt-1 text-xs tabular-nums text-muted">
79
+ {{ item.sku }}
80
+ </p>
81
+ </NuxtLink>
82
+ </li>
83
+ </ul>
84
+ </section>
85
+ </template>
86
+
87
+ <!--
88
+ A product that relates to nothing renders nothing here. The slot lets a
89
+ host (the blokkli block) put a selectable stand-in in its place on the
90
+ editor canvas, where a zero-height block is unreachable.
91
+ -->
92
+ <slot
93
+ v-else
94
+ name="empty"
95
+ />
96
+ </template>
@@ -1,17 +1,50 @@
1
1
  <script setup lang="ts">
2
2
  /**
3
- * Product identity block: manufacturer, name and a copy-to-clipboard SKU.
3
+ * Product identity block: manufacturer, name, the manufacturer logo where the
4
+ * catalogue has one, and a copy-to-clipboard SKU.
4
5
  */
5
6
  const props = defineProps<{
6
7
  manufacturer: string;
7
8
  name: string;
8
9
  sku: string;
10
+ /**
11
+ * Manufacturer logo src, or null/undefined for none. Whether a logo MAY be
12
+ * shown is the caller's decision (the blokkli block exposes it as an
13
+ * editor option) — this component only renders what it is handed.
14
+ */
15
+ logo?: string | null;
9
16
  }>();
10
17
 
11
18
  const { icon } = useIcons();
12
19
  const { t } = useI18n();
13
20
  const toast = useToast();
14
21
 
22
+ const root = ref<HTMLElement | null>(null);
23
+ // A logo URL that 404s (a stale CDN key after a PIM re-import) must leave the
24
+ // heading alone, not a broken-image glyph next to it. The manufacturer name is
25
+ // already on the line above, so there is nothing to fall back TO.
26
+ const logoFailed = ref(false);
27
+
28
+ const showLogo = computed<boolean>(() => Boolean(props.logo) && !logoFailed.value);
29
+
30
+ /**
31
+ * `@error` alone cannot promise that. An SSR-rendered <img> starts loading while
32
+ * the HTML is still parsing and can fail BEFORE Vue hydrates; the listener
33
+ * attached at hydration never sees an event that already fired. Sweep once on
34
+ * mount for an image that is already finished and has no intrinsic width —
35
+ * anything still in flight is `@error`'s job. `currentSrc` guards against a
36
+ * false positive: the browser only sets it once it has actually selected a
37
+ * source, so an image that was never fetched (a hidden one below `sm`, or any
38
+ * non-loading environment such as the jsdom test env) is skipped rather than
39
+ * declared broken.
40
+ */
41
+ onMounted(() => {
42
+ const image = root.value?.querySelector<HTMLImageElement>("img[data-manufacturer-logo]");
43
+ if (image?.complete && image.naturalWidth === 0 && image.currentSrc) {
44
+ logoFailed.value = true;
45
+ }
46
+ });
47
+
15
48
  async function copySku(): Promise<void> {
16
49
  await navigator.clipboard.writeText(props.sku);
17
50
  toast.add({ title: t("product.detail.skuCopied"), duration: 1200, icon: icon("copy-check") });
@@ -19,13 +52,25 @@ async function copySku(): Promise<void> {
19
52
  </script>
20
53
 
21
54
  <template>
22
- <div>
55
+ <div ref="root">
23
56
  <p class="text-xs font-semibold uppercase tracking-wide text-muted">
24
57
  {{ manufacturer }}
25
58
  </p>
26
- <h1 class="mt-1 text-3xl font-semibold tracking-tight text-highlighted">
27
- {{ name }}
28
- </h1>
59
+ <div class="mt-1 flex items-start justify-between gap-6">
60
+ <h1 class="text-3xl font-semibold tracking-tight text-highlighted">
61
+ {{ name }}
62
+ </h1>
63
+ <!-- Desktop only: on a phone the product name needs the full width. -->
64
+ <img
65
+ v-if="showLogo"
66
+ :src="logo ?? undefined"
67
+ :alt="manufacturer"
68
+ data-manufacturer-logo
69
+ loading="lazy"
70
+ class="hidden sm:block h-14 w-auto max-w-36 object-contain shrink-0"
71
+ @error="logoFailed = true"
72
+ >
73
+ </div>
29
74
  <button
30
75
  type="button"
31
76
  tabindex="0"
@@ -0,0 +1,139 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * One row of the variants table.
4
+ *
5
+ * Its own component because price, orderability and add-to-cart are per-product
6
+ * composable instances (`useOffer` via CategoryPrice, `useProductCardActions`) —
7
+ * they cannot be called from inside a `v-for`. The row synthesises the
8
+ * `ProductList` shape those expect from the variant plus the page product's tax
9
+ * rate and category path.
10
+ *
11
+ * Two details that read as odd in the template: the current article links to
12
+ * ITSELF, because that is what makes the router mark it `aria-current="page"` —
13
+ * the cue that tells a screen reader which row you are on; and the order
14
+ * button's absolutely positioned empty span pads its hit area out to 3rem on
15
+ * coarse pointers only.
16
+ */
17
+ import type { ProductList } from "../../../interfaces/product-list";
18
+ import type { ProductVariantAxis, ProductVariantRow } from "../../../interfaces/product-variants";
19
+
20
+ const props = withDefaults(defineProps<{
21
+ row: ProductVariantRow;
22
+ axes: readonly ProductVariantAxis[];
23
+ /** Localised route to this variant's detail page. */
24
+ to: string;
25
+ /** Catalog tax rate of the page's article — variants share the model's. */
26
+ taxRate: number;
27
+ categorySlug?: string;
28
+ subcategorySlug?: string;
29
+ showOrderButton?: boolean;
30
+ }>(), {
31
+ categorySlug: "",
32
+ showOrderButton: true,
33
+ });
34
+
35
+ const { t } = useI18n();
36
+ const { icon } = useIcons();
37
+
38
+ const asProduct = computed<ProductList>(() => ({
39
+ id: props.row.id,
40
+ sku: props.row.sku,
41
+ name: props.row.name,
42
+ available: props.row.available,
43
+ prices: [],
44
+ tax: { rate: props.taxRate },
45
+ // No per-variant image in the payload — the cart falls back to its
46
+ // placeholder icon, and the table shows no thumbnails anyway. The category
47
+ // path IS carried through so a cart line can link back to its product.
48
+ image: "",
49
+ category: "",
50
+ categorySlug: props.categorySlug,
51
+ ...(props.subcategorySlug ? { subcategorySlug: props.subcategorySlug } : {}),
52
+ }));
53
+
54
+ const { isOutOfStock, hasPrice, addToCart } = useProductCardActions(() => asProduct.value);
55
+
56
+ const isInStock = computed(() => props.row.available && !isOutOfStock.value);
57
+ const canOrder = computed(() => !isOutOfStock.value && hasPrice.value);
58
+ const addToCartLabel = computed(() => t("product.actions.addToCart"));
59
+ </script>
60
+
61
+ <template>
62
+ <tr :class="row.isSelf ? 'bg-primary/5' : 'hover:bg-elevated/40'">
63
+ <td
64
+ class="py-3 pr-4 whitespace-nowrap"
65
+ :class="row.isSelf ? 'border-l-2 border-primary pl-3' : 'pl-0'"
66
+ >
67
+ <NuxtLink
68
+ :to="to"
69
+ class="tabular-nums"
70
+ :class="row.isSelf ? 'font-semibold text-highlighted' : 'text-primary hover:underline'"
71
+ >
72
+ {{ row.sku }}
73
+ </NuxtLink>
74
+ </td>
75
+
76
+ <td
77
+ v-for="axis in axes"
78
+ :key="axis.code"
79
+ class="py-3 pr-4 whitespace-nowrap tabular-nums"
80
+ :class="row.values[axis.code] ? 'text-highlighted' : 'text-muted'"
81
+ >
82
+ {{ row.values[axis.code] ?? '—' }}
83
+ </td>
84
+
85
+ <td class="py-3 pr-4 text-muted">
86
+ {{ row.shortName }}
87
+ </td>
88
+
89
+ <td class="py-3 pr-4 text-right whitespace-nowrap">
90
+ <CategoryInfoCategoryPrice
91
+ :product="asProduct"
92
+ class="justify-items-end"
93
+ />
94
+ </td>
95
+
96
+ <td class="py-3 pr-4 whitespace-nowrap">
97
+ <span class="inline-flex items-center gap-1.5">
98
+ <span
99
+ class="size-2 shrink-0 rounded-full"
100
+ :class="isInStock ? 'bg-success' : 'bg-error'"
101
+ aria-hidden="true"
102
+ />
103
+ <span :class="isInStock ? 'text-success' : 'text-error'">
104
+ {{ isInStock ? t('product.stock.available') : t('product.stock.unavailable') }}
105
+ </span>
106
+ </span>
107
+ </td>
108
+
109
+ <td
110
+ v-if="showOrderButton"
111
+ class="py-3 text-right"
112
+ >
113
+ <button
114
+ type="button"
115
+ :disabled="!canOrder"
116
+ class="relative inline-flex items-center gap-1.5 rounded-md py-1.5 pr-2.5 pl-2
117
+ text-sm font-medium ring-1 cursor-pointer text-primary ring-(--ui-border)
118
+ hover:bg-primary/5 disabled:cursor-not-allowed disabled:text-dimmed
119
+ disabled:ring-(--ui-border) disabled:hover:bg-transparent
120
+ focus-visible:outline-2 focus-visible:outline-offset-2
121
+ focus-visible:outline-(--ui-primary)"
122
+ :title="canOrder ? addToCartLabel : t('product.variants.notOrderable')"
123
+ :aria-label="t('product.variants.addToCartAria', { sku: row.sku })"
124
+ @click="addToCart()"
125
+ >
126
+ <span
127
+ class="absolute top-1/2 left-1/2 size-[max(100%,3rem)] -translate-1/2
128
+ pointer-fine:hidden"
129
+ aria-hidden="true"
130
+ />
131
+ <UIcon
132
+ :name="icon('cart')"
133
+ class="size-4 shrink-0"
134
+ />
135
+ <span class="max-sm:sr-only">{{ t('product.actions.order') }}</span>
136
+ </button>
137
+ </td>
138
+ </tr>
139
+ </template>