@vectoriox/iox-ui 5.88.0 → 5.90.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 (49) hide show
  1. package/design-core/index.d.ts +523 -2
  2. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +3 -2
  3. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  4. package/fesm2022/vectoriox-iox-ui-design-core.mjs +581 -1
  5. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +4692 -160
  7. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +12 -1
  9. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui-scene-core.mjs +46 -6
  11. package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
  12. package/fesm2022/vectoriox-iox-ui.mjs +6 -4
  13. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  14. package/generation-core/index.d.ts +1611 -10
  15. package/harness-core/index.d.ts +52 -3
  16. package/package.json +1 -1
  17. package/scene-core/index.d.ts +28 -2
  18. package/src/composite-core/slider.ts +3 -2
  19. package/src/design-core/flavor-spec.generated.ts +500 -0
  20. package/src/design-core/font-metrics.ts +105 -0
  21. package/src/design-core/public-api.ts +1 -0
  22. package/src/generation-core/ai-run.ts +11 -0
  23. package/src/generation-core/audit-site.ts +5 -0
  24. package/src/generation-core/check-layout.ts +940 -0
  25. package/src/generation-core/compose-layout.ts +907 -0
  26. package/src/generation-core/compose-site.ts +136 -5
  27. package/src/generation-core/layout-drift.ts +78 -0
  28. package/src/generation-core/layout-edits.ts +122 -0
  29. package/src/generation-core/layout-fingerprint.ts +203 -0
  30. package/src/generation-core/layout-language.ts +537 -0
  31. package/src/generation-core/layout-look.ts +57 -0
  32. package/src/generation-core/layout-photos.ts +19 -0
  33. package/src/generation-core/layout-render-check.ts +275 -0
  34. package/src/generation-core/layout-section-fallback.ts +156 -0
  35. package/src/generation-core/layout-type.ts +48 -0
  36. package/src/generation-core/layout-wire.ts +282 -0
  37. package/src/generation-core/nav-shape.ts +23 -1
  38. package/src/generation-core/photo-inventory.ts +250 -0
  39. package/src/generation-core/plan-edits.ts +25 -2
  40. package/src/generation-core/plan-wire.ts +19 -2
  41. package/src/generation-core/public-api.ts +13 -0
  42. package/src/generation-core/site-plan.model.ts +16 -0
  43. package/src/generation-core/site-spec.generated.ts +759 -2
  44. package/src/generation-core/validate-site-plan.ts +55 -1
  45. package/src/harness-core/generation-view.ts +52 -1
  46. package/src/scene-core/scroll-driver.ts +14 -2
  47. package/src/scene-core/scroll-range.ts +37 -4
  48. package/styles/iox-design.css +17 -0
  49. package/styles/iox-forms.css +4 -0
@@ -0,0 +1,537 @@
1
+ /**
2
+ * The LAYOUT LANGUAGE (premium components M8 — the prototype's CL2 / CL2.1, premium-sites plan "Breaking limits"): a page
3
+ * composed as layers of closed kinds placed on a 12-column grid, with closed sizes, the look's five colours, roles, time
4
+ * entrances, a parallax depth, held sections whose layers move by tracks, sideways sections, galleries, forms and a phone
5
+ * reading order. The model writes no CSS and no node tree; `composeLayout` stamps ordinary builder nodes from it.
6
+ *
7
+ * Gate 1 typed the shape the three proof sites were saved in (iox-ai-guidance `prototypes/breaking-limits/round4|round3`).
8
+ * Gate 2 moved the closed lists into the contract (`site.layout`, SPEC_SITE_LAYOUT): these enums are held equal to it by
9
+ * layout-language.spec, and a generated page carries one in `PagePlan.layout` (a `LayoutPage`).
10
+ */
11
+
12
+ export enum LayoutLayerKind {
13
+ Word = 'word',
14
+ Heading = 'heading',
15
+ Text = 'text',
16
+ Photo = 'photo',
17
+ Gallery = 'gallery',
18
+ Button = 'button',
19
+ List = 'list',
20
+ Number = 'number',
21
+ Shape = 'shape',
22
+ Label = 'label',
23
+ Form = 'form',
24
+ Marquee = 'marquee',
25
+ }
26
+
27
+ export enum LayoutSize {
28
+ Xs = 'xs',
29
+ S = 's',
30
+ M = 'm',
31
+ L = 'l',
32
+ Xl = 'xl',
33
+ Xxl = 'xxl',
34
+ /** As wide as its columns allow — a word, never a sentence. */
35
+ Screen = 'screen',
36
+ }
37
+
38
+ /** The look's five colours, by role. */
39
+ export enum LayoutColour {
40
+ Ground = 'ground',
41
+ Ink = 'ink',
42
+ Accent = 'accent',
43
+ Soft = 'soft',
44
+ Muted = 'muted',
45
+ }
46
+
47
+ export enum LayoutRole {
48
+ Lead = 'lead',
49
+ Support = 'support',
50
+ Decoration = 'decoration',
51
+ Static = 'static',
52
+ }
53
+
54
+ export enum LayoutEnter {
55
+ None = 'none',
56
+ Fade = 'fade',
57
+ FadeRise = 'fadeRise',
58
+ ScaleIn = 'scaleIn',
59
+ ClipReveal = 'clipReveal',
60
+ MaskRise = 'maskRise',
61
+ BlurIn = 'blurIn',
62
+ Pop = 'pop',
63
+ }
64
+
65
+ export enum LayoutDepth {
66
+ Back = 'back',
67
+ Mid = 'mid',
68
+ Front = 'front',
69
+ }
70
+
71
+ export enum LayoutTransition {
72
+ Cut = 'cut',
73
+ Flood = 'flood',
74
+ WipeUp = 'wipe-up',
75
+ WipeDown = 'wipe-down',
76
+ WipeStart = 'wipe-start',
77
+ WipeEnd = 'wipe-end',
78
+ }
79
+
80
+ export enum LayoutEase {
81
+ Out = 'out',
82
+ InOut = 'inOut',
83
+ Drawer = 'drawer',
84
+ Linear = 'linear',
85
+ }
86
+
87
+ export enum LayoutPace {
88
+ Slow = 'slow',
89
+ Normal = 'normal',
90
+ Quick = 'quick',
91
+ }
92
+
93
+ export enum LayoutSide {
94
+ Bottom = 'bottom',
95
+ Top = 'top',
96
+ Start = 'start',
97
+ End = 'end',
98
+ }
99
+
100
+ export enum LayoutTrackProp {
101
+ X = 'x',
102
+ Y = 'y',
103
+ Scale = 'scale',
104
+ Opacity = 'opacity',
105
+ Rotate = 'rotate',
106
+ Clip = 'clip',
107
+ Blur = 'blur',
108
+ }
109
+
110
+ export enum LayoutAlign {
111
+ Start = 'start',
112
+ Center = 'center',
113
+ End = 'end',
114
+ }
115
+
116
+ export enum LayoutBleed {
117
+ None = 'none',
118
+ Start = 'start',
119
+ End = 'end',
120
+ Both = 'both',
121
+ }
122
+
123
+ /** A pool photo's shape (the inventory measures each one): what it keeps where nothing else gives it a height. */
124
+ export enum LayoutPhotoShape {
125
+ Wide = 'wide',
126
+ Landscape = 'landscape',
127
+ Square = 'square',
128
+ Portrait = 'portrait',
129
+ Tall = 'tall',
130
+ }
131
+
132
+ export const LAYOUT_PHOTO_ASPECT: Readonly<Record<LayoutPhotoShape, string>> = {
133
+ [LayoutPhotoShape.Wide]: '16 / 9',
134
+ [LayoutPhotoShape.Landscape]: '3 / 2',
135
+ [LayoutPhotoShape.Square]: '1 / 1',
136
+ [LayoutPhotoShape.Portrait]: '2 / 3',
137
+ [LayoutPhotoShape.Tall]: '9 / 16',
138
+ };
139
+
140
+ export enum LayoutSectionKind {
141
+ Content = 'content',
142
+ Inhale = 'inhale',
143
+ }
144
+
145
+ export enum LayoutButtonVariant {
146
+ Primary = 'primary',
147
+ Secondary = 'secondary',
148
+ Ghost = 'ghost',
149
+ }
150
+
151
+ /** The product SliderContainer's own effects (iox-ui `slider-options.ts`). */
152
+ export enum LayoutGalleryEffect {
153
+ Slide = 'slide',
154
+ Fade = 'fade',
155
+ Cube = 'cube',
156
+ Flip = 'flip',
157
+ Coverflow = 'coverflow',
158
+ Cards = 'cards',
159
+ Creative = 'creative',
160
+ }
161
+
162
+ export enum LayoutNavKind {
163
+ Bar = 'bar',
164
+ Corner = 'corner',
165
+ Index = 'index',
166
+ Side = 'side',
167
+ }
168
+
169
+ export interface LayoutTrack {
170
+ prop: `${LayoutTrackProp}`;
171
+ from: number;
172
+ to: number;
173
+ /** The part of the section's scroll it plays over (0 = it arrives, 1 = it leaves; held: 0..1 is the hold). */
174
+ at: [number, number];
175
+ ease?: `${LayoutEase}`;
176
+ }
177
+
178
+ export interface LayoutGallery {
179
+ slides: Array<{ photo: { id: string }; caption?: string }>;
180
+ effect?: `${LayoutGalleryEffect}`;
181
+ perView?: number | 'auto';
182
+ centered?: boolean;
183
+ freeMode?: boolean;
184
+ loop?: boolean;
185
+ /** 0 or milliseconds. */
186
+ autoplay?: number;
187
+ /** Captions and pictures move at their own speed inside each slide (Swiper parallax). */
188
+ drift?: boolean;
189
+ /** Only in a held section: the page's scroll turns the slides. */
190
+ scroll?: boolean;
191
+ /** Gate 2: a list data source of the plan whose items the slides show (their image role) instead of fixed photos. */
192
+ source?: string;
193
+ }
194
+
195
+ export interface LayoutForm {
196
+ preset: 'lead' | 'contact' | 'booking' | 'newsletter';
197
+ title?: string;
198
+ intro?: string;
199
+ /** The chips a preset has (lead: needs, budget; booking: guests), in the business's language. */
200
+ options?: Partial<Record<'needs' | 'budget' | 'guests', string[]>>;
201
+ submit?: string;
202
+ successTitle?: string;
203
+ successText?: string;
204
+ channel?: { label: string; href?: string };
205
+ }
206
+
207
+ export interface LayoutLayer {
208
+ kind: `${LayoutLayerKind}`;
209
+ role?: `${LayoutRole}`;
210
+ text?: string;
211
+ items?: string[];
212
+ photo?: { id: string };
213
+ gallery?: LayoutGallery;
214
+ form?: LayoutForm;
215
+ variant?: `${LayoutButtonVariant}`;
216
+ /** Grid lines: 1..13, or 1..12×track+1 in a sideways section. */
217
+ col: [number, number];
218
+ row: [number, number];
219
+ size?: `${LayoutSize}`;
220
+ color?: `${LayoutColour}`;
221
+ align?: `${LayoutAlign}`;
222
+ z?: number;
223
+ bleed?: `${LayoutBleed}`;
224
+ rotate?: number;
225
+ fit?: 'cover' | 'contain';
226
+ /** A button's section id. */
227
+ to?: string;
228
+ scrim?: boolean;
229
+ enter?: `${LayoutEnter}`;
230
+ from?: `${LayoutSide}`;
231
+ beat?: number;
232
+ depth?: `${LayoutDepth}`;
233
+ inner?: number;
234
+ kinetic?: boolean;
235
+ motion?: LayoutTrack[];
236
+ }
237
+
238
+ export interface LayoutSection {
239
+ id: string;
240
+ kind?: `${LayoutSectionKind}`;
241
+ signature?: boolean;
242
+ screens: number;
243
+ pin?: boolean;
244
+ track?: number;
245
+ /** A colour name, or `photo:<id>`. */
246
+ ground?: string;
247
+ rows: number;
248
+ transition?: `${LayoutTransition}`;
249
+ layers: LayoutLayer[];
250
+ /** Every layer's index once, in a phone's reading order. */
251
+ phone?: number[];
252
+ /** Silent section fallback (Doron, 2026-11-09): this place is the plan's ready-made section `PagePlan.sections[at]`,
253
+ * stamped from its pattern in the look; it has no layers of its own. Set only by `fallBackBySection`, never by a model. */
254
+ readyMade?: LayoutReadyMade;
255
+ }
256
+
257
+ /** The plan section a place of a composed page was given to: its index in `PagePlan.sections` and its pattern. */
258
+ export interface LayoutReadyMade {
259
+ at: number;
260
+ pattern: string;
261
+ }
262
+
263
+ /** How far a composed page breaks the usual layout (M8-G2-D5: follows How animated and the type's ceiling). */
264
+ export enum LayoutDial {
265
+ Distinct = 'distinct',
266
+ Daring = 'daring',
267
+ }
268
+
269
+ /** One composed page of a Site Plan (`PagePlan.layout`): the sections, and how far they dare. */
270
+ export interface LayoutPage {
271
+ dial: `${LayoutDial}`;
272
+ sections: LayoutSection[];
273
+ }
274
+
275
+ /** Where a layout's photo comes from (M8-G2-D10): `own:<assetId>` · `stock:<libraryKey>` · `box:<shape>`. */
276
+ export enum LayoutPhotoSource {
277
+ Own = 'own',
278
+ Stock = 'stock',
279
+ Box = 'box',
280
+ }
281
+
282
+ /** A photo id read: its source and key (`box:portrait` → box, portrait). Null when it names no source. */
283
+ export function parseLayoutPhotoId(id: string): { source: LayoutPhotoSource; key: string } | null {
284
+ const m = /^(own|stock|box):(.+)$/.exec(String(id ?? '').trim());
285
+ if (!m) return null;
286
+ if (m[1] === LayoutPhotoSource.Box && !Object.values(LayoutPhotoShape).includes(m[2] as LayoutPhotoShape)) return null;
287
+ return { source: m[1] as LayoutPhotoSource, key: m[2] };
288
+ }
289
+
290
+ /** What can be wrong with a composed page, each refused with a path (`checkLayout`, `expandLayoutWire`). */
291
+ export enum LayoutIssueCode {
292
+ /** The answer cannot be read (not an object, no sections). */
293
+ Shape = 'shape',
294
+ /** A value outside its closed list or range. */
295
+ Value = 'value',
296
+ /** The page's structure (sections, leads, signature, phone order). */
297
+ Structure = 'structure',
298
+ /** The look's composition notes (space, type contrast, rotation, accent, what it avoids). */
299
+ Look = 'look',
300
+ /** How things move (Emil). */
301
+ Motion = 'motion',
302
+ /** Words that would not read: on a photo's busy part, too faint, too long for their box. */
303
+ Reading = 'reading',
304
+ /** A photo, a source, a fact or a form that is not the business's. */
305
+ Content = 'content',
306
+ /** What daring asks for and the page does not do. */
307
+ Daring = 'daring',
308
+ /** It repeats a page already made (the fingerprint). */
309
+ Sameness = 'sameness',
310
+ /** The rendered page (the render check): overlap, overflow, a first screen without its lead. */
311
+ Render = 'render',
312
+ }
313
+
314
+ /** What the composer may settle by itself, with no word or place changed (`mendLayout`). */
315
+ export enum LayoutMendKind {
316
+ /** Words over a busy or too-light part of a photo, in a look that allows scrims: the layer gets one. */
317
+ Scrim = 'scrim',
318
+ /** The accent on more layers than the look allows: the least important words go back to the ink, then — where words
319
+ * cannot give enough back — the least important accent bands take the ground nearest the accent their words read on. */
320
+ Accent = 'accent',
321
+ /** Words too faint on their ground, where the ink holds there: they go back to the ink. */
322
+ Ink = 'ink',
323
+ /** Decoration that enters with a move: it fades instead. */
324
+ Fade = 'fade',
325
+ /** Fewer layers glide than the look asks (iox-ui#63): the layers that may glide and do not get a depth, most important
326
+ * first — exactly as many as are missing. */
327
+ Depth = 'depth',
328
+ /** A gallery naming a list with no pictures (iox-ui#64): it shows a list that has them — the only one, else the one
329
+ * the section's words name, else the first in plan order. None, or the section's words name the list it named
330
+ * (iox-ui#66): left to the model. */
331
+ Source = 'source',
332
+ }
333
+
334
+ /** Which rule chose a mended gallery's list. */
335
+ export enum LayoutSourceChoice {
336
+ /** The plan has exactly one list with pictures. */
337
+ Only = 'only',
338
+ /** Several: the first whose name or type the section's own words name. */
339
+ Intent = 'intent',
340
+ /** Several, none named: the first in plan order. */
341
+ Order = 'order',
342
+ }
343
+
344
+ /** A list a composed gallery could name: its alias, the words it is known by (the alias, its type's name and label), and
345
+ * whether its items carry a picture. Plan order. */
346
+ export interface LayoutGalleryList {
347
+ alias: string;
348
+ words: ReadonlyArray<string>;
349
+ pictures: boolean;
350
+ }
351
+
352
+ /** An accent band the accent mend may move, and the ground it takes. */
353
+ export interface LayoutBandMove {
354
+ section: number;
355
+ ground: `${LayoutColour}`;
356
+ }
357
+
358
+ export type LayoutMend =
359
+ | { kind: LayoutMendKind.Scrim | LayoutMendKind.Ink | LayoutMendKind.Fade; layer: string }
360
+ | { kind: LayoutMendKind.Accent; over: number; bands?: ReadonlyArray<LayoutBandMove> }
361
+ | { kind: LayoutMendKind.Depth; layers: ReadonlyArray<string> }
362
+ | { kind: LayoutMendKind.Source; layer: string; source: string; by: `${LayoutSourceChoice}` };
363
+
364
+ export interface LayoutIssue {
365
+ code: `${LayoutIssueCode}`;
366
+ /** `sections[2].layers[1].box`, or `sections` for the page. */
367
+ path: string;
368
+ message: string;
369
+ /** Set when the composer can settle it alone (`mendLayout`); the model is asked only for what is left. */
370
+ mend?: LayoutMend;
371
+ }
372
+
373
+ export interface LayoutSite {
374
+ name: string;
375
+ idea?: string;
376
+ locale?: string;
377
+ dial?: 'distinct' | 'daring';
378
+ /** CL2.1: `{ preset, seed? }`. A CL2 site carries a round-three `recipe` and colours (the runner maps it to a preset). */
379
+ look?: { preset?: string; seed?: string; recipe?: string; accent?: string };
380
+ motion?: { ease?: `${LayoutEase}`; pace?: `${LayoutPace}` };
381
+ nav?: { kind?: `${LayoutNavKind}`; links?: Array<{ label: string; to: string }> };
382
+ sections: LayoutSection[];
383
+ }
384
+
385
+ // ── The tables the composer reads (the prototype renderer v4's values, `code/renderer-round4.src.html`) ──────────────
386
+
387
+ /** A size as CSS — the prototype's `.s-*` rules. `screen` is computed per word (`screenFontSize`). */
388
+ export const LAYOUT_FONT_SIZE: Readonly<Record<Exclude<LayoutSize, LayoutSize.Screen>, string>> = {
389
+ [LayoutSize.Xs]: '12px',
390
+ [LayoutSize.S]: '15px',
391
+ [LayoutSize.M]: '19px',
392
+ [LayoutSize.L]: 'clamp(26px, 2.8vw, 44px)',
393
+ [LayoutSize.Xl]: 'clamp(38px, 5vw, 82px)',
394
+ [LayoutSize.Xxl]: 'clamp(54px, 8.5vw, 150px)',
395
+ };
396
+
397
+ /** A colour name as the look's token (what the prototype probed off the preset: `--iox-bg` … `--iox-text-muted`). */
398
+ export const LAYOUT_COLOUR_TOKEN: Readonly<Record<LayoutColour, string>> = {
399
+ [LayoutColour.Ground]: 'var(--iox-bg)',
400
+ [LayoutColour.Ink]: 'var(--iox-text)',
401
+ [LayoutColour.Accent]: 'var(--iox-accent)',
402
+ [LayoutColour.Soft]: 'var(--iox-surface-2)',
403
+ [LayoutColour.Muted]: 'var(--iox-text-muted)',
404
+ };
405
+ /** Words in the accent colour read the accent's text shade (round four: `accent-text`). */
406
+ export const LAYOUT_ACCENT_TEXT = 'var(--iox-accent-text)';
407
+
408
+ /** Emil's easing tokens (never ease-in). */
409
+ export const LAYOUT_EASING: Readonly<Record<LayoutEase, string>> = {
410
+ [LayoutEase.Out]: 'cubic-bezier(0.23, 1, 0.32, 1)',
411
+ [LayoutEase.InOut]: 'cubic-bezier(0.77, 0, 0.175, 1)',
412
+ [LayoutEase.Drawer]: 'cubic-bezier(0.32, 0.72, 0, 1)',
413
+ [LayoutEase.Linear]: 'linear',
414
+ };
415
+
416
+ /** How long an entrance takes, by the look's pace and the layer's role, and how far apart the beats are. */
417
+ export const LAYOUT_PACE: Readonly<Record<LayoutPace, { lead: number; support: number; decoration: number; gap: number }>> = {
418
+ [LayoutPace.Slow]: { lead: 1100, support: 900, decoration: 900, gap: 1.3 },
419
+ [LayoutPace.Normal]: { lead: 800, support: 650, decoration: 600, gap: 1 },
420
+ [LayoutPace.Quick]: { lead: 560, support: 460, decoration: 420, gap: 0.7 },
421
+ };
422
+ /** A stagger that shrinks as the beats go on, capped at the sixth — never a metronome. */
423
+ export const LAYOUT_BEAT_DELAY: ReadonlyArray<number> = [0, 120, 210, 275, 320, 350];
424
+ /** How far a rise travels, by role (px). */
425
+ export const LAYOUT_RISE: Readonly<Record<LayoutRole, number>> = {
426
+ [LayoutRole.Lead]: 44,
427
+ [LayoutRole.Support]: 22,
428
+ [LayoutRole.Decoration]: 0,
429
+ [LayoutRole.Static]: 0,
430
+ };
431
+
432
+ /** The kinds a visitor OPERATES: never moved for style (Emil gate 4). */
433
+ export const LAYOUT_OPERATED: ReadonlySet<string> = new Set([LayoutLayerKind.Gallery, LayoutLayerKind.Button, LayoutLayerKind.Form, LayoutLayerKind.Marquee]);
434
+ export const LAYOUT_TEXT_KINDS: ReadonlySet<string> = new Set([
435
+ LayoutLayerKind.Word, LayoutLayerKind.Heading, LayoutLayerKind.Text, LayoutLayerKind.Label, LayoutLayerKind.Number, LayoutLayerKind.List,
436
+ ]);
437
+
438
+ /** The grid's gutter and column gap (the prototype's `--gutter` and `.grid`). */
439
+ export const LAYOUT_GUTTER = 'max(4vw, 16px)';
440
+ export const LAYOUT_COLUMN_GAP = '1.2vw';
441
+ /** A depth's `params.phone`: scene-core `ParallaxPhone.Rest` — stacked on a phone, a layer never glides into its neighbour.
442
+ * Stamped verbatim and read where it plays (not imported, as `PatternTrack`); compose-layout.spec holds the two equal. */
443
+ export const LAYOUT_DEPTH_ON_PHONE = 'rest';
444
+
445
+ /** Below this opacity a layer counts as hidden: the static check's rule for an entrance or an exit that hides, and the
446
+ * render check's for words a held section never shows together. */
447
+ export const LAYOUT_HIDDEN_OPACITY = 0.3;
448
+
449
+ /**
450
+ * The stretches of a held section's play (0..1) in which a layer's opacity tracks show it — above
451
+ * `LAYOUT_HIDDEN_OPACITY`, each fade taken as linear. A layer with no opacity track shows throughout. Captions that take
452
+ * turns in one cell (the live café's four, M8 gate 2 fix first part 3) never show together, so they never overlap.
453
+ */
454
+ export function layerShownSpans(l: Pick<LayoutLayer, 'motion'>): Array<[number, number]> {
455
+ const fades = (l.motion ?? []).filter(m => m.prop === LayoutTrackProp.Opacity && Array.isArray(m.at) && m.at[1] > m.at[0]).sort((a, b) => a.at[0] - b.at[0]);
456
+ if (!fades.length) return [[0, 1]];
457
+ const shows = (v: number) => v > LAYOUT_HIDDEN_OPACITY;
458
+ const spans: Array<[number, number]> = [];
459
+ let from: number | null = shows(fades[0].from) ? 0 : null;
460
+ for (const m of fades) {
461
+ if (shows(m.from) === shows(m.to)) continue;
462
+ const at = Math.round(Math.min(1, Math.max(0, m.at[0] + ((LAYOUT_HIDDEN_OPACITY - m.from) / (m.to - m.from)) * (m.at[1] - m.at[0]))) * 1000) / 1000;
463
+ if (shows(m.to) && from === null) from = at;
464
+ else if (!shows(m.to) && from !== null) {
465
+ if (at > from) spans.push([from, at]);
466
+ from = null;
467
+ }
468
+ }
469
+ if (from !== null && from < 1) spans.push([from, 1]);
470
+ return spans;
471
+ }
472
+
473
+ /** Whether two layers' shown stretches meet for any length (no spans: shown throughout). */
474
+ export function shownTogether(a: ReadonlyArray<[number, number]> | undefined, b: ReadonlyArray<[number, number]> | undefined): boolean {
475
+ const A = a ?? [[0, 1]], B = b ?? [[0, 1]];
476
+ return A.some(([a0, a1]) => B.some(([b0, b1]) => Math.min(a1, b1) > Math.max(a0, b0)));
477
+ }
478
+
479
+ /** A control's tooltip words: the main entry's `A11yTrait.Tooltip` (premium M5), held equal by compose-layout.spec. */
480
+ export const LAYOUT_TOOLTIP_TRAIT = 'tooltip';
481
+
482
+ /** The phone: at or under this breakpoint a section stacks in its `phone` order (the `mobile` breakpoint, ≤ 767px). */
483
+ export const LAYOUT_PHONE_BREAKPOINT = 'mobile';
484
+ /** A phone section's padding above and below (M1.3: 56). */
485
+ export const LAYOUT_PHONE_PADDING = '56px';
486
+
487
+ /** The kind of layer, for the phone's rhythm: the space between two stacked layers says how they belong (M1.3). */
488
+ export function phoneGapBefore(prev: LayoutLayer | null, next: LayoutLayer): number {
489
+ if (!prev) return 0;
490
+ const k = (l: LayoutLayer) => l.kind;
491
+ if (k(prev) === LayoutLayerKind.Photo || k(prev) === LayoutLayerKind.Gallery || k(next) === LayoutLayerKind.Photo || k(next) === LayoutLayerKind.Gallery) return 32;
492
+ if (k(next) === LayoutLayerKind.Button || k(next) === LayoutLayerKind.Form) return 28;
493
+ if (k(prev) === LayoutLayerKind.Label || (k(prev) === LayoutLayerKind.Number && k(next) === LayoutLayerKind.Heading)) return 10;
494
+ if ((k(prev) === LayoutLayerKind.Heading && (k(next) === LayoutLayerKind.Text || k(next) === LayoutLayerKind.List)) || (k(prev) === LayoutLayerKind.Text && k(next) === LayoutLayerKind.Text)) return 14;
495
+ return 20;
496
+ }
497
+
498
+ /** The grid a laptop page is laid on, in vw: its width inside the gutters (`LAYOUT_GUTTER` 4vw a side), the gap between
499
+ * columns (`LAYOUT_COLUMN_GAP`), and 12 columns. */
500
+ const GRID_VW = 92;
501
+ const COLUMN_GAP_VW = 1.2;
502
+ const GRID_COLUMNS = 12;
503
+ /** A `screen` word's smallest and largest size (px), and the share of its room it fills (the renderer's margin). */
504
+ export const LAYOUT_SCREEN_PX: readonly [number, number] = [36, 560];
505
+ const SCREEN_FILL = 0.98;
506
+ const round2 = (n: number) => Math.round(n * 100) / 100;
507
+
508
+ /** How wide `cols` columns of the laptop grid stand, in vw (12 columns: 92vw). */
509
+ export function layoutColumnsVw(cols: number): number {
510
+ const column = (GRID_VW - (GRID_COLUMNS - 1) * COLUMN_GAP_VW) / GRID_COLUMNS;
511
+ return cols * column + Math.max(0, cols - 1) * COLUMN_GAP_VW;
512
+ }
513
+
514
+ /** The room a layer of `cols` columns has on a screen `width` px wide, in px — a phone stacks every layer full width
515
+ * inside its gutters (`max(4vw, 16px)` a side). */
516
+ export function layoutRoomPx(cols: number, width: number, phone: boolean): number {
517
+ return phone ? width - 2 * Math.max(0.04 * width, 16) : (layoutColumnsVw(cols) * width) / 100;
518
+ }
519
+
520
+ /**
521
+ * A `screen` word's size (iox-ui#46): the word fills its columns' width — `widthEm` is how wide it stands at 1em in its
522
+ * own face (design-core `textWidthEm`, from the face's measured letters) — and never stands taller than its rows; never
523
+ * under 36px or over 560px. `rows` 0 sizes by width alone (a phone's stacked word). Held sections are one screen tall.
524
+ */
525
+ export function screenFontSize(widthEm: number, cols: number, rows: number, sectionRows: number, screens: number): string {
526
+ const [min, max] = LAYOUT_SCREEN_PX;
527
+ const widthVw = round2((layoutColumnsVw(cols) / Math.max(widthEm, 0.01)) * SCREEN_FILL);
528
+ if (!rows || !sectionRows) return `clamp(${min}px, ${widthVw}vw, ${max}px)`;
529
+ const heightSvh = round2((((rows / sectionRows) * screens * 100) / 0.92) * SCREEN_FILL);
530
+ return `clamp(${min}px, min(${widthVw}vw, ${heightSvh}svh), ${max}px)`;
531
+ }
532
+
533
+ /** How many px a `screen` word `widthEm` wide runs past its room at its smallest size, on a screen `width` px wide — 0
534
+ * when it fits. The one thing sizing cannot mend: the static check refuses it (a browser would show it cut). */
535
+ export function screenWordOverflowPx(widthEm: number, cols: number, width: number, phone: boolean): number {
536
+ return Math.max(0, Math.round(LAYOUT_SCREEN_PX[0] * widthEm - layoutRoomPx(cols, width, phone)));
537
+ }
@@ -0,0 +1,57 @@
1
+ import { DesignChoices, presetModes, resolveDesignChoices, STYLE_PRESETS, StylePreset, stylePresetOfChoices } from '@vectoriox/iox-ui/design-core';
2
+
3
+ import { LayoutDial, LayoutEase, LayoutPace } from './layout-language';
4
+ import { SPEC_SITE_LAYOUT } from './site-spec.generated';
5
+
6
+ /** A look's composition notes (contract `site.layout.looks`): what a composed page in that look keeps to. */
7
+ export type LayoutLook = (typeof SPEC_SITE_LAYOUT.looks)[number];
8
+
9
+ const LOOKS: ReadonlyArray<LayoutLook> = SPEC_SITE_LAYOUT.looks;
10
+ const PRESET_LOOK: Readonly<Record<string, string>> = SPEC_SITE_LAYOUT.presetLook;
11
+ const DARING_LEVELS: ReadonlyArray<string> = SPEC_SITE_LAYOUT.daringLevels;
12
+
13
+ /** How far two brand colours are apart (RGB) — the last word between two presets that differ by their colour alone. */
14
+ function seedDistance(a: string, b: string): number {
15
+ const rgb = (hex: string) => [1, 3, 5].map(i => parseInt(hex.slice(i, i + 2), 16) || 0);
16
+ const [x, y] = [rgb(a), rgb(b)];
17
+ return x.reduce((sum, v, i) => sum + (v - y[i]) ** 2, 0);
18
+ }
19
+
20
+ /**
21
+ * The style preset a design wears (M8 gate 2): the preset it IS, else the closest of its flavor — same font pairing,
22
+ * then the most of shape · density · pill buttons · tint · mode in common, then the nearer brand colour (six pairings
23
+ * carry two presets each: Quiet luxury and Soft spa are both Linen + Cormorant; Morning glass and Coral studio differ by
24
+ * their colour alone) — so an owner whose brand became a reference colour still wears THEIR preset's composition notes.
25
+ * Never null: a design with no preset of its flavor reads the first preset's.
26
+ */
27
+ export function layoutPresetOf(choices: DesignChoices): StylePreset {
28
+ const exact = stylePresetOfChoices(choices);
29
+ if (exact) return exact;
30
+ const c = resolveDesignChoices(choices);
31
+ const kept = (p: StylePreset) => [p.shape === c.shape, p.density === c.density, p.pillButtons === c.pillButtons, p.tint === c.tint,
32
+ presetModes(p).includes(c.mode)].filter(Boolean).length;
33
+ const nearer = (a: StylePreset, b: StylePreset) => kept(a) - kept(b) || seedDistance(b.seed, c.seed) - seedDistance(a.seed, c.seed);
34
+ const paired = STYLE_PRESETS.filter(p => p.flavorId === c.flavorId && p.pairId === c.pairId);
35
+ if (paired.length) return paired.reduce((best, p) => (nearer(p, best) > 0 ? p : best));
36
+ return STYLE_PRESETS.find(p => p.flavorId === c.flavorId) ?? STYLE_PRESETS[0];
37
+ }
38
+
39
+ /** A preset's look (the round-three composition notes it carries). */
40
+ export function layoutLookOf(presetId: string): LayoutLook {
41
+ return LOOKS.find(l => l.id === PRESET_LOOK[presetId]) ?? LOOKS[0];
42
+ }
43
+
44
+ /** The pace and ease a composed page moves with: its look's. */
45
+ export function layoutMotionOf(presetId: string): { pace: `${LayoutPace}`; ease: `${LayoutEase}` } {
46
+ const look = layoutLookOf(presetId);
47
+ return { pace: look.pace as `${LayoutPace}`, ease: look.ease as `${LayoutEase}` };
48
+ }
49
+
50
+ /**
51
+ * How far a composed page dares (M8-G2-D5): daring when the look moves Lively or Expressive and the business type's
52
+ * ceiling allows it (a trust or care type never dares), else distinct. `ceiling` is harness-core's for the type.
53
+ */
54
+ export function layoutDialOf(animate: string | null | undefined, ceiling: string | null | undefined): `${LayoutDial}` {
55
+ const daring = !!animate && DARING_LEVELS.includes(animate) && (!ceiling || DARING_LEVELS.includes(ceiling));
56
+ return daring ? LayoutDial.Daring : LayoutDial.Distinct;
57
+ }
@@ -0,0 +1,19 @@
1
+ import { layoutPhotoIds } from './check-layout';
2
+ import { LayoutPhotoSource, parseLayoutPhotoId } from './layout-language';
3
+ import { SitePlan } from './site-plan.model';
4
+
5
+ /**
6
+ * Where the composed pages' photos come from (M8-G2-D10 — the Plan step's Pictures line: "Your 4 photos go first · 8 from
7
+ * your photo library · 0 empty boxes"): every distinct photo id the plan's composed layouts name, by source. Pure.
8
+ */
9
+ export function planLayoutPhotos(plan: Pick<SitePlan, 'pages'>): Record<LayoutPhotoSource, string[]> {
10
+ const out: Record<LayoutPhotoSource, Set<string>> = { [LayoutPhotoSource.Own]: new Set(), [LayoutPhotoSource.Stock]: new Set(), [LayoutPhotoSource.Box]: new Set() };
11
+ for (const page of plan.pages) {
12
+ if (!page.layout) continue;
13
+ for (const id of layoutPhotoIds(page.layout)) {
14
+ const read = parseLayoutPhotoId(id);
15
+ if (read) out[read.source].add(id);
16
+ }
17
+ }
18
+ return { [LayoutPhotoSource.Own]: [...out.own], [LayoutPhotoSource.Stock]: [...out.stock], [LayoutPhotoSource.Box]: [...out.box] };
19
+ }