@veroxm/react-sdk 1.12.0 → 1.12.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.12.1
4
+
5
+ - The quick-quote look for native forms. A date of birth set to **Compact** in the builder (Birth date > Style) is one
6
+ field box: the question title as a small label, then Day / Month / Year as borderless menus sized to their text with
7
+ an arrow in `--vx-color-action`, and, when both calendars are offered, a Hijri switch at the end (`role="switch"`).
8
+ Switching calendar clears the date. The title shows in every field style, "Placeholder only" too. Arabic mirrors it.
9
+ - The mobile number is one field box too: the country code, a divider, then the number with its placeholder.
10
+ - Saudi ID and mobile placeholders, and the button text, are set per form in the builder and translated per language;
11
+ the renderer uses them. `submitLabel` still overrides the button text.
12
+ - An empty error line no longer takes space, so a single-row form is exactly one field high.
13
+
3
14
  ## 1.12.0
4
15
 
5
16
  - `<VeroxmForm>` from `@veroxm/react-sdk/next` draws a form built in VeroXM's Forms natively in the page (no iframe):
@@ -40,6 +40,8 @@ export type NativeFormElement = (ElementBase<'short_text' | 'long_text'> & {
40
40
  defaultCalendar: FormCalendar;
41
41
  minAge: number | null;
42
42
  maxAge: number | null;
43
+ /** compact: one field box, the title a small label, the menus in a row, the calendar a switch (1.12.1). */
44
+ display?: 'standard' | 'compact';
43
45
  }) | (ElementBase<'mobile'> & {
44
46
  placeholder: string;
45
47
  countries: string[];
@@ -74,6 +76,8 @@ export interface NativeFormDefinition {
74
76
  rows: NativeLayoutRow[];
75
77
  fieldStyle: NativeFieldStyle;
76
78
  };
79
+ /** The send button's text, set on the form in the builder (translated as form.submit). */
80
+ submitLabel?: string;
77
81
  /** What the visitor sees after sending a form that doesn't hand off. */
78
82
  endings?: Array<{
79
83
  id: string;
@@ -37,6 +37,7 @@ export function localizeForm(def, locale) {
37
37
  return next;
38
38
  }),
39
39
  endings: def.endings?.map((e) => ({ ...e, title: tr(`end.${e.id}.title`, e.title), description: tr(`end.${e.id}.description`, e.description) })),
40
+ ...(def.submitLabel ? { submitLabel: tr('form.submit', def.submitLabel) } : {}),
40
41
  };
41
42
  }
42
43
  /**
@@ -26,6 +26,7 @@ textarea.vx-control{block-size:auto;min-block-size:calc(var(--vx-field-height,48
26
26
  .vx-ltr{direction:ltr;text-align:start}
27
27
  [dir=rtl] .vx-ltr{text-align:end}
28
28
  .vx-error{color:var(--vx-color-danger,#b91c1c);font-size:var(--vx-font-size-small,14px);margin:0}
29
+ .vx-error:empty{display:none}
29
30
  .vx-hint{color:var(--vx-color-text-muted,inherit);font-size:var(--vx-font-size-small,14px);margin:0}
30
31
  .vx-choices{display:flex;flex-wrap:wrap;gap:8px 16px}
31
32
  .vx-choice{display:inline-flex;gap:8px;align-items:flex-start;cursor:pointer}
@@ -35,6 +36,29 @@ textarea.vx-control{block-size:auto;min-block-size:calc(var(--vx-field-height,48
35
36
  .vx-seg input{position:absolute;opacity:0;inline-size:1px;block-size:1px}
36
37
  .vx-seg span{display:block;padding:2px 10px;font-size:var(--vx-font-size-small,13px)}
37
38
  .vx-seg input:checked+span{background:var(--vx-color-action,#4f46e5);color:var(--vx-color-on-action,#fff)}
39
+ .vx-bd,.vx-phone{margin:0;min-inline-size:0;block-size:var(--vx-field-height,48px);border:var(--vx-border-width,1px) solid var(--vx-field-border,#c7cad1);border-radius:var(--vx-field-radius,var(--vx-radius-control,14px));background:var(--vx-field-background,#fff);color:var(--vx-field-text,inherit);display:flex;align-items:center}
40
+ .vx-bd{padding:0 16px;gap:12px}
41
+ .vx-bd:focus-within,.vx-phone:focus-within{border-color:var(--vx-color-focus,#4f46e5)}
42
+ .vx-bd[aria-invalid=true],.vx-phone[aria-invalid=true]{border-color:var(--vx-color-danger,#b91c1c)}
43
+ .vx-bd-main{flex:1 1 auto;min-inline-size:0;display:flex;flex-direction:column;gap:2px}
44
+ .vx-bd-label{font-size:var(--vx-font-size-small,12px);line-height:1.3;color:var(--vx-field-label,var(--vx-color-text-muted,#5b6478))}
45
+ .vx-bd-menus{display:flex;gap:24px;min-inline-size:0}
46
+ .vx-menu{position:relative;display:inline-flex;align-items:center;min-inline-size:0}
47
+ .vx-menu select{appearance:none;-webkit-appearance:none;border:0;background:transparent;color:inherit;font:inherit;font-size:var(--vx-font-size-body,14px);font-weight:500;padding:0;padding-inline-end:18px;margin:0;field-sizing:content;min-inline-size:0;cursor:pointer;line-height:1.4}
48
+ .vx-menu select:focus-visible,.vx-phone-number:focus-visible{outline:2px solid var(--vx-color-focus,#4f46e5);outline-offset:2px;border-radius:4px}
49
+ .vx-chevron{position:absolute;inset-inline-end:0;pointer-events:none;color:var(--vx-color-action,#4f46e5)}
50
+ .vx-bd-switch{flex:none;display:inline-flex;align-items:center;gap:8px;font-size:var(--vx-font-size-small,12px);color:var(--vx-field-label,var(--vx-color-text-muted,#5b6478))}
51
+ .vx-phone{padding-inline:16px;gap:12px}
52
+ .vx-phone>.vx-menu{flex:none}
53
+ .vx-phone-rule{flex:none;inline-size:1px;block-size:24px;background:var(--vx-field-border,#c7cad1)}
54
+ .vx-phone-number{flex:1 1 auto;min-inline-size:0;block-size:100%;border:0;padding:0;background:transparent;color:inherit;font:inherit;font-size:var(--vx-font-size-body,16px);text-align:start}
55
+ .vx-phone-number::placeholder{color:var(--vx-field-label,var(--vx-color-text-muted,#5b6478));opacity:1}
56
+ .vx-switch{position:relative;inline-size:32px;block-size:18px;padding:0;border:0;border-radius:999px;background:var(--vx-color-control,#dcdee3);cursor:pointer;flex:none}
57
+ .vx-switch[aria-checked=true]{background:var(--vx-color-action,#4f46e5)}
58
+ .vx-switch-knob{position:absolute;inset-block-start:2px;inset-inline-start:2px;inline-size:14px;block-size:14px;border-radius:50%;background:#fff;transition:inset-inline-start .15s}
59
+ .vx-switch[aria-checked=true] .vx-switch-knob{inset-inline-start:16px}
60
+ .vx-switch:focus-visible{outline:2px solid var(--vx-color-focus,#4f46e5);outline-offset:2px}
61
+ @media (prefers-reduced-motion:reduce){.vx-switch-knob{transition:none}}
38
62
  .vx-submit{block-size:var(--vx-button-height,var(--vx-field-height,48px));inline-size:100%;padding-inline:20px;border:var(--vx-border-width,1px) solid var(--vx-button-primary-border,var(--vx-button-primary-background,#4f46e5));border-radius:var(--vx-button-primary-radius,var(--vx-radius-control,14px));background:var(--vx-button-primary-background,#4f46e5);color:var(--vx-button-primary-text,#fff);font:inherit;font-weight:var(--vx-font-weight-heading,600);cursor:pointer}
39
63
  .vx-submit[aria-disabled=true]{opacity:.7;cursor:progress}
40
64
  .vx-form-error{color:var(--vx-color-danger,#b91c1c);margin:0}
@@ -227,13 +251,17 @@ export function VeroxmFormView({ form, locale, hidden, submitPath, submitLabel,
227
251
  return _jsx(BirthDate, { el: el, values: values, set: set, common: common, groupBlur: groupBlur(el.id), locale: locale, words: words, hint: hint, errorLine: errorLine, fieldStyle: fieldStyle });
228
252
  }
229
253
  };
230
- return (_jsxs("form", { className: ['vx-form', className].filter(Boolean).join(' '), style: style, method: "post", action: action, noValidate: true, onSubmit: submit, dir: rtl ? 'rtl' : 'ltr', lang: locale, "aria-busy": sending || undefined, children: [_jsx("style", { children: CSS }), _jsx("input", { type: "hidden", name: "version", value: form.version }), _jsx("input", { type: "hidden", name: "locale", value: locale }), Object.entries(hiddenValues).map(([k, v]) => _jsx("input", { type: "hidden", name: `h.${k}`, value: v }, k)), rows.map((row) => (_jsx("div", { className: "vx-row", "data-medium": row.medium ? '' : undefined, "data-wide-submit": row.submitFullWidth ? '' : undefined, style: { columnGap: row.gap, rowGap: Math.max(row.gap, 8), ['--vx-cols']: gridColumns(row), ['--vx-cols-m']: row.medium ?? undefined, ['--vx-cols-s']: row.small ?? 1 }, children: row.cells.map((cell) => cell.element === FORM_LAYOUT_SUBMIT ? (_jsx("div", { className: "vx-cell vx-cell-submit", children: _jsx("button", { type: "submit", className: "vx-submit", "aria-disabled": sending || undefined, children: sending ? words.sending : submitLabel || words.submit }) }, cell.element)) : byId.has(cell.element) ? (_jsx("div", { className: "vx-cell", children: field(byId.get(cell.element)) }, cell.element)) : null) }, row.id))), _jsx("p", { className: "vx-form-error", role: "alert", children: formError })] }));
254
+ return (_jsxs("form", { className: ['vx-form', className].filter(Boolean).join(' '), style: style, method: "post", action: action, noValidate: true, onSubmit: submit, dir: rtl ? 'rtl' : 'ltr', lang: locale, "aria-busy": sending || undefined, children: [_jsx("style", { children: CSS }), _jsx("input", { type: "hidden", name: "version", value: form.version }), _jsx("input", { type: "hidden", name: "locale", value: locale }), Object.entries(hiddenValues).map(([k, v]) => _jsx("input", { type: "hidden", name: `h.${k}`, value: v }, k)), rows.map((row) => (_jsx("div", { className: "vx-row", "data-medium": row.medium ? '' : undefined, "data-wide-submit": row.submitFullWidth ? '' : undefined, style: { columnGap: row.gap, rowGap: Math.max(row.gap, 8), ['--vx-cols']: gridColumns(row), ['--vx-cols-m']: row.medium ?? undefined, ['--vx-cols-s']: row.small ?? 1 }, children: row.cells.map((cell) => cell.element === FORM_LAYOUT_SUBMIT ? (_jsx("div", { className: "vx-cell vx-cell-submit", children: _jsx("button", { type: "submit", className: "vx-submit", "aria-disabled": sending || undefined, children: sending ? words.sending : submitLabel || def.submitLabel || words.submit }) }, cell.element)) : byId.has(cell.element) ? (_jsx("div", { className: "vx-cell", children: field(byId.get(cell.element)) }, cell.element)) : null) }, row.id))), _jsx("p", { className: "vx-form-error", role: "alert", children: formError })] }));
255
+ }
256
+ /** The menu arrow of the quick-quote look, in the action colour. */
257
+ function Chevron() {
258
+ return (_jsx("svg", { className: "vx-chevron", viewBox: "0 0 12 12", width: "12", height: "12", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M2.5 4.5 6 8l3.5-3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) }));
231
259
  }
232
260
  function Mobile({ el, values, set, common, groupBlur, labelClass, locale, words, hint, errorLine, fieldStyle }) {
233
261
  const cur = values[el.id];
234
262
  const v = cur && typeof cur === 'object' && 'number' in cur ? cur : { country: el.defaultCountry, number: '' };
235
263
  const countries = mobileCountries(el, locale);
236
- return (_jsxs("fieldset", { className: "vx-field", onBlur: groupBlur, "aria-invalid": common['aria-invalid'], "aria-describedby": common['aria-describedby'], children: [_jsx("legend", { className: labelClass, children: el.title }), _jsxs("div", { className: "vx-group", dir: "ltr", "aria-invalid": common['aria-invalid'], children: [_jsx("select", { className: "vx-control vx-dial", name: `m.${el.ref}.country`, "aria-label": words.countryCode, value: v.country, onChange: (e) => set(el.id, { ...v, country: e.target.value }), children: countries.map((c) => _jsx("option", { value: c.code, title: c.name, children: c.dial }, c.code)) }), _jsx("input", { ...common, className: "vx-control vx-ltr", type: "tel", inputMode: "tel", autoComplete: "tel-national", name: `m.${el.ref}.number`, "aria-label": el.title, placeholder: fieldStyle === 'floating' ? undefined : el.placeholder || undefined, value: v.number, onChange: (e) => set(el.id, { ...v, number: e.target.value }) })] }), hint, errorLine] }));
264
+ return (_jsxs("fieldset", { className: "vx-field", onBlur: groupBlur, "aria-invalid": common['aria-invalid'], "aria-describedby": common['aria-describedby'], children: [_jsx("legend", { className: labelClass, children: el.title }), _jsxs("div", { className: "vx-phone", dir: "ltr", "aria-invalid": common['aria-invalid'], children: [_jsxs("span", { className: "vx-menu", children: [_jsx("select", { name: `m.${el.ref}.country`, "aria-label": words.countryCode, value: v.country, onChange: (e) => set(el.id, { ...v, country: e.target.value }), children: countries.map((c) => _jsx("option", { value: c.code, title: c.name, children: c.dial }, c.code)) }), _jsx(Chevron, {})] }), _jsx("span", { className: "vx-phone-rule", "aria-hidden": "true" }), _jsx("input", { ...common, className: "vx-phone-number", type: "tel", inputMode: "tel", autoComplete: "tel-national", name: `m.${el.ref}.number`, "aria-label": el.title, placeholder: fieldStyle === 'floating' ? undefined : el.placeholder || undefined, value: v.number, onChange: (e) => set(el.id, { ...v, number: e.target.value }) })] }), hint, errorLine] }));
237
265
  }
238
266
  function BirthDate({ el, values, set, common, groupBlur, locale, words, hint, errorLine, fieldStyle }) {
239
267
  const cur = values[el.id];
@@ -246,5 +274,13 @@ function BirthDate({ el, values, set, common, groupBlur, locale, words, hint, er
246
274
  const days = daysInMonth(cal, Number(v.year), Number(v.month));
247
275
  const legendClass = fieldStyle === 'placeholder' ? 'vx-sr' : 'vx-label';
248
276
  const update = (patch) => set(el.id, { ...v, ...patch });
249
- return (_jsxs("fieldset", { className: "vx-field", onBlur: groupBlur, "aria-invalid": common['aria-invalid'], "aria-describedby": common['aria-describedby'], children: [_jsx("legend", { className: legendClass, children: el.title }), el.calendars.length > 1 ? (_jsx("div", { className: "vx-seg", role: "radiogroup", "aria-label": words.calendar, style: { alignSelf: 'flex-start' }, children: el.calendars.map((c) => (_jsxs("label", { children: [_jsx("input", { type: "radio", name: `d.${el.ref}.calendar`, value: c, checked: cal === c, onChange: () => set(el.id, { calendar: c, year: '', month: '', day: '' }) }), _jsx("span", { children: c === 'hijri' ? words.hijri : words.gregorian })] }, c))) })) : (_jsx("input", { type: "hidden", name: `d.${el.ref}.calendar`, value: cal })), _jsxs("div", { className: "vx-group", "aria-invalid": common['aria-invalid'], children: [_jsxs("select", { ...common, className: "vx-control", name: `d.${el.ref}.day`, "aria-label": words.day, value: v.day, onChange: (e) => update({ day: e.target.value }), children: [_jsx("option", { value: "", children: words.day }), Array.from({ length: days }, (_, i) => _jsx("option", { value: i + 1, children: i + 1 }, i + 1))] }), _jsxs("select", { className: "vx-control", name: `d.${el.ref}.month`, "aria-label": words.month, value: v.month, onChange: (e) => update({ month: e.target.value }), children: [_jsx("option", { value: "", children: words.month }), months.map((m, i) => _jsx("option", { value: i + 1, children: m }, i + 1))] }), _jsxs("select", { className: "vx-control", name: `d.${el.ref}.year`, "aria-label": words.year, value: v.year, onChange: (e) => update({ year: e.target.value }), children: [_jsx("option", { value: "", children: words.year }), years.map((y) => _jsx("option", { value: y, children: y }, y))] })] }), hint, errorLine] }));
277
+ // Changing the calendar starts the date again: a Gregorian day isn't a Hijri one.
278
+ const switchTo = (c) => set(el.id, { calendar: c, year: '', month: '', day: '' });
279
+ if (el.display === 'compact') {
280
+ const both = el.calendars.includes('gregorian') && el.calendars.includes('hijri');
281
+ const switchLabel = `${common.id}-hijri`;
282
+ const menu = (key, label, options, first) => (_jsxs("span", { className: "vx-menu", children: [_jsxs("select", { ...(first ? common : { 'aria-describedby': common['aria-describedby'] }), name: `d.${el.ref}.${key}`, "aria-label": label, value: v[key], onChange: (e) => update({ [key]: e.target.value }), children: [_jsx("option", { value: "", children: label }), options.map((o) => (_jsx("option", { value: o.value, children: o.text }, o.value)))] }), _jsx(Chevron, {})] }));
283
+ return (_jsxs("div", { className: "vx-field", children: [_jsxs("div", { role: "group", className: "vx-bd", onBlur: groupBlur, "aria-labelledby": `${common.id}-title`, "aria-invalid": common['aria-invalid'], "aria-describedby": common['aria-describedby'], children: [_jsxs("span", { className: "vx-bd-main", children: [_jsx("span", { id: `${common.id}-title`, className: "vx-bd-label", children: el.title }), _jsxs("span", { className: "vx-bd-menus", children: [menu('day', words.day, Array.from({ length: days }, (_, i) => ({ value: i + 1, text: i + 1 })), true), menu('month', words.month, months.map((m, i) => ({ value: i + 1, text: m })), false), menu('year', words.year, years.map((y) => ({ value: y, text: y })), false)] })] }), both ? (_jsxs("span", { className: "vx-bd-switch", children: [_jsx("span", { id: switchLabel, children: words.hijri }), _jsx("button", { type: "button", role: "switch", "aria-checked": cal === 'hijri', "aria-labelledby": switchLabel, className: "vx-switch", onClick: () => switchTo(cal === 'hijri' ? 'gregorian' : 'hijri'), children: _jsx("span", { className: "vx-switch-knob" }) })] })) : null, _jsx("input", { type: "hidden", name: `d.${el.ref}.calendar`, value: cal })] }), hint, errorLine] }));
284
+ }
285
+ return (_jsxs("fieldset", { className: "vx-field", onBlur: groupBlur, "aria-invalid": common['aria-invalid'], "aria-describedby": common['aria-describedby'], children: [_jsx("legend", { className: legendClass, children: el.title }), el.calendars.length > 1 ? (_jsx("div", { className: "vx-seg", role: "radiogroup", "aria-label": words.calendar, style: { alignSelf: 'flex-start' }, children: el.calendars.map((c) => (_jsxs("label", { children: [_jsx("input", { type: "radio", name: `d.${el.ref}.calendar`, value: c, checked: cal === c, onChange: () => switchTo(c) }), _jsx("span", { children: c === 'hijri' ? words.hijri : words.gregorian })] }, c))) })) : (_jsx("input", { type: "hidden", name: `d.${el.ref}.calendar`, value: cal })), _jsxs("div", { className: "vx-group", "aria-invalid": common['aria-invalid'], children: [_jsxs("select", { ...common, className: "vx-control", name: `d.${el.ref}.day`, "aria-label": words.day, value: v.day, onChange: (e) => update({ day: e.target.value }), children: [_jsx("option", { value: "", children: words.day }), Array.from({ length: days }, (_, i) => _jsx("option", { value: i + 1, children: i + 1 }, i + 1))] }), _jsxs("select", { className: "vx-control", name: `d.${el.ref}.month`, "aria-label": words.month, value: v.month, onChange: (e) => update({ month: e.target.value }), children: [_jsx("option", { value: "", children: words.month }), months.map((m, i) => _jsx("option", { value: i + 1, children: m }, i + 1))] }), _jsxs("select", { className: "vx-control", name: `d.${el.ref}.year`, "aria-label": words.year, value: v.year, onChange: (e) => update({ year: e.target.value }), children: [_jsx("option", { value: "", children: words.year }), years.map((y) => _jsx("option", { value: y, children: y }, y))] })] }), hint, errorLine] }));
250
286
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veroxm/react-sdk",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "React and Next.js SDK for VeroXM: content hooks, visual slots with A/B tests, the on-page editor, forms and product journeys, llms.txt and structured data.",
5
5
  "keywords": [
6
6
  "veroxm",