@vectoriox/iox-ui 5.193.0 → 5.194.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 +186 -122
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +193 -95
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +194 -132
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/forms-core/index.d.ts +17 -2
- package/harness-core/index.d.ts +102 -12
- package/index.d.ts +7 -5
- package/package.json +1 -1
- package/src/forms-core/messages.ts +72 -1
- package/src/forms-core/submit-lifecycle.ts +4 -5
- package/src/harness-core/business-types.ts +14 -9
- package/src/harness-core/harness-spec.generated.ts +168 -84
- package/src/harness-core/lint.ts +29 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { FORM_SUBMIT_ACTION_DESCRIPTORS as ACTION_DESCRIPTORS, addableActions } from '@vectoriox/iox-ui/actions-core';
|
|
2
1
|
import { languageOf, FieldClass } from '@vectoriox/iox-ui/design-core';
|
|
3
2
|
export { FIELD_INVALID_CLASS, FieldClass, writeFieldError } from '@vectoriox/iox-ui/design-core';
|
|
3
|
+
export { FORM_SUBMIT_ACTION_DESCRIPTORS as ACTION_DESCRIPTORS, addableActions } from '@vectoriox/iox-ui/actions-core';
|
|
4
4
|
|
|
5
5
|
// The persisted shape of a form. Pure types + the one derived constant each renderer needs.
|
|
6
6
|
//
|
|
@@ -121,6 +121,121 @@ function isMultiValueField(field) {
|
|
|
121
121
|
/** The controls whose answers must be one of the field's own options (the implied `oneOf` rule). */
|
|
122
122
|
const OPTION_CONTROLS = new Set([ControlType.Choices, ControlType.Radio, ControlType.Select]);
|
|
123
123
|
|
|
124
|
+
/**
|
|
125
|
+
* FORM WORDS — what a form part says the moment it lands on a page, in the SITE's language (iox-ui#159).
|
|
126
|
+
*
|
|
127
|
+
* ONE table for the words nobody wrote yet: a new Field's label, the plain Form's Name / Email / Send, each field kind's
|
|
128
|
+
* label and starter choices (the Forms tray's Checkbox, Radio group, …), and a second channel's words (WhatsApp, Call
|
|
129
|
+
* us, …). The builder's Form type, its field-kind presets and `addFormChannel`, and the admin's channel panel all read
|
|
130
|
+
* it — a Hebrew site gets Hebrew parts from the tray, never English it has to retype. The English column IS the
|
|
131
|
+
* baseline the builder's configs carry; `formWordIn` turns an untouched baseline word into the site's language.
|
|
132
|
+
*
|
|
133
|
+
* Data + lookups only: framework-free, like the rest of forms-core. The preset forms' own words stay in
|
|
134
|
+
* `form-presets.ts` (`FORM_PRESET_WORDS_HE`); "While sending" and "Sent" in `submit-lifecycle.ts`.
|
|
135
|
+
*/
|
|
136
|
+
var FormWordsLanguage;
|
|
137
|
+
(function (FormWordsLanguage) {
|
|
138
|
+
FormWordsLanguage["En"] = "en";
|
|
139
|
+
FormWordsLanguage["He"] = "he";
|
|
140
|
+
})(FormWordsLanguage || (FormWordsLanguage = {}));
|
|
141
|
+
const CHOICES_EN = 'First choice\nSecond choice\nThird choice';
|
|
142
|
+
const CHOICES_HE = 'אפשרות ראשונה\nאפשרות שנייה\nאפשרות שלישית';
|
|
143
|
+
|
|
144
|
+
const FORM_WORDS = /* @__PURE__ */ Object.freeze({
|
|
145
|
+
en: {
|
|
146
|
+
field: 'Label',
|
|
147
|
+
name: 'Name',
|
|
148
|
+
email: 'Email',
|
|
149
|
+
send: 'Send',
|
|
150
|
+
kinds: {
|
|
151
|
+
checkbox: { label: 'I agree' },
|
|
152
|
+
switch: { label: 'Enable' },
|
|
153
|
+
radio: { label: 'Pick one', optionsText: CHOICES_EN },
|
|
154
|
+
choices: { label: 'What do you need?', optionsText: CHOICES_EN },
|
|
155
|
+
select: { label: 'Choose', optionsText: CHOICES_EN },
|
|
156
|
+
range: { label: 'How much' },
|
|
157
|
+
date: { label: 'Date' },
|
|
158
|
+
time: { label: 'Time' },
|
|
159
|
+
},
|
|
160
|
+
channels: {
|
|
161
|
+
whatsapp: 'Message us on WhatsApp',
|
|
162
|
+
phone: 'Call us',
|
|
163
|
+
email: 'Email us',
|
|
164
|
+
link: 'Book online',
|
|
165
|
+
},
|
|
166
|
+
announce: {
|
|
167
|
+
failed: 'That did not send.',
|
|
168
|
+
oneField: '1 field needs attention.',
|
|
169
|
+
fields: '{count} fields need attention.',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
he: {
|
|
173
|
+
field: 'שם השדה',
|
|
174
|
+
name: 'שם',
|
|
175
|
+
email: 'אימייל',
|
|
176
|
+
send: 'שליחה',
|
|
177
|
+
kinds: {
|
|
178
|
+
checkbox: { label: 'אני מאשר/ת' },
|
|
179
|
+
switch: { label: 'הפעלה' },
|
|
180
|
+
radio: { label: 'בחרו אחת', optionsText: CHOICES_HE },
|
|
181
|
+
choices: { label: 'מה אתם צריכים?', optionsText: CHOICES_HE },
|
|
182
|
+
select: { label: 'בחירה', optionsText: CHOICES_HE },
|
|
183
|
+
range: { label: 'כמה' },
|
|
184
|
+
date: { label: 'תאריך' },
|
|
185
|
+
time: { label: 'שעה' },
|
|
186
|
+
},
|
|
187
|
+
channels: {
|
|
188
|
+
whatsapp: 'שלחו לנו הודעה בוואטסאפ',
|
|
189
|
+
phone: 'התקשרו אלינו',
|
|
190
|
+
email: 'כתבו לנו',
|
|
191
|
+
link: 'הזמנה אונליין',
|
|
192
|
+
},
|
|
193
|
+
announce: {
|
|
194
|
+
failed: 'השליחה לא הצליחה.',
|
|
195
|
+
oneField: 'שדה אחד דורש תשומת לב.',
|
|
196
|
+
fields: '{count} שדות דורשים תשומת לב.',
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
/** The language a form speaks for a `lang` attribute or site locale: design-core's subtag (`he-IL` → `he`), the old
|
|
201
|
+
* `iw` read as `he`; '' when none. */
|
|
202
|
+
function formLanguageOf(lang) {
|
|
203
|
+
const language = languageOf(lang);
|
|
204
|
+
return language === 'iw' ? 'he' : language;
|
|
205
|
+
}
|
|
206
|
+
/** The words in a site's language — English for any language the table does not hold, and when none is given. */
|
|
207
|
+
function formWords(lang) {
|
|
208
|
+
return ownWord(FORM_WORDS, formLanguageOf(lang)) ?? FORM_WORDS[FormWordsLanguage.En];
|
|
209
|
+
}
|
|
210
|
+
/** The baseline — what a builder config carries before anyone writes. */
|
|
211
|
+
function baselineFormWords() {
|
|
212
|
+
return FORM_WORDS[FormWordsLanguage.En];
|
|
213
|
+
}
|
|
214
|
+
/** A field kind's seeded label and choices in `lang`; undefined for a control the tray does not offer as a row. */
|
|
215
|
+
function fieldKindWords(control, lang) {
|
|
216
|
+
return ownWord(formWords(lang).kinds, control);
|
|
217
|
+
}
|
|
218
|
+
/** A channel's words in `lang` ('' for an unknown kind — the caller keeps what it has). */
|
|
219
|
+
function channelWords(kind, lang) {
|
|
220
|
+
return ownWord(formWords(lang).channels, kind) ?? '';
|
|
221
|
+
}
|
|
222
|
+
/** A table's own entry — never an inherited `constructor` or `toString` for a key someone typed. */
|
|
223
|
+
function ownWord(table, key) {
|
|
224
|
+
return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : undefined;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* An UNTOUCHED baseline word in `lang`: when `value` is the English word one of `slots` carries, the site language's word
|
|
228
|
+
* for that slot; anything an author wrote (or an empty value) comes back as it is. How a freshly created Form, Field or
|
|
229
|
+
* submit button speaks the site's language without a second copy of its config.
|
|
230
|
+
*/
|
|
231
|
+
function formWordIn(value, lang, slots) {
|
|
232
|
+
if (typeof value !== 'string' || !value)
|
|
233
|
+
return value;
|
|
234
|
+
const base = baselineFormWords();
|
|
235
|
+
const slot = slots.find(s => base[s] === value);
|
|
236
|
+
return slot ? formWords(lang)[slot] : value;
|
|
237
|
+
}
|
|
238
|
+
|
|
124
239
|
// The default message for every rule, as an i18n KEY — never a rendered string.
|
|
125
240
|
//
|
|
126
241
|
// This is what lets the Validation panel stay empty and still produce good errors: an author who
|
|
@@ -192,7 +307,8 @@ const FORM_ERROR_KEYS = Object.freeze({
|
|
|
192
307
|
RateLimited: `${MESSAGE_NAMESPACE}.form.rateLimited`,
|
|
193
308
|
Server: `${MESSAGE_NAMESPACE}.form.server`,
|
|
194
309
|
});
|
|
195
|
-
/** The English
|
|
310
|
+
/** The English column of the ONE forms message catalog (`formMessage`) — what a site in any language the catalog does not
|
|
311
|
+
* hold reads, and what a consumer that has not added the keys yet still shows. */
|
|
196
312
|
const DEFAULT_EN_MESSAGES = Object.freeze({
|
|
197
313
|
[RULE_MESSAGE_KEYS[RuleName.Required]]: 'This field is required',
|
|
198
314
|
[RULE_MESSAGE_KEYS[RuleName.MinLength]]: 'Use at least {{n}} characters',
|
|
@@ -224,6 +340,70 @@ const DEFAULT_EN_MESSAGES = Object.freeze({
|
|
|
224
340
|
[DATE_MESSAGE_KEYS.Max]: 'Choose an earlier date',
|
|
225
341
|
[SUBMIT_MESSAGE_KEYS.Sent]: 'Sent',
|
|
226
342
|
});
|
|
343
|
+
/**
|
|
344
|
+
* The Hebrew column (iox-client-engine#15). A visitor is spoken to in the plural imperative, like every other word a site
|
|
345
|
+
* says (`form-words.ts`: בחרו, כתבו לנו). Every key of the English column has its entry here — a spec holds that.
|
|
346
|
+
*/
|
|
347
|
+
const HE_MESSAGES = /* @__PURE__ */ Object.freeze({
|
|
348
|
+
[RULE_MESSAGE_KEYS[RuleName.Required]]: 'שדה חובה',
|
|
349
|
+
[RULE_MESSAGE_KEYS[RuleName.MinLength]]: 'כתבו לפחות {{n}} תווים',
|
|
350
|
+
[RULE_MESSAGE_KEYS[RuleName.MaxLength]]: 'כתבו עד {{n}} תווים',
|
|
351
|
+
[RULE_MESSAGE_KEYS[RuleName.Min]]: 'הזינו {{n}} או יותר',
|
|
352
|
+
[RULE_MESSAGE_KEYS[RuleName.Max]]: 'הזינו {{n}} או פחות',
|
|
353
|
+
[RULE_MESSAGE_KEYS[RuleName.Pattern]]: 'בדקו את צורת הערך',
|
|
354
|
+
[RULE_MESSAGE_KEYS[RuleName.Matches]]: 'הערך צריך להתאים לשדה {{field}}',
|
|
355
|
+
[RULE_MESSAGE_KEYS[RuleName.Accepted]]: 'סמנו כדי להמשיך',
|
|
356
|
+
[RULE_MESSAGE_KEYS[RuleName.FileType]]: 'סוג הקובץ הזה לא מתקבל',
|
|
357
|
+
[RULE_MESSAGE_KEYS[RuleName.FileSize]]: 'הקובץ גדול מ-{{n}}MB',
|
|
358
|
+
[PATTERN_MESSAGE_KEYS['email']]: 'הזינו כתובת אימייל תקינה',
|
|
359
|
+
[PATTERN_MESSAGE_KEYS['phone']]: 'הזינו מספר טלפון תקין',
|
|
360
|
+
[PATTERN_MESSAGE_KEYS['url']]: 'הזינו כתובת אתר תקינה',
|
|
361
|
+
[PATTERN_MESSAGE_KEYS['digits']]: 'ספרות בלבד',
|
|
362
|
+
[PATTERN_MESSAGE_KEYS['letters']]: 'אותיות בלבד',
|
|
363
|
+
[PATTERN_MESSAGE_KEYS['slug']]: 'אותיות לטיניות קטנות, ספרות ומקפים',
|
|
364
|
+
[FORM_ERROR_KEYS.Network]: 'לא הצלחנו להגיע לשרת — בדקו את החיבור ונסו שוב',
|
|
365
|
+
[FORM_ERROR_KEYS.Rejected]: 'יש תשובות שצריך לתקן',
|
|
366
|
+
[FORM_ERROR_KEYS.Spam]: 'לא יכולנו לקבל את השליחה הזו',
|
|
367
|
+
[FORM_ERROR_KEYS.RateLimited]: 'יותר מדי ניסיונות — חכו רגע ונסו שוב',
|
|
368
|
+
[FORM_ERROR_KEYS.Server]: 'משהו השתבש אצלנו — התשובות שלכם עדיין כאן',
|
|
369
|
+
[RULE_MESSAGE_KEYS[RuleName.OneOf]]: 'בחרו אחת מהאפשרויות',
|
|
370
|
+
[RULE_MESSAGE_KEYS[RuleName.ValidDate]]: 'בחרו תאריך מלוח השנה',
|
|
371
|
+
[CHOICE_MESSAGE_KEYS.One]: 'בחרו אפשרות',
|
|
372
|
+
[CHOICE_MESSAGE_KEYS.Some]: 'בחרו לפחות אחת',
|
|
373
|
+
[CHOICE_MESSAGE_KEYS.Date]: 'בחרו תאריך',
|
|
374
|
+
[DATE_MESSAGE_KEYS.Min]: 'בחרו תאריך מאוחר יותר',
|
|
375
|
+
[DATE_MESSAGE_KEYS.Max]: 'בחרו תאריך מוקדם יותר',
|
|
376
|
+
[SUBMIT_MESSAGE_KEYS.Sent]: 'נשלח',
|
|
377
|
+
});
|
|
378
|
+
/** The catalog, by the language `formLanguageOf` reads. */
|
|
379
|
+
const FORM_MESSAGES = /* @__PURE__ */ Object.freeze({
|
|
380
|
+
en: DEFAULT_EN_MESSAGES,
|
|
381
|
+
he: HE_MESSAGES,
|
|
382
|
+
});
|
|
383
|
+
/** The languages the catalog holds. */
|
|
384
|
+
const FORM_MESSAGE_LANGUAGES = Object.freeze(['en', 'he']);
|
|
385
|
+
/** The whole column for `lang` (`he-IL` → he, `iw` → he) — English for a language the catalog does not hold. */
|
|
386
|
+
function formMessages(lang) {
|
|
387
|
+
const language = formLanguageOf(lang);
|
|
388
|
+
return Object.prototype.hasOwnProperty.call(FORM_MESSAGES, language) ? FORM_MESSAGES[language] : DEFAULT_EN_MESSAGES;
|
|
389
|
+
}
|
|
390
|
+
/** `{{n}}` / `{{field}}` placed where the sentence's grammar put them; a missing param reads as ''. */
|
|
391
|
+
function interpolateMessage(template, params) {
|
|
392
|
+
if (!params)
|
|
393
|
+
return template;
|
|
394
|
+
return template.replace(/\{\{(\w+)\}\}/g, (_, name) => String(params[name] ?? ''));
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* A message KEY as the sentence a visitor reads, in the page's language — THE reading both renderers make (the
|
|
398
|
+
* component path's default `IOX_FORM_MESSAGES`, the string runtime's): `lang`'s sentence, else the English one, else the
|
|
399
|
+
* key itself (an author's own message, which travels as its text).
|
|
400
|
+
*/
|
|
401
|
+
function formMessage(key, params, lang) {
|
|
402
|
+
const own = formMessages(lang);
|
|
403
|
+
const template = Object.prototype.hasOwnProperty.call(own, key) ? own[key]
|
|
404
|
+
: Object.prototype.hasOwnProperty.call(DEFAULT_EN_MESSAGES, key) ? DEFAULT_EN_MESSAGES[key] : key;
|
|
405
|
+
return interpolateMessage(template, params);
|
|
406
|
+
}
|
|
227
407
|
|
|
228
408
|
/**
|
|
229
409
|
* DATES — the date picker's pure half (premium components N8) and the date rules' one reading.
|
|
@@ -1155,121 +1335,6 @@ function normaliseErrors(raw) {
|
|
|
1155
1335
|
return Object.keys(errors).length ? errors : undefined;
|
|
1156
1336
|
}
|
|
1157
1337
|
|
|
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
|
-
announce: {
|
|
1201
|
-
failed: 'That did not send.',
|
|
1202
|
-
oneField: '1 field needs attention.',
|
|
1203
|
-
fields: '{count} fields need attention.',
|
|
1204
|
-
},
|
|
1205
|
-
},
|
|
1206
|
-
he: {
|
|
1207
|
-
field: 'שם השדה',
|
|
1208
|
-
name: 'שם',
|
|
1209
|
-
email: 'אימייל',
|
|
1210
|
-
send: 'שליחה',
|
|
1211
|
-
kinds: {
|
|
1212
|
-
checkbox: { label: 'אני מאשר/ת' },
|
|
1213
|
-
switch: { label: 'הפעלה' },
|
|
1214
|
-
radio: { label: 'בחרו אחת', optionsText: CHOICES_HE },
|
|
1215
|
-
choices: { label: 'מה אתם צריכים?', optionsText: CHOICES_HE },
|
|
1216
|
-
select: { label: 'בחירה', optionsText: CHOICES_HE },
|
|
1217
|
-
range: { label: 'כמה' },
|
|
1218
|
-
date: { label: 'תאריך' },
|
|
1219
|
-
time: { label: 'שעה' },
|
|
1220
|
-
},
|
|
1221
|
-
channels: {
|
|
1222
|
-
whatsapp: 'שלחו לנו הודעה בוואטסאפ',
|
|
1223
|
-
phone: 'התקשרו אלינו',
|
|
1224
|
-
email: 'כתבו לנו',
|
|
1225
|
-
link: 'הזמנה אונליין',
|
|
1226
|
-
},
|
|
1227
|
-
announce: {
|
|
1228
|
-
failed: 'השליחה לא הצליחה.',
|
|
1229
|
-
oneField: 'שדה אחד דורש תשומת לב.',
|
|
1230
|
-
fields: '{count} שדות דורשים תשומת לב.',
|
|
1231
|
-
},
|
|
1232
|
-
},
|
|
1233
|
-
});
|
|
1234
|
-
/** The language a form speaks for a `lang` attribute or site locale: design-core's subtag (`he-IL` → `he`), the old
|
|
1235
|
-
* `iw` read as `he`; '' when none. */
|
|
1236
|
-
function formLanguageOf(lang) {
|
|
1237
|
-
const language = languageOf(lang);
|
|
1238
|
-
return language === 'iw' ? 'he' : language;
|
|
1239
|
-
}
|
|
1240
|
-
/** The words in a site's language — English for any language the table does not hold, and when none is given. */
|
|
1241
|
-
function formWords(lang) {
|
|
1242
|
-
return ownWord(FORM_WORDS, formLanguageOf(lang)) ?? FORM_WORDS[FormWordsLanguage.En];
|
|
1243
|
-
}
|
|
1244
|
-
/** The baseline — what a builder config carries before anyone writes. */
|
|
1245
|
-
function baselineFormWords() {
|
|
1246
|
-
return FORM_WORDS[FormWordsLanguage.En];
|
|
1247
|
-
}
|
|
1248
|
-
/** A field kind's seeded label and choices in `lang`; undefined for a control the tray does not offer as a row. */
|
|
1249
|
-
function fieldKindWords(control, lang) {
|
|
1250
|
-
return ownWord(formWords(lang).kinds, control);
|
|
1251
|
-
}
|
|
1252
|
-
/** A channel's words in `lang` ('' for an unknown kind — the caller keeps what it has). */
|
|
1253
|
-
function channelWords(kind, lang) {
|
|
1254
|
-
return ownWord(formWords(lang).channels, kind) ?? '';
|
|
1255
|
-
}
|
|
1256
|
-
/** A table's own entry — never an inherited `constructor` or `toString` for a key someone typed. */
|
|
1257
|
-
function ownWord(table, key) {
|
|
1258
|
-
return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : undefined;
|
|
1259
|
-
}
|
|
1260
|
-
/**
|
|
1261
|
-
* An UNTOUCHED baseline word in `lang`: when `value` is the English word one of `slots` carries, the site language's word
|
|
1262
|
-
* for that slot; anything an author wrote (or an empty value) comes back as it is. How a freshly created Form, Field or
|
|
1263
|
-
* submit button speaks the site's language without a second copy of its config.
|
|
1264
|
-
*/
|
|
1265
|
-
function formWordIn(value, lang, slots) {
|
|
1266
|
-
if (typeof value !== 'string' || !value)
|
|
1267
|
-
return value;
|
|
1268
|
-
const base = baselineFormWords();
|
|
1269
|
-
const slot = slots.find(s => base[s] === value);
|
|
1270
|
-
return slot ? formWords(lang)[slot] : value;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
1338
|
/**
|
|
1274
1339
|
* The submit LIFECYCLE's decisions — what a form shows after the server answers, what it says when a
|
|
1275
1340
|
* submit fails, what a client needs to validate a form, and how its submit button follows its state.
|
|
@@ -1379,11 +1444,10 @@ var SubmitLabelClass;
|
|
|
1379
1444
|
* the shared CSS draws it by `stroke-dashoffset` whatever its real length. */
|
|
1380
1445
|
const SUBMIT_CHECK_SVG = `<svg class="${SubmitLabelClass.Check}" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true" focusable="false">` +
|
|
1381
1446
|
'<path d="M5 12.5l4.5 4.5L19 7.5" pathLength="100" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
1382
|
-
/** "Sent" in the site's language, for a button whose author wrote no Sent words
|
|
1383
|
-
*
|
|
1384
|
-
const SENT_WORDS = Object.freeze({ en: 'Sent', he: 'נשלח' });
|
|
1447
|
+
/** "Sent" in the site's language, for a button whose author wrote no Sent words — the forms message catalog's
|
|
1448
|
+
* (`formMessage`), the document's `lang` picking, like the date picker's words. */
|
|
1385
1449
|
function sentWord(lang) {
|
|
1386
|
-
return
|
|
1450
|
+
return formMessage(SUBMIT_MESSAGE_KEYS.Sent, null, lang);
|
|
1387
1451
|
}
|
|
1388
1452
|
/** "While sending" in the site's language (iox-ui#158). The English one is the SubmitButton's baseline
|
|
1389
1453
|
* (`loadingLabel`), which every stamped node carries until its author writes their own. */
|
|
@@ -1898,5 +1962,5 @@ function dateHtml(p, options, describedBy) {
|
|
|
1898
1962
|
* Generated bundle index. Do not edit.
|
|
1899
1963
|
*/
|
|
1900
1964
|
|
|
1901
|
-
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 };
|
|
1965
|
+
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_MESSAGE_LANGUAGES, 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, formMessage, formMessages, formPresetById, formPresetIn, formWordIn, formWords, formatDateInWords, inputTypeOf, interpolateMessage, 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 };
|
|
1902
1966
|
//# sourceMappingURL=vectoriox-iox-ui-forms-core.mjs.map
|