@revenexx/cover 0.2.22 → 0.2.24

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/app.config.ts CHANGED
@@ -54,6 +54,32 @@ export default defineAppConfig({
54
54
  sku_desc: true,
55
55
  },
56
56
  },
57
+ // The reassurance lines under the buy box and in the cart summary. Both
58
+ // are promises about THIS merchant's terms, and a storefront whose terms
59
+ // differ has to be able to take one down — a shop with three weeks of lead
60
+ // time must not tell buyers it delivers by the next working day.
61
+ //
62
+ // Maps rather than lists, for the reason spelled out at `search.sorts`:
63
+ // app.config merges with defu, which CONCATENATES arrays, so an app
64
+ // overriding a list would append to the layer's instead of replacing it.
65
+ // Booleans merge key by key, and an unset key stays on — an app that
66
+ // configures nothing behaves exactly as before.
67
+ //
68
+ // Display order follows the declaration here, not the override.
69
+ product: {
70
+ incentives: {
71
+ delivery: true,
72
+ paymentTerms: true,
73
+ volume: true,
74
+ },
75
+ },
76
+ cart: {
77
+ trust: {
78
+ delivery: true,
79
+ invoice: true,
80
+ support: true,
81
+ },
82
+ },
57
83
  ui: {
58
84
  icons: nuxtUiIcons(DEFAULT_ICON_WEIGHT),
59
85
  },
@@ -73,11 +73,24 @@ const incentiveProgress = computed(() => {
73
73
  return Math.min(100, Math.round((subtotalAmount.value / openIncentive.value.threshold) * 100));
74
74
  });
75
75
 
76
+ /**
77
+ * The promises that close B2B orders — and promises are merchant-specific. A
78
+ * storefront switches off what its own terms do not cover; a shop with three
79
+ * weeks of lead time must not tell buyers it delivers by the next working day.
80
+ * `id` is the config key, `token` only the icon. Declaration order decides
81
+ * display order, the config only membership, and an unset key stays on.
82
+ */
76
83
  const TRUST_ITEMS = [
77
- { token: "delivery", key: "cart.trust.delivery" },
78
- { token: "payment", key: "cart.trust.invoice" },
79
- { token: "phone", key: "cart.trust.support" },
84
+ { id: "delivery", token: "delivery", key: "cart.trust.delivery" },
85
+ { id: "invoice", token: "payment", key: "cart.trust.invoice" },
86
+ { id: "support", token: "phone", key: "cart.trust.support" },
80
87
  ] as const;
88
+
89
+ const appConfig = useAppConfig();
90
+ const trustItems = computed(() => {
91
+ const configured = appConfig.cart?.trust as Record<string, boolean> | undefined;
92
+ return TRUST_ITEMS.filter(item => configured?.[item.id] !== false);
93
+ });
81
94
  </script>
82
95
 
83
96
  <template>
@@ -176,12 +189,13 @@ const TRUST_ITEMS = [
176
189
 
177
190
  <!-- Trust: the promises that close B2B orders -->
178
191
  <ul
192
+ v-if="trustItems.length"
179
193
  role="list"
180
194
  class="space-y-1.5 pt-1 border-t border-(--ui-border) print:hidden"
181
195
  >
182
196
  <li
183
- v-for="item in TRUST_ITEMS"
184
- :key="item.token"
197
+ v-for="item in trustItems"
198
+ :key="item.id"
185
199
  class="flex items-start gap-2 text-xs text-muted pt-1"
186
200
  >
187
201
  <UIcon
@@ -34,6 +34,19 @@ const quantityExceeded = computed(() =>
34
34
  let exceededTimer: ReturnType<typeof setTimeout> | null = null;
35
35
  const showQuantityExceeded = ref(false);
36
36
 
37
+ /**
38
+ * The reassurance lines under the buy box. A storefront switches off what its
39
+ * terms do not cover — offering "volume pricing" where none exists is a promise
40
+ * the merchant then has to explain away. Declaration order here decides display
41
+ * order; the config only decides membership, and an unset key stays on.
42
+ */
43
+ const INCENTIVES = ["delivery", "paymentTerms", "volume"] as const;
44
+ const appConfig = useAppConfig();
45
+ const incentives = computed<string[]>(() => {
46
+ const configured = appConfig.product?.incentives as Record<string, boolean> | undefined;
47
+ return INCENTIVES.filter(key => configured?.[key] !== false);
48
+ });
49
+
37
50
  function triggerExceededError() {
38
51
  showQuantityExceeded.value = true;
39
52
  if (exceededTimer !== null) {
@@ -171,9 +184,12 @@ onUnmounted(() => {
171
184
  />
172
185
 
173
186
  <!-- B2B incentives -->
174
- <ul class="rounded-xl bg-elevated/60 ring-1 ring-(--ui-border) divide-y divide-(--ui-border)">
187
+ <ul
188
+ v-if="incentives.length"
189
+ class="rounded-xl bg-elevated/60 ring-1 ring-(--ui-border) divide-y divide-(--ui-border)"
190
+ >
175
191
  <li
176
- v-for="incentive in (['delivery', 'paymentTerms', 'volume'] as const)"
192
+ v-for="incentive in incentives"
177
193
  :key="incentive"
178
194
  class="flex items-center gap-2.5 px-3.5 py-2.5 text-sm text-muted"
179
195
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenexx/cover",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "description": "Cover \u2014 revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -372,17 +372,32 @@ async function buildSpecRows(attrs: Record<string, unknown>, locale: Locale): Pr
372
372
  const pick = (labels: Record<string, string> | null | undefined, fallback: string): string =>
373
373
  labels?.[locale] ?? labels?.de ?? labels?.en ?? fallback;
374
374
 
375
+ // One value of an attribute, as a person should read it: an option code
376
+ // resolved to its label, a declared unit appended.
377
+ const render = (m: LiveAttributeMeta | undefined, value: unknown): string => {
378
+ const raw = String(value);
379
+ const label = m?.options?.[raw] ? pick(m.options[raw], raw) : raw;
380
+ return m?.unit && !raw.includes(m.unit) ? `${label} ${m.unit}` : label;
381
+ };
382
+
375
383
  const rows = Object.entries(attrs)
376
384
  .filter(([key, value]) => {
377
385
  if (value === null || value === undefined || value === "") return false;
386
+ // A multiselect with nothing chosen is an empty array, which is not
387
+ // `""` and would otherwise render as a row with no value at all.
388
+ if (Array.isArray(value) && value.length === 0) return false;
378
389
  if (key === "image") return false;
379
390
  return !meta[key]?.hidden;
380
391
  })
381
392
  .map(([key, value]) => {
382
393
  const m = meta[key];
383
- const raw = String(value);
384
- let display = m?.options?.[raw] ? pick(m.options[raw], raw) : raw;
385
- if (m?.unit && !raw.includes(m.unit)) display = `${display} ${m.unit}`;
394
+ // A MULTISELECT HOLDS AN ARRAY, and `String(["a","b"])` is "a,b" —
395
+ // which then matches no option and printed the raw codes, e.g.
396
+ // `ok-10,oks-1,fks-1` where the page should read `OK 10, OKS 1,
397
+ // FKS 1`. Resolve each value on its own and join them for reading.
398
+ const display = Array.isArray(value)
399
+ ? value.map(v => render(m, v)).join(", ")
400
+ : render(m, value);
386
401
  const rank = m?.groupCode && SPEC_GROUP_RANK[m.groupCode] !== undefined ? SPEC_GROUP_RANK[m.groupCode] : 5;
387
402
  return { label: pick(m?.labels, prettifyAttrKey(key)), value: display, sort: rank * 1000 + (m?.position ?? 999) };
388
403
  })