@vectoriox/iox-ui 5.88.0 → 5.89.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.
@@ -526,14 +526,26 @@ function composeForm(node: SerializedNode, pn: PatternNode, id: string, ctx: Ctx
526
526
  }
527
527
  // A section may give the pattern's form another preset (`form`: Practice's contact page asks to book).
528
528
  const presetId = ctx.section?.form ?? pn.preset;
529
+ if (pn.c?.length) throw new ComposeError(`${id}: a preset Form takes its fields from the preset, not the pattern`);
530
+ stampPresetForm(node, presetId, id, ctx.owner);
531
+ }
532
+
533
+ /** A preset's name, stable form id and children on a Form node — the ONE stamping `composeSite` and `composeLayout` share. */
534
+ function stampPresetForm(node: SerializedNode, presetId: string, id: string, owner: string): void {
529
535
  const preset = formPresetById(presetId);
530
536
  if (!preset) throw new ComposeError(`${id}: no form preset "${presetId}" in forms-core`);
531
- if (pn.c?.length) throw new ComposeError(`${id}: a preset Form takes its fields from the preset, not the pattern`);
532
537
  setProp(node, 'name', preset.formName);
533
- setProp(node, 'formId', `${preset.id}-${stableHash(`${ctx.owner}/${id}`)}`);
538
+ setProp(node, 'formId', `${preset.id}-${stableHash(`${owner}/${id}`)}`);
534
539
  node.children = presetChildren(preset, id);
535
540
  }
536
541
 
542
+ /** A NEW Form stamped from a forms-core preset, exactly as a pattern's preset form is (premium M8: a layout's form layer). */
543
+ export function composePresetForm(id: string, presetId: string, owner: string): SerializedNode {
544
+ const node = create(id, FORM);
545
+ stampPresetForm(node, presetId, id, owner);
546
+ return node;
547
+ }
548
+
537
549
  /** A pattern node's children; an `each` child is stamped once per navigation page, its id carrying the
538
550
  * page key so it survives a page being left out or reordered. */
539
551
  function composeChildren(pn: PatternNode, id: string, repeater: RepeaterScope | null, ctx: Ctx): SerializedNode[] {
@@ -0,0 +1,354 @@
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 types the shape the three proof sites were saved in (iox-ai-guidance `prototypes/breaking-limits/round4|round3`).
8
+ * The closed lists move into the contract in gate 2 (m8-proof-sites.md, M8-D1).
9
+ */
10
+
11
+ export enum LayoutLayerKind {
12
+ Word = 'word',
13
+ Heading = 'heading',
14
+ Text = 'text',
15
+ Photo = 'photo',
16
+ Gallery = 'gallery',
17
+ Button = 'button',
18
+ List = 'list',
19
+ Number = 'number',
20
+ Shape = 'shape',
21
+ Label = 'label',
22
+ Form = 'form',
23
+ Marquee = 'marquee',
24
+ }
25
+
26
+ export enum LayoutSize {
27
+ Xs = 'xs',
28
+ S = 's',
29
+ M = 'm',
30
+ L = 'l',
31
+ Xl = 'xl',
32
+ Xxl = 'xxl',
33
+ /** As wide as its columns allow — a word, never a sentence. */
34
+ Screen = 'screen',
35
+ }
36
+
37
+ /** The look's five colours, by role. */
38
+ export enum LayoutColour {
39
+ Ground = 'ground',
40
+ Ink = 'ink',
41
+ Accent = 'accent',
42
+ Soft = 'soft',
43
+ Muted = 'muted',
44
+ }
45
+
46
+ export enum LayoutRole {
47
+ Lead = 'lead',
48
+ Support = 'support',
49
+ Decoration = 'decoration',
50
+ Static = 'static',
51
+ }
52
+
53
+ export enum LayoutEnter {
54
+ None = 'none',
55
+ Fade = 'fade',
56
+ FadeRise = 'fadeRise',
57
+ ScaleIn = 'scaleIn',
58
+ ClipReveal = 'clipReveal',
59
+ MaskRise = 'maskRise',
60
+ BlurIn = 'blurIn',
61
+ Pop = 'pop',
62
+ }
63
+
64
+ export enum LayoutDepth {
65
+ Back = 'back',
66
+ Mid = 'mid',
67
+ Front = 'front',
68
+ }
69
+
70
+ export enum LayoutTransition {
71
+ Cut = 'cut',
72
+ Flood = 'flood',
73
+ WipeUp = 'wipe-up',
74
+ WipeDown = 'wipe-down',
75
+ WipeStart = 'wipe-start',
76
+ WipeEnd = 'wipe-end',
77
+ }
78
+
79
+ export enum LayoutEase {
80
+ Out = 'out',
81
+ InOut = 'inOut',
82
+ Drawer = 'drawer',
83
+ Linear = 'linear',
84
+ }
85
+
86
+ export enum LayoutPace {
87
+ Slow = 'slow',
88
+ Normal = 'normal',
89
+ Quick = 'quick',
90
+ }
91
+
92
+ export enum LayoutSide {
93
+ Bottom = 'bottom',
94
+ Top = 'top',
95
+ Start = 'start',
96
+ End = 'end',
97
+ }
98
+
99
+ export enum LayoutTrackProp {
100
+ X = 'x',
101
+ Y = 'y',
102
+ Scale = 'scale',
103
+ Opacity = 'opacity',
104
+ Rotate = 'rotate',
105
+ Clip = 'clip',
106
+ Blur = 'blur',
107
+ }
108
+
109
+ export enum LayoutAlign {
110
+ Start = 'start',
111
+ Center = 'center',
112
+ End = 'end',
113
+ }
114
+
115
+ export enum LayoutBleed {
116
+ None = 'none',
117
+ Start = 'start',
118
+ End = 'end',
119
+ Both = 'both',
120
+ }
121
+
122
+ /** A pool photo's shape (the inventory measures each one): what it keeps where nothing else gives it a height. */
123
+ export enum LayoutPhotoShape {
124
+ Wide = 'wide',
125
+ Landscape = 'landscape',
126
+ Square = 'square',
127
+ Portrait = 'portrait',
128
+ Tall = 'tall',
129
+ }
130
+
131
+ export const LAYOUT_PHOTO_ASPECT: Readonly<Record<LayoutPhotoShape, string>> = {
132
+ [LayoutPhotoShape.Wide]: '16 / 9',
133
+ [LayoutPhotoShape.Landscape]: '3 / 2',
134
+ [LayoutPhotoShape.Square]: '1 / 1',
135
+ [LayoutPhotoShape.Portrait]: '2 / 3',
136
+ [LayoutPhotoShape.Tall]: '9 / 16',
137
+ };
138
+
139
+ export enum LayoutSectionKind {
140
+ Content = 'content',
141
+ Inhale = 'inhale',
142
+ }
143
+
144
+ export enum LayoutButtonVariant {
145
+ Primary = 'primary',
146
+ Secondary = 'secondary',
147
+ Ghost = 'ghost',
148
+ }
149
+
150
+ /** The product SliderContainer's own effects (iox-ui `slider-options.ts`). */
151
+ export enum LayoutGalleryEffect {
152
+ Slide = 'slide',
153
+ Fade = 'fade',
154
+ Cube = 'cube',
155
+ Flip = 'flip',
156
+ Coverflow = 'coverflow',
157
+ Cards = 'cards',
158
+ Creative = 'creative',
159
+ }
160
+
161
+ export enum LayoutNavKind {
162
+ Bar = 'bar',
163
+ Corner = 'corner',
164
+ Index = 'index',
165
+ Side = 'side',
166
+ }
167
+
168
+ export interface LayoutTrack {
169
+ prop: `${LayoutTrackProp}`;
170
+ from: number;
171
+ to: number;
172
+ /** The part of the section's scroll it plays over (0 = it arrives, 1 = it leaves; held: 0..1 is the hold). */
173
+ at: [number, number];
174
+ ease?: `${LayoutEase}`;
175
+ }
176
+
177
+ export interface LayoutGallery {
178
+ slides: Array<{ photo: { id: string }; caption?: string }>;
179
+ effect?: `${LayoutGalleryEffect}`;
180
+ perView?: number | 'auto';
181
+ centered?: boolean;
182
+ freeMode?: boolean;
183
+ loop?: boolean;
184
+ /** 0 or milliseconds. */
185
+ autoplay?: number;
186
+ /** Captions and pictures move at their own speed inside each slide (Swiper parallax). */
187
+ drift?: boolean;
188
+ /** Only in a held section: the page's scroll turns the slides. */
189
+ scroll?: boolean;
190
+ }
191
+
192
+ export interface LayoutForm {
193
+ preset: 'lead' | 'contact' | 'booking' | 'newsletter';
194
+ title?: string;
195
+ intro?: string;
196
+ /** The chips a preset has (lead: needs, budget; booking: guests), in the business's language. */
197
+ options?: Partial<Record<'needs' | 'budget' | 'guests', string[]>>;
198
+ submit?: string;
199
+ successTitle?: string;
200
+ successText?: string;
201
+ channel?: { label: string; href?: string };
202
+ }
203
+
204
+ export interface LayoutLayer {
205
+ kind: `${LayoutLayerKind}`;
206
+ role?: `${LayoutRole}`;
207
+ text?: string;
208
+ items?: string[];
209
+ photo?: { id: string };
210
+ gallery?: LayoutGallery;
211
+ form?: LayoutForm;
212
+ variant?: `${LayoutButtonVariant}`;
213
+ /** Grid lines: 1..13, or 1..12×track+1 in a sideways section. */
214
+ col: [number, number];
215
+ row: [number, number];
216
+ size?: `${LayoutSize}`;
217
+ color?: `${LayoutColour}`;
218
+ align?: `${LayoutAlign}`;
219
+ z?: number;
220
+ bleed?: `${LayoutBleed}`;
221
+ rotate?: number;
222
+ fit?: 'cover' | 'contain';
223
+ /** A button's section id. */
224
+ to?: string;
225
+ scrim?: boolean;
226
+ enter?: `${LayoutEnter}`;
227
+ from?: `${LayoutSide}`;
228
+ beat?: number;
229
+ depth?: `${LayoutDepth}`;
230
+ inner?: number;
231
+ kinetic?: boolean;
232
+ motion?: LayoutTrack[];
233
+ }
234
+
235
+ export interface LayoutSection {
236
+ id: string;
237
+ kind?: `${LayoutSectionKind}`;
238
+ signature?: boolean;
239
+ screens: number;
240
+ pin?: boolean;
241
+ track?: number;
242
+ /** A colour name, or `photo:<id>`. */
243
+ ground?: string;
244
+ rows: number;
245
+ transition?: `${LayoutTransition}`;
246
+ layers: LayoutLayer[];
247
+ /** Every layer's index once, in a phone's reading order. */
248
+ phone?: number[];
249
+ }
250
+
251
+ export interface LayoutSite {
252
+ name: string;
253
+ idea?: string;
254
+ locale?: string;
255
+ dial?: 'distinct' | 'daring';
256
+ /** CL2.1: `{ preset, seed? }`. A CL2 site carries a round-three `recipe` and colours (the runner maps it to a preset). */
257
+ look?: { preset?: string; seed?: string; recipe?: string; accent?: string };
258
+ motion?: { ease?: `${LayoutEase}`; pace?: `${LayoutPace}` };
259
+ nav?: { kind?: `${LayoutNavKind}`; links?: Array<{ label: string; to: string }> };
260
+ sections: LayoutSection[];
261
+ }
262
+
263
+ // ── The tables the composer reads (the prototype renderer v4's values, `code/renderer-round4.src.html`) ──────────────
264
+
265
+ /** A size as CSS — the prototype's `.s-*` rules. `screen` is computed per word (`screenFontSize`). */
266
+ export const LAYOUT_FONT_SIZE: Readonly<Record<Exclude<LayoutSize, LayoutSize.Screen>, string>> = {
267
+ [LayoutSize.Xs]: '12px',
268
+ [LayoutSize.S]: '15px',
269
+ [LayoutSize.M]: '19px',
270
+ [LayoutSize.L]: 'clamp(26px, 2.8vw, 44px)',
271
+ [LayoutSize.Xl]: 'clamp(38px, 5vw, 82px)',
272
+ [LayoutSize.Xxl]: 'clamp(54px, 8.5vw, 150px)',
273
+ };
274
+
275
+ /** A colour name as the look's token (what the prototype probed off the preset: `--iox-bg` … `--iox-text-muted`). */
276
+ export const LAYOUT_COLOUR_TOKEN: Readonly<Record<LayoutColour, string>> = {
277
+ [LayoutColour.Ground]: 'var(--iox-bg)',
278
+ [LayoutColour.Ink]: 'var(--iox-text)',
279
+ [LayoutColour.Accent]: 'var(--iox-accent)',
280
+ [LayoutColour.Soft]: 'var(--iox-surface-2)',
281
+ [LayoutColour.Muted]: 'var(--iox-text-muted)',
282
+ };
283
+ /** Words in the accent colour read the accent's text shade (round four: `accent-text`). */
284
+ export const LAYOUT_ACCENT_TEXT = 'var(--iox-accent-text)';
285
+
286
+ /** Emil's easing tokens (never ease-in). */
287
+ export const LAYOUT_EASING: Readonly<Record<LayoutEase, string>> = {
288
+ [LayoutEase.Out]: 'cubic-bezier(0.23, 1, 0.32, 1)',
289
+ [LayoutEase.InOut]: 'cubic-bezier(0.77, 0, 0.175, 1)',
290
+ [LayoutEase.Drawer]: 'cubic-bezier(0.32, 0.72, 0, 1)',
291
+ [LayoutEase.Linear]: 'linear',
292
+ };
293
+
294
+ /** How long an entrance takes, by the look's pace and the layer's role, and how far apart the beats are. */
295
+ export const LAYOUT_PACE: Readonly<Record<LayoutPace, { lead: number; support: number; decoration: number; gap: number }>> = {
296
+ [LayoutPace.Slow]: { lead: 1100, support: 900, decoration: 900, gap: 1.3 },
297
+ [LayoutPace.Normal]: { lead: 800, support: 650, decoration: 600, gap: 1 },
298
+ [LayoutPace.Quick]: { lead: 560, support: 460, decoration: 420, gap: 0.7 },
299
+ };
300
+ /** A stagger that shrinks as the beats go on, capped at the sixth — never a metronome. */
301
+ export const LAYOUT_BEAT_DELAY: ReadonlyArray<number> = [0, 120, 210, 275, 320, 350];
302
+ /** How far a rise travels, by role (px). */
303
+ export const LAYOUT_RISE: Readonly<Record<LayoutRole, number>> = {
304
+ [LayoutRole.Lead]: 44,
305
+ [LayoutRole.Support]: 22,
306
+ [LayoutRole.Decoration]: 0,
307
+ [LayoutRole.Static]: 0,
308
+ };
309
+
310
+ /** The kinds a visitor OPERATES: never moved for style (Emil gate 4). */
311
+ export const LAYOUT_OPERATED: ReadonlySet<string> = new Set([LayoutLayerKind.Gallery, LayoutLayerKind.Button, LayoutLayerKind.Form, LayoutLayerKind.Marquee]);
312
+ export const LAYOUT_TEXT_KINDS: ReadonlySet<string> = new Set([
313
+ LayoutLayerKind.Word, LayoutLayerKind.Heading, LayoutLayerKind.Text, LayoutLayerKind.Label, LayoutLayerKind.Number, LayoutLayerKind.List,
314
+ ]);
315
+
316
+ /** The grid's gutter and column gap (the prototype's `--gutter` and `.grid`). */
317
+ export const LAYOUT_GUTTER = 'max(4vw, 16px)';
318
+ export const LAYOUT_COLUMN_GAP = '1.2vw';
319
+ /** A depth's `params.phone`: scene-core `ParallaxPhone.Rest` — stacked on a phone, a layer never glides into its neighbour.
320
+ * Stamped verbatim and read where it plays (not imported, as `PatternTrack`); compose-layout.spec holds the two equal. */
321
+ export const LAYOUT_DEPTH_ON_PHONE = 'rest';
322
+
323
+ /** A control's tooltip words: the main entry's `A11yTrait.Tooltip` (premium M5), held equal by compose-layout.spec. */
324
+ export const LAYOUT_TOOLTIP_TRAIT = 'tooltip';
325
+
326
+ /** The phone: at or under this breakpoint a section stacks in its `phone` order (the `mobile` breakpoint, ≤ 767px). */
327
+ export const LAYOUT_PHONE_BREAKPOINT = 'mobile';
328
+ /** A phone section's padding above and below (M1.3: 56). */
329
+ export const LAYOUT_PHONE_PADDING = '56px';
330
+
331
+ /** The kind of layer, for the phone's rhythm: the space between two stacked layers says how they belong (M1.3). */
332
+ export function phoneGapBefore(prev: LayoutLayer | null, next: LayoutLayer): number {
333
+ if (!prev) return 0;
334
+ const k = (l: LayoutLayer) => l.kind;
335
+ if (k(prev) === LayoutLayerKind.Photo || k(prev) === LayoutLayerKind.Gallery || k(next) === LayoutLayerKind.Photo || k(next) === LayoutLayerKind.Gallery) return 32;
336
+ if (k(next) === LayoutLayerKind.Button || k(next) === LayoutLayerKind.Form) return 28;
337
+ if (k(prev) === LayoutLayerKind.Label || (k(prev) === LayoutLayerKind.Number && k(next) === LayoutLayerKind.Heading)) return 10;
338
+ if ((k(prev) === LayoutLayerKind.Heading && (k(next) === LayoutLayerKind.Text || k(next) === LayoutLayerKind.List)) || (k(prev) === LayoutLayerKind.Text && k(next) === LayoutLayerKind.Text)) return 14;
339
+ return 20;
340
+ }
341
+
342
+ /**
343
+ * A `screen` word's size: its letters fill its columns' width (a display face runs about `advance` em a letter) and
344
+ * never stand taller than its rows; never under 36px or over 560px (M8-G1: estimated, the product fits nothing in the
345
+ * browser). `rows` 0 sizes by width alone (a phone's stacked word). Held sections are one screen tall.
346
+ */
347
+ export function screenFontSize(text: string, cols: number, rows: number, sectionRows: number, screens: number, advance = 0.6): string {
348
+ const letters = Math.max(1, Array.from(String(text ?? '').trim()).length);
349
+ // The columns' share of the screen's width less its gutters (92vw for 12 columns), at 98% (the renderer's margin).
350
+ const widthVw = Math.round(((92 * (cols / 12)) / (letters * advance)) * 0.98 * 100) / 100;
351
+ if (!rows || !sectionRows) return `clamp(36px, ${widthVw}vw, 560px)`;
352
+ const heightSvh = Math.round((((rows / sectionRows) * screens * 100) / 0.92) * 0.98 * 100) / 100;
353
+ return `clamp(36px, min(${widthVw}vw, ${heightSvh}svh), 560px)`;
354
+ }
@@ -39,3 +39,5 @@ export * from './stock-photos';
39
39
  export * from './film';
40
40
  export * from './art-direction';
41
41
  export * from './pictures';
42
+ export * from './layout-language';
43
+ export * from './compose-layout';
@@ -102,6 +102,18 @@ export const PARALLAX_SPEED = 0.3;
102
102
  /** A phone's layers move half as far: on a narrow stack a glide reaches the next block sooner (round three's phone rule). */
103
103
  export const PARALLAX_PHONE_FACTOR = 0.5;
104
104
 
105
+ /** What a depth does on a phone (its action's `params.phone`). */
106
+ export enum ParallaxPhone {
107
+ /** Half as far (round three's phone rule; a depth with no `phone` param). */
108
+ Half = 'half',
109
+ /** Still: a layer that stacks with its neighbours on a phone never glides into them (round four, CL2 layers). */
110
+ Rest = 'rest',
111
+ }
112
+
113
+ export function normalizeParallaxPhone(value: unknown): ParallaxPhone {
114
+ return value === ParallaxPhone.Rest ? ParallaxPhone.Rest : ParallaxPhone.Half;
115
+ }
116
+
105
117
  export function normalizeParallaxDepth(value: unknown): ParallaxDepth {
106
118
  return value === ParallaxDepth.Front ? ParallaxDepth.Front : PARALLAX_DEPTH_DEFAULT;
107
119
  }
@@ -111,7 +123,8 @@ export function normalizeParallaxDepth(value: unknown): ParallaxDepth {
111
123
  * (back) or the other way (front), and stands exactly in its place halfway. Never more than the share of one screen, so
112
124
  * a tall layer never slides a screen away from what it belongs to.
113
125
  */
114
- export function parallaxShift(distance: number, viewHeight: number, options: { phone?: boolean } = {}): number {
126
+ export function parallaxShift(distance: number, viewHeight: number, options: { phone?: boolean; onPhone?: ParallaxPhone } = {}): number {
127
+ if (options.phone && options.onPhone === ParallaxPhone.Rest) return 0;
115
128
  const speed = PARALLAX_SPEED * (options.phone ? PARALLAX_PHONE_FACTOR : 1);
116
129
  const shift = speed * Math.min(Math.max(0, distance) / 2, Math.max(0, viewHeight));
117
130
  return Math.round(shift * 10) / 10;
@@ -660,6 +660,23 @@ span.iox-video__play { pointer-events: none; }
660
660
  every language. */
661
661
  :where(.iox-role-slider-bar) .iox-role-slider-caption {
662
662
  min-width: 0;
663
+ overflow: hidden;
664
+ text-overflow: ellipsis;
665
+ white-space: nowrap;
666
+ }
667
+ /* A slider holding its bar is a column: at its content's height the picture then the bar, as in flow; given a height
668
+ (a gallery bounded by its cell — M8), the picture takes what the bar leaves and the bar never spills out under it.
669
+ Out-ranks Swiper's `.swiper { display: block }` and a node's own compiled display. */
670
+ .swiper:has(> .iox-role-slider-bar) {
671
+ display: flex;
672
+ flex-direction: column;
673
+ }
674
+ .swiper:has(> .iox-role-slider-bar) > .swiper-wrapper {
675
+ flex: 1 1 auto;
676
+ min-height: 0;
677
+ }
678
+ .swiper:has(> .iox-role-slider-bar) > .iox-role-slider-bar {
679
+ flex-shrink: 0;
663
680
  }
664
681
  /* Their words are the slide in view's, written by the runtime as an attribute (composite-core attachSliderBar). */
665
682
  :is(.iox-role-slider-caption, .iox-role-slider-count)::before {