@vectoriox/iox-ui 5.197.0 → 5.198.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.
Files changed (47) hide show
  1. package/composite-core/index.d.ts +16 -2
  2. package/design-core/index.d.ts +160 -28
  3. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +34 -2
  4. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  5. package/fesm2022/vectoriox-iox-ui-design-core.mjs +259 -72
  6. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  7. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1845 -396
  8. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  9. package/fesm2022/vectoriox-iox-ui.mjs +2 -2
  10. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  11. package/generation-core/index.d.ts +1286 -184
  12. package/package.json +1 -1
  13. package/src/composite-core/header.ts +34 -1
  14. package/src/design-core/brand.ts +58 -5
  15. package/src/design-core/contrast-audit.ts +49 -22
  16. package/src/design-core/design-apply.ts +34 -3
  17. package/src/design-core/flavor-fixtures.generated.ts +123 -123
  18. package/src/design-core/flavor-spec.generated.ts +44 -4
  19. package/src/design-core/flavor-tokens.ts +1 -1
  20. package/src/design-core/header-behaviour.ts +72 -13
  21. package/src/design-core/motion-language.ts +5 -14
  22. package/src/design-core/preloader.ts +4 -5
  23. package/src/generation-core/body-mix.ts +40 -102
  24. package/src/generation-core/check-free.ts +5 -2
  25. package/src/generation-core/check-layout.ts +10 -4
  26. package/src/generation-core/check-list.ts +3 -25
  27. package/src/generation-core/colour-mix.ts +296 -0
  28. package/src/generation-core/compose-free.ts +40 -18
  29. package/src/generation-core/compose-site.ts +92 -13
  30. package/src/generation-core/footer-mix.ts +102 -54
  31. package/src/generation-core/free-fallback.ts +6 -4
  32. package/src/generation-core/free-parts.ts +87 -0
  33. package/src/generation-core/free-slot-words.ts +30 -0
  34. package/src/generation-core/generation-tier.ts +6 -17
  35. package/src/generation-core/header-mix.ts +42 -1
  36. package/src/generation-core/layout-drawers.ts +3 -2
  37. package/src/generation-core/layout-wire.ts +10 -16
  38. package/src/generation-core/list-panel.ts +3 -3
  39. package/src/generation-core/list-table.ts +5 -14
  40. package/src/generation-core/list-words.ts +2 -1
  41. package/src/generation-core/opening-mix.ts +7 -34
  42. package/src/generation-core/part-tier.ts +14 -0
  43. package/src/generation-core/plan-wire.ts +31 -43
  44. package/src/generation-core/public-api.ts +2 -0
  45. package/src/generation-core/site-spec.generated.ts +1127 -93
  46. package/src/generation-core/validate-site-plan.ts +4 -5
  47. package/styles/iox-design.css +137 -3
@@ -2,7 +2,7 @@ import {
2
2
  LayoutIssue, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHow, LayoutListHover, LayoutListItem, LayoutListMix,
3
3
  LayoutListMove, LayoutListPhone, LayoutListShape, LayoutListWho, LayoutMendKind, LayoutPage,
4
4
  } from './layout-language';
5
- import { LIST_RULES, bentoFill, listBelowPro, listBuiltWords, listMeaning, listWait, listWordRefusal, ListWordRefusal } from './list-table';
5
+ import { LIST_RULES, bentoFill, listBuiltWords, listMeaning, listWait, listWordRefusal, ListWordRefusal } from './list-table';
6
6
  import { bentoFillsParams, listSaidSentence, ListSaid, ListSayCode, ListSayParams, listWordRef, listWordRefs } from './list-words';
7
7
  import { SPEC_SITE_LAYOUT } from './site-spec.generated';
8
8
 
@@ -15,7 +15,6 @@ import { SPEC_SITE_LAYOUT } from './site-spec.generated';
15
15
 
16
16
  const R = SPEC_SITE_LAYOUT.list.rules;
17
17
  const IMAGE = 'image';
18
- const AWARD = 'award';
19
18
  /** What a name set on its picture may show beside the picture: the name and a short detail (AW11-D8). */
20
19
  const TITLE_ON_PHOTO_PARTS: ReadonlySet<string> = new Set(['title', 'meta', 'date']);
21
20
  const inList = (values: ReadonlyArray<string>, v: unknown): boolean => typeof v === 'string' && values.includes(v);
@@ -46,7 +45,7 @@ export interface LayoutListNever {
46
45
 
47
46
  /** AW11: what the judge knows of where the list sits and who it is built for. */
48
47
  export interface ListCheckOptions {
49
- /** AW-D23: the tier the site is built at; absent: the builder (the owner's choice — no word is held back). */
48
+ /** The tier the site is built at. Since AW-D42 it holds back no word; kept so its callers still read. */
50
49
  readonly tier?: string | null;
51
50
  /** The list is in the page's first screen (its first section): no arrival plays there (AW11-D15). */
52
51
  readonly firstScreen?: boolean;
@@ -105,27 +104,6 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
105
104
  const drawn = (next[k] as string[]).map(w => { const stand = waiting(k, w); return stand === undefined ? w : stand; }).filter((w): w is string => !!w);
106
105
  (next as unknown as Record<string, string[]>)[k] = [...new Set(drawn)];
107
106
  }
108
- // AW-D23: a round-two word on a site built below the award tier is drawn as its stand-in (the contract's belowPro).
109
- if (options.tier !== undefined && options.tier !== null && options.tier !== AWARD) {
110
- const below = (k: 'item' | 'arrange' | 'arrive', fallback: string) => {
111
- const stand = listBelowPro(k, next[k]);
112
- if (stand === undefined) return;
113
- repair(ListSayCode.AwardOnly, { k, word: listWordRef(k, next[k]), as: listWordRef(k, stand ?? fallback) });
114
- (next as unknown as Record<string, string>)[k] = stand ?? fallback;
115
- };
116
- below('item', LayoutListItem.Card);
117
- below('arrange', LayoutListArrange.Grid);
118
- below('arrive', LayoutListArrive.Together);
119
- for (const k of ['move', 'hover'] as const) {
120
- const kept = (next[k] as string[]).flatMap(w => {
121
- const stand = listBelowPro(k, w);
122
- if (stand === undefined) return [w];
123
- repair(ListSayCode.AwardOnly, { k, word: listWordRef(k, w), ...(stand ? { as: listWordRef(k, stand) } : {}) });
124
- return stand ? [stand] : [];
125
- });
126
- (next as unknown as Record<string, string[]>)[k] = [...new Set(kept)];
127
- }
128
- }
129
107
  const roles = shape.roles as ReadonlyArray<string>;
130
108
  const pictured = roles.includes(IMAGE);
131
109
 
@@ -313,7 +291,7 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
313
291
  next.hover = next.hover.filter(h => !has(R.onlyStrips.hover, h));
314
292
  }
315
293
  // AW11: hover words that need what the list may not have (one table), and the hover tilt — a still card's.
316
- const unread = next.hover.filter(h => listWordRefusal('hover', h, shape) !== null && listWordRefusal('hover', h, shape) !== ListWordRefusal.ProOnly);
294
+ const unread = next.hover.filter(h => listWordRefusal('hover', h, shape) !== null);
317
295
  if (unread.length) {
318
296
  // One sentence each (#123: they were one joined line — a screen says each in the owner's words).
319
297
  for (const h of unread) {
@@ -0,0 +1,296 @@
1
+ import { GroundTone, sectionPictured } from './body-mix';
2
+ import { LayoutIssue, LayoutIssueCode, LayoutSection, LayoutSectionKind } from './layout-language';
3
+ import { GenerationTier } from './site-plan.model';
4
+ import { SPEC_SITE_LAYOUT } from './site-spec.generated';
5
+
6
+ /**
7
+ * THE COLOUR (colour-v2-plan.md §5, CV0/CV1; CV-D1…CV-D14): how a site wears its colours — the page's ground family, the
8
+ * colour of its dark bands, how much accent and where, what the main button is painted with, how the section grounds
9
+ * follow one another (the rhythm), the bands' shape, how a ground is painted, the pictures' grade and where the seed comes
10
+ * from. Every word, its meaning in both languages, whether the product draws it, its tier, each rhythm's rule and the 24
11
+ * style presets' default mixes live in ONE table, the contract's `site.layout.colour` (layout.mjs `COLOUR`), read from
12
+ * Doron's references. This module reads it and judges a composed page's grounds against its rhythm (`colourRhythmIssues`,
13
+ * run by `checkLayout` — AW6's judge, moved here with the words, CV-D6). Pure.
14
+ *
15
+ * CV1 draws no new word: every word past today's look waits for CV2–CV5 and is drawn as today's (`drawnColourMix`).
16
+ */
17
+
18
+ interface ColourTable {
19
+ ingredients: Readonly<Record<string, ReadonlyArray<string>>>;
20
+ meanings: Readonly<Record<string, string>>;
21
+ meaningsHe: Readonly<Record<string, string>>;
22
+ waits: Readonly<Record<string, { phase: string; drawnAs: string }>>;
23
+ defaults: Readonly<Record<string, string>>;
24
+ fingerprint: ReadonlyArray<string>;
25
+ rhythms: {
26
+ 'one-ground': { darks: number };
27
+ 'long-runs': { run: number; breaks: number };
28
+ alternate: { neighbours: 'differ' };
29
+ 'paper-picture': { every: number };
30
+ chapters: { changesAt: ReadonlyArray<string> };
31
+ tail: { last: number };
32
+ flood: { neighbours: 'differ'; apart: number };
33
+ };
34
+ rules: {
35
+ groundsMax: Readonly<Record<string, number>>;
36
+ accentMax: Readonly<Record<string, number>>;
37
+ mutedGroundIn: ReadonlyArray<string>;
38
+ accentKeepsSeed: boolean;
39
+ washAudited: boolean;
40
+ };
41
+ tiers: Readonly<Record<string, 'all' | 'pro'>>;
42
+ presets: Readonly<Record<string, Readonly<Record<string, string>>>>;
43
+ }
44
+
45
+ const C = SPEC_SITE_LAYOUT.colour as unknown as ColourTable;
46
+
47
+ /** The ingredients, by the contract's keys (held equal to it by colour-mix.spec). */
48
+ export enum ColourIngredient {
49
+ Ground = 'ground',
50
+ Dark = 'dark',
51
+ Accent = 'accent',
52
+ Action = 'action',
53
+ Rhythm = 'rhythm',
54
+ Bands = 'bands',
55
+ Wash = 'wash',
56
+ Pictures = 'pictures',
57
+ Source = 'source',
58
+ }
59
+
60
+ export enum ColourGround { Look = 'look', Paper = 'paper', White = 'white', Cool = 'cool' }
61
+ export enum ColourDark { Ink = 'ink', BrandDeep = 'brand-deep', Earth = 'earth' }
62
+ export enum ColourAccent { Signal = 'signal', OnePlace = 'one-place', None = 'none', Flood = 'flood' }
63
+ export enum ColourAction { Accent = 'accent', Ink = 'ink', Deep = 'deep' }
64
+ export enum ColourRhythm {
65
+ Free = 'free',
66
+ OneGround = 'one-ground',
67
+ LongRuns = 'long-runs',
68
+ Alternate = 'alternate',
69
+ PaperPicture = 'paper-picture',
70
+ Chapters = 'chapters',
71
+ Tail = 'tail',
72
+ Flood = 'flood',
73
+ Flow = 'flow',
74
+ }
75
+ export enum ColourBands { Full = 'full', Inset = 'inset' }
76
+ export enum ColourWash { Flat = 'flat', Gradient = 'gradient', Glow = 'glow', PhotoDim = 'photo-dim' }
77
+ export enum ColourPictures { Natural = 'natural', Warm = 'warm', Cool = 'cool', Mono = 'mono' }
78
+ export enum ColourSource { Brand = 'brand', Photos = 'photos', Look = 'look' }
79
+
80
+ /** One word per ingredient. */
81
+ export type ColourMix = Readonly<Record<`${ColourIngredient}`, string>>;
82
+
83
+ export class ColourMixError extends Error {}
84
+
85
+ const HEBREW = 'he';
86
+ const ORDER: ReadonlyArray<ColourIngredient> = Object.values(ColourIngredient);
87
+
88
+ /** The words an ingredient may take, in the table's order (waiting ones too). */
89
+ export function colourWords(ingredient: `${ColourIngredient}`): ReadonlyArray<string> {
90
+ return C.ingredients[ingredient] ?? [];
91
+ }
92
+
93
+ /** What a word means — in Hebrew when the builder speaks it. */
94
+ export function colourMeaning(ingredient: `${ColourIngredient}`, word: string, locale?: string | null): string {
95
+ const key = `${ingredient}.${word}`;
96
+ return (locale === HEBREW ? C.meaningsHe[key] : undefined) ?? C.meanings[key] ?? word;
97
+ }
98
+
99
+ /** Whether the product draws a word today. */
100
+ export function colourWordDrawn(ingredient: `${ColourIngredient}`, word: string): boolean {
101
+ return colourWords(ingredient).includes(word) && !C.waits[`${ingredient}.${word}`];
102
+ }
103
+
104
+ /** The phase a waiting word waits for, or null. */
105
+ export function colourWordWaits(ingredient: `${ColourIngredient}`, word: string): string | null {
106
+ return C.waits[`${ingredient}.${word}`]?.phase ?? null;
107
+ }
108
+
109
+ /** CV-D10: a word every plan wears (`all`) or one the award tier alone is offered (`pro`). */
110
+ export function colourWordTier(ingredient: `${ColourIngredient}`, word: string): 'all' | 'pro' {
111
+ return C.tiers[`${ingredient}.${word}`] === 'pro' ? 'pro' : 'all';
112
+ }
113
+
114
+ /** May a build at `tier` wear this word? */
115
+ export function colourWordOffered(ingredient: `${ColourIngredient}`, word: string, tier: `${GenerationTier}`): boolean {
116
+ return colourWordTier(ingredient, word) === 'all' || tier === GenerationTier.Award;
117
+ }
118
+
119
+ /** A whole mix from part of one: what is not named is the default (today's look). Refuses a word the table lacks. */
120
+ export function colourMix(partial: Partial<Record<string, string>> = {}): ColourMix {
121
+ const mix: Record<string, string> = { ...C.defaults };
122
+ for (const [k, w] of Object.entries(partial)) {
123
+ if (w === undefined) continue;
124
+ if (!C.ingredients[k]) throw new ColourMixError(`no colour ingredient "${k}"`);
125
+ if (!C.ingredients[k].includes(w)) throw new ColourMixError(`a site's colour ${k} cannot be "${w}" (${C.ingredients[k].join(' · ')})`);
126
+ mix[k] = w;
127
+ }
128
+ return mix as ColourMix;
129
+ }
130
+
131
+ /** CV-D13: a style preset's default colour mix (its §6 row, the rest the defaults); an unknown preset wears the defaults. */
132
+ export function presetColourMix(presetId: string | null | undefined): ColourMix {
133
+ return colourMix(C.presets[presetId ?? ''] ?? {});
134
+ }
135
+
136
+ /** A mix on the wire: one `<ingredient>:<word>` per ingredient, in the table's order. */
137
+ export function colourMixWords(mix: ColourMix): string[] {
138
+ return ORDER.map(k => `${k}:${mix[k]}`);
139
+ }
140
+
141
+ /** The words back into a mix. Refuses an unknown word and two words for one ingredient. */
142
+ export function colourMixFromWords(words: ReadonlyArray<string>): ColourMix {
143
+ const partial: Record<string, string> = {};
144
+ for (const pair of words) {
145
+ const [k, w] = String(pair).split(':');
146
+ if (!C.ingredients[k] || !w) throw new ColourMixError(`"${pair}" is no colour word (<ingredient>:<word>)`);
147
+ if (partial[k] !== undefined && partial[k] !== w) throw new ColourMixError(`a site has one colour ${k} ("${partial[k]}" and "${w}")`);
148
+ partial[k] = w;
149
+ }
150
+ return colourMix(partial);
151
+ }
152
+
153
+ export interface ColourGap {
154
+ ingredient: `${ColourIngredient}`;
155
+ word: string;
156
+ phase: string;
157
+ drawnAs: string;
158
+ }
159
+
160
+ /** The mix the product DRAWS today: a waiting word becomes its stand-in, each said. */
161
+ export function drawnColourMix(mix: ColourMix): { drawn: ColourMix; gaps: ColourGap[] } {
162
+ const drawn: Record<string, string> = { ...mix };
163
+ const gaps: ColourGap[] = [];
164
+ for (const k of ORDER) {
165
+ const wait = C.waits[`${k}.${mix[k]}`];
166
+ if (!wait) continue;
167
+ gaps.push({ ingredient: k, word: mix[k], phase: wait.phase, drawnAs: wait.drawnAs });
168
+ drawn[k] = wait.drawnAs;
169
+ }
170
+ return { drawn: drawn as ColourMix, gaps };
171
+ }
172
+
173
+ /** The fingerprint's prefix for a site's colour. */
174
+ export const COLOUR_TOKEN = 'colour';
175
+
176
+ /** A site's colour as the fingerprint sees it: `colour:<ground>/<dark>/<accent>/<rhythm>` — what a visitor takes in at once. */
177
+ export function colourTokenOf(mix: ColourMix): string {
178
+ return `${COLOUR_TOKEN}:${C.fingerprint.map(k => mix[k as ColourIngredient]).join('/')}`;
179
+ }
180
+
181
+ /** Every `<ingredient>:<word>` a generator's wire may carry at `tier`: drawn words only, the award tier's only there. */
182
+ export function colourWireWords(tier: `${GenerationTier}` = GenerationTier.Basic): string[] {
183
+ return ORDER.flatMap(k => colourWords(k).filter(w => colourWordDrawn(k, w) && colourWordOffered(k, w, tier)).map(w => `${k}:${w}`));
184
+ }
185
+
186
+ /** CV-D7: the most different grounds a page may wear (photos excepted) under an accent word. */
187
+ export function colourGroundsMax(accent: string): number {
188
+ return C.rules.groundsMax[accent] ?? C.rules.groundsMax[ColourAccent.Signal];
189
+ }
190
+
191
+ /** The accent budget an accent word sets (replaces the look's `accentMax` when a plan names one, CV2). */
192
+ export function colourAccentMax(accent: string): number {
193
+ return C.rules.accentMax[accent] ?? C.rules.accentMax[ColourAccent.Signal];
194
+ }
195
+
196
+ // ── The rhythm: a composed page's grounds against the site's colour rhythm ──────────────────────────────────────────
197
+
198
+ export interface ColourRhythmContext {
199
+ /** Each section's ground, as it reads. */
200
+ toneOf: (section: LayoutSection) => GroundTone;
201
+ /** The footer's ground, as it reads; absent: the tail is not judged (the footer's scheme is not known). */
202
+ footerTone?: GroundTone | null;
203
+ }
204
+
205
+ const startsChapter = (s: LayoutSection, at: ReadonlyArray<string>) =>
206
+ (at.includes('inhale') && s.kind === LayoutSectionKind.Inhale) || (at.includes('signature') && !!s.signature);
207
+ const PHOTO_GROUND = 'photo:';
208
+ const groundWordOf = (s: LayoutSection): string => s.ground ?? 'ground';
209
+
210
+ /**
211
+ * A composed page's grounds judged against the colour rhythm (`COLOUR.rhythms`): each issue a `Structure` issue on the
212
+ * page, so the layout request is asked again with it. `free`, `flow` (CV5: the ScrollDriver's, not a section's) and an
213
+ * unknown word ask nothing. A photo ground is free in every rhythm. Pure.
214
+ */
215
+ export function colourRhythmIssues(sections: ReadonlyArray<LayoutSection>, rhythm: string | null | undefined, ctx: ColourRhythmContext): LayoutIssue[] {
216
+ const issues: LayoutIssue[] = [];
217
+ const add = (path: string, message: string) => issues.push({ code: LayoutIssueCode.Structure, path, message });
218
+ const tones = sections.map(s => ctx.toneOf(s));
219
+ const darks = tones.flatMap((t, i) => (t === GroundTone.Dark ? [i] : []));
220
+ const R = C.rhythms;
221
+ switch (rhythm) {
222
+ case ColourRhythm.Alternate:
223
+ for (let i = 1; i < sections.length; i++) {
224
+ if (tones[i] !== GroundTone.Photo && tones[i] === tones[i - 1]) {
225
+ add(`sections[${i}].ground`, `grounds alternate dark and light — "${sections[i].id}" is ${tones[i]} like the section before it`);
226
+ }
227
+ }
228
+ break;
229
+ case ColourRhythm.OneGround: {
230
+ const lastShown = tones.reduce((at, t, i) => (t === GroundTone.Photo ? at : i), -1);
231
+ darks.forEach((i, n) => {
232
+ if (n >= R['one-ground'].darks || i !== lastShown) {
233
+ add(`sections[${i}].ground`, `one ground for most of the page, at most ${R['one-ground'].darks} dark section before the footer — "${sections[i].id}" is dark`);
234
+ }
235
+ });
236
+ break;
237
+ }
238
+ case ColourRhythm.LongRuns: {
239
+ const { run, breaks } = R['long-runs'];
240
+ darks.forEach((i, n) => {
241
+ const since = n ? i - darks[n - 1] - 1 : i;
242
+ if (n >= breaks || since < Math.min(run, sections.length - 1)) {
243
+ add(`sections[${i}].ground`, `long light runs (${run} sections or more) broken by at most ${breaks} dark section — "${sections[i].id}" breaks it too soon`);
244
+ }
245
+ });
246
+ break;
247
+ }
248
+ case ColourRhythm.PaperPicture: {
249
+ const { every } = R['paper-picture'];
250
+ let since = 0;
251
+ sections.forEach((s, i) => {
252
+ since = sectionPictured(s) ? 0 : since + 1;
253
+ if (since > every) add(`sections[${i}]`, `paper and full pictures take turns, a picture at least every ${every} sections — "${s.id}" is the ${since}th without one`);
254
+ });
255
+ break;
256
+ }
257
+ case ColourRhythm.Chapters: {
258
+ const at = R.chapters.changesAt;
259
+ let last: GroundTone | null = null;
260
+ sections.forEach((s, i) => {
261
+ const tone = tones[i];
262
+ if (tone === GroundTone.Photo) return;
263
+ if (last !== null && tone !== last && !startsChapter(s, at)) {
264
+ add(`sections[${i}].ground`, `the ground changes only where a chapter starts (an inhale or the signature) — "${s.id}" changes it`);
265
+ }
266
+ last = tone;
267
+ });
268
+ break;
269
+ }
270
+ case ColourRhythm.Tail: {
271
+ if (!ctx.footerTone || ctx.footerTone === GroundTone.Photo) break;
272
+ const from = Math.max(0, sections.length - R.tail.last);
273
+ for (let i = from; i < sections.length; i++) {
274
+ if (tones[i] !== GroundTone.Photo && tones[i] !== ctx.footerTone) {
275
+ add(`sections[${i}].ground`, `the last ${R.tail.last} sections wear the footer's ${ctx.footerTone} ground — "${sections[i].id}" is ${tones[i]}`);
276
+ }
277
+ }
278
+ break;
279
+ }
280
+ case ColourRhythm.Flood: {
281
+ const { apart } = R.flood;
282
+ sections.forEach((s, i) => {
283
+ const g = groundWordOf(s);
284
+ if (g.startsWith(PHOTO_GROUND)) return;
285
+ for (let j = Math.max(0, i - apart); j < i; j++) {
286
+ if (groundWordOf(sections[j]) === g) {
287
+ add(`sections[${i}].ground`, `a different full colour each section, none again within ${apart} — "${s.id}" repeats "${g}"`);
288
+ break;
289
+ }
290
+ }
291
+ });
292
+ break;
293
+ }
294
+ }
295
+ return issues;
296
+ }
@@ -1,9 +1,10 @@
1
- import { NO_ELEMENT_STYLE } from '@vectoriox/iox-ui/composite-core';
1
+ import { CarouselFrom, ContentFieldLike, NO_ELEMENT_STYLE } from '@vectoriox/iox-ui/composite-core';
2
2
  import { LinkType } from '@vectoriox/iox-ui/design-core';
3
3
  import { VideoMode, VideoSource } from '@vectoriox/iox-ui/media-core';
4
4
 
5
5
  import { composeListFrame, LayoutListBinding } from './compose-layout';
6
- import { composePresetForm } from './compose-site';
6
+ import { composeListAccordion, composeListLightbox, composeListTabs, composePresetForm, composeQuoteCarousel } from './compose-site';
7
+ import { FREE_OPEN_LIGHTBOX, freeSlotOf, FreeSlotKind } from './free-slot-words';
7
8
  import { freeNodeId } from './free-render-check';
8
9
  import { freeStyleToSlots } from './free-slots';
9
10
  import { FREE_BUILDER_TYPE, FreeLayer, FreeNode, FreeNodeType, FreePage, FreeStyle, FreeTrigger } from './free-wire';
@@ -26,8 +27,9 @@ import { stampSection } from './section-stamp';
26
27
  const COMPOSED = { releaseLayoutDefaults: true } as const;
27
28
  const SECTION_LINK = '#';
28
29
  const ROUTE_MARK = '/';
29
- const LIST_SLOT = 'list:';
30
- const FORM_SLOT = 'form:';
30
+ /** The list roles a lightbox reads: the picture, and the name its picture is described by. */
31
+ const IMAGE_ROLE = 'image';
32
+ const TITLE_ROLE = 'title';
31
33
  /** A list slot's mix when the answer names no option: cards of the list's parts, in a grid. */
32
34
  const LIST_SLOT_WORDS: ReadonlyArray<string> = ['item:card', 'arrange:grid'];
33
35
 
@@ -44,6 +46,10 @@ export interface ComposeFreeOptions {
44
46
  photoAlt: (id: string) => string;
45
47
  /** How a list slot's items are read (`layoutListBinding`); null for an alias that is no list. */
46
48
  listOf: (alias: string) => LayoutListBinding | null;
49
+ /** A list's fields as composite-core's pickers read them (an `accordion:` / `tabs:` slot binds them). */
50
+ listFields?: (alias: string) => ReadonlyArray<ContentFieldLike>;
51
+ /** The plan's list of real quotes (`quoteListOf`) — what a `quotes:` slot repeats; null: the plan holds none. */
52
+ quotes?: CarouselFrom | null;
47
53
  /** The plan's ready-made section at plan index `at`, composed under `id` (a section the fall back gave back). */
48
54
  readyMade?: (at: number, id: string) => SerializedNode;
49
55
  }
@@ -114,7 +120,7 @@ function composeNode(n: FreeNode, ctx: Ctx, beat: number): SerializedNode {
114
120
  styleInto(node, n, ctx);
115
121
  const move = moveOf(n, id, ctx, beat);
116
122
  if (move) node.interactions = [...node.interactions, move];
117
- if (n.type === FreeNodeType.Slot) node.children = [slotOf(n, id, ctx)];
123
+ if (n.type === FreeNodeType.Slot) node.children = slotOf(n, id, ctx);
118
124
  else if (n.children?.length) {
119
125
  let moving = 0;
120
126
  node.children = [...(node.children ?? []), ...n.children.map(c => composeNode(c, ctx, c.move ? moving++ : 0))];
@@ -180,20 +186,36 @@ function moveOf(n: FreeNode, id: string, ctx: Ctx, beat: number): unknown | null
180
186
  };
181
187
  }
182
188
 
183
- /** The recipe a Slot places: the list composer's frame, or the preset form. */
184
- function slotOf(n: FreeNode, id: string, ctx: Ctx): SerializedNode {
185
- const slot = n.slot ?? '';
186
- if (slot.startsWith(LIST_SLOT)) {
187
- const alias = slot.slice(LIST_SLOT.length);
188
- const list = ctx.o.listOf(alias);
189
- if (!list) throw new ComposeError(`${n.id}: "${alias}" is no list of the plan`);
190
- const asked = (n.opts ?? []).filter(Boolean);
191
- const words = [...LIST_SLOT_WORDS.filter(w => !asked.some(a => a.split(':')[0] === w.split(':')[0])), ...asked];
192
- const mix = listMixFromWords(words, Object.keys(list.roles))!;
193
- return composeListFrame({ id: `${id}-list`, mix, source: alias, list, locale: ctx.o.locale, label: n.purpose ?? alias, path: n.id, ...(ctx.o.motion ? { motion: ctx.o.motion } : {}) }).frame;
189
+ /**
190
+ * What a Slot places (`free-parts.ts`): the list composer's frame (and, asked `open:lightbox`, the Lightbox its pictures
191
+ * open), the preset form, or a recipe over a list — the Accordion, Tabs, the testimonial carousel. Never the model's nodes.
192
+ */
193
+ function slotOf(n: FreeNode, id: string, ctx: Ctx): SerializedNode[] {
194
+ const slot = freeSlotOf(n.slot ?? '');
195
+ const locale = ctx.o.locale;
196
+ switch (slot?.kind) {
197
+ case FreeSlotKind.List: {
198
+ const list = ctx.o.listOf(slot.ref);
199
+ if (!list) throw new ComposeError(`${n.id}: "${slot.ref}" is no list of the plan`);
200
+ const asked = (n.opts ?? []).filter(o => o && o !== FREE_OPEN_LIGHTBOX);
201
+ const words = [...LIST_SLOT_WORDS.filter(w => !asked.some(a => a.split(':')[0] === w.split(':')[0])), ...asked];
202
+ const mix = listMixFromWords(words, Object.keys(list.roles))!;
203
+ const frame = composeListFrame({ id: `${id}-list`, mix, source: slot.ref, list, locale, label: n.purpose ?? slot.ref, path: n.id, ...(ctx.o.motion ? { motion: ctx.o.motion } : {}) }).frame;
204
+ if (!(n.opts ?? []).includes(FREE_OPEN_LIGHTBOX)) return [frame];
205
+ const image = list.roles[IMAGE_ROLE];
206
+ const lightbox = image ? composeListLightbox(`${id}-lightbox`, frame, slot.ref, image, locale, list.roles[TITLE_ROLE]) : null;
207
+ if (!lightbox) throw new ComposeError(`${n.id}: "${slot.ref}" shows no picture a click could open`);
208
+ return [frame, lightbox];
209
+ }
210
+ case FreeSlotKind.Form: return [composePresetForm(`${id}-form`, slot.ref, ctx.o.owner, locale)];
211
+ case FreeSlotKind.Accordion: return [composeListAccordion(`${id}-accordion`, slot.ref, ctx.o.listFields?.(slot.ref) ?? [], locale)];
212
+ case FreeSlotKind.Tabs: return [composeListTabs(`${id}-tabs`, slot.ref, ctx.o.listFields?.(slot.ref) ?? [], locale)];
213
+ case FreeSlotKind.Quotes: {
214
+ if (!ctx.o.quotes || ctx.o.quotes.source !== slot.ref) throw new ComposeError(`${n.id}: "${slot.ref}" is no list of real quotes`);
215
+ return [composeQuoteCarousel(`${id}-quotes`, ctx.o.quotes, locale)];
216
+ }
217
+ default: throw new ComposeError(`${n.id}: "${n.slot ?? ''}" is not a part a free page may place`);
194
218
  }
195
- if (slot.startsWith(FORM_SLOT)) return composePresetForm(`${id}-form`, slot.slice(FORM_SLOT.length), ctx.o.owner, ctx.o.locale);
196
- throw new ComposeError(`${n.id}: "${slot}" is not a part a free page may place`);
197
219
  }
198
220
 
199
221
  /** A Button to a section of this page scrolls to it (the product's `scrollTo`: M8-G7, no shareable `#id`). */