@veroxm/react-sdk 1.10.0 → 1.11.1

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.
@@ -9,27 +9,24 @@ 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 { fallbackImage, isEmptyValue, readFallback, sameSiteImage, seedFromFallback } from './seed.js';
12
+ import { fallbackImage, fallbackItem, isEmptyValue, readFallback, sameSiteImage, seedFromFallback } from './seed.js';
13
+ import { Ui, useUi } from './ui-context.js';
14
+ import { EDITOR_LANGS, LANG_NAMES, createTranslator, editorLang, pickLabel } from './i18n.js';
13
15
  function asComponentValue(v) {
14
16
  return v && typeof v === 'object' && !Array.isArray(v) && typeof v.component === 'string' ? v : null;
15
17
  }
16
- const TEST_STATUS = {
17
- draft: 'Test draft',
18
- pending_approval: 'Test waiting for approval',
19
- live: 'Test running',
20
- paused: 'Test paused',
21
- };
18
+ const TEST_STATUS = { draft: 'test.draft', pending_approval: 'test.pending_approval', live: 'test.live', paused: 'test.paused' };
22
19
  function setPreviewCookie(value) {
23
20
  document.cookie = value
24
21
  ? `${PREVIEW_COOKIE}=${encodeURIComponent(value)}; Path=/; SameSite=Lax`
25
22
  : `${PREVIEW_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax`;
26
23
  }
27
24
  const OUTCOME_NOTICE = {
28
- published: 'Published. Visitors see this now.',
29
- submitted: 'Sent for approval. Nothing changes for visitors until it is approved.',
30
- approved: 'Approved. It moves to the next step.',
31
- rejected: 'Rejected. The author can change it and send it again.',
32
- withdrawn: 'Request withdrawn. Your draft is unchanged.',
25
+ published: 'outcome.published',
26
+ submitted: 'outcome.submitted',
27
+ approved: 'outcome.approved',
28
+ rejected: 'outcome.rejected',
29
+ withdrawn: 'outcome.withdrawn',
33
30
  };
34
31
  class EditorError extends Error {
35
32
  constructor(status, problems) {
@@ -57,7 +54,7 @@ async function call(path, init = {}) {
57
54
  const res = await transport.request(path, { method: init.method ?? 'GET', body: init.body });
58
55
  const body = (await res.json().catch(() => ({})));
59
56
  if (!res.ok) {
60
- const problems = body.errors ?? (body.error ? [body.error] : Array.isArray(body.message) ? body.message : [body.message ?? `Something went wrong (HTTP ${res.status}).`]);
57
+ const problems = body.errors ?? (body.error ? [body.error] : Array.isArray(body.message) ? body.message : [body.message ?? currentUi.t('error.http', { status: String(res.status) })]);
61
58
  throw new EditorError(res.status, problems);
62
59
  }
63
60
  return body;
@@ -92,16 +89,49 @@ function toPayload(fields, values) {
92
89
  return out;
93
90
  }
94
91
  /** What the panel says after starting a slot from the page: which fields came from where. */
95
- function seedNotice(s, seeded, locale) {
96
- const label = (f) => s.fields[f]?.label ?? f;
97
- const fromPage = seeded.map(label).join(', ');
92
+ function seedNotice(ui, s, seeded, locale) {
93
+ const label = (f) => fieldLabel(ui, s.fields[f], f);
94
+ const fields = ui.list(seeded.map(label));
98
95
  if (!s.inherited)
99
- return `Filled from the page’s current content (${fromPage}). Change what you need, then publish.`;
96
+ return ui.t('seed.filled', { fields });
100
97
  const rest = Object.keys(s.fields).filter((f) => !seeded.includes(f) && !isEmptyValue(s.values[f]));
101
- const lang = locale ? ` ${locale}` : '';
102
- return rest.length
103
- ? `Nothing saved in${lang} yet. From this page’s${lang} content: ${fromPage}. From the default language’s published copy: ${rest.map(label).join(', ')}.`
104
- : `Nothing saved in${lang} yet. Filled from this page’s${lang} content (${fromPage}). Change what you need, then publish.`;
98
+ return rest.length ? ui.t('seed.inheritedSplit', { locale, fields, rest: ui.list(rest.map(label)) }) : ui.t('seed.inheritedAll', { locale, fields });
99
+ }
100
+ // ------------------------------------------------------------- interface language
101
+ // The editor's own words follow the interface language: the editor's saved choice, else the page's language, else
102
+ // English. It never changes the content language being edited.
103
+ /** The interface language, for code outside React (request errors). */
104
+ let currentUi = createTranslator('en');
105
+ const PREFS_KEY = 'veroxm-editor-ui';
106
+ function readStoredPrefs() {
107
+ try {
108
+ const raw = JSON.parse(localStorage.getItem(PREFS_KEY) ?? 'null');
109
+ return raw && typeof raw === 'object' ? { language: editorLang(raw.language) ?? undefined, digits: raw.digits === 'arab' || raw.digits === 'latn' ? raw.digits : undefined } : {};
110
+ }
111
+ catch {
112
+ return {};
113
+ }
114
+ }
115
+ function storePrefs(prefs) {
116
+ try {
117
+ localStorage.setItem(PREFS_KEY, JSON.stringify(prefs));
118
+ }
119
+ catch {
120
+ // Private windows and blocked storage: the choice still lasts for this page.
121
+ }
122
+ }
123
+ /** The page's language: its slots' locale (data-veroxm-locale), then <html lang>. */
124
+ function pageLanguage() {
125
+ for (const el of Array.from(document.querySelectorAll('[data-veroxm-slot][data-veroxm-locale]'))) {
126
+ const lang = editorLang(el.getAttribute('data-veroxm-locale'));
127
+ if (lang)
128
+ return lang;
129
+ }
130
+ return editorLang(document.documentElement.getAttribute('lang'));
131
+ }
132
+ /** A field's label in the interface language (the site's per-language labels, else its one label), else its name. */
133
+ function fieldLabel(ui, def, name) {
134
+ return pickLabel(ui.lang, def?.label, def?.labels) ?? name;
105
135
  }
106
136
  /** What the open panel may do beyond editing (read deep inside the form, by the image fields). */
107
137
  const PanelCaps = createContext({ canUploadMedia: false });
@@ -148,7 +178,16 @@ function findPageSlots() {
148
178
  if (!name || seen.has(key))
149
179
  return;
150
180
  seen.add(key);
151
- out.push({ name, locale, label: el.getAttribute('data-veroxm-label') || name, el });
181
+ let labels = null;
182
+ try {
183
+ const raw = JSON.parse(el.getAttribute('data-veroxm-labels') ?? 'null');
184
+ if (raw && typeof raw === 'object' && !Array.isArray(raw))
185
+ labels = raw;
186
+ }
187
+ catch {
188
+ labels = null;
189
+ }
190
+ out.push({ name, locale, label: el.getAttribute('data-veroxm-label') || name, labels, el });
152
191
  });
153
192
  return out;
154
193
  }
@@ -264,6 +303,16 @@ function Overlay({ onChange, tools }) {
264
303
  const [highlightField, setHighlightField] = useState(null);
265
304
  const [inlineHint, setInlineHint] = useState(null);
266
305
  useLayoutTick(Boolean(hover || open || inlineHint), rootRef);
306
+ // Interface language: the editor's choice (VeroXM's copy wins over this browser's), else the page's, else English.
307
+ const [prefs, setPrefs] = useState(readStoredPrefs);
308
+ const [pageLang] = useState(pageLanguage);
309
+ const ui = createTranslator(prefs.language ?? pageLang ?? 'en', { digits: prefs.digits ?? 'latn' });
310
+ currentUi = ui;
311
+ const savePrefs = (next) => {
312
+ setPrefs(next);
313
+ storePrefs(next);
314
+ call('preferences', { method: 'PUT', body: { language: next.language ?? null, digits: next.digits ?? null } }).catch(() => undefined);
315
+ };
267
316
  useEffect(() => {
268
317
  openFromOutside = (name, locale) => {
269
318
  setListOpen(false);
@@ -275,8 +324,16 @@ function Overlay({ onChange, tools }) {
275
324
  }, []);
276
325
  useEffect(() => {
277
326
  call('session')
278
- .then(setSession)
279
- .catch((err) => setEnded(err instanceof EditorError ? err.problems.join(' ') : 'VeroXM could not be reached.'));
327
+ .then((s) => {
328
+ setSession(s);
329
+ const saved = s.editorPrefs;
330
+ if (saved?.language || saved?.digits) {
331
+ const next = { language: editorLang(saved.language) ?? undefined, digits: saved.digits ?? undefined };
332
+ setPrefs((prev) => ({ language: next.language ?? prev.language, digits: next.digits ?? prev.digits }));
333
+ storePrefs(next);
334
+ }
335
+ })
336
+ .catch((err) => setEnded(err instanceof EditorError ? err.problems.join(' ') : currentUi.t('error.unreachable')));
280
337
  }, []);
281
338
  // Once the session is confirmed: the site's own text for each slot, for
282
339
  // the dashboard. Again shortly after, for slots whose fallback arrives late.
@@ -337,46 +394,91 @@ function Overlay({ onChange, tools }) {
337
394
  document.documentElement.removeEventListener('mouseleave', onLeave);
338
395
  };
339
396
  }, [editMode, ended]);
397
+ // The bar can wrap (a narrow window, longer Arabic words): the panel and the slot list always end above it, so the
398
+ // bar never covers the panel's buttons. barSpace = from the bar's top edge to the bottom of the window.
399
+ const barRef = useRef(null);
400
+ const [barSpace, setBarSpace] = useState(64);
401
+ useEffect(() => {
402
+ const bar = barRef.current;
403
+ if (!bar)
404
+ return;
405
+ const measure = () => setBarSpace(Math.max(0, Math.ceil(window.innerHeight - bar.getBoundingClientRect().top)));
406
+ measure();
407
+ const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(measure) : null;
408
+ observer?.observe(bar);
409
+ window.addEventListener('resize', measure);
410
+ return () => {
411
+ observer?.disconnect();
412
+ window.removeEventListener('resize', measure);
413
+ };
414
+ }, []);
340
415
  const openEl = open ? slotElement(open.name, open.locale) : null;
341
416
  const hoverRect = hover && hover !== openEl ? rectOf(hover) : null;
342
417
  const openRect = rectOf(openEl);
343
418
  const fieldRect = openEl && highlightField ? rectOf(openEl.querySelector(`[data-veroxm-field="${CSS.escape(highlightField)}"]`)) : null;
344
- return (_jsxs("div", { ref: rootRef, className: "vx-root", "data-veroxm-overlay": "", children: [_jsx("style", { children: STYLES + RICH_TEXT_STYLES + MENU_STYLES }), hoverRect && _jsx(Outline, { rect: hoverRect, label: hover?.getAttribute('data-veroxm-label') || hover?.getAttribute('data-veroxm-slot') || '' }), openRect && _jsx(Outline, { rect: openRect, active: true }), fieldRect && !inlineHint && _jsx(Outline, { rect: fieldRect, field: true }), inlineHint ? _jsx(InlineHintBar, { hint: inlineHint }) : null, open && session && !ended && (_jsx(SlotPanel, { slot: open, canPublish: session.canPublish, canManageTests: session.canManageTests ?? false, canUploadMedia: session.canUploadMedia ?? false, dashboardUrl: session.dashboardUrl ?? null, onClose: () => {
345
- setOpen(null);
346
- setHighlightField(null);
347
- }, onFieldFocus: setHighlightField, onSessionError: onSessionError, onChange: onChange, onInline: setInlineHint }, `${open.name}|${open.locale}`)), listOpen && (_jsx(SlotList, { onPick: (s) => {
348
- setListOpen(false);
349
- s.el.firstElementChild?.scrollIntoView?.({ block: 'center', behavior: 'smooth' });
350
- setOpen({ name: s.name, locale: s.locale });
351
- }, onClose: () => {
352
- setListOpen(false);
353
- listToggleRef.current?.focus();
354
- } })), _jsxs("div", { className: "vx-toolbar", role: "toolbar", "aria-label": "VeroXM editor", children: [_jsxs("span", { className: "vx-brand", children: [_jsx("span", { className: "vx-dot", "aria-hidden": "true" }), ended ? 'Editing ended' : 'Editing drafts', session?.projectName ? _jsxs("span", { className: "vx-muted", children: [" \u00B7 ", session.projectName] }) : null] }), ended ? (_jsx("span", { className: "vx-muted vx-ended", role: "alert", children: ended })) : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "vx-btn", "aria-pressed": editMode, onClick: () => setEditMode((v) => !v), children: editMode ? 'Click to edit: on' : 'Click to edit: off' }), _jsx("button", { type: "button", ref: listToggleRef, className: "vx-btn", "data-vx-list-toggle": "", "aria-expanded": listOpen, onClick: () => setListOpen((v) => !v), children: "Slots on this page" }), tools] })), _jsx("button", { type: "button", className: "vx-btn", onClick: () => transport.exit(), children: "Exit" })] })] }));
419
+ return (_jsx(Ui.Provider, { value: ui, children: _jsxs("div", { ref: rootRef, className: "vx-root", "data-veroxm-overlay": "", dir: ui.dir, lang: ui.lang, style: { '--vx-bar-space': `${barSpace}px` }, children: [_jsx("style", { children: STYLES + RICH_TEXT_STYLES + MENU_STYLES }), hoverRect && _jsx(Outline, { rect: hoverRect, label: hover ? elementLabel(ui, hover) : '' }), openRect && _jsx(Outline, { rect: openRect, active: true }), fieldRect && !inlineHint && _jsx(Outline, { rect: fieldRect, field: true }), inlineHint ? _jsx(InlineHintBar, { hint: inlineHint }) : null, open && session && !ended && (_jsx(SlotPanel, { slot: open, canPublish: session.canPublish, canManageTests: session.canManageTests ?? false, canUploadMedia: session.canUploadMedia ?? false, dashboardUrl: session.dashboardUrl ?? null, onClose: () => {
420
+ setOpen(null);
421
+ setHighlightField(null);
422
+ }, onFieldFocus: setHighlightField, onSessionError: onSessionError, onChange: onChange, onInline: setInlineHint }, `${open.name}|${open.locale}`)), listOpen && (_jsx(SlotList, { onPick: (s) => {
423
+ setListOpen(false);
424
+ s.el.firstElementChild?.scrollIntoView?.({ block: 'center', behavior: 'smooth' });
425
+ setOpen({ name: s.name, locale: s.locale });
426
+ }, onClose: () => {
427
+ setListOpen(false);
428
+ listToggleRef.current?.focus();
429
+ } })), _jsxs("div", { ref: barRef, className: "vx-toolbar", role: "toolbar", "aria-label": ui.t('bar.aria'), dir: ui.dir, lang: ui.lang, children: [_jsxs("span", { className: "vx-brand", children: [_jsx("span", { className: "vx-dot", "aria-hidden": "true" }), ended ? ui.t('bar.ended') : ui.t('bar.editing'), session?.projectName ? (_jsxs("span", { className: "vx-muted vx-project", title: session.projectName, children: [' · ', _jsx("bdi", { children: session.projectName })] })) : null] }), ended ? (_jsx("span", { className: "vx-muted vx-ended", role: "alert", children: ended })) : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "vx-btn", "aria-pressed": editMode, onClick: () => setEditMode((v) => !v), children: editMode ? ui.t('bar.clickOn') : ui.t('bar.clickOff') }), _jsx("button", { type: "button", ref: listToggleRef, className: "vx-btn", "data-vx-list-toggle": "", "aria-expanded": listOpen, onClick: () => setListOpen((v) => !v), children: ui.t('bar.slots') }), tools] })), _jsx("select", { className: "vx-lang", "aria-label": ui.t('bar.language'), title: ui.t('bar.language'), value: ui.lang === 'ar' ? `ar-${ui.digits}` : ui.lang, onChange: (e) => {
430
+ const [language, digits] = e.target.value.split('-');
431
+ savePrefs({ language: editorLang(language) ?? 'en', digits: digits === 'arab' ? 'arab' : digits === 'latn' ? 'latn' : prefs.digits });
432
+ }, children: EDITOR_LANGS.flatMap((l) => l === 'ar'
433
+ ? [
434
+ _jsxs("option", { value: "ar-latn", lang: "ar", "aria-label": `${LANG_NAMES.ar} – ${ui.t('bar.digitsLatn')}`, children: [LANG_NAMES.ar, " \u00B7 0123"] }, "ar-latn"),
435
+ _jsxs("option", { value: "ar-arab", lang: "ar", "aria-label": `${LANG_NAMES.ar} – ${ui.t('bar.digitsArab')}`, children: [LANG_NAMES.ar, " \u00B7 \u0660\u0661\u0662\u0663"] }, "ar-arab"),
436
+ ]
437
+ : [
438
+ _jsx("option", { value: l, lang: l, children: LANG_NAMES[l] }, l),
439
+ ]) }), _jsx("button", { type: "button", className: "vx-btn", onClick: () => transport.exit(), children: ui.t('bar.exit') })] })] }) }));
440
+ }
441
+ /** A slot's name on the page, in the interface language (data-veroxm-labels), else its one label, else its name. */
442
+ function elementLabel(ui, el) {
443
+ let labels = null;
444
+ try {
445
+ labels = JSON.parse(el.getAttribute('data-veroxm-labels') ?? 'null');
446
+ }
447
+ catch {
448
+ labels = null;
449
+ }
450
+ return pickLabel(ui.lang, el.getAttribute('data-veroxm-label'), labels) || el.getAttribute('data-veroxm-slot') || '';
355
451
  }
356
452
  function InlineHintBar({ hint }) {
453
+ const ui = useUi();
357
454
  const rect = rectOf(hint.el);
358
455
  if (!rect)
359
456
  return null;
360
457
  const below = rect.bottom + 40 < window.innerHeight;
361
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "vx-outline vx-outline-inline", style: { top: rect.top - 4, left: rect.left - 4, width: rect.width + 8, height: rect.height + 8 }, "aria-hidden": "true" }), _jsxs("div", { className: "vx-inline-hint", style: { top: below ? rect.bottom + 8 : Math.max(8, rect.top - 36), left: Math.max(8, rect.left - 4) }, role: "status", "aria-live": "polite", children: [_jsx("strong", { children: hint.label }), hint.max !== undefined ? _jsxs("span", { children: [" \u00B7 ", hint.length, "/", hint.max] }) : null, _jsx("span", { className: "vx-inline-keys", children: " \u00B7 Enter to save \u00B7 Esc to cancel" })] })] }));
458
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "vx-outline vx-outline-inline", style: { top: rect.top - 4, left: rect.left - 4, width: rect.width + 8, height: rect.height + 8 }, "aria-hidden": "true" }), _jsxs("div", { className: "vx-inline-hint", style: { top: below ? rect.bottom + 8 : Math.max(8, rect.top - 36), left: Math.max(8, rect.left - 4) }, role: "status", "aria-live": "polite", children: [_jsx("strong", { children: hint.label }), hint.max !== undefined ? (_jsxs("span", { children: [' · ', _jsx("bdi", { dir: "ltr", children: ui.t('text.count', { n: hint.length, max: hint.max }) })] })) : null, _jsxs("span", { className: "vx-inline-keys", children: [" \u00B7 ", ui.t('inline.keys')] })] })] }));
362
459
  }
363
460
  function Outline({ rect, label, active, field }) {
364
461
  return (_jsx("div", { className: `vx-outline${active ? ' vx-outline-active' : ''}${field ? ' vx-outline-field' : ''}`, style: { top: rect.top - 3, left: rect.left - 3, width: rect.width + 6, height: rect.height + 6 }, "aria-hidden": "true", children: label ? _jsx("span", { className: "vx-tag", children: label }) : null }));
365
462
  }
366
463
  // -------------------------------------------------------------- slot list
367
464
  function SlotList({ onPick, onClose }) {
465
+ const ui = useUi();
368
466
  const [slots] = useState(findPageSlots);
369
467
  const firstRef = useRef(null);
370
468
  useEffect(() => firstRef.current?.focus(), []);
371
- return (_jsxs("div", { className: "vx-list", role: "dialog", "aria-label": "Slots on this page", onKeyDown: (e) => {
469
+ return (_jsxs("div", { className: "vx-list", role: "dialog", "aria-label": ui.t('bar.slots'), onKeyDown: (e) => {
372
470
  if (e.key !== 'Escape')
373
471
  return;
374
472
  e.stopPropagation();
375
473
  onClose();
376
- }, children: [_jsx("p", { className: "vx-list-title", children: "Slots on this page" }), slots.length === 0 ? (_jsx("p", { className: "vx-muted", children: "No slots are visible on this page." })) : (_jsx("ul", { children: slots.map((s, i) => (_jsx("li", { children: _jsxs("button", { type: "button", ref: i === 0 ? firstRef : undefined, onClick: () => onPick(s), children: [_jsx("span", { children: s.label }), s.label !== s.name ? _jsx("code", { children: s.name }) : null, s.locale ? _jsxs("span", { className: "vx-muted", children: [" \u00B7 ", s.locale] }) : null] }) }, `${s.name}|${s.locale}`))) }))] }));
474
+ }, children: [_jsx("p", { className: "vx-list-title", children: ui.t('bar.slots') }), slots.length === 0 ? (_jsx("p", { className: "vx-muted", children: ui.t('list.empty') })) : (_jsx("ul", { children: slots.map((s, i) => {
475
+ const label = pickLabel(ui.lang, s.label, s.labels) || s.name;
476
+ return (_jsx("li", { children: _jsxs("button", { type: "button", ref: i === 0 ? firstRef : undefined, onClick: () => onPick(s), children: [_jsx("span", { children: label }), label !== s.name ? (_jsx("code", { children: _jsx("bdi", { children: s.name }) })) : null, s.locale ? (_jsxs("span", { className: "vx-muted", children: [' · ', _jsx("bdi", { children: s.locale })] })) : null] }) }, `${s.name}|${s.locale}`));
477
+ }) }))] }));
377
478
  }
378
479
  const AUTOSAVE_MS = 800;
379
480
  function SlotPanel({ slot, canPublish, canManageTests, canUploadMedia = false, dashboardUrl, onClose, onFieldFocus, onSessionError, onChange, onInline, }) {
481
+ const ui = useUi();
380
482
  const titleId = useId();
381
483
  const panelRef = useRef(null);
382
484
  const returnFocus = useRef(typeof document !== 'undefined' ? document.activeElement : null);
@@ -421,7 +523,7 @@ function SlotPanel({ slot, canPublish, canManageTests, canUploadMedia = false, d
421
523
  setLocale(res.locale);
422
524
  const s = res.slots[slot.name];
423
525
  if (!s)
424
- setLoadError('VeroXM doesn’t know this slot yet. Reload the page so the site can report it, then try again.');
526
+ setLoadError(currentUi.t('error.unknownSlot'));
425
527
  else {
426
528
  if (position === 0)
427
529
  baseValues.current = s.values;
@@ -441,14 +543,14 @@ function SlotPanel({ slot, canPublish, canManageTests, canUploadMedia = false, d
441
543
  touched.current.add(f);
442
544
  setValues(seededValues);
443
545
  latest.current = seededValues;
444
- setNotice(seedNotice(s, seeded, res.locale));
546
+ setNotice(seedNotice(currentUi, s, seeded, res.locale));
445
547
  }
446
548
  }
447
549
  }
448
550
  }
449
551
  catch (err) {
450
552
  onSessionError(err);
451
- setLoadError(err instanceof EditorError ? err.problems.join(' ') : 'VeroXM could not be reached.');
553
+ setLoadError(err instanceof EditorError ? err.problems.join(' ') : currentUi.t('error.unreachable'));
452
554
  }
453
555
  }, [slot.name, slot.locale, apply, onSessionError]);
454
556
  useEffect(() => {
@@ -508,7 +610,7 @@ function SlotPanel({ slot, canPublish, canManageTests, canUploadMedia = false, d
508
610
  }
509
611
  catch (err) {
510
612
  onSessionError(err);
511
- setSave({ kind: 'error', problems: err instanceof EditorError ? err.problems : ['Could not save. Check your connection.'] });
613
+ setSave({ kind: 'error', problems: err instanceof EditorError ? err.problems : [currentUi.t('error.save')] });
512
614
  return false;
513
615
  }
514
616
  }, [data, locale, slot.name, onChange, onSessionError, load]);
@@ -548,11 +650,12 @@ function SlotPanel({ slot, canPublish, canManageTests, canUploadMedia = false, d
548
650
  // Nothing stored: start from the text the page shows (its fallback), not an empty box.
549
651
  const startText = isEmptyValue(before) && typeof shownRef.current[target.field] === 'string' ? shownRef.current[target.field] : undefined;
550
652
  let typed = false;
551
- const label = def.label ?? target.field;
653
+ const label = fieldLabel(currentUi, def, target.field);
552
654
  onFieldFocus(target.field);
553
655
  onInline({ el: target.el, label, length: target.el.textContent?.length ?? 0, max: def.max });
554
656
  inlineRef.current = startInlineEdit(target.el, {
555
657
  label,
658
+ ariaLabel: currentUi.t('inline.aria', { label }),
556
659
  max: def.max,
557
660
  point: target.point,
558
661
  initialText: startText,
@@ -612,14 +715,15 @@ function SlotPanel({ slot, canPublish, canManageTests, canUploadMedia = false, d
612
715
  });
613
716
  apply(res.slot);
614
717
  setSave({ kind: 'idle' });
615
- setNotice(OUTCOME_NOTICE[res.outcome] ?? null);
718
+ const outcome = OUTCOME_NOTICE[res.outcome];
719
+ setNotice(outcome ? ui.t(outcome) : null);
616
720
  setReviewComment('');
617
721
  if (res.outcome === 'published' || verb === 'publish')
618
722
  onChange();
619
723
  }
620
724
  catch (err) {
621
725
  onSessionError(err);
622
- setSave({ kind: 'error', problems: err instanceof EditorError ? err.problems : ['Something went wrong. Try again.'] });
726
+ setSave({ kind: 'error', problems: err instanceof EditorError ? err.problems : [ui.t('error.generic')] });
623
727
  }
624
728
  finally {
625
729
  setBusy(null);
@@ -634,13 +738,13 @@ function SlotPanel({ slot, canPublish, canManageTests, canUploadMedia = false, d
634
738
  setBusy('discard');
635
739
  try {
636
740
  apply(await call(slotPath(slot.name, locale, '/discard'), { method: 'POST' }));
637
- setNotice('Changes discarded.');
741
+ setNotice(ui.t('notice.discarded'));
638
742
  setSave({ kind: 'idle' });
639
743
  onChange();
640
744
  }
641
745
  catch (err) {
642
746
  onSessionError(err);
643
- setSave({ kind: 'error', problems: err instanceof EditorError ? err.problems : ['Could not discard.'] });
747
+ setSave({ kind: 'error', problems: err instanceof EditorError ? err.problems : [ui.t('error.discard')] });
644
748
  }
645
749
  finally {
646
750
  setBusy(null);
@@ -665,23 +769,25 @@ function SlotPanel({ slot, canPublish, canManageTests, canUploadMedia = false, d
665
769
  setValues(next);
666
770
  latest.current = next;
667
771
  setConfirmDiscard(false);
668
- setNotice(`Filled ${seeded.map((f) => data.fields[f]?.label ?? f).join(', ')} from the page. Change what you need, then publish.`);
772
+ setNotice(ui.t('fill.done', { fields: ui.list(seeded.map((f) => fieldLabel(ui, data.fields[f], f))) }));
669
773
  };
670
774
  const dirty = Boolean(data?.unpublishedChanges) || save.kind === 'saving' || latest.current !== null;
671
- const title = data?.label || slot.name;
775
+ const title = pickLabel(ui.lang, data?.label, data?.labels) || slot.name;
672
776
  const approval = data?.approval ?? null;
673
- return (_jsx(PanelCaps.Provider, { value: { canUploadMedia }, children: _jsxs("div", { ref: panelRef, className: "vx-panel", role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, onKeyDown: (e) => {
777
+ return (_jsx(PanelCaps.Provider, { value: { canUploadMedia }, children: _jsxs("div", { ref: panelRef, className: "vx-panel", dir: ui.dir, lang: ui.lang, role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, onKeyDown: (e) => {
674
778
  if (e.key === 'Escape') {
675
779
  e.stopPropagation();
676
780
  close();
677
781
  }
678
- }, children: [_jsxs("div", { className: "vx-panel-head", children: [_jsxs("div", { children: [_jsx("h2", { id: titleId, children: title }), _jsxs("p", { className: "vx-muted", children: [title !== slot.name ? _jsx("code", { children: slot.name }) : null, locale ? _jsxs("span", { children: [" \u00B7 ", locale] }) : null, data ? _jsxs("span", { children: [" \u00B7 ", data.version ? `v${data.version} live` : 'never published'] }) : null] })] }), _jsx("button", { type: "button", className: "vx-icon", "aria-label": "Close", onClick: close, children: "\u00D7" })] }), _jsxs("div", { className: "vx-panel-body", children: [loadError ? _jsx("p", { role: "alert", children: loadError }) : null, !data && !loadError ? _jsx("p", { className: "vx-muted", children: "Loading\u2026" }) : null, data?.test ? (_jsxs("div", { className: "vx-test", children: [_jsxs("p", { className: "vx-test-title", children: [TEST_STATUS[data.test.status] ?? 'Test', ": ", data.test.name] }), _jsx("div", { className: "vx-tabs", role: "tablist", "aria-label": "Version to show and edit", onKeyDown: (e) => {
679
- // Arrow keys move between versions (one tab stop for the whole list).
782
+ }, children: [_jsxs("div", { className: "vx-panel-head", children: [_jsxs("div", { children: [_jsx("h2", { id: titleId, children: title }), _jsxs("p", { className: "vx-muted vx-slot-key", children: [title !== slot.name ? (_jsx("code", { children: _jsx("bdi", { children: slot.name }) })) : null, locale ? (_jsxs("span", { children: [' · ', _jsx("bdi", { children: locale })] })) : null, data ? (_jsxs("span", { children: [' · ', _jsx("bdi", { children: data.version ? ui.t('panel.live', { version: data.version }) : ui.t('panel.neverPublished') })] })) : null] })] }), _jsx("button", { type: "button", className: "vx-icon", "aria-label": ui.t('panel.close'), onClick: close, children: "\u00D7" })] }), _jsxs("div", { className: "vx-panel-body", children: [loadError ? _jsx("p", { role: "alert", children: loadError }) : null, !data && !loadError ? _jsx("p", { className: "vx-muted", children: ui.t('panel.loading') }) : null, data?.test ? (_jsxs("div", { className: "vx-test", children: [_jsxs("p", { className: "vx-test-title", children: [ui.t(TEST_STATUS[data.test.status] ?? 'test.generic'), ": ", _jsx("bdi", { children: data.test.name })] }), _jsx("div", { className: "vx-tabs", role: "tablist", "aria-label": ui.t('test.versions'), onKeyDown: (e) => {
783
+ // Arrow keys move between versions (one tab stop for the whole list); right to left, the arrows swap.
680
784
  const order = data.test.variants.map((v) => v.position);
681
785
  const at = order.indexOf(variant);
682
- const next = e.key === 'ArrowRight' || e.key === 'ArrowDown'
786
+ const forward = ui.dir === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
787
+ const back = ui.dir === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
788
+ const next = e.key === forward || e.key === 'ArrowDown'
683
789
  ? order[(at + 1) % order.length]
684
- : e.key === 'ArrowLeft' || e.key === 'ArrowUp'
790
+ : e.key === back || e.key === 'ArrowUp'
685
791
  ? order[(at - 1 + order.length) % order.length]
686
792
  : e.key === 'Home'
687
793
  ? order[0]
@@ -693,59 +799,66 @@ function SlotPanel({ slot, canPublish, canManageTests, canUploadMedia = false, d
693
799
  e.preventDefault();
694
800
  void selectVariant(next);
695
801
  e.currentTarget.querySelector(`[data-position="${next}"]`)?.focus();
696
- }, children: data.test.variants.map((v) => (_jsx("button", { type: "button", role: "tab", "data-position": v.position, "aria-selected": variant === v.position, tabIndex: variant === v.position ? 0 : -1, className: "vx-tab", onClick: () => void selectVariant(v.position), children: v.isControl ? 'Published' : v.label }, v.position))) }), variant > 0 ? (_jsx("p", { className: "vx-muted", children: data.test.editable && canManageTests
697
- ? 'The page shows this variant. Edits change only this variant; empty fields use the published version.'
698
- : data.test.editable
699
- ? 'The page shows this variant. Editing variants needs permission to manage experiments.'
700
- : 'The page shows this variant. Variants can’t change once the test has started.' })) : null] })) : null, data?.inherited && locale && !touched.current.size ? (_jsxs("p", { className: "vx-note", children: ["Nothing saved in ", locale, " yet; you\u2019re starting from the default language\u2019s published copy."] })) : null, fillable.length ? (_jsxs("div", { className: "vx-fill", children: [_jsxs("p", { className: "vx-muted", children: ["Empty here, but the page shows content for: ", fillable.map((f) => data?.fields[f]?.label ?? f).join(', '), "."] }), _jsx("button", { type: "button", className: "vx-btn", onClick: fillFromPage, children: "Fill empty fields from the page" })] })) : null, data
802
+ }, children: data.test.variants.map((v) => (_jsx("button", { type: "button", role: "tab", "data-position": v.position, "aria-selected": variant === v.position, tabIndex: variant === v.position ? 0 : -1, className: "vx-tab", onClick: () => void selectVariant(v.position), children: v.isControl ? ui.t('test.published') : _jsx("bdi", { children: v.label }) }, v.position))) }), variant > 0 ? (_jsx("p", { className: "vx-muted", children: data.test.editable && canManageTests ? ui.t('test.editable') : data.test.editable ? ui.t('test.noPermission') : ui.t('test.locked') })) : null] })) : null, data?.inherited && locale && !touched.current.size ? (_jsx("p", { className: "vx-note", children: ui.t('panel.inherited', { locale }) })) : null, fillable.length ? (_jsxs("div", { className: "vx-fill", children: [_jsx("p", { className: "vx-muted", children: ui.t('fill.offer', { fields: ui.list(fillable.map((f) => fieldLabel(ui, data?.fields[f], f))) }) }), _jsx("button", { type: "button", className: "vx-btn", onClick: fillFromPage, children: ui.t('fill.button') })] })) : null, data
701
803
  ? (variant > 0 && !(data.test?.editable && canManageTests) ? [] : Object.entries(data.fields)).map(([name, def]) => (_jsx(FieldInput, { name: name, def: def, value: values[name], shown: shown[name], fallback: fallback?.[name], onChange: (v) => change(name, v), onFocus: () => onFieldFocus(name) }, name)))
702
804
  : null] }), _jsxs("div", { className: "vx-panel-foot", children: [_jsx("p", { className: "vx-status", role: "status", "aria-live": "polite", children: save.kind === 'saving'
703
805
  ? variant > 0
704
- ? 'Saving variant…'
705
- : 'Saving draft…'
806
+ ? ui.t('status.savingVariant')
807
+ : ui.t('status.savingDraft')
706
808
  : save.kind === 'saved'
707
809
  ? variant > 0
708
- ? 'Variant saved'
709
- : 'Draft saved'
810
+ ? ui.t('status.variantSaved')
811
+ : ui.t('status.draftSaved')
710
812
  : save.kind === 'error'
711
813
  ? ''
712
814
  : latest.current !== null
713
- ? (notice ?? 'Editing… saves in a moment')
714
- : 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
715
- ? ` · step ${approval.steps.findIndex((st) => st.stepOrder === approval.currentStep) + 1} of ${approval.steps.length}`
716
- : ''] }), _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] })] })] }) }));
815
+ ? (notice ?? ui.t('status.editing'))
816
+ : notice ?? (data?.unpublishedChanges ? ui.t('status.unpublished') : data ? ui.t('status.clean') : '') }), 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: ui.t('test.settings') })) : null, _jsx("button", { type: "button", className: "vx-btn", onClick: () => void selectVariant(0), children: ui.t('test.back') })] })) : null, variant === 0 && approval?.pending ? (_jsxs("div", { className: "vx-review", role: "group", "aria-label": ui.t('approval.aria'), children: [_jsxs("p", { className: "vx-review-title", children: [ui.t('approval.waiting'), approval.steps.length > 1 && approval.currentStep !== null
817
+ ? ` · ${ui.t('approval.step', { n: approval.steps.findIndex((st) => st.stepOrder === approval.currentStep) + 1, total: approval.steps.length })}`
818
+ : ''] }), _jsxs("p", { className: "vx-muted", children: [approval.steps.find((st) => st.stepOrder === approval.currentStep)?.label, approval.submittedByName ? ` · ${ui.t('approval.sentBy', { name: approval.submittedByName })}` : ''] }), approval.changedSinceSubmission ? _jsx("p", { className: "vx-muted", children: ui.t('approval.changed') }) : null, approval.canAct ? (_jsxs(_Fragment, { children: [_jsx("label", { className: "vx-sublabel", htmlFor: `${titleId}-review`, children: ui.t('approval.comment') }), _jsx("textarea", { dir: "auto", 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'
819
+ ? ui.t('approval.approving')
820
+ : approval.steps[approval.steps.length - 1]?.stepOrder === approval.currentStep
821
+ ? ui.t('approval.approvePublish')
822
+ : ui.t('approval.approve') }), _jsx("button", { type: "button", className: "vx-btn", disabled: busy !== null || !reviewComment.trim(), onClick: () => act('reject', { comment: reviewComment }), children: busy === 'reject' ? ui.t('approval.rejecting') : ui.t('approval.reject') })] })] })) : approval.isSubmitter ? (_jsx("p", { className: "vx-muted", children: ui.t('approval.other') })) : null, approval.canWithdraw ? (_jsx("button", { type: "button", className: "vx-btn vx-review-withdraw", disabled: busy !== null, onClick: () => act('withdraw'), children: busy === 'withdraw' ? ui.t('approval.withdrawing') : ui.t('approval.withdraw') })) : 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'
823
+ ? approval?.required
824
+ ? ui.t('publish.sending')
825
+ : ui.t('publish.busy')
826
+ : approval?.required
827
+ ? ui.t('publish.send')
828
+ : ui.t('publish.button') })) : (_jsx("span", { className: "vx-muted", children: ui.t('publish.noPermission') })), data?.unpublishedChanges && data.version > 0 ? (_jsx("button", { type: "button", className: "vx-btn", disabled: busy !== null, onClick: discard, children: busy === 'discard' ? ui.t('discard.busy') : confirmDiscard ? ui.t('discard.confirm') : ui.t('discard.button') })) : null] })] })] }) }));
717
829
  }
718
830
  // ----------------------------------------------------------------- fields
719
831
  function stripTags(html) {
720
832
  return html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
721
833
  }
722
834
  function FieldInput({ name, def, value, shown, fallback, onChange, onFocus, }) {
835
+ const ui = useUi();
723
836
  const placeholder = typeof shown === 'string' && shown ? shown : undefined;
724
837
  const id = useId();
725
- const label = (_jsxs("label", { htmlFor: id, className: "vx-label", children: [def.label ?? name, def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }));
838
+ const label = (_jsxs("label", { htmlFor: id, className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }));
726
839
  const common = { id, 'data-field': name, onFocus, 'aria-required': def.required || undefined };
727
840
  switch (def.type) {
728
841
  case 'text': {
729
842
  const text = typeof value === 'string' ? value : '';
730
- return (_jsxs("div", { className: "vx-field", children: [label, _jsx("input", { ...common, type: "text", value: text, placeholder: placeholder, maxLength: def.max, onChange: (e) => onChange(e.target.value) }), def.max ? _jsxs("span", { className: "vx-count", children: [text.length, " / ", def.max] }) : null] }));
843
+ return (_jsxs("div", { className: "vx-field", children: [label, _jsx("input", { ...common, type: "text", dir: "auto", value: text, placeholder: placeholder, maxLength: def.max, onChange: (e) => onChange(e.target.value) }), def.max ? (_jsx("span", { className: "vx-count", children: _jsx("bdi", { dir: "ltr", children: ui.t('text.count', { n: text.length, max: def.max }) }) })) : null] }));
731
844
  }
732
845
  case 'richText': {
733
846
  const html = typeof value === 'string' ? value : '';
734
- return (_jsxs("div", { className: "vx-field", children: [_jsxs("span", { id: `${id}-label`, className: "vx-label", children: [def.label ?? name, def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsx(RichTextInput, { id: id, value: html, onChange: onChange, onFocus: onFocus, max: def.max, required: def.required, labelledBy: `${id}-label`, placeholder: placeholder ? stripTags(placeholder) : undefined, regionProps: { 'data-field': name } })] }));
847
+ return (_jsxs("div", { className: "vx-field", children: [_jsxs("span", { id: `${id}-label`, className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsx(RichTextInput, { id: id, value: html, onChange: onChange, onFocus: onFocus, max: def.max, required: def.required, labelledBy: `${id}-label`, placeholder: placeholder ? stripTags(placeholder) : undefined, regionProps: { 'data-field': name } })] }));
735
848
  }
736
849
  case 'number':
737
850
  return (_jsxs("div", { className: "vx-field", children: [label, _jsx("input", { ...common, type: "number", value: typeof value === 'number' ? value : '', onChange: (e) => onChange(e.target.value === '' ? null : Number(e.target.value)) })] }));
738
851
  case 'boolean':
739
852
  return (_jsxs("div", { className: "vx-field vx-check", children: [_jsx("input", { ...common, type: "checkbox", checked: typeof value === 'boolean' ? value : shown === true, onChange: (e) => onChange(e.target.checked) }), label] }));
740
853
  case 'select':
741
- return (_jsxs("div", { className: "vx-field", children: [label, _jsxs("select", { ...common, value: typeof value === 'string' ? value : typeof shown === 'string' ? shown : '', onChange: (e) => onChange(e.target.value || null), children: [!def.required ? _jsx("option", { value: "", children: "\u2014" }) : null, (def.options ?? []).map((o) => (_jsx("option", { value: o, children: o }, o)))] })] }));
854
+ return (_jsxs("div", { className: "vx-field", children: [label, _jsxs("select", { ...common, value: typeof value === 'string' ? value : typeof shown === 'string' ? shown : '', onChange: (e) => onChange(e.target.value || null), children: [!def.required ? _jsx("option", { value: "", children: "\u2014" }) : null, (def.options ?? []).map((o) => (_jsx("option", { value: o, children: pickLabel(ui.lang, undefined, def.optionLabels?.[o]) ?? o }, o)))] })] }));
742
855
  case 'link': {
743
856
  const link = (value && typeof value === 'object' ? value : { label: '', href: '' });
744
857
  const set = (patch) => {
745
858
  const next = { ...link, ...patch };
746
859
  onChange(next.label || next.href ? next : null);
747
860
  };
748
- 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] }), _jsx("label", { htmlFor: `${id}-label`, className: "vx-sublabel", children: "Text" }), _jsx("input", { id: `${id}-label`, "data-field": name, onFocus: onFocus, type: "text", value: link.label, onChange: (e) => set({ label: e.target.value }) }), _jsx("label", { htmlFor: `${id}-href`, className: "vx-sublabel", children: "Address" }), _jsx("input", { id: `${id}-href`, onFocus: onFocus, type: "text", inputMode: "url", placeholder: "https://\u2026 or /page", value: link.href, onChange: (e) => set({ href: e.target.value }) })] }));
861
+ return (_jsxs("fieldset", { className: "vx-field vx-fieldset", children: [_jsxs("legend", { className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsx("label", { htmlFor: `${id}-label`, className: "vx-sublabel", children: ui.t('link.text') }), _jsx("input", { id: `${id}-label`, "data-field": name, onFocus: onFocus, type: "text", dir: "auto", value: link.label, onChange: (e) => set({ label: e.target.value }) }), _jsx("label", { htmlFor: `${id}-href`, className: "vx-sublabel", children: ui.t('link.address') }), _jsx("input", { id: `${id}-href`, onFocus: onFocus, type: "text", dir: "auto", inputMode: "url", placeholder: ui.t('common.pagePlaceholder'), value: link.href, onChange: (e) => set({ href: e.target.value }) })] }));
749
862
  }
750
863
  case 'media':
751
864
  return _jsx(MediaInput, { name: name, def: def, value: value, fallback: fallback, onChange: onChange, onFocus: onFocus });
@@ -756,20 +869,21 @@ function FieldInput({ name, def, value, shown, fallback, onChange, onFocus, }) {
756
869
  case 'map':
757
870
  return _jsx(MapInput, { name: name, def: def, value: value, onChange: onChange, onFocus: onFocus });
758
871
  case 'slides':
759
- return _jsx(SlidesInput, { name: name, def: def, value: value, onChange: onChange, onFocus: onFocus });
872
+ return _jsx(SlidesInput, { name: name, def: def, value: value, fallback: fallback, onChange: onChange, onFocus: onFocus });
760
873
  case 'menu':
761
- 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 });
874
+ return _jsx(MenuInput, { name: name, label: fieldLabel(ui, def, name), required: def.required, depth: def.depth ?? 2, icons: def.icons, value: value, onChange: onChange, onFocus: onFocus });
762
875
  case 'list':
763
- return _jsx(ListInput, { name: name, def: def, value: value, onChange: onChange, onFocus: onFocus });
876
+ return _jsx(ListInput, { name: name, def: def, value: value, fallback: fallback, onChange: onChange, onFocus: onFocus });
764
877
  case 'component':
765
- return _jsx(ComponentInput, { name: name, def: def, value: value, onChange: onChange, onFocus: onFocus });
878
+ return _jsx(ComponentInput, { name: name, def: def, value: value, fallback: fallback, onChange: onChange, onFocus: onFocus });
766
879
  }
767
880
  }
768
881
  /**
769
882
  * A component field: choose one of the components the developer registered for this place, then fill in that
770
883
  * component's own fields. Switching components keeps what was typed into fields both have (same name and type).
771
884
  */
772
- function ComponentInput({ name, def, value, onChange, onFocus }) {
885
+ function ComponentInput({ name, def, value, fallback, onChange, onFocus }) {
886
+ const ui = useUi();
773
887
  const id = useId();
774
888
  const components = def.components ?? {};
775
889
  const current = asComponentValue(value);
@@ -788,11 +902,12 @@ function ComponentInput({ name, def, value, onChange, onFocus }) {
788
902
  }
789
903
  onChange({ component: next, version: target.version, values: carried });
790
904
  };
791
- 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] }), _jsx("label", { htmlFor: id, className: "vx-sublabel", children: "Component" }), _jsxs("select", { id: id, "data-field": name, onFocus: onFocus, value: chosen?.component ?? '', onChange: (e) => pick(e.target.value), children: [_jsx("option", { value: "", children: def.required ? 'Choose a component' : 'None (the site’s default)' }), Object.entries(components).map(([n, c]) => (_jsx("option", { value: n, children: c.label ?? n }, n)))] }), chosen && schema
792
- ? Object.entries(schema.fields).map(([f, d]) => (_jsx(FieldInput, { name: `${name}.${f}`, def: d, value: chosen.values?.[f], onChange: (v) => onChange({ ...chosen, version: schema.version, values: { ...(chosen.values ?? {}), [f]: v } }), onFocus: onFocus }, `${chosen.component}.${f}`)))
905
+ return (_jsxs("fieldset", { className: "vx-field vx-fieldset", children: [_jsxs("legend", { className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsx("label", { htmlFor: id, className: "vx-sublabel", children: ui.t('component.label') }), _jsxs("select", { id: id, "data-field": name, onFocus: onFocus, value: chosen?.component ?? '', onChange: (e) => pick(e.target.value), children: [_jsx("option", { value: "", children: def.required ? ui.t('component.choose') : ui.t('component.none') }), Object.entries(components).map(([n, c]) => (_jsx("option", { value: n, children: pickLabel(ui.lang, c.label, c.labels) ?? n }, n)))] }), chosen && schema
906
+ ? Object.entries(schema.fields).map(([f, d]) => (_jsx(FieldInput, { name: `${name}.${f}`, def: d, value: chosen.values?.[f], fallback: asComponentValue(fallback)?.component === chosen.component ? asComponentValue(fallback)?.values?.[f] : undefined, onChange: (v) => onChange({ ...chosen, version: schema.version, values: { ...(chosen.values ?? {}), [f]: v } }), onFocus: onFocus }, `${chosen.component}.${f}`)))
793
907
  : null] }));
794
908
  }
795
909
  function VideoInput({ name, def, value, onChange, onFocus }) {
910
+ const ui = useUi();
796
911
  const id = useId();
797
912
  const video = (value && typeof value === 'object' ? value : { url: typeof value === 'string' ? value : '' });
798
913
  const url = video.url ?? '';
@@ -803,17 +918,30 @@ function VideoInput({ name, def, value, onChange, onFocus }) {
803
918
  delete next.title;
804
919
  onChange(next.url || next.title ? next : null);
805
920
  };
806
- 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] }), _jsx("label", { htmlFor: `${id}-url`, className: "vx-sublabel", children: "YouTube or Vimeo link, or a video file" }), _jsx("input", { id: `${id}-url`, "data-field": name, onFocus: onFocus, type: "text", inputMode: "url", placeholder: "https://www.youtube.com/watch?v=\u2026", value: url, "aria-describedby": `${id}-status`, onChange: (e) => set({ url: e.target.value }) }), _jsx("span", { id: `${id}-status`, className: "vx-count", "aria-live": "polite", children: !url ? 'The page shows it as a player.' : ref ? `${ref.provider === 'youtube' ? 'YouTube' : ref.provider === 'vimeo' ? 'Vimeo' : 'Video file'}: recognised.` : 'Not a video link VeroXM can play.' }), _jsx("label", { htmlFor: `${id}-title`, className: "vx-sublabel", children: "Title" }), _jsx("input", { id: `${id}-title`, onFocus: onFocus, type: "text", maxLength: 120, value: video.title ?? '', onChange: (e) => set({ title: e.target.value }) })] }));
921
+ return (_jsxs("fieldset", { className: "vx-field vx-fieldset", children: [_jsxs("legend", { className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsx("label", { htmlFor: `${id}-url`, className: "vx-sublabel", children: ui.t('video.url') }), _jsx("input", { id: `${id}-url`, "data-field": name, onFocus: onFocus, type: "text", dir: "auto", inputMode: "url", placeholder: "https://www.youtube.com/watch?v=\u2026", value: url, "aria-describedby": `${id}-status`, onChange: (e) => set({ url: e.target.value }) }), _jsx("span", { id: `${id}-status`, className: "vx-count", "aria-live": "polite", children: !url
922
+ ? ui.t('video.empty')
923
+ : ref
924
+ ? ui.t('video.recognised', { provider: ref.provider === 'youtube' ? 'YouTube' : ref.provider === 'vimeo' ? 'Vimeo' : ui.t('video.file') })
925
+ : ui.t('video.bad') }), _jsx("label", { htmlFor: `${id}-title`, className: "vx-sublabel", children: ui.t('common.title') }), _jsx("input", { id: `${id}-title`, onFocus: onFocus, type: "text", dir: "auto", maxLength: 120, value: video.title ?? '', onChange: (e) => set({ title: e.target.value }) })] }));
807
926
  }
808
- const KIND_NAMES = { bar: 'Columns', hbar: 'Bars', line: 'Line', area: 'Area', pie: 'Pie', donut: 'Donut', kpi: 'Key figure' };
927
+ const KIND_NAMES = {
928
+ bar: 'chart.kind.bar',
929
+ hbar: 'chart.kind.hbar',
930
+ line: 'chart.kind.line',
931
+ area: 'chart.kind.area',
932
+ pie: 'chart.kind.pie',
933
+ donut: 'chart.kind.donut',
934
+ kpi: 'chart.kind.kpi',
935
+ };
809
936
  function ChartInput({ name, def, value, onChange, onFocus }) {
937
+ const ui = useUi();
810
938
  const id = useId();
811
939
  const chart = (value && typeof value === 'object' ? value : { kind: 'bar', labels: [], series: [], source: { type: 'manual' } });
812
940
  const [text, setText] = useState(null);
813
941
  const [error, setError] = useState(null);
814
942
  const set = (patch) => onChange({ ...chart, ...patch });
815
943
  const typed = chart.source.type === 'manual';
816
- 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] }), chart.sample ? _jsx("p", { className: "vx-note", children: "These are the template's sample numbers. Put in your own before publishing." }) : null, _jsx("label", { htmlFor: `${id}-kind`, className: "vx-sublabel", children: "Kind" }), _jsx("select", { id: `${id}-kind`, "data-field": name, onFocus: onFocus, value: chart.kind, onChange: (e) => set({ kind: e.target.value }), children: CHART_KINDS.map((k) => (_jsx("option", { value: k, children: KIND_NAMES[k] }, k))) }), _jsx("label", { htmlFor: `${id}-title`, className: "vx-sublabel", children: "Title" }), _jsx("input", { id: `${id}-title`, onFocus: onFocus, type: "text", maxLength: 120, value: chart.title ?? '', onChange: (e) => set({ title: e.target.value }) }), typed ? (_jsxs(_Fragment, { children: [_jsx("label", { htmlFor: `${id}-data`, className: "vx-sublabel", children: "Numbers: paste from a spreadsheet, or type a row per label" }), _jsx("textarea", { id: `${id}-data`, onFocus: onFocus, rows: Math.min(12, chart.labels.length + 2), value: text ?? chartTableText(chart), "aria-describedby": `${id}-data-note`, onChange: (e) => {
944
+ return (_jsxs("fieldset", { className: "vx-field vx-fieldset", children: [_jsxs("legend", { className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), chart.sample ? _jsx("p", { className: "vx-note", children: ui.t('chart.sample') }) : null, _jsx("label", { htmlFor: `${id}-kind`, className: "vx-sublabel", children: ui.t('chart.kind') }), _jsx("select", { id: `${id}-kind`, "data-field": name, onFocus: onFocus, value: chart.kind, onChange: (e) => set({ kind: e.target.value }), children: CHART_KINDS.map((k) => (_jsx("option", { value: k, children: ui.t(KIND_NAMES[k]) }, k))) }), _jsx("label", { htmlFor: `${id}-title`, className: "vx-sublabel", children: ui.t('common.title') }), _jsx("input", { id: `${id}-title`, onFocus: onFocus, type: "text", dir: "auto", maxLength: 120, value: chart.title ?? '', onChange: (e) => set({ title: e.target.value }) }), typed ? (_jsxs(_Fragment, { children: [_jsx("label", { htmlFor: `${id}-data`, className: "vx-sublabel", children: ui.t('chart.numbers') }), _jsx("textarea", { id: `${id}-data`, onFocus: onFocus, rows: Math.min(12, chart.labels.length + 2), value: text ?? chartTableText(chart), "aria-describedby": `${id}-data-note`, onChange: (e) => {
817
945
  setText(e.target.value);
818
946
  const parsed = parseChartTable(e.target.value);
819
947
  if ('error' in parsed)
@@ -822,9 +950,14 @@ function ChartInput({ name, def, value, onChange, onFocus }) {
822
950
  setError(null);
823
951
  onChange({ ...chart, labels: parsed.labels, series: parsed.series, sample: undefined });
824
952
  }
825
- }, onBlur: () => !error && setText(null) }), _jsx("span", { id: `${id}-data-note`, className: error ? 'vx-errors' : 'vx-count', "aria-live": "polite", children: error ?? 'First row: Label, then a name for each series.' })] })) : (_jsxs("p", { className: "vx-muted", children: [chart.source.type === 'analytics' ? 'The numbers come from VeroXM analytics' : chart.source.type === 'content' ? `The numbers come from the “${chart.source.collection}” collection` : 'The numbers come from your API', " and fill in when the page loads. Change where they come from in the dashboard."] })), _jsxs("div", { className: "vx-menu-row", children: [_jsx("input", { "aria-label": "Before numbers, such as $", placeholder: "Before (SAR )", onFocus: onFocus, type: "text", maxLength: 8, value: chart.format?.prefix ?? '', onChange: (e) => set({ format: { ...chart.format, prefix: e.target.value || undefined } }) }), _jsx("input", { "aria-label": "After numbers, such as %", placeholder: "After ( SAR, %)", onFocus: onFocus, type: "text", maxLength: 12, value: chart.format?.suffix ?? '', onChange: (e) => set({ format: { ...chart.format, suffix: e.target.value || undefined } }) })] }), _jsx("label", { htmlFor: `${id}-caption`, className: "vx-sublabel", children: "Caption" }), _jsx("input", { id: `${id}-caption`, onFocus: onFocus, type: "text", maxLength: 300, value: chart.caption ?? '', onChange: (e) => set({ caption: e.target.value }) })] }));
953
+ }, onBlur: () => !error && setText(null) }), _jsx("span", { id: `${id}-data-note`, className: error ? 'vx-errors' : 'vx-count', "aria-live": "polite", children: error ?? ui.t('chart.firstRow') })] })) : (_jsx("p", { className: "vx-muted", children: chart.source.type === 'analytics'
954
+ ? ui.t('chart.fromAnalytics')
955
+ : chart.source.type === 'content'
956
+ ? ui.t('chart.fromContent', { collection: chart.source.collection })
957
+ : ui.t('chart.fromApi') })), _jsxs("div", { className: "vx-menu-row", children: [_jsx("input", { "aria-label": ui.t('chart.prefix'), placeholder: ui.t('chart.prefixPlaceholder'), onFocus: onFocus, type: "text", dir: "auto", maxLength: 8, value: chart.format?.prefix ?? '', onChange: (e) => set({ format: { ...chart.format, prefix: e.target.value || undefined } }) }), _jsx("input", { "aria-label": ui.t('chart.suffix'), placeholder: ui.t('chart.suffixPlaceholder'), onFocus: onFocus, type: "text", dir: "auto", maxLength: 12, value: chart.format?.suffix ?? '', onChange: (e) => set({ format: { ...chart.format, suffix: e.target.value || undefined } }) })] }), _jsx("label", { htmlFor: `${id}-caption`, className: "vx-sublabel", children: ui.t('chart.caption') }), _jsx("input", { id: `${id}-caption`, onFocus: onFocus, type: "text", dir: "auto", maxLength: 300, value: chart.caption ?? '', onChange: (e) => set({ caption: e.target.value }) })] }));
826
958
  }
827
959
  function MapInput({ name, def, value, onChange, onFocus }) {
960
+ const ui = useUi();
828
961
  const id = useId();
829
962
  const map = (value && typeof value === 'object' ? value : { places: [] });
830
963
  const places = Array.isArray(map.places) ? map.places : [];
@@ -837,35 +970,36 @@ function MapInput({ name, def, value, onChange, onFocus }) {
837
970
  setSearch({ at: i, q, results: null, error: null, busy: true });
838
971
  try {
839
972
  const r = await call(`geocode?q=${encodeURIComponent(q)}`);
840
- setSearch({ at: i, q, results: r.results, error: r.results.length ? null : 'Nothing found. Try a fuller address, or paste a map link.', busy: false });
973
+ setSearch({ at: i, q, results: r.results, error: r.results.length ? null : ui.t('map.nothingFound'), busy: false });
841
974
  }
842
975
  catch (err) {
843
- setSearch({ at: i, q, results: null, error: err instanceof EditorError ? err.problems.join(' ') : 'Address search failed.', busy: false });
976
+ setSearch({ at: i, q, results: null, error: err instanceof EditorError ? err.problems.join(' ') : ui.t('map.searchFailed'), busy: false });
844
977
  }
845
978
  };
846
- 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: [places.length, " / ", max, " places"] }), places.map((place, i) => {
847
- const title = place.name.trim() || `place ${i + 1}`;
979
+ return (_jsxs("fieldset", { className: "vx-field vx-fieldset", children: [_jsxs("legend", { className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsx("span", { className: "vx-count", children: ui.t('map.count', { n: places.length, max }) }), places.map((place, i) => {
980
+ const title = place.name.trim() || ui.t('map.placeN', { n: i + 1 });
848
981
  const located = place.lat !== null && place.lng !== null && Number.isFinite(place.lat) && Number.isFinite(place.lng);
849
982
  const q = search?.at === i ? search.q : (place.address ?? '');
850
- return (_jsxs("div", { className: "vx-slide-card", children: [_jsx("label", { htmlFor: `${id}-${i}-name`, className: "vx-sublabel", children: "Name" }), _jsx("input", { id: `${id}-${i}-name`, "data-field": i === 0 ? name : undefined, onFocus: onFocus, type: "text", maxLength: 80, value: place.name, onChange: (e) => update(i, { name: e.target.value }) }), _jsx("label", { htmlFor: `${id}-${i}-address`, className: "vx-sublabel", children: "Address" }), _jsxs("div", { className: "vx-menu-row", children: [_jsx("input", { id: `${id}-${i}-address`, onFocus: onFocus, type: "text", maxLength: 200, value: place.address ?? '', onChange: (e) => update(i, { address: e.target.value }), onKeyDown: (e) => {
983
+ return (_jsxs("div", { className: "vx-slide-card", children: [_jsx("label", { htmlFor: `${id}-${i}-name`, className: "vx-sublabel", children: ui.t('common.name') }), _jsx("input", { id: `${id}-${i}-name`, "data-field": i === 0 ? name : undefined, onFocus: onFocus, type: "text", dir: "auto", maxLength: 80, value: place.name, onChange: (e) => update(i, { name: e.target.value }) }), _jsx("label", { htmlFor: `${id}-${i}-address`, className: "vx-sublabel", children: ui.t('common.address') }), _jsxs("div", { className: "vx-menu-row", children: [_jsx("input", { id: `${id}-${i}-address`, onFocus: onFocus, type: "text", dir: "auto", maxLength: 200, value: place.address ?? '', onChange: (e) => update(i, { address: e.target.value }), onKeyDown: (e) => {
851
984
  if (e.key === 'Enter') {
852
985
  e.preventDefault();
853
986
  void find(i, (place.address ?? '').trim());
854
987
  }
855
- } }), _jsx("button", { type: "button", className: "vx-btn", disabled: (place.address ?? '').trim().length < 3 || (search?.at === i && search.busy), onClick: () => void find(i, (place.address ?? '').trim()), children: search?.at === i && search.busy ? 'Finding…' : 'Find on map' })] }), search?.at === i && (search.results?.length || search.error) ? (_jsxs("div", { className: "vx-picker", role: "group", "aria-label": `Places matching ${q}`, children: [search.error ? _jsx("p", { className: "vx-errors", children: search.error }) : null, search.results?.map((r, k) => (_jsxs("button", { type: "button", className: "vx-result", onClick: () => {
988
+ } }), _jsx("button", { type: "button", className: "vx-btn", disabled: (place.address ?? '').trim().length < 3 || (search?.at === i && search.busy), onClick: () => void find(i, (place.address ?? '').trim()), children: search?.at === i && search.busy ? ui.t('map.finding') : ui.t('map.find') })] }), search?.at === i && (search.results?.length || search.error) ? (_jsxs("div", { className: "vx-picker", role: "group", "aria-label": ui.t('map.matches', { q }), children: [search.error ? _jsx("p", { className: "vx-errors", children: search.error }) : null, search.results?.map((r, k) => (_jsxs("button", { type: "button", className: "vx-result", onClick: () => {
856
989
  update(i, { lat: r.lat, lng: r.lng, ...(place.name.trim() ? {} : { name: r.name }), address: place.address?.trim() ? place.address : r.address });
857
990
  setSearch(null);
858
- }, children: [_jsx("strong", { children: r.name }), " ", _jsx("span", { className: "vx-muted", children: r.address })] }, k))), _jsx("span", { className: "vx-count", children: "Search by OpenStreetMap Nominatim" })] })) : null, _jsx("label", { htmlFor: `${id}-${i}-pos`, className: "vx-sublabel", children: "Position: coordinates or a map link" }), _jsx("input", { id: `${id}-${i}-pos`, onFocus: onFocus, type: "text", placeholder: "24.7136, 46.6753", value: pasted[i] ?? (located ? `${place.lat}, ${place.lng}` : ''), "aria-describedby": `${id}-${i}-pos-note`, onChange: (e) => {
991
+ }, children: [_jsx("strong", { children: r.name }), " ", _jsx("span", { className: "vx-muted", children: r.address })] }, k))), _jsx("span", { className: "vx-count", children: ui.t('map.attribution') })] })) : null, _jsx("label", { htmlFor: `${id}-${i}-pos`, className: "vx-sublabel", children: ui.t('map.position') }), _jsx("input", { id: `${id}-${i}-pos`, onFocus: onFocus, type: "text", placeholder: "24.7136, 46.6753", dir: "ltr", value: pasted[i] ?? (located ? `${place.lat}, ${place.lng}` : ''), "aria-describedby": `${id}-${i}-pos-note`, onChange: (e) => {
859
992
  setPasted({ ...pasted, [i]: e.target.value });
860
993
  const p = parseMapLink(e.target.value);
861
994
  if (p)
862
995
  update(i, { lat: p.lat, lng: p.lng });
863
996
  else if (!e.target.value.trim())
864
997
  update(i, { lat: null, lng: null });
865
- }, onBlur: () => setPasted(({ [i]: _gone, ...rest }) => rest) }), _jsx("span", { id: `${id}-${i}-pos-note`, className: "vx-count", children: located ? 'On the map.' : 'Not placed yet: find the address, or paste coordinates or a link from a map site.' }), _jsx("div", { className: "vx-menu-tools", children: _jsx("button", { type: "button", className: "vx-mini", "aria-label": `Remove ${title}`, onClick: () => set(places.filter((_, j) => j !== i)), children: "Remove" }) })] }, i));
866
- }), _jsx("div", { className: "vx-actions", children: _jsx("button", { type: "button", className: "vx-btn", "data-field": places.length ? undefined : name, onFocus: onFocus, disabled: places.length >= max, onClick: () => set([...places, { lat: null, lng: null, name: '' }]), children: "Add place" }) })] }));
998
+ }, onBlur: () => setPasted(({ [i]: _gone, ...rest }) => rest) }), _jsx("span", { id: `${id}-${i}-pos-note`, className: "vx-count", children: located ? ui.t('map.placed') : ui.t('map.notPlaced') }), _jsx("div", { className: "vx-menu-tools", children: _jsx("button", { type: "button", className: "vx-mini", "aria-label": ui.t('common.removeItem', { title }), onClick: () => set(places.filter((_, j) => j !== i)), children: ui.t('common.remove') }) })] }, i));
999
+ }), _jsx("div", { className: "vx-actions", children: _jsx("button", { type: "button", className: "vx-btn", "data-field": places.length ? undefined : name, onFocus: onFocus, disabled: places.length >= max, onClick: () => set([...places, { lat: null, lng: null, name: '' }]), children: ui.t('map.add') }) })] }));
867
1000
  }
868
- function SlidesInput({ name, def, value, onChange, onFocus }) {
1001
+ function SlidesInput({ name, def, value, fallback, onChange, onFocus }) {
1002
+ const ui = useUi();
869
1003
  const id = useId();
870
1004
  const slides = Array.isArray(value) ? value : [];
871
1005
  const max = def.max ?? 10;
@@ -879,27 +1013,44 @@ function SlidesInput({ name, def, value, onChange, onFocus }) {
879
1013
  [next[i], next[to]] = [next[to], next[i]];
880
1014
  set(next);
881
1015
  };
882
- 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: [slides.length, " / ", max, " slides"] }), slides.map((slide, i) => {
883
- const title = slide.title?.trim() || `slide ${i + 1}`;
884
- 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));
885
- }), _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" }) })] }));
1016
+ return (_jsxs("fieldset", { className: "vx-field vx-fieldset", children: [_jsxs("legend", { className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsx("span", { className: "vx-count", children: ui.t('slides.count', { n: slides.length, max }) }), slides.map((slide, i) => {
1017
+ const title = slide.title?.trim() || ui.t('slides.slideN', { n: i + 1 });
1018
+ return (_jsxs("div", { className: "vx-slide-card", children: [_jsx(MediaInput, { name: i === 0 ? name : `${name}-${i}`, def: { type: 'media', label: ui.t('slides.image', { n: i + 1 }), required: true }, value: slide.image, fallback: Array.isArray(fallback) ? fallback[i]?.image : undefined, onChange: (v) => update(i, { image: v }), onFocus: onFocus }), _jsx("label", { htmlFor: `${id}-${i}-title`, className: "vx-sublabel", children: ui.t('common.title') }), _jsx("input", { id: `${id}-${i}-title`, onFocus: onFocus, type: "text", dir: "auto", maxLength: 120, value: slide.title ?? '', onChange: (e) => update(i, { title: e.target.value }) }), _jsx("label", { htmlFor: `${id}-${i}-text`, className: "vx-sublabel", children: ui.t('common.text') }), _jsx("textarea", { dir: "auto", 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": ui.t('slides.buttonTextOf', { title }), placeholder: ui.t('slides.buttonText'), onFocus: onFocus, type: "text", dir: "auto", value: slide.link?.label ?? '', onChange: (e) => update(i, { link: { label: e.target.value, href: slide.link?.href ?? '' } }) }), _jsx("input", { "aria-label": ui.t('slides.buttonLinkOf', { title }), placeholder: ui.t('common.pagePlaceholderShort'), inputMode: "url", onFocus: onFocus, type: "text", dir: "auto", 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": ui.t('common.moveEarlier', { title }), onClick: () => move(i, -1), children: "\u2191" }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === slides.length - 1, "aria-label": ui.t('common.moveLater', { title }), onClick: () => move(i, 1), children: "\u2193" }), _jsx("button", { type: "button", className: "vx-mini", "aria-label": ui.t('common.removeItem', { title }), onClick: () => set(slides.filter((_, j) => j !== i)), children: ui.t('common.remove') })] })] }, i));
1019
+ }), _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: ui.t('slides.add') }) })] }));
886
1020
  }
887
- /** A short name for a list item: its first text field's value, or "Item 3". */
888
- function itemTitle(fields, item, i) {
889
- for (const [f, d] of Object.entries(fields)) {
890
- const v = item[f];
891
- if (d.type === 'text' && typeof v === 'string' && v.trim())
892
- return v.trim().slice(0, 40);
893
- if (d.type === 'link' && v && typeof v === 'object' && typeof v.label === 'string' && v.label.trim())
894
- return v.label.trim().slice(0, 40);
1021
+ /** The text a list item shows for a field: a text field's value, or a link's text. */
1022
+ function itemText(def, v) {
1023
+ if (def?.type === 'text' && typeof v === 'string' && v.trim())
1024
+ return v.trim().slice(0, 40);
1025
+ if (def?.type === 'link' && v && typeof v === 'object' && typeof v.label === 'string' && v.label.trim()) {
1026
+ return v.label.trim().slice(0, 40);
1027
+ }
1028
+ return null;
1029
+ }
1030
+ /**
1031
+ * A short name for a collapsed list item: the list's titleField, else its first required text field, else its first
1032
+ * text field (a link's text counts), else "Item 3".
1033
+ */
1034
+ export function itemTitle(fields, item, i, titleField, ui = currentUi) {
1035
+ const entries = Object.entries(fields);
1036
+ const order = [
1037
+ ...(titleField && fields[titleField] ? [titleField] : []),
1038
+ ...entries.filter(([, d]) => d.type === 'text' && d.required).map(([f]) => f),
1039
+ ...entries.map(([f]) => f),
1040
+ ];
1041
+ for (const f of order) {
1042
+ const text = itemText(fields[f], item[f]);
1043
+ if (text)
1044
+ return text;
895
1045
  }
896
- return `Item ${i + 1}`;
1046
+ return ui.t('list.itemN', { n: i + 1 });
897
1047
  }
898
1048
  /**
899
1049
  * A list field: items to add, remove and reorder, each with the list's own fields (the same inputs as a slot's), and
900
1050
  * with schedule, the first and last day it shows on. Items open one at a time, so a long list stays short on screen.
901
1051
  */
902
- function ListInput({ name, def, value, onChange, onFocus }) {
1052
+ function ListInput({ name, def, value, fallback, onChange, onFocus }) {
1053
+ const ui = useUi();
903
1054
  const id = useId();
904
1055
  const items = Array.isArray(value) ? value : [];
905
1056
  const fields = def.fields ?? {};
@@ -916,19 +1067,20 @@ function ListInput({ name, def, value, onChange, onFocus }) {
916
1067
  set(next);
917
1068
  setOpenItem((o) => (o === i ? to : o === to ? i : o));
918
1069
  };
919
- 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) => {
920
- const title = itemTitle(fields, item, i);
1070
+ return (_jsxs("fieldset", { className: "vx-field vx-fieldset", children: [_jsxs("legend", { className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsx("span", { className: "vx-count", children: ui.t('list.count', { n: items.length, max }) }), items.map((item, i) => {
1071
+ const title = itemTitle(fields, item, i, def.titleField, ui);
921
1072
  const isOpen = openItem === i;
922
- 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: () => {
1073
+ 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 ? '▾' : ui.dir === 'rtl' ? '◂' : '▸', " ", _jsx("bdi", { children: title })] }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === 0, "aria-label": ui.t('common.moveEarlier', { title }), onClick: () => move(i, -1), children: "\u2191" }), _jsx("button", { type: "button", className: "vx-mini", disabled: i === items.length - 1, "aria-label": ui.t('common.moveLater', { title }), onClick: () => move(i, 1), children: "\u2193" }), _jsx("button", { type: "button", className: "vx-mini", "aria-label": ui.t('common.removeItem', { title }), onClick: () => {
923
1074
  set(items.filter((_, j) => j !== i));
924
1075
  setOpenItem(null);
925
- }, 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));
1076
+ }, children: ui.t('common.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, fallback: fallbackItem(fields, item, i, fallback)?.[f], onChange: (v) => update(i, { [f]: v }), onFocus: onFocus }, f))), def.schedule ? (_jsxs("div", { className: "vx-menu-row", children: [_jsxs("label", { className: "vx-sublabel", children: [ui.t('list.showsFrom'), _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: [ui.t('list.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));
926
1077
  }), _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: () => {
927
1078
  set([...items, {}]);
928
1079
  setOpenItem(items.length);
929
- }, children: "Add item" }) })] }));
1080
+ }, children: ui.t('list.add') }) })] }));
930
1081
  }
931
1082
  function MediaInput({ name, def, value, fallback, onChange, onFocus, }) {
1083
+ const ui = useUi();
932
1084
  const { canUploadMedia } = useContext(PanelCaps);
933
1085
  const [importing, setImporting] = useState(false);
934
1086
  const [importError, setImportError] = useState(null);
@@ -944,12 +1096,12 @@ function MediaInput({ name, def, value, fallback, onChange, onFocus, }) {
944
1096
  const res = await fetch(importable.href, { credentials: 'same-origin' });
945
1097
  const blob = res.ok ? await res.blob() : null;
946
1098
  if (!blob || !blob.type.startsWith('image/'))
947
- throw new EditorError(res.status, ['That address didn’t return an image.']);
1099
+ throw new EditorError(res.status, [ui.t('media.notImage')]);
948
1100
  const m = await call('media', { method: 'POST', body: { fileName: importable.pathname, data: await toBase64(blob), alt: fromCode.alt } });
949
1101
  onChange({ id: m.id, url: m.url, alt: m.alt });
950
1102
  }
951
1103
  catch (err) {
952
- setImportError(err instanceof EditorError ? err.problems.join(' ') : 'Could not import the image.');
1104
+ setImportError(err instanceof EditorError ? err.problems.join(' ') : ui.t('media.importFailed'));
953
1105
  }
954
1106
  finally {
955
1107
  setImporting(false);
@@ -970,11 +1122,11 @@ function MediaInput({ name, def, value, fallback, onChange, onFocus, }) {
970
1122
  setItems(r.data);
971
1123
  setError(null);
972
1124
  })
973
- .catch((err) => setError(err instanceof EditorError ? err.problems.join(' ') : 'Could not load images.'));
1125
+ .catch((err) => setError(err instanceof EditorError ? err.problems.join(' ') : currentUi.t('media.loadFailed')));
974
1126
  }, 250);
975
1127
  return () => clearTimeout(t);
976
1128
  }, [picking, search]);
977
- return (_jsxs("div", { className: "vx-field", role: "group", "aria-labelledby": labelId, children: [_jsxs("span", { id: labelId, className: "vx-label", children: [def.label ?? name, def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), value?.url ? (_jsx("img", { className: "vx-preview", src: value.url, alt: value.alt ?? '' })) : fromCode ? (_jsxs(_Fragment, { children: [_jsx("img", { className: "vx-preview", src: fromCode.url, alt: fromCode.alt }), _jsxs("p", { className: "vx-muted", children: ["Shown from the site\u2019s code. It isn\u2019t in the media library, so it can\u2019t be saved with the slot", canUploadMedia && importable ? ' until you import it' : '', "."] }), canUploadMedia && importable ? (_jsx("div", { className: "vx-actions", children: _jsx("button", { type: "button", className: "vx-btn", disabled: importing, onClick: () => void importIntoMedia(), children: importing ? 'Importing…' : 'Import into Media' }) })) : null, importError ? _jsx("p", { role: "alert", children: importError }) : null] })) : (_jsx("p", { className: "vx-muted", children: "No image chosen." })), _jsxs("div", { className: "vx-actions", children: [_jsx("button", { type: "button", className: "vx-btn", "data-field": name, onFocus: onFocus, "aria-expanded": picking, onClick: () => setPicking((p) => !p), children: picking ? 'Close library' : value ? 'Replace image' : 'Choose image' }), value && !def.required ? (_jsx("button", { type: "button", className: "vx-btn", onClick: () => onChange(null), children: "Remove" })) : null] }), picking ? (_jsxs("div", { className: "vx-picker", children: [_jsx("label", { htmlFor: searchId, className: "vx-sublabel", children: "Search the media library" }), _jsx("input", { id: searchId, type: "search", value: search, onChange: (e) => setSearch(e.target.value) }), error ? _jsx("p", { role: "alert", children: error }) : null, items && items.length === 0 ? _jsx("p", { className: "vx-muted", children: "No images found." }) : null, _jsx("div", { className: "vx-grid", children: (items ?? []).map((m) => (_jsxs("button", { type: "button", "aria-pressed": value?.id === m.id, onClick: () => {
1129
+ return (_jsxs("div", { className: "vx-field", role: "group", "aria-labelledby": labelId, children: [_jsxs("span", { id: labelId, className: "vx-label", children: [fieldLabel(ui, def, name), def.required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), value?.url ? (_jsx("img", { className: "vx-preview", src: value.url, alt: value.alt ?? '' })) : fromCode ? (_jsxs(_Fragment, { children: [_jsx("img", { className: "vx-preview", src: fromCode.url, alt: fromCode.alt }), _jsx("p", { className: "vx-muted", children: canUploadMedia && importable ? ui.t('media.fromCodeImport') : ui.t('media.fromCode') }), canUploadMedia && importable ? (_jsx("div", { className: "vx-actions", children: _jsx("button", { type: "button", className: "vx-btn", disabled: importing, onClick: () => void importIntoMedia(), children: importing ? ui.t('media.importing') : ui.t('media.import') }) })) : null, importError ? _jsx("p", { role: "alert", children: importError }) : null] })) : (_jsx("p", { className: "vx-muted", children: ui.t('media.none') })), _jsxs("div", { className: "vx-actions", children: [_jsx("button", { type: "button", className: "vx-btn", "data-field": name, onFocus: onFocus, "aria-expanded": picking, onClick: () => setPicking((p) => !p), children: picking ? ui.t('media.closeLibrary') : value ? ui.t('media.replace') : ui.t('media.choose') }), value && !def.required ? (_jsx("button", { type: "button", className: "vx-btn", onClick: () => onChange(null), children: ui.t('common.remove') })) : null] }), picking ? (_jsxs("div", { className: "vx-picker", children: [_jsx("label", { htmlFor: searchId, className: "vx-sublabel", children: ui.t('media.search') }), _jsx("input", { id: searchId, type: "search", dir: "auto", value: search, onChange: (e) => setSearch(e.target.value) }), error ? _jsx("p", { role: "alert", children: error }) : null, items && items.length === 0 ? _jsx("p", { className: "vx-muted", children: ui.t('media.noneFound') }) : null, _jsx("div", { className: "vx-grid", children: (items ?? []).map((m) => (_jsxs("button", { type: "button", "aria-pressed": value?.id === m.id, onClick: () => {
978
1130
  onChange({ id: m.id, url: m.url, alt: m.alt });
979
1131
  setPicking(false);
980
1132
  }, children: [_jsx("img", { src: m.thumbUrl, alt: "" }), _jsx("span", { children: m.alt || m.name })] }, m.id))) })] })) : null] }));
@@ -1003,19 +1155,23 @@ const STYLES = `
1003
1155
  .vx-inline-hint{position:fixed;z-index:2147483002;background:#18181b;color:#fafafa;font-size:12px;padding:5px 9px;border-radius:7px;box-shadow:0 6px 20px rgba(0,0,0,.25);white-space:nowrap;pointer-events:none}
1004
1156
  .vx-inline-keys{color:#a1a1aa}
1005
1157
  [data-veroxm-inline]{outline:none;cursor:text;caret-color:auto}
1006
- .vx-tag{position:absolute;top:-24px;left:-2px;background:#6d28d9;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;white-space:nowrap}
1158
+ .vx-tag{position:absolute;top:-24px;inset-inline-start:-2px;background:#6d28d9;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;white-space:nowrap}
1007
1159
  .vx-toolbar{position:fixed;z-index:2147483002;left:50%;bottom:16px;transform:translateX(-50%);width:max-content;display:flex;flex-wrap:wrap;align-items:center;gap:8px;max-width:calc(100vw - 32px);background:#18181b;color:#fafafa;padding:8px 10px;border-radius:12px;box-shadow:0 8px 30px rgba(0,0,0,.3)}
1008
1160
  .vx-toolbar .vx-muted{color:#a1a1aa}
1009
- .vx-brand{display:flex;align-items:center;gap:6px;font-weight:600;padding:0 4px}
1161
+ .vx-brand{display:flex;align-items:center;gap:6px;font-weight:600;padding:0 4px;white-space:nowrap;min-width:0}
1162
+ .vx-project{max-width:10rem;overflow:hidden;text-overflow:ellipsis}
1163
+ .vx-toolbar .vx-btn{white-space:nowrap}
1164
+ @media (max-width:1000px){.vx-project{display:none}}
1010
1165
  .vx-dot{width:8px;height:8px;border-radius:50%;background:#a78bfa}
1011
1166
  .vx-ended{max-width:28rem}
1012
1167
  .vx-btn{appearance:none;cursor:pointer;display:inline-flex;align-items:center;min-height:32px;padding:4px 12px;border-radius:8px;border:1px solid #d4d4d8;background:#fff;color:#18181b;text-decoration:none}
1013
1168
  .vx-toolbar .vx-btn{background:#27272a;border-color:#3f3f46;color:#fafafa}
1014
1169
  .vx-toolbar .vx-btn[aria-pressed="true"]{background:#4c1d95;border-color:#6d28d9}
1170
+ .vx-lang{appearance:auto;min-height:32px;max-width:9.5rem;padding:4px 8px;border-radius:8px;border:1px solid #3f3f46;background:#27272a;color:#fafafa;cursor:pointer}
1015
1171
  .vx-btn:disabled{opacity:.5;cursor:not-allowed}
1016
1172
  .vx-primary{background:#6d28d9;border-color:#6d28d9;color:#fff}
1017
1173
  .vx-root :focus-visible{outline:2px solid #f59e0b;outline-offset:2px}
1018
- .vx-panel{position:fixed;z-index:2147483001;top:12px;right:12px;bottom:76px;width:min(380px,calc(100vw - 24px));display:flex;flex-direction:column;background:#fff;border:1px solid #e4e4e7;border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.18)}
1174
+ .vx-panel{position:fixed;z-index:2147483003;top:12px;inset-inline-end:12px;bottom:calc(var(--vx-bar-space,64px) + 12px);max-height:calc(100vh - var(--vx-bar-space,64px) - 24px);width:min(380px,calc(100vw - 24px));display:flex;flex-direction:column;background:#fff;border:1px solid #e4e4e7;border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.18)}
1019
1175
  .vx-panel-head{display:flex;justify-content:space-between;gap:8px;padding:14px 16px;border-bottom:1px solid #f4f4f5}
1020
1176
  .vx-panel-head h2{margin:0;font-size:16px;font-weight:650}
1021
1177
  .vx-panel-head p{margin:2px 0 0}
@@ -1033,15 +1189,16 @@ const STYLES = `
1033
1189
  .vx-field input::placeholder,.vx-field textarea::placeholder{color:#a1a1aa;opacity:1}
1034
1190
  .vx-field textarea{resize:vertical;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:13px}
1035
1191
  .vx-count{font-size:12px;color:#71717a}
1192
+ .vx-root bdi{unicode-bidi:isolate}
1036
1193
  .vx-preview{max-width:100%;max-height:160px;border-radius:8px;object-fit:contain;background:#f4f4f5;align-self:flex-start}
1037
1194
  .vx-picker{border:1px solid #e4e4e7;border-radius:10px;padding:8px;margin-top:6px}
1038
1195
  .vx-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin-top:8px;max-height:240px;overflow:auto}
1039
- .vx-grid button{appearance:none;cursor:pointer;border:2px solid transparent;border-radius:8px;padding:2px;background:#f4f4f5;display:flex;flex-direction:column;gap:2px;font-size:11px;text-align:left}
1196
+ .vx-grid button{appearance:none;cursor:pointer;border:2px solid transparent;border-radius:8px;padding:2px;background:#f4f4f5;display:flex;flex-direction:column;gap:2px;font-size:11px;text-align:start}
1040
1197
  .vx-grid button[aria-pressed="true"]{border-color:#6d28d9}
1041
1198
  .vx-grid img{width:100%;aspect-ratio:1;object-fit:cover;border-radius:6px}
1042
1199
  .vx-grid span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1043
1200
  .vx-status{margin:0 0 8px;min-height:20px;color:#52525b}
1044
- .vx-errors{margin:0 0 8px;padding-left:18px;color:#b91c1c}
1201
+ .vx-errors{margin:0 0 8px;padding-inline-start:18px;color:#b91c1c}
1045
1202
  .vx-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
1046
1203
  .vx-actions[hidden]{display:none}
1047
1204
  .vx-test{border:1px solid #ddd6fe;background:#faf5ff;border-radius:10px;padding:8px 10px;margin:0 0 12px;display:flex;flex-direction:column;gap:6px}
@@ -1053,10 +1210,10 @@ const STYLES = `
1053
1210
  .vx-review-title{margin:0;font-weight:600}
1054
1211
  .vx-review-comment{width:100%;padding:6px 8px;border:1px solid #d4d4d8;border-radius:8px;background:#fff;resize:vertical}
1055
1212
  .vx-review-withdraw{align-self:flex-start;margin-top:4px}
1056
- .vx-list{position:fixed;z-index:2147483002;left:50%;bottom:70px;transform:translateX(-50%);width:min(360px,calc(100vw - 24px));max-height:50vh;overflow:auto;background:#fff;border:1px solid #e4e4e7;border-radius:12px;box-shadow:0 12px 40px rgba(0,0,0,.18);padding:10px}
1213
+ .vx-list{position:fixed;z-index:2147483003;left:50%;bottom:calc(var(--vx-bar-space,64px) + 8px);transform:translateX(-50%);width:min(360px,calc(100vw - 24px));max-height:50vh;overflow:auto;background:#fff;border:1px solid #e4e4e7;border-radius:12px;box-shadow:0 12px 40px rgba(0,0,0,.18);padding:10px}
1057
1214
  .vx-list-title{font-weight:650;margin:0 0 6px}
1058
1215
  .vx-list ul{list-style:none;margin:0;padding:0}
1059
- .vx-list button{appearance:none;cursor:pointer;width:100%;text-align:left;border:0;background:transparent;padding:8px;border-radius:8px;display:flex;gap:6px;align-items:baseline;flex-wrap:wrap}
1216
+ .vx-list button{appearance:none;cursor:pointer;width:100%;text-align:start;border:0;background:transparent;padding:8px;border-radius:8px;display:flex;gap:6px;align-items:baseline;flex-wrap:wrap}
1060
1217
  .vx-list button:hover{background:#f4f4f5}
1061
1218
  @media (prefers-color-scheme: dark){
1062
1219
  .vx-root{color:#fafafa}