@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.
@@ -6,7 +6,7 @@ import { Subject, fromEvent } from 'rxjs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import * as i1 from '@angular/common';
8
8
  import { CommonModule, isPlatformBrowser } from '@angular/common';
9
- import { SPEC_AXES, resolveDesignMotion, FILTER_FUNCTIONS, BACKDROP_FUNCTIONS, decomposeCssFunctions, FieldClass, HeaderAttribute, HeaderBehaviour, HeaderInk, OPENING_ATTRIBUTE, schemeOfClasses, schemeUnderBar, BRAND_NAME_ATTRIBUTE, BAR_ATTRIBUTE, BAR_NAME_ATTRIBUTE, MENU_ATTRIBUTES, menuDialogAttributes, menuButtonAttributes, headerAttributes, HeaderTrait, BRAND_ROLE, brandNameAttributes, NAV_ROLE, navBarAttributes, REDUCED_ENTRANCE_MAX_MS, roleClass, preloaderWords, PreloaderKind, preloaderGraphemes, PRELOADER_EXIT_EASE, PRELOADER_CAP_MS, isFirstVisit, PRELOADER_ENTER_EASE, PreloaderExit, PRELOADER_MIN_SHOW_MS, preloaderLeaveAt, preloaderExitMotion, preloaderPercent, inkOnGround, writeFieldError } from '@vectoriox/iox-ui/design-core';
9
+ import { SPEC_AXES, resolveDesignMotion, FILTER_FUNCTIONS, BACKDROP_FUNCTIONS, decomposeCssFunctions, languageOf, FieldClass, HeaderAttribute, HeaderBehaviour, HeaderInk, OPENING_ATTRIBUTE, schemeOfClasses, schemeUnderBar, BRAND_NAME_ATTRIBUTE, BAR_ATTRIBUTE, BAR_NAME_ATTRIBUTE, MENU_ATTRIBUTES, menuDialogAttributes, menuButtonAttributes, headerAttributes, HeaderTrait, BRAND_ROLE, brandNameAttributes, NAV_ROLE, navBarAttributes, REDUCED_ENTRANCE_MAX_MS, roleClass, preloaderWords, PreloaderKind, preloaderGraphemes, PRELOADER_EXIT_EASE, PRELOADER_CAP_MS, isFirstVisit, PRELOADER_ENTER_EASE, PreloaderExit, PRELOADER_MIN_SHOW_MS, preloaderLeaveAt, preloaderExitMotion, preloaderPercent, inkOnGround, writeFieldError } from '@vectoriox/iox-ui/design-core';
10
10
  export * from '@vectoriox/iox-ui/design-core';
11
11
  import { setPageScroller, pageScroller, SceneAttribute, SCENE_WAKE_EVENT, SCENE_REVEAL_DEFAULT, SceneRevealFrom, revealClipPath, playTextReveal, textRevealByOf, textRevealLookOf, textRevealStaggerOf, ScrollActionKind, lightMotionWanted, scrubTextReveal, ScrollPlay, gentleFrames, SCENE_PHONE_MAX_WIDTH, normalizeParallaxDepth, normalizeParallaxPhone, parallaxShift, parallaxRest, parallaxFrames, PROGRESS_BAR_FRAMES, ParallaxPhone, outermostNodeOf, normalizeScrollRange, scrollPlayFor, ScrollRange } from '@vectoriox/iox-ui/scene-core';
12
12
  import Lenis from 'lenis';
@@ -5094,6 +5094,111 @@ function normaliseErrors(raw) {
5094
5094
  return Object.keys(errors).length ? errors : undefined;
5095
5095
  }
5096
5096
 
5097
+ /**
5098
+ * FORM WORDS — what a form part says the moment it lands on a page, in the SITE's language (iox-ui#159).
5099
+ *
5100
+ * ONE table for the words nobody wrote yet: a new Field's label, the plain Form's Name / Email / Send, each field kind's
5101
+ * label and starter choices (the Forms tray's Checkbox, Radio group, …), and a second channel's words (WhatsApp, Call
5102
+ * us, …). The builder's Form type, its field-kind presets and `addFormChannel`, and the admin's channel panel all read
5103
+ * it — a Hebrew site gets Hebrew parts from the tray, never English it has to retype. The English column IS the
5104
+ * baseline the builder's configs carry; `formWordIn` turns an untouched baseline word into the site's language.
5105
+ *
5106
+ * Data + lookups only: framework-free, like the rest of forms-core. The preset forms' own words stay in
5107
+ * `form-presets.ts` (`FORM_PRESET_WORDS_HE`); "While sending" and "Sent" in `submit-lifecycle.ts`.
5108
+ */
5109
+ var FormWordsLanguage;
5110
+ (function (FormWordsLanguage) {
5111
+ FormWordsLanguage["En"] = "en";
5112
+ FormWordsLanguage["He"] = "he";
5113
+ })(FormWordsLanguage || (FormWordsLanguage = {}));
5114
+ const CHOICES_EN = 'First choice\nSecond choice\nThird choice';
5115
+ const CHOICES_HE = 'אפשרות ראשונה\nאפשרות שנייה\nאפשרות שלישית';
5116
+
5117
+ const FORM_WORDS = /* @__PURE__ */ Object.freeze({
5118
+ en: {
5119
+ field: 'Label',
5120
+ name: 'Name',
5121
+ email: 'Email',
5122
+ send: 'Send',
5123
+ kinds: {
5124
+ checkbox: { label: 'I agree' },
5125
+ switch: { label: 'Enable' },
5126
+ radio: { label: 'Pick one', optionsText: CHOICES_EN },
5127
+ choices: { label: 'What do you need?', optionsText: CHOICES_EN },
5128
+ select: { label: 'Choose', optionsText: CHOICES_EN },
5129
+ range: { label: 'How much' },
5130
+ date: { label: 'Date' },
5131
+ time: { label: 'Time' },
5132
+ },
5133
+ channels: {
5134
+ whatsapp: 'Message us on WhatsApp',
5135
+ phone: 'Call us',
5136
+ email: 'Email us',
5137
+ link: 'Book online',
5138
+ },
5139
+ },
5140
+ he: {
5141
+ field: 'שם השדה',
5142
+ name: 'שם',
5143
+ email: 'אימייל',
5144
+ send: 'שליחה',
5145
+ kinds: {
5146
+ checkbox: { label: 'אני מאשר/ת' },
5147
+ switch: { label: 'הפעלה' },
5148
+ radio: { label: 'בחרו אחת', optionsText: CHOICES_HE },
5149
+ choices: { label: 'מה אתם צריכים?', optionsText: CHOICES_HE },
5150
+ select: { label: 'בחירה', optionsText: CHOICES_HE },
5151
+ range: { label: 'כמה' },
5152
+ date: { label: 'תאריך' },
5153
+ time: { label: 'שעה' },
5154
+ },
5155
+ channels: {
5156
+ whatsapp: 'שלחו לנו הודעה בוואטסאפ',
5157
+ phone: 'התקשרו אלינו',
5158
+ email: 'כתבו לנו',
5159
+ link: 'הזמנה אונליין',
5160
+ },
5161
+ },
5162
+ });
5163
+ /** The language a form speaks for a `lang` attribute or site locale: design-core's subtag (`he-IL` → `he`), the old
5164
+ * `iw` read as `he`; '' when none. */
5165
+ function formLanguageOf(lang) {
5166
+ const language = languageOf(lang);
5167
+ return language === 'iw' ? 'he' : language;
5168
+ }
5169
+ /** The words in a site's language — English for any language the table does not hold, and when none is given. */
5170
+ function formWords(lang) {
5171
+ return ownWord(FORM_WORDS, formLanguageOf(lang)) ?? FORM_WORDS[FormWordsLanguage.En];
5172
+ }
5173
+ /** The baseline — what a builder config carries before anyone writes. */
5174
+ function baselineFormWords() {
5175
+ return FORM_WORDS[FormWordsLanguage.En];
5176
+ }
5177
+ /** A field kind's seeded label and choices in `lang`; undefined for a control the tray does not offer as a row. */
5178
+ function fieldKindWords(control, lang) {
5179
+ return ownWord(formWords(lang).kinds, control);
5180
+ }
5181
+ /** A channel's words in `lang` ('' for an unknown kind — the caller keeps what it has). */
5182
+ function channelWords(kind, lang) {
5183
+ return ownWord(formWords(lang).channels, kind) ?? '';
5184
+ }
5185
+ /** A table's own entry — never an inherited `constructor` or `toString` for a key someone typed. */
5186
+ function ownWord(table, key) {
5187
+ return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : undefined;
5188
+ }
5189
+ /**
5190
+ * An UNTOUCHED baseline word in `lang`: when `value` is the English word one of `slots` carries, the site language's word
5191
+ * for that slot; anything an author wrote (or an empty value) comes back as it is. How a freshly created Form, Field or
5192
+ * submit button speaks the site's language without a second copy of its config.
5193
+ */
5194
+ function formWordIn(value, lang, slots) {
5195
+ if (typeof value !== 'string' || !value)
5196
+ return value;
5197
+ const base = baselineFormWords();
5198
+ const slot = slots.find(s => base[s] === value);
5199
+ return slot ? formWords(lang)[slot] : value;
5200
+ }
5201
+
5097
5202
  /**
5098
5203
  * The submit LIFECYCLE's decisions — what a form shows after the server answers, what it says when a
5099
5204
  * submit fails, what a client needs to validate a form, and how its submit button follows its state.
@@ -5202,8 +5307,23 @@ const SUBMIT_CHECK_SVG = `<svg class="${SubmitLabelClass.Check}" width="16" heig
5202
5307
  * translation service — the document's `lang` picks, like the date picker's words). */
5203
5308
  const SENT_WORDS = Object.freeze({ en: 'Sent', he: 'נשלח' });
5204
5309
  function sentWord(lang) {
5205
- const language = String(lang ?? '').toLowerCase().split(/[-_]/)[0];
5206
- return SENT_WORDS[language === 'iw' ? 'he' : language] ?? SENT_WORDS['en'];
5310
+ return SENT_WORDS[formLanguageOf(lang)] ?? SENT_WORDS['en'];
5311
+ }
5312
+ /** "While sending" in the site's language (iox-ui#158). The English one is the SubmitButton's baseline
5313
+ * (`loadingLabel`), which every stamped node carries until its author writes their own. */
5314
+ const BUSY_WORDS = Object.freeze({ en: 'Sending…', he: 'שולחים…' });
5315
+ /** The SubmitButton's baseline "While sending" words — what a node holds that nobody wrote. */
5316
+ const DEFAULT_BUSY_WORDS = BUSY_WORDS['en'];
5317
+ function busyWord(lang) {
5318
+ return BUSY_WORDS[formLanguageOf(lang)] ?? DEFAULT_BUSY_WORDS;
5319
+ }
5320
+ /**
5321
+ * What a submit button says while its form sends, in BOTH renderers (iox-ui#158): the author's words; the untouched
5322
+ * English baseline (or none set at all) in the page's language — a Hebrew site built before its composer wrote Hebrew
5323
+ * here says "שולחים…" without a rebuild. An empty string stays empty: the button keeps its idle words while sending.
5324
+ */
5325
+ function submitBusyWords(loadingLabel, lang) {
5326
+ return loadingLabel == null || loadingLabel === DEFAULT_BUSY_WORDS ? busyWord(lang) : loadingLabel;
5207
5327
  }
5208
5328
  /**
5209
5329
  * A submit button's words, as markup: its three labels stacked in one grid cell (the button keeps the longest one's
@@ -5383,7 +5503,6 @@ const FORM_PRESET_WORDS_HE = /* @__PURE__ */ Object.freeze({
5383
5503
  submitLabel: 'שליחה',
5384
5504
  successText: 'תודה — נחזור אליכם בקרוב.',
5385
5505
  errorText: 'לא הצלחנו לשלוח את הפרטים. נסו שוב — התשובות שלכם עדיין כאן.',
5386
- channel: 'שלחו לנו הודעה בוואטסאפ',
5387
5506
  },
5388
5507
  });
5389
5508
  /** A preset in a language: Hebrew when `lang` is, else the preset as it is. Fresh objects; the shape never changes. */
@@ -5396,7 +5515,8 @@ function formPresetIn(def, lang) {
5396
5515
  formName: he.formName,
5397
5516
  fields: def.fields.map((f, i) => ({ ...f, ...(he.fields[i] ?? {}) })),
5398
5517
  submitLabel: he.submitLabel, successText: he.successText, errorText: he.errorText,
5399
- ...(def.channel ? { channel: { ...def.channel, label: he.channel ?? def.channel.label } } : {}),
5518
+ // The channel's words are the kind's own (`form-words.ts`, iox-ui#159) unless the preset says otherwise.
5519
+ ...(def.channel ? { channel: { ...def.channel, label: he.channel ?? (channelWords(def.channel.kind, 'he') || def.channel.label) } } : {}),
5400
5520
  };
5401
5521
  }
5402
5522
  /** The config key of an email step that goes to the studio owner's account address (iox-cms#84). */
@@ -7801,11 +7921,16 @@ class IoxSubmitButtonComponent {
7801
7921
  this.host = host;
7802
7922
  this.nodeId = '';
7803
7923
  this.label = 'Submit';
7804
- this.loadingLabel = 'Sending…';
7924
+ this.loadingLabel = DEFAULT_BUSY_WORDS;
7805
7925
  /** What it says once its form has sent (N2). Empty: the catalog's "Sent", in the host's language. */
7806
7926
  this.sentLabel = '';
7807
7927
  this.disableWhileSubmitting = true;
7808
7928
  }
7929
+ /** The author's While sending words; the untouched English baseline in the page's language (iox-ui#158) — forms-core
7930
+ * `submitBusyWords`, the ONE decision the string renderer makes too. Empty: the idle words stay while sending. */
7931
+ get busyWords() {
7932
+ return submitBusyWords(this.loadingLabel, this.pageLang());
7933
+ }
7809
7934
  /** The author's Sent words; else the host's translation of the catalog's; else "Sent" in the page's language. */
7810
7935
  get sentWords() {
7811
7936
  if (this.sentLabel)
@@ -7814,15 +7939,19 @@ class IoxSubmitButtonComponent {
7814
7939
  const translated = (this.resolveMessage ?? defaultMessageResolver)(key);
7815
7940
  if (translated && translated !== key && translated !== DEFAULT_EN_MESSAGES[key])
7816
7941
  return translated;
7942
+ return sentWord(this.pageLang());
7943
+ }
7944
+ /** The page's language: the nearest `lang` (the canvas's site scope, the engine's `<html>`). */
7945
+ pageLang() {
7817
7946
  const element = this.host?.nativeElement;
7818
- return sentWord(element?.closest?.('[lang]')?.getAttribute('lang') ?? element?.ownerDocument?.documentElement?.lang);
7947
+ return element?.closest?.('[lang]')?.getAttribute('lang') ?? element?.ownerDocument?.documentElement?.lang;
7819
7948
  }
7820
7949
  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 }); }
7821
- 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">{{ loadingLabel || 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"] }); }
7950
+ 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"] }); }
7822
7951
  }
7823
7952
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.31", ngImport: i0, type: IoxSubmitButtonComponent, decorators: [{
7824
7953
  type: Component,
7825
- args: [{ selector: 'button[iox-submit]', template: `<span class="iox-submit__labels"><span class="iox-submit__idle">{{ label }}</span><span class="iox-submit__busy">{{ loadingLabel || 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>`, host: {
7954
+ args: [{ selector: 'button[iox-submit]', 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>`, host: {
7826
7955
  '[class]': "'iox-submit iox-node-' + nodeId",
7827
7956
  '[attr.type]': "'submit'",
7828
7957
  // forms-core SUBMIT_KEEP_ENABLED_ATTRIBUTE — read by `syncSubmitButtons`.