@veroxm/react-sdk 1.11.1 → 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 +33 -0
- package/dist/editor/handler.js +5 -1
- package/dist/editor/i18n.d.ts +3 -0
- package/dist/editor/i18n.js +6 -0
- package/dist/editor/overlay.d.ts +1 -1
- package/dist/editor/overlay.js +25 -0
- package/dist/form-native/checks.d.ts +53 -0
- package/dist/form-native/checks.js +168 -0
- package/dist/form-native/model.d.ts +184 -0
- package/dist/form-native/model.js +261 -0
- package/dist/form-native/relay.d.ts +11 -0
- package/dist/form-native/relay.js +156 -0
- package/dist/form-native/view.d.ts +28 -0
- package/dist/form-native/view.js +286 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/next/form.d.ts +34 -0
- package/dist/next/form.js +47 -0
- package/dist/next/index.d.ts +2 -0
- package/dist/next/index.js +1 -0
- package/dist/slots-core.d.ts +16 -1
- package/dist/slots-core.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { currentYear, daysInMonth, monthNames } from './checks.js';
|
|
5
|
+
import { FORM_LAYOUT_SUBMIT, checkAnswer, checkAnswers, formWords, gridColumns, isRtl, layoutRows, mobileCountries, } from './model.js';
|
|
6
|
+
import { FORM_HEADER } from './relay.js';
|
|
7
|
+
const CSS = `
|
|
8
|
+
.vx-form{display:grid;gap:var(--vx-space-md,16px);color:var(--vx-color-text,inherit);font:inherit}
|
|
9
|
+
.vx-form *{box-sizing:border-box}
|
|
10
|
+
.vx-row{display:grid;grid-template-columns:var(--vx-cols);align-items:end}
|
|
11
|
+
@media (max-width:1099.98px){.vx-row[data-medium]{grid-template-columns:repeat(var(--vx-cols-m),minmax(0,1fr))}.vx-row[data-medium][data-wide-submit] .vx-cell-submit{grid-column:1/-1}}
|
|
12
|
+
@media (max-width:639.98px){.vx-row{grid-template-columns:repeat(var(--vx-cols-s,1),minmax(0,1fr))}.vx-row[data-wide-submit] .vx-cell-submit{grid-column:1/-1}}
|
|
13
|
+
.vx-cell{min-inline-size:0;align-self:start}
|
|
14
|
+
.vx-cell-submit{align-self:end}
|
|
15
|
+
.vx-field{display:flex;flex-direction:column;gap:var(--vx-space-xs,4px);margin:0;padding:0;border:0;min-inline-size:0;position:relative}
|
|
16
|
+
.vx-label{color:var(--vx-field-label,var(--vx-color-text-muted,inherit));font-size:var(--vx-font-size-small,14px);padding:0;display:flex;justify-content:space-between;gap:8px;align-items:center}
|
|
17
|
+
.vx-sr{position:absolute!important;inline-size:1px;block-size:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
18
|
+
.vx-control{block-size:var(--vx-field-height,48px);inline-size:100%;padding-inline:12px;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);font:inherit;font-size:var(--vx-font-size-body,16px)}
|
|
19
|
+
textarea.vx-control{block-size:auto;min-block-size:calc(var(--vx-field-height,48px)*2);padding-block:10px}
|
|
20
|
+
.vx-control::placeholder{color:var(--vx-field-label,var(--vx-color-text-muted,#5b6478));opacity:1}
|
|
21
|
+
.vx-control:focus-visible,.vx-choice input:focus-visible,.vx-submit:focus-visible,.vx-seg input:focus-visible+span{outline:2px solid var(--vx-color-focus,#4f46e5);outline-offset:2px}
|
|
22
|
+
.vx-control[aria-invalid=true],.vx-group[aria-invalid=true] .vx-control{border-color:var(--vx-color-danger,#b91c1c)}
|
|
23
|
+
.vx-group{display:flex;gap:8px;min-inline-size:0}
|
|
24
|
+
.vx-group>.vx-control{flex:1 1 0;min-inline-size:0}
|
|
25
|
+
.vx-group>.vx-dial{flex:0 0 auto;inline-size:auto;padding-inline:8px}
|
|
26
|
+
.vx-ltr{direction:ltr;text-align:start}
|
|
27
|
+
[dir=rtl] .vx-ltr{text-align:end}
|
|
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}
|
|
30
|
+
.vx-hint{color:var(--vx-color-text-muted,inherit);font-size:var(--vx-font-size-small,14px);margin:0}
|
|
31
|
+
.vx-choices{display:flex;flex-wrap:wrap;gap:8px 16px}
|
|
32
|
+
.vx-choice{display:inline-flex;gap:8px;align-items:flex-start;cursor:pointer}
|
|
33
|
+
.vx-choice input{accent-color:var(--vx-color-action,#4f46e5);inline-size:18px;block-size:18px;margin:2px 0 0;flex:none}
|
|
34
|
+
.vx-seg{display:inline-flex;border:var(--vx-border-width,1px) solid var(--vx-field-border,#c7cad1);border-radius:999px;overflow:hidden}
|
|
35
|
+
.vx-seg label{cursor:pointer}
|
|
36
|
+
.vx-seg input{position:absolute;opacity:0;inline-size:1px;block-size:1px}
|
|
37
|
+
.vx-seg span{display:block;padding:2px 10px;font-size:var(--vx-font-size-small,13px)}
|
|
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}}
|
|
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}
|
|
63
|
+
.vx-submit[aria-disabled=true]{opacity:.7;cursor:progress}
|
|
64
|
+
.vx-form-error{color:var(--vx-color-danger,#b91c1c);margin:0}
|
|
65
|
+
.vx-form-error:empty{display:none}
|
|
66
|
+
.vx-field[data-style=floating]{display:block}
|
|
67
|
+
.vx-field[data-style=floating]>.vx-label{position:absolute;inset-inline-start:12px;inset-block-start:6px;font-size:12px;pointer-events:none}
|
|
68
|
+
.vx-field[data-style=floating]>.vx-control{padding-block-start:18px}
|
|
69
|
+
`;
|
|
70
|
+
/** The visitor's own random id for this send (the API never stores it twice). */
|
|
71
|
+
function newKey() {
|
|
72
|
+
const bytes = new Uint8Array(16);
|
|
73
|
+
(globalThis.crypto ?? { getRandomValues: (b) => b.map(() => Math.floor(Math.random() * 256)) }).getRandomValues(bytes);
|
|
74
|
+
return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
75
|
+
}
|
|
76
|
+
function campaign() {
|
|
77
|
+
if (typeof location === 'undefined')
|
|
78
|
+
return {};
|
|
79
|
+
const out = {};
|
|
80
|
+
for (const [k, v] of new URLSearchParams(location.search))
|
|
81
|
+
if (/^utm_(source|medium|campaign|term|content)$/.test(k) && v)
|
|
82
|
+
out[k] = v.slice(0, 200);
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
export function VeroxmFormView({ form, locale, hidden, submitPath, submitLabel, onSubmitted, className, style }) {
|
|
86
|
+
const def = form.definition;
|
|
87
|
+
const uid = useId().replace(/:/g, '');
|
|
88
|
+
const words = formWords(locale);
|
|
89
|
+
const rtl = isRtl(locale);
|
|
90
|
+
const fieldStyle = def.layout?.fieldStyle ?? 'label';
|
|
91
|
+
const elements = def.elements;
|
|
92
|
+
const byId = useMemo(() => new Map(elements.map((e) => [e.id, e])), [elements]);
|
|
93
|
+
const rows = useMemo(() => layoutRows(def), [def]);
|
|
94
|
+
const [values, setValues] = useState({});
|
|
95
|
+
const [errors, setErrors] = useState({});
|
|
96
|
+
const [formError, setFormError] = useState('');
|
|
97
|
+
const [sending, setSending] = useState(false);
|
|
98
|
+
const [ending, setEnding] = useState(null);
|
|
99
|
+
const key = useRef('');
|
|
100
|
+
const action = submitPath ?? `/api/veroxm/forms/${encodeURIComponent(form.publicId)}/submit`;
|
|
101
|
+
const controlId = (id) => `vx${uid}-${id}`;
|
|
102
|
+
const errorId = (id) => `vx${uid}-${id}-error`;
|
|
103
|
+
const hiddenValues = Object.fromEntries(Object.entries(hidden ?? {}).filter(([, v]) => v !== null && v !== undefined && v !== '').map(([k, v]) => [k, String(v)]));
|
|
104
|
+
const set = (id, v) => {
|
|
105
|
+
setValues((prev) => ({ ...prev, [id]: v }));
|
|
106
|
+
// A field already marked wrong is checked again as it is fixed.
|
|
107
|
+
if (errors[id]) {
|
|
108
|
+
const el = byId.get(id);
|
|
109
|
+
if (el)
|
|
110
|
+
setErrors((prev) => ({ ...prev, [id]: checkAnswer(el, v, words.messages).error ?? '' }));
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const blur = (id, v = values[id]) => {
|
|
114
|
+
const el = byId.get(id);
|
|
115
|
+
if (!el)
|
|
116
|
+
return;
|
|
117
|
+
const empty = v === undefined || v === '' || (Array.isArray(v) && !v.length);
|
|
118
|
+
// Leaving a field empty isn't an error until the form is sent.
|
|
119
|
+
const err = empty ? '' : (checkAnswer(el, v, words.messages).error ?? '');
|
|
120
|
+
setErrors((prev) => ({ ...prev, [id]: err }));
|
|
121
|
+
};
|
|
122
|
+
/** A group (date of birth, mobile) is checked when focus leaves the whole group. */
|
|
123
|
+
const groupBlur = (id) => (e) => {
|
|
124
|
+
if (!e.currentTarget.contains(e.relatedTarget))
|
|
125
|
+
blur(id);
|
|
126
|
+
};
|
|
127
|
+
/** The elements in the order they're drawn, so focus goes to the first error on screen. */
|
|
128
|
+
const order = rows.flatMap((r) => r.cells.map((c) => c.element)).filter((id) => byId.has(id));
|
|
129
|
+
async function submit(e) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
if (sending)
|
|
132
|
+
return;
|
|
133
|
+
const checked = checkAnswers(def, values, words);
|
|
134
|
+
setErrors(checked.errors);
|
|
135
|
+
const first = order.find((id) => checked.errors[id]);
|
|
136
|
+
if (first) {
|
|
137
|
+
setFormError(words.errorsTitle);
|
|
138
|
+
document.getElementById(controlId(first))?.focus();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
setFormError('');
|
|
142
|
+
setSending(true);
|
|
143
|
+
key.current || (key.current = newKey());
|
|
144
|
+
try {
|
|
145
|
+
const res = await fetch(action, {
|
|
146
|
+
method: 'POST',
|
|
147
|
+
headers: { 'Content-Type': 'application/json', [FORM_HEADER]: '1' },
|
|
148
|
+
body: JSON.stringify({
|
|
149
|
+
key: key.current,
|
|
150
|
+
version: form.version,
|
|
151
|
+
answers: checked.answers,
|
|
152
|
+
hidden: { ...campaign(), ...hiddenValues },
|
|
153
|
+
locale,
|
|
154
|
+
page: { url: location.href.split('#')[0], referrer: document.referrer || undefined },
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
const body = (await res.json().catch(() => ({})));
|
|
158
|
+
if (!res.ok) {
|
|
159
|
+
if (body.fieldErrors && Object.keys(body.fieldErrors).length) {
|
|
160
|
+
setErrors(body.fieldErrors);
|
|
161
|
+
const firstServer = order.find((id) => body.fieldErrors[id]);
|
|
162
|
+
if (firstServer)
|
|
163
|
+
document.getElementById(controlId(firstServer))?.focus();
|
|
164
|
+
}
|
|
165
|
+
setFormError(body.error ?? words.sendError);
|
|
166
|
+
// A new key for the next try: this one may be remembered with its failure.
|
|
167
|
+
if (res.status !== 409)
|
|
168
|
+
key.current = '';
|
|
169
|
+
setSending(false);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const result = { redirectUrl: body.redirectUrl ?? null, endingId: body.endingId ?? null };
|
|
173
|
+
if (onSubmitted?.(result) === false) {
|
|
174
|
+
setSending(false);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (result.redirectUrl) {
|
|
178
|
+
window.location.assign(result.redirectUrl);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const end = def.endings?.find((x) => x.id === result.endingId) ?? def.endings?.[0];
|
|
182
|
+
setEnding({ title: end?.title || (rtl ? 'شكرًا لك!' : 'Thank you!'), description: end?.description ?? '' });
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
setFormError(words.sendError);
|
|
186
|
+
setSending(false);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (ending) {
|
|
190
|
+
return (_jsxs("div", { className: ['vx-form', className].filter(Boolean).join(' '), style: style, dir: rtl ? 'rtl' : 'ltr', lang: locale, role: "status", children: [_jsx("p", { style: { margin: 0, fontWeight: 600 }, children: ending.title }), ending.description ? _jsx("p", { className: "vx-hint", children: ending.description }) : null] }));
|
|
191
|
+
}
|
|
192
|
+
const field = (el) => {
|
|
193
|
+
const err = errors[el.id] || '';
|
|
194
|
+
const invalid = err ? true : undefined;
|
|
195
|
+
const described = [err ? errorId(el.id) : '', el.description ? `${controlId(el.id)}-hint` : ''].filter(Boolean).join(' ') || undefined;
|
|
196
|
+
const labelClass = fieldStyle === 'placeholder' ? 'vx-sr' : 'vx-label';
|
|
197
|
+
const errorLine = _jsx("p", { id: errorId(el.id), className: "vx-error", "aria-live": "polite", children: err });
|
|
198
|
+
const hint = el.description ? _jsx("p", { id: `${controlId(el.id)}-hint`, className: "vx-hint", children: el.description }) : null;
|
|
199
|
+
const common = { id: controlId(el.id), 'aria-invalid': invalid, 'aria-describedby': described, 'aria-required': el.required || undefined };
|
|
200
|
+
const ph = (p) => (fieldStyle === 'floating' ? ' ' : p || (fieldStyle === 'placeholder' ? el.title : '') || undefined);
|
|
201
|
+
switch (el.type) {
|
|
202
|
+
case 'heading':
|
|
203
|
+
return _jsx("h3", { style: { margin: 0 }, children: el.title });
|
|
204
|
+
case 'statement':
|
|
205
|
+
return _jsx("p", { style: { margin: 0 }, children: el.title });
|
|
206
|
+
case 'short_text':
|
|
207
|
+
case 'long_text':
|
|
208
|
+
case 'email':
|
|
209
|
+
case 'phone':
|
|
210
|
+
case 'url':
|
|
211
|
+
case 'number':
|
|
212
|
+
case 'saudi_id': {
|
|
213
|
+
const v = typeof values[el.id] === 'string' ? values[el.id] : '';
|
|
214
|
+
const ltr = el.type === 'saudi_id' || el.type === 'phone' || el.type === 'email' || el.type === 'url';
|
|
215
|
+
const attrs = {
|
|
216
|
+
...common,
|
|
217
|
+
name: `a.${el.ref}`,
|
|
218
|
+
className: `vx-control${ltr ? ' vx-ltr' : ''}`,
|
|
219
|
+
value: v,
|
|
220
|
+
placeholder: ph(el.placeholder),
|
|
221
|
+
dir: ltr ? 'ltr' : undefined,
|
|
222
|
+
onChange: (e) => set(el.id, e.target.value),
|
|
223
|
+
onBlur: () => blur(el.id),
|
|
224
|
+
};
|
|
225
|
+
return (_jsxs("div", { className: "vx-field", "data-style": fieldStyle, children: [_jsx("label", { className: labelClass, htmlFor: common.id, children: el.title }), el.type === 'long_text' ? (_jsx("textarea", { ...attrs, rows: 3, maxLength: el.maxLength })) : (_jsx("input", { ...attrs, type: el.type === 'email' ? 'email' : el.type === 'phone' ? 'tel' : el.type === 'url' ? 'url' : 'text', inputMode: el.type === 'saudi_id' ? 'numeric' : el.type === 'number' ? 'decimal' : undefined, autoComplete: el.type === 'email' ? 'email' : el.type === 'phone' ? 'tel' : 'off', maxLength: el.type === 'saudi_id' ? 12 : el.type === 'short_text' ? el.maxLength : undefined })), hint, errorLine] }));
|
|
226
|
+
}
|
|
227
|
+
case 'dropdown': {
|
|
228
|
+
const v = typeof values[el.id] === 'string' ? values[el.id] : '';
|
|
229
|
+
return (_jsxs("div", { className: "vx-field", children: [_jsx("label", { className: fieldStyle === 'floating' ? 'vx-label' : labelClass, htmlFor: common.id, children: el.title }), _jsxs("select", { ...common, name: `c.${el.ref}`, className: "vx-control", value: v, onChange: (e) => { set(el.id, e.target.value); blur(el.id, e.target.value); }, children: [_jsx("option", { value: "", children: el.placeholder || (fieldStyle === 'placeholder' ? el.title : words.chooseOption) }), el.choices.map((c) => _jsx("option", { value: c.id, children: c.label }, c.id))] }), hint, errorLine] }));
|
|
230
|
+
}
|
|
231
|
+
case 'single_choice':
|
|
232
|
+
case 'multiple_choice':
|
|
233
|
+
case 'yes_no': {
|
|
234
|
+
const multi = el.type === 'multiple_choice';
|
|
235
|
+
const choices = el.type === 'yes_no' ? [{ id: 'yes', label: words.yes }, { id: 'no', label: words.no }] : el.choices;
|
|
236
|
+
const cur = values[el.id];
|
|
237
|
+
const picked = (id) => (Array.isArray(cur) ? cur.includes(id) : cur === id);
|
|
238
|
+
return (_jsxs("fieldset", { className: "vx-field", "aria-invalid": invalid, "aria-describedby": described, onBlur: groupBlur(el.id), children: [_jsx("legend", { className: "vx-label", children: el.title }), _jsx("div", { className: "vx-choices", role: multi ? undefined : 'radiogroup', "aria-required": el.required || undefined, children: choices.map((c, i) => (_jsxs("label", { className: "vx-choice", children: [_jsx("input", { id: i === 0 ? common.id : undefined, type: multi ? 'checkbox' : 'radio', name: `${el.type === 'yes_no' ? 'b' : 'c'}.${el.ref}`, value: c.id, checked: picked(c.id), onChange: (e) => {
|
|
239
|
+
if (!multi)
|
|
240
|
+
return set(el.id, c.id);
|
|
241
|
+
const list = Array.isArray(cur) ? cur : [];
|
|
242
|
+
set(el.id, e.target.checked ? [...list, c.id] : list.filter((x) => x !== c.id));
|
|
243
|
+
} }), _jsx("span", { children: c.label })] }, c.id))) }), hint, errorLine] }));
|
|
244
|
+
}
|
|
245
|
+
case 'legal':
|
|
246
|
+
return (_jsxs("div", { className: "vx-field", children: [_jsxs("label", { className: "vx-choice", children: [_jsx("input", { ...common, type: "checkbox", name: `b.${el.ref}`, checked: values[el.id] === true, onChange: (e) => { set(el.id, e.target.checked); if (e.target.checked)
|
|
247
|
+
blur(el.id, true); } }), _jsx("span", { children: el.title })] }), hint, errorLine] }));
|
|
248
|
+
case 'mobile':
|
|
249
|
+
return _jsx(Mobile, { el: el, values: values, set: set, common: common, groupBlur: groupBlur(el.id), labelClass: labelClass, locale: locale, words: words, hint: hint, errorLine: errorLine, fieldStyle: fieldStyle });
|
|
250
|
+
case 'birth_date':
|
|
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 });
|
|
252
|
+
}
|
|
253
|
+
};
|
|
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" }) }));
|
|
259
|
+
}
|
|
260
|
+
function Mobile({ el, values, set, common, groupBlur, labelClass, locale, words, hint, errorLine, fieldStyle }) {
|
|
261
|
+
const cur = values[el.id];
|
|
262
|
+
const v = cur && typeof cur === 'object' && 'number' in cur ? cur : { country: el.defaultCountry, number: '' };
|
|
263
|
+
const countries = mobileCountries(el, locale);
|
|
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] }));
|
|
265
|
+
}
|
|
266
|
+
function BirthDate({ el, values, set, common, groupBlur, locale, words, hint, errorLine, fieldStyle }) {
|
|
267
|
+
const cur = values[el.id];
|
|
268
|
+
const v = cur && typeof cur === 'object' && 'calendar' in cur ? cur : { calendar: el.defaultCalendar, year: '', month: '', day: '' };
|
|
269
|
+
const cal = v.calendar;
|
|
270
|
+
const top = currentYear(cal) - (el.minAge ?? 0);
|
|
271
|
+
const span = (el.maxAge ?? 100) - (el.minAge ?? 0) + 1;
|
|
272
|
+
const years = Array.from({ length: Math.max(1, span) }, (_, i) => top - i);
|
|
273
|
+
const months = monthNames(locale, cal);
|
|
274
|
+
const days = daysInMonth(cal, Number(v.year), Number(v.month));
|
|
275
|
+
const legendClass = fieldStyle === 'placeholder' ? 'vx-sr' : 'vx-label';
|
|
276
|
+
const update = (patch) => set(el.id, { ...v, ...patch });
|
|
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] }));
|
|
286
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export type { VideoRef, VideoProvider } from './site/video.js';
|
|
|
43
43
|
export type { CollectionFieldMeta, CollectionMeta, Entry, EntryConnection, EntriesQueryOptions, MediaView, MediaHotspot, WhereClause, } from './types.js';
|
|
44
44
|
export { VeroxmForm, useVeroxmForm } from './form.js';
|
|
45
45
|
export type { VeroxmFormProps, VeroxmFormOptions, VeroxmFormMode, VeroxmFormHandle } from './form.js';
|
|
46
|
+
export { VeroxmFormView } from './form-native/view.js';
|
|
47
|
+
export { localizeForm, nativeProblem, checkAnswers as checkFormAnswers, formWords } from './form-native/model.js';
|
|
48
|
+
export type { VeroxmFormViewProps } from './form-native/view.js';
|
|
49
|
+
export type { PublicForm, NativeFormDefinition, NativeFormElement, NativeLayoutRow } from './form-native/model.js';
|
|
46
50
|
export { VeroxmJourney } from './journey.js';
|
|
47
51
|
export type { VeroxmJourneyProps, VeroxmJourneyEvent } from './journey.js';
|
|
48
52
|
export { VeroxmTranslationsProvider, useTranslations } from './translations.js';
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,8 @@ export { chartSvg, chartSummary, formatChartNumber, chartFromRows, chartDataFrom
|
|
|
29
29
|
export { parseVideoUrl, videoEmbedUrl, videoThumbnailUrl } from './site/video.js';
|
|
30
30
|
// Forms: inline, popup, full page or toast, through the embed script of your VeroXM address.
|
|
31
31
|
export { VeroxmForm, useVeroxmForm } from './form.js';
|
|
32
|
+
export { VeroxmFormView } from './form-native/view.js';
|
|
33
|
+
export { localizeForm, nativeProblem, checkAnswers as checkFormAnswers, formWords } from './form-native/model.js';
|
|
32
34
|
// Product journeys: a quote-and-buy journey in your page, in a frame of its hosted page.
|
|
33
35
|
export { VeroxmJourney } from './journey.js';
|
|
34
36
|
// App translations: a locale's bundle in one request, t() and its writing direction. (i18next: @veroxm/sdk's VeroxmI18nextBackend.)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { type PublicForm } from '../form-native/model.js';
|
|
3
|
+
/** Cache tag of every form read: `revalidateTag('veroxm-forms')`. */
|
|
4
|
+
export declare const FORMS_TAG = "veroxm-forms";
|
|
5
|
+
export interface VeroxmFormProps {
|
|
6
|
+
/** The form's id (f_...), as field.form() gives it; nothing, to show `fallback`. */
|
|
7
|
+
form: string | null | undefined;
|
|
8
|
+
/** The page's language; the form's own language when it has no translation for it. */
|
|
9
|
+
locale?: string;
|
|
10
|
+
/** The page's context, sent with the answers: the selected product (key, slug or id) and its line (FB-21). */
|
|
11
|
+
context?: {
|
|
12
|
+
product?: string | null;
|
|
13
|
+
line?: string | null;
|
|
14
|
+
};
|
|
15
|
+
/** Values for the form's own hidden fields. */
|
|
16
|
+
hidden?: Record<string, string | number | null | undefined>;
|
|
17
|
+
/** Shown when there is no form, it's closed, or it can't be drawn on the page. */
|
|
18
|
+
fallback?: ReactNode;
|
|
19
|
+
submitLabel?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
style?: CSSProperties;
|
|
22
|
+
/** Seconds Next.js keeps the form's definition (default 60), or false until `veroxm-forms` is revalidated. */
|
|
23
|
+
revalidate?: number | false;
|
|
24
|
+
}
|
|
25
|
+
/** A published form as the respondent side serves it, or null when VeroXM can't be reached or doesn't have it. */
|
|
26
|
+
export declare function loadForm(publicId: string, opts?: {
|
|
27
|
+
revalidate?: number | false;
|
|
28
|
+
}): Promise<PublicForm | null>;
|
|
29
|
+
/** The language to show: the page's when the form has it (or its base language: "ar" for "ar-SA"), else the form's own. */
|
|
30
|
+
export declare function formLocale(def: {
|
|
31
|
+
locale: string;
|
|
32
|
+
translations?: Record<string, unknown>;
|
|
33
|
+
}, wanted: string | undefined): string;
|
|
34
|
+
export declare function VeroxmForm({ form, locale, context, hidden, fallback, submitLabel, className, style, revalidate }: VeroxmFormProps): Promise<import("react").JSX.Element>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { resolveSlotsConfig } from '../slots-core.js';
|
|
3
|
+
import { localizeForm, nativeProblem } from '../form-native/model.js';
|
|
4
|
+
import { VeroxmFormView } from '../form-native/view.js';
|
|
5
|
+
/** Cache tag of every form read: `revalidateTag('veroxm-forms')`. */
|
|
6
|
+
export const FORMS_TAG = 'veroxm-forms';
|
|
7
|
+
/** A published form as the respondent side serves it, or null when VeroXM can't be reached or doesn't have it. */
|
|
8
|
+
export async function loadForm(publicId, opts = {}) {
|
|
9
|
+
const cfg = resolveSlotsConfig();
|
|
10
|
+
if (!cfg.baseUrl || !cfg.fetch || !/^f_[A-Za-z0-9]{20}$/.test(publicId))
|
|
11
|
+
return null;
|
|
12
|
+
const res = await cfg
|
|
13
|
+
.fetch(`${cfg.baseUrl}/public/v2/forms/${publicId}`, {
|
|
14
|
+
headers: { Accept: 'application/json' },
|
|
15
|
+
next: { revalidate: opts.revalidate ?? 60, tags: [FORMS_TAG, `${FORMS_TAG}:${publicId}`] },
|
|
16
|
+
})
|
|
17
|
+
.catch(() => null);
|
|
18
|
+
if (!res?.ok)
|
|
19
|
+
return null;
|
|
20
|
+
return (await res.json().catch(() => null)) ?? null;
|
|
21
|
+
}
|
|
22
|
+
/** The language to show: the page's when the form has it (or its base language: "ar" for "ar-SA"), else the form's own. */
|
|
23
|
+
export function formLocale(def, wanted) {
|
|
24
|
+
const have = [def.locale, ...Object.keys(def.translations ?? {})];
|
|
25
|
+
if (!wanted)
|
|
26
|
+
return def.locale;
|
|
27
|
+
return have.find((l) => l.toLowerCase() === wanted.toLowerCase()) ?? have.find((l) => l.toLowerCase() === wanted.toLowerCase().split('-')[0]) ?? def.locale;
|
|
28
|
+
}
|
|
29
|
+
export async function VeroxmForm({ form, locale, context, hidden, fallback = null, submitLabel, className, style, revalidate }) {
|
|
30
|
+
if (!form)
|
|
31
|
+
return _jsx(_Fragment, { children: fallback });
|
|
32
|
+
const live = await loadForm(form, { revalidate });
|
|
33
|
+
if (!live?.open || !live.definition || live.signInRequired) {
|
|
34
|
+
return _jsx(_Fragment, { children: fallback ?? (live?.closedMessage ? _jsx("p", { children: live.closedMessage }) : null) });
|
|
35
|
+
}
|
|
36
|
+
const problem = nativeProblem(live.definition);
|
|
37
|
+
if (problem) {
|
|
38
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
39
|
+
console.warn(`[veroxm] form ${form} can't be drawn on the page (${problem}): show it with VeroxmForm from '@veroxm/react-sdk' (an embed) instead.`);
|
|
40
|
+
}
|
|
41
|
+
return _jsx(_Fragment, { children: fallback });
|
|
42
|
+
}
|
|
43
|
+
const shown = formLocale(live.definition, locale);
|
|
44
|
+
return (_jsx(VeroxmFormView
|
|
45
|
+
// The same form keeps what was typed when the product changes (FB-22); another form starts empty.
|
|
46
|
+
, { form: { ...live, definition: localizeForm(live.definition, shown) }, locale: shown, hidden: { ...hidden, product: context?.product ?? undefined, line: context?.line ?? undefined }, submitLabel: submitLabel, className: className, style: style }, form));
|
|
47
|
+
}
|
package/dist/next/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export { VeroxmComponentBoundary } from '../component-boundary.js';
|
|
|
9
9
|
export type { RegisteredComponent, ComponentSchema, SlotComponentValue } from '../slots-core.js';
|
|
10
10
|
export type { VeroxmRegionProps, RegionFallback, RenderComponentOptions } from '../components.js';
|
|
11
11
|
export { VeroxmEditor } from './editor.js';
|
|
12
|
+
export { VeroxmForm, loadForm, formLocale, FORMS_TAG } from './form.js';
|
|
13
|
+
export type { VeroxmFormProps } from './form.js';
|
|
12
14
|
export { field, configureSlots, loadSlot, mergeSlotValues } from '../slots-core.js';
|
|
13
15
|
export type { VeroxmSlotProps, SlotFieldDef, SlotFieldDefs, SlotValues, SlotInfo, SlotTest, SlotMedia, SlotLink, SlotMenuItem, SlotFallback, ListItemFieldDef, NestedListItemFieldDef, SlotVideo, SlotSlide, SlotMap, SlotPlace, SlotChart, SlotsConfig, LoadSlotOptions, SlotPerson, Label, LabelMap } from '../slots-core.js';
|
|
14
16
|
export { NavMenu } from '../site/nav-menu.js';
|
package/dist/next/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { defineComponent } from '../slots-core.js';
|
|
|
14
14
|
export { renderComponent, regionSlotProps } from '../components.js';
|
|
15
15
|
export { VeroxmComponentBoundary } from '../component-boundary.js';
|
|
16
16
|
export { VeroxmEditor } from './editor.js';
|
|
17
|
+
export { VeroxmForm, loadForm, formLocale, FORMS_TAG } from './form.js';
|
|
17
18
|
export { field, configureSlots, loadSlot, mergeSlotValues } from '../slots-core.js';
|
|
18
19
|
// Site parts (also in '@veroxm/react-sdk'), here so a Next.js site imports from one place.
|
|
19
20
|
export { NavMenu } from '../site/nav-menu.js';
|
package/dist/slots-core.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export type SlotFieldDef = (BaseField & {
|
|
|
39
39
|
max?: number;
|
|
40
40
|
}) | (BaseField & {
|
|
41
41
|
type: 'chart';
|
|
42
|
+
}) | (BaseField & {
|
|
43
|
+
type: 'form';
|
|
42
44
|
}) | (BaseField & {
|
|
43
45
|
type: 'component';
|
|
44
46
|
components: Record<string, ComponentSchema>;
|
|
@@ -56,7 +58,7 @@ export type NestedListItemFieldDef = Extract<SlotFieldDef, {
|
|
|
56
58
|
}>;
|
|
57
59
|
/** The field types a list's items can have: the simple ones, and one list of plain values (a card's ticked points). */
|
|
58
60
|
export type ListItemFieldDef = Extract<SlotFieldDef, {
|
|
59
|
-
type: 'text' | 'richText' | 'media' | 'link' | 'number' | 'boolean' | 'select';
|
|
61
|
+
type: 'text' | 'richText' | 'media' | 'link' | 'number' | 'boolean' | 'select' | 'form';
|
|
60
62
|
}> | (BaseField & {
|
|
61
63
|
type: 'list';
|
|
62
64
|
fields: Record<string, NestedListItemFieldDef>;
|
|
@@ -246,6 +248,17 @@ export declare const field: {
|
|
|
246
248
|
required?: boolean;
|
|
247
249
|
type: "chart";
|
|
248
250
|
};
|
|
251
|
+
/**
|
|
252
|
+
* A form built in VeroXM's Forms, chosen by a marketer from the project's published forms (or none): its id (f_...),
|
|
253
|
+
* for `<VeroxmForm form={...} />`. Also on list items, so each tab or product can carry its own form.
|
|
254
|
+
* @since 1.12.0
|
|
255
|
+
*/
|
|
256
|
+
form: (o?: BaseField) => {
|
|
257
|
+
/** What editors see: one text, or one per language ({ en: 'Tabs', ar: 'التبويبات' }). */
|
|
258
|
+
label?: Label;
|
|
259
|
+
required?: boolean;
|
|
260
|
+
type: "form";
|
|
261
|
+
};
|
|
249
262
|
/**
|
|
250
263
|
* One of the components you registered (defineComponent), chosen by a marketer, with that component's own fields.
|
|
251
264
|
* A component's fields can't be components or charts. Render the value with renderComponent.
|
|
@@ -349,6 +362,8 @@ type SlotValue<F> = F extends {
|
|
|
349
362
|
} ? SlotMap | null : F extends {
|
|
350
363
|
type: 'chart';
|
|
351
364
|
} ? SlotChart | null : F extends {
|
|
365
|
+
type: 'form';
|
|
366
|
+
} ? string | null : F extends {
|
|
352
367
|
type: 'component';
|
|
353
368
|
components: infer C extends Record<string, ComponentSchema>;
|
|
354
369
|
} ? {
|
package/dist/slots-core.js
CHANGED
|
@@ -61,6 +61,12 @@ export const field = {
|
|
|
61
61
|
map: (o = {}) => ({ type: 'map', ...o }),
|
|
62
62
|
/** A chart: numbers typed in, read from your own systems (Connected APIs), or from VeroXM's analytics. */
|
|
63
63
|
chart: (o = {}) => ({ type: 'chart', ...o }),
|
|
64
|
+
/**
|
|
65
|
+
* A form built in VeroXM's Forms, chosen by a marketer from the project's published forms (or none): its id (f_...),
|
|
66
|
+
* for `<VeroxmForm form={...} />`. Also on list items, so each tab or product can carry its own form.
|
|
67
|
+
* @since 1.12.0
|
|
68
|
+
*/
|
|
69
|
+
form: (o = {}) => ({ type: 'form', ...o }),
|
|
64
70
|
/**
|
|
65
71
|
* One of the components you registered (defineComponent), chosen by a marketer, with that component's own fields.
|
|
66
72
|
* A component's fields can't be components or charts. Render the value with renderComponent.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veroxm/react-sdk",
|
|
3
|
-
"version": "1.
|
|
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",
|