@vectoriox/iox-ui 5.187.0 → 5.189.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 +111 -11
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +136 -20
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +110 -10
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/forms-core/index.d.ts +59 -3
- package/generation-core/index.d.ts +24 -1
- 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 +3 -8
- package/src/generation-core/type-led.ts +120 -4
|
@@ -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,12 +5307,7 @@ 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
|
-
return SENT_WORDS[
|
|
5206
|
-
}
|
|
5207
|
-
/** A `lang` attribute's language: `he-IL` → `he` (and the old `iw`). */
|
|
5208
|
-
function languageOf(lang) {
|
|
5209
|
-
const language = String(lang ?? '').toLowerCase().split(/[-_]/)[0];
|
|
5210
|
-
return language === 'iw' ? 'he' : language;
|
|
5310
|
+
return SENT_WORDS[formLanguageOf(lang)] ?? SENT_WORDS['en'];
|
|
5211
5311
|
}
|
|
5212
5312
|
/** "While sending" in the site's language (iox-ui#158). The English one is the SubmitButton's baseline
|
|
5213
5313
|
* (`loadingLabel`), which every stamped node carries until its author writes their own. */
|
|
@@ -5215,7 +5315,7 @@ const BUSY_WORDS = Object.freeze({ en: 'Sending…', he: 'שולחים…' });
|
|
|
5215
5315
|
/** The SubmitButton's baseline "While sending" words — what a node holds that nobody wrote. */
|
|
5216
5316
|
const DEFAULT_BUSY_WORDS = BUSY_WORDS['en'];
|
|
5217
5317
|
function busyWord(lang) {
|
|
5218
|
-
return BUSY_WORDS[
|
|
5318
|
+
return BUSY_WORDS[formLanguageOf(lang)] ?? DEFAULT_BUSY_WORDS;
|
|
5219
5319
|
}
|
|
5220
5320
|
/**
|
|
5221
5321
|
* What a submit button says while its form sends, in BOTH renderers (iox-ui#158): the author's words; the untouched
|
|
@@ -5403,7 +5503,6 @@ const FORM_PRESET_WORDS_HE = /* @__PURE__ */ Object.freeze({
|
|
|
5403
5503
|
submitLabel: 'שליחה',
|
|
5404
5504
|
successText: 'תודה — נחזור אליכם בקרוב.',
|
|
5405
5505
|
errorText: 'לא הצלחנו לשלוח את הפרטים. נסו שוב — התשובות שלכם עדיין כאן.',
|
|
5406
|
-
channel: 'שלחו לנו הודעה בוואטסאפ',
|
|
5407
5506
|
},
|
|
5408
5507
|
});
|
|
5409
5508
|
/** A preset in a language: Hebrew when `lang` is, else the preset as it is. Fresh objects; the shape never changes. */
|
|
@@ -5416,7 +5515,8 @@ function formPresetIn(def, lang) {
|
|
|
5416
5515
|
formName: he.formName,
|
|
5417
5516
|
fields: def.fields.map((f, i) => ({ ...f, ...(he.fields[i] ?? {}) })),
|
|
5418
5517
|
submitLabel: he.submitLabel, successText: he.successText, errorText: he.errorText,
|
|
5419
|
-
|
|
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) } } : {}),
|
|
5420
5520
|
};
|
|
5421
5521
|
}
|
|
5422
5522
|
/** The config key of an email step that goes to the studio owner's account address (iox-cms#84). */
|