@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
@@ -12,7 +12,7 @@ import { ContentFieldControl, FIELD_TYPE_OF_CONTROL,
12
12
  } from './site-plan.model';
13
13
  import { artDirectionIssues } from './art-direction';
14
14
  import { patternListGap } from './recipe-fields';
15
- import { SPEC_SITE_PLAN_SHAPE } from './site-spec.generated';
15
+ import { SPEC_SITE_LAYOUT, SPEC_SITE_PLAN_SHAPE } from './site-spec.generated';
16
16
  import {
17
17
  isNonEmptyString, isPlainObject as isObject, PathIssue, PathIssueCollector, pathAt as at, PlainObject as Obj, requiredShapeKeys, ShapeEntry, shapeKeys,
18
18
  } from './shape-check';
@@ -79,6 +79,12 @@ export enum SitePlanIssueCode {
79
79
  Film = 'film',
80
80
  /** M7: the art direction is not a picture world with its five parts. Set by the generation, never by a model. */
81
81
  ArtDirection = 'art-direction',
82
+ /** M8 gate 2: the site's direction (the idea, the cliché, the flip, three rules) — written whole or not at all. */
83
+ Direction = 'direction',
84
+ /** M8 gate 2: which pages are composed — the home page and at most one other that is no per-item page. */
85
+ Compose = 'compose',
86
+ /** M8 gate 2: a composed page's layout (`checkLayout`'s issues, each at its path under `layout`). */
87
+ Layout = 'layout',
82
88
  }
83
89
 
84
90
  export type SitePlanIssue = PathIssue<SitePlanIssueCode>;
@@ -119,6 +125,11 @@ const RELATIVE_SOURCE_KEYS = shapeKeys(SHAPE['relativeDataSource']);
119
125
  const PAGE_KEYS = shapeKeys(SHAPE['page']);
120
126
  const FILM_KEYS = shapeKeys(SHAPE['film']);
121
127
  const ART_DIRECTION_KEYS = shapeKeys(SHAPE['artDirection']);
128
+ const DIRECTION_KEYS = shapeKeys(SHAPE['direction']);
129
+ const LAYOUT_PAGE_KEYS = shapeKeys(SHAPE['layoutPage']);
130
+ const LAYOUT_DIALS: ReadonlyArray<string> = SPEC_SITE_LAYOUT.vocab.dials;
131
+ const COMPOSED_PAGES_MAX: number = SPEC_SITE_LAYOUT.limits.composedPages;
132
+ const DIRECTION_RULES_MAX = 3;
122
133
  const SECTION_KEYS = shapeKeys(SHAPE['section']);
123
134
  const GLOBAL_POSITION: Readonly<Record<`${GlobalSlot}`, `${PatternGlobalPosition}`>> = {
124
135
  [GlobalSlot.Header]: PatternGlobalPosition.Before,
@@ -570,9 +581,52 @@ export function validateSitePlan(plan: unknown): SitePlanValidation {
570
581
  validateScenes(c, c.array(plan, 'pages', ''), typeof design['animate'] === 'string' ? design['animate'] : null);
571
582
  validateFilm(c, plan['film'], c.array(plan, 'pages', ''));
572
583
  validateArtDirection(c, plan['artDirection']);
584
+ validateDirection(c, plan['direction']);
585
+ validateComposed(c, c.array(plan, 'pages', ''));
573
586
  return { valid: c.issues.length === 0, issues: c.issues };
574
587
  }
575
588
 
589
+ /** M8 gate 2: the direction is whole — three sentences and up to three rules — or absent. */
590
+ function validateDirection(c: Collector, direction: unknown): void {
591
+ if (direction === undefined) return;
592
+ if (!isObject(direction)) return c.add(SitePlanIssueCode.Shape, 'direction', 'must be an object');
593
+ c.keys(direction, DIRECTION_KEYS, 'direction');
594
+ for (const key of ['idea', 'cliche', 'flip']) if (!isNonEmptyString(direction[key])) c.add(SitePlanIssueCode.Direction, `direction.${key}`, 'one sentence');
595
+ const rules = direction['rules'];
596
+ if (!Array.isArray(rules) || !rules.length || rules.length > DIRECTION_RULES_MAX || !rules.every(isNonEmptyString)) {
597
+ c.add(SitePlanIssueCode.Direction, 'direction.rules', `1–${DIRECTION_RULES_MAX} short rules`);
598
+ }
599
+ }
600
+
601
+ /**
602
+ * M8 gate 2: the composed pages. The home page and at most one other, never a per-item page (its words come from the
603
+ * item); a layout only on a page marked `compose`, its dial one of the dials and 4–8 sections (the rest is `checkLayout`'s
604
+ * — the plan stage runs it with the photos, `layoutIssues` on a whole plan).
605
+ */
606
+ function validateComposed(c: Collector, pages: unknown[]): void {
607
+ let composed = 0;
608
+ pages.forEach((raw, i) => {
609
+ if (!isObject(raw)) return;
610
+ const path = `pages[${i}]`;
611
+ c.boolean(raw, 'compose', path);
612
+ const compose = raw['compose'] === true;
613
+ if (compose) {
614
+ composed++;
615
+ if (raw['template'] !== undefined || raw['routeSource'] !== undefined || (typeof raw['route'] === 'string' && routeParams(raw['route']).length)) {
616
+ c.add(SitePlanIssueCode.Compose, `${path}.compose`, 'a per-item page shows its item from patterns — it is not composed');
617
+ }
618
+ }
619
+ const layout = raw['layout'];
620
+ if (layout === undefined) return;
621
+ if (!compose) c.add(SitePlanIssueCode.Compose, `${path}.layout`, 'a layout only on a page marked compose');
622
+ if (!isObject(layout)) return c.add(SitePlanIssueCode.Shape, `${path}.layout`, 'must be an object');
623
+ c.keys(layout, LAYOUT_PAGE_KEYS, `${path}.layout`);
624
+ if (!LAYOUT_DIALS.includes(String(layout['dial']))) c.add(SitePlanIssueCode.Layout, `${path}.layout.dial`, LAYOUT_DIALS.join(' | '));
625
+ if (!Array.isArray(layout['sections'])) c.add(SitePlanIssueCode.Shape, `${path}.layout.sections`, 'must be an array');
626
+ });
627
+ if (composed > COMPOSED_PAGES_MAX) c.add(SitePlanIssueCode.Compose, 'pages', `${composed} composed pages — the home page and at most ${COMPOSED_PAGES_MAX - 1} other`);
628
+ }
629
+
576
630
  /** Throw a `SitePlanError` carrying every issue unless the plan is valid. */
577
631
  export function assertValidSitePlan(plan: unknown): void {
578
632
  const result = validateSitePlan(plan);
@@ -1,6 +1,8 @@
1
1
  import type { DesignChoices } from '@vectoriox/iox-ui/design-core';
2
2
  import type { FrameSequence } from '@vectoriox/iox-ui/media-core';
3
- import type { AiGenerationStage, AiRefusalCode, AiStep, PictureRefusal, PlanChange, PlanEdit, SitePlan } from '@vectoriox/iox-ui/generation-core';
3
+ import type {
4
+ AiGenerationStage, AiRefusalCode, AiStep, LayoutFingerprint, LayoutIssue, LayoutPhotoAddress, MeasuredLayout, PictureRefusal, PlanChange, PlanEdit, SitePlan,
5
+ } from '@vectoriox/iox-ui/generation-core';
4
6
 
5
7
  import type { StyleRead } from './rank';
6
8
  import type { SiteAnalysis } from './site-analysis';
@@ -111,6 +113,37 @@ export interface GenerationPicturesView {
111
113
  spent?: number;
112
114
  }
113
115
 
116
+ /** Where a composed page is (M8 gate 2): the Plan step's planning row and its card read it. */
117
+ export enum ComposedPageState {
118
+ /** Its layout is being asked (or asked again: a repair, Try another layout, a sentence). */
119
+ Composing = 'composing',
120
+ /** Its layout passed the static gate; the owner's browser measures it at laptop and phone width. */
121
+ Checking = 'checking',
122
+ Ready = 'ready',
123
+ /** Its layout did not pass after the one repair: the page is built from its sections (the card says so). */
124
+ Patterns = 'patterns',
125
+ }
126
+
127
+ /** One composed page of the plan — the layout itself is `plan.pages[k].layout`. */
128
+ export interface ComposedPageView {
129
+ page: string;
130
+ state: `${ComposedPageState}`;
131
+ /** Raised each time the page's layout changes (a repair, Try another layout, a sentence): the render check names it. */
132
+ version: number;
133
+ /** The card's checks line: the static gate, the laptop-and-phone check, unlike the studio's other sites. */
134
+ checks: { layout: boolean; render: boolean; unlike: boolean };
135
+ /** How many times the page was asked (1 = the first; Try another layout and a sentence each add one). A Home that fell
136
+ * back to sections is offered Try another layout while this is 1 — once (M8 gate 2 follow-up D3). */
137
+ round: number;
138
+ /** Repairs asked in this round: at most ONE, static or render (D2). */
139
+ repairs: number;
140
+ /** What made it fall back to sections, or what the last check found. */
141
+ issues?: LayoutIssue[];
142
+ fingerprint?: LayoutFingerprint;
143
+ /** The owner's sentence it was asked again with (Try another layout has none). */
144
+ ask?: string;
145
+ }
146
+
114
147
  export interface AiGenerationView {
115
148
  _id: string;
116
149
  organization: string;
@@ -141,6 +174,24 @@ export interface AiGenerationView {
141
174
  error?: { code: string; detail: string; providerMessage?: string; issues?: Array<{ code: string; path: string }> };
142
175
  /** M7: the pictures that may be made (on the Plan step) or are being made. Absent: no plan yet. */
143
176
  pictures?: GenerationPicturesView;
177
+ /** M8 gate 2: the plan's composed pages, in plan order. Absent: no plan yet, or none composed. */
178
+ composed?: ComposedPageView[];
179
+ /** M8 gate 2: what one more layout of a page costs (Try another layout), in credits — the server's figure. */
180
+ composeCredits?: number;
181
+ /** M8 gate 2: every photo id the layouts may name (`own:<n>`, `stock:<key>`), where it is kept and what it shows —
182
+ * what the Plan map and the in-browser render check draw them with. A `box:` id is never here. */
183
+ layoutPhotos?: Record<string, LayoutPhotoView>;
184
+ }
185
+
186
+ /** Where a layout's photo is kept, what it shows and its shape — what generation-core `composeContextOf` reads. */
187
+ export type LayoutPhotoView = LayoutPhotoAddress;
188
+
189
+ /** `POST …/ai/generations/:id/layout-check`: one composed page as the owner's browser laid it out (M8-G2-D8). */
190
+ export interface LayoutCheckRequest {
191
+ page: string;
192
+ /** The page's `version` it was measured on — a check of an older layout is dropped. */
193
+ version: number;
194
+ measured: MeasuredLayout[];
144
195
  }
145
196
 
146
197
  /** `POST …/ai/generations/:id/build` (and `/auto`). */
@@ -102,6 +102,9 @@ export interface ScrollLinkGeometry {
102
102
  distance: number;
103
103
  /** The height of the part of the page on screen. */
104
104
  viewHeight: number;
105
+ /** How far through its range the measured element stood when its page was at its top (0 when it was below the
106
+ * screen): where a depth rests (`parallaxRest`). */
107
+ opening: number;
105
108
  }
106
109
 
107
110
  interface LinkState {
@@ -289,7 +292,7 @@ export class ScrollDriver {
289
292
  * frame exactly where the scroll is, with no glide.
290
293
  */
291
294
  addLink(link: ScrollLink): () => void {
292
- const state: LinkState = { link, progress: 0, target: 0, fresh: true, geometry: { distance: 0, viewHeight: 0 } };
295
+ const state: LinkState = { link, progress: 0, target: 0, fresh: true, geometry: { distance: 0, viewHeight: 0, opening: 0 } };
293
296
  this.links.add(state);
294
297
  this.wake();
295
298
  return () => { this.links.delete(state); };
@@ -416,10 +419,19 @@ export class ScrollDriver {
416
419
  const { box, zoom } = layoutBoxOnScreen(state.link.measured, state.link.within ?? null);
417
420
  const z = zoom || 1;
418
421
  const target = rangeProgress(state.link.range, box, view);
419
- state.geometry = { distance: rangeDistance(state.link.range, box, view) / z, viewHeight: view.height / z };
422
+ state.geometry = { distance: rangeDistance(state.link.range, box, view) / z, viewHeight: view.height / z, opening: this.openingOf(state.link, box, view) };
420
423
  return { state, target };
421
424
  }
422
425
 
426
+ /** The link's progress with its page scrolled to the top: the page's top on the view's, the element where it stands in it. */
427
+ private openingOf(link: ScrollLink, box: ScrollBox, view: ScrollBox): number {
428
+ if (link.range === ScrollRange.Page) return 0;
429
+ const page = link.within ?? link.measured.ownerDocument?.documentElement ?? null;
430
+ if (!page) return 0;
431
+ const top = page.getBoundingClientRect().top;
432
+ return rangeProgress(link.range, { top: view.top + (box.top - top), height: box.height }, view);
433
+ }
434
+
423
435
  private read(scene: Scene): { scene: Scene; local: number; target: number } {
424
436
  const rect = scene.root.getBoundingClientRect();
425
437
  const origin = this.options.originOf?.(scene.root)?.getBoundingClientRect().top ?? 0;
@@ -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,17 +123,38 @@ 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;
118
131
  }
119
132
 
133
+ /** Halfway through its range: where a depth stands in its place when the page opens with it out of sight. */
134
+ export const PARALLAX_REST_DEFAULT = 0.5;
135
+
136
+ /**
137
+ * Where in its range a depth stands exactly in its place (iox-ui#65). A layer the page opens with on screen rests where it
138
+ * stands then — `opening`, its progress at the page's top — so the first screen is drawn as it was laid out and the glide
139
+ * starts with the scroll; one out of sight rests halfway. (Resting halfway, a hero paragraph at 664 of a 900px screen
140
+ * stood 74px low at the top of the page and ran under its buttons.)
141
+ */
142
+ export function parallaxRest(opening: number): number {
143
+ return opening > 0 && opening < 1 ? Math.round(opening * 1000) / 1000 : PARALLAX_REST_DEFAULT;
144
+ }
145
+
146
+ /** How far a depth stands off its place at `progress` through its range, in px (down is positive): 0 at `rest`, moving
147
+ * at the same speed as ever — `shift` each way of a half range. */
148
+ export function parallaxOffset(depth: ParallaxDepth, shift: number, progress: number, rest: number = PARALLAX_REST_DEFAULT): number {
149
+ const sign = depth === ParallaxDepth.Front ? -1 : 1;
150
+ return 2 * sign * shift * (progress - rest);
151
+ }
152
+
120
153
  /** The frames of a parallax depth over its range: the individual `translate` property, so the element's own `transform`
121
154
  * (a hover lift, an entrance) is never overwritten. */
122
- export function parallaxFrames(depth: ParallaxDepth, shift: number): Array<Record<string, string>> {
123
- const sign = depth === ParallaxDepth.Front ? -1 : 1;
124
- return [{ translate: `0 ${-sign * shift}px` }, { translate: `0 ${sign * shift}px` }];
155
+ export function parallaxFrames(depth: ParallaxDepth, shift: number, rest: number = PARALLAX_REST_DEFAULT): Array<Record<string, string>> {
156
+ const px = (v: number) => `0 ${Math.round(v * 10) / 10 || 0}px`;
157
+ return [{ translate: px(parallaxOffset(depth, shift, 0, rest)) }, { translate: px(parallaxOffset(depth, shift, 1, rest)) }];
125
158
  }
126
159
 
127
160
  /** A bar that fills along the reading direction: the individual `scale` property, from its reading start (iox-design.css). */
@@ -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 {
@@ -390,6 +390,10 @@ dialog.iox-cal[data-iox-instant]::backdrop { transition: none !important; }
390
390
  outline: 2px solid transparent;
391
391
  outline-offset: 2px;
392
392
  }
393
+ .iox-es-field .iox-field__control:where(input:not([type='checkbox'], [type='radio'], [type='range']), textarea, select) {
394
+ inline-size: 100%;
395
+ box-sizing: border-box;
396
+ }
393
397
  .iox-es-field .iox-field__label {
394
398
  font-family: var(--iox-font-body);
395
399
  font-size: var(--iox-field-label-size);