@vectoriox/iox-ui 5.90.0 → 5.90.2

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.
@@ -493,6 +493,8 @@ function galleryLayer(id: string, l: LayoutLayer, lc: LayerCtx, ctx: Ctx): Seria
493
493
  const frame = create(id, T.Container, {}, NO_ELEMENT_STYLE);
494
494
  setStyleProps(frame, { position: 'relative' });
495
495
  phone(frame, { height: 'auto' });
496
+ const scheme = layoutBandScheme(lc.section.ground);
497
+ if (scheme) setColorScheme(frame, scheme);
496
498
  const effect = g.effect ?? 'slide';
497
499
  const stacked = STACKED_EFFECTS.has(effect);
498
500
  const per = stacked ? 1 : g.perView === 'auto' ? 'auto' : Number(g.perView ?? 1);
@@ -581,25 +583,37 @@ function buttonLayer(id: string, l: LayoutLayer, ctx: Ctx): SerializedNode {
581
583
  return button;
582
584
  }
583
585
 
584
- /** The colour scheme a form wears on each band (iox-ui#58): its labels, fields and button are drawn by element styles that
585
- * read the page's tokens, so on a band painted with the ink (or the accent) they would vanish into it. The scheme
586
- * re-declares those tokens for that band; on the page's own ground (or the soft one) the form wears none. */
587
- const FORM_SCHEME_ON: Readonly<Partial<Record<LayoutColour, ColorScheme>>> = {
586
+ /** The colour scheme a form or a gallery wears on each band (iox-ui#58; the gallery's bar since M8 gate 2): its labels,
587
+ * fields, buttons, caption, count and arrows are drawn by element styles that read the page's tokens, so on a band
588
+ * painted with the ink (or the accent) they would vanish into it — a gallery's arrows were empty circles on the ink. The
589
+ * scheme re-declares those tokens for that band; on the page's own ground (or the soft one) they wear none. */
590
+ const BAND_SCHEME_ON: Readonly<Partial<Record<LayoutColour, ColorScheme>>> = {
588
591
  [LayoutColour.Ink]: ColorScheme.Inverse,
589
- [LayoutColour.Muted]: ColorScheme.Inverse,
592
+ [LayoutColour.Muted]: ColorScheme.Muted,
590
593
  [LayoutColour.Accent]: ColorScheme.Accent,
591
594
  };
592
595
 
593
- /** The scheme a form on this section ground wears, or null on the page's own ground. */
594
- export function layoutFormScheme(ground: string | undefined): ColorScheme | null {
595
- return FORM_SCHEME_ON[(ground ?? LayoutColour.Ground) as LayoutColour] ?? null;
596
+ /** A wrapper that adds no box (`display: contents` — its children keep their place in the grid) and re-declares the band's
597
+ * tokens for them: a ready-made section's content, a button on a band. */
598
+ function bandColours(id: string, scheme: ColorScheme, children: SerializedNode[]): SerializedNode {
599
+ const band = create(id, T.Container, {}, NO_ELEMENT_STYLE);
600
+ band.label = 'band colours';
601
+ setStyleProps(band, { display: 'contents' });
602
+ setColorScheme(band, scheme);
603
+ band.children = children;
604
+ return band;
605
+ }
606
+
607
+ /** The scheme a form, a gallery, a button or a ready-made section's content on this section ground wears, or null on the page's own ground. */
608
+ export function layoutBandScheme(ground: string | undefined): ColorScheme | null {
609
+ return BAND_SCHEME_ON[(ground ?? LayoutColour.Ground) as LayoutColour] ?? null;
596
610
  }
597
611
 
598
612
  /** A form layer: its title and intro, and the product's preset form — the layout's options become the preset's choices. */
599
613
  function formLayer(id: string, l: LayoutLayer, lc: LayerCtx, ctx: Ctx, path: string): SerializedNode {
600
614
  const f: LayoutForm = l.form ?? { preset: 'contact' };
601
615
  const frame = create(id, T.Container, {}, NO_ELEMENT_STYLE);
602
- const scheme = layoutFormScheme(lc.section.ground);
616
+ const scheme = layoutBandScheme(lc.section.ground);
603
617
  if (scheme) setColorScheme(frame, scheme);
604
618
  setStyleProps(frame, { display: 'flex', flexDirection: 'column', gap: '12px', color: 'var(--iox-text)' });
605
619
  const parts: SerializedNode[] = [];
@@ -702,7 +716,10 @@ function composeLayer(l: LayoutLayer, lc: LayerCtx, ctx: Ctx): SerializedNode {
702
716
  gap(ctx, LayoutGapCode.DepthSpeed, lc.path, `${depth} glides at the product's one speed`);
703
717
  }
704
718
  if (interactions.length) outer.interactions = [...outer.interactions, ...interactions];
705
- return outer;
719
+ // A button draws its ink from the page's button tokens: on a band they must be the band's, or a text button on the ink
720
+ // (or the muted) band is the ground's own colour — the bar's "See the whole menu" (M8 gate 2, iox-ui#70).
721
+ const scheme = l.kind === LayoutLayerKind.Button ? layoutBandScheme(lc.section.ground) : null;
722
+ return scheme ? bandColours(`${outer.id}-band`, scheme, [outer]) : outer;
706
723
  }
707
724
 
708
725
  // ── Sections ────────────────────────────────────────────────────────────────────────────────────────────
@@ -832,7 +849,7 @@ function composeHeader(ctx: Ctx): SerializedNode | null {
832
849
  gap(ctx, LayoutGapCode.SectionLink, 'nav', 'section links scroll by an action, with no #address');
833
850
  const pages = [{ name: ctx.site.name, route: NAV_ROUTE, isHome: true }, ...links.map(link => ({ name: link.label, route: `/${link.to}` }))];
834
851
  let n = 0;
835
- const { header } = composeNavHeader({ business: { name: ctx.site.name } as never, pages }, { id: `${ctx.p}-nav`, newId: suffix => `${ctx.p}-nav-${++n}-${suffix}` });
852
+ const { header } = composeNavHeader({ business: { name: ctx.site.name } as never, pages, locale: ctx.site.locale }, { id: `${ctx.p}-nav`, newId: suffix => `${ctx.p}-nav-${++n}-${suffix}` });
836
853
  if (ctx.rtl) setStyleProps(header, { textDirection: 'rtl' });
837
854
  let drawer: string | undefined;
838
855
  walkSerialized([header], node => { if (node.role === 'nav.drawer') drawer = node.id; });
@@ -861,6 +878,68 @@ function wireLinks(ctx: Ctx): void {
861
878
  }
862
879
  }
863
880
 
881
+ // ── A ready-made section among composed ones (vectoriox/iox-ui#69) ───────────────────────────────────────
882
+
883
+ /** The pattern's own section padding: its ground's rhythm above and below, the pattern's gutter at the sides. */
884
+ const PATTERN_SECTION_PAD = 'var(--iox-section-pad)';
885
+ const PATTERN_SECTION_SPACE = 'var(--iox-space-section)';
886
+ /** The furthest in a ready-made section's words start: the column grid keeps at least eight columns for them. */
887
+ const READY_MADE_MAX_COLUMN = 3;
888
+
889
+ /** The ground a section paints, by name (a photo ground reads as the ink: its words are light). */
890
+ function groundOf(s: LayoutSection): string {
891
+ const ground = String(s.ground ?? LayoutColour.Ground);
892
+ return ground.startsWith('photo:') ? LayoutColour.Ink : ground;
893
+ }
894
+
895
+ /** The composed section a ready-made place stands beside: the one it follows, or for an opening the one after it; null
896
+ * when the page has no composed section. */
897
+ function readyMadeNeighbour(sections: ReadonlyArray<LayoutSection>, si: number): LayoutSection | null {
898
+ for (let i = si - 1; i >= 0; i--) if (!sections[i].readyMade) return sections[i];
899
+ for (let i = si + 1; i < sections.length; i++) if (!sections[i].readyMade) return sections[i];
900
+ return null;
901
+ }
902
+
903
+ /** The column a ready-made section's words start on: where its neighbour's words start (their first column), so the two
904
+ * share an edge; at most READY_MADE_MAX_COLUMN; 1 (the gutter) when the neighbour has no words. */
905
+ export function readyMadeColumn(neighbour: LayoutSection | null): number {
906
+ const starts = (neighbour?.layers ?? []).filter(l => LAYOUT_TEXT_KINDS.has(l.kind) && Array.isArray(l.col)).map(l => l.col[0]);
907
+ return Math.min(READY_MADE_MAX_COLUMN, Math.max(1, starts.length ? Math.min(...starts) : 1));
908
+ }
909
+
910
+ /** Where column `n` starts from the page's edge, on the composed sections' own grid (`gridLayout`): the gutter, then
911
+ * n - 1 columns and their gaps. */
912
+ function columnInset(n: number): string {
913
+ if (n <= 1) return LAYOUT_GUTTER;
914
+ const column = `((100% - 2 * ${LAYOUT_GUTTER} - ${GRID_COLUMNS - 1} * ${LAYOUT_COLUMN_GAP}) / ${GRID_COLUMNS} + ${LAYOUT_COLUMN_GAP})`;
915
+ return `calc(${LAYOUT_GUTTER} + ${n - 1} * ${column})`;
916
+ }
917
+
918
+ /** A pattern that paints its own ground — a Scene, or a picture behind its words — keeps its colours. */
919
+ function paintsItsOwnGround(root: SerializedNode): boolean {
920
+ return root.role === SceneRole.Scene || (root.children ?? []).some(c => c.styleProps?.['position'] === 'absolute');
921
+ }
922
+
923
+ /**
924
+ * iox-ui#69: a ready-made section reads as the same hand as the composed sections around it. It paints the ground it
925
+ * follows with the composed sections' own paint (the page's tokens on the section), its content wears that band's
926
+ * colour scheme in a wrapper that adds no box (`display: contents` — the pattern's layout is untouched, its tokens
927
+ * re-resolve), and its words start on the layout's column instead of the pattern's gutter; on a phone, the composed
928
+ * sections' gutter. A pattern that paints its own ground keeps its colours.
929
+ */
930
+ function dressReadyMade(root: SerializedNode, ground: string | null, column: number): void {
931
+ if (root.styleProps?.['padding'] === PATTERN_SECTION_PAD) {
932
+ setStyleProps(root, { padding: `${PATTERN_SECTION_SPACE} ${columnInset(column)}` });
933
+ phone(root, { padding: `${PATTERN_SECTION_SPACE} ${LAYOUT_GUTTER}` });
934
+ }
935
+ if (ground === null || paintsItsOwnGround(root)) return;
936
+ setColorScheme(root, ColorScheme.Default);
937
+ setStyleProps(root, { backgroundColor: groundPaint(ground) });
938
+ const scheme = layoutBandScheme(ground);
939
+ if (!scheme || !root.children?.length) return;
940
+ root.children = [bandColours(`${root.id}-band`, scheme, root.children)];
941
+ }
942
+
864
943
  /**
865
944
  * A layout-language page → its layout and header. Deterministic: the same layout composes to byte-identical nodes.
866
945
  * Refuses (ComposeError) a link to a section the layout does not have; everything the product cannot say comes back in
@@ -891,13 +970,15 @@ export function composeLayout(site: LayoutSite, options: ComposeLayoutOptions):
891
970
  if (s.readyMade) {
892
971
  if (!options.readyMade) throw new ComposeError(`sections[${si}]: a ready-made place needs its plan section stamped (options.readyMade)`);
893
972
  const node = options.readyMade(s, `${ctx.p}-s${si}`);
973
+ const neighbour = readyMadeNeighbour(site.sections, si);
974
+ const ground = neighbour ? groundOf(neighbour) : null;
975
+ dressReadyMade(node, ground, readyMadeColumn(neighbour));
894
976
  ctx.sections[s.id] = node.id;
895
- prev = LayoutColour.Ground;
977
+ prev = paintsItsOwnGround(node) || ground === null ? LayoutColour.Ground : ground;
896
978
  return node;
897
979
  }
898
980
  const node = composeSection(s, si, prev, ctx);
899
- const ground = String(s.ground ?? LayoutColour.Ground);
900
- prev = ground.startsWith('photo:') ? LayoutColour.Ink : ground;
981
+ prev = groundOf(s);
901
982
  return node;
902
983
  });
903
984
  const header = composeHeader(ctx);
@@ -335,6 +335,11 @@ interface TextChoice {
335
335
  placeholder?: { kind: PlaceholderKind; fact?: FactKey };
336
336
  }
337
337
 
338
+ /** A pattern node's own words in the site's language: its Hebrew on a Hebrew site when the contract gives one. */
339
+ function ownWords(pn: PatternNode, locale: string | undefined): string {
340
+ return locale === SiteLocale.He && pn.textHe ? pn.textHe : pn.text!;
341
+ }
342
+
338
343
  /** Where a node's words come from: the plan's slot → the business → the customer's fact → the pattern's
339
344
  * own text. A missing fact shows its label and is a placeholder; nothing is ever made up. */
340
345
  function chooseText(pn: PatternNode, ctx: Ctx): TextChoice {
@@ -349,7 +354,7 @@ function chooseText(pn: PatternNode, ctx: Ctx): TextChoice {
349
354
  const given = ctx.plan.business.facts?.[fact];
350
355
  return nonEmpty(given) ? { value: given } : { value: SITE_FACT_LABELS[fact], placeholder: { kind: PlaceholderKind.Fact, fact } };
351
356
  }
352
- const own = pn.text === undefined ? undefined : fillVariables(pn.text, ctx);
357
+ const own = pn.text === undefined ? undefined : fillVariables(ownWords(pn, ctx.plan.locale), ctx);
353
358
  if (pn.ph === PatternPlaceholder.Copy) return { value: own, placeholder: { kind: PlaceholderKind.Copy } };
354
359
  if (pn.ph === PatternPlaceholder.Price) return { value: own, placeholder: { kind: PlaceholderKind.Price } };
355
360
  if (pn.ph === PatternPlaceholder.Stat) return { value: own, placeholder: { kind: PlaceholderKind.Stat } };
@@ -1381,6 +1386,8 @@ export interface NavHeaderInput {
1381
1386
  readonly business: SiteBusiness;
1382
1387
  /** Every page of the studio, in the order the navigation should list them. */
1383
1388
  readonly pages: ReadonlyArray<SitePageRef>;
1389
+ /** The site's language (`SiteLocale`): the header's own words (its call to action) in it. English when not given. */
1390
+ readonly locale?: string;
1384
1391
  }
1385
1392
 
1386
1393
  export interface NavHeaderOptions {
@@ -1428,7 +1435,7 @@ export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOption
1428
1435
  const all = navPagePlans(input.pages);
1429
1436
  const navRoutes = new Set(siteNavPages(input.pages).map(p => p.route));
1430
1437
  const pages = all.map(p => ({ ...p, inNav: navRoutes.has(p.route) }));
1431
- const plan = { business: input.business, pages, dataSources: [], contentTypes: [] } as unknown as SitePlan;
1438
+ const plan = { business: input.business, pages, dataSources: [], contentTypes: [], locale: input.locale } as unknown as SitePlan;
1432
1439
  const email = nonEmpty(input.business.facts?.email) ? input.business.facts!.email!.trim() : null;
1433
1440
  const issues: ComposeIssue[] = [];
1434
1441
  const ctx: Ctx = {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The words that carry no subject in the languages a site is written in (English, Hebrew): "the", "with", "our", "כמו",
3
+ * "שלנו"… Shared by every comparison of meaning by words — a stock photo against a slot (`stockWords`), a model's section
4
+ * against a ready-made one (silent section fallback). Lower case; only words of three letters or more (shorter ones never
5
+ * count anywhere).
6
+ */
7
+ export const FUNCTION_WORDS: ReadonlySet<string> = new Set([
8
+ 'the', 'and', 'with', 'for', 'your', 'our', 'you', 'from', 'into', 'this', 'that', 'here', 'there', 'about', 'how', 'what',
9
+ 'who', 'are', 'all', 'but', 'not', 'was', 'were', 'has', 'have', 'had', 'its', 'they', 'them', 'their', 'then', 'than',
10
+ 'when', 'where', 'which', 'will', 'can', 'just', 'out', 'over', 'under', 'onto', 'each', 'every', 'some', 'any', 'one', 'also',
11
+ 'too', 'very', 'more', 'most', 'less', 'only', 'own', 'yours', 'ours', 'these', 'those',
12
+ 'אנחנו', 'אני', 'הוא', 'היא', 'אתם', 'אתן', 'שלנו', 'שלכם', 'שלך', 'שלו', 'שלה', 'אצלנו', 'כמו', 'אבל', 'זאת', 'כאן', 'יותר',
13
+ 'מאוד', 'כבר', 'עוד', 'אחרי', 'לפני', 'בין', 'כדי', 'איך',
14
+ ]);
@@ -270,6 +270,16 @@ export enum LayoutDial {
270
270
  export interface LayoutPage {
271
271
  dial: `${LayoutDial}`;
272
272
  sections: LayoutSection[];
273
+ /** Silent section fallback (iox-ui#67): the model's sections given away — replaced by a ready-made one or dropped — each
274
+ * at its place in the model's page. The page's MINIMUMS forgive what these carried; set only by `fallBackBySection`. */
275
+ givenAway?: LayoutGivenAway[];
276
+ }
277
+
278
+ /** One of the model's sections that silent section fallback gave away, kept with the page it left. */
279
+ export interface LayoutGivenAway {
280
+ /** Its place in the model's page. */
281
+ at: number;
282
+ section: LayoutSection;
273
283
  }
274
284
 
275
285
  /** Where a layout's photo comes from (M8-G2-D10): `own:<assetId>` · `stock:<libraryKey>` · `box:<shape>`. */
@@ -1,3 +1,4 @@
1
+ import { FUNCTION_WORDS } from './function-words';
1
2
  import { LayoutIssue, LayoutLayer, LayoutPage, LayoutSection } from './layout-language';
2
3
  import { PageSectionPlan } from './site-plan.model';
3
4
 
@@ -6,9 +7,12 @@ import { PageSectionPlan } from './site-plan.model';
6
7
  * A composed page that still fails after the mends and its one repair — or after the browser's check — no longer falls
7
8
  * back whole: each section an issue names is given to the plan's READY-MADE section for the same place (the pattern the
8
9
  * whole-page fallback would have stamped there, worn in the same look), or dropped where none fits and the page keeps its
9
- * opening and its close. Then the page is judged again, once, exactly like any composed page. Only a page that still
10
- * fails — an issue that names no section, a place with nothing to give it, a swap that breaks a section kept or a count
11
- * of the page — falls back whole: the last resort, counted. A swap never leads to another swap. The owner sees a composed page; the swaps are recorded for us, the model's sections kept.
10
+ * opening and its close. Then the page is judged again, once, exactly like any composed page — its MINIMUMS on the model's
11
+ * own remaining sections (the given-away ones ride on `page.givenAway`; iox-ui#67, Doron 2026-11-09), its maximums on the
12
+ * whole page. A ready-made section that would say again what a section the model kept already says (its title, its text —
13
+ * iox-ui#68) is never given a place: a page that repeats a paragraph is worse than the last resort. Only a page that still
14
+ * fails — an issue that names no section, a place with nothing to give it, a swap that
15
+ * breaks a section kept or a maximum of the page — falls back whole: the last resort, counted. A swap never leads to another swap. The owner sees a composed page; the swaps are recorded for us, the model's sections kept.
12
16
  * Pure: the service and `ai:replay` run this one function.
13
17
  */
14
18
 
@@ -28,7 +32,7 @@ export enum SectionSwapRule {
28
32
  Close = 'close',
29
33
  /** A middle section: the ready-made section that shows the same list, holds the form, or says most of its words. */
30
34
  Fit = 'fit',
31
- /** A middle section no ready-made section fits: dropped. */
35
+ /** A middle section no ready-made section fits (or every one that does would repeat a kept section, iox-ui#68): dropped. */
32
36
  NoFit = 'no-fit',
33
37
  }
34
38
 
@@ -52,7 +56,8 @@ export interface SectionSwap {
52
56
  export enum SectionFallbackLastResort {
53
57
  /** Nothing left names a section (a count, a share, the order of sections), or after the swaps only such an issue is. */
54
58
  PageWide = 'page-wide',
55
- /** The place named is the opening or the close, and the plan has no ready-made section left for it. */
59
+ /** The place named is the opening or the close, and the plan has no ready-made section left for it — or only one that
60
+ * would repeat what a kept section says (iox-ui#68). */
56
61
  NoReadyMade = 'no-ready-made',
57
62
  /** It names a section already given to a ready-made one. */
58
63
  ReadyMadeNamed = 'ready-made-named',
@@ -83,8 +88,43 @@ export function sectionsNamed(issue: Pick<LayoutIssue, 'path' | 'message'>): num
83
88
  }
84
89
 
85
90
  const WORD = /[\p{L}\p{N}]{3,}/gu;
86
- const wordsOf = (text: string): string[] => (String(text ?? '').toLowerCase().match(WORD) ?? []);
87
- const layerWords = (l: LayoutLayer): string[] => [l.text ?? '', ...(l.items ?? []), ...(l.gallery?.slides ?? []).map(s => s.caption ?? ''), l.form?.title ?? '', l.form?.intro ?? ''].flatMap(wordsOf);
91
+ /** The words that can make a fit: three letters or more, never a function word (iox-ui#68: "the" made one). */
92
+ const wordsOf = (text: string): string[] => (String(text ?? '').toLowerCase().match(WORD) ?? []).filter(w => !FUNCTION_WORDS.has(w));
93
+ const layerTexts = (l: LayoutLayer): string[] => [l.text ?? '', ...(l.items ?? []), ...(l.gallery?.slides ?? []).map(s => s.caption ?? ''), l.form?.title ?? '', l.form?.intro ?? ''];
94
+ const layerWords = (l: LayoutLayer): string[] => layerTexts(l).flatMap(wordsOf);
95
+
96
+ /** Every word of a text, in order, as a phrase that can be found inside another (` a small room kept slow `). */
97
+ const PHRASE_WORD = /[\p{L}\p{N}]+/gu;
98
+ const phraseOf = (text: string): { phrase: string; words: number } => {
99
+ const words = String(text ?? '').toLowerCase().match(PHRASE_WORD) ?? [];
100
+ return { phrase: ` ${words.join(' ')} `, words: words.length };
101
+ };
102
+ /** The fewest words a text needs to count as said twice — a two-word label ("The room") may well appear twice. */
103
+ const REPEAT_MIN_WORDS = 3;
104
+ /** The share of the shorter text's words the longer one holds for the two to be the same sentence said twice: one word
105
+ * changed is still a repeat (the café's quote, "…וחברים צריכים שולחן" and "…וחברים טובים צריכים שולחן"). */
106
+ const REPEAT_SHARED = 0.8;
107
+
108
+ /** Whether two texts say the same thing: one inside the other, or the shorter's words (function words aside) nearly all
109
+ * in the longer. */
110
+ function sameSaying(a: { phrase: string; text: string }, b: { phrase: string; text: string }): boolean {
111
+ if (a.phrase.includes(b.phrase) || b.phrase.includes(a.phrase)) return true;
112
+ const [short, long] = [new Set(wordsOf(a.text)), new Set(wordsOf(b.text))].sort((x, y) => x.size - y.size);
113
+ if (short.size < REPEAT_MIN_WORDS) return false;
114
+ return [...short].filter(w => long.has(w)).length / short.size >= REPEAT_SHARED;
115
+ }
116
+
117
+ /**
118
+ * Whether the plan section would say again what the sections the model kept already say (iox-ui#68): a title or a text of
119
+ * its slots found inside a kept layer's words, or a kept layer's words found inside it, or the two the same sentence
120
+ * with a word changed — each of three words or more.
121
+ */
122
+ function repeatsKept(plan: PageSectionPlan, kept: ReadonlyArray<LayoutSection>): boolean {
123
+ const long = (text: string) => ({ ...phraseOf(text), text });
124
+ const said = kept.flatMap(s => (s.layers ?? []).flatMap(layerTexts)).map(long).filter(p => p.words >= REPEAT_MIN_WORDS);
125
+ return Object.values(plan.slots ?? {}).map(long).filter(p => p.words >= REPEAT_MIN_WORDS)
126
+ .some(slot => said.some(k => sameSaying(slot, k)));
127
+ }
88
128
 
89
129
  /** How well a ready-made section stands for a model's section: the same list, the form, the words they share. */
90
130
  function fitScore(section: LayoutSection, plan: PageSectionPlan): number {
@@ -119,6 +159,8 @@ export function fallBackBySection(page: LayoutPage, plan: ReadonlyArray<PageSect
119
159
  if (!named.size) return last(SectionFallbackLastResort.PageWide, [...issues]);
120
160
  if ([...named.keys()].some(i => current.sections[i].readyMade)) return last(SectionFallbackLastResort.ReadyMadeNamed, [...issues]);
121
161
  const used = new Set(current.sections.map(s => s.readyMade?.at).filter((n): n is number => n !== undefined));
162
+ // The sections the model composed and keeps: a ready-made section must not say again what they say.
163
+ const keptSections = current.sections.filter((s, i) => !s.readyMade && !named.has(i));
122
164
  const lastAt = current.sections.length - 1;
123
165
  const next = [...current.sections];
124
166
  const drop = new Set<number>();
@@ -128,14 +170,14 @@ export function fallBackBySection(page: LayoutPage, plan: ReadonlyArray<PageSect
128
170
  swaps.push({ id: s.id, at: i, action, rule, ...(readyMade ? { readyMade } : {}), why, original: structuredClone(s) });
129
171
  if (i === 0 || i === lastAt) {
130
172
  const at = i === 0 ? 0 : plan.length - 1;
131
- if (!plan[at] || used.has(at)) return last(SectionFallbackLastResort.NoReadyMade, [...issues]);
173
+ if (!plan[at] || used.has(at) || repeatsKept(plan[at], keptSections)) return last(SectionFallbackLastResort.NoReadyMade, [...issues]);
132
174
  used.add(at);
133
175
  next[i] = readyMadeSection(s, at, plan[at]);
134
176
  record(SectionSwapAction.Replaced, i === 0 ? SectionSwapRule.Opening : SectionSwapRule.Close, { at, pattern: plan[at].pattern });
135
177
  continue;
136
178
  }
137
179
  const best = plan
138
- .map((p, at) => ({ at, score: at > 0 && at < plan.length - 1 && !used.has(at) ? fitScore(s, p) : -1 }))
180
+ .map((p, at) => ({ at, score: at > 0 && at < plan.length - 1 && !used.has(at) && !repeatsKept(p, keptSections) ? fitScore(s, p) : -1 }))
139
181
  .filter(c => c.score >= FIT_MIN)
140
182
  .sort((a, b) => b.score - a.score || a.at - b.at)[0];
141
183
  if (best) {
@@ -147,7 +189,10 @@ export function fallBackBySection(page: LayoutPage, plan: ReadonlyArray<PageSect
147
189
  record(SectionSwapAction.Dropped, SectionSwapRule.NoFit);
148
190
  }
149
191
  }
150
- const judged = judge({ ...current, sections: next.filter((_, i) => !drop.has(i)) });
192
+ // What the given-away sections carried toward the page's minimums goes with the page (checkLayout forgives exactly
193
+ // that, iox-ui#67); its maximums stay the whole page's.
194
+ const givenAway = [...(current.givenAway ?? []), ...swaps.map(w => ({ at: w.at, section: w.original }))];
195
+ const judged = judge({ ...current, sections: next.filter((_, i) => !drop.has(i)), givenAway });
151
196
  if (!judged.issues.length) return { page: judged.page, swaps, left: [] };
152
197
  const kept = judged.issues.flatMap(sectionsNamed).filter(i => !judged.page.sections[i]?.readyMade);
153
198
  const reason = kept.length ? SectionFallbackLastResort.Neighbour
@@ -47,6 +47,8 @@ export interface PatternNode {
47
47
  readonly slot?: string;
48
48
  readonly fromBusiness?: string;
49
49
  readonly text?: string;
50
+ /** The pattern's own words on a Hebrew site (the contract's COPY_HE); `text` everywhere else. */
51
+ readonly textHe?: string;
50
52
  readonly ph?: string;
51
53
  readonly bind?: string;
52
54
  readonly alt?: string;
@@ -25,7 +25,8 @@ export const SPEC_SITE_PLAN_SHAPE = {
25
25
  },
26
26
  "layoutPage": {
27
27
  "dial": "'distinct' | 'daring' — how far the page breaks the usual layout (site.layout.vocab.dials; follows How animated, never the model's)",
28
- "sections": "layoutSection[] — the page in the layout language (site.layout): 4–8 sections of layers on a 12-column grid, checked by generation-core checkLayout, stamped by composeLayout"
28
+ "sections": "layoutSection[] — the page in the layout language (site.layout): 4–8 sections of layers on a 12-column grid, checked by generation-core checkLayout, stamped by composeLayout",
29
+ "givenAway?": "{ at, section }[] — the model's sections silent section fallback gave away (replaced by a ready-made section or dropped), at their places in the model's page; the page's minimums forgive what they carried (iox-ui#67). Set by the server, never by a model"
29
30
  },
30
31
  "film": {
31
32
  "sequence": "object — a media-core FrameSequence: where the numbered pictures live, how many, their size"
@@ -599,7 +600,8 @@ export const SPEC_SITE_PATTERNS = {
599
600
  ]
600
601
  ]
601
602
  }
602
- ]
603
+ ],
604
+ "textHe": "צרו קשר"
603
605
  }
604
606
  ]
605
607
  }
@@ -750,7 +752,8 @@ export const SPEC_SITE_PATTERNS = {
750
752
  ]
751
753
  ]
752
754
  }
753
- ]
755
+ ],
756
+ "textHe": "צרו קשר"
754
757
  }
755
758
  ]
756
759
  }
@@ -1222,7 +1225,8 @@ export const SPEC_SITE_PATTERNS = {
1222
1225
  "slot": "cta",
1223
1226
  "max": 24,
1224
1227
  "text": "Get in touch",
1225
- "role": "nav.cta"
1228
+ "role": "nav.cta",
1229
+ "textHe": "צרו קשר"
1226
1230
  }
1227
1231
  ]
1228
1232
  }
@@ -1301,7 +1305,8 @@ export const SPEC_SITE_PATTERNS = {
1301
1305
  "slot": "cta",
1302
1306
  "max": 24,
1303
1307
  "text": "Get in touch",
1304
- "role": "nav.cta"
1308
+ "role": "nav.cta",
1309
+ "textHe": "צרו קשר"
1305
1310
  }
1306
1311
  ]
1307
1312
  }
@@ -1374,7 +1379,8 @@ export const SPEC_SITE_PATTERNS = {
1374
1379
  "level": "h4",
1375
1380
  "slot": "pagesLabel",
1376
1381
  "max": 40,
1377
- "text": "Pages"
1382
+ "text": "Pages",
1383
+ "textHe": "עמודים"
1378
1384
  },
1379
1385
  {
1380
1386
  "t": "Link",
@@ -1400,7 +1406,8 @@ export const SPEC_SITE_PATTERNS = {
1400
1406
  "level": "h4",
1401
1407
  "slot": "contactLabel",
1402
1408
  "max": 40,
1403
- "text": "Contact"
1409
+ "text": "Contact",
1410
+ "textHe": "יצירת קשר"
1404
1411
  },
1405
1412
  {
1406
1413
  "t": "Text",
@@ -1509,7 +1516,8 @@ export const SPEC_SITE_PATTERNS = {
1509
1516
  "level": "h4",
1510
1517
  "slot": "pagesLabel",
1511
1518
  "max": 40,
1512
- "text": "Pages"
1519
+ "text": "Pages",
1520
+ "textHe": "עמודים"
1513
1521
  },
1514
1522
  {
1515
1523
  "t": "Link",
@@ -1535,7 +1543,8 @@ export const SPEC_SITE_PATTERNS = {
1535
1543
  "level": "h4",
1536
1544
  "slot": "visitLabel",
1537
1545
  "max": 40,
1538
- "text": "Visit"
1546
+ "text": "Visit",
1547
+ "textHe": "ביקור"
1539
1548
  },
1540
1549
  {
1541
1550
  "t": "Text",
@@ -1564,7 +1573,8 @@ export const SPEC_SITE_PATTERNS = {
1564
1573
  "level": "h4",
1565
1574
  "slot": "contactLabel",
1566
1575
  "max": 40,
1567
- "text": "Contact"
1576
+ "text": "Contact",
1577
+ "textHe": "יצירת קשר"
1568
1578
  },
1569
1579
  {
1570
1580
  "t": "Text",
@@ -1745,7 +1755,8 @@ export const SPEC_SITE_PATTERNS = {
1745
1755
  "href": "/contact",
1746
1756
  "slot": "secondary",
1747
1757
  "max": 24,
1748
- "text": "Get in touch"
1758
+ "text": "Get in touch",
1759
+ "textHe": "צרו קשר"
1749
1760
  }
1750
1761
  ]
1751
1762
  }
@@ -1835,7 +1846,8 @@ export const SPEC_SITE_PATTERNS = {
1835
1846
  "href": "/contact",
1836
1847
  "slot": "primary",
1837
1848
  "max": 24,
1838
- "text": "Get in touch"
1849
+ "text": "Get in touch",
1850
+ "textHe": "צרו קשר"
1839
1851
  },
1840
1852
  {
1841
1853
  "t": "ButtonBlock",
@@ -2769,7 +2781,8 @@ export const SPEC_SITE_PATTERNS = {
2769
2781
  "href": "/contact",
2770
2782
  "slot": "action",
2771
2783
  "max": 24,
2772
- "text": "Get in touch"
2784
+ "text": "Get in touch",
2785
+ "textHe": "צרו קשר"
2773
2786
  }
2774
2787
  ]
2775
2788
  }
@@ -3515,7 +3528,8 @@ export const SPEC_SITE_PATTERNS = {
3515
3528
  "slot": "title",
3516
3529
  "max": 44,
3517
3530
  "text": "Get in touch",
3518
- "enter": "heading"
3531
+ "enter": "heading",
3532
+ "textHe": "צרו קשר"
3519
3533
  },
3520
3534
  {
3521
3535
  "t": "Text",
@@ -4536,7 +4550,8 @@ export const SPEC_SITE_PATTERNS = {
4536
4550
  "href": "/contact",
4537
4551
  "slot": "cta",
4538
4552
  "max": 24,
4539
- "text": "Get in touch"
4553
+ "text": "Get in touch",
4554
+ "textHe": "צרו קשר"
4540
4555
  }
4541
4556
  ]
4542
4557
  }
@@ -5,6 +5,8 @@
5
5
  * its INTENT (what kind of picture its section wants), its aspect ratio and the plan's words around it.
6
6
  */
7
7
 
8
+ import { FUNCTION_WORDS } from './function-words';
9
+
8
10
  export enum StockOrientation {
9
11
  Horizontal = 'horizontal',
10
12
  Vertical = 'vertical',
@@ -95,9 +97,8 @@ export const STOCK_SUBJECT_WORDS: Readonly<Record<StockSubject, ReadonlyArray<st
95
97
 
96
98
  /** Words that say nothing about what a picture shows (the plan's sample and placeholder words among them). */
97
99
  const STOP_WORDS: ReadonlySet<string> = new Set([
98
- 'the', 'and', 'with', 'for', 'your', 'our', 'you', 'from', 'into', 'this', 'that', 'here', 'there', 'about', 'page', 'section',
99
- 'sample', 'replace', 'image', 'photo', 'picture', 'sentence', 'words', 'own', 'how', 'what', 'who', 'are', 'all', 'one', 'two',
100
- 'three', 'more', 'less', 'very', 'tell', 'story', 'item', 'service', 'project',
100
+ ...FUNCTION_WORDS, 'page', 'section', 'sample', 'replace', 'image', 'photo', 'picture', 'sentence', 'words', 'two', 'three',
101
+ 'tell', 'story', 'item', 'service', 'project',
101
102
  ]);
102
103
  const MIN_WORD = 3;
103
104
  const HTML_TAG = /<[^>]*>/g;