@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
|
@@ -4075,6 +4075,121 @@ function isMultiValueField(field) {
|
|
|
4075
4075
|
/** The controls whose answers must be one of the field's own options (the implied `oneOf` rule). */
|
|
4076
4076
|
const OPTION_CONTROLS = new Set([ControlType.Choices, ControlType.Radio, ControlType.Select]);
|
|
4077
4077
|
|
|
4078
|
+
/**
|
|
4079
|
+
* FORM WORDS — what a form part says the moment it lands on a page, in the SITE's language (iox-ui#159).
|
|
4080
|
+
*
|
|
4081
|
+
* ONE table for the words nobody wrote yet: a new Field's label, the plain Form's Name / Email / Send, each field kind's
|
|
4082
|
+
* label and starter choices (the Forms tray's Checkbox, Radio group, …), and a second channel's words (WhatsApp, Call
|
|
4083
|
+
* us, …). The builder's Form type, its field-kind presets and `addFormChannel`, and the admin's channel panel all read
|
|
4084
|
+
* it — a Hebrew site gets Hebrew parts from the tray, never English it has to retype. The English column IS the
|
|
4085
|
+
* baseline the builder's configs carry; `formWordIn` turns an untouched baseline word into the site's language.
|
|
4086
|
+
*
|
|
4087
|
+
* Data + lookups only: framework-free, like the rest of forms-core. The preset forms' own words stay in
|
|
4088
|
+
* `form-presets.ts` (`FORM_PRESET_WORDS_HE`); "While sending" and "Sent" in `submit-lifecycle.ts`.
|
|
4089
|
+
*/
|
|
4090
|
+
var FormWordsLanguage;
|
|
4091
|
+
(function (FormWordsLanguage) {
|
|
4092
|
+
FormWordsLanguage["En"] = "en";
|
|
4093
|
+
FormWordsLanguage["He"] = "he";
|
|
4094
|
+
})(FormWordsLanguage || (FormWordsLanguage = {}));
|
|
4095
|
+
const CHOICES_EN = 'First choice\nSecond choice\nThird choice';
|
|
4096
|
+
const CHOICES_HE = 'אפשרות ראשונה\nאפשרות שנייה\nאפשרות שלישית';
|
|
4097
|
+
|
|
4098
|
+
const FORM_WORDS = /* @__PURE__ */ Object.freeze({
|
|
4099
|
+
en: {
|
|
4100
|
+
field: 'Label',
|
|
4101
|
+
name: 'Name',
|
|
4102
|
+
email: 'Email',
|
|
4103
|
+
send: 'Send',
|
|
4104
|
+
kinds: {
|
|
4105
|
+
checkbox: { label: 'I agree' },
|
|
4106
|
+
switch: { label: 'Enable' },
|
|
4107
|
+
radio: { label: 'Pick one', optionsText: CHOICES_EN },
|
|
4108
|
+
choices: { label: 'What do you need?', optionsText: CHOICES_EN },
|
|
4109
|
+
select: { label: 'Choose', optionsText: CHOICES_EN },
|
|
4110
|
+
range: { label: 'How much' },
|
|
4111
|
+
date: { label: 'Date' },
|
|
4112
|
+
time: { label: 'Time' },
|
|
4113
|
+
},
|
|
4114
|
+
channels: {
|
|
4115
|
+
whatsapp: 'Message us on WhatsApp',
|
|
4116
|
+
phone: 'Call us',
|
|
4117
|
+
email: 'Email us',
|
|
4118
|
+
link: 'Book online',
|
|
4119
|
+
},
|
|
4120
|
+
announce: {
|
|
4121
|
+
failed: 'That did not send.',
|
|
4122
|
+
oneField: '1 field needs attention.',
|
|
4123
|
+
fields: '{count} fields need attention.',
|
|
4124
|
+
},
|
|
4125
|
+
},
|
|
4126
|
+
he: {
|
|
4127
|
+
field: 'שם השדה',
|
|
4128
|
+
name: 'שם',
|
|
4129
|
+
email: 'אימייל',
|
|
4130
|
+
send: 'שליחה',
|
|
4131
|
+
kinds: {
|
|
4132
|
+
checkbox: { label: 'אני מאשר/ת' },
|
|
4133
|
+
switch: { label: 'הפעלה' },
|
|
4134
|
+
radio: { label: 'בחרו אחת', optionsText: CHOICES_HE },
|
|
4135
|
+
choices: { label: 'מה אתם צריכים?', optionsText: CHOICES_HE },
|
|
4136
|
+
select: { label: 'בחירה', optionsText: CHOICES_HE },
|
|
4137
|
+
range: { label: 'כמה' },
|
|
4138
|
+
date: { label: 'תאריך' },
|
|
4139
|
+
time: { label: 'שעה' },
|
|
4140
|
+
},
|
|
4141
|
+
channels: {
|
|
4142
|
+
whatsapp: 'שלחו לנו הודעה בוואטסאפ',
|
|
4143
|
+
phone: 'התקשרו אלינו',
|
|
4144
|
+
email: 'כתבו לנו',
|
|
4145
|
+
link: 'הזמנה אונליין',
|
|
4146
|
+
},
|
|
4147
|
+
announce: {
|
|
4148
|
+
failed: 'השליחה לא הצליחה.',
|
|
4149
|
+
oneField: 'שדה אחד דורש תשומת לב.',
|
|
4150
|
+
fields: '{count} שדות דורשים תשומת לב.',
|
|
4151
|
+
},
|
|
4152
|
+
},
|
|
4153
|
+
});
|
|
4154
|
+
/** The language a form speaks for a `lang` attribute or site locale: design-core's subtag (`he-IL` → `he`), the old
|
|
4155
|
+
* `iw` read as `he`; '' when none. */
|
|
4156
|
+
function formLanguageOf(lang) {
|
|
4157
|
+
const language = languageOf(lang);
|
|
4158
|
+
return language === 'iw' ? 'he' : language;
|
|
4159
|
+
}
|
|
4160
|
+
/** The words in a site's language — English for any language the table does not hold, and when none is given. */
|
|
4161
|
+
function formWords(lang) {
|
|
4162
|
+
return ownWord(FORM_WORDS, formLanguageOf(lang)) ?? FORM_WORDS[FormWordsLanguage.En];
|
|
4163
|
+
}
|
|
4164
|
+
/** The baseline — what a builder config carries before anyone writes. */
|
|
4165
|
+
function baselineFormWords() {
|
|
4166
|
+
return FORM_WORDS[FormWordsLanguage.En];
|
|
4167
|
+
}
|
|
4168
|
+
/** A field kind's seeded label and choices in `lang`; undefined for a control the tray does not offer as a row. */
|
|
4169
|
+
function fieldKindWords(control, lang) {
|
|
4170
|
+
return ownWord(formWords(lang).kinds, control);
|
|
4171
|
+
}
|
|
4172
|
+
/** A channel's words in `lang` ('' for an unknown kind — the caller keeps what it has). */
|
|
4173
|
+
function channelWords(kind, lang) {
|
|
4174
|
+
return ownWord(formWords(lang).channels, kind) ?? '';
|
|
4175
|
+
}
|
|
4176
|
+
/** A table's own entry — never an inherited `constructor` or `toString` for a key someone typed. */
|
|
4177
|
+
function ownWord(table, key) {
|
|
4178
|
+
return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : undefined;
|
|
4179
|
+
}
|
|
4180
|
+
/**
|
|
4181
|
+
* An UNTOUCHED baseline word in `lang`: when `value` is the English word one of `slots` carries, the site language's word
|
|
4182
|
+
* for that slot; anything an author wrote (or an empty value) comes back as it is. How a freshly created Form, Field or
|
|
4183
|
+
* submit button speaks the site's language without a second copy of its config.
|
|
4184
|
+
*/
|
|
4185
|
+
function formWordIn(value, lang, slots) {
|
|
4186
|
+
if (typeof value !== 'string' || !value)
|
|
4187
|
+
return value;
|
|
4188
|
+
const base = baselineFormWords();
|
|
4189
|
+
const slot = slots.find(s => base[s] === value);
|
|
4190
|
+
return slot ? formWords(lang)[slot] : value;
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4078
4193
|
// The default message for every rule, as an i18n KEY — never a rendered string.
|
|
4079
4194
|
//
|
|
4080
4195
|
// This is what lets the Validation panel stay empty and still produce good errors: an author who
|
|
@@ -4146,7 +4261,8 @@ const FORM_ERROR_KEYS = Object.freeze({
|
|
|
4146
4261
|
RateLimited: `${MESSAGE_NAMESPACE}.form.rateLimited`,
|
|
4147
4262
|
Server: `${MESSAGE_NAMESPACE}.form.server`,
|
|
4148
4263
|
});
|
|
4149
|
-
/** The English
|
|
4264
|
+
/** The English column of the ONE forms message catalog (`formMessage`) — what a site in any language the catalog does not
|
|
4265
|
+
* hold reads, and what a consumer that has not added the keys yet still shows. */
|
|
4150
4266
|
const DEFAULT_EN_MESSAGES = Object.freeze({
|
|
4151
4267
|
[RULE_MESSAGE_KEYS[RuleName.Required]]: 'This field is required',
|
|
4152
4268
|
[RULE_MESSAGE_KEYS[RuleName.MinLength]]: 'Use at least {{n}} characters',
|
|
@@ -4178,6 +4294,70 @@ const DEFAULT_EN_MESSAGES = Object.freeze({
|
|
|
4178
4294
|
[DATE_MESSAGE_KEYS.Max]: 'Choose an earlier date',
|
|
4179
4295
|
[SUBMIT_MESSAGE_KEYS.Sent]: 'Sent',
|
|
4180
4296
|
});
|
|
4297
|
+
/**
|
|
4298
|
+
* The Hebrew column (iox-client-engine#15). A visitor is spoken to in the plural imperative, like every other word a site
|
|
4299
|
+
* says (`form-words.ts`: בחרו, כתבו לנו). Every key of the English column has its entry here — a spec holds that.
|
|
4300
|
+
*/
|
|
4301
|
+
const HE_MESSAGES = /* @__PURE__ */ Object.freeze({
|
|
4302
|
+
[RULE_MESSAGE_KEYS[RuleName.Required]]: 'שדה חובה',
|
|
4303
|
+
[RULE_MESSAGE_KEYS[RuleName.MinLength]]: 'כתבו לפחות {{n}} תווים',
|
|
4304
|
+
[RULE_MESSAGE_KEYS[RuleName.MaxLength]]: 'כתבו עד {{n}} תווים',
|
|
4305
|
+
[RULE_MESSAGE_KEYS[RuleName.Min]]: 'הזינו {{n}} או יותר',
|
|
4306
|
+
[RULE_MESSAGE_KEYS[RuleName.Max]]: 'הזינו {{n}} או פחות',
|
|
4307
|
+
[RULE_MESSAGE_KEYS[RuleName.Pattern]]: 'בדקו את צורת הערך',
|
|
4308
|
+
[RULE_MESSAGE_KEYS[RuleName.Matches]]: 'הערך צריך להתאים לשדה {{field}}',
|
|
4309
|
+
[RULE_MESSAGE_KEYS[RuleName.Accepted]]: 'סמנו כדי להמשיך',
|
|
4310
|
+
[RULE_MESSAGE_KEYS[RuleName.FileType]]: 'סוג הקובץ הזה לא מתקבל',
|
|
4311
|
+
[RULE_MESSAGE_KEYS[RuleName.FileSize]]: 'הקובץ גדול מ-{{n}}MB',
|
|
4312
|
+
[PATTERN_MESSAGE_KEYS['email']]: 'הזינו כתובת אימייל תקינה',
|
|
4313
|
+
[PATTERN_MESSAGE_KEYS['phone']]: 'הזינו מספר טלפון תקין',
|
|
4314
|
+
[PATTERN_MESSAGE_KEYS['url']]: 'הזינו כתובת אתר תקינה',
|
|
4315
|
+
[PATTERN_MESSAGE_KEYS['digits']]: 'ספרות בלבד',
|
|
4316
|
+
[PATTERN_MESSAGE_KEYS['letters']]: 'אותיות בלבד',
|
|
4317
|
+
[PATTERN_MESSAGE_KEYS['slug']]: 'אותיות לטיניות קטנות, ספרות ומקפים',
|
|
4318
|
+
[FORM_ERROR_KEYS.Network]: 'לא הצלחנו להגיע לשרת — בדקו את החיבור ונסו שוב',
|
|
4319
|
+
[FORM_ERROR_KEYS.Rejected]: 'יש תשובות שצריך לתקן',
|
|
4320
|
+
[FORM_ERROR_KEYS.Spam]: 'לא יכולנו לקבל את השליחה הזו',
|
|
4321
|
+
[FORM_ERROR_KEYS.RateLimited]: 'יותר מדי ניסיונות — חכו רגע ונסו שוב',
|
|
4322
|
+
[FORM_ERROR_KEYS.Server]: 'משהו השתבש אצלנו — התשובות שלכם עדיין כאן',
|
|
4323
|
+
[RULE_MESSAGE_KEYS[RuleName.OneOf]]: 'בחרו אחת מהאפשרויות',
|
|
4324
|
+
[RULE_MESSAGE_KEYS[RuleName.ValidDate]]: 'בחרו תאריך מלוח השנה',
|
|
4325
|
+
[CHOICE_MESSAGE_KEYS.One]: 'בחרו אפשרות',
|
|
4326
|
+
[CHOICE_MESSAGE_KEYS.Some]: 'בחרו לפחות אחת',
|
|
4327
|
+
[CHOICE_MESSAGE_KEYS.Date]: 'בחרו תאריך',
|
|
4328
|
+
[DATE_MESSAGE_KEYS.Min]: 'בחרו תאריך מאוחר יותר',
|
|
4329
|
+
[DATE_MESSAGE_KEYS.Max]: 'בחרו תאריך מוקדם יותר',
|
|
4330
|
+
[SUBMIT_MESSAGE_KEYS.Sent]: 'נשלח',
|
|
4331
|
+
});
|
|
4332
|
+
/** The catalog, by the language `formLanguageOf` reads. */
|
|
4333
|
+
const FORM_MESSAGES = /* @__PURE__ */ Object.freeze({
|
|
4334
|
+
en: DEFAULT_EN_MESSAGES,
|
|
4335
|
+
he: HE_MESSAGES,
|
|
4336
|
+
});
|
|
4337
|
+
/** The languages the catalog holds. */
|
|
4338
|
+
const FORM_MESSAGE_LANGUAGES = Object.freeze(['en', 'he']);
|
|
4339
|
+
/** The whole column for `lang` (`he-IL` → he, `iw` → he) — English for a language the catalog does not hold. */
|
|
4340
|
+
function formMessages(lang) {
|
|
4341
|
+
const language = formLanguageOf(lang);
|
|
4342
|
+
return Object.prototype.hasOwnProperty.call(FORM_MESSAGES, language) ? FORM_MESSAGES[language] : DEFAULT_EN_MESSAGES;
|
|
4343
|
+
}
|
|
4344
|
+
/** `{{n}}` / `{{field}}` placed where the sentence's grammar put them; a missing param reads as ''. */
|
|
4345
|
+
function interpolateMessage(template, params) {
|
|
4346
|
+
if (!params)
|
|
4347
|
+
return template;
|
|
4348
|
+
return template.replace(/\{\{(\w+)\}\}/g, (_, name) => String(params[name] ?? ''));
|
|
4349
|
+
}
|
|
4350
|
+
/**
|
|
4351
|
+
* A message KEY as the sentence a visitor reads, in the page's language — THE reading both renderers make (the
|
|
4352
|
+
* component path's default `IOX_FORM_MESSAGES`, the string runtime's): `lang`'s sentence, else the English one, else the
|
|
4353
|
+
* key itself (an author's own message, which travels as its text).
|
|
4354
|
+
*/
|
|
4355
|
+
function formMessage(key, params, lang) {
|
|
4356
|
+
const own = formMessages(lang);
|
|
4357
|
+
const template = Object.prototype.hasOwnProperty.call(own, key) ? own[key]
|
|
4358
|
+
: Object.prototype.hasOwnProperty.call(DEFAULT_EN_MESSAGES, key) ? DEFAULT_EN_MESSAGES[key] : key;
|
|
4359
|
+
return interpolateMessage(template, params);
|
|
4360
|
+
}
|
|
4181
4361
|
|
|
4182
4362
|
/**
|
|
4183
4363
|
* DATES — the date picker's pure half (premium components N8) and the date rules' one reading.
|
|
@@ -5109,121 +5289,6 @@ function normaliseErrors(raw) {
|
|
|
5109
5289
|
return Object.keys(errors).length ? errors : undefined;
|
|
5110
5290
|
}
|
|
5111
5291
|
|
|
5112
|
-
/**
|
|
5113
|
-
* FORM WORDS — what a form part says the moment it lands on a page, in the SITE's language (iox-ui#159).
|
|
5114
|
-
*
|
|
5115
|
-
* ONE table for the words nobody wrote yet: a new Field's label, the plain Form's Name / Email / Send, each field kind's
|
|
5116
|
-
* label and starter choices (the Forms tray's Checkbox, Radio group, …), and a second channel's words (WhatsApp, Call
|
|
5117
|
-
* us, …). The builder's Form type, its field-kind presets and `addFormChannel`, and the admin's channel panel all read
|
|
5118
|
-
* it — a Hebrew site gets Hebrew parts from the tray, never English it has to retype. The English column IS the
|
|
5119
|
-
* baseline the builder's configs carry; `formWordIn` turns an untouched baseline word into the site's language.
|
|
5120
|
-
*
|
|
5121
|
-
* Data + lookups only: framework-free, like the rest of forms-core. The preset forms' own words stay in
|
|
5122
|
-
* `form-presets.ts` (`FORM_PRESET_WORDS_HE`); "While sending" and "Sent" in `submit-lifecycle.ts`.
|
|
5123
|
-
*/
|
|
5124
|
-
var FormWordsLanguage;
|
|
5125
|
-
(function (FormWordsLanguage) {
|
|
5126
|
-
FormWordsLanguage["En"] = "en";
|
|
5127
|
-
FormWordsLanguage["He"] = "he";
|
|
5128
|
-
})(FormWordsLanguage || (FormWordsLanguage = {}));
|
|
5129
|
-
const CHOICES_EN = 'First choice\nSecond choice\nThird choice';
|
|
5130
|
-
const CHOICES_HE = 'אפשרות ראשונה\nאפשרות שנייה\nאפשרות שלישית';
|
|
5131
|
-
|
|
5132
|
-
const FORM_WORDS = /* @__PURE__ */ Object.freeze({
|
|
5133
|
-
en: {
|
|
5134
|
-
field: 'Label',
|
|
5135
|
-
name: 'Name',
|
|
5136
|
-
email: 'Email',
|
|
5137
|
-
send: 'Send',
|
|
5138
|
-
kinds: {
|
|
5139
|
-
checkbox: { label: 'I agree' },
|
|
5140
|
-
switch: { label: 'Enable' },
|
|
5141
|
-
radio: { label: 'Pick one', optionsText: CHOICES_EN },
|
|
5142
|
-
choices: { label: 'What do you need?', optionsText: CHOICES_EN },
|
|
5143
|
-
select: { label: 'Choose', optionsText: CHOICES_EN },
|
|
5144
|
-
range: { label: 'How much' },
|
|
5145
|
-
date: { label: 'Date' },
|
|
5146
|
-
time: { label: 'Time' },
|
|
5147
|
-
},
|
|
5148
|
-
channels: {
|
|
5149
|
-
whatsapp: 'Message us on WhatsApp',
|
|
5150
|
-
phone: 'Call us',
|
|
5151
|
-
email: 'Email us',
|
|
5152
|
-
link: 'Book online',
|
|
5153
|
-
},
|
|
5154
|
-
announce: {
|
|
5155
|
-
failed: 'That did not send.',
|
|
5156
|
-
oneField: '1 field needs attention.',
|
|
5157
|
-
fields: '{count} fields need attention.',
|
|
5158
|
-
},
|
|
5159
|
-
},
|
|
5160
|
-
he: {
|
|
5161
|
-
field: 'שם השדה',
|
|
5162
|
-
name: 'שם',
|
|
5163
|
-
email: 'אימייל',
|
|
5164
|
-
send: 'שליחה',
|
|
5165
|
-
kinds: {
|
|
5166
|
-
checkbox: { label: 'אני מאשר/ת' },
|
|
5167
|
-
switch: { label: 'הפעלה' },
|
|
5168
|
-
radio: { label: 'בחרו אחת', optionsText: CHOICES_HE },
|
|
5169
|
-
choices: { label: 'מה אתם צריכים?', optionsText: CHOICES_HE },
|
|
5170
|
-
select: { label: 'בחירה', optionsText: CHOICES_HE },
|
|
5171
|
-
range: { label: 'כמה' },
|
|
5172
|
-
date: { label: 'תאריך' },
|
|
5173
|
-
time: { label: 'שעה' },
|
|
5174
|
-
},
|
|
5175
|
-
channels: {
|
|
5176
|
-
whatsapp: 'שלחו לנו הודעה בוואטסאפ',
|
|
5177
|
-
phone: 'התקשרו אלינו',
|
|
5178
|
-
email: 'כתבו לנו',
|
|
5179
|
-
link: 'הזמנה אונליין',
|
|
5180
|
-
},
|
|
5181
|
-
announce: {
|
|
5182
|
-
failed: 'השליחה לא הצליחה.',
|
|
5183
|
-
oneField: 'שדה אחד דורש תשומת לב.',
|
|
5184
|
-
fields: '{count} שדות דורשים תשומת לב.',
|
|
5185
|
-
},
|
|
5186
|
-
},
|
|
5187
|
-
});
|
|
5188
|
-
/** The language a form speaks for a `lang` attribute or site locale: design-core's subtag (`he-IL` → `he`), the old
|
|
5189
|
-
* `iw` read as `he`; '' when none. */
|
|
5190
|
-
function formLanguageOf(lang) {
|
|
5191
|
-
const language = languageOf(lang);
|
|
5192
|
-
return language === 'iw' ? 'he' : language;
|
|
5193
|
-
}
|
|
5194
|
-
/** The words in a site's language — English for any language the table does not hold, and when none is given. */
|
|
5195
|
-
function formWords(lang) {
|
|
5196
|
-
return ownWord(FORM_WORDS, formLanguageOf(lang)) ?? FORM_WORDS[FormWordsLanguage.En];
|
|
5197
|
-
}
|
|
5198
|
-
/** The baseline — what a builder config carries before anyone writes. */
|
|
5199
|
-
function baselineFormWords() {
|
|
5200
|
-
return FORM_WORDS[FormWordsLanguage.En];
|
|
5201
|
-
}
|
|
5202
|
-
/** A field kind's seeded label and choices in `lang`; undefined for a control the tray does not offer as a row. */
|
|
5203
|
-
function fieldKindWords(control, lang) {
|
|
5204
|
-
return ownWord(formWords(lang).kinds, control);
|
|
5205
|
-
}
|
|
5206
|
-
/** A channel's words in `lang` ('' for an unknown kind — the caller keeps what it has). */
|
|
5207
|
-
function channelWords(kind, lang) {
|
|
5208
|
-
return ownWord(formWords(lang).channels, kind) ?? '';
|
|
5209
|
-
}
|
|
5210
|
-
/** A table's own entry — never an inherited `constructor` or `toString` for a key someone typed. */
|
|
5211
|
-
function ownWord(table, key) {
|
|
5212
|
-
return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : undefined;
|
|
5213
|
-
}
|
|
5214
|
-
/**
|
|
5215
|
-
* An UNTOUCHED baseline word in `lang`: when `value` is the English word one of `slots` carries, the site language's word
|
|
5216
|
-
* for that slot; anything an author wrote (or an empty value) comes back as it is. How a freshly created Form, Field or
|
|
5217
|
-
* submit button speaks the site's language without a second copy of its config.
|
|
5218
|
-
*/
|
|
5219
|
-
function formWordIn(value, lang, slots) {
|
|
5220
|
-
if (typeof value !== 'string' || !value)
|
|
5221
|
-
return value;
|
|
5222
|
-
const base = baselineFormWords();
|
|
5223
|
-
const slot = slots.find(s => base[s] === value);
|
|
5224
|
-
return slot ? formWords(lang)[slot] : value;
|
|
5225
|
-
}
|
|
5226
|
-
|
|
5227
5292
|
/**
|
|
5228
5293
|
* The submit LIFECYCLE's decisions — what a form shows after the server answers, what it says when a
|
|
5229
5294
|
* submit fails, what a client needs to validate a form, and how its submit button follows its state.
|
|
@@ -5333,11 +5398,10 @@ var SubmitLabelClass;
|
|
|
5333
5398
|
* the shared CSS draws it by `stroke-dashoffset` whatever its real length. */
|
|
5334
5399
|
const SUBMIT_CHECK_SVG = `<svg class="${SubmitLabelClass.Check}" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true" focusable="false">` +
|
|
5335
5400
|
'<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>';
|
|
5336
|
-
/** "Sent" in the site's language, for a button whose author wrote no Sent words
|
|
5337
|
-
*
|
|
5338
|
-
const SENT_WORDS = Object.freeze({ en: 'Sent', he: 'נשלח' });
|
|
5401
|
+
/** "Sent" in the site's language, for a button whose author wrote no Sent words — the forms message catalog's
|
|
5402
|
+
* (`formMessage`), the document's `lang` picking, like the date picker's words. */
|
|
5339
5403
|
function sentWord(lang) {
|
|
5340
|
-
return
|
|
5404
|
+
return formMessage(SUBMIT_MESSAGE_KEYS.Sent, null, lang);
|
|
5341
5405
|
}
|
|
5342
5406
|
/** "While sending" in the site's language (iox-ui#158). The English one is the SubmitButton's baseline
|
|
5343
5407
|
* (`loadingLabel`), which every stamped node carries until its author writes their own. */
|
|
@@ -6417,13 +6481,8 @@ const IOX_FORM_MESSAGES = new InjectionToken('IOX_FORM_MESSAGES', {
|
|
|
6417
6481
|
providedIn: 'root',
|
|
6418
6482
|
factory: () => defaultMessageResolver,
|
|
6419
6483
|
});
|
|
6420
|
-
/** `{{n}}` / `{{field}}`
|
|
6421
|
-
const defaultMessageResolver = (key, params) =>
|
|
6422
|
-
const template = DEFAULT_EN_MESSAGES[key] ?? key;
|
|
6423
|
-
if (!params)
|
|
6424
|
-
return template;
|
|
6425
|
-
return template.replace(/\{\{(\w+)\}\}/g, (_, name) => String(params[name] ?? ''));
|
|
6426
|
-
};
|
|
6484
|
+
/** The catalog's sentence in the page's language, `{{n}}` / `{{field}}` placed — forms-core `formMessage`. */
|
|
6485
|
+
const defaultMessageResolver = (key, params, lang) => formMessage(key, params, lang);
|
|
6427
6486
|
/**
|
|
6428
6487
|
* Per-form runtime. **Provided by `IoxFormComponent`**, so every Field created into that form's
|
|
6429
6488
|
* `childrenHost` resolves THIS instance through its element injector — which is exactly how a field
|
|
@@ -7428,12 +7487,13 @@ class IoxFieldComponent {
|
|
|
7428
7487
|
return true;
|
|
7429
7488
|
return !!this.runtime?.showsError(this.fieldName);
|
|
7430
7489
|
}
|
|
7431
|
-
/** The message a visitor reads
|
|
7490
|
+
/** The message a visitor reads, in the page's language (`pageLanguageOf`) — IOX_FORM_MESSAGES, whose default is
|
|
7491
|
+
* forms-core's ONE catalog (iox-client-engine#15). */
|
|
7432
7492
|
get errorText() {
|
|
7433
7493
|
if (this.forceInvalid)
|
|
7434
7494
|
return this.designErrorText;
|
|
7435
7495
|
const error = this.runtime?.errorFor(this.fieldName);
|
|
7436
|
-
return error ? this.resolveMessage(error.messageKey, error.params) : '';
|
|
7496
|
+
return error ? this.resolveMessage(error.messageKey, error.params, pageLanguageOf(this.host?.nativeElement)) : '';
|
|
7437
7497
|
}
|
|
7438
7498
|
/** The field's spec under the name its form gave it — forms-core `fieldSpecOf`, the reading the saved spec uses. */
|
|
7439
7499
|
toSpec(name) {
|
|
@@ -7975,10 +8035,12 @@ class IoxSubmitButtonComponent {
|
|
|
7975
8035
|
if (this.sentLabel)
|
|
7976
8036
|
return this.sentLabel;
|
|
7977
8037
|
const key = SUBMIT_MESSAGE_KEYS.Sent;
|
|
7978
|
-
const
|
|
8038
|
+
const lang = this.pageLang();
|
|
8039
|
+
const translated = (this.resolveMessage ?? defaultMessageResolver)(key, undefined, lang);
|
|
8040
|
+
// A host resolver that knows no language hands back the English column — the page's language wins over it.
|
|
7979
8041
|
if (translated && translated !== key && translated !== DEFAULT_EN_MESSAGES[key])
|
|
7980
8042
|
return translated;
|
|
7981
|
-
return sentWord(
|
|
8043
|
+
return sentWord(lang);
|
|
7982
8044
|
}
|
|
7983
8045
|
/** The page's language (`pageLanguageOf`). */
|
|
7984
8046
|
pageLang() {
|
|
@@ -13478,7 +13540,7 @@ class StringFormRuntime {
|
|
|
13478
13540
|
continue;
|
|
13479
13541
|
const error = this.state.errors[field.name];
|
|
13480
13542
|
const shown = !!error && shouldShowError(field.name, this.state, this.spec.feedback);
|
|
13481
|
-
const text = shown ? this.messages(error.messageKey, error.params) : '';
|
|
13543
|
+
const text = shown ? this.messages(error.messageKey, error.params, pageLanguageOf(this.form)) : '';
|
|
13482
13544
|
writeFieldError(el, shown ? text : '');
|
|
13483
13545
|
}
|
|
13484
13546
|
}
|