@vectoriox/iox-ui 5.186.0 → 5.188.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs +126 -6
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +14 -7
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +138 -9
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/forms-core/index.d.ts +68 -3
- package/generation-core/index.d.ts +4 -1
- package/index.d.ts +5 -0
- package/package.json +1 -1
- package/src/forms-core/form-presets.ts +5 -3
- package/src/forms-core/form-words.ts +140 -0
- package/src/forms-core/public-api.ts +1 -0
- package/src/forms-core/submit-lifecycle.ts +22 -2
- package/src/generation-core/compose-site.ts +6 -5
- package/src/generation-core/opening-mix.ts +7 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { FORM_SUBMIT_ACTION_DESCRIPTORS as ACTION_DESCRIPTORS, addableActions } from '@vectoriox/iox-ui/actions-core';
|
|
2
|
-
import { FieldClass } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
import { languageOf, FieldClass } from '@vectoriox/iox-ui/design-core';
|
|
3
3
|
export { FIELD_INVALID_CLASS, FieldClass, writeFieldError } from '@vectoriox/iox-ui/design-core';
|
|
4
4
|
|
|
5
5
|
// The persisted shape of a form. Pure types + the one derived constant each renderer needs.
|
|
@@ -1155,6 +1155,111 @@ function normaliseErrors(raw) {
|
|
|
1155
1155
|
return Object.keys(errors).length ? errors : undefined;
|
|
1156
1156
|
}
|
|
1157
1157
|
|
|
1158
|
+
/**
|
|
1159
|
+
* FORM WORDS — what a form part says the moment it lands on a page, in the SITE's language (iox-ui#159).
|
|
1160
|
+
*
|
|
1161
|
+
* ONE table for the words nobody wrote yet: a new Field's label, the plain Form's Name / Email / Send, each field kind's
|
|
1162
|
+
* label and starter choices (the Forms tray's Checkbox, Radio group, …), and a second channel's words (WhatsApp, Call
|
|
1163
|
+
* us, …). The builder's Form type, its field-kind presets and `addFormChannel`, and the admin's channel panel all read
|
|
1164
|
+
* it — a Hebrew site gets Hebrew parts from the tray, never English it has to retype. The English column IS the
|
|
1165
|
+
* baseline the builder's configs carry; `formWordIn` turns an untouched baseline word into the site's language.
|
|
1166
|
+
*
|
|
1167
|
+
* Data + lookups only: framework-free, like the rest of forms-core. The preset forms' own words stay in
|
|
1168
|
+
* `form-presets.ts` (`FORM_PRESET_WORDS_HE`); "While sending" and "Sent" in `submit-lifecycle.ts`.
|
|
1169
|
+
*/
|
|
1170
|
+
var FormWordsLanguage;
|
|
1171
|
+
(function (FormWordsLanguage) {
|
|
1172
|
+
FormWordsLanguage["En"] = "en";
|
|
1173
|
+
FormWordsLanguage["He"] = "he";
|
|
1174
|
+
})(FormWordsLanguage || (FormWordsLanguage = {}));
|
|
1175
|
+
const CHOICES_EN = 'First choice\nSecond choice\nThird choice';
|
|
1176
|
+
const CHOICES_HE = 'אפשרות ראשונה\nאפשרות שנייה\nאפשרות שלישית';
|
|
1177
|
+
|
|
1178
|
+
const FORM_WORDS = /* @__PURE__ */ Object.freeze({
|
|
1179
|
+
en: {
|
|
1180
|
+
field: 'Label',
|
|
1181
|
+
name: 'Name',
|
|
1182
|
+
email: 'Email',
|
|
1183
|
+
send: 'Send',
|
|
1184
|
+
kinds: {
|
|
1185
|
+
checkbox: { label: 'I agree' },
|
|
1186
|
+
switch: { label: 'Enable' },
|
|
1187
|
+
radio: { label: 'Pick one', optionsText: CHOICES_EN },
|
|
1188
|
+
choices: { label: 'What do you need?', optionsText: CHOICES_EN },
|
|
1189
|
+
select: { label: 'Choose', optionsText: CHOICES_EN },
|
|
1190
|
+
range: { label: 'How much' },
|
|
1191
|
+
date: { label: 'Date' },
|
|
1192
|
+
time: { label: 'Time' },
|
|
1193
|
+
},
|
|
1194
|
+
channels: {
|
|
1195
|
+
whatsapp: 'Message us on WhatsApp',
|
|
1196
|
+
phone: 'Call us',
|
|
1197
|
+
email: 'Email us',
|
|
1198
|
+
link: 'Book online',
|
|
1199
|
+
},
|
|
1200
|
+
},
|
|
1201
|
+
he: {
|
|
1202
|
+
field: 'שם השדה',
|
|
1203
|
+
name: 'שם',
|
|
1204
|
+
email: 'אימייל',
|
|
1205
|
+
send: 'שליחה',
|
|
1206
|
+
kinds: {
|
|
1207
|
+
checkbox: { label: 'אני מאשר/ת' },
|
|
1208
|
+
switch: { label: 'הפעלה' },
|
|
1209
|
+
radio: { label: 'בחרו אחת', optionsText: CHOICES_HE },
|
|
1210
|
+
choices: { label: 'מה אתם צריכים?', optionsText: CHOICES_HE },
|
|
1211
|
+
select: { label: 'בחירה', optionsText: CHOICES_HE },
|
|
1212
|
+
range: { label: 'כמה' },
|
|
1213
|
+
date: { label: 'תאריך' },
|
|
1214
|
+
time: { label: 'שעה' },
|
|
1215
|
+
},
|
|
1216
|
+
channels: {
|
|
1217
|
+
whatsapp: 'שלחו לנו הודעה בוואטסאפ',
|
|
1218
|
+
phone: 'התקשרו אלינו',
|
|
1219
|
+
email: 'כתבו לנו',
|
|
1220
|
+
link: 'הזמנה אונליין',
|
|
1221
|
+
},
|
|
1222
|
+
},
|
|
1223
|
+
});
|
|
1224
|
+
/** The language a form speaks for a `lang` attribute or site locale: design-core's subtag (`he-IL` → `he`), the old
|
|
1225
|
+
* `iw` read as `he`; '' when none. */
|
|
1226
|
+
function formLanguageOf(lang) {
|
|
1227
|
+
const language = languageOf(lang);
|
|
1228
|
+
return language === 'iw' ? 'he' : language;
|
|
1229
|
+
}
|
|
1230
|
+
/** The words in a site's language — English for any language the table does not hold, and when none is given. */
|
|
1231
|
+
function formWords(lang) {
|
|
1232
|
+
return ownWord(FORM_WORDS, formLanguageOf(lang)) ?? FORM_WORDS[FormWordsLanguage.En];
|
|
1233
|
+
}
|
|
1234
|
+
/** The baseline — what a builder config carries before anyone writes. */
|
|
1235
|
+
function baselineFormWords() {
|
|
1236
|
+
return FORM_WORDS[FormWordsLanguage.En];
|
|
1237
|
+
}
|
|
1238
|
+
/** A field kind's seeded label and choices in `lang`; undefined for a control the tray does not offer as a row. */
|
|
1239
|
+
function fieldKindWords(control, lang) {
|
|
1240
|
+
return ownWord(formWords(lang).kinds, control);
|
|
1241
|
+
}
|
|
1242
|
+
/** A channel's words in `lang` ('' for an unknown kind — the caller keeps what it has). */
|
|
1243
|
+
function channelWords(kind, lang) {
|
|
1244
|
+
return ownWord(formWords(lang).channels, kind) ?? '';
|
|
1245
|
+
}
|
|
1246
|
+
/** A table's own entry — never an inherited `constructor` or `toString` for a key someone typed. */
|
|
1247
|
+
function ownWord(table, key) {
|
|
1248
|
+
return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : undefined;
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* An UNTOUCHED baseline word in `lang`: when `value` is the English word one of `slots` carries, the site language's word
|
|
1252
|
+
* for that slot; anything an author wrote (or an empty value) comes back as it is. How a freshly created Form, Field or
|
|
1253
|
+
* submit button speaks the site's language without a second copy of its config.
|
|
1254
|
+
*/
|
|
1255
|
+
function formWordIn(value, lang, slots) {
|
|
1256
|
+
if (typeof value !== 'string' || !value)
|
|
1257
|
+
return value;
|
|
1258
|
+
const base = baselineFormWords();
|
|
1259
|
+
const slot = slots.find(s => base[s] === value);
|
|
1260
|
+
return slot ? formWords(lang)[slot] : value;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1158
1263
|
/**
|
|
1159
1264
|
* The submit LIFECYCLE's decisions — what a form shows after the server answers, what it says when a
|
|
1160
1265
|
* submit fails, what a client needs to validate a form, and how its submit button follows its state.
|
|
@@ -1263,8 +1368,23 @@ const SUBMIT_CHECK_SVG = `<svg class="${SubmitLabelClass.Check}" width="16" heig
|
|
|
1263
1368
|
* translation service — the document's `lang` picks, like the date picker's words). */
|
|
1264
1369
|
const SENT_WORDS = Object.freeze({ en: 'Sent', he: 'נשלח' });
|
|
1265
1370
|
function sentWord(lang) {
|
|
1266
|
-
|
|
1267
|
-
|
|
1371
|
+
return SENT_WORDS[formLanguageOf(lang)] ?? SENT_WORDS['en'];
|
|
1372
|
+
}
|
|
1373
|
+
/** "While sending" in the site's language (iox-ui#158). The English one is the SubmitButton's baseline
|
|
1374
|
+
* (`loadingLabel`), which every stamped node carries until its author writes their own. */
|
|
1375
|
+
const BUSY_WORDS = Object.freeze({ en: 'Sending…', he: 'שולחים…' });
|
|
1376
|
+
/** The SubmitButton's baseline "While sending" words — what a node holds that nobody wrote. */
|
|
1377
|
+
const DEFAULT_BUSY_WORDS = BUSY_WORDS['en'];
|
|
1378
|
+
function busyWord(lang) {
|
|
1379
|
+
return BUSY_WORDS[formLanguageOf(lang)] ?? DEFAULT_BUSY_WORDS;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* What a submit button says while its form sends, in BOTH renderers (iox-ui#158): the author's words; the untouched
|
|
1383
|
+
* English baseline (or none set at all) in the page's language — a Hebrew site built before its composer wrote Hebrew
|
|
1384
|
+
* here says "שולחים…" without a rebuild. An empty string stays empty: the button keeps its idle words while sending.
|
|
1385
|
+
*/
|
|
1386
|
+
function submitBusyWords(loadingLabel, lang) {
|
|
1387
|
+
return loadingLabel == null || loadingLabel === DEFAULT_BUSY_WORDS ? busyWord(lang) : loadingLabel;
|
|
1268
1388
|
}
|
|
1269
1389
|
/**
|
|
1270
1390
|
* A submit button's words, as markup: its three labels stacked in one grid cell (the button keeps the longest one's
|
|
@@ -1444,7 +1564,6 @@ const FORM_PRESET_WORDS_HE = /* @__PURE__ */ Object.freeze({
|
|
|
1444
1564
|
submitLabel: 'שליחה',
|
|
1445
1565
|
successText: 'תודה — נחזור אליכם בקרוב.',
|
|
1446
1566
|
errorText: 'לא הצלחנו לשלוח את הפרטים. נסו שוב — התשובות שלכם עדיין כאן.',
|
|
1447
|
-
channel: 'שלחו לנו הודעה בוואטסאפ',
|
|
1448
1567
|
},
|
|
1449
1568
|
});
|
|
1450
1569
|
/** A preset in a language: Hebrew when `lang` is, else the preset as it is. Fresh objects; the shape never changes. */
|
|
@@ -1457,7 +1576,8 @@ function formPresetIn(def, lang) {
|
|
|
1457
1576
|
formName: he.formName,
|
|
1458
1577
|
fields: def.fields.map((f, i) => ({ ...f, ...(he.fields[i] ?? {}) })),
|
|
1459
1578
|
submitLabel: he.submitLabel, successText: he.successText, errorText: he.errorText,
|
|
1460
|
-
|
|
1579
|
+
// The channel's words are the kind's own (`form-words.ts`, iox-ui#159) unless the preset says otherwise.
|
|
1580
|
+
...(def.channel ? { channel: { ...def.channel, label: he.channel ?? (channelWords(def.channel.kind, 'he') || def.channel.label) } } : {}),
|
|
1461
1581
|
};
|
|
1462
1582
|
}
|
|
1463
1583
|
/** The config key of an email step that goes to the studio owner's account address (iox-cms#84). */
|
|
@@ -1763,5 +1883,5 @@ function dateHtml(p, options, describedBy) {
|
|
|
1763
1883
|
* Generated bundle index. Do not edit.
|
|
1764
1884
|
*/
|
|
1765
1885
|
|
|
1766
|
-
export { CALENDAR_ROWS, CHANNEL_KINDS, CHOICE_MESSAGE_KEYS, CalendarKey, ChannelKind, ChoiceAppearance, ControlType, DATE_EMPTY_ATTRIBUTE, DATE_ICON_SVG, DATE_MAX_ATTRIBUTE, DATE_MESSAGE_KEYS, DATE_MIN_ATTRIBUTE, DATE_PICKER_WORDS, DEFAULT_EN_MESSAGES, EMAIL_TO_OWNER, FIELD_GROUP_NODE_TYPE, FIELD_NODE_TYPE, FORM_ACTIONS_ROLE, FORM_AFTER_SEND_ATTRIBUTE, FORM_AFTER_SEND_TRAIT, FORM_ANNOUNCER_ATTRIBUTE, FORM_CHANNEL_ROLE, FORM_CONTENT_TYPES, FORM_ERROR_KEYS, FORM_FIELDS_ATTRIBUTE, FORM_HONEYPOT_CLASS, FORM_NODE_TYPE, FORM_PRESETS, FORM_PRESET_WORDS_HE, FORM_STATE_ATTRIBUTE, FeedbackTiming, FormAfterSend, FormPresetId, FormRenderState, HONEYPOT_FIELD, IMPLIED_PATTERN, INITIAL_FORM_STATE, INTERACTIVE_HOST_TAGS, InteractiveTag, MESSAGE_NAMESPACE, OPTION_CONTROLS, PATTERN_MESSAGE_KEYS, PATTERN_PRESETS, PATTERN_PRESET_OPTIONS, PatternPreset, RENDERED_AT_FIELD, RULE_DESCRIPTORS, RULE_MESSAGE_KEYS, RuleName, RuleParamKind, STORE_ACTION, SUBMIT_BUTTON_NODE_TYPE, SUBMIT_CHECK_SVG, SUBMIT_KEEP_ENABLED_ATTRIBUTE, SUBMIT_MESSAGE_KEYS, SubmitLabelClass, addDaysIso, addMonthsIso, addableRules, applyServerErrors, baseFieldName, calendarKeyTarget, calendarMonth, channelHref, channelOpensNewTab, choiceAppearanceOf, clampIso, clientFormSpec, collectFieldNodes, collectFormSpec, dateBoundRules, dateOfIso, datePickerWords, deriveFieldName, emailsOwner, failureAnnouncement, fieldDateRange, fieldHtml, fieldOptionsOf, fieldSpecOf, findFormContentInHosts, firstInvalidField, formAfterSend, formChromeHtml, formContentInHost, formFieldNameMap, formFieldNames, formPresetById, formPresetIn, formatDateInWords, inputTypeOf, interpretSubmitResponse, isChannelFilled, isDateBoundParams, isDateField, isFormContent, isInteractiveHost, isIsoDate, isMultiValueField, isoOfDate, normaliseAnswers, onFieldBlur, onFieldChange, onSubmitAttempt, parseChannelHref, parseClientFormSpec, parseDateBound, parseFieldOptions, planFormPresetIds, presetFormActions, resetFormState, resolveDateBound, rulesFor, sentWord, shouldShowError, submitButtonLabelsHtml, submitButtonView, submitEndpointPath, submitOutcome, todayIso, uniqueFieldName, uniqueFieldNames, validateField, validateForm, weekStartFor, withAntiSpamFields };
|
|
1886
|
+
export { CALENDAR_ROWS, CHANNEL_KINDS, CHOICE_MESSAGE_KEYS, CalendarKey, ChannelKind, ChoiceAppearance, ControlType, DATE_EMPTY_ATTRIBUTE, DATE_ICON_SVG, DATE_MAX_ATTRIBUTE, DATE_MESSAGE_KEYS, DATE_MIN_ATTRIBUTE, DATE_PICKER_WORDS, DEFAULT_BUSY_WORDS, DEFAULT_EN_MESSAGES, EMAIL_TO_OWNER, FIELD_GROUP_NODE_TYPE, FIELD_NODE_TYPE, FORM_ACTIONS_ROLE, FORM_AFTER_SEND_ATTRIBUTE, FORM_AFTER_SEND_TRAIT, FORM_ANNOUNCER_ATTRIBUTE, FORM_CHANNEL_ROLE, FORM_CONTENT_TYPES, FORM_ERROR_KEYS, FORM_FIELDS_ATTRIBUTE, FORM_HONEYPOT_CLASS, FORM_NODE_TYPE, FORM_PRESETS, FORM_PRESET_WORDS_HE, FORM_STATE_ATTRIBUTE, FeedbackTiming, FormAfterSend, FormPresetId, FormRenderState, FormWordsLanguage, HONEYPOT_FIELD, IMPLIED_PATTERN, INITIAL_FORM_STATE, INTERACTIVE_HOST_TAGS, InteractiveTag, MESSAGE_NAMESPACE, OPTION_CONTROLS, PATTERN_MESSAGE_KEYS, PATTERN_PRESETS, PATTERN_PRESET_OPTIONS, PatternPreset, RENDERED_AT_FIELD, RULE_DESCRIPTORS, RULE_MESSAGE_KEYS, RuleName, RuleParamKind, STORE_ACTION, SUBMIT_BUTTON_NODE_TYPE, SUBMIT_CHECK_SVG, SUBMIT_KEEP_ENABLED_ATTRIBUTE, SUBMIT_MESSAGE_KEYS, SubmitLabelClass, addDaysIso, addMonthsIso, addableRules, applyServerErrors, baseFieldName, baselineFormWords, busyWord, calendarKeyTarget, calendarMonth, channelHref, channelOpensNewTab, channelWords, choiceAppearanceOf, clampIso, clientFormSpec, collectFieldNodes, collectFormSpec, dateBoundRules, dateOfIso, datePickerWords, deriveFieldName, emailsOwner, failureAnnouncement, fieldDateRange, fieldHtml, fieldKindWords, fieldOptionsOf, fieldSpecOf, findFormContentInHosts, firstInvalidField, formAfterSend, formChromeHtml, formContentInHost, formFieldNameMap, formFieldNames, formLanguageOf, formPresetById, formPresetIn, formWordIn, formWords, formatDateInWords, inputTypeOf, interpretSubmitResponse, isChannelFilled, isDateBoundParams, isDateField, isFormContent, isInteractiveHost, isIsoDate, isMultiValueField, isoOfDate, normaliseAnswers, onFieldBlur, onFieldChange, onSubmitAttempt, parseChannelHref, parseClientFormSpec, parseDateBound, parseFieldOptions, planFormPresetIds, presetFormActions, resetFormState, resolveDateBound, rulesFor, sentWord, shouldShowError, submitBusyWords, submitButtonLabelsHtml, submitButtonView, submitEndpointPath, submitOutcome, todayIso, uniqueFieldName, uniqueFieldNames, validateField, validateForm, weekStartFor, withAntiSpamFields };
|
|
1767
1887
|
//# sourceMappingURL=vectoriox-iox-ui-forms-core.mjs.map
|