@revenexx/cover 0.2.22 → 0.2.23
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/package.json +1 -1
- package/server/utils/liveCatalog.ts +18 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.23",
|
|
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
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
})
|