@vectoriox/iox-ui 5.87.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.
Files changed (38) hide show
  1. package/actions-core/index.d.ts +17 -3
  2. package/composite-core/index.d.ts +208 -2
  3. package/design-core/index.d.ts +373 -1
  4. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +30 -4
  5. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +659 -118
  7. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-design-core.mjs +444 -3
  9. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1082 -51
  11. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  12. package/fesm2022/vectoriox-iox-ui-scene-core.mjs +244 -7
  13. package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
  14. package/fesm2022/vectoriox-iox-ui.mjs +604 -20
  15. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  16. package/generation-core/index.d.ts +375 -2
  17. package/index.d.ts +196 -2
  18. package/package.json +1 -1
  19. package/scene-core/index.d.ts +167 -2
  20. package/src/actions-core/action.model.ts +3 -0
  21. package/src/actions-core/element-actions.ts +32 -3
  22. package/src/composite-core/marquee-runtime.ts +255 -0
  23. package/src/composite-core/marquee.ts +267 -0
  24. package/src/composite-core/public-api.ts +3 -0
  25. package/src/composite-core/scroll-recipes.ts +74 -0
  26. package/src/composite-core/slider.ts +3 -2
  27. package/src/composite-core/structure.ts +7 -0
  28. package/src/design-core/contrast-audit.ts +6 -1
  29. package/src/design-core/flavor-spec.generated.ts +435 -1
  30. package/src/generation-core/compose-layout.ts +821 -0
  31. package/src/generation-core/compose-site.ts +14 -2
  32. package/src/generation-core/layout-language.ts +354 -0
  33. package/src/generation-core/node-baselines.generated.ts +5 -1
  34. package/src/generation-core/public-api.ts +2 -0
  35. package/src/scene-core/public-api.ts +1 -0
  36. package/src/scene-core/scroll-driver.ts +98 -0
  37. package/src/scene-core/scroll-range.ts +208 -0
  38. package/styles/iox-design.css +66 -1
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Scroll-driven motion outside a Scene (premium components M6, N7 — Motion v2 V1). An element plays its actions by WHERE
3
+ * it stands in the page, not by time: a fade that follows the scroll, a layer that glides at its own depth, a bar that
4
+ * fills as the page is read. Every one of them rides the ONE `ScrollDriver` (its links), never a loop of its own.
5
+ *
6
+ * The ranges are CSS's named view-timeline ranges, so a `view()` timeline could take them over 1:1, plus the whole page
7
+ * (a reading-progress bar). The maths is pure: geometry in, progress out, the same at any canvas zoom because every length
8
+ * is in one space.
9
+ */
10
+
11
+ export enum ScrollRange {
12
+ /** From the element's top edge at the bottom of the screen until it is wholly in (CSS `entry`). */
13
+ Enter = 'enter',
14
+ /** From the moment it starts to come in until it has wholly left (CSS `cover`). */
15
+ Cover = 'cover',
16
+ /** While it is wholly in view, or, when it is taller than the screen, while it fills it (CSS `contain`). */
17
+ Contain = 'contain',
18
+ /** From the moment it starts to leave until it has gone (CSS `exit`). */
19
+ Exit = 'exit',
20
+ /** The section the element stands in, while it is read: Contain, measured on the section (a section's reading bar). */
21
+ Section = 'section',
22
+ /** The whole page, from its top to its bottom: how much of it has been read. */
23
+ Page = 'page',
24
+ }
25
+
26
+ export const SCROLL_RANGE_DEFAULT = ScrollRange.Cover;
27
+
28
+ const RANGES: ReadonlySet<string> = new Set(Object.values(ScrollRange));
29
+
30
+ /** The node element that holds `el` outermost — its section on the page — stopping below `stop`. A node element is one
31
+ * carrying its `iox-node-<id>` class, in every render path; a wrapper a renderer drew around nodes is never one. */
32
+ export function outermostNodeOf(el: Element, stop: Element | null = null): HTMLElement {
33
+ let found = el as HTMLElement;
34
+ for (let p = el.parentElement; p && p !== stop; p = p.parentElement) {
35
+ if (Array.from(p.classList).some(c => c.startsWith('iox-node-'))) found = p;
36
+ }
37
+ return found;
38
+ }
39
+
40
+ /** A saved range, or the default for anything else. */
41
+ export function normalizeScrollRange(value: unknown): ScrollRange {
42
+ return typeof value === 'string' && RANGES.has(value) ? (value as ScrollRange) : SCROLL_RANGE_DEFAULT;
43
+ }
44
+
45
+ /** A box along the scroll axis: its top and its height, in the same space as the view's. */
46
+ export interface ScrollBox {
47
+ top: number;
48
+ height: number;
49
+ }
50
+
51
+ const clamp01 = (v: number): number => Math.min(1, Math.max(0, v));
52
+
53
+ /** Where a range starts and ends, as the element's top relative to the view's top. */
54
+ export function rangeEnds(range: ScrollRange, box: ScrollBox, view: ScrollBox): { start: number; end: number } {
55
+ const vh = view.height;
56
+ const h = box.height;
57
+ const fit = vh - h;
58
+ switch (range) {
59
+ case ScrollRange.Enter: return { start: vh, end: Math.max(fit, 0) };
60
+ case ScrollRange.Contain:
61
+ case ScrollRange.Section: return { start: Math.max(fit, 0), end: Math.min(fit, 0) };
62
+ case ScrollRange.Exit: return { start: Math.min(fit, 0), end: -h };
63
+ default: return { start: vh, end: -h };
64
+ }
65
+ }
66
+
67
+ /** How far the scroll travels through a range, in the box's space: what a parallax depth is a share of. */
68
+ export function rangeDistance(range: ScrollRange, box: ScrollBox, view: ScrollBox): number {
69
+ if (range === ScrollRange.Page) return Math.max(0, box.height - view.height);
70
+ const { start, end } = rangeEnds(range, box, view);
71
+ return Math.abs(start - end);
72
+ }
73
+
74
+ /**
75
+ * How far `box` has come through `range` of `view`, 0–1. For `Page`, `box` is the page itself: 0 at its top, 1 once its
76
+ * bottom reaches the bottom of the view. A range of no length is a step: 0 before it, 1 from it on.
77
+ */
78
+ export function rangeProgress(range: ScrollRange, box: ScrollBox, view: ScrollBox): number {
79
+ if (range === ScrollRange.Page) {
80
+ const travel = box.height - view.height;
81
+ return travel > 0 ? clamp01((view.top - box.top) / travel) : 0;
82
+ }
83
+ const { start, end } = rangeEnds(range, box, view);
84
+ const t = box.top - view.top;
85
+ if (start === end) return t <= start ? 1 : 0;
86
+ return clamp01((start - t) / (start - end));
87
+ }
88
+
89
+ /**
90
+ * The parallax trio (round three's back · middle · front). Middle is the page's own speed, so it is no action at all.
91
+ * Back glides slower than the page, front faster: a share of the scroll it travels through.
92
+ */
93
+ export enum ParallaxDepth {
94
+ Back = 'back',
95
+ Front = 'front',
96
+ }
97
+
98
+ export const PARALLAX_DEPTH_DEFAULT = ParallaxDepth.Back;
99
+
100
+ /** The share of the scroll a depth moves against the page. Round three moved its layers by about this much. */
101
+ export const PARALLAX_SPEED = 0.3;
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
+ export const PARALLAX_PHONE_FACTOR = 0.5;
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
+
117
+ export function normalizeParallaxDepth(value: unknown): ParallaxDepth {
118
+ return value === ParallaxDepth.Front ? ParallaxDepth.Front : PARALLAX_DEPTH_DEFAULT;
119
+ }
120
+
121
+ /**
122
+ * How far a layer stands off its place at each end of its range, in the box's px: it runs from `-shift` to `+shift`
123
+ * (back) or the other way (front), and stands exactly in its place halfway. Never more than the share of one screen, so
124
+ * a tall layer never slides a screen away from what it belongs to.
125
+ */
126
+ export function parallaxShift(distance: number, viewHeight: number, options: { phone?: boolean; onPhone?: ParallaxPhone } = {}): number {
127
+ if (options.phone && options.onPhone === ParallaxPhone.Rest) return 0;
128
+ const speed = PARALLAX_SPEED * (options.phone ? PARALLAX_PHONE_FACTOR : 1);
129
+ const shift = speed * Math.min(Math.max(0, distance) / 2, Math.max(0, viewHeight));
130
+ return Math.round(shift * 10) / 10;
131
+ }
132
+
133
+ /** The frames of a parallax depth over its range: the individual `translate` property, so the element's own `transform`
134
+ * (a hover lift, an entrance) is never overwritten. */
135
+ export function parallaxFrames(depth: ParallaxDepth, shift: number): Array<Record<string, string>> {
136
+ const sign = depth === ParallaxDepth.Front ? -1 : 1;
137
+ return [{ translate: `0 ${-sign * shift}px` }, { translate: `0 ${sign * shift}px` }];
138
+ }
139
+
140
+ /** A bar that fills along the reading direction: the individual `scale` property, from its reading start (iox-design.css). */
141
+ export const PROGRESS_BAR_FRAMES: ReadonlyArray<Record<string, string>> = Object.freeze([{ scale: '0 1' }, { scale: '1 1' }]);
142
+
143
+ /** What a scroll-driven action is, for what each visitor gets of it (`scrollPlayFor`). */
144
+ export enum ScrollActionKind {
145
+ /** A glide at a depth: pure decoration. */
146
+ Parallax = 'parallax',
147
+ /** How much has been read: information, tied to the visitor's own scroll. */
148
+ Progress = 'progress',
149
+ /** Any entrance or exit, played by the scroll instead of the clock. */
150
+ Scrub = 'scrub',
151
+ }
152
+
153
+ /** What a visitor gets of one scroll-driven action. */
154
+ export enum ScrollPlay {
155
+ /** All of it. */
156
+ Full = 'full',
157
+ /** Its opacity only: no movement (reduced motion, Emil 192: gentler, not zero). */
158
+ Gentle = 'gentle',
159
+ /** Nothing: the element stands as it is, where it is. */
160
+ Rest = 'rest',
161
+ }
162
+
163
+ export interface ScrollMotionEnv {
164
+ reducedMotion: boolean;
165
+ /** Save-Data, or a device that says it has little memory (`lightMotionWanted`). */
166
+ light: boolean;
167
+ }
168
+
169
+ const PLAY: Readonly<Record<ScrollActionKind, { reduced: ScrollPlay; light: ScrollPlay }>> = {
170
+ // Decoration goes first: reduced motion and a light device keep the layer in its place.
171
+ [ScrollActionKind.Parallax]: { reduced: ScrollPlay.Rest, light: ScrollPlay.Rest },
172
+ // A reading bar is the visitor's own scroll drawn: it stays, and under reduced motion it follows with no glide.
173
+ [ScrollActionKind.Progress]: { reduced: ScrollPlay.Full, light: ScrollPlay.Full },
174
+ // A scrubbed fade keeps its fade under reduced motion; a light device sees the element as it rests.
175
+ [ScrollActionKind.Scrub]: { reduced: ScrollPlay.Gentle, light: ScrollPlay.Rest },
176
+ };
177
+
178
+ /** THE degrade (motion-v2 §3d/§3e): one table, read by the canvas and both engine paths. */
179
+ export function scrollPlayFor(kind: ScrollActionKind, env: ScrollMotionEnv): ScrollPlay {
180
+ if (env.reducedMotion) return PLAY[kind].reduced;
181
+ if (env.light) return PLAY[kind].light;
182
+ return ScrollPlay.Full;
183
+ }
184
+
185
+ /** Properties a Gentle play keeps: what changes colour or opacity, never place. */
186
+ const GENTLE_PROPERTIES: ReadonlySet<string> = new Set(['opacity', 'color', 'backgroundColor', 'offset', 'easing']);
187
+
188
+ /** A frame list cut down to what a Gentle play keeps; empty when nothing is left to play. */
189
+ export function gentleFrames<T extends Record<string, unknown>>(frames: ReadonlyArray<T>): T[] {
190
+ const cut = frames.map(frame => Object.fromEntries(Object.entries(frame).filter(([key]) => GENTLE_PROPERTIES.has(key))) as T);
191
+ return cut.some(frame => Object.keys(frame).some(key => key !== 'offset' && key !== 'easing')) ? cut : [];
192
+ }
193
+
194
+ interface LightHost {
195
+ navigator?: Navigator & { connection?: { saveData?: boolean }; deviceMemory?: number };
196
+ }
197
+
198
+ /** The least memory a device may report before decoration stays still. Not `hardwareConcurrency`: Safari caps it, and an
199
+ * iPhone would read as a weak device. */
200
+ const LIGHT_DEVICE_MEMORY_GB = 2;
201
+
202
+ /** True when the visitor asked to save data, or the device reports little memory: scrubs and depths rest. */
203
+ export function lightMotionWanted(host: LightHost | null | undefined = typeof window !== 'undefined' ? window : null): boolean {
204
+ const nav = host?.navigator;
205
+ if (!nav) return false;
206
+ if (nav.connection?.saveData) return true;
207
+ return typeof nav.deviceMemory === 'number' && nav.deviceMemory <= LIGHT_DEVICE_MEMORY_GB;
208
+ }
@@ -642,7 +642,7 @@ span.iox-video__play { pointer-events: none; }
642
642
 
643
643
  /* ── Premium components M4 (Emil 55/85): a press lands faster than its release ──────────────────────────────────────
644
644
  While pressed, every pressable's transition runs on dur-press; it releases on its own (slower) dur-fast. */
645
- :is(.iox-es-button-primary, .iox-es-button-secondary, .iox-es-button-ghost, .iox-es-bottom-bar-item):active {
645
+ :is(.iox-es-button-primary, .iox-es-button-secondary, .iox-es-button-ghost, .iox-es-bottom-bar-item, .iox-es-marquee-control):active {
646
646
  transition-duration: var(--iox-dur-press, 100ms);
647
647
  }
648
648
 
@@ -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 {
@@ -918,3 +935,51 @@ html:has(.iox-bar-reserve) .iox-toasts[data-iox-edge='bottom'] { bottom: calc(16
918
935
  @starting-style { [data-iox-popover][popover][data-iox-sheet][data-iox-sheet]:popover-open { opacity: 0; translate: none; } }
919
936
  [data-iox-popover][popover][data-iox-sheet][data-iox-sheet][data-iox-closing] { opacity: 0; translate: none; }
920
937
  }
938
+
939
+ /* ── Premium components M6 — a number that counts (N5), the Marquee (N6), scroll-driven motion outside a Scene (N7) ──
940
+ A number a count plays on is tabular from the first paint (Emil 176), so its box never changes width when the count
941
+ starts or ends. */
942
+ [data-iox-count] { font-variant-numeric: tabular-nums; }
943
+
944
+ /* The reading bar: empty until the scroll fills it (a visitor with no script sees no bar, never a full one), filling from
945
+ its reading start by `scale` — never a width (Emil 41). The runtime turns the origin for a right-to-left page (it reads
946
+ the computed direction: a live page's RTL is CSS `direction`, never a `dir` attribute `:dir()` could see). */
947
+ [data-iox-progress] { scale: 0 1; transform-origin: 0 50%; }
948
+
949
+ /* A section holding a layer at a depth clips vertically: a glide never carries a layer onto the next section's ground
950
+ (round three, M1). `clip`, not `hidden`: no scroll container, so a sticky child still sticks. */
951
+ [data-iox-depth-clip] { overflow-y: clip; }
952
+
953
+ /* The Marquee: ONE linear loop (Emil 180) on the track and its copy, both started by the runtime's Running in the same
954
+ style pass, so they never drift. `translate`, so a hover lift on an item is never overwritten; the duration — and, in a
955
+ right-to-left band, the mirrored keyframes — are the runtime's, written on each track (it reads the computed direction). */
956
+ @keyframes iox-marquee { from { translate: 0 0; } to { translate: -100% 0; } }
957
+ @keyframes iox-marquee-rtl { from { translate: 0 0; } to { translate: 100% 0; } }
958
+ [data-iox-marquee-running] .iox-role-marquee-track { animation: iox-marquee 30s linear infinite; }
959
+ [data-iox-marquee-running][data-iox-marquee-direction="end"] .iox-role-marquee-track { animation-direction: reverse; }
960
+ /* Held: the visitor paused it, it is off screen or the tab is hidden; and while focus is on an item inside. */
961
+ [data-iox-marquee-paused] .iox-role-marquee-track,
962
+ [data-iox-marquee] .iox-role-marquee-rail:focus-within .iox-role-marquee-track { animation-play-state: paused; }
963
+ @media (hover: hover) and (pointer: fine) {
964
+ [data-iox-marquee-hover] .iox-role-marquee-rail:hover .iox-role-marquee-track { animation-play-state: paused; }
965
+ }
966
+ /* Its edges fade on an eased curve (Emil 174), so the words arrive and leave with no visible edge. */
967
+ [data-iox-marquee-fade] .iox-role-marquee-rail {
968
+ --marquee-edge: var(--iox-marquee-fade, 48px);
969
+ mask-image: linear-gradient(to right,
970
+ rgb(0 0 0 / 0) 0, rgb(0 0 0 / 0.2) calc(var(--marquee-edge) * 0.35), rgb(0 0 0 / 0.6) calc(var(--marquee-edge) * 0.7),
971
+ rgb(0 0 0) var(--marquee-edge), rgb(0 0 0) calc(100% - var(--marquee-edge)),
972
+ rgb(0 0 0 / 0.6) calc(100% - var(--marquee-edge) * 0.7), rgb(0 0 0 / 0.2) calc(100% - var(--marquee-edge) * 0.35), rgb(0 0 0 / 0) 100%);
973
+ }
974
+ /* Still for good (a look whose motion is Off): nothing moves, so there is nothing to pause. */
975
+ [data-iox-marquee-still] .iox-role-marquee-pause { display: none; }
976
+ /* Reduced motion (D5): the band stops completely and wraps into a still row, from the first paint; its control goes.
977
+ The canvas keeps the control, so the author can still select and style it. */
978
+ @media (prefers-reduced-motion: reduce) {
979
+ [data-iox-marquee] .iox-role-marquee-track {
980
+ animation: none !important; flex-wrap: wrap !important; justify-content: center !important;
981
+ flex-shrink: 1 !important; width: 100% !important; padding-inline-end: 0 !important;
982
+ }
983
+ [data-iox-marquee] .iox-role-marquee-rail { mask-image: none; }
984
+ [data-iox-marquee]:not(#canvas-preview *, .global-elements-overlay *) .iox-role-marquee-pause { display: none; }
985
+ }