@vectoriox/iox-ui 5.199.0 → 5.201.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 (51) hide show
  1. package/design-core/index.d.ts +454 -52
  2. package/fesm2022/vectoriox-iox-ui-design-core.mjs +640 -55
  3. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  4. package/fesm2022/vectoriox-iox-ui-forms-core.mjs +5 -2
  5. package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1062 -177
  7. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +441 -63
  9. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui.mjs +5 -2
  11. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  12. package/generation-core/index.d.ts +473 -124
  13. package/harness-core/index.d.ts +282 -6
  14. package/package.json +1 -1
  15. package/src/design-core/brand-neutrals.ts +125 -3
  16. package/src/design-core/colour-words.ts +48 -0
  17. package/src/design-core/design-settings.ts +24 -5
  18. package/src/design-core/design-token.model.ts +8 -0
  19. package/src/design-core/flavor-fixtures.generated.ts +272 -2
  20. package/src/design-core/flavor-spec.generated.ts +310 -40
  21. package/src/design-core/flavor-tokens.ts +5 -1
  22. package/src/design-core/public-api.ts +2 -0
  23. package/src/design-core/signature-move.ts +107 -0
  24. package/src/design-core/style-presets.ts +9 -3
  25. package/src/design-core/token-css.ts +59 -1
  26. package/src/forms-core/form-presets.ts +5 -2
  27. package/src/generation-core/body-mix.ts +41 -0
  28. package/src/generation-core/check-layout.ts +17 -7
  29. package/src/generation-core/colour-mix.ts +53 -3
  30. package/src/generation-core/compose-site.ts +136 -32
  31. package/src/generation-core/composition.ts +320 -0
  32. package/src/generation-core/footer-mix.ts +43 -3
  33. package/src/generation-core/footer-sign-up.ts +51 -0
  34. package/src/generation-core/header-edit.ts +15 -0
  35. package/src/generation-core/header-mix.ts +128 -19
  36. package/src/generation-core/opening-edit.ts +17 -3
  37. package/src/generation-core/opening-mix.ts +69 -5
  38. package/src/generation-core/plan-wire.ts +22 -5
  39. package/src/generation-core/public-api.ts +2 -0
  40. package/src/generation-core/site-build-run.ts +3 -0
  41. package/src/generation-core/site-plan.model.ts +3 -0
  42. package/src/generation-core/site-spec.generated.ts +250 -104
  43. package/src/generation-core/type-led.ts +4 -2
  44. package/src/generation-core/validate-site-plan.ts +2 -1
  45. package/src/harness-core/business-types.ts +27 -0
  46. package/src/harness-core/harness-spec.generated.ts +405 -56
  47. package/src/harness-core/motion.ts +19 -2
  48. package/src/harness-core/run-compose-context.ts +9 -3
  49. package/src/harness-core/starting-design.ts +15 -7
  50. package/styles/iox-design.css +10 -0
  51. package/styles/iox-forms.css +53 -0
@@ -0,0 +1,107 @@
1
+ import { ANIMATE_IDS, AnimateId, DesignChoices } from './design-token.model';
2
+ import { presetMotionLanguage, QUIET_LEVELS } from './motion-language';
3
+ import { PRELOADER_LEVELS, PreloaderKind } from './preloader';
4
+ import { SCRUB_LEVELS, ScrubId, scrubOfChoices } from './scrub';
5
+ import { stylePresetOfChoices } from './style-presets';
6
+
7
+ /**
8
+ * THE SIGNATURE MOVE (motion-reach-plan.md MR-D1…MR-D4; the 2026-11-28 reference baseline's gap #2) — pure,
9
+ * framework-free. Every reference a generated site is scored against has a signature move; the J10 sites had none,
10
+ * because the look's preloader and By the scroll were kept only on a Lively start and nearly every generated start is
11
+ * Still, Subtle or Standard. This completes a GENERATED look with ONE move its kind of business signs with (harness
12
+ * `SIGNATURE_MOVES`, carried on each business type as `signature`), so the wizard's start (harness-core `presetDesign`)
13
+ * and every compose of a plan (generation-core `composeSite`) wear the same — a rebuild from a kept plan included, with no
14
+ * model call. Only BUILT parts: the look's first-visit preloader (`design.preloader`) and By the scroll
15
+ * (`design.scrub`); their runtimes are the ones every look already plays (reduced motion: no preloader, a scrub keeps only
16
+ * its opacity — AW-D6). Binds generated output only (D12): Design ▸ Motion turns either off.
17
+ */
18
+
19
+ /** The closed vocabulary (contract `SIGNATURE_MOVES.moves`; build-spec holds the two equal). */
20
+ export enum SignatureMove {
21
+ /** The first visit opens on the look's mark — the preset's own kind, else `mark` (`design.preloader`). */
22
+ Preloader = 'preloader',
23
+ /** The look's entrances follow the scroll (`design.scrub` = `entrances`); the opening plays on time (AW10-D8). */
24
+ Scroll = 'scroll',
25
+ }
26
+
27
+ export const SIGNATURE_MOVES: ReadonlyArray<SignatureMove> = Object.values(SignatureMove);
28
+
29
+ /** What the kind of business says about its signature — every field the caller's (harness-core reads its type). */
30
+ export interface SignatureInput {
31
+ /** The moves it signs with, best first (`BusinessType.signature.moves`). Empty or absent: the look is left as it is. */
32
+ readonly moves?: ReadonlyArray<string> | null;
33
+ /** The level a Still start is lifted to (`BusinessType.signature.floor`, MR-D4) — a still page has nothing to sign with. */
34
+ readonly floor?: string | null;
35
+ /** Its How animated ceiling (`BusinessType.ceiling`): the floor never lifts past it. */
36
+ readonly ceiling?: string | null;
37
+ /** The preloader kinds its art direction refuses (`BusinessType.art.preloader`, ART_NEVER). */
38
+ readonly preloaderNever?: ReadonlyArray<string> | null;
39
+ /** The owner asked for little movement: nothing is added (PL-D6). */
40
+ readonly littleMovement?: boolean;
41
+ }
42
+
43
+ export interface SignatureResult {
44
+ readonly design: DesignChoices;
45
+ /** The move the look signs with — one it already carried, or the one added. Null: none fits (or none asked). */
46
+ readonly move: SignatureMove | null;
47
+ /** The move was added here (false: the look already carried it, or nothing fits). */
48
+ readonly added: boolean;
49
+ /** A Still start was lifted to the floor (MR-D4). */
50
+ readonly lifted: boolean;
51
+ }
52
+
53
+ const rank = (level: string | null | undefined) => ANIMATE_IDS.indexOf(level as AnimateId);
54
+ const STILL: AnimateId = ANIMATE_IDS[0];
55
+
56
+ /** The preloader kind a look would sign with: its own (when its kind of business allows it), else `mark` — or null. */
57
+ export function signaturePreloaderOf(design: DesignChoices, never: ReadonlyArray<string> = []): string | null {
58
+ const own = design.preloader ?? presetMotionLanguage(stylePresetOfChoices(design)?.id ?? null)?.preloader;
59
+ if (own && own !== PreloaderKind.None && !never.includes(own)) return own;
60
+ return never.includes(PreloaderKind.Mark) ? null : PreloaderKind.Mark;
61
+ }
62
+
63
+ /**
64
+ * The signature move a look already carries: a preloader that plays at its level and its kind of business allows, or a
65
+ * By the scroll that moves something at its level (`words` lights only text reveals, which a quiet level never stamps —
66
+ * so on Subtle only `entrances` counts). Null: none. Pure.
67
+ */
68
+ export function signatureMoveOf(design: DesignChoices, preloaderNever: ReadonlyArray<string> = []): SignatureMove | null {
69
+ const level = String(design.animate ?? '');
70
+ if (design.preloader && design.preloader !== PreloaderKind.None && PRELOADER_LEVELS.includes(level) && !preloaderNever.includes(design.preloader)) {
71
+ return SignatureMove.Preloader;
72
+ }
73
+ const scrub = scrubOfChoices(design);
74
+ if (scrub !== ScrubId.Never && SCRUB_LEVELS.includes(level) && (scrub === ScrubId.Entrances || !QUIET_LEVELS.includes(level))) return SignatureMove.Scroll;
75
+ return null;
76
+ }
77
+
78
+ /**
79
+ * A generated look, signed (MR-D1): unchanged when its kind of business names no move or the owner asked for little
80
+ * movement; else a Still start is lifted to the floor (never past the ceiling), and — unless the look already carries a
81
+ * signature move — the first of the type's moves that plays at its level is added. A move the owner turned off (an
82
+ * explicit `none` / `never`) is never added (D12); with every one off, the look is left exactly as it is. Idempotent. Pure.
83
+ */
84
+ export function withSignatureMove(design: DesignChoices, input: SignatureInput | null | undefined): SignatureResult {
85
+ // D12: a move the owner turned off (`none` / `never`, stored explicitly) is never added back — and when every move the
86
+ // type signs with is off, nothing is lifted either.
87
+ const off = (m: SignatureMove) => (m === SignatureMove.Preloader ? design.preloader === PreloaderKind.None : design.scrub === ScrubId.Never);
88
+ const moves = (input?.moves ?? []).filter((m): m is SignatureMove => (SIGNATURE_MOVES as ReadonlyArray<string>).includes(m) && !off(m as SignatureMove));
89
+ const never = input?.preloaderNever ?? [];
90
+ if (!moves.length || input?.littleMovement) return { design, move: signatureMoveOf(design, never), added: false, lifted: false };
91
+ const floor = input?.floor && rank(input.floor) > 0 ? (input.floor as AnimateId) : null;
92
+ const liftable = floor && design.animate === STILL && (!input?.ceiling || rank(input.ceiling) >= rank(floor));
93
+ const lifted: DesignChoices = liftable ? { ...design, animate: floor } : design;
94
+ const carried = signatureMoveOf(lifted, never);
95
+ if (carried) return { design: lifted, move: carried, added: false, lifted: !!liftable };
96
+ const level = String(lifted.animate ?? '');
97
+ for (const move of moves) {
98
+ if (move === SignatureMove.Preloader && PRELOADER_LEVELS.includes(level)) {
99
+ const kind = signaturePreloaderOf(lifted, never);
100
+ if (kind) return { design: { ...lifted, preloader: kind }, move, added: true, lifted: !!liftable };
101
+ }
102
+ if (move === SignatureMove.Scroll && SCRUB_LEVELS.includes(level)) {
103
+ return { design: { ...lifted, scrub: ScrubId.Entrances }, move, added: true, lifted: !!liftable };
104
+ }
105
+ }
106
+ return { design: lifted, move: null, added: false, lifted: !!liftable };
107
+ }
@@ -1,6 +1,8 @@
1
1
  import { SPEC_MOODS, SPEC_STYLE_PRESETS } from './flavor-spec.generated';
2
2
  import { resolveDesignChoices } from './design-settings';
3
3
  import { presetMotionLanguage } from './motion-language';
4
+ import { PreloaderKind } from './preloader';
5
+ import { ScrubId } from './scrub';
4
6
  import {
5
7
  DensityId, DesignChoices, DesignMode, DesignMotion, MotionId, ShapeId, TintId,
6
8
  } from './design-token.model';
@@ -63,6 +65,9 @@ export function presetModes(preset: StylePreset): DesignMode[] {
63
65
  * What picking a preset means — the complete `DesignChoices`, its motion included — in `mode` (default:
64
66
  * its first). A mode it was not audited in is REFUSED (null): a light-only preset is never worn dark.
65
67
  */
68
+ /** A style's own motion word, or nothing when it is the style's "none" — never stored as the owner's choice. */
69
+ const ownWord = (word: string | undefined, none: string): string | undefined => (word && word !== none ? word : undefined);
70
+
66
71
  export function presetChoices(id: string, mode?: DesignMode): DesignChoices | null {
67
72
  const preset = stylePresetById(id);
68
73
  if (!preset) return null;
@@ -74,9 +79,10 @@ export function presetChoices(id: string, mode?: DesignMode): DesignChoices | nu
74
79
  // AW3: the look's own motion language — its Feel and how its headings arrive (MB-D5); AW5: its first-visit
75
80
  // preloader (PL-D1 — the exit is the preset's, never stored).
76
81
  feel: presetMotionLanguage(preset.id)?.arrive, headings: presetMotionLanguage(preset.id)?.move,
77
- preloader: presetMotionLanguage(preset.id)?.preloader,
78
- // AW10: its By the scroll (never reads absent).
79
- scrub: presetMotionLanguage(preset.id)?.scrub,
82
+ // A style without one stores nothing (absent, not `none`): only the OWNER's none is a choice (motion reach, D12).
83
+ preloader: ownWord(presetMotionLanguage(preset.id)?.preloader, PreloaderKind.None),
84
+ // AW10: its By the scroll (a style's never stores nothing, as its preloader's none).
85
+ scrub: ownWord(presetMotionLanguage(preset.id)?.scrub, ScrubId.Never),
80
86
  });
81
87
  }
82
88
 
@@ -15,9 +15,11 @@ import { specTokenNames } from './token-names';
15
15
  * 2. schemes `.iox-scheme-<id> { overrides; every var()-referencing token re-declared }`, then the
16
16
  * ONE scheme-ink rule `.iox-scheme-subtle, … { color: var(--iox-text) }` (iox-ui#15)
17
17
  * columns `[data-iox-column="<word>"] { --iox-content-width: <literal>; --iox-content-cap: <length>; every token reading it }` (award §0c)
18
+ * phone step `@media (max-width: 767px) { <root> { --iox-space-section: <phone>; its readers } }` (CO5; the builder's
19
+ * canvas: `@container iox-canvas (…) { <scope> > * { … } }`)
18
20
  * caseless script `<root>:is([lang|="he" i], …), <root> :is(…) { case + tracking tokens stand down }` (iox-ui#124)
19
21
  * 3. reduced motion `@media (prefers-reduced-motion: reduce)`
20
- * 4. reduced transparency `@media (prefers-reduced-transparency: reduce)`
22
+ * 4. reduced transparency `@media (prefers-reduced-transparency: reduce)`, then more contrast `(prefers-contrast: more)`
21
23
  * 5. dark — LAST `@media (prefers-color-scheme: dark)`
22
24
  *
23
25
  * MODE (design-system D6) is a compile choice, never a row change: `auto` is the visitor-following
@@ -53,6 +55,12 @@ export interface TokenCssOptions {
53
55
  * computes exactly what the live site computes for that row — unset.
54
56
  */
55
57
  isolate?: boolean;
58
+ /**
59
+ * CO5: the canvas's named container (the builder's `iox-canvas`). The section space's phone step is then a container
60
+ * query on the scope's children — the scope element IS the container, which cannot query itself — instead of the
61
+ * live site's `@media`. Absent: `@media`.
62
+ */
63
+ phoneContainer?: string;
56
64
  }
57
65
 
58
66
  export interface TokenCssBlocks {
@@ -68,6 +76,10 @@ export const REDUCED_MOTION_OVERRIDES: Readonly<Record<string, string>> = SPEC_A
68
76
  /** What `prefers-reduced-transparency: reduce` makes solid — the contract's `a11y.reducedTransparency`. */
69
77
  export const REDUCED_TRANSPARENCY_OVERRIDES: Readonly<Record<string, string>> = SPEC_A11Y.reducedTransparency;
70
78
 
79
+ /** What `prefers-contrast: more` makes plain — the contract's `a11y.moreContrast` (colour v2 CV3: a painted page turns
80
+ * into its flat ground). */
81
+ export const MORE_CONTRAST_OVERRIDES: Readonly<Record<string, string>> = SPEC_A11Y.moreContrast;
82
+
71
83
  /**
72
84
  * What a page in a CASELESS script (Hebrew, Arabic, Japanese… — locale-direction `CASELESS_LANGUAGES`) does with the
73
85
  * look's case and tracking tokens (vectoriox/iox-ui#124): a pairing that sets buttons and labels `uppercase` with
@@ -99,6 +111,7 @@ const MEDIA_DARK = '(prefers-color-scheme: dark)';
99
111
  const ACCESSIBILITY_MEDIA: ReadonlyArray<{ query: string; overrides: Readonly<Record<string, string>> }> = [
100
112
  { query: '(prefers-reduced-motion: reduce)', overrides: REDUCED_MOTION_OVERRIDES },
101
113
  { query: '(prefers-reduced-transparency: reduce)', overrides: REDUCED_TRANSPARENCY_OVERRIDES },
114
+ { query: '(prefers-contrast: more)', overrides: MORE_CONTRAST_OVERRIDES },
102
115
  ];
103
116
 
104
117
  const usable = (t: DesignTokenLike | null | undefined): t is DesignTokenLike =>
@@ -132,6 +145,49 @@ const nonDefaultSchemes = (): ReadonlyArray<[string, Readonly<Record<string, str
132
145
  .filter(([id]) => id !== DEFAULT_SCHEME)
133
146
  .map(([id, scheme]) => [id, scheme.set as Readonly<Record<string, string>>]);
134
147
 
148
+ /** CO5 (composition-plan.md, contract `axes.sectionPhone`): how the section space steps down on a phone. */
149
+ interface SectionPhoneRule { maxWidth: number; toward: number; share: number }
150
+ const SECTION_PHONE = (SPEC_AXES as unknown as { sectionPhone: SectionPhoneRule }).sectionPhone;
151
+ const SECTION_SPACE = 'space-section';
152
+ const PX_VALUE = /^(\d+(?:\.\d+)?)px$/;
153
+ const GRID = 8;
154
+
155
+ /**
156
+ * The section space on a phone (≤ 767px): a figure above the references' phone median (`toward`, 64px) moves `share`
157
+ * of the way to it, floored to the 8px grid — 112px → 88px, 72px → 64px; at or below it (48px), or a value that is not a
158
+ * px figure (an owner's `var()` / `calc()`), there is no step (null). Pure.
159
+ */
160
+ export function sectionSpaceOnPhone(value: string): string | null {
161
+ const m = PX_VALUE.exec(value.trim());
162
+ if (!m || !SECTION_PHONE) return null;
163
+ const px = Number(m[1]);
164
+ if (px <= SECTION_PHONE.toward) return null;
165
+ const phone = Math.floor((px - (px - SECTION_PHONE.toward) * SECTION_PHONE.share) / GRID) * GRID;
166
+ return phone < px ? `${phone}px` : null;
167
+ }
168
+
169
+ /**
170
+ * CO5: the phone step block — `space-section` at its phone figure and every row that reads it (directly or through
171
+ * another reader, re-declared verbatim so each computes where it is declared, the scheme rule's lesson). The live site
172
+ * wraps it in `@media (max-width: 767px)` on the scope; the builder (`phoneContainer`) in its canvas's container query on
173
+ * the scope's children. Empty when there is no step.
174
+ */
175
+ function sectionPhoneCss(rows: ReadonlyArray<DesignTokenLike>, opts: TokenCssOptions): string {
176
+ const space = rows.find(t => t.name === SECTION_SPACE);
177
+ const phone = space ? sectionSpaceOnPhone(space.value) : null;
178
+ if (!phone) return '';
179
+ const reading = new Set([SECTION_SPACE]);
180
+ for (let grew = true; grew;) {
181
+ grew = false;
182
+ for (const t of rows) if (!reading.has(t.name) && [...reading].some(n => t.value.includes(`var(--iox-${n})`))) { reading.add(t.name); grew = true; }
183
+ }
184
+ const entries: Array<[string, string]> = [[SECTION_SPACE, phone], ...rows.filter(t => t.name !== SECTION_SPACE && reading.has(t.name)).map((t): [string, string] => [t.name, t.value])];
185
+ const width = `(max-width: ${SECTION_PHONE.maxWidth}px)`;
186
+ const root = opts.scope ?? ROOT;
187
+ if (opts.phoneContainer) return `@container ${opts.phoneContainer} ${width} {\n${rule(`${root} > *`, entries, ' ')}\n}`;
188
+ return media(width, [rule(root, entries, ' ')]);
189
+ }
190
+
135
191
  /** `{ 'iox-brand': '#2f6f62', … }` — the builder registry's input shape for base values. */
136
192
  export function tokensToVarMap(tokens: ReadonlyArray<DesignTokenLike> | null | undefined): Record<string, string> {
137
193
  const map: Record<string, string> = {};
@@ -440,6 +496,8 @@ export function compileTokenCssBlocks(
440
496
  rule(root, [...unset, ...rows.map((t): [string, string] => [t.name, t.value])]),
441
497
  compileSchemeCss(rows, opts.scope, opposite),
442
498
  columns.base,
499
+ // CO5: the section space's phone step (after the base and the columns, so its re-declared readers win on a phone).
500
+ sectionPhoneCss(rows, opts),
443
501
  rule(caselessSelector(root), presentOverrides(rows, CASELESS_SCRIPT_OVERRIDES, false)),
444
502
  ...ACCESSIBILITY_MEDIA.map(({ query, overrides }) =>
445
503
  media(query, [rule(root, presentOverrides(rows, overrides, false), ' ')])),
@@ -96,10 +96,13 @@ export const FORM_PRESETS: readonly FormPresetDef[] = /* @__PURE__ */ Object.fre
96
96
  description: 'One email field plus consent. Stored.',
97
97
  formName: 'Newsletter signup',
98
98
  fields: [
99
- { label: 'Email', control: 'email', required: true, placeholder: 'you@company.com' },
100
99
  // Consent is a checkbox that must be TICKED — `required` on a checkbox becomes the
101
100
  // `accepted` rule, with its own message, rather than a generic "this is required".
101
+ // It comes FIRST: the email box and Subscribe are the sign-up row the shared CSS lays side by side
102
+ // (iox-forms.css "The sign-up row"), and the keyboard must meet the parts in the order the eye does
103
+ // (WCAG 2.4.3) — the tick above the row, never a CSS `order` that moves it under the button.
102
104
  { label: 'Email me occasional updates', control: 'checkbox', required: true },
105
+ { label: 'Email', control: 'email', required: true, placeholder: 'you@company.com' },
103
106
  ],
104
107
  submitLabel: 'Subscribe',
105
108
  successText: 'You’re on the list.',
@@ -190,7 +193,7 @@ export const FORM_PRESET_WORDS_HE: Readonly<Record<`${FormPresetId}`, FormPreset
190
193
  },
191
194
  newsletter: {
192
195
  formName: 'הרשמה לניוזלטר',
193
- fields: [{ label: 'אימייל', placeholder: 'you@company.com' }, { label: 'שלחו לי עדכונים מדי פעם' }],
196
+ fields: [{ label: 'שלחו לי עדכונים מדי פעם' }, { label: 'אימייל', placeholder: 'you@company.com' }],
194
197
  submitLabel: 'הרשמה',
195
198
  successText: 'נרשמתם לרשימה.',
196
199
  errorText: 'לא הצלחנו לרשום אתכם. נסו שוב.',
@@ -4,6 +4,7 @@ import { LayoutIssue, LayoutIssueCode, LayoutLayer, LayoutLayerKind, LayoutSecti
4
4
  import { SPEC_SITE_LAYOUT } from './site-spec.generated';
5
5
  import { colorSchemeOf, planSectionShape, SECTION_EDGE_TYPES, sectionShapeOf, sectionEdgeClass, SectionShape, setSectionEdge, setSectionShape } from '@vectoriox/iox-ui/design-core';
6
6
  import { patternById } from './patterns';
7
+ import { NODE_BASELINES } from './node-baselines.generated';
7
8
  import { SerializedNode, walkSerialized } from './serialized-node';
8
9
 
9
10
  /**
@@ -351,6 +352,46 @@ export function joinPageHeader(layout: ReadonlyArray<SerializedNode>): Serialize
351
352
  return out ?? (layout as SerializedNode[]);
352
353
  }
353
354
 
355
+ /** The style props a section's own block space may be written in — a section carrying any other (a step's `paddingBlock`,
356
+ * a held screen's height) keeps its space as it is. */
357
+ const HELD_SPACE_PROPS: ReadonlyArray<string> = ['paddingBlock', 'paddingTop', 'paddingBottom', 'paddingBlockEnd', 'minHeight', 'height'];
358
+ const UNHELD_VALUES: ReadonlySet<string> = new Set(['', 'auto', '0px', '0']);
359
+
360
+ /** True for a section root stamped from a pattern (never one the model laid, never a free section). */
361
+ function isPatternSection(node: SerializedNode): boolean {
362
+ return !!(node.composed && 'pattern' in node.composed && node.composed.pattern);
363
+ }
364
+
365
+ /**
366
+ * Composition CO4 (composition-plan.md, contract `COMPOSITION.air.join: 'same-ground'`): two neighbouring PATTERN sections
367
+ * on one ground are ONE section space apart — the upper gives its bottom space up (iox-ui#130's page-header rule, for
368
+ * every pair of pattern sections; a free or model-laid neighbour keeps the space it was written with). Before, each padded its rhythm on both sides, so two sections on one ground stood two section spaces apart
369
+ * (288px on an airy look) — the J10 reading's "mostly empty bands". A ground change pads itself on both sides (the band
370
+ * reads as a band); nothing joins across a card, a Scene, a seam, a held screen or a section carrying a spacing step of
371
+ * its own. Pure: copies only what it changes.
372
+ */
373
+ export function joinSameGround(layout: ReadonlyArray<SerializedNode>): SerializedNode[] {
374
+ let out: SerializedNode[] | null = null;
375
+ for (let i = 0; i + 1 < layout.length; i++) {
376
+ const upper = layout[i];
377
+ const next = layout[i + 1];
378
+ // Both stamped from patterns: a free or model-laid section below pads itself as it was written (its top may be 0).
379
+ if (!isPatternSection(upper) || !isPatternSection(next) || !SECTION_EDGE_TYPES.includes(upper.type) || !SECTION_EDGE_TYPES.includes(next.type)) continue;
380
+ if ((colorSchemeOf(upper) ?? 'default') !== (colorSchemeOf(next) ?? 'default')) continue;
381
+ if (sectionShapeOf(upper) === SectionShape.Card || sectionShapeOf(next) === SectionShape.Card || holdsScene(upper) || holdsScene(next)) continue;
382
+ if (sectionEdgeClass(next.props?.['seam'])) continue;
383
+ // A value the type's baseline stamps (`height: auto`, `minHeight: 200px`) or an `auto` / `0px` is no hold of its own.
384
+ const baseline = (NODE_BASELINES[upper.type]?.styleProps ?? {}) as Record<string, unknown>;
385
+ if (HELD_SPACE_PROPS.some(p => { const v = upper.styleProps?.[p]; return v !== undefined && !UNHELD_VALUES.has(String(v)) && v !== baseline[p]; })) continue;
386
+ const own = upper.styleProps?.['padding'];
387
+ const parts = typeof own === 'string' && own.trim() && own.trim() !== SECTION_PAD ? shorthandParts(own) : [...SECTION_PAD_SIDES];
388
+ const [top, right = top, , left = right] = parts;
389
+ out ??= layout.map(n => n);
390
+ out[i] = { ...upper, styleProps: { ...(upper.styleProps ?? {}), padding: `${top} ${right} ${NO_SPACE} ${left}` } };
391
+ }
392
+ return out ?? (layout as SerializedNode[]);
393
+ }
394
+
354
395
  // ── The check: a mix judged against the site, mended where the site cannot carry it, each mend said ──────────────────
355
396
 
356
397
  export enum BodyRepairCode {
@@ -21,7 +21,7 @@ import { SPEC_SITE_FACTS, SPEC_SITE_LAYOUT } from './site-spec.generated';
21
21
  import { checkList, LayoutListNever, pageListIssues } from './check-list';
22
22
  import { LIST_WORDS_BESIDE_RULE, LayoutListSide, layoutListBare, layoutListPair } from './list-space';
23
23
  import { GroundTone, groundToneOf, paceIssues } from './body-mix';
24
- import { colourRhythmIssues } from './colour-mix';
24
+ import { colourAccentMax, colourGroundsMax, colourRhythmIssues } from './colour-mix';
25
25
  import {
26
26
  LAYOUT_CHECK_VIEWPORT, LAYOUT_DRIFT, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, layoutBoxPx, layoutDriftPhoto, layoutHeldStill, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutShapeHasPurpose,
27
27
  layoutStillLine, layoutTextFits, layoutVoidScreens, layoutVoids,
@@ -83,6 +83,10 @@ export interface CheckLayoutContext {
83
83
  * the COLOUR table): the page's grounds are judged against it (`colourRhythmIssues`). Absent or `free`: each
84
84
  * section's ground is its own. */
85
85
  rhythm?: string | null;
86
+ /** Colour v2 CV2 (CV-D7): the site's accent word (`colourMixOfPlan(plan).accent`). Present: its budget replaces the
87
+ * look's `accentMax` (`colourAccentMax`) and the page wears at most `colourGroundsMax` distinct colour grounds, photos
88
+ * excepted (R-H-CV3). Absent: the look's budget, grounds uncounted. */
89
+ accent?: string | null;
86
90
  /** AW6: the body's pace as DRAWN (`drawnBodyMix(bodyMixOfPlan(plan)).drawn.pace`): `loud-quiet` asks picture sections
87
91
  * followed by quiet ones (`paceIssues`). Absent or `free`: nothing asked. */
88
92
  pace?: string | null;
@@ -418,6 +422,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
418
422
  let eyebrows = 0;
419
423
  let splitRun = 0;
420
424
  let lightGrounds = 0;
425
+ const colourGrounds = new Set<string>();
421
426
  let bleeds = 0;
422
427
  let screenWords = 0;
423
428
  let wordsOnPhoto = 0;
@@ -460,6 +465,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
460
465
  }
461
466
  if (inList(V.colours, ground) && paint && lumOf(paint.colours[ground as LayoutColour]) > PHOTO_LIGHT_LUMINANCE) lightGrounds++;
462
467
  if (ground === LayoutColour.Accent) accentUses += ACCENT_GROUND_USES;
468
+ if (inList(V.colours, ground)) colourGrounds.add(ground);
463
469
  const layers = Array.isArray(s.layers) ? s.layers : [];
464
470
  if (!layers.length) add(LayoutIssueCode.Structure, `${at}.layers`, 'at least one layer');
465
471
  if (s.pin) pinned++;
@@ -855,13 +861,17 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
855
861
  const entering = sectionsWithEnters + readyMadeEntering;
856
862
  if (entering > enteringMax) add(LayoutIssueCode.Motion, 'sections', `${entering} sections have entrances — at most ${enteringMax}; let the others glide`);
857
863
  if (eyebrows > composedCount * EYEBROW_SHARE) add(LayoutIssueCode.Look, 'sections', `${eyebrows} headings carry a small label right above them — the AI-site cliché; keep it to a few`);
864
+ const accentBudget = ctx.accent ? { max: colourAccentMax(ctx.accent), by: `the "${ctx.accent}" accent` } : look ? { max: look.accentMax, by: `the ${look.id} look` } : null;
865
+ if (accentBudget && accentUses > accentBudget.max) {
866
+ const bands = paint ? accentBandMoves(sections, ground => paint.colours[ground], (name, text) => colourHex(name, text)) : [];
867
+ const buttons = accentButtonSteps(sections);
868
+ add(LayoutIssueCode.Look, 'sections', `the accent is on ${accentUses} layers (a button counts, an accent ground twice) — ${accentBudget.by} allows ${accentBudget.max}`,
869
+ { kind: LayoutMendKind.Accent, over: accentUses - accentBudget.max, ...(bands.length ? { bands } : {}), ...(buttons.length ? { buttons } : {}) });
870
+ }
871
+ if (ctx.accent && colourGrounds.size > colourGroundsMax(ctx.accent)) {
872
+ add(LayoutIssueCode.Look, 'sections', `${colourGrounds.size} different grounds (${[...colourGrounds].join(', ')}) — the "${ctx.accent}" accent allows ${colourGroundsMax(ctx.accent)}, photos excepted`);
873
+ }
858
874
  if (look) {
859
- if (accentUses > look.accentMax) {
860
- const bands = paint ? accentBandMoves(sections, ground => paint.colours[ground], (name, text) => colourHex(name, text)) : [];
861
- const buttons = accentButtonSteps(sections);
862
- add(LayoutIssueCode.Look, 'sections', `the accent is on ${accentUses} layers (a button counts, an accent ground twice) — the ${look.id} look allows ${look.accentMax}`,
863
- { kind: LayoutMendKind.Accent, over: accentUses - look.accentMax, ...(bands.length ? { bands } : {}), ...(buttons.length ? { buttons } : {}) });
864
- }
865
875
  if (limits.hugeMax !== undefined && huge > limits.hugeMax) add(LayoutIssueCode.Look, 'sections', `${huge} xxl/screen layers — the ${look.id} look allows ${limits.hugeMax}`);
866
876
  if (limits.centerMax !== undefined && textLayers && centered / textLayers > limits.centerMax) {
867
877
  add(LayoutIssueCode.Look, 'sections', `${centered} of ${textLayers} text layers are centred — the ${look.id} look allows ${Math.round(limits.centerMax * 100)}%`);
@@ -1,6 +1,9 @@
1
- import { GroundTone, sectionPictured } from './body-mix';
1
+ import { BodyMix, bodyMix, BodySectionWord, GroundTone, sectionPictured } from './body-mix';
2
2
  import { LayoutIssue, LayoutIssueCode, LayoutSection, LayoutSectionKind } from './layout-language';
3
- import { GenerationTier } from './site-plan.model';
3
+ import { ColourWordKey, DesignChoices, resolveColourWords, resolveDesignChoices } from '@vectoriox/iox-ui/design-core';
4
+
5
+ import { layoutPresetOf } from './layout-look';
6
+ import { GenerationTier, SitePlan } from './site-plan.model';
4
7
  import { SPEC_SITE_LAYOUT } from './site-spec.generated';
5
8
 
6
9
  /**
@@ -133,6 +136,32 @@ export function presetColourMix(presetId: string | null | undefined): ColourMix
133
136
  return colourMix(C.presets[presetId ?? ''] ?? {});
134
137
  }
135
138
 
139
+ /** CV2: the colour mix a plan wears — its style preset's §6 row (CV-D13) with the plan's own words (`mixes.colour`) over
140
+ * it: an ingredient the plan leaves out is the preset's. A plan whose words do not read wears its preset's row (the
141
+ * validator names the word). Pure. */
142
+ export function colourMixOfPlan(plan: Pick<SitePlan, 'mixes' | 'design'>): ColourMix {
143
+ const presetId = layoutPresetOf(resolveDesignChoices(JSON.parse(JSON.stringify(plan.design ?? {})))).id;
144
+ const row = C.presets[presetId] ?? {};
145
+ try {
146
+ return colourMix({ ...row, ...colourWordsPartial(plan.mixes?.colour ?? []) });
147
+ } catch {
148
+ return colourMix(row); // the validator names the word
149
+ }
150
+ }
151
+
152
+ /** CV2 + CV3: the colour words a look carries as TOKENS (ground · dark · button · wash), as drawn — the rest are judged,
153
+ * never painted. */
154
+ export function colourDesignWords(mix: ColourMix): Pick<DesignChoices, ColourWordKey> {
155
+ const { drawn } = drawnColourMix(mix);
156
+ return resolveColourWords({ ground: drawn.ground, dark: drawn.dark, action: drawn.action, wash: drawn.wash });
157
+ }
158
+
159
+ /** CV2: the ONE design a plan is built and composed with — its design and its colour words (the build's Look step writes
160
+ * these; every compose of the plan judges against them). Pure. */
161
+ export function planDesignChoices(plan: Pick<SitePlan, 'mixes' | 'design'>): DesignChoices {
162
+ return resolveDesignChoices({ ...JSON.parse(JSON.stringify(plan.design ?? {})), ...colourDesignWords(colourMixOfPlan(plan)) });
163
+ }
164
+
136
165
  /** A mix on the wire: one `<ingredient>:<word>` per ingredient, in the table's order. */
137
166
  export function colourMixWords(mix: ColourMix): string[] {
138
167
  return ORDER.map(k => `${k}:${mix[k]}`);
@@ -140,6 +169,11 @@ export function colourMixWords(mix: ColourMix): string[] {
140
169
 
141
170
  /** The words back into a mix. Refuses an unknown word and two words for one ingredient. */
142
171
  export function colourMixFromWords(words: ReadonlyArray<string>): ColourMix {
172
+ return colourMix(colourWordsPartial(words));
173
+ }
174
+
175
+ /** The ingredients the words name, and only those. Refuses an unknown word and two words for one ingredient. */
176
+ function colourWordsPartial(words: ReadonlyArray<string>): Record<string, string> {
143
177
  const partial: Record<string, string> = {};
144
178
  for (const pair of words) {
145
179
  const [k, w] = String(pair).split(':');
@@ -147,7 +181,7 @@ export function colourMixFromWords(words: ReadonlyArray<string>): ColourMix {
147
181
  if (partial[k] !== undefined && partial[k] !== w) throw new ColourMixError(`a site has one colour ${k} ("${partial[k]}" and "${w}")`);
148
182
  partial[k] = w;
149
183
  }
150
- return colourMix(partial);
184
+ return partial;
151
185
  }
152
186
 
153
187
  export interface ColourGap {
@@ -170,6 +204,22 @@ export function drawnColourMix(mix: ColourMix): { drawn: ColourMix; gaps: Colour
170
204
  return { drawn: drawn as ColourMix, gaps };
171
205
  }
172
206
 
207
+ /** CV2: the colour words `checkLayout` judges, as DRAWN — spread into its context (`{ ...checkContext, ...colourCheckOf(plan) }`)
208
+ * so the accent word's budget, the grounds cap and the rhythm read the plan's own words (else its preset's row, CV-D13). */
209
+ export function colourCheckOf(plan: Pick<SitePlan, 'mixes' | 'design'>): { accent: string; rhythm: string } {
210
+ const { drawn } = drawnColourMix(colourMixOfPlan(plan));
211
+ return { accent: drawn.accent, rhythm: drawn.rhythm };
212
+ }
213
+
214
+ /** CV-D9: `bands.inset` reuses AW6's inset card — the body the site wears with the colour's bands folded in (`inset`
215
+ * adds `sections:inset-card`, so every section that wears a scheme stands as a rounded card on the page's ground). The
216
+ * same body back when the bands are `full` or the card is already asked. Pure. */
217
+ export function bodyWithColourBands(body: BodyMix | null, mix: ColourMix): BodyMix | null {
218
+ if (drawnColourMix(mix).drawn.bands !== ColourBands.Inset) return body;
219
+ if (body?.sections.includes(BodySectionWord.InsetCard)) return body;
220
+ return bodyMix({ ...(body ?? {}), sections: [...(body?.sections ?? []), BodySectionWord.InsetCard] });
221
+ }
222
+
173
223
  /** The fingerprint's prefix for a site's colour. */
174
224
  export const COLOUR_TOKEN = 'colour';
175
225