@veroxm/react-sdk 1.7.0 → 1.9.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.0
4
+
5
+ - The on-page editor starts a slot that was never published from what the page shows: its empty fields (empty text,
6
+ nothing chosen, an empty list) are filled from the slot's `fallback`, and the panel says so ("Filled from the page's
7
+ current content"). Editing one field and publishing then stores the rest of the page's content too, instead of
8
+ empty fields: a list of tabs or cards no longer disappears after the first edit. Media is taken only when it is an
9
+ item of the media library (it has an `id`). A published slot, a field with content and a test variant are never
10
+ filled.
11
+ - `mergeSlotValues(fields, fallback, values, { neverPublished: true })`: an empty list in the draft of a slot never
12
+ published is treated as not set, so the fallback's list shows. `<VeroxmSlot>` in draft mode
13
+ (`@veroxm/react-sdk/next`) passes it. Once a slot is published, an empty list stays empty.
14
+
15
+ ## 1.8.0
16
+
17
+ - App translations: `const { t, dir, ready } = useTranslations('ar')` reads a locale's whole bundle from VeroXM in one
18
+ request, shared by every component asking for it. `t('checkout.pay', { amount })` fills `{{placeholders}}`, plural
19
+ forms by `count` and `$t(other.key)`; keys not translated yet show the default locale's text. `dir` (`rtl`/`ltr`) and
20
+ `nativeName` ("العربية") come with it. Mount `<VeroxmTranslationsProvider baseUrl projectId apiKey locale>` once (a
21
+ browser key is enough), or pass the same as the hook's options. `initial` takes bundles fetched on the server with
22
+ `fetchTranslations()`, so the first render has the words; `applyToDocument` sets `<html lang dir>`. While another
23
+ locale loads, `t` keeps the previous one's texts. For i18next, use `@veroxm/sdk`'s `VeroxmI18nextBackend`. Needs
24
+ `@veroxm/sdk` 1.13 and a VeroXM server with app translations.
25
+
3
26
  ## 1.7.0
4
27
 
5
28
  - Product journeys: `<VeroxmJourney src="https://buy.example.com/ar/sports-insurance" />` (or `baseUrl` + `journey`)
@@ -9,6 +32,8 @@
9
32
  `onComplete`, `onEvent` (screen ids and steps, never what the person typed). The finish is recorded as
10
33
  `$journey_completed` with the `<VeroxmTrackerProvider>`'s tracker (`track={false}` to skip). The journey must list
11
34
  your site under Embedding; needs the VeroXM version with embeddable journeys (2026-10-27).
35
+ - Draft previews: a page opened from the builder's "Preview in your app" (`?veroxm_journey_preview=<token>`) shows the
36
+ journey's draft with test answers in the same `<VeroxmJourney>`; `preview={false}` always shows the published one.
12
37
 
13
38
  ## 1.6.0
14
39
 
package/README.md CHANGED
@@ -301,6 +301,9 @@ screen ids and steps only, never what the person typed. List your site's origin
301
301
  Look and brand (or in its page layout), or the browser refuses to show it. Works the same in Next.js (a client
302
302
  component). The finish is recorded as `$journey_completed` with the `<VeroxmTrackerProvider>`'s tracker.
303
303
 
304
+ Opened from the builder's **Preview in your app**, the page's address carries `?veroxm_journey_preview=…`, and the
305
+ same component shows the draft (test answers, nothing sent); pass `preview={false}` to always show the published one.
306
+
304
307
  ## Visitor tracking
305
308
 
306
309
  Pair with `@veroxm/sdk`'s `createTracker()` (see that package's README for
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from 'react';
2
- import { field, type SlotFieldDefs, type SlotInfo, type SlotValues } from './slots-core.js';
2
+ import { field, type SlotFallback, type SlotFieldDefs, type SlotInfo, type SlotValues } from './slots-core.js';
3
3
  export { field };
4
4
  export type { SlotFieldDefs, SlotValues, SlotInfo };
5
5
  /** True while this browser is in an "Edit on page" session. */
@@ -10,7 +10,7 @@ export declare function configureClientSlots(options: {
10
10
  }): void;
11
11
  export interface ClientSlotOptions<F extends SlotFieldDefs> {
12
12
  fields: F;
13
- fallback?: Partial<SlotValues<F>>;
13
+ fallback?: SlotFallback<F>;
14
14
  label?: string;
15
15
  locale?: string;
16
16
  }
package/dist/client.d.ts CHANGED
@@ -1,6 +1,16 @@
1
1
  import { type RequestControl } from '@veroxm/sdk';
2
2
  import { VeroxmCache, type CacheOptions } from './cache.js';
3
3
  import type { CollectionMeta, Entry, EntryConnection, EntriesQueryOptions, MediaView } from './types.js';
4
+ /** A live design system's values (GET /public/v2/design-systems/:slug). */
5
+ export interface DesignSystemTokens {
6
+ slug: string;
7
+ name: string;
8
+ version: number | null;
9
+ hash: string;
10
+ modes: Array<'light' | 'dark' | 'rtl'>;
11
+ tokens: Partial<Record<'light' | 'dark' | 'rtl', Record<string, string>>>;
12
+ own: string[];
13
+ }
4
14
  /** GraphQL variables: any object. */
5
15
  type Variables = object;
6
16
  export interface VeroxmClientOptions {
@@ -85,6 +95,16 @@ export declare class VeroxmClient {
85
95
  }): Promise<Entry<T> | null>;
86
96
  /** A page of entries -- see EntriesQueryOptions for the full filter/sort/pagination vocabulary. */
87
97
  listEntries<T = Record<string, unknown>>(collection: string, options?: EntriesQueryOptions): Promise<EntryConnection<T>>;
98
+ /**
99
+ * A live design system's CSS (`:root` variables named `--vx-color-action` and so on, dark ones under
100
+ * `[data-vx-theme="dark"]`, right-to-left ones under `[dir="rtl"]`), for <VeroxmDesignSystem>. `slug`: one of the
101
+ * tenant's design systems, `"default"` (the project's default, or VeroXM's own) or `"veroxm"`. `null`: no such
102
+ * design system is live.
103
+ */
104
+ getDesignSystemCss(slug?: string, control?: RequestControl): Promise<string | null>;
105
+ /** The same design system as values: each mode's tokens by name, and the names it sets itself (`own`). */
106
+ getDesignSystem(slug?: string, control?: RequestControl): Promise<DesignSystemTokens | null>;
107
+ private designSystemFile;
88
108
  /** A single media item by id. `null` means no media with that id exists on this project. */
89
109
  getMedia(id: number): Promise<MediaView | null>;
90
110
  }
package/dist/client.js CHANGED
@@ -133,6 +133,35 @@ export class VeroxmClient {
133
133
  });
134
134
  return data.entries;
135
135
  }
136
+ /**
137
+ * A live design system's CSS (`:root` variables named `--vx-color-action` and so on, dark ones under
138
+ * `[data-vx-theme="dark"]`, right-to-left ones under `[dir="rtl"]`), for <VeroxmDesignSystem>. `slug`: one of the
139
+ * tenant's design systems, `"default"` (the project's default, or VeroXM's own) or `"veroxm"`. `null`: no such
140
+ * design system is live.
141
+ */
142
+ async getDesignSystemCss(slug = 'default', control = {}) {
143
+ return this.designSystemFile(`${slug}.css`, control, (res) => res.text());
144
+ }
145
+ /** The same design system as values: each mode's tokens by name, and the names it sets itself (`own`). */
146
+ async getDesignSystem(slug = 'default', control = {}) {
147
+ return this.designSystemFile(slug, control, (res) => res.json());
148
+ }
149
+ async designSystemFile(file, control, read) {
150
+ if (!/^[a-z0-9][a-z0-9-]{0,62}(\.css)?$/.test(file))
151
+ throw new Error(`"${file}" is not a design system's slug`);
152
+ const token = (this.getAccessToken ? await this.getAccessToken() : null) || this.apiKey;
153
+ const timeout = control.timeoutMs ?? this.timeoutMs;
154
+ const signals = [control.signal, timeout ? AbortSignal.timeout(timeout) : undefined].filter((x) => !!x);
155
+ const res = await (this.fetchImpl ?? fetch)(`${this.apiBase.replace(/\/$/, '')}/public/v2/design-systems/${file}`, {
156
+ headers: { Authorization: `Bearer ${token}`, Accept: file.endsWith('.css') ? 'text/css' : 'application/json' },
157
+ ...(signals.length ? { signal: signals.length === 1 ? signals[0] : AbortSignal.any(signals) } : {}),
158
+ });
159
+ if (res.status === 404)
160
+ return null;
161
+ if (!res.ok)
162
+ throw new Error(`VeroXM answered ${res.status} for the design system ${file}`);
163
+ return read(res);
164
+ }
136
165
  /** A single media item by id. `null` means no media with that id exists on this project. */
137
166
  async getMedia(id) {
138
167
  const data = await this.request(`query Media($id: Int!) { media(id: $id) { ${MEDIA_FIELDS} } }`, { id });
@@ -0,0 +1,4 @@
1
+ /** @experimental A site building block: it can still change in a minor release (see SDK-STABILITY.md). */
2
+ export declare function VeroxmDesignSystem({ css }: {
3
+ css: string | null | undefined;
4
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Design systems: a tenant's brand as CSS variables on the page (--vx-color-action, --vx-radius-control...). Fetch the
3
+ // CSS with client.getDesignSystemCss() (on the server, in a root layout) and render it once:
4
+ //
5
+ // const css = await client.getDesignSystemCss('default');
6
+ // <VeroxmDesignSystem css={css} />
7
+ //
8
+ // VeroXM's site blocks (<VeroxmSiteStyles />) take their colours and corners from it; your own CSS can read the same
9
+ // variables. Dark values apply inside [data-vx-theme="dark"], right-to-left ones inside [dir="rtl"].
10
+ /** @experimental A site building block: it can still change in a minor release (see SDK-STABILITY.md). */
11
+ export function VeroxmDesignSystem({ css }) {
12
+ if (!css)
13
+ return null;
14
+ // As text in a <style> element: a "<" can't end the element early.
15
+ return _jsx("style", { id: "veroxm-design-system", dangerouslySetInnerHTML: { __html: css.replace(/</g, '\\3c ') } });
16
+ }
@@ -13,11 +13,13 @@ export declare const menuOps: {
13
13
  /** Becomes the next item after its parent, one level up. */
14
14
  outdent: (items: SlotMenuItem[], path: Path) => SlotMenuItem[];
15
15
  };
16
- export declare function MenuInput({ name, label, required, depth, value, onChange, onFocus, }: {
16
+ export declare function MenuInput({ name, label, required, depth, icons, value, onChange, onFocus, }: {
17
17
  name: string;
18
18
  label: string;
19
19
  required?: boolean;
20
20
  depth: number;
21
+ /** The icons an item may have (the menu field's), by name. */
22
+ icons?: string[];
21
23
  value: unknown;
22
24
  onChange(v: SlotMenuItem[] | null): void;
23
25
  onFocus(): void;
@@ -4,6 +4,8 @@ import { useId } from 'react';
4
4
  // compact enough for the side panel. Each item has a label, a link and
5
5
  // "new tab"; items move up and down, in under the item above, and out a
6
6
  // level. An item with sub-items may have no link: it just opens them.
7
+ // Each item may also have a badge ("New"), a description and, when the
8
+ // developer declared icons for the menu, an icon.
7
9
  export const MAX_MENU_ITEMS = 100;
8
10
  export function countItems(items) {
9
11
  return items.reduce((n, i) => n + 1 + countItems(i.children ?? []), 0);
@@ -73,7 +75,7 @@ export const menuOps = {
73
75
  return withList(removed, grand, (l) => [...l.slice(0, p + 1), item, ...l.slice(p + 1)]);
74
76
  },
75
77
  };
76
- export function MenuInput({ name, label, required, depth, value, onChange, onFocus, }) {
78
+ export function MenuInput({ name, label, required, depth, icons, value, onChange, onFocus, }) {
77
79
  const id = useId();
78
80
  const items = Array.isArray(value) ? value : [];
79
81
  const total = countItems(items);
@@ -83,7 +85,7 @@ export function MenuInput({ name, label, required, depth, value, onChange, onFoc
83
85
  const level = path.length;
84
86
  const title = item.label.trim() || `item ${i + 1}`;
85
87
  const canIndent = i > 0 && level + depthOf(item) <= depth;
86
- return (_jsxs("li", { className: "vx-menu-item", children: [_jsxs("div", { className: "vx-menu-row", children: [_jsx("input", { type: "text", "data-field": level === 1 && i === 0 ? name : undefined, onFocus: onFocus, value: item.label, maxLength: 80, placeholder: "Label", "aria-label": `Label of ${title}`, onChange: (e) => set(menuOps.update(items, path, { label: e.target.value })) }), _jsx("input", { type: "text", inputMode: "url", onFocus: onFocus, value: item.href, placeholder: item.children?.length ? 'Link (optional)' : '/page or https://…', "aria-label": `Link of ${title}`, onChange: (e) => set(menuOps.update(items, path, { href: e.target.value })) })] }), _jsxs("div", { className: "vx-menu-tools", children: [_jsxs("label", { className: "vx-menu-tab", children: [_jsx("input", { type: "checkbox", checked: !!item.newTab, onChange: (e) => set(menuOps.update(items, path, { newTab: e.target.checked || undefined })) }), "New tab"] }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === 0, "aria-label": `Move ${title} up`, onClick: () => set(menuOps.move(items, path, -1)), children: "\u2191" }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === list.length - 1, "aria-label": `Move ${title} down`, onClick: () => set(menuOps.move(items, path, 1)), children: "\u2193" }), depth > 1 ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "vx-mini", disabled: level === 1, "aria-label": `Move ${title} out a level`, onClick: () => set(menuOps.outdent(items, path)), children: "\u2190" }), _jsx("button", { type: "button", className: "vx-mini", disabled: !canIndent, "aria-label": `Move ${title} under the item above`, onClick: () => set(menuOps.indent(items, path)), children: "\u2192" })] })) : null, level < depth ? (_jsx("button", { type: "button", className: "vx-mini", disabled: total >= MAX_MENU_ITEMS, "aria-label": `Add a sub-item under ${title}`, onClick: () => set(menuOps.add(items, path)), children: "+ Sub" })) : null, _jsx("button", { type: "button", className: "vx-mini", "aria-label": `Remove ${title}${item.children?.length ? ' and its sub-items' : ''}`, onClick: () => set(menuOps.remove(items, path)), children: "Remove" })] }), item.children?.length ? _jsx("ul", { className: "vx-menu-list vx-menu-sub", children: rows(item.children, path) }) : null] }, path.join('-')));
88
+ return (_jsxs("li", { className: "vx-menu-item", children: [_jsxs("div", { className: "vx-menu-row", children: [_jsx("input", { type: "text", "data-field": level === 1 && i === 0 ? name : undefined, onFocus: onFocus, value: item.label, maxLength: 80, placeholder: "Label", "aria-label": `Label of ${title}`, onChange: (e) => set(menuOps.update(items, path, { label: e.target.value })) }), _jsx("input", { type: "text", inputMode: "url", onFocus: onFocus, value: item.href, placeholder: item.children?.length ? 'Link (optional)' : '/page or https://…', "aria-label": `Link of ${title}`, onChange: (e) => set(menuOps.update(items, path, { href: e.target.value })) })] }), _jsxs("div", { className: "vx-menu-row", children: [icons?.length ? (_jsxs("select", { "aria-label": `Icon of ${title}`, onFocus: onFocus, value: item.icon ?? '', onChange: (e) => set(menuOps.update(items, path, { icon: e.target.value || undefined })), children: [_jsx("option", { value: "", children: "No icon" }), icons.map((icon) => (_jsx("option", { value: icon, children: icon }, icon)))] })) : null, _jsx("input", { type: "text", onFocus: onFocus, value: item.badge ?? '', maxLength: 24, placeholder: "Badge (optional)", "aria-label": `Badge of ${title}`, onChange: (e) => set(menuOps.update(items, path, { badge: e.target.value || undefined })) }), _jsx("input", { type: "text", onFocus: onFocus, value: item.description ?? '', maxLength: 160, placeholder: "Description (optional)", "aria-label": `Description of ${title}`, onChange: (e) => set(menuOps.update(items, path, { description: e.target.value || undefined })) })] }), _jsxs("div", { className: "vx-menu-tools", children: [_jsxs("label", { className: "vx-menu-tab", children: [_jsx("input", { type: "checkbox", checked: !!item.newTab, onChange: (e) => set(menuOps.update(items, path, { newTab: e.target.checked || undefined })) }), "New tab"] }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === 0, "aria-label": `Move ${title} up`, onClick: () => set(menuOps.move(items, path, -1)), children: "\u2191" }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === list.length - 1, "aria-label": `Move ${title} down`, onClick: () => set(menuOps.move(items, path, 1)), children: "\u2193" }), depth > 1 ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "vx-mini", disabled: level === 1, "aria-label": `Move ${title} out a level`, onClick: () => set(menuOps.outdent(items, path)), children: "\u2190" }), _jsx("button", { type: "button", className: "vx-mini", disabled: !canIndent, "aria-label": `Move ${title} under the item above`, onClick: () => set(menuOps.indent(items, path)), children: "\u2192" })] })) : null, level < depth ? (_jsx("button", { type: "button", className: "vx-mini", disabled: total >= MAX_MENU_ITEMS, "aria-label": `Add a sub-item under ${title}`, onClick: () => set(menuOps.add(items, path)), children: "+ Sub" })) : null, _jsx("button", { type: "button", className: "vx-mini", "aria-label": `Remove ${title}${item.children?.length ? ' and its sub-items' : ''}`, onClick: () => set(menuOps.remove(items, path)), children: "Remove" })] }), item.children?.length ? _jsx("ul", { className: "vx-menu-list vx-menu-sub", children: rows(item.children, path) }) : null] }, path.join('-')));
87
89
  });
88
90
  return (_jsxs("fieldset", { className: "vx-field vx-fieldset", "aria-describedby": `${id}-count`, children: [_jsxs("legend", { className: "vx-label", children: [label, required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsxs("span", { id: `${id}-count`, className: "vx-count", children: [total, " / ", MAX_MENU_ITEMS, " items \u00B7 ", depth === 1 ? 'one level' : `up to ${depth} levels`] }), items.length ? _jsx("ul", { className: "vx-menu-list", children: rows(items, []) }) : _jsx("p", { className: "vx-muted", children: "No items yet: the site shows its own menu." }), _jsx("div", { className: "vx-actions", children: _jsx("button", { type: "button", className: "vx-btn", "data-field": items.length ? undefined : name, onFocus: onFocus, disabled: total >= MAX_MENU_ITEMS, onClick: () => set(menuOps.add(items, [])), children: "Add item" }) })] }));
89
91
  }
@@ -9,6 +9,7 @@ import { parseVideoUrl } from '../site/video.js';
9
9
  import { parseMapLink } from '../site/map-math.js';
10
10
  import { CHART_KINDS, chartTableText, parseChartTable } from '../site/chart.js';
11
11
  import { canEditInline, startInlineEdit } from './inline.js';
12
+ import { readFallback, seedFromFallback } from './seed.js';
12
13
  function asComponentValue(v) {
13
14
  return v && typeof v === 'object' && !Array.isArray(v) && typeof v.component === 'string' ? v : null;
14
15
  }
@@ -77,6 +78,14 @@ function toPayload(fields, values) {
77
78
  const schema = c ? def.components?.[c.component] : undefined;
78
79
  out[name] = c && schema ? { component: c.component, version: schema.version, values: toPayload(schema.fields, c.values ?? {}) } : null;
79
80
  }
81
+ else if (def.type === 'list' && Array.isArray(v)) {
82
+ // Each item stored like a slot's values (media as { id }), with its dates.
83
+ out[name] = v.map((item) => ({
84
+ ...toPayload(def.fields ?? {}, item ?? {}),
85
+ ...(item?._from ? { _from: item._from } : {}),
86
+ ...(item?._until ? { _until: item._until } : {}),
87
+ }));
88
+ }
80
89
  else
81
90
  out[name] = v;
82
91
  }
@@ -370,6 +379,8 @@ function SlotPanel({ slot, canPublish, canManageTests, dashboardUrl, onClose, on
370
379
  const inlineRef = useRef(null);
371
380
  const valuesRef = useRef({});
372
381
  const latest = useRef(null);
382
+ // Seeding from the page's fallback happens once per opening, for a slot never published.
383
+ const seededOnce = useRef(false);
373
384
  const apply = useCallback((next) => {
374
385
  if (!next)
375
386
  return;
@@ -397,6 +408,18 @@ function SlotPanel({ slot, canPublish, canManageTests, dashboardUrl, onClose, on
397
408
  if (position === 0)
398
409
  baseValues.current = s.values;
399
410
  apply(s);
411
+ // Never published: start from what the page shows now (its fallback), so the first save stores the real
412
+ // content instead of empty fields. Not for a test variant (it stores only differences), and never over a
413
+ // field with stored content.
414
+ if (position === 0 && !s.version && !seededOnce.current) {
415
+ seededOnce.current = true;
416
+ const { values: seededValues, seeded } = seedFromFallback(s.fields, s.values, readFallback(slotElement(slot.name, slot.locale)));
417
+ if (seeded.length) {
418
+ setValues(seededValues);
419
+ latest.current = seededValues;
420
+ setNotice('Filled from the page’s current content. Change what you need, then publish.');
421
+ }
422
+ }
400
423
  }
401
424
  }
402
425
  catch (err) {
@@ -628,7 +651,7 @@ function SlotPanel({ slot, canPublish, canManageTests, dashboardUrl, onClose, on
628
651
  : save.kind === 'error'
629
652
  ? ''
630
653
  : latest.current !== null
631
- ? 'Editing… saves in a moment'
654
+ ? (notice ?? 'Editing… saves in a moment')
632
655
  : notice ?? (data?.unpublishedChanges ? 'Unpublished changes' : data ? 'No unpublished changes' : '') }), save.kind === 'error' ? (_jsx("ul", { className: "vx-errors", role: "alert", children: save.problems.map((p) => (_jsx("li", { children: p }, p))) })) : null, variant > 0 && data?.test ? (_jsxs("div", { className: "vx-actions", children: [dashboardUrl ? (_jsx("a", { className: "vx-btn", href: `${dashboardUrl}${data.test.dashboardPath}`, target: "_blank", rel: "noopener noreferrer", children: "Test settings and results" })) : null, _jsx("button", { type: "button", className: "vx-btn", onClick: () => void selectVariant(0), children: "Back to published" })] })) : null, variant === 0 && approval?.pending ? (_jsxs("div", { className: "vx-review", role: "group", "aria-label": "Approval", children: [_jsxs("p", { className: "vx-review-title", children: ["Waiting for approval", approval.steps.length > 1 && approval.currentStep !== null
633
656
  ? ` · step ${approval.steps.findIndex((st) => st.stepOrder === approval.currentStep) + 1} of ${approval.steps.length}`
634
657
  : ''] }), _jsxs("p", { className: "vx-muted", children: [approval.steps.find((st) => st.stepOrder === approval.currentStep)?.label, approval.submittedByName ? ` · sent by ${approval.submittedByName}` : ''] }), approval.changedSinceSubmission ? (_jsx("p", { className: "vx-muted", children: "Edits made since it was sent aren't part of the request." })) : null, approval.canAct ? (_jsxs(_Fragment, { children: [_jsx("label", { className: "vx-sublabel", htmlFor: `${titleId}-review`, children: "Comment (needed to reject)" }), _jsx("textarea", { id: `${titleId}-review`, className: "vx-review-comment", rows: 2, value: reviewComment, onChange: (e) => setReviewComment(e.target.value) }), _jsxs("div", { className: "vx-actions", children: [_jsx("button", { type: "button", className: "vx-btn vx-primary", disabled: busy !== null, onClick: () => act('approve', { comment: reviewComment }), children: busy === 'approve' ? 'Approving…' : approval.steps[approval.steps.length - 1]?.stepOrder === approval.currentStep ? 'Approve and publish' : 'Approve' }), _jsx("button", { type: "button", className: "vx-btn", disabled: busy !== null || !reviewComment.trim(), onClick: () => act('reject', { comment: reviewComment }), children: busy === 'reject' ? 'Rejecting…' : 'Reject' })] })] })) : approval.isSubmitter ? (_jsx("p", { className: "vx-muted", children: "Someone else on that step's role approves it." })) : null, approval.canWithdraw ? (_jsx("button", { type: "button", className: "vx-btn vx-review-withdraw", disabled: busy !== null, onClick: () => act('withdraw'), children: busy === 'withdraw' ? 'Withdrawing…' : 'Withdraw request' })) : null] })) : null, _jsxs("div", { className: "vx-actions", hidden: variant > 0, children: [canPublish ? (_jsx("button", { type: "button", className: "vx-btn vx-primary", disabled: !data || !dirty || busy !== null || approval?.pending, onClick: () => act('publish'), children: busy === 'publish' ? (approval?.required ? 'Sending…' : 'Publishing…') : approval?.required ? 'Send for approval' : 'Publish' })) : (_jsx("span", { className: "vx-muted", children: "Someone with publish permission can make this live." })), data?.unpublishedChanges && data.version > 0 ? (_jsx("button", { type: "button", className: "vx-btn", disabled: busy !== null, onClick: discard, children: busy === 'discard' ? 'Discarding…' : confirmDiscard ? 'Discard all changes?' : 'Discard changes' })) : null] })] })] }));
@@ -676,7 +699,9 @@ function FieldInput({ name, def, value, shown, onChange, onFocus, }) {
676
699
  case 'slides':
677
700
  return _jsx(SlidesInput, { name: name, def: def, value: value, onChange: onChange, onFocus: onFocus });
678
701
  case 'menu':
679
- return _jsx(MenuInput, { name: name, label: def.label ?? name, required: def.required, depth: def.depth ?? 2, value: value, onChange: onChange, onFocus: onFocus });
702
+ return _jsx(MenuInput, { name: name, label: def.label ?? name, required: def.required, depth: def.depth ?? 2, icons: def.icons, value: value, onChange: onChange, onFocus: onFocus });
703
+ case 'list':
704
+ return _jsx(ListInput, { name: name, def: def, value: value, onChange: onChange, onFocus: onFocus });
680
705
  case 'component':
681
706
  return _jsx(ComponentInput, { name: name, def: def, value: value, onChange: onChange, onFocus: onFocus });
682
707
  }
@@ -800,6 +825,50 @@ function SlidesInput({ name, def, value, onChange, onFocus }) {
800
825
  return (_jsxs("div", { className: "vx-slide-card", children: [_jsx(MediaInput, { name: i === 0 ? name : `${name}-${i}`, def: { type: 'media', label: `Slide ${i + 1} image`, required: true }, value: slide.image, onChange: (v) => update(i, { image: v }), onFocus: onFocus }), _jsx("label", { htmlFor: `${id}-${i}-title`, className: "vx-sublabel", children: "Title" }), _jsx("input", { id: `${id}-${i}-title`, onFocus: onFocus, type: "text", maxLength: 120, value: slide.title ?? '', onChange: (e) => update(i, { title: e.target.value }) }), _jsx("label", { htmlFor: `${id}-${i}-text`, className: "vx-sublabel", children: "Text" }), _jsx("textarea", { id: `${id}-${i}-text`, onFocus: onFocus, rows: 2, maxLength: 300, value: slide.text ?? '', onChange: (e) => update(i, { text: e.target.value }) }), _jsxs("div", { className: "vx-menu-row", children: [_jsx("input", { "aria-label": `Button text of ${title}`, placeholder: "Button text", onFocus: onFocus, type: "text", value: slide.link?.label ?? '', onChange: (e) => update(i, { link: { label: e.target.value, href: slide.link?.href ?? '' } }) }), _jsx("input", { "aria-label": `Button link of ${title}`, placeholder: "/page or https://\u2026", inputMode: "url", onFocus: onFocus, type: "text", value: slide.link?.href ?? '', onChange: (e) => update(i, { link: { label: slide.link?.label ?? '', href: e.target.value } }) })] }), _jsxs("div", { className: "vx-menu-tools", children: [_jsx("button", { type: "button", className: "vx-mini", disabled: i === 0, "aria-label": `Move ${title} earlier`, onClick: () => move(i, -1), children: "\u2191" }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === slides.length - 1, "aria-label": `Move ${title} later`, onClick: () => move(i, 1), children: "\u2193" }), _jsx("button", { type: "button", className: "vx-mini", "aria-label": `Remove ${title}`, onClick: () => set(slides.filter((_, j) => j !== i)), children: "Remove" })] })] }, i));
801
826
  }), _jsx("div", { className: "vx-actions", children: _jsx("button", { type: "button", className: "vx-btn", "data-field": slides.length ? undefined : name, onFocus: onFocus, disabled: slides.length >= max, onClick: () => set([...slides, { image: null }]), children: "Add slide" }) })] }));
802
827
  }
828
+ /** A short name for a list item: its first text field's value, or "Item 3". */
829
+ function itemTitle(fields, item, i) {
830
+ for (const [f, d] of Object.entries(fields)) {
831
+ const v = item[f];
832
+ if (d.type === 'text' && typeof v === 'string' && v.trim())
833
+ return v.trim().slice(0, 40);
834
+ if (d.type === 'link' && v && typeof v === 'object' && typeof v.label === 'string' && v.label.trim())
835
+ return v.label.trim().slice(0, 40);
836
+ }
837
+ return `Item ${i + 1}`;
838
+ }
839
+ /**
840
+ * A list field: items to add, remove and reorder, each with the list's own fields (the same inputs as a slot's), and
841
+ * with schedule, the first and last day it shows on. Items open one at a time, so a long list stays short on screen.
842
+ */
843
+ function ListInput({ name, def, value, onChange, onFocus }) {
844
+ const id = useId();
845
+ const items = Array.isArray(value) ? value : [];
846
+ const fields = def.fields ?? {};
847
+ const max = def.max ?? 20;
848
+ const [openItem, setOpenItem] = useState(null);
849
+ const set = (next) => onChange(next);
850
+ const update = (i, patch) => set(items.map((it, j) => (j === i ? { ...it, ...patch } : it)));
851
+ const move = (i, by) => {
852
+ const to = i + by;
853
+ if (to < 0 || to >= items.length)
854
+ return;
855
+ const next = [...items];
856
+ [next[i], next[to]] = [next[to], next[i]];
857
+ set(next);
858
+ setOpenItem((o) => (o === i ? to : o === to ? i : o));
859
+ };
860
+ return (_jsxs("fieldset", { className: "vx-field vx-fieldset", children: [_jsxs("legend", { className: "vx-label", children: [def.label ?? name, def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsxs("span", { className: "vx-count", children: [items.length, " / ", max, " items"] }), items.map((item, i) => {
861
+ const title = itemTitle(fields, item, i);
862
+ const isOpen = openItem === i;
863
+ return (_jsxs("div", { className: "vx-slide-card", children: [_jsxs("div", { className: "vx-menu-tools", children: [_jsxs("button", { type: "button", className: "vx-mini vx-item-toggle", "aria-expanded": isOpen, "aria-controls": `${id}-${i}`, onClick: () => setOpenItem(isOpen ? null : i), children: [isOpen ? '▾' : '▸', " ", title] }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === 0, "aria-label": `Move ${title} earlier`, onClick: () => move(i, -1), children: "\u2191" }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === items.length - 1, "aria-label": `Move ${title} later`, onClick: () => move(i, 1), children: "\u2193" }), _jsx("button", { type: "button", className: "vx-mini", "aria-label": `Remove ${title}`, onClick: () => {
864
+ set(items.filter((_, j) => j !== i));
865
+ setOpenItem(null);
866
+ }, children: "Remove" })] }), isOpen ? (_jsxs("div", { id: `${id}-${i}`, children: [Object.entries(fields).map(([f, d]) => (_jsx(FieldInput, { name: `${name}-${i}-${f}`, def: d, value: item[f] ?? null, onChange: (v) => update(i, { [f]: v }), onFocus: onFocus }, f))), def.schedule ? (_jsxs("div", { className: "vx-menu-row", children: [_jsxs("label", { className: "vx-sublabel", children: ["Shows from", _jsx("input", { type: "date", onFocus: onFocus, value: typeof item._from === 'string' ? item._from : '', onChange: (e) => update(i, { _from: e.target.value || undefined }) })] }), _jsxs("label", { className: "vx-sublabel", children: ["Until", _jsx("input", { type: "date", onFocus: onFocus, value: typeof item._until === 'string' ? item._until : '', onChange: (e) => update(i, { _until: e.target.value || undefined }) })] })] })) : null] })) : null] }, i));
867
+ }), _jsx("div", { className: "vx-actions", children: _jsx("button", { type: "button", className: "vx-btn", "data-field": items.length ? undefined : name, onFocus: onFocus, disabled: items.length >= max, onClick: () => {
868
+ set([...items, {}]);
869
+ setOpenItem(items.length);
870
+ }, children: "Add item" }) })] }));
871
+ }
803
872
  function MediaInput({ name, def, value, onChange, onFocus }) {
804
873
  const [picking, setPicking] = useState(false);
805
874
  const [search, setSearch] = useState('');
@@ -0,0 +1,20 @@
1
+ /** The parts of a field definition seeding reads. */
2
+ export interface SeedFieldDef {
3
+ type: string;
4
+ fields?: Record<string, SeedFieldDef>;
5
+ components?: Record<string, {
6
+ fields: Record<string, SeedFieldDef>;
7
+ }>;
8
+ }
9
+ /** Nothing stored: undefined, null, '' or an empty list. */
10
+ export declare function isEmptyValue(v: unknown): boolean;
11
+ /**
12
+ * The form's values with every empty field filled from the fallback (when it has something storable), and which fields
13
+ * were filled. A field with stored content keeps it.
14
+ */
15
+ export declare function seedFromFallback(fields: Record<string, SeedFieldDef>, values: Record<string, unknown>, fallback: Record<string, unknown> | null | undefined): {
16
+ values: Record<string, unknown>;
17
+ seeded: string[];
18
+ };
19
+ /** The slot's fallback as the page rendered it (data-veroxm-fallback), or null. Never the shown values: those may be a test variant's. */
20
+ export declare function readFallback(el: Element | null): Record<string, unknown> | null;
@@ -0,0 +1,71 @@
1
+ // Starting the on-page editor from the page's fallback (the site's own copy in code), so the first save stores real
2
+ // content instead of empty fields. Pure, so the panel and its tests share it.
3
+ //
4
+ // Only for a slot that was never published: its stored values are empty, and the page shows the fallback. Every
5
+ // empty field (undefined, null, '' or an empty list) takes the fallback's value. Media is only taken when it is an item
6
+ // of the media library (it has an id), because a slot stores media as { id }; inside lists, components and slides,
7
+ // media without an id is left empty for the same reason.
8
+ /** Nothing stored: undefined, null, '' or an empty list. */
9
+ export function isEmptyValue(v) {
10
+ return v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0);
11
+ }
12
+ const isObject = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
13
+ const libraryMedia = (v) => isObject(v) && typeof v.id === 'number' && Number.isFinite(v.id);
14
+ /** A fallback value as the slot can store it: media only from the library, inside lists and components too. */
15
+ function storable(def, v) {
16
+ switch (def.type) {
17
+ case 'media':
18
+ return libraryMedia(v) ? v : null;
19
+ case 'slides':
20
+ return Array.isArray(v) ? v.map((s) => (isObject(s) ? { ...s, image: libraryMedia(s.image) ? s.image : null } : s)) : v;
21
+ case 'list':
22
+ return Array.isArray(v) ? v.filter(isObject).map((item) => storableValues(def.fields ?? {}, item)) : v;
23
+ case 'component': {
24
+ if (!isObject(v) || typeof v.component !== 'string')
25
+ return null;
26
+ const schema = def.components?.[v.component];
27
+ if (!schema)
28
+ return null;
29
+ return { ...v, values: storableValues(schema.fields, isObject(v.values) ? v.values : {}) };
30
+ }
31
+ default:
32
+ return v;
33
+ }
34
+ }
35
+ function storableValues(fields, values) {
36
+ const out = { ...values };
37
+ for (const [name, def] of Object.entries(fields))
38
+ if (name in values)
39
+ out[name] = storable(def, values[name]);
40
+ return out;
41
+ }
42
+ /**
43
+ * The form's values with every empty field filled from the fallback (when it has something storable), and which fields
44
+ * were filled. A field with stored content keeps it.
45
+ */
46
+ export function seedFromFallback(fields, values, fallback) {
47
+ const out = { ...values };
48
+ const seeded = [];
49
+ if (!fallback)
50
+ return { values: out, seeded };
51
+ for (const [name, def] of Object.entries(fields)) {
52
+ if (!isEmptyValue(values[name]) || isEmptyValue(fallback[name]))
53
+ continue;
54
+ const v = storable(def, fallback[name]);
55
+ if (isEmptyValue(v))
56
+ continue;
57
+ out[name] = v;
58
+ seeded.push(name);
59
+ }
60
+ return { values: out, seeded };
61
+ }
62
+ /** The slot's fallback as the page rendered it (data-veroxm-fallback), or null. Never the shown values: those may be a test variant's. */
63
+ export function readFallback(el) {
64
+ try {
65
+ const v = JSON.parse(el?.getAttribute('data-veroxm-fallback') ?? 'null');
66
+ return isObject(v) ? v : null;
67
+ }
68
+ catch {
69
+ return null;
70
+ }
71
+ }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { VeroxmProvider, useVeroxmClient } from './provider.js';
2
2
  export type { VeroxmProviderProps } from './provider.js';
3
3
  export { VeroxmClient } from './client.js';
4
- export type { VeroxmClientOptions } from './client.js';
4
+ export type { VeroxmClientOptions, DesignSystemTokens } from './client.js';
5
5
  export { VeroxmAuthProvider, useAuth, SignedIn } from './auth.js';
6
6
  export type { VeroxmAuthProviderProps, VeroxmAuthLike, VeroxmAuthUser, AuthState } from './auth.js';
7
7
  export { VeroxmCache } from './cache.js';
@@ -26,6 +26,7 @@ export type { NavMenuProps } from './site/nav-menu.js';
26
26
  export { SiteHeader, SiteFooter, headerFields, footerFields } from './site/site-parts.js';
27
27
  export type { SiteHeaderProps, SiteFooterProps } from './site/site-parts.js';
28
28
  export { VeroxmSiteStyles, SITE_STYLES } from './site/styles.js';
29
+ export { VeroxmDesignSystem } from './design-system.js';
29
30
  export { VideoEmbed } from './site/video-embed.js';
30
31
  export type { VideoEmbedProps } from './site/video-embed.js';
31
32
  export { Slider } from './site/slider.js';
@@ -44,6 +45,8 @@ export { VeroxmForm, useVeroxmForm } from './form.js';
44
45
  export type { VeroxmFormProps, VeroxmFormOptions, VeroxmFormMode, VeroxmFormHandle } from './form.js';
45
46
  export { VeroxmJourney } from './journey.js';
46
47
  export type { VeroxmJourneyProps, VeroxmJourneyEvent } from './journey.js';
48
+ export { VeroxmTranslationsProvider, useTranslations } from './translations.js';
49
+ export type { VeroxmTranslationsProviderProps, TranslationsSource, TranslationsState, UseTranslationsOptions } from './translations.js';
47
50
  export { VeroxmTrackerProvider, useTracker, usePageViews, useExperience, Experience, useContentView, useRecommendations, useSlotImpression, VeroxmSlotImpression, } from './tracking.js';
48
51
  export type { VeroxmTrackerProviderProps, VeroxmTrackerLike, ExperienceDecision, ExperienceState, ExperienceProps, RecommendationsState, VeroxmSlotImpressionProps, } from './tracking.js';
49
52
  export { VeroxmSlot, useSlot, field, configureSlots, loadSlot, mergeSlotValues } from './slots.js';
@@ -52,6 +55,6 @@ export { VeroxmRegion, renderComponent, regionSlotProps } from './components.js'
52
55
  export { VeroxmComponentBoundary } from './component-boundary.js';
53
56
  export type { RegisteredComponent, ComponentSchema, SlotComponentValue } from './slots.js';
54
57
  export type { VeroxmRegionProps, RegionFallback, RenderComponentOptions } from './components.js';
55
- export type { VeroxmSlotProps, SlotFieldDef, SlotFieldDefs, SlotValues, SlotInfo, SlotTest, SlotMedia, SlotLink, SlotMenuItem, SlotVideo, SlotSlide, SlotMap, SlotPlace, SlotChart, SlotState, SlotsConfig, LoadSlotOptions, SlotPerson, } from './slots.js';
58
+ export type { VeroxmSlotProps, SlotFieldDef, SlotFieldDefs, SlotValues, SlotInfo, SlotTest, SlotMedia, SlotLink, SlotMenuItem, SlotFallback, ListItemFieldDef, NestedListItemFieldDef, SlotVideo, SlotSlide, SlotMap, SlotPlace, SlotChart, SlotState, SlotsConfig, LoadSlotOptions, SlotPerson, } from './slots.js';
56
59
  export { loadStructuredData, jsonLdScript } from './structured-data.js';
57
60
  export type { StructuredDataOptions } from './structured-data.js';
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ export { VeroxmImage, focalPosition } from './image.js';
19
19
  export { NavMenu, isSafeMenuHref } from './site/nav-menu.js';
20
20
  export { SiteHeader, SiteFooter, headerFields, footerFields } from './site/site-parts.js';
21
21
  export { VeroxmSiteStyles, SITE_STYLES } from './site/styles.js';
22
+ export { VeroxmDesignSystem } from './design-system.js';
22
23
  export { VideoEmbed } from './site/video-embed.js';
23
24
  export { Slider } from './site/slider.js';
24
25
  export { MapEmbed } from './site/map-embed.js';
@@ -30,6 +31,8 @@ export { parseVideoUrl, videoEmbedUrl, videoThumbnailUrl } from './site/video.js
30
31
  export { VeroxmForm, useVeroxmForm } from './form.js';
31
32
  // Product journeys: a quote-and-buy journey in your page, in a frame of its hosted page.
32
33
  export { VeroxmJourney } from './journey.js';
34
+ // App translations: a locale's bundle in one request, t() and its writing direction. (i18next: @veroxm/sdk's VeroxmI18nextBackend.)
35
+ export { VeroxmTranslationsProvider, useTranslations } from './translations.js';
33
36
  // Experience OS visitor tracking -- pair with @veroxm/sdk's createTracker().
34
37
  export { VeroxmTrackerProvider, useTracker, usePageViews, useExperience, Experience, useContentView, useRecommendations, useSlotImpression, VeroxmSlotImpression, } from './tracking.js';
35
38
  // Visual slots (Experience Layer): named regions marketers edit from VeroXM.
package/dist/journey.d.ts CHANGED
@@ -51,6 +51,12 @@ export interface VeroxmJourneyProps {
51
51
  }>) => void;
52
52
  /** Every event, as it comes. */
53
53
  onEvent?: (e: VeroxmJourneyEvent) => void;
54
+ /**
55
+ * Show the journey's draft when the page is opened from the builder's "Preview in your app" (the page's address has
56
+ * `?veroxm_journey_preview=<token>`): test answers, nothing is sent, and parts can be picked to edit in the builder.
57
+ * Default true; false always shows the published journey.
58
+ */
59
+ preview?: boolean;
54
60
  /**
55
61
  * Record the finish as `$journey_completed` (usable as an experience's goal) with the `<VeroxmTrackerProvider>`'s
56
62
  * tracker. Default true; false records nothing.
@@ -61,7 +67,7 @@ export interface VeroxmJourneyProps {
61
67
  * The frame's address: the journey's, with ?embed=1, the language, chrome=0 and the page's own origin (where the
62
68
  * journey sends its events). Null when neither src nor baseUrl + journey make an http(s) address. @internal
63
69
  */
64
- export declare function journeyFrameUrl(p: Pick<VeroxmJourneyProps, 'src' | 'baseUrl' | 'journey' | 'lang' | 'chrome'>, parent: string | null): URL | null;
70
+ export declare function journeyFrameUrl(p: Pick<VeroxmJourneyProps, 'src' | 'baseUrl' | 'journey' | 'lang' | 'chrome'>, parent: string | null, previewToken?: string | null): URL | null;
65
71
  /** A message from the journey's frame, checked: from its origin and window, in the journey's own format. @internal */
66
72
  export declare function journeyEventOf(data: unknown): VeroxmJourneyEvent | null;
67
73
  /**
@@ -73,4 +79,4 @@ export declare function journeyEventOf(data: unknown): VeroxmJourneyEvent | null
73
79
  * onComplete={() => router.push('/thank-you')} />
74
80
  * ```
75
81
  */
76
- export declare function VeroxmJourney({ src, baseUrl, journey, lang, chrome, height, title, className, style, track, ...handlers }: VeroxmJourneyProps): import("react").JSX.Element;
82
+ export declare function VeroxmJourney({ src, baseUrl, journey, lang, chrome, height, title, className, style, track, preview, ...handlers }: VeroxmJourneyProps): import("react").JSX.Element;
package/dist/journey.js CHANGED
@@ -7,7 +7,7 @@ const LANG_PATH = /^\/([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\/([a-z0-9](?:[a-z0-9-]{0,6
7
7
  * The frame's address: the journey's, with ?embed=1, the language, chrome=0 and the page's own origin (where the
8
8
  * journey sends its events). Null when neither src nor baseUrl + journey make an http(s) address. @internal
9
9
  */
10
- export function journeyFrameUrl(p, parent) {
10
+ export function journeyFrameUrl(p, parent, previewToken) {
11
11
  let url;
12
12
  try {
13
13
  if (p.src)
@@ -22,7 +22,17 @@ export function journeyFrameUrl(p, parent) {
22
22
  }
23
23
  if (url.protocol !== 'https:' && url.protocol !== 'http:')
24
24
  return null;
25
- if (p.lang) {
25
+ if (previewToken) {
26
+ // The draft, on the same VeroXM address: /j/preview?token=…
27
+ const preview = new URL('/j/preview', url.origin);
28
+ preview.searchParams.set('token', previewToken);
29
+ const at = LANG_PATH.exec(url.pathname);
30
+ const lang = p.lang ?? (at ? at[1] : url.searchParams.get('lang'));
31
+ if (lang)
32
+ preview.searchParams.set('lang', lang);
33
+ url = preview;
34
+ }
35
+ else if (p.lang) {
26
36
  // A readable address carries the language in its path (/ar/sports-insurance); a link takes ?lang=.
27
37
  const at = LANG_PATH.exec(url.pathname);
28
38
  if (at)
@@ -66,12 +76,17 @@ export function journeyEventOf(data) {
66
76
  * onComplete={() => router.push('/thank-you')} />
67
77
  * ```
68
78
  */
69
- export function VeroxmJourney({ src, baseUrl, journey, lang, chrome, height = 760, title = 'Insurance quote', className, style, track = true, ...handlers }) {
79
+ export function VeroxmJourney({ src, baseUrl, journey, lang, chrome, height = 760, title = 'Insurance quote', className, style, track = true, preview = true, ...handlers }) {
70
80
  const frame = useRef(null);
71
81
  // The page's own origin is known only in the browser: the frame is made there.
72
82
  const [parent, setParent] = useState(null);
73
- useEffect(() => setParent(window.location.origin), []);
74
- const url = useMemo(() => (parent ? journeyFrameUrl({ src, baseUrl, journey, lang, chrome }, parent) : null), [src, baseUrl, journey, lang, chrome, parent]);
83
+ const [previewToken, setPreviewToken] = useState(null);
84
+ useEffect(() => {
85
+ setParent(window.location.origin);
86
+ const t = new URLSearchParams(window.location.search).get('veroxm_journey_preview');
87
+ setPreviewToken(t && t.length <= 4096 ? t : null);
88
+ }, []);
89
+ const url = useMemo(() => (parent ? journeyFrameUrl({ src, baseUrl, journey, lang, chrome }, parent, preview ? previewToken : null) : null), [src, baseUrl, journey, lang, chrome, parent, preview, previewToken]);
75
90
  // Handlers change on every render; the listener calls the latest ones.
76
91
  const latest = useRef({ handlers, track });
77
92
  latest.current = { handlers, track };
@@ -97,7 +112,8 @@ export function VeroxmJourney({ src, baseUrl, journey, lang, chrome, height = 76
97
112
  else if (e.event === 'locale')
98
113
  h.onLocaleChange?.(e);
99
114
  else if (e.event === 'complete') {
100
- if (latest.current.track)
115
+ // A preview's finish isn't a real one.
116
+ if (latest.current.track && !m.data.preview)
101
117
  trackerRef.current.track('$journey_completed', { journey: e.journey });
102
118
  h.onComplete?.(e);
103
119
  }
@@ -10,7 +10,7 @@ export type { RegisteredComponent, ComponentSchema, SlotComponentValue } from '.
10
10
  export type { VeroxmRegionProps, RegionFallback, RenderComponentOptions } from '../components.js';
11
11
  export { VeroxmEditor } from './editor.js';
12
12
  export { field, configureSlots, loadSlot, mergeSlotValues } from '../slots-core.js';
13
- export type { VeroxmSlotProps, SlotFieldDef, SlotFieldDefs, SlotValues, SlotInfo, SlotTest, SlotMedia, SlotLink, SlotMenuItem, SlotVideo, SlotSlide, SlotMap, SlotPlace, SlotChart, SlotsConfig, LoadSlotOptions, SlotPerson } from '../slots-core.js';
13
+ export type { VeroxmSlotProps, SlotFieldDef, SlotFieldDefs, SlotValues, SlotInfo, SlotTest, SlotMedia, SlotLink, SlotMenuItem, SlotFallback, ListItemFieldDef, NestedListItemFieldDef, SlotVideo, SlotSlide, SlotMap, SlotPlace, SlotChart, SlotsConfig, LoadSlotOptions, SlotPerson } from '../slots-core.js';
14
14
  export { NavMenu } from '../site/nav-menu.js';
15
15
  export { SiteHeader, SiteFooter, headerFields, footerFields } from '../site/site-parts.js';
16
16
  export { VeroxmSiteStyles } from '../site/styles.js';
package/dist/next/slot.js CHANGED
@@ -45,7 +45,8 @@ export async function slotWith(props, load, cached) {
45
45
  editing: true,
46
46
  edit: (fieldName) => ({ 'data-veroxm-field': fieldName }),
47
47
  };
48
- const values = mergeSlotValues(fields, fallback, draft?.values ?? null);
48
+ // A draft of a slot never published: an empty list there means "not set yet" (the page keeps its own list).
49
+ const values = mergeSlotValues(fields, fallback, draft?.values ?? null, { neverPublished: !draft?.version });
49
50
  return (_jsxs(_Fragment, { children: [_jsx("div", { "data-veroxm-slot": name, "data-veroxm-label": label ?? '', "data-veroxm-locale": locale ?? '', "data-veroxm-shown": JSON.stringify(values), "data-veroxm-fallback": JSON.stringify(site), style: { display: 'contents' }, children: children(values, slot) }), _jsx(VeroxmEditor, {})] }));
50
51
  }
51
52
  const cacheComponents = Boolean(process.env.__NEXT_CACHE_COMPONENTS);
@@ -1,4 +1,4 @@
1
- import { type ElementType } from 'react';
1
+ import { type ElementType, type ReactNode } from 'react';
2
2
  import type { SlotMenuItem } from '../slots-core.js';
3
3
  /** @experimental A site building block: it can still change in a minor release (see SDK-STABILITY.md). */
4
4
  export interface NavMenuProps {
@@ -14,6 +14,8 @@ export interface NavMenuProps {
14
14
  className?: string;
15
15
  /** Spread on the nav, e.g. slot.edit('menu') for VeroXM's on-page editor. */
16
16
  editProps?: Record<string, string>;
17
+ /** Draws an item's icon (a name from the menu field's `icons`). Without it, icons aren't shown. */
18
+ renderIcon?: (name: string) => ReactNode;
17
19
  }
18
20
  /**
19
21
  * Links VeroXM accepts in a menu; anything else renders as plain text.
@@ -22,4 +24,4 @@ export interface NavMenuProps {
22
24
  */
23
25
  export declare function isSafeMenuHref(href: string): boolean;
24
26
  /** @experimental A site building block: it can still change in a minor release (see SDK-STABILITY.md). */
25
- export declare function NavMenu({ items, label, currentPath, linkComponent, toggleLabel, className, editProps }: NavMenuProps): import("react").JSX.Element | null;
27
+ export declare function NavMenu({ items, label, currentPath, linkComponent, toggleLabel, className, editProps, renderIcon }: NavMenuProps): import("react").JSX.Element | null;
@@ -1,6 +1,10 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useId, useRef, useState } from 'react';
4
+ /** An item's icon, label, badge and description, as the menu shows them. */
5
+ function ItemText({ item, renderIcon }) {
6
+ return (_jsxs(_Fragment, { children: [item.icon && renderIcon ? (_jsx("span", { className: "vxs-nav-icon", "aria-hidden": "true", children: renderIcon(item.icon) })) : null, _jsx("span", { className: "vxs-nav-label", children: item.label }), item.badge ? _jsx("span", { className: "vxs-nav-badge", children: item.badge }) : null, item.description ? _jsx("span", { className: "vxs-nav-description", children: item.description }) : null] }));
7
+ }
4
8
  /**
5
9
  * Links VeroXM accepts in a menu; anything else renders as plain text.
6
10
  *
@@ -15,13 +19,13 @@ const samePage = (href, current) => {
15
19
  const clean = (p) => withoutTrailingSlashes(p.split(/[?#]/)[0]) || '/';
16
20
  return clean(href) === clean(current);
17
21
  };
18
- function MenuLink({ item, currentPath, Link, onNavigate }) {
22
+ function MenuLink({ item, currentPath, Link, onNavigate, renderIcon, }) {
19
23
  if (!item.href || !isSafeMenuHref(item.href))
20
- return _jsx("span", { className: "vxs-nav-text", children: item.label });
21
- return (_jsxs(Link, { className: "vxs-nav-link", href: item.href, onClick: onNavigate, ...(samePage(item.href, currentPath) ? { 'aria-current': 'page' } : {}), ...(item.newTab ? { target: '_blank', rel: 'noopener noreferrer' } : {}), children: [item.label, item.newTab ? _jsx("span", { className: "vxs-sr", children: " (opens in a new tab)" }) : null] }));
24
+ return (_jsx("span", { className: "vxs-nav-text", children: _jsx(ItemText, { item: item, renderIcon: renderIcon }) }));
25
+ return (_jsxs(Link, { className: "vxs-nav-link", href: item.href, onClick: onNavigate, ...(samePage(item.href, currentPath) ? { 'aria-current': 'page' } : {}), ...(item.newTab ? { target: '_blank', rel: 'noopener noreferrer' } : {}), children: [_jsx(ItemText, { item: item, renderIcon: renderIcon }), item.newTab ? _jsx("span", { className: "vxs-sr", children: " (opens in a new tab)" }) : null] }));
22
26
  }
23
27
  /** @experimental A site building block: it can still change in a minor release (see SDK-STABILITY.md). */
24
- export function NavMenu({ items, label = 'Main', currentPath, linkComponent = 'a', toggleLabel = 'Menu', className, editProps }) {
28
+ export function NavMenu({ items, label = 'Main', currentPath, linkComponent = 'a', toggleLabel = 'Menu', className, editProps, renderIcon }) {
25
29
  const id = useId();
26
30
  const navRef = useRef(null);
27
31
  // Open sub-menus, by path ("0", "0-2"); opening one closes its siblings.
@@ -73,7 +77,7 @@ export function NavMenu({ items, label = 'Main', currentPath, linkComponent = 'a
73
77
  const key = parent ? `${parent}-${i}` : `${i}`;
74
78
  const kids = item.children?.length ? item.children : null;
75
79
  const isOpen = open.includes(key);
76
- return (_jsxs("li", { className: `vxs-nav-item${kids ? ' vxs-nav-parent' : ''}`, children: [kids && !item.href ? (_jsxs("button", { type: "button", className: "vxs-nav-button", "aria-expanded": isOpen, "aria-controls": `${id}-sub-${key}`, "data-vxs-toggle": key, onClick: () => toggle(key), children: [item.label, _jsx("span", { className: "vxs-caret", "aria-hidden": "true" })] })) : (_jsxs("span", { className: "vxs-nav-row", children: [_jsx(MenuLink, { item: item, currentPath: currentPath, Link: linkComponent, onNavigate: closeAll }), kids ? (_jsx("button", { type: "button", className: "vxs-nav-button vxs-nav-more", "aria-expanded": isOpen, "aria-controls": `${id}-sub-${key}`, "aria-label": `${item.label}: more links`, "data-vxs-toggle": key, onClick: () => toggle(key), children: _jsx("span", { className: "vxs-caret", "aria-hidden": "true" }) })) : null] })), kids ? list(kids, key, level + 1) : null] }, key));
80
+ return (_jsxs("li", { className: `vxs-nav-item${kids ? ' vxs-nav-parent' : ''}`, children: [kids && !item.href ? (_jsxs("button", { type: "button", className: "vxs-nav-button", "aria-expanded": isOpen, "aria-controls": `${id}-sub-${key}`, "data-vxs-toggle": key, onClick: () => toggle(key), children: [_jsx(ItemText, { item: item, renderIcon: renderIcon }), _jsx("span", { className: "vxs-caret", "aria-hidden": "true" })] })) : (_jsxs("span", { className: "vxs-nav-row", children: [_jsx(MenuLink, { item: item, currentPath: currentPath, Link: linkComponent, onNavigate: closeAll, renderIcon: renderIcon }), kids ? (_jsx("button", { type: "button", className: "vxs-nav-button vxs-nav-more", "aria-expanded": isOpen, "aria-controls": `${id}-sub-${key}`, "aria-label": `${item.label}: more links`, "data-vxs-toggle": key, onClick: () => toggle(key), children: _jsx("span", { className: "vxs-caret", "aria-hidden": "true" }) })) : null] })), kids ? list(kids, key, level + 1) : null] }, key));
77
81
  }) }));
78
82
  if (!items.length)
79
83
  return null;
@@ -21,6 +21,7 @@ export declare const headerFields: {
21
21
  label?: string;
22
22
  required?: boolean;
23
23
  depth?: 1 | 2 | 3;
24
+ icons?: readonly string[] | undefined;
24
25
  type: "menu";
25
26
  };
26
27
  cta: {
@@ -35,6 +36,7 @@ export declare const footerFields: {
35
36
  label?: string;
36
37
  required?: boolean;
37
38
  depth?: 1 | 2 | 3;
39
+ icons?: readonly string[] | undefined;
38
40
  type: "menu";
39
41
  };
40
42
  text: {
@@ -47,6 +49,7 @@ export declare const footerFields: {
47
49
  label?: string;
48
50
  required?: boolean;
49
51
  depth?: 1 | 2 | 3;
52
+ icons?: readonly string[] | undefined;
50
53
  type: "menu";
51
54
  };
52
55
  legal: {
@@ -1,5 +1,5 @@
1
1
  /** @experimental A site building block: it can still change in a minor release (see SDK-STABILITY.md). */
2
- export declare const SITE_STYLES = "\n:root{--vxs-bg:#fff;--vxs-fg:#18181b;--vxs-muted:#52525b;--vxs-line:#e4e4e7;--vxs-accent:#4f46e5;--vxs-accent-fg:#fff;--vxs-menu-bg:#fff;--vxs-radius:10px;--vxs-width:1200px;--vxs-footer-bg:#fafafa}\n.vxs-sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.vxs-header{background:var(--vxs-bg);color:var(--vxs-fg);border-bottom:1px solid var(--vxs-line);position:relative;z-index:40}\n.vxs-sticky{position:sticky;top:0}\n.vxs-header-inner{max-width:var(--vxs-width);margin:0 auto;padding:12px 20px;display:flex;align-items:center;gap:24px}\n.vxs-brand{display:flex;align-items:center;color:inherit;text-decoration:none;font-weight:700;font-size:1.15rem;flex-shrink:0}\n.vxs-logo{display:block;max-height:40px;width:auto;height:auto}\n.vxs-nav{flex:1;display:flex;align-items:center}\n.vxs-nav ul{list-style:none;margin:0;padding:0}\n.vxs-nav-list{display:flex;flex-wrap:wrap;gap:4px}\n.vxs-nav-item{position:relative}\n.vxs-nav-row{display:flex;align-items:center}\n.vxs-nav-link,.vxs-nav-text,.vxs-nav-button{display:flex;align-items:center;gap:6px;padding:8px 12px;border-radius:8px;color:inherit;text-decoration:none;font:inherit;background:none;border:0;cursor:pointer;line-height:1.3}\n.vxs-nav-text{cursor:default}\n.vxs-nav-more{padding:8px 6px;margin-left:-8px}\n.vxs-nav-link:hover,.vxs-nav-button:hover{background:color-mix(in srgb,var(--vxs-fg) 6%,transparent)}\n.vxs-nav-link[aria-current=page]{color:var(--vxs-accent);font-weight:600}\n.vxs-nav :focus-visible,.vxs-footer :focus-visible,.vxs-brand:focus-visible,.vxs-cta:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:2px}\n.vxs-caret{width:7px;height:7px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:translateY(-2px) rotate(45deg);transition:transform .15s}\n[aria-expanded=true]>.vxs-caret{transform:translateY(1px) rotate(-135deg)}\n.vxs-nav-sub{min-width:220px;background:var(--vxs-menu-bg);border:1px solid var(--vxs-line);border-radius:var(--vxs-radius);box-shadow:0 12px 32px rgba(0,0,0,.12);padding:6px}\n.vxs-nav-sub-2{position:absolute;top:calc(100% + 4px);left:0}\n.vxs-nav-sub .vxs-nav-link,.vxs-nav-sub .vxs-nav-button,.vxs-nav-sub .vxs-nav-text{width:100%;justify-content:space-between}\n.vxs-nav-sub .vxs-nav-row .vxs-nav-link{width:auto;flex:1}\n.vxs-nav-sub .vxs-nav-more{width:auto;flex:none}\n.vxs-nav-link,.vxs-nav-button,.vxs-nav-text{white-space:nowrap}\n.vxs-nav-sub-3{border:0;box-shadow:none;padding:0 0 0 12px;min-width:0;border-left:2px solid var(--vxs-line);border-radius:0;margin:2px 0 4px 12px}\n.vxs-nav-sub[hidden]{display:none}\n.vxs-nav-toggle{display:none;align-items:center;gap:8px;margin-left:auto;padding:8px 12px;border:1px solid var(--vxs-line);border-radius:8px;background:none;color:inherit;font:inherit;cursor:pointer}\n.vxs-burger,.vxs-burger::before,.vxs-burger::after{display:block;width:16px;height:2px;background:currentColor;border-radius:2px;position:relative}\n.vxs-burger::before,.vxs-burger::after{content:\"\";position:absolute;left:0}\n.vxs-burger::before{top:-5px}.vxs-burger::after{top:5px}\n.vxs-cta{display:inline-flex;align-items:center;padding:9px 16px;border-radius:999px;background:var(--vxs-accent);color:var(--vxs-accent-fg);text-decoration:none;font-weight:600;white-space:nowrap}\n@media (max-width:767px){\n.vxs-header-inner{flex-wrap:wrap;gap:12px}\n.vxs-nav{display:contents}\n.vxs-cta{order:1;margin-left:auto}\n.vxs-nav-toggle{display:inline-flex;order:2;margin-left:auto}\n.vxs-header-inner:has(.vxs-cta) .vxs-nav-toggle{margin-left:0}\n.vxs-nav-list{order:3;flex-basis:100%;display:none;flex-direction:column;padding:4px 0 8px}\n.vxs-nav-list[data-open=true]{display:flex}\n.vxs-nav-sub,.vxs-nav-sub-2{position:static;box-shadow:none;border:0;border-left:2px solid var(--vxs-line);border-radius:0;margin:0 0 4px 12px;padding:0 0 0 8px;min-width:0}\n}\n@media (max-width:479px){\n.vxs-header-inner{gap:8px}\n.vxs-nav-toggle{padding:10px}\n.vxs-nav-toggle-text{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.vxs-cta{padding:7px 12px;font-size:.875rem}\n}\n@media (prefers-reduced-motion:reduce){.vxs-caret{transition:none}}\n.vxs-video{position:relative;aspect-ratio:16/9;background:#000;border-radius:var(--vxs-radius);overflow:hidden}\n.vxs-video-frame{position:absolute;inset:0;width:100%;height:100%;border:0;display:block}\n.vxs-video-cover{all:unset;position:absolute;inset:0;cursor:pointer;display:block}\n.vxs-video-cover img{width:100%;height:100%;object-fit:cover;display:block}\n.vxs-video-play{position:absolute;left:50%;top:50%;width:68px;height:48px;margin:-24px 0 0 -34px;border-radius:14px;background:rgba(0,0,0,.72);transition:background .15s}\n.vxs-video-play::after{content:\"\";position:absolute;left:28px;top:14px;border-style:solid;border-width:10px 0 10px 17px;border-color:transparent transparent transparent #fff}\n.vxs-video-cover:hover .vxs-video-play,.vxs-video-cover:focus-visible .vxs-video-play{background:var(--vxs-accent)}\n.vxs-video-cover:focus-visible{outline:3px solid var(--vxs-accent);outline-offset:-3px}\n.vxs-video-title{position:absolute;left:0;right:0;bottom:0;padding:24px 16px 12px;color:#fff;font-weight:600;background:linear-gradient(transparent,rgba(0,0,0,.7))}\n.vxs-slider{position:relative;--vxs-slide-ratio:16/7}\n.vxs-slider-viewport{overflow:hidden;border-radius:var(--vxs-radius);touch-action:pan-y}\n.vxs-slider-track{display:flex;transition:transform .45s ease}\n.vxs-slide{flex:0 0 100%;position:relative;aspect-ratio:var(--vxs-slide-ratio);background:var(--vxs-line);overflow:hidden}\n.vxs-slide picture{display:contents}\n.vxs-slide-img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}\n.vxs-slide-caption{position:absolute;inset:auto 0 0 0;padding:48px clamp(16px,4vw,48px) clamp(16px,3vw,36px);color:#fff;background:linear-gradient(transparent,rgba(0,0,0,.65));display:flex;flex-direction:column;align-items:flex-start;gap:8px}\n.vxs-slide-title{margin:0;font-size:clamp(1.25rem,3vw,2.25rem);font-weight:700;line-height:1.15;max-width:24ch}\n.vxs-slide-text{margin:0;max-width:52ch;opacity:.92}\n.vxs-slide-link{display:inline-flex;margin-top:4px;padding:9px 16px;border-radius:999px;background:var(--vxs-accent);color:var(--vxs-accent-fg);text-decoration:none;font-weight:600}\n.vxs-slide-link:focus-visible{outline:2px solid #fff;outline-offset:2px}\n.vxs-slider-controls{display:flex;align-items:center;justify-content:center;gap:12px;margin-top:12px}\n.vxs-slider-btn{appearance:none;display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:50%;border:1px solid var(--vxs-line);background:var(--vxs-bg);color:var(--vxs-fg);cursor:pointer}\n.vxs-slider-btn:focus-visible,.vxs-slider-dot:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:2px}\n.vxs-chevron{width:8px;height:8px;border-right:2px solid currentColor;border-bottom:2px solid currentColor}\n.vxs-slider-prev .vxs-chevron{transform:translateX(2px) rotate(135deg)}\n.vxs-slider-next .vxs-chevron{transform:translateX(-2px) rotate(-45deg)}\n[dir=rtl] .vxs-slider-prev .vxs-chevron{transform:translateX(-2px) rotate(-45deg)}\n[dir=rtl] .vxs-slider-next .vxs-chevron{transform:translateX(2px) rotate(135deg)}\n.vxs-icon-pause{width:10px;height:12px;border-left:3px solid currentColor;border-right:3px solid currentColor}\n.vxs-icon-play{width:0;height:0;margin-left:3px;border-style:solid;border-width:6px 0 6px 10px;border-color:transparent transparent transparent currentColor}\n.vxs-slider-dots{display:flex;gap:2px}\n.vxs-slider-dot{appearance:none;width:24px;height:24px;border:0;background:none;cursor:pointer;position:relative;padding:0}\n.vxs-slider-dot::after{content:\"\";position:absolute;left:8px;top:8px;width:8px;height:8px;border-radius:50%;background:var(--vxs-muted);opacity:.4}\n.vxs-slider-dot[aria-current=true]::after{opacity:1;background:var(--vxs-accent);transform:scale(1.25)}\n.vxs-map{margin:0}\n.vxs-map-view{position:relative;overflow:hidden;border-radius:var(--vxs-radius);background:#e5e3df;touch-action:none;cursor:grab;user-select:none}\n.vxs-map-view:active{cursor:grabbing}\n.vxs-map-view:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:2px}\n.vxs-map-tiles img{position:absolute;width:256px;height:256px;max-width:none;pointer-events:none}\n.vxs-map-pin{appearance:none;position:absolute;width:28px;height:28px;margin:-28px 0 0 -14px;padding:0;border:0;background:none;cursor:pointer}\n.vxs-map-pin::before{content:\"\";position:absolute;inset:0;border-radius:50% 50% 50% 0;transform:rotate(-45deg);background:var(--vxs-pin,#e11d48);border:2px solid #fff;box-shadow:0 2px 6px rgba(0,0,0,.35)}\n.vxs-map-pin::after{content:\"\";position:absolute;left:10px;top:8px;width:8px;height:8px;border-radius:50%;background:#fff}\n.vxs-map-pin[aria-expanded=true]::before{background:var(--vxs-accent)}\n.vxs-map-pin:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:4px;border-radius:50%}\n.vxs-map-card{position:absolute;z-index:1;transform:translate(-50%,calc(-100% - 36px));min-width:180px;max-width:260px;background:var(--vxs-bg);color:var(--vxs-fg);border-radius:10px;box-shadow:0 8px 24px rgba(0,0,0,.2);padding:10px 12px;display:flex;flex-direction:column;gap:2px;font-size:.875rem;cursor:auto}\n.vxs-place-name{font-weight:650}\n.vxs-place-address{color:var(--vxs-muted)}\n.vxs-place-links{display:flex;gap:12px;margin-top:4px}\n.vxs-place-links a{color:var(--vxs-accent)}\n.vxs-map-zoom{position:absolute;z-index:2;top:10px;right:10px;display:flex;flex-direction:column;border-radius:8px;overflow:hidden;box-shadow:0 2px 8px rgba(0,0,0,.2)}\n.vxs-map-zoom button{appearance:none;width:34px;height:34px;border:0;border-bottom:1px solid var(--vxs-line);background:var(--vxs-bg);color:var(--vxs-fg);font-size:18px;line-height:1;cursor:pointer}\n.vxs-map-zoom button:last-child{border-bottom:0}\n.vxs-map-zoom button:disabled{opacity:.4;cursor:not-allowed}\n.vxs-map-zoom button:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:-2px}\n.vxs-map-credit{position:absolute;right:0;bottom:0;padding:2px 6px;font-size:11px;background:rgba(255,255,255,.8);color:#333;text-decoration:none}\n.vxs-map-defer{appearance:none;width:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;border:1px dashed var(--vxs-line);border-radius:var(--vxs-radius);background:var(--vxs-footer-bg);color:var(--vxs-fg);font:inherit;font-weight:600;cursor:pointer}\n.vxs-map-defer-note{font-weight:400;font-size:.8rem;color:var(--vxs-muted)}\n.vxs-map-list{list-style:none;margin:12px 0 0;padding:0;display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px}\n.vxs-map-item{display:flex;flex-direction:column;gap:2px;font-size:.9rem;padding:10px 12px;border:1px solid var(--vxs-line);border-radius:10px}\n[dir=rtl] .vxs-map-zoom{right:auto;left:10px}\n.vxs-chart{margin:0;--vxc-surface:var(--vxs-bg)}\n.vxs-chart-title{margin:0 0 8px;font-weight:650;font-size:1.05rem}\n.vxs-chart-box{position:relative}\n.vxs-chart-box svg{display:block;width:100%;height:100%;overflow:visible}\n.vxs-chart-cross{position:absolute;top:8px;bottom:26px;width:1px;background:var(--vxc-axis,#c3c2b7);pointer-events:none}\n.vxs-chart-tip{position:absolute;z-index:2;min-width:120px;max-width:200px;padding:8px 10px;border-radius:8px;background:var(--vxs-bg);color:var(--vxs-fg);box-shadow:0 6px 20px rgba(0,0,0,.18);font-size:.8rem;display:flex;flex-direction:column;gap:2px;pointer-events:none}\n.vxs-chart-tip-label{color:var(--vxs-muted)}\n.vxs-chart-tip-row{display:flex;align-items:center;gap:6px}\n.vxs-chart-tip-row i{width:8px;height:8px;border-radius:2px;flex:none}\n.vxs-chart-caption{margin:8px 0 0;color:var(--vxs-muted);font-size:.875rem}\n.vxs-chart-data{margin-top:8px;font-size:.875rem}\n.vxs-chart-data summary{cursor:pointer;color:var(--vxs-accent)}\n.vxs-chart-table{overflow-x:auto;margin-top:6px}\n.vxs-chart-table table{border-collapse:collapse;min-width:100%}\n.vxs-chart-table th,.vxs-chart-table td{padding:4px 10px;border-bottom:1px solid var(--vxs-line);text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}\n.vxs-chart-table th:first-child{text-align:left;font-weight:500}\n@media (prefers-color-scheme:dark){:root:where(:not([data-theme=light])) .vxs-chart{--vxc-1:#3987e5;--vxc-2:#d95926;--vxc-3:#199e70;--vxc-4:#c98500;--vxc-5:#d55181;--vxc-6:#008300;--vxc-ink:#ffffff;--vxc-ink2:#c3c2b7;--vxc-muted:#898781;--vxc-grid:#2c2c2a;--vxc-axis:#383835;--vxc-good:#0ca30c;--vxc-bad:#e66767}}\n:root[data-theme=dark] .vxs-chart{--vxc-1:#3987e5;--vxc-2:#d95926;--vxc-3:#199e70;--vxc-4:#c98500;--vxc-5:#d55181;--vxc-6:#008300;--vxc-ink:#ffffff;--vxc-ink2:#c3c2b7;--vxc-muted:#898781;--vxc-grid:#2c2c2a;--vxc-axis:#383835;--vxc-good:#0ca30c;--vxc-bad:#e66767}\n@media (max-width:767px){.vxs-slider{--vxs-slide-ratio:4/3}}\n@media (prefers-reduced-motion:reduce){.vxs-slider-track{transition:none}}\n.vxs-footer{background:var(--vxs-footer-bg);color:var(--vxs-fg);border-top:1px solid var(--vxs-line);margin-top:48px}\n.vxs-footer-inner{max-width:var(--vxs-width);margin:0 auto;padding:40px 20px 24px;display:grid;grid-template-columns:minmax(200px,1.2fr) 3fr;gap:32px}\n.vxs-footer-inner>:only-child{grid-column:1/-1}\n.vxs-footer-text{color:var(--vxs-muted);max-width:36ch}\n.vxs-footer-text p{margin:0 0 8px}\n.vxs-footer-columns{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:24px}\n.vxs-footer-heading{display:block;margin:0 0 10px;font-weight:650;color:inherit;text-decoration:none}\n.vxs-footer-column ul,.vxs-social{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}\n.vxs-footer-link{color:var(--vxs-muted);text-decoration:none}\n.vxs-footer-link:hover{color:var(--vxs-fg);text-decoration:underline}\n.vxs-footer-bottom{max-width:var(--vxs-width);margin:0 auto;padding:16px 20px 28px;border-top:1px solid var(--vxs-line);display:flex;flex-wrap:wrap;gap:16px;align-items:center;justify-content:space-between}\n.vxs-legal{margin:0;color:var(--vxs-muted);font-size:.875rem}\n.vxs-social{flex-direction:row;flex-wrap:wrap;gap:16px}\n@media (max-width:767px){.vxs-footer-inner{grid-template-columns:1fr}}\n";
2
+ export declare const SITE_STYLES = "\n:root{--vxs-bg:var(--vx-color-surface,#fff);--vxs-fg:var(--vx-color-text,#18181b);--vxs-muted:var(--vx-color-text-muted,#52525b);--vxs-line:var(--vx-color-border,#e4e4e7);--vxs-accent:var(--vx-color-action,#4f46e5);--vxs-accent-fg:var(--vx-color-on-action,#fff);--vxs-menu-bg:var(--vx-color-surface,#fff);--vxs-radius:var(--vx-radius-card,10px);--vxs-width:1200px;--vxs-footer-bg:var(--vx-color-subtle,#fafafa)}\n.vxs-sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.vxs-header{background:var(--vxs-bg);color:var(--vxs-fg);border-bottom:1px solid var(--vxs-line);position:relative;z-index:40}\n.vxs-sticky{position:sticky;top:0}\n.vxs-header-inner{max-width:var(--vxs-width);margin:0 auto;padding:12px 20px;display:flex;align-items:center;gap:24px}\n.vxs-brand{display:flex;align-items:center;color:inherit;text-decoration:none;font-weight:700;font-size:1.15rem;flex-shrink:0}\n.vxs-logo{display:block;max-height:40px;width:auto;height:auto}\n.vxs-nav{flex:1;display:flex;align-items:center}\n.vxs-nav ul{list-style:none;margin:0;padding:0}\n.vxs-nav-list{display:flex;flex-wrap:wrap;gap:4px}\n.vxs-nav-item{position:relative}\n.vxs-nav-row{display:flex;align-items:center}\n.vxs-nav-link,.vxs-nav-text,.vxs-nav-button{display:flex;align-items:center;gap:6px;padding:8px 12px;border-radius:8px;color:inherit;text-decoration:none;font:inherit;background:none;border:0;cursor:pointer;line-height:1.3}\n.vxs-nav-text{cursor:default}\n.vxs-nav-icon{display:inline-flex;width:1.2em;height:1.2em}\n.vxs-nav-icon svg{width:100%;height:100%}\n.vxs-nav-badge{font-size:.72em;font-weight:600;padding:1px 8px;border-radius:999px;background:var(--vxs-accent);color:var(--vxs-accent-fg)}\n.vxs-nav-description{display:block;flex-basis:100%;font-size:.85em;opacity:.7}\n.vxs-nav-more{padding:8px 6px;margin-left:-8px}\n.vxs-nav-link:hover,.vxs-nav-button:hover{background:color-mix(in srgb,var(--vxs-fg) 6%,transparent)}\n.vxs-nav-link[aria-current=page]{color:var(--vxs-accent);font-weight:600}\n.vxs-nav :focus-visible,.vxs-footer :focus-visible,.vxs-brand:focus-visible,.vxs-cta:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:2px}\n.vxs-caret{width:7px;height:7px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:translateY(-2px) rotate(45deg);transition:transform .15s}\n[aria-expanded=true]>.vxs-caret{transform:translateY(1px) rotate(-135deg)}\n.vxs-nav-sub{min-width:220px;background:var(--vxs-menu-bg);border:1px solid var(--vxs-line);border-radius:var(--vxs-radius);box-shadow:0 12px 32px rgba(0,0,0,.12);padding:6px}\n.vxs-nav-sub-2{position:absolute;top:calc(100% + 4px);left:0}\n.vxs-nav-sub .vxs-nav-link,.vxs-nav-sub .vxs-nav-button,.vxs-nav-sub .vxs-nav-text{width:100%;justify-content:space-between}\n.vxs-nav-sub .vxs-nav-row .vxs-nav-link{width:auto;flex:1}\n.vxs-nav-sub .vxs-nav-more{width:auto;flex:none}\n.vxs-nav-link,.vxs-nav-button,.vxs-nav-text{white-space:nowrap}\n.vxs-nav-sub-3{border:0;box-shadow:none;padding:0 0 0 12px;min-width:0;border-left:2px solid var(--vxs-line);border-radius:0;margin:2px 0 4px 12px}\n.vxs-nav-sub[hidden]{display:none}\n.vxs-nav-toggle{display:none;align-items:center;gap:8px;margin-left:auto;padding:8px 12px;border:1px solid var(--vxs-line);border-radius:8px;background:none;color:inherit;font:inherit;cursor:pointer}\n.vxs-burger,.vxs-burger::before,.vxs-burger::after{display:block;width:16px;height:2px;background:currentColor;border-radius:2px;position:relative}\n.vxs-burger::before,.vxs-burger::after{content:\"\";position:absolute;left:0}\n.vxs-burger::before{top:-5px}.vxs-burger::after{top:5px}\n.vxs-cta{display:inline-flex;align-items:center;padding:9px 16px;border-radius:999px;background:var(--vxs-accent);color:var(--vxs-accent-fg);text-decoration:none;font-weight:600;white-space:nowrap}\n@media (max-width:767px){\n.vxs-header-inner{flex-wrap:wrap;gap:12px}\n.vxs-nav{display:contents}\n.vxs-cta{order:1;margin-left:auto}\n.vxs-nav-toggle{display:inline-flex;order:2;margin-left:auto}\n.vxs-header-inner:has(.vxs-cta) .vxs-nav-toggle{margin-left:0}\n.vxs-nav-list{order:3;flex-basis:100%;display:none;flex-direction:column;padding:4px 0 8px}\n.vxs-nav-list[data-open=true]{display:flex}\n.vxs-nav-sub,.vxs-nav-sub-2{position:static;box-shadow:none;border:0;border-left:2px solid var(--vxs-line);border-radius:0;margin:0 0 4px 12px;padding:0 0 0 8px;min-width:0}\n}\n@media (max-width:479px){\n.vxs-header-inner{gap:8px}\n.vxs-nav-toggle{padding:10px}\n.vxs-nav-toggle-text{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.vxs-cta{padding:7px 12px;font-size:.875rem}\n}\n@media (prefers-reduced-motion:reduce){.vxs-caret{transition:none}}\n.vxs-video{position:relative;aspect-ratio:16/9;background:#000;border-radius:var(--vxs-radius);overflow:hidden}\n.vxs-video-frame{position:absolute;inset:0;width:100%;height:100%;border:0;display:block}\n.vxs-video-cover{all:unset;position:absolute;inset:0;cursor:pointer;display:block}\n.vxs-video-cover img{width:100%;height:100%;object-fit:cover;display:block}\n.vxs-video-play{position:absolute;left:50%;top:50%;width:68px;height:48px;margin:-24px 0 0 -34px;border-radius:14px;background:rgba(0,0,0,.72);transition:background .15s}\n.vxs-video-play::after{content:\"\";position:absolute;left:28px;top:14px;border-style:solid;border-width:10px 0 10px 17px;border-color:transparent transparent transparent #fff}\n.vxs-video-cover:hover .vxs-video-play,.vxs-video-cover:focus-visible .vxs-video-play{background:var(--vxs-accent)}\n.vxs-video-cover:focus-visible{outline:3px solid var(--vxs-accent);outline-offset:-3px}\n.vxs-video-title{position:absolute;left:0;right:0;bottom:0;padding:24px 16px 12px;color:#fff;font-weight:600;background:linear-gradient(transparent,rgba(0,0,0,.7))}\n.vxs-slider{position:relative;--vxs-slide-ratio:16/7}\n.vxs-slider-viewport{overflow:hidden;border-radius:var(--vxs-radius);touch-action:pan-y}\n.vxs-slider-track{display:flex;transition:transform .45s ease}\n.vxs-slide{flex:0 0 100%;position:relative;aspect-ratio:var(--vxs-slide-ratio);background:var(--vxs-line);overflow:hidden}\n.vxs-slide picture{display:contents}\n.vxs-slide-img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}\n.vxs-slide-caption{position:absolute;inset:auto 0 0 0;padding:48px clamp(16px,4vw,48px) clamp(16px,3vw,36px);color:#fff;background:linear-gradient(transparent,rgba(0,0,0,.65));display:flex;flex-direction:column;align-items:flex-start;gap:8px}\n.vxs-slide-title{margin:0;font-size:clamp(1.25rem,3vw,2.25rem);font-weight:700;line-height:1.15;max-width:24ch}\n.vxs-slide-text{margin:0;max-width:52ch;opacity:.92}\n.vxs-slide-link{display:inline-flex;margin-top:4px;padding:9px 16px;border-radius:999px;background:var(--vxs-accent);color:var(--vxs-accent-fg);text-decoration:none;font-weight:600}\n.vxs-slide-link:focus-visible{outline:2px solid #fff;outline-offset:2px}\n.vxs-slider-controls{display:flex;align-items:center;justify-content:center;gap:12px;margin-top:12px}\n.vxs-slider-btn{appearance:none;display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:50%;border:1px solid var(--vxs-line);background:var(--vxs-bg);color:var(--vxs-fg);cursor:pointer}\n.vxs-slider-btn:focus-visible,.vxs-slider-dot:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:2px}\n.vxs-chevron{width:8px;height:8px;border-right:2px solid currentColor;border-bottom:2px solid currentColor}\n.vxs-slider-prev .vxs-chevron{transform:translateX(2px) rotate(135deg)}\n.vxs-slider-next .vxs-chevron{transform:translateX(-2px) rotate(-45deg)}\n[dir=rtl] .vxs-slider-prev .vxs-chevron{transform:translateX(-2px) rotate(-45deg)}\n[dir=rtl] .vxs-slider-next .vxs-chevron{transform:translateX(2px) rotate(135deg)}\n.vxs-icon-pause{width:10px;height:12px;border-left:3px solid currentColor;border-right:3px solid currentColor}\n.vxs-icon-play{width:0;height:0;margin-left:3px;border-style:solid;border-width:6px 0 6px 10px;border-color:transparent transparent transparent currentColor}\n.vxs-slider-dots{display:flex;gap:2px}\n.vxs-slider-dot{appearance:none;width:24px;height:24px;border:0;background:none;cursor:pointer;position:relative;padding:0}\n.vxs-slider-dot::after{content:\"\";position:absolute;left:8px;top:8px;width:8px;height:8px;border-radius:50%;background:var(--vxs-muted);opacity:.4}\n.vxs-slider-dot[aria-current=true]::after{opacity:1;background:var(--vxs-accent);transform:scale(1.25)}\n.vxs-map{margin:0}\n.vxs-map-view{position:relative;overflow:hidden;border-radius:var(--vxs-radius);background:#e5e3df;touch-action:none;cursor:grab;user-select:none}\n.vxs-map-view:active{cursor:grabbing}\n.vxs-map-view:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:2px}\n.vxs-map-tiles img{position:absolute;width:256px;height:256px;max-width:none;pointer-events:none}\n.vxs-map-pin{appearance:none;position:absolute;width:28px;height:28px;margin:-28px 0 0 -14px;padding:0;border:0;background:none;cursor:pointer}\n.vxs-map-pin::before{content:\"\";position:absolute;inset:0;border-radius:50% 50% 50% 0;transform:rotate(-45deg);background:var(--vxs-pin,#e11d48);border:2px solid #fff;box-shadow:0 2px 6px rgba(0,0,0,.35)}\n.vxs-map-pin::after{content:\"\";position:absolute;left:10px;top:8px;width:8px;height:8px;border-radius:50%;background:#fff}\n.vxs-map-pin[aria-expanded=true]::before{background:var(--vxs-accent)}\n.vxs-map-pin:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:4px;border-radius:50%}\n.vxs-map-card{position:absolute;z-index:1;transform:translate(-50%,calc(-100% - 36px));min-width:180px;max-width:260px;background:var(--vxs-bg);color:var(--vxs-fg);border-radius:10px;box-shadow:0 8px 24px rgba(0,0,0,.2);padding:10px 12px;display:flex;flex-direction:column;gap:2px;font-size:.875rem;cursor:auto}\n.vxs-place-name{font-weight:650}\n.vxs-place-address{color:var(--vxs-muted)}\n.vxs-place-links{display:flex;gap:12px;margin-top:4px}\n.vxs-place-links a{color:var(--vxs-accent)}\n.vxs-map-zoom{position:absolute;z-index:2;top:10px;right:10px;display:flex;flex-direction:column;border-radius:8px;overflow:hidden;box-shadow:0 2px 8px rgba(0,0,0,.2)}\n.vxs-map-zoom button{appearance:none;width:34px;height:34px;border:0;border-bottom:1px solid var(--vxs-line);background:var(--vxs-bg);color:var(--vxs-fg);font-size:18px;line-height:1;cursor:pointer}\n.vxs-map-zoom button:last-child{border-bottom:0}\n.vxs-map-zoom button:disabled{opacity:.4;cursor:not-allowed}\n.vxs-map-zoom button:focus-visible{outline:2px solid var(--vxs-accent);outline-offset:-2px}\n.vxs-map-credit{position:absolute;right:0;bottom:0;padding:2px 6px;font-size:11px;background:rgba(255,255,255,.8);color:#333;text-decoration:none}\n.vxs-map-defer{appearance:none;width:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;border:1px dashed var(--vxs-line);border-radius:var(--vxs-radius);background:var(--vxs-footer-bg);color:var(--vxs-fg);font:inherit;font-weight:600;cursor:pointer}\n.vxs-map-defer-note{font-weight:400;font-size:.8rem;color:var(--vxs-muted)}\n.vxs-map-list{list-style:none;margin:12px 0 0;padding:0;display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px}\n.vxs-map-item{display:flex;flex-direction:column;gap:2px;font-size:.9rem;padding:10px 12px;border:1px solid var(--vxs-line);border-radius:10px}\n[dir=rtl] .vxs-map-zoom{right:auto;left:10px}\n.vxs-chart{margin:0;--vxc-surface:var(--vxs-bg)}\n.vxs-chart-title{margin:0 0 8px;font-weight:650;font-size:1.05rem}\n.vxs-chart-box{position:relative}\n.vxs-chart-box svg{display:block;width:100%;height:100%;overflow:visible}\n.vxs-chart-cross{position:absolute;top:8px;bottom:26px;width:1px;background:var(--vxc-axis,#c3c2b7);pointer-events:none}\n.vxs-chart-tip{position:absolute;z-index:2;min-width:120px;max-width:200px;padding:8px 10px;border-radius:8px;background:var(--vxs-bg);color:var(--vxs-fg);box-shadow:0 6px 20px rgba(0,0,0,.18);font-size:.8rem;display:flex;flex-direction:column;gap:2px;pointer-events:none}\n.vxs-chart-tip-label{color:var(--vxs-muted)}\n.vxs-chart-tip-row{display:flex;align-items:center;gap:6px}\n.vxs-chart-tip-row i{width:8px;height:8px;border-radius:2px;flex:none}\n.vxs-chart-caption{margin:8px 0 0;color:var(--vxs-muted);font-size:.875rem}\n.vxs-chart-data{margin-top:8px;font-size:.875rem}\n.vxs-chart-data summary{cursor:pointer;color:var(--vxs-accent)}\n.vxs-chart-table{overflow-x:auto;margin-top:6px}\n.vxs-chart-table table{border-collapse:collapse;min-width:100%}\n.vxs-chart-table th,.vxs-chart-table td{padding:4px 10px;border-bottom:1px solid var(--vxs-line);text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}\n.vxs-chart-table th:first-child{text-align:left;font-weight:500}\n@media (prefers-color-scheme:dark){:root:where(:not([data-theme=light])) .vxs-chart{--vxc-1:#3987e5;--vxc-2:#d95926;--vxc-3:#199e70;--vxc-4:#c98500;--vxc-5:#d55181;--vxc-6:#008300;--vxc-ink:#ffffff;--vxc-ink2:#c3c2b7;--vxc-muted:#898781;--vxc-grid:#2c2c2a;--vxc-axis:#383835;--vxc-good:#0ca30c;--vxc-bad:#e66767}}\n:root[data-theme=dark] .vxs-chart{--vxc-1:#3987e5;--vxc-2:#d95926;--vxc-3:#199e70;--vxc-4:#c98500;--vxc-5:#d55181;--vxc-6:#008300;--vxc-ink:#ffffff;--vxc-ink2:#c3c2b7;--vxc-muted:#898781;--vxc-grid:#2c2c2a;--vxc-axis:#383835;--vxc-good:#0ca30c;--vxc-bad:#e66767}\n@media (max-width:767px){.vxs-slider{--vxs-slide-ratio:4/3}}\n@media (prefers-reduced-motion:reduce){.vxs-slider-track{transition:none}}\n.vxs-footer{background:var(--vxs-footer-bg);color:var(--vxs-fg);border-top:1px solid var(--vxs-line);margin-top:48px}\n.vxs-footer-inner{max-width:var(--vxs-width);margin:0 auto;padding:40px 20px 24px;display:grid;grid-template-columns:minmax(200px,1.2fr) 3fr;gap:32px}\n.vxs-footer-inner>:only-child{grid-column:1/-1}\n.vxs-footer-text{color:var(--vxs-muted);max-width:36ch}\n.vxs-footer-text p{margin:0 0 8px}\n.vxs-footer-columns{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:24px}\n.vxs-footer-heading{display:block;margin:0 0 10px;font-weight:650;color:inherit;text-decoration:none}\n.vxs-footer-column ul,.vxs-social{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}\n.vxs-footer-link{color:var(--vxs-muted);text-decoration:none}\n.vxs-footer-link:hover{color:var(--vxs-fg);text-decoration:underline}\n.vxs-footer-bottom{max-width:var(--vxs-width);margin:0 auto;padding:16px 20px 28px;border-top:1px solid var(--vxs-line);display:flex;flex-wrap:wrap;gap:16px;align-items:center;justify-content:space-between}\n.vxs-legal{margin:0;color:var(--vxs-muted);font-size:.875rem}\n.vxs-social{flex-direction:row;flex-wrap:wrap;gap:16px}\n@media (max-width:767px){.vxs-footer-inner{grid-template-columns:1fr}}\n";
3
3
  /**
4
4
  * The default look for the site components; render once, e.g. in the root layout.
5
5
  *
@@ -2,10 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // A plain look for NavMenu, SiteHeader, SiteFooter, VideoEmbed, Slider, MapEmbed and Chart. Render
3
3
  // <VeroxmSiteStyles /> once (in the root layout), then restyle with the
4
4
  // variables on :root, or leave it out and write your own CSS against the
5
- // vxs-* classes.
5
+ // vxs-* classes. With a design system on the page (<VeroxmDesignSystem />), its colours and corners are the defaults.
6
6
  /** @experimental A site building block: it can still change in a minor release (see SDK-STABILITY.md). */
7
7
  export const SITE_STYLES = `
8
- :root{--vxs-bg:#fff;--vxs-fg:#18181b;--vxs-muted:#52525b;--vxs-line:#e4e4e7;--vxs-accent:#4f46e5;--vxs-accent-fg:#fff;--vxs-menu-bg:#fff;--vxs-radius:10px;--vxs-width:1200px;--vxs-footer-bg:#fafafa}
8
+ :root{--vxs-bg:var(--vx-color-surface,#fff);--vxs-fg:var(--vx-color-text,#18181b);--vxs-muted:var(--vx-color-text-muted,#52525b);--vxs-line:var(--vx-color-border,#e4e4e7);--vxs-accent:var(--vx-color-action,#4f46e5);--vxs-accent-fg:var(--vx-color-on-action,#fff);--vxs-menu-bg:var(--vx-color-surface,#fff);--vxs-radius:var(--vx-radius-card,10px);--vxs-width:1200px;--vxs-footer-bg:var(--vx-color-subtle,#fafafa)}
9
9
  .vxs-sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
10
10
  .vxs-header{background:var(--vxs-bg);color:var(--vxs-fg);border-bottom:1px solid var(--vxs-line);position:relative;z-index:40}
11
11
  .vxs-sticky{position:sticky;top:0}
@@ -19,6 +19,10 @@ export const SITE_STYLES = `
19
19
  .vxs-nav-row{display:flex;align-items:center}
20
20
  .vxs-nav-link,.vxs-nav-text,.vxs-nav-button{display:flex;align-items:center;gap:6px;padding:8px 12px;border-radius:8px;color:inherit;text-decoration:none;font:inherit;background:none;border:0;cursor:pointer;line-height:1.3}
21
21
  .vxs-nav-text{cursor:default}
22
+ .vxs-nav-icon{display:inline-flex;width:1.2em;height:1.2em}
23
+ .vxs-nav-icon svg{width:100%;height:100%}
24
+ .vxs-nav-badge{font-size:.72em;font-weight:600;padding:1px 8px;border-radius:999px;background:var(--vxs-accent);color:var(--vxs-accent-fg)}
25
+ .vxs-nav-description{display:block;flex-basis:100%;font-size:.85em;opacity:.7}
22
26
  .vxs-nav-more{padding:8px 6px;margin-left:-8px}
23
27
  .vxs-nav-link:hover,.vxs-nav-button:hover{background:color-mix(in srgb,var(--vxs-fg) 6%,transparent)}
24
28
  .vxs-nav-link[aria-current=page]{color:var(--vxs-accent);font-weight:600}
@@ -24,6 +24,7 @@ export type SlotFieldDef = (BaseField & {
24
24
  }) | (BaseField & {
25
25
  type: 'menu';
26
26
  depth?: 1 | 2 | 3;
27
+ icons?: readonly string[];
27
28
  }) | (BaseField & {
28
29
  type: 'video';
29
30
  }) | (BaseField & {
@@ -37,8 +38,26 @@ export type SlotFieldDef = (BaseField & {
37
38
  }) | (BaseField & {
38
39
  type: 'component';
39
40
  components: Record<string, ComponentSchema>;
41
+ }) | (BaseField & {
42
+ type: 'list';
43
+ fields: Record<string, ListItemFieldDef>;
44
+ max?: number;
45
+ schedule?: boolean;
40
46
  });
41
47
  export type SlotFieldDefs = Record<string, SlotFieldDef>;
48
+ /** The field types of a list inside a list item (a card's ticked points): plain values only. */
49
+ export type NestedListItemFieldDef = Extract<SlotFieldDef, {
50
+ type: 'text' | 'link' | 'number' | 'boolean' | 'select';
51
+ }>;
52
+ /** The field types a list's items can have: the simple ones, and one list of plain values (a card's ticked points). */
53
+ export type ListItemFieldDef = Extract<SlotFieldDef, {
54
+ type: 'text' | 'richText' | 'media' | 'link' | 'number' | 'boolean' | 'select';
55
+ }> | (BaseField & {
56
+ type: 'list';
57
+ fields: Record<string, NestedListItemFieldDef>;
58
+ max?: number;
59
+ schedule?: boolean;
60
+ });
42
61
  /** What VeroXM is told about a registered component: its fields, and the version of that field list. */
43
62
  export interface ComponentSchema<F extends SlotFieldDefs = SlotFieldDefs> {
44
63
  label?: string;
@@ -131,15 +150,41 @@ export declare const field: {
131
150
  type: "select";
132
151
  options: T;
133
152
  };
134
- /** A navigation menu marketers edit: links, with sub-menus up to `depth` levels (default 2, at most 3). */
135
- menu: (o?: BaseField & {
153
+ /**
154
+ * A navigation menu marketers edit: links, with sub-menus up to `depth` levels (default 2, at most 3). Each item may
155
+ * have a badge ("New") and a description; with `icons`, an icon chosen from those names (your site draws them).
156
+ */
157
+ menu: <const I extends readonly string[] = readonly string[]>(o?: BaseField & {
136
158
  depth?: 1 | 2 | 3;
159
+ icons?: I;
137
160
  }) => {
138
161
  label?: string;
139
162
  required?: boolean;
140
163
  depth?: 1 | 2 | 3;
164
+ icons?: I;
141
165
  type: "menu";
142
166
  };
167
+ /**
168
+ * A list marketers add to, remove from and reorder: product cards, plan cards, ticker items, footer columns. Each item
169
+ * has the `fields` you give (text, rich text, image, link, number, yes/no, choice, and one list of plain values, such
170
+ * as a card's ticked points). `max` 1 to 50 items (default 20).
171
+ * With `schedule`, each item may have a first and a last day it shows on (a ticker, a "New" badge that expires).
172
+ *
173
+ * ```tsx
174
+ * cards: field.list({ title: field.text({ max: 40, required: true }), badge: field.text({ max: 24 }), link: field.link() }, { max: 12 })
175
+ * ```
176
+ */
177
+ list: <const IF extends Record<string, ListItemFieldDef>>(fields: IF, o?: BaseField & {
178
+ max?: number;
179
+ schedule?: boolean;
180
+ }) => {
181
+ label?: string;
182
+ required?: boolean;
183
+ max?: number;
184
+ schedule?: boolean;
185
+ type: "list";
186
+ fields: IF;
187
+ };
143
188
  /** A YouTube or Vimeo link, or a video file, that the site shows as a player. */
144
189
  video: (o?: BaseField) => {
145
190
  label?: string;
@@ -240,6 +285,12 @@ export interface SlotMenuItem {
240
285
  /** Empty for an item that only opens its sub-items. */
241
286
  href: string;
242
287
  newTab?: boolean;
288
+ /** One of the field's `icons`, when it declares them. */
289
+ icon?: string;
290
+ /** A short tag next to the label ("New"). */
291
+ badge?: string;
292
+ /** A line under the label (a mega-menu). */
293
+ description?: string;
243
294
  children?: SlotMenuItem[];
244
295
  }
245
296
  type SlotValue<F> = F extends {
@@ -270,11 +321,21 @@ type SlotValue<F> = F extends {
270
321
  components: infer C extends Record<string, ComponentSchema>;
271
322
  } ? {
272
323
  [K in keyof C & string]: SlotComponentValue<K, C[K]['fields']>;
273
- }[keyof C & string] | null : never;
324
+ }[keyof C & string] | null : F extends {
325
+ type: 'list';
326
+ fields: infer IF extends SlotFieldDefs;
327
+ } ? Array<SlotValues<IF>> : never;
274
328
  /** The values a slot renders with, typed from its field definitions. */
275
329
  export type SlotValues<F extends SlotFieldDefs> = {
276
330
  [K in keyof F]: SlotValue<F[K]>;
277
331
  };
332
+ /** What a slot shows before anything is published: any of its fields, and list items with only some of theirs. */
333
+ export type SlotFallback<F extends SlotFieldDefs> = {
334
+ [K in keyof F]?: F[K] extends {
335
+ type: 'list';
336
+ fields: infer IF extends SlotFieldDefs;
337
+ } ? Array<Partial<SlotValues<IF>>> : SlotValue<F[K]>;
338
+ };
278
339
  /** What the render function gets as its second argument. */
279
340
  export interface SlotInfo {
280
341
  name: string;
@@ -411,14 +472,22 @@ export declare function reportSlotNow(name: string, fields: SlotFieldDefs, label
411
472
  * leaves empty are left out): what the site shows before anything is
412
473
  * published, sent to VeroXM so its dashboard can show it in empty fields.
413
474
  */
414
- export declare function fallbackValues<F extends SlotFieldDefs>(fields: F, fallback: Partial<SlotValues<F>> | undefined): Record<string, unknown>;
415
- /** Published value where there is one, else the fallback, else an empty value for the field type. */
416
- export declare function mergeSlotValues<F extends SlotFieldDefs>(fields: F, fallback: Partial<SlotValues<F>> | undefined, published: Record<string, unknown> | null): SlotValues<F>;
475
+ export declare function fallbackValues<F extends SlotFieldDefs>(fields: F, fallback: SlotFallback<F> | undefined): Record<string, unknown>;
476
+ /**
477
+ * Published value where there is one, else the fallback, else an empty value for the field type.
478
+ *
479
+ * `neverPublished`: the values are the draft of a slot never published (the on-page editor). Then an empty list is
480
+ * treated as not set yet and the fallback's list shows, so saving one field can't make a list vanish from the page.
481
+ * Once a slot is published, an empty list stays empty: an editor may clear a list on purpose.
482
+ */
483
+ export declare function mergeSlotValues<F extends SlotFieldDefs>(fields: F, fallback: SlotFallback<F> | undefined, published: Record<string, unknown> | null, options?: {
484
+ neverPublished?: boolean;
485
+ }): SlotValues<F>;
417
486
  /** SlotInfo for published content (or the fallback when null). */
418
487
  export declare function slotInfo(name: string, published: PublishedSlot | null): SlotInfo;
419
488
  export interface LoadSlotOptions<F extends SlotFieldDefs> {
420
489
  fields: F;
421
- fallback?: Partial<SlotValues<F>>;
490
+ fallback?: SlotFallback<F>;
422
491
  label?: string;
423
492
  locale?: string;
424
493
  /** Page path, shown in the dashboard as where the slot was last seen. */
@@ -23,8 +23,22 @@ export const field = {
23
23
  number: (o = {}) => ({ type: 'number', ...o }),
24
24
  boolean: (o = {}) => ({ type: 'boolean', ...o }),
25
25
  select: (options, o = {}) => ({ type: 'select', options, ...o }),
26
- /** A navigation menu marketers edit: links, with sub-menus up to `depth` levels (default 2, at most 3). */
26
+ /**
27
+ * A navigation menu marketers edit: links, with sub-menus up to `depth` levels (default 2, at most 3). Each item may
28
+ * have a badge ("New") and a description; with `icons`, an icon chosen from those names (your site draws them).
29
+ */
27
30
  menu: (o = {}) => ({ type: 'menu', ...o }),
31
+ /**
32
+ * A list marketers add to, remove from and reorder: product cards, plan cards, ticker items, footer columns. Each item
33
+ * has the `fields` you give (text, rich text, image, link, number, yes/no, choice, and one list of plain values, such
34
+ * as a card's ticked points). `max` 1 to 50 items (default 20).
35
+ * With `schedule`, each item may have a first and a last day it shows on (a ticker, a "New" badge that expires).
36
+ *
37
+ * ```tsx
38
+ * cards: field.list({ title: field.text({ max: 40, required: true }), badge: field.text({ max: 24 }), link: field.link() }, { max: 12 })
39
+ * ```
40
+ */
41
+ list: (fields, o = {}) => ({ type: 'list', fields, ...o }),
28
42
  /** A YouTube or Vimeo link, or a video file, that the site shows as a player. */
29
43
  video: (o = {}) => ({ type: 'video', ...o }),
30
44
  /** Slides for a slider: each an image with optional title, text and link. `max` 1 to 20 (default 10). */
@@ -266,13 +280,20 @@ function emptyValue(def) {
266
280
  return def.options[0];
267
281
  case 'menu':
268
282
  case 'slides':
283
+ case 'list':
269
284
  return [];
270
285
  default:
271
286
  return null;
272
287
  }
273
288
  }
274
- /** Published value where there is one, else the fallback, else an empty value for the field type. */
275
- export function mergeSlotValues(fields, fallback, published) {
289
+ /**
290
+ * Published value where there is one, else the fallback, else an empty value for the field type.
291
+ *
292
+ * `neverPublished`: the values are the draft of a slot never published (the on-page editor). Then an empty list is
293
+ * treated as not set yet and the fallback's list shows, so saving one field can't make a list vanish from the page.
294
+ * Once a slot is published, an empty list stays empty: an editor may clear a list on purpose.
295
+ */
296
+ export function mergeSlotValues(fields, fallback, published, options = {}) {
276
297
  const out = {};
277
298
  for (const [name, def] of Object.entries(fields)) {
278
299
  const fb = fallback?.[name];
@@ -280,6 +301,16 @@ export function mergeSlotValues(fields, fallback, published) {
280
301
  out[name] = mergeComponentValue(def.components, published?.[name], fb);
281
302
  continue;
282
303
  }
304
+ if (def.type === 'list') {
305
+ // Each item gets every field (an empty value for one left blank), so a card can read item.badge safely.
306
+ const live = published?.[name];
307
+ const unset = !Array.isArray(live) || (options.neverPublished && live.length === 0);
308
+ const items = !unset ? live : Array.isArray(fb) ? fb : [];
309
+ out[name] = items
310
+ .filter((item) => !!item && typeof item === 'object' && !Array.isArray(item))
311
+ .map((item) => mergeSlotValues(def.fields, undefined, item));
312
+ continue;
313
+ }
283
314
  const live = published?.[name];
284
315
  const hasLive = live !== undefined && live !== null && live !== '';
285
316
  out[name] = hasLive ? live : fb !== undefined && fb !== null ? fb : emptyValue(def);
@@ -0,0 +1,54 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ import { type TranslationBundle, type Translator } from '@veroxm/sdk';
3
+ /** Where the bundles come from. */
4
+ export interface TranslationsSource {
5
+ /** Your VeroXM deployment's origin, e.g. "https://cms.example.com". */
6
+ baseUrl: string;
7
+ /** The project's UUID. */
8
+ projectId: string;
9
+ /** Any key of the project; a browser key is enough. */
10
+ apiKey: string;
11
+ /** The fetch to send with. Default: the global fetch. */
12
+ fetch?: typeof fetch;
13
+ }
14
+ export interface VeroxmTranslationsProviderProps extends TranslationsSource {
15
+ children: ReactNode;
16
+ /** The locale `useTranslations()` uses when it isn't given one. */
17
+ locale?: string;
18
+ /** Bundles you already have (fetched on the server): used at once, with no request. */
19
+ initial?: TranslationBundle | TranslationBundle[];
20
+ /** Fill keys a locale doesn't have yet from the default locale. Default: true. */
21
+ fallback?: boolean;
22
+ /** Set `<html lang>` and `<html dir>` from the provider's `locale` once its bundle is in, so the layout flips for right-to-left languages. Default: false. */
23
+ applyToDocument?: boolean;
24
+ }
25
+ /** Supplies the bundles' source (and a default locale) to `useTranslations()` below it. */
26
+ export declare function VeroxmTranslationsProvider(props: VeroxmTranslationsProviderProps): ReactElement;
27
+ export interface UseTranslationsOptions extends Partial<TranslationsSource> {
28
+ /** Fill keys not translated yet from the default locale. Default: the provider's, or true. */
29
+ fallback?: boolean;
30
+ }
31
+ export interface TranslationsState {
32
+ /** `t('checkout.pay', { amount })`: the text with its placeholders filled, or the key while it loads. */
33
+ t: Translator;
34
+ /** The locale answered (`ar` for `ar-SA` when the project has only `ar`), once loaded. */
35
+ locale: string | undefined;
36
+ /** Writing direction: put it on your root element (`<div dir={dir}>`). `ltr` until the bundle is in. */
37
+ dir: 'rtl' | 'ltr';
38
+ /** The language's own name ("العربية"), once loaded. */
39
+ nativeName: string | undefined;
40
+ /** The project's translations version of the bundle shown. */
41
+ version: number | undefined;
42
+ /** The whole bundle, with `fallback` (keys shown in the default locale). */
43
+ bundle: TranslationBundle | undefined;
44
+ /** True once the requested locale's bundle is in. While another locale loads, `t` keeps the previous one's texts. */
45
+ ready: boolean;
46
+ error: Error | undefined;
47
+ /** Fetch the bundle again (after the texts change, for example). */
48
+ reload: () => Promise<void>;
49
+ }
50
+ /**
51
+ * A locale's app translations: `const { t, dir, ready } = useTranslations('ar')`. Without a locale, the provider's.
52
+ * Every component asking for the same locale shares one request.
53
+ */
54
+ export declare function useTranslations(locale?: string, options?: UseTranslationsOptions): TranslationsState;
@@ -0,0 +1,130 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
4
+ import { createTranslator, fetchTranslations } from '@veroxm/sdk';
5
+ /** Loaded bundles and the requests in flight, per locale. */
6
+ class BundleStore {
7
+ constructor(source, fallback, initial) {
8
+ this.source = source;
9
+ this.fallback = fallback;
10
+ this.bundles = new Map();
11
+ this.pending = new Map();
12
+ for (const b of initial ? (Array.isArray(initial) ? initial : [initial]) : [])
13
+ this.bundles.set(b.locale.toLowerCase(), b);
14
+ }
15
+ peek(locale) {
16
+ return this.bundles.get(locale.toLowerCase());
17
+ }
18
+ load(locale, reload = false) {
19
+ const key = locale.toLowerCase();
20
+ if (!reload) {
21
+ const have = this.bundles.get(key);
22
+ if (have)
23
+ return Promise.resolve(have);
24
+ const inFlight = this.pending.get(key);
25
+ if (inFlight)
26
+ return inFlight;
27
+ }
28
+ const p = fetchTranslations({ ...this.source, locale, fallback: this.fallback })
29
+ .then((b) => {
30
+ this.bundles.set(key, b);
31
+ // A request for "ar-SA" answered by "ar": keep it under both.
32
+ this.bundles.set(b.locale.toLowerCase(), b);
33
+ return b;
34
+ })
35
+ .finally(() => this.pending.delete(key));
36
+ this.pending.set(key, p);
37
+ return p;
38
+ }
39
+ }
40
+ const TranslationsContext = createContext(null);
41
+ /** Supplies the bundles' source (and a default locale) to `useTranslations()` below it. */
42
+ export function VeroxmTranslationsProvider(props) {
43
+ const { children, baseUrl, projectId, apiKey, fetch: fetchFn, locale, initial, fallback = true, applyToDocument = false } = props;
44
+ const store = useMemo(() => new BundleStore({ baseUrl, projectId, apiKey, fetch: fetchFn }, fallback, initial),
45
+ // `initial` seeds the store once; later values are ignored, like a useState initial value.
46
+ // eslint-disable-next-line react-hooks/exhaustive-deps
47
+ [baseUrl, projectId, apiKey, fetchFn, fallback]);
48
+ const value = useMemo(() => ({ store, locale }), [store, locale]);
49
+ return (_jsxs(TranslationsContext.Provider, { value: value, children: [applyToDocument && locale ? _jsx(DocumentLanguage, { locale: locale }) : null, children] }));
50
+ }
51
+ function DocumentLanguage({ locale }) {
52
+ const { bundle } = useTranslations(locale);
53
+ useEffect(() => {
54
+ if (!bundle || typeof document === 'undefined')
55
+ return;
56
+ document.documentElement.lang = bundle.locale;
57
+ document.documentElement.dir = bundle.dir;
58
+ }, [bundle]);
59
+ return null;
60
+ }
61
+ const standalone = new Map();
62
+ function storeFor(context, options) {
63
+ const { baseUrl, projectId, apiKey } = options;
64
+ if (baseUrl && projectId && apiKey) {
65
+ const fallback = options.fallback ?? context?.store.fallback ?? true;
66
+ if (context && context.store.source.baseUrl === baseUrl && context.store.source.projectId === projectId && context.store.source.apiKey === apiKey && context.store.fallback === fallback) {
67
+ return context.store;
68
+ }
69
+ const key = `${baseUrl}|${projectId}|${apiKey}|${fallback ? 1 : 0}`;
70
+ let store = standalone.get(key);
71
+ if (!store) {
72
+ store = new BundleStore({ baseUrl, projectId, apiKey, fetch: options.fetch }, fallback);
73
+ standalone.set(key, store);
74
+ }
75
+ return store;
76
+ }
77
+ if (context)
78
+ return context.store;
79
+ throw new Error('useTranslations() needs a <VeroxmTranslationsProvider> above it, or { baseUrl, projectId, apiKey }.');
80
+ }
81
+ const EMPTY = createTranslator({});
82
+ /**
83
+ * A locale's app translations: `const { t, dir, ready } = useTranslations('ar')`. Without a locale, the provider's.
84
+ * Every component asking for the same locale shares one request.
85
+ */
86
+ export function useTranslations(locale, options = {}) {
87
+ const context = useContext(TranslationsContext);
88
+ const store = storeFor(context, options);
89
+ const wanted = locale ?? context?.locale;
90
+ if (!wanted)
91
+ throw new Error('useTranslations() needs a locale, or a <VeroxmTranslationsProvider locale="...">.');
92
+ const [state, setState] = useState(() => {
93
+ const have = store.peek(wanted);
94
+ return { bundle: have, for: have ? wanted.toLowerCase() : undefined, error: undefined };
95
+ });
96
+ useEffect(() => {
97
+ let live = true;
98
+ const have = store.peek(wanted);
99
+ if (have) {
100
+ setState((s) => (s.bundle === have && s.for === wanted.toLowerCase() ? s : { bundle: have, for: wanted.toLowerCase(), error: undefined }));
101
+ return;
102
+ }
103
+ store.load(wanted).then((b) => live && setState({ bundle: b, for: wanted.toLowerCase(), error: undefined }), (e) => live && setState((s) => ({ ...s, error: e instanceof Error ? e : new Error(String(e)) })));
104
+ return () => {
105
+ live = false;
106
+ };
107
+ }, [store, wanted]);
108
+ const reload = useCallback(async () => {
109
+ try {
110
+ const b = await store.load(wanted, true);
111
+ setState({ bundle: b, for: wanted.toLowerCase(), error: undefined });
112
+ }
113
+ catch (e) {
114
+ setState((s) => ({ ...s, error: e instanceof Error ? e : new Error(String(e)) }));
115
+ }
116
+ }, [store, wanted]);
117
+ const { bundle } = state;
118
+ const t = useMemo(() => (bundle ? createTranslator(bundle.translations, { locale: bundle.locale }) : EMPTY), [bundle]);
119
+ return {
120
+ t,
121
+ locale: bundle?.locale,
122
+ dir: bundle?.dir ?? 'ltr',
123
+ nativeName: bundle?.nativeName,
124
+ version: bundle?.version,
125
+ bundle,
126
+ ready: !!bundle && state.for === wanted.toLowerCase(),
127
+ error: state.error,
128
+ reload,
129
+ };
130
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veroxm/react-sdk",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "React and Next.js SDK for VeroXM: content hooks, visual slots with A/B tests, the on-page editor, forms and product journeys, llms.txt and structured data.",
5
5
  "keywords": [
6
6
  "veroxm",
@@ -71,7 +71,7 @@
71
71
  "api:report": "node ../../scripts/api-report.mjs . --write"
72
72
  },
73
73
  "dependencies": {
74
- "@veroxm/sdk": "^1.10.0"
74
+ "@veroxm/sdk": "^1.13.0"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "react": "^18.0.0 || ^19.0.0",