@vectoriox/iox-ui 5.161.0 → 5.163.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.
- package/actions-core/index.d.ts +171 -3
- package/assist-core/index.d.ts +3 -2
- package/composite-core/index.d.ts +185 -2
- package/design-core/index.d.ts +130 -0
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +243 -2
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -5
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +404 -163
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +152 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +302 -10
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +140 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +306 -48
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +383 -10
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +243 -6
- package/harness-core/index.d.ts +132 -2
- package/index.d.ts +105 -3
- package/package.json +1 -1
- package/scene-core/index.d.ts +130 -10
- package/src/actions-core/popup-arrival.ts +328 -0
- package/src/actions-core/public-api.ts +1 -0
- package/src/assist-core/media-generate.ts +6 -5
- package/src/composite-core/popup.ts +285 -0
- package/src/composite-core/public-api.ts +1 -0
- package/src/design-core/flavor-spec.generated.ts +152 -1
- package/src/generation-core/ai-run.ts +65 -2
- package/src/generation-core/compose-layout.ts +11 -5
- package/src/generation-core/pictures.ts +4 -3
- package/src/generation-core/site-spec.generated.ts +235 -0
- package/src/harness-core/business-types.ts +2 -0
- package/src/harness-core/harness-spec.generated.ts +83 -0
- package/src/harness-core/popup-stance.ts +111 -0
- package/src/harness-core/public-api.ts +1 -0
- package/src/scene-core/scene-edit.ts +12 -8
- package/src/scene-core/scene.ts +131 -21
- package/src/scene-core/scroll-driver.ts +209 -23
- package/styles/iox-design.css +121 -2
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { CompositeNode, CompositeNodeFactory, writeProp } from './composite-node';
|
|
2
|
+
import { COLUMN, recipeLang, recipePart, recipeText, ROW, WORDS, ZERO } from './recipe-parts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* THE POPUP (popups-plan.md, PU1; PU-D1…PU-D18) — the owner's own news, arriving once, as ordinary builder nodes. A popup
|
|
6
|
+
* is a Dialog stamped from this ONE recipe (PU-D1): the builder's palette (PU2) and generation-core's composer (PU3) stamp
|
|
7
|
+
* it with their own node factories, so a generated popup and a hand-placed one are the same tree.
|
|
8
|
+
*
|
|
9
|
+
* Popup Dialog popup (kind · form · arrive · again · dates — the popup traits below)
|
|
10
|
+
* › Container popup.media? Image (the owner's picture) — `art: picture`
|
|
11
|
+
* › Container popup.content
|
|
12
|
+
* Text popup.eyebrow? (only from a date the owner gave)
|
|
13
|
+
* Heading popup.title (h2, worn as the look's h3 — its smallest heading style)
|
|
14
|
+
* Text popup.body (≤ 160 characters)
|
|
15
|
+
* <form> popup.form? (newsletter: the caller's forms-core newsletter preset)
|
|
16
|
+
* Link popup.action? (ONE quiet action — a page link; a form's Send is its own)
|
|
17
|
+
* › the Dialog's own ✕ (44 × 44, named in the site's language by the runtime)
|
|
18
|
+
*
|
|
19
|
+
* Its LOOK is the site's element styles (dialog, h4, small, link) — never a colour. Its words are the OWNER's (title, body,
|
|
20
|
+
* eyebrow, the action's label), passed in; the recipe's own words are mechanism microcopy only ("Close", "Send").
|
|
21
|
+
* Framework-free: no actions-core import (actions-core reads this module, never the other way).
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export enum PopupRole {
|
|
25
|
+
Popup = 'popup',
|
|
26
|
+
Media = 'popup.media',
|
|
27
|
+
Content = 'popup.content',
|
|
28
|
+
Eyebrow = 'popup.eyebrow',
|
|
29
|
+
Title = 'popup.title',
|
|
30
|
+
Body = 'popup.body',
|
|
31
|
+
Form = 'popup.form',
|
|
32
|
+
Action = 'popup.action',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const POPUP_ROLES: ReadonlySet<string> = new Set(Object.values(PopupRole));
|
|
36
|
+
|
|
37
|
+
/** PU-D3: what the popup says (contract POPUP `kind`). Seasonal is not a kind — it is dates on any kind. */
|
|
38
|
+
export enum PopupKind {
|
|
39
|
+
Announcement = 'announcement',
|
|
40
|
+
Offer = 'offer',
|
|
41
|
+
Newsletter = 'newsletter',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** §3b: where it sits (contract POPUP `form`). Only `centred` is modal, and only a newsletter's on a laptop. */
|
|
45
|
+
export enum PopupForm {
|
|
46
|
+
Corner = 'corner',
|
|
47
|
+
Bar = 'bar',
|
|
48
|
+
Centred = 'centred',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** PU-D5: what makes it arrive (contract POPUP `arrive`). `leaving` waits for PU2b (drawn as `time`). */
|
|
52
|
+
export enum PopupArrive {
|
|
53
|
+
Scroll = 'scroll',
|
|
54
|
+
Time = 'time',
|
|
55
|
+
ScrollOrTime = 'scrollOrTime',
|
|
56
|
+
Leaving = 'leaving',
|
|
57
|
+
Button = 'button',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** PU-D6: when it may show again after a close (contract POPUP `again`). "Every page view" is refused. */
|
|
61
|
+
export enum PopupAgain {
|
|
62
|
+
Days = 'days',
|
|
63
|
+
Visit = 'visit',
|
|
64
|
+
Once = 'once',
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The contract's `art`. */
|
|
68
|
+
export enum PopupArt {
|
|
69
|
+
None = 'none',
|
|
70
|
+
Picture = 'picture',
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The Dialog traits a popup carries (Bindings ▸ Popup, PU2). Like the menu traits (HI2a) they have NO default: a Dialog
|
|
75
|
+
* without `popupKind` is not a popup and renders exactly as before (R-H4). `modal` is the one Dialog trait the popup
|
|
76
|
+
* adds for every Dialog: absent = modal, so every existing Dialog keeps `showModal()`.
|
|
77
|
+
*/
|
|
78
|
+
export enum PopupTrait {
|
|
79
|
+
Kind = 'popupKind',
|
|
80
|
+
Form = 'popupForm',
|
|
81
|
+
Arrive = 'popupArrive',
|
|
82
|
+
/** `scroll`: the share of the FIRST screen scrolled (default 0.5). */
|
|
83
|
+
Screens = 'popupScreens',
|
|
84
|
+
/** `scroll`: the share of the whole PAGE scrolled instead (a newsletter's 40%). */
|
|
85
|
+
PageShare = 'popupPageShare',
|
|
86
|
+
/** `time`: seconds on the page (visible tab), never under 3. */
|
|
87
|
+
Seconds = 'popupSeconds',
|
|
88
|
+
Again = 'popupAgain',
|
|
89
|
+
/** `again: days`: how many (default 30). */
|
|
90
|
+
Days = 'popupDays',
|
|
91
|
+
/** PU-D18: whole days, `YYYY-MM-DD`, on the visitor's clock. */
|
|
92
|
+
ShowFrom = 'popupFrom',
|
|
93
|
+
ShowUntil = 'popupUntil',
|
|
94
|
+
/** "Show it again to everyone" raises it; a remembered close of an older version is forgotten. */
|
|
95
|
+
Version = 'popupVersion',
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A Dialog's own trait: false = non-modal (`showPopover()`, the page stays usable). Absent = modal (as ever). */
|
|
99
|
+
export const DIALOG_MODAL_TRAIT = 'modal';
|
|
100
|
+
|
|
101
|
+
/** The attributes a popup renders on its `<dialog>` — read by the shared CSS (placement, motion) and the popup runtime. */
|
|
102
|
+
export enum PopupAttribute {
|
|
103
|
+
Kind = 'data-iox-popup',
|
|
104
|
+
Form = 'data-iox-popup-form',
|
|
105
|
+
Arrive = 'data-iox-popup-arrive',
|
|
106
|
+
Screens = 'data-iox-popup-screens',
|
|
107
|
+
PageShare = 'data-iox-popup-page',
|
|
108
|
+
Seconds = 'data-iox-popup-seconds',
|
|
109
|
+
Again = 'data-iox-popup-again',
|
|
110
|
+
Days = 'data-iox-popup-days',
|
|
111
|
+
ShowFrom = 'data-iox-popup-from',
|
|
112
|
+
ShowUntil = 'data-iox-popup-until',
|
|
113
|
+
Version = 'data-iox-popup-version',
|
|
114
|
+
/** A non-modal Dialog (a popup's corner / bar, or `modal: false`): opened with `showPopover()`. */
|
|
115
|
+
NonModal = 'data-iox-dialog-nonmodal',
|
|
116
|
+
/** §8 / R-H8: its words never become the page's search snippet. */
|
|
117
|
+
NoSnippet = 'data-nosnippet',
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const POPUP_ATTRIBUTES: ReadonlyArray<string> = Object.values(PopupAttribute);
|
|
121
|
+
|
|
122
|
+
const TRAIT_ATTRIBUTE: ReadonlyArray<readonly [PopupTrait, PopupAttribute]> = [
|
|
123
|
+
[PopupTrait.Arrive, PopupAttribute.Arrive], [PopupTrait.Screens, PopupAttribute.Screens], [PopupTrait.PageShare, PopupAttribute.PageShare],
|
|
124
|
+
[PopupTrait.Seconds, PopupAttribute.Seconds], [PopupTrait.Again, PopupAttribute.Again], [PopupTrait.Days, PopupAttribute.Days],
|
|
125
|
+
[PopupTrait.ShowFrom, PopupAttribute.ShowFrom], [PopupTrait.ShowUntil, PopupAttribute.ShowUntil], [PopupTrait.Version, PopupAttribute.Version],
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
const inEnum = <E extends Record<string, string>>(e: E, v: unknown): v is E[keyof E] => typeof v === 'string' && (Object.values(e) as string[]).includes(v);
|
|
129
|
+
const isOff = (v: unknown) => v === false || v === 'false';
|
|
130
|
+
const text = (v: unknown): string => (typeof v === 'number' && Number.isFinite(v) ? String(v) : typeof v === 'string' ? v.trim() : '');
|
|
131
|
+
|
|
132
|
+
/** A popup's form, judged: `centred` only for a newsletter (PU-D2) — any other kind asking for it sits in the corner. */
|
|
133
|
+
export function popupFormOf(kind: unknown, form: unknown): PopupForm {
|
|
134
|
+
const f = inEnum(PopupForm, form) ? form : POPUP_KIND_MIX[inEnum(PopupKind, kind) ? kind : PopupKind.Offer].form;
|
|
135
|
+
return f === PopupForm.Centred && kind !== PopupKind.Newsletter ? PopupForm.Corner : f;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** True when a Dialog opens as a modal: a popup only when its form is `centred`; any other Dialog unless `modal: false`. */
|
|
139
|
+
export function dialogIsModal(get: (name: string) => unknown): boolean {
|
|
140
|
+
const kind = get(PopupTrait.Kind);
|
|
141
|
+
if (inEnum(PopupKind, kind)) return popupFormOf(kind, get(PopupTrait.Form)) === PopupForm.Centred;
|
|
142
|
+
return !isOff(get(DIALOG_MODAL_TRAIT));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The attributes a Dialog renders for the popup and the non-modal opening — ONE function, applied by every renderer
|
|
147
|
+
* through `nodeA11yAttributes` (the engine's string path, its component path, the builder canvas). A plain modal Dialog
|
|
148
|
+
* gets `{}` and renders exactly as before.
|
|
149
|
+
*/
|
|
150
|
+
export function popupDialogAttributes(get: (name: string) => unknown): Record<string, string> {
|
|
151
|
+
const out: Record<string, string> = {};
|
|
152
|
+
if (!dialogIsModal(get)) out[PopupAttribute.NonModal] = '';
|
|
153
|
+
const kind = get(PopupTrait.Kind);
|
|
154
|
+
if (!inEnum(PopupKind, kind)) return out;
|
|
155
|
+
out[PopupAttribute.Kind] = kind;
|
|
156
|
+
out[PopupAttribute.Form] = popupFormOf(kind, get(PopupTrait.Form));
|
|
157
|
+
out[PopupAttribute.NoSnippet] = '';
|
|
158
|
+
for (const [trait, attr] of TRAIT_ATTRIBUTE) {
|
|
159
|
+
const v = text(get(trait));
|
|
160
|
+
if (v) out[attr] = v;
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** §3a + PU-D6: each kind's defaults (contract POPUP `named` — generation-core's spec holds them equal). */
|
|
166
|
+
export const POPUP_KIND_MIX: Readonly<Record<PopupKind, { form: PopupForm; arrive: PopupArrive; again: PopupAgain; art: PopupArt }>> = {
|
|
167
|
+
[PopupKind.Announcement]: { form: PopupForm.Bar, arrive: PopupArrive.Scroll, again: PopupAgain.Visit, art: PopupArt.None },
|
|
168
|
+
[PopupKind.Offer]: { form: PopupForm.Corner, arrive: PopupArrive.ScrollOrTime, again: PopupAgain.Days, art: PopupArt.Picture },
|
|
169
|
+
[PopupKind.Newsletter]: { form: PopupForm.Corner, arrive: PopupArrive.ScrollOrTime, again: PopupAgain.Days, art: PopupArt.None },
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/** §3a: when each kind arrives by default (contract POPUP `arrival`). */
|
|
173
|
+
export const POPUP_KIND_ARRIVAL: Readonly<Record<PopupKind, { screens?: number; pageShare?: number; seconds?: number }>> = {
|
|
174
|
+
[PopupKind.Announcement]: { screens: 0.5 },
|
|
175
|
+
[PopupKind.Offer]: { screens: 0.5, seconds: 8 },
|
|
176
|
+
[PopupKind.Newsletter]: { pageShare: 0.4, seconds: 25 },
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/** The recipe's OWN words — mechanism microcopy, in the site's language. The rest is the owner's. */
|
|
180
|
+
const POPUP_WORDS = {
|
|
181
|
+
en: { close: 'Close', send: 'Send', label: { [PopupKind.Announcement]: 'Announcement', [PopupKind.Offer]: 'Offer', [PopupKind.Newsletter]: 'Newsletter' } },
|
|
182
|
+
he: { close: 'סגירה', send: 'שליחה', label: { [PopupKind.Announcement]: 'הודעה', [PopupKind.Offer]: 'הצעה', [PopupKind.Newsletter]: 'ניוזלטר' } },
|
|
183
|
+
} as const;
|
|
184
|
+
|
|
185
|
+
export type PopupWords = (typeof POPUP_WORDS)['en'] | (typeof POPUP_WORDS)['he'];
|
|
186
|
+
|
|
187
|
+
/** The popup's mechanism words in `lang` (English for any language it does not speak yet). */
|
|
188
|
+
export function popupWords(lang: string | null | undefined = 'en'): PopupWords {
|
|
189
|
+
return POPUP_WORDS[recipeLang(lang)];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
enum Style {
|
|
193
|
+
Dialog = 'dialog',
|
|
194
|
+
/** The look's smallest heading style (there is no h4 element style): the plan's "h4-sized" title. */
|
|
195
|
+
Title = 'h3',
|
|
196
|
+
Body = 'small',
|
|
197
|
+
Eyebrow = 'eyebrow',
|
|
198
|
+
Link = 'link',
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** §6: a heading of at most this many words; a body of at most this many characters (the gate judges stored ones). */
|
|
202
|
+
export const POPUP_TITLE_MAX_WORDS = 6;
|
|
203
|
+
export const POPUP_BODY_MAX_CHARS = 160;
|
|
204
|
+
|
|
205
|
+
export interface PopupRecipeOptions {
|
|
206
|
+
kind?: PopupKind;
|
|
207
|
+
/** The site's language — the ✕'s name and the Dialog's label fall back to it. */
|
|
208
|
+
lang?: string | null;
|
|
209
|
+
/** The owner's words. Empty words stay empty (the Publishable gate blocks an empty title — never invented). */
|
|
210
|
+
title?: string;
|
|
211
|
+
body?: string;
|
|
212
|
+
/** Only from a date the owner gave ("Until 30 November"). */
|
|
213
|
+
eyebrow?: string;
|
|
214
|
+
/** The ONE action: a link to a page of the site, with its words. No route = no action (an announcement may have none). */
|
|
215
|
+
actionLabel?: string;
|
|
216
|
+
actionRoute?: string | null;
|
|
217
|
+
/** The owner's picture (`art: picture`); '' = the DS3 empty-image box ("Add image"). */
|
|
218
|
+
imageSrc?: string;
|
|
219
|
+
imageAlt?: string;
|
|
220
|
+
/** Overrides of the kind's mix. */
|
|
221
|
+
form?: PopupForm;
|
|
222
|
+
arrive?: PopupArrive;
|
|
223
|
+
again?: PopupAgain;
|
|
224
|
+
art?: PopupArt;
|
|
225
|
+
/** A newsletter's form — the caller's forms-core newsletter preset (with the AW-D15 legal line), stamped by the caller's
|
|
226
|
+
* own factory; it carries its own Send. */
|
|
227
|
+
newsletterForm?: CompositeNode | null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** The popup — ONE root. Pure over the factory: the builder and the composer get the same tree. */
|
|
231
|
+
export function buildPopupRecipe(create: CompositeNodeFactory, options: PopupRecipeOptions = {}): CompositeNode {
|
|
232
|
+
const kind = options.kind ?? PopupKind.Offer;
|
|
233
|
+
const mix = POPUP_KIND_MIX[kind];
|
|
234
|
+
const form = popupFormOf(kind, options.form ?? mix.form);
|
|
235
|
+
const art = form === PopupForm.Bar ? PopupArt.None : options.art ?? mix.art;
|
|
236
|
+
const words = popupWords(options.lang);
|
|
237
|
+
const title = options.title?.trim() ?? '';
|
|
238
|
+
const bar = form === PopupForm.Bar;
|
|
239
|
+
|
|
240
|
+
const picture = art === PopupArt.Picture;
|
|
241
|
+
// The dialog style's padding holds, except around a picture: the picture runs to the card's edge, the words keep the pad.
|
|
242
|
+
const { padding: _rowPad, ...row } = ROW;
|
|
243
|
+
const root = recipePart(create, 'popup', 'Dialog', PopupRole.Popup, Style.Dialog, {}, `Popup — ${words.label[kind]}`,
|
|
244
|
+
bar ? { ...row, width: '100%', maxWidth: '100%', gap: '16px' }
|
|
245
|
+
: { ...row, width: picture ? '560px' : '420px', maxWidth: '100%', alignItems: 'stretch', gap: '0px', ...(picture ? { padding: ZERO } : {}) });
|
|
246
|
+
writeProp(root, 'placement', 'center'); // the popup's own form places it (iox-design.css), never the placement
|
|
247
|
+
writeProp(root, 'closeOnBackdrop', true); // centred only: a click on the scrim is a close (remembered)
|
|
248
|
+
writeProp(root, 'showCloseButton', true);
|
|
249
|
+
writeProp(root, 'ariaLabel', title || words.label[kind]);
|
|
250
|
+
writeProp(root, PopupTrait.Kind, kind);
|
|
251
|
+
writeProp(root, PopupTrait.Form, form);
|
|
252
|
+
writeProp(root, PopupTrait.Arrive, options.arrive ?? mix.arrive);
|
|
253
|
+
writeProp(root, PopupTrait.Again, options.again ?? mix.again);
|
|
254
|
+
|
|
255
|
+
const children: CompositeNode[] = [];
|
|
256
|
+
if (picture) {
|
|
257
|
+
const media = recipePart(create, 'popup-media', 'Container', PopupRole.Media, null, {}, 'Picture',
|
|
258
|
+
{ ...COLUMN, width: '40%', flexShrink: '0', overflow: 'hidden' });
|
|
259
|
+
media.children = [recipePart(create, 'popup-image', 'Image', null, null, { src: options.imageSrc ?? '', alt: options.imageAlt ?? '' }, 'Picture',
|
|
260
|
+
{ width: '100%', height: '100%', minHeight: '160px', objectFit: 'cover', margin: ZERO })];
|
|
261
|
+
children.push(media);
|
|
262
|
+
}
|
|
263
|
+
const content = recipePart(create, 'popup-content', 'Container', PopupRole.Content, null, {}, 'Words',
|
|
264
|
+
bar ? { ...ROW, flexGrow: '1', flexWrap: 'wrap', gap: '4px 16px' }
|
|
265
|
+
: { ...COLUMN, flexGrow: '1', width: 'auto', gap: '8px', ...(picture ? { padding: 'var(--iox-dialog-pad)' } : {}) });
|
|
266
|
+
const parts: CompositeNode[] = [];
|
|
267
|
+
if (options.eyebrow?.trim()) parts.push(recipeText(create, 'popup-eyebrow', PopupRole.Eyebrow, Style.Eyebrow, options.eyebrow.trim(), 'Dates'));
|
|
268
|
+
parts.push(recipePart(create, 'popup-title', 'Heading', PopupRole.Title, Style.Title, { content: title, level: 'h2' }, 'Title', WORDS));
|
|
269
|
+
if (options.body?.trim() || !bar) parts.push(recipeText(create, 'popup-body', PopupRole.Body, Style.Body, options.body?.trim() ?? '', 'Words'));
|
|
270
|
+
if (kind === PopupKind.Newsletter && options.newsletterForm) {
|
|
271
|
+
const f = options.newsletterForm;
|
|
272
|
+
f.role = PopupRole.Form;
|
|
273
|
+
parts.push(f);
|
|
274
|
+
} else if (options.actionRoute) {
|
|
275
|
+
// A popup's action is QUIET — never the page's primary button (§6): the look's link (a Link, the consent banner's
|
|
276
|
+
// privacy link's shape), hugging its words — the column would stretch its box (focus ring, hover) to full width.
|
|
277
|
+
parts.push(recipePart(create, 'popup-action', 'Link', PopupRole.Action, Style.Link,
|
|
278
|
+
{ label: options.actionLabel?.trim() ?? '', linkType: 'page', pageRoute: options.actionRoute }, 'Action',
|
|
279
|
+
{ ...WORDS, alignSelf: 'flex-start' }));
|
|
280
|
+
}
|
|
281
|
+
content.children = parts;
|
|
282
|
+
children.push(content);
|
|
283
|
+
root.children = children;
|
|
284
|
+
return root;
|
|
285
|
+
}
|
|
@@ -1130,6 +1130,21 @@ export const SPEC_TIERS = {
|
|
|
1130
1130
|
"type": "duration",
|
|
1131
1131
|
"default": "220ms"
|
|
1132
1132
|
},
|
|
1133
|
+
{
|
|
1134
|
+
"name": "popup-inset",
|
|
1135
|
+
"type": "size",
|
|
1136
|
+
"default": "24px"
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
"name": "popup-dur-in",
|
|
1140
|
+
"type": "duration",
|
|
1141
|
+
"default": "450ms"
|
|
1142
|
+
},
|
|
1143
|
+
{
|
|
1144
|
+
"name": "popup-dur-out",
|
|
1145
|
+
"type": "duration",
|
|
1146
|
+
"default": "250ms"
|
|
1147
|
+
},
|
|
1133
1148
|
{
|
|
1134
1149
|
"name": "dialog-edge",
|
|
1135
1150
|
"type": "color",
|
|
@@ -1809,7 +1824,9 @@ export const SPEC_AXES = {
|
|
|
1809
1824
|
"sheet-dur-in": "0ms",
|
|
1810
1825
|
"sheet-dur-out": "0ms",
|
|
1811
1826
|
"toast-dur-in": "0ms",
|
|
1812
|
-
"toast-dur-out": "0ms"
|
|
1827
|
+
"toast-dur-out": "0ms",
|
|
1828
|
+
"popup-dur-in": "0ms",
|
|
1829
|
+
"popup-dur-out": "0ms"
|
|
1813
1830
|
},
|
|
1814
1831
|
"snappy": {
|
|
1815
1832
|
"label": "Snappy",
|
|
@@ -1833,6 +1850,8 @@ export const SPEC_AXES = {
|
|
|
1833
1850
|
"sheet-dur-out": "240ms",
|
|
1834
1851
|
"toast-dur-in": "320ms",
|
|
1835
1852
|
"toast-dur-out": "180ms",
|
|
1853
|
+
"popup-dur-in": "360ms",
|
|
1854
|
+
"popup-dur-out": "200ms",
|
|
1836
1855
|
"ease-pop": "cubic-bezier(0.34, 1.56, 0.64, 1)"
|
|
1837
1856
|
},
|
|
1838
1857
|
"standard": {
|
|
@@ -1857,6 +1876,8 @@ export const SPEC_AXES = {
|
|
|
1857
1876
|
"sheet-dur-out": "280ms",
|
|
1858
1877
|
"toast-dur-in": "400ms",
|
|
1859
1878
|
"toast-dur-out": "220ms",
|
|
1879
|
+
"popup-dur-in": "450ms",
|
|
1880
|
+
"popup-dur-out": "250ms",
|
|
1860
1881
|
"ease-pop": "cubic-bezier(0.34, 1.56, 0.64, 1)"
|
|
1861
1882
|
},
|
|
1862
1883
|
"calm": {
|
|
@@ -1881,6 +1902,8 @@ export const SPEC_AXES = {
|
|
|
1881
1902
|
"sheet-dur-out": "340ms",
|
|
1882
1903
|
"toast-dur-in": "480ms",
|
|
1883
1904
|
"toast-dur-out": "280ms",
|
|
1905
|
+
"popup-dur-in": "560ms",
|
|
1906
|
+
"popup-dur-out": "310ms",
|
|
1884
1907
|
"ease-pop": "cubic-bezier(0.34, 1.56, 0.64, 1)"
|
|
1885
1908
|
},
|
|
1886
1909
|
"lively": {
|
|
@@ -1905,6 +1928,8 @@ export const SPEC_AXES = {
|
|
|
1905
1928
|
"sheet-dur-out": "280ms",
|
|
1906
1929
|
"toast-dur-in": "400ms",
|
|
1907
1930
|
"toast-dur-out": "220ms",
|
|
1931
|
+
"popup-dur-in": "450ms",
|
|
1932
|
+
"popup-dur-out": "250ms",
|
|
1908
1933
|
"ease-pop": "cubic-bezier(0.34, 1.56, 0.64, 1)"
|
|
1909
1934
|
}
|
|
1910
1935
|
},
|
|
@@ -7720,6 +7745,27 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
7720
7745
|
"group": "components",
|
|
7721
7746
|
"value": "220ms"
|
|
7722
7747
|
},
|
|
7748
|
+
{
|
|
7749
|
+
"name": "popup-inset",
|
|
7750
|
+
"tier": "component",
|
|
7751
|
+
"type": "size",
|
|
7752
|
+
"group": "components",
|
|
7753
|
+
"value": "24px"
|
|
7754
|
+
},
|
|
7755
|
+
{
|
|
7756
|
+
"name": "popup-dur-in",
|
|
7757
|
+
"tier": "component",
|
|
7758
|
+
"type": "duration",
|
|
7759
|
+
"group": "components",
|
|
7760
|
+
"value": "450ms"
|
|
7761
|
+
},
|
|
7762
|
+
{
|
|
7763
|
+
"name": "popup-dur-out",
|
|
7764
|
+
"tier": "component",
|
|
7765
|
+
"type": "duration",
|
|
7766
|
+
"group": "components",
|
|
7767
|
+
"value": "250ms"
|
|
7768
|
+
},
|
|
7723
7769
|
{
|
|
7724
7770
|
"name": "dialog-edge",
|
|
7725
7771
|
"tier": "component",
|
|
@@ -10154,6 +10200,27 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
10154
10200
|
"group": "components",
|
|
10155
10201
|
"value": "280ms"
|
|
10156
10202
|
},
|
|
10203
|
+
{
|
|
10204
|
+
"name": "popup-inset",
|
|
10205
|
+
"tier": "component",
|
|
10206
|
+
"type": "size",
|
|
10207
|
+
"group": "components",
|
|
10208
|
+
"value": "24px"
|
|
10209
|
+
},
|
|
10210
|
+
{
|
|
10211
|
+
"name": "popup-dur-in",
|
|
10212
|
+
"tier": "component",
|
|
10213
|
+
"type": "duration",
|
|
10214
|
+
"group": "components",
|
|
10215
|
+
"value": "560ms"
|
|
10216
|
+
},
|
|
10217
|
+
{
|
|
10218
|
+
"name": "popup-dur-out",
|
|
10219
|
+
"tier": "component",
|
|
10220
|
+
"type": "duration",
|
|
10221
|
+
"group": "components",
|
|
10222
|
+
"value": "310ms"
|
|
10223
|
+
},
|
|
10157
10224
|
{
|
|
10158
10225
|
"name": "dialog-edge",
|
|
10159
10226
|
"tier": "component",
|
|
@@ -12594,6 +12661,27 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
12594
12661
|
"group": "components",
|
|
12595
12662
|
"value": "220ms"
|
|
12596
12663
|
},
|
|
12664
|
+
{
|
|
12665
|
+
"name": "popup-inset",
|
|
12666
|
+
"tier": "component",
|
|
12667
|
+
"type": "size",
|
|
12668
|
+
"group": "components",
|
|
12669
|
+
"value": "24px"
|
|
12670
|
+
},
|
|
12671
|
+
{
|
|
12672
|
+
"name": "popup-dur-in",
|
|
12673
|
+
"tier": "component",
|
|
12674
|
+
"type": "duration",
|
|
12675
|
+
"group": "components",
|
|
12676
|
+
"value": "450ms"
|
|
12677
|
+
},
|
|
12678
|
+
{
|
|
12679
|
+
"name": "popup-dur-out",
|
|
12680
|
+
"tier": "component",
|
|
12681
|
+
"type": "duration",
|
|
12682
|
+
"group": "components",
|
|
12683
|
+
"value": "250ms"
|
|
12684
|
+
},
|
|
12597
12685
|
{
|
|
12598
12686
|
"name": "dialog-edge",
|
|
12599
12687
|
"tier": "component",
|
|
@@ -15058,6 +15146,27 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
15058
15146
|
"group": "components",
|
|
15059
15147
|
"value": "220ms"
|
|
15060
15148
|
},
|
|
15149
|
+
{
|
|
15150
|
+
"name": "popup-inset",
|
|
15151
|
+
"tier": "component",
|
|
15152
|
+
"type": "size",
|
|
15153
|
+
"group": "components",
|
|
15154
|
+
"value": "24px"
|
|
15155
|
+
},
|
|
15156
|
+
{
|
|
15157
|
+
"name": "popup-dur-in",
|
|
15158
|
+
"tier": "component",
|
|
15159
|
+
"type": "duration",
|
|
15160
|
+
"group": "components",
|
|
15161
|
+
"value": "450ms"
|
|
15162
|
+
},
|
|
15163
|
+
{
|
|
15164
|
+
"name": "popup-dur-out",
|
|
15165
|
+
"tier": "component",
|
|
15166
|
+
"type": "duration",
|
|
15167
|
+
"group": "components",
|
|
15168
|
+
"value": "250ms"
|
|
15169
|
+
},
|
|
15061
15170
|
{
|
|
15062
15171
|
"name": "dialog-edge",
|
|
15063
15172
|
"tier": "component",
|
|
@@ -17503,6 +17612,27 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
17503
17612
|
"group": "components",
|
|
17504
17613
|
"value": "220ms"
|
|
17505
17614
|
},
|
|
17615
|
+
{
|
|
17616
|
+
"name": "popup-inset",
|
|
17617
|
+
"tier": "component",
|
|
17618
|
+
"type": "size",
|
|
17619
|
+
"group": "components",
|
|
17620
|
+
"value": "24px"
|
|
17621
|
+
},
|
|
17622
|
+
{
|
|
17623
|
+
"name": "popup-dur-in",
|
|
17624
|
+
"tier": "component",
|
|
17625
|
+
"type": "duration",
|
|
17626
|
+
"group": "components",
|
|
17627
|
+
"value": "450ms"
|
|
17628
|
+
},
|
|
17629
|
+
{
|
|
17630
|
+
"name": "popup-dur-out",
|
|
17631
|
+
"tier": "component",
|
|
17632
|
+
"type": "duration",
|
|
17633
|
+
"group": "components",
|
|
17634
|
+
"value": "250ms"
|
|
17635
|
+
},
|
|
17506
17636
|
{
|
|
17507
17637
|
"name": "dialog-edge",
|
|
17508
17638
|
"tier": "component",
|
|
@@ -19944,6 +20074,27 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
19944
20074
|
"group": "components",
|
|
19945
20075
|
"value": "180ms"
|
|
19946
20076
|
},
|
|
20077
|
+
{
|
|
20078
|
+
"name": "popup-inset",
|
|
20079
|
+
"tier": "component",
|
|
20080
|
+
"type": "size",
|
|
20081
|
+
"group": "components",
|
|
20082
|
+
"value": "24px"
|
|
20083
|
+
},
|
|
20084
|
+
{
|
|
20085
|
+
"name": "popup-dur-in",
|
|
20086
|
+
"tier": "component",
|
|
20087
|
+
"type": "duration",
|
|
20088
|
+
"group": "components",
|
|
20089
|
+
"value": "360ms"
|
|
20090
|
+
},
|
|
20091
|
+
{
|
|
20092
|
+
"name": "popup-dur-out",
|
|
20093
|
+
"tier": "component",
|
|
20094
|
+
"type": "duration",
|
|
20095
|
+
"group": "components",
|
|
20096
|
+
"value": "200ms"
|
|
20097
|
+
},
|
|
19947
20098
|
{
|
|
19948
20099
|
"name": "dialog-edge",
|
|
19949
20100
|
"tier": "component",
|
|
@@ -248,11 +248,74 @@ export function creditsOfUsd(usd: number): number {
|
|
|
248
248
|
return Math.round(usd * CREDITS_PER_USD * CREDIT_PRECISION) / CREDIT_PRECISION;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
/**
|
|
252
|
-
|
|
251
|
+
/**
|
|
252
|
+
* What a typical request of `step` reads and writes — one part's when the step is asked in parts, else the whole step's.
|
|
253
|
+
* A picture step on a named `model` is counted as that model's maker bills one picture (`pictureTokensFor`, iox-ui#138);
|
|
254
|
+
* with no model named it is the step's own count (its default model's maker).
|
|
255
|
+
*/
|
|
256
|
+
export function typicalStepTokens(step: AiStep, part?: PlanPart, model?: string | null): AiTokenCounts {
|
|
257
|
+
if (model && aiModelStep(step) === AiStep.MakePictures) return pictureTokensFor(model);
|
|
253
258
|
return (part && AI_STEP_PART_TOKENS[step]?.[part]) || AI_STEP_TYPICAL_TOKENS[step];
|
|
254
259
|
}
|
|
255
260
|
|
|
261
|
+
// ── One picture's bill, by who draws it (iox-ui#138) ────────────────────────────────────────────────────────────────
|
|
262
|
+
|
|
263
|
+
/** Who draws a picture model's pictures — how many tokens one picture is billed depends on it, not on its price. */
|
|
264
|
+
export enum AiPictureMaker {
|
|
265
|
+
/** Google's image models (Nano Banana): a 1 K picture is 1,120 image tokens and a short text beside it. */
|
|
266
|
+
Gemini = 'gemini',
|
|
267
|
+
/** Google's Pro image model, which thinks before it draws: the same picture, more text written. */
|
|
268
|
+
GeminiThinking = 'geminiThinking',
|
|
269
|
+
/** OpenAI's image models behind GPT-5 Image: a reasoning model writes, gpt-image draws — far more image tokens. */
|
|
270
|
+
OpenAiImage = 'openaiImage',
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface AiPictureMakerRow {
|
|
274
|
+
readonly maker: AiPictureMaker;
|
|
275
|
+
/** The model ids it draws for — the first row that matches wins. */
|
|
276
|
+
readonly ids: RegExp;
|
|
277
|
+
/** The MOST one picture is billed: what a shown estimate is made of, so the cost shown is never below the charge. */
|
|
278
|
+
readonly tokens: AiTokenCounts;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* One row per maker, the most specific first. Each count is an upper bound, held by `ai-run.spec` against a recorded
|
|
283
|
+
* charge where one exists:
|
|
284
|
+
* - Gemini — the M7 count (`PICTURE_TOKENS`); Nano Banana 2.1 was charged 3.6492 credits on 2026-11-24 (133 in, 359 out,
|
|
285
|
+
* 1,120 image) against 3.915 counted.
|
|
286
|
+
* - Gemini thinking — the same picture with 2,000 written for its thoughts and text (not yet measured; counted high).
|
|
287
|
+
* - OpenAI image — gpt-image writes at most 6,240 image tokens for one picture (1024×1536 at high quality, OpenAI's own
|
|
288
|
+
* table; the model chooses the quality) and GPT-5's reasoning and text beside it are counted at 4,000. GPT-5 Image Mini
|
|
289
|
+
* was charged 4.30365 credits on 2026-11-25 where 1.191 had been shown (iox-ui#138); counted now: 5.967.
|
|
290
|
+
*/
|
|
291
|
+
export const AI_PICTURE_MAKERS: ReadonlyArray<AiPictureMakerRow> = [
|
|
292
|
+
{ maker: AiPictureMaker.GeminiThinking, ids: /^google\/gemini-[\w.-]*pro-image/, tokens: { ...PICTURE_TOKENS, output: 2_000 } },
|
|
293
|
+
{ maker: AiPictureMaker.Gemini, ids: /^google\//, tokens: PICTURE_TOKENS },
|
|
294
|
+
{ maker: AiPictureMaker.OpenAiImage, ids: /^openai\//, tokens: { input: 700, output: 4_000, cacheWrite: 0, cacheRead: 0, imageOutput: 6_240 } },
|
|
295
|
+
];
|
|
296
|
+
|
|
297
|
+
/** The maker of a picture model, or null when no row names it. */
|
|
298
|
+
export function pictureMakerOf(model: string): AiPictureMakerRow | null {
|
|
299
|
+
return AI_PICTURE_MAKERS.find(row => row.ids.test(model)) ?? null;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const largestOf = (rows: ReadonlyArray<AiTokenCounts>): AiTokenCounts => rows.reduce((a, b) => ({
|
|
303
|
+
input: Math.max(a.input, b.input), output: Math.max(a.output, b.output),
|
|
304
|
+
cacheWrite: Math.max(a.cacheWrite, b.cacheWrite), cacheRead: Math.max(a.cacheRead, b.cacheRead),
|
|
305
|
+
imageOutput: Math.max(a.imageOutput ?? 0, b.imageOutput ?? 0),
|
|
306
|
+
}));
|
|
307
|
+
|
|
308
|
+
/** Every class at the most any maker bills it — what a picture of a model no row names is counted as. */
|
|
309
|
+
export const PICTURE_TOKENS_UNKNOWN_MAKER: AiTokenCounts = largestOf(AI_PICTURE_MAKERS.map(row => row.tokens));
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* The most one picture on `model` is billed. A model no row names (an own key's choice) is counted at every maker's
|
|
313
|
+
* largest count — never below what it may be charged; the cost shown may be high, it is never short.
|
|
314
|
+
*/
|
|
315
|
+
export function pictureTokensFor(model: string): AiTokenCounts {
|
|
316
|
+
return pictureMakerOf(model)?.tokens ?? PICTURE_TOKENS_UNKNOWN_MAKER;
|
|
317
|
+
}
|
|
318
|
+
|
|
256
319
|
/** The credits a typical use of `step` costs on a model of `price` — never typed, always computed (§3d). */
|
|
257
320
|
export function estimateStepCredits(step: AiStep, price: AiTokenPrice, tokens: AiTokenCounts = AI_STEP_TYPICAL_TOKENS[step]): number {
|
|
258
321
|
return creditsOfUsd(costUsd(tokens, price));
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from '@vectoriox/iox-ui/composite-core';
|
|
6
6
|
|
|
7
7
|
import { ColorScheme, DesignChoices, LIST_MIX_PROP, LinkType, scrubOfChoices, setColorScheme, SPEC_AXES } from '@vectoriox/iox-ui/design-core';
|
|
8
|
-
import { TextRevealBy } from '@vectoriox/iox-ui/scene-core';
|
|
8
|
+
import { SCENE_TRACK_EASE, SceneEase, SceneProp, TextRevealBy } from '@vectoriox/iox-ui/scene-core';
|
|
9
9
|
import { FORM_AFTER_SEND_TRAIT, FormAfterSend, FormPresetId } from '@vectoriox/iox-ui/forms-core';
|
|
10
10
|
import { composeNavHeader, composePresetForm } from './compose-site';
|
|
11
11
|
import { drawnHeaderMix, headerMixOfNavKind } from './header-mix';
|
|
@@ -50,7 +50,8 @@ export enum LayoutGapCode {
|
|
|
50
50
|
Blur = 'blur',
|
|
51
51
|
/** M8-G3: `scaleIn` / `pop` start at the product's 0.8, not 0.95 / 0.9, and `pop` has no overshoot. */
|
|
52
52
|
ScaleIn = 'scale-in',
|
|
53
|
-
/** M8-G4: a held layer's keys
|
|
53
|
+
/** M8-G4: a held layer's keys run straight (travel) or smooth (a fade) — an `out` or `drawer` ease is drawn as its
|
|
54
|
+
* property's (award plan "Reddottours", RT-D1: travel linear, fades smooth; `linear` / `inOut` are drawn as asked). */
|
|
54
55
|
TrackEase = 'track-ease',
|
|
55
56
|
/** M8-G5: a depth glides at the product's one speed (no per-look scale), and a picture's own drift inside its frame
|
|
56
57
|
* is a fixed over-scale. */
|
|
@@ -520,7 +521,10 @@ function depthInteraction(nodeId: string, depth: string): unknown {
|
|
|
520
521
|
|
|
521
522
|
const TRACK_REST: Readonly<Record<string, number>> = { x: 0, y: 0, scale: 1, rotate: 0, opacity: 1, clip: 100, words: 100 };
|
|
522
523
|
|
|
523
|
-
interface SceneTrackOut { prop: string; keys: Array<[number, number]>; from?: string }
|
|
524
|
+
interface SceneTrackOut { prop: string; keys: Array<[number, number]>; from?: string; ease?: SceneEase }
|
|
525
|
+
|
|
526
|
+
/** The layout's eases the product's tracks can run (RT-D1); anything else is drawn as the property's own. */
|
|
527
|
+
const TRACK_EASE: Readonly<Partial<Record<LayoutEase, SceneEase>>> = { [LayoutEase.Linear]: SceneEase.Linear, [LayoutEase.InOut]: SceneEase.Smooth };
|
|
524
528
|
|
|
525
529
|
/** A layout track as a scene-core track: lengths move from the layer's own box to the stage's (cqw / cqh). */
|
|
526
530
|
function sceneTrackOf(t: LayoutTrack, l: LayoutLayer, rows: number, ctx: Ctx, path: string): SceneTrackOut | null {
|
|
@@ -529,13 +533,16 @@ function sceneTrackOf(t: LayoutTrack, l: LayoutLayer, rows: number, ctx: Ctx, pa
|
|
|
529
533
|
gap(ctx, LayoutGapCode.Blur, path, 'a blur track is dropped');
|
|
530
534
|
return null;
|
|
531
535
|
}
|
|
532
|
-
|
|
536
|
+
const own = SCENE_TRACK_EASE[t.prop as SceneProp];
|
|
537
|
+
const ease = t.ease ? TRACK_EASE[t.ease as LayoutEase] : undefined;
|
|
538
|
+
if (t.ease && !ease) gap(ctx, LayoutGapCode.TrackEase, path, `${t.prop} runs ${own === SceneEase.Linear ? 'straight' : 'smooth (smoothstep)'}, not ${t.ease}`);
|
|
533
539
|
let scale = 1;
|
|
534
540
|
if (t.prop === LayoutTrackProp.X) scale = (l.col[1] - l.col[0]) / GRID_COLUMNS;
|
|
535
541
|
if (t.prop === LayoutTrackProp.Y) scale = (l.row[1] - l.row[0]) / rows;
|
|
536
542
|
const round = (v: number) => Math.round(v * scale * 100) / 100;
|
|
537
543
|
const track: SceneTrackOut = { prop: t.prop, keys: [[a, round(Number(t.from))], [b, round(Number(t.to))]] };
|
|
538
544
|
if (t.prop === LayoutTrackProp.Clip) track.from = LayoutSide.Bottom;
|
|
545
|
+
if (ease && ease !== own) track.ease = ease;
|
|
539
546
|
return track;
|
|
540
547
|
}
|
|
541
548
|
|
|
@@ -1646,7 +1653,6 @@ function composeSection(s: LayoutSection, si: number, prevGround: string | null,
|
|
|
1646
1653
|
phone(wide, { width: FULL, ...phoneStack(si === 0) });
|
|
1647
1654
|
wide.sceneTracks = [{ prop: 'x', keys: [[0, 0], [1, -(track - 1) * 100]] }];
|
|
1648
1655
|
wide.scenePhoneTracks = [{ prop: 'x', keys: [[0, 0]] }];
|
|
1649
|
-
gap(ctx, LayoutGapCode.TrackEase, `sections[${si}]`, 'the sideways travel eases (smoothstep), not linear');
|
|
1650
1656
|
wide.children = layers;
|
|
1651
1657
|
stage.children = [wide];
|
|
1652
1658
|
}
|