@vectoriox/iox-ui 5.189.0 → 5.191.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.
@@ -5136,6 +5136,11 @@ const FORM_WORDS = /* @__PURE__ */ Object.freeze({
5136
5136
  email: 'Email us',
5137
5137
  link: 'Book online',
5138
5138
  },
5139
+ announce: {
5140
+ failed: 'That did not send.',
5141
+ oneField: '1 field needs attention.',
5142
+ fields: '{count} fields need attention.',
5143
+ },
5139
5144
  },
5140
5145
  he: {
5141
5146
  field: 'שם השדה',
@@ -5158,6 +5163,11 @@ const FORM_WORDS = /* @__PURE__ */ Object.freeze({
5158
5163
  email: 'כתבו לנו',
5159
5164
  link: 'הזמנה אונליין',
5160
5165
  },
5166
+ announce: {
5167
+ failed: 'השליחה לא הצליחה.',
5168
+ oneField: 'שדה אחד דורש תשומת לב.',
5169
+ fields: '{count} שדות דורשים תשומת לב.',
5170
+ },
5161
5171
  },
5162
5172
  });
5163
5173
  /** The language a form speaks for a `lang` attribute or site locale: design-core's subtag (`he-IL` → `he`), the old
@@ -5253,12 +5263,17 @@ function submitOutcome(response, afterSend = FormAfterSend.Message) {
5253
5263
  return { state: FormRenderState.Idle, errors: response.errors, reset: false };
5254
5264
  return { state: FormRenderState.Error, reset: false };
5255
5265
  }
5256
- /** What the live region says after a refused submit: how many fields need attention, or that it did not send. */
5257
- function failureAnnouncement(errors) {
5266
+ /**
5267
+ * What the live region says after a refused submit: how many fields need attention, or that it did not send — in the
5268
+ * page's language (iox-ui#161: a Hebrew visitor heard English at the moment something went wrong). The words are
5269
+ * forms-core's ONE form words table; English for a language it does not hold.
5270
+ */
5271
+ function failureAnnouncement(errors, lang) {
5258
5272
  const count = errors ? Object.keys(errors).length : 0;
5273
+ const words = formWords(lang).announce;
5259
5274
  if (!count)
5260
- return 'That did not send.';
5261
- return `${count} ${count === 1 ? 'field needs' : 'fields need'} attention.`;
5275
+ return words.failed;
5276
+ return count === 1 ? words.oneField : words.fields.replace('{count}', String(count));
5262
5277
  }
5263
5278
  const FORM_FIELDS_ATTRIBUTE = 'data-iox-form-fields';
5264
5279
  function clientFormSpec(spec) {
@@ -5507,7 +5522,7 @@ const FORM_PRESET_WORDS_HE = /* @__PURE__ */ Object.freeze({
5507
5522
  });
5508
5523
  /** A preset in a language: Hebrew when `lang` is, else the preset as it is. Fresh objects; the shape never changes. */
5509
5524
  function formPresetIn(def, lang) {
5510
- const he = (lang ?? '').toLowerCase().startsWith('he') ? FORM_PRESET_WORDS_HE[def.id] : undefined;
5525
+ const he = formLanguageOf(lang) === FormWordsLanguage.He ? FORM_PRESET_WORDS_HE[def.id] : undefined;
5511
5526
  if (!he)
5512
5527
  return def;
5513
5528
  return {
@@ -6352,6 +6367,15 @@ function showToastDesign(doc, text, show, options = {}) {
6352
6367
  stackOf(layer, toastEdge(options.edge)).stack.add(String(text ?? '').trim() || ' ', options, true);
6353
6368
  }
6354
6369
 
6370
+ /**
6371
+ * The page's language for a form part: the nearest `lang` (the builder canvas's site scope, the engine's `<html>`), else
6372
+ * the document's. ONE reading for every form word the page's language picks — the submit button's Sending / Sent, the
6373
+ * toast, the failure announcement (iox-ui#158, #161) — on the component path and the string path alike.
6374
+ */
6375
+ function pageLanguageOf(element) {
6376
+ return element?.closest?.('[lang]')?.getAttribute('lang') ?? element?.ownerDocument?.documentElement?.lang;
6377
+ }
6378
+
6355
6379
  /**
6356
6380
  * A form that KEEPS its fields after sending says so in a toast (premium M5, N3 — the Form's After sending ▸ "Keep the
6357
6381
  * fields and show a toast"). Its words are the form's own Sent words — the ones its submit button shows once it has sent
@@ -6363,7 +6387,7 @@ function formSentWords(form) {
6363
6387
  const label = form.querySelector(`.${SubmitLabelClass.Sent}`)?.textContent?.trim();
6364
6388
  if (label)
6365
6389
  return label;
6366
- return sentWord(form.closest('[lang]')?.getAttribute('lang') ?? form.ownerDocument?.documentElement?.lang);
6390
+ return sentWord(pageLanguageOf(form));
6367
6391
  }
6368
6392
  /** True when the rendered form keeps its fields and toasts (the attribute every renderer writes). */
6369
6393
  function formToastsOnSend(form) {
@@ -6740,7 +6764,7 @@ class IoxFormComponent {
6740
6764
  announce(errors) {
6741
6765
  if (!this.announceFailure)
6742
6766
  return;
6743
- const next = failureAnnouncement(errors);
6767
+ const next = failureAnnouncement(errors, pageLanguageOf(this.host?.nativeElement));
6744
6768
  this.announcement = '';
6745
6769
  // A microtask is enough for the empty value to be committed before the new one lands.
6746
6770
  Promise.resolve().then(() => { this.announcement = next; });
@@ -7941,10 +7965,9 @@ class IoxSubmitButtonComponent {
7941
7965
  return translated;
7942
7966
  return sentWord(this.pageLang());
7943
7967
  }
7944
- /** The page's language: the nearest `lang` (the canvas's site scope, the engine's `<html>`). */
7968
+ /** The page's language (`pageLanguageOf`). */
7945
7969
  pageLang() {
7946
- const element = this.host?.nativeElement;
7947
- return element?.closest?.('[lang]')?.getAttribute('lang') ?? element?.ownerDocument?.documentElement?.lang;
7970
+ return pageLanguageOf(this.host?.nativeElement);
7948
7971
  }
7949
7972
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.31", ngImport: i0, type: IoxSubmitButtonComponent, deps: [{ token: IOX_FORM_MESSAGES, optional: true }, { token: i0.ElementRef, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
7950
7973
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.31", type: IoxSubmitButtonComponent, isStandalone: false, selector: "button[iox-submit]", inputs: { nodeId: "nodeId", label: "label", loadingLabel: "loadingLabel", sentLabel: "sentLabel", disableWhileSubmitting: "disableWhileSubmitting" }, host: { properties: { "class": "'iox-submit iox-node-' + nodeId", "attr.type": "'submit'", "attr.data-iox-keep-enabled": "disableWhileSubmitting === false ? \"\" : null" } }, ngImport: i0, template: `<span class="iox-submit__labels"><span class="iox-submit__idle">{{ label }}</span><span class="iox-submit__busy">{{ busyWords || label }}</span><span class="iox-submit__sent"><svg class="iox-submit__check" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><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><span>{{ sentWords }}</span></span></span>`, isInline: true, styles: [":host{box-sizing:border-box;cursor:pointer}\n"] }); }
@@ -13424,7 +13447,7 @@ class StringFormRuntime {
13424
13447
  return;
13425
13448
  // Cleared first: a live region speaks on CHANGE, and the same failure twice must be said twice.
13426
13449
  region.textContent = '';
13427
- const next = failureAnnouncement(errors);
13450
+ const next = failureAnnouncement(errors, pageLanguageOf(this.form));
13428
13451
  Promise.resolve().then(() => { region.textContent = next; });
13429
13452
  }
13430
13453
  /** Focus the first field that failed and shake it once (premium N2 — the ONE `shakeElement`). */