@vectoriox/iox-ui 5.133.0 → 5.135.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 (77) hide show
  1. package/commerce-core/index.d.ts +12 -1
  2. package/composite-core/index.d.ts +27 -22
  3. package/design-core/index.d.ts +436 -35
  4. package/domain-core/index.d.ts +353 -0
  5. package/domain-core/package.json +3 -0
  6. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +2 -0
  7. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -48
  9. package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +21 -0
  11. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
  12. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +68 -57
  13. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  14. package/fesm2022/vectoriox-iox-ui-design-core.mjs +895 -416
  15. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  16. package/fesm2022/vectoriox-iox-ui-domain-core.mjs +422 -0
  17. package/fesm2022/vectoriox-iox-ui-domain-core.mjs.map +1 -0
  18. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +14039 -12067
  19. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  20. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +9 -3
  21. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  22. package/fesm2022/vectoriox-iox-ui-mail-core.mjs +210 -2
  23. package/fesm2022/vectoriox-iox-ui-mail-core.mjs.map +1 -1
  24. package/fesm2022/vectoriox-iox-ui.mjs +290 -16
  25. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  26. package/generation-core/index.d.ts +1511 -432
  27. package/harness-core/index.d.ts +6 -1
  28. package/index.d.ts +139 -10
  29. package/mail-core/index.d.ts +190 -2
  30. package/package.json +5 -1
  31. package/src/actions-core/element-actions.ts +2 -0
  32. package/src/assist-core/page-sections.ts +7 -37
  33. package/src/commerce-core/shop-display.ts +21 -0
  34. package/src/composite-core/shop.ts +71 -57
  35. package/src/design-core/design-settings.ts +16 -0
  36. package/src/design-core/design-token.model.ts +7 -1
  37. package/src/design-core/flavor-spec.generated.ts +374 -35
  38. package/src/design-core/flavor-tokens.ts +12 -1
  39. package/src/design-core/header-behaviour.ts +32 -0
  40. package/src/design-core/motion-language.ts +115 -0
  41. package/src/design-core/public-api.ts +1 -0
  42. package/src/design-core/style-presets.ts +3 -0
  43. package/src/domain-core/domain-vocabulary.ts +125 -0
  44. package/src/domain-core/domain-wire.ts +95 -0
  45. package/src/domain-core/org-path-redirect.ts +105 -0
  46. package/src/domain-core/public-api.ts +12 -0
  47. package/src/domain-core/web-domain.ts +251 -0
  48. package/src/generation-core/carry-fill.ts +36 -0
  49. package/src/generation-core/carry.ts +398 -0
  50. package/src/generation-core/check-carry.ts +216 -0
  51. package/src/generation-core/check-layout.ts +71 -5
  52. package/src/generation-core/compose-layout.ts +187 -28
  53. package/src/generation-core/compose-site.ts +154 -31
  54. package/src/generation-core/entrances.ts +66 -10
  55. package/src/generation-core/header-edit.ts +299 -0
  56. package/src/generation-core/header-mix.ts +64 -5
  57. package/src/generation-core/layout-fingerprint.ts +5 -1
  58. package/src/generation-core/layout-language.ts +20 -1
  59. package/src/generation-core/layout-space.ts +4 -4
  60. package/src/generation-core/layout-wire.ts +36 -1
  61. package/src/generation-core/node-baselines.generated.ts +1 -0
  62. package/src/generation-core/public-api.ts +7 -0
  63. package/src/generation-core/redesign-additions.ts +273 -0
  64. package/src/generation-core/redesign-run.ts +364 -0
  65. package/src/generation-core/refit-page.ts +151 -0
  66. package/src/generation-core/section-stamp.ts +4 -4
  67. package/src/generation-core/shop-plan.ts +15 -0
  68. package/src/generation-core/site-build-run.ts +67 -3
  69. package/src/generation-core/site-spec.generated.ts +194 -94
  70. package/src/generation-core/site-tree.ts +19 -5
  71. package/src/generation-core/validate-site-plan.ts +37 -3
  72. package/src/harness-core/motion.ts +13 -3
  73. package/src/harness-core/starting-design.ts +1 -1
  74. package/src/mail-core/mail-domain.ts +305 -0
  75. package/src/mail-core/mail-wire.ts +8 -0
  76. package/src/mail-core/public-api.ts +3 -1
  77. package/styles/iox-design.css +30 -1
@@ -0,0 +1,299 @@
1
+ import { AccountRole, ShopRole } from '@vectoriox/iox-ui/composite-core';
2
+ import { HeaderBehaviour, headerBehaviourOf, headerEdgeOf, HeaderTrait } from '@vectoriox/iox-ui/design-core';
3
+
4
+ import { composeNavHeader, ComposeIssue, NavHeaderInput, navHeaderContext } from './compose-site';
5
+ import { checkHeader, drawnHeaderMix, headerGalleryIdOf, HeaderIngredient, headerMix, HeaderMix, HeaderPages, HeaderRepair, storedHeaderMix } from './header-mix';
6
+ import { NavRole, NavShape, navShapeOf, menuAtEveryWidth } from './nav-shape';
7
+ import { canonicalValue } from './section-stamp';
8
+ import { SerializedNode } from './serialized-node';
9
+
10
+ /**
11
+ * EDITING A HEADER IN THE BUILDER (header-ingredients-plan HI1b, board header-studio — HS-4, HS-5): what Bindings ▸ Header
12
+ * and the Header studio read off a header, and what Apply writes. Pure, one recipe with the generator: every header is
13
+ * `composeNavHeader(mix)`; the builder never builds one by hand.
14
+ *
15
+ * - `readHeader` — the mix the header root stores (`HeaderTrait.Mix`), else its nearest mix; and whether it is still what
16
+ * that mix composes (`custom` once a part was moved, added or restyled by hand — the owner's words, the pages it lists
17
+ * and where its buttons lead never make it Custom).
18
+ * - `applyHeaderMix` — the header for a new mix, composed by the recipe and merged three ways with the header as it is:
19
+ * the owner's words and their buttons' links are always kept; a part's own style or setting the owner changed is kept
20
+ * where the new mix leaves that part as the old one did, and REPLACED (and named, before Apply) where it does not;
21
+ * a part the owner added is named too. A change of trait words only (how the menu opens, its button…) replaces nothing.
22
+ * - `headerAdvice` — `checkHeader` as advice (HB-D8): what it would mend, never mended silently.
23
+ */
24
+
25
+ /** What the header is composed from (the builder's studio: its name, its pages, its language, its look, its shop). */
26
+ export type HeaderSite = Omit<NavHeaderInput, 'mix' | 'asAsked'>;
27
+
28
+ /** The store's parts a selling site's header holds (`withStoreSlots`). */
29
+ const STORE_SLOT_ROLES: ReadonlySet<string> = new Set([ShopRole.CartButton, AccountRole.Entry]);
30
+
31
+ /** The roles that link to one of the site's pages (the bar's row, the drawer's list, the bottom bar's items). */
32
+ const PAGE_LINK_ROLES: ReadonlySet<string> = new Set([NavRole.Link, NavRole.DrawerLink, NavRole.BarItem]);
33
+
34
+ /** The pages a header and its companions link to, in their order, once each — what the header is recomposed with when the
35
+ * studio's own page list is not known (yet): a mix change never takes the owner's links away (CC1's `phoneMenuPages`). */
36
+ function pagesOfHeader(current: SerializedNode, companions: ReadonlyArray<SerializedNode>): HeaderSite['pages'] {
37
+ const out: { name: string; route: string }[] = [];
38
+ const walk = (n: SerializedNode): void => {
39
+ const route = n.role && PAGE_LINK_ROLES.has(n.role) ? String(n.props?.['pageRoute'] ?? '') : '';
40
+ if (route && !out.some(p => p.route === route)) out.push({ name: wordsOf(n) || route, route });
41
+ (n.children ?? []).forEach(walk);
42
+ };
43
+ [current, ...companions].forEach(walk);
44
+ return out;
45
+ }
46
+
47
+ /** The site a header is recomposed for: a header that holds the bag or the account entry is a selling site's (unless the
48
+ * site says), and a studio whose pages are not known keeps the pages the header links to. */
49
+ function siteFor(site: HeaderSite, current: SerializedNode, companions: ReadonlyArray<SerializedNode> = []): HeaderSite {
50
+ let at = site;
51
+ if (!site.pages?.length) {
52
+ const own = pagesOfHeader(current, companions);
53
+ if (own.length) at = { ...at, pages: own };
54
+ }
55
+ if (at.storeSlots !== undefined) return at;
56
+ let sells = false;
57
+ const walk = (n: SerializedNode): void => { if (n.role && STORE_SLOT_ROLES.has(n.role)) sells = true; (n.children ?? []).forEach(walk); };
58
+ walk(current);
59
+ return sells ? { ...at, storeSlots: true } : at;
60
+ }
61
+
62
+ export interface HeaderEditOptions {
63
+ /** A phone-shape part's id (the builder's id generator). */
64
+ readonly newId?: (suffix: string) => string;
65
+ /** The header's companion globals as they are now — the Both shape's drawer, the bottom bar (`headerCompanions`). */
66
+ readonly companions?: ReadonlyArray<SerializedNode>;
67
+ }
68
+
69
+ /** The roles a header's phone shape keeps as globals of their own, beside the header (Both: the drawer; Bar, Both: the bar). */
70
+ const COMPANION_ROLES: ReadonlySet<string> = new Set([NavRole.Drawer, NavRole.Bar]);
71
+
72
+ /** The globals that belong to the site's header (its phone shape's drawer and bar) — what the studio replaces with it. */
73
+ export function headerCompanions(globals: ReadonlyArray<SerializedNode>): SerializedNode[] {
74
+ return globals.filter(g => !!g.role && COMPANION_ROLES.has(g.role));
75
+ }
76
+
77
+ /** The header and its companions as ONE tree, so a part is matched wherever the shape puts it (a drawer moves out of
78
+ * the header for Both). Never stored. */
79
+ const GROUP = '__header-group';
80
+ function grouped(header: SerializedNode, companions: ReadonlyArray<SerializedNode>): SerializedNode {
81
+ return { id: GROUP, type: GROUP, children: [header, ...companions] } as SerializedNode;
82
+ }
83
+
84
+ /** The props that are the owner's WORDS, carried by every Apply. */
85
+ const WORD_PROPS: ReadonlySet<string> = new Set(['content', 'label', 'text', 'caption', 'alt', 'ariaLabel', 'tooltip']);
86
+ /** Where a part leads. The owner's for a call to action (carried); a page link's is its page's. */
87
+ const LINK_PROPS: ReadonlySet<string> = new Set(['linkType', 'url', 'href', 'pageRoute', 'target']);
88
+ /** The parts whose link is the owner's choice. */
89
+ const OWNED_LINK_ROLES: ReadonlySet<string> = new Set([NavRole.Cta, NavRole.DrawerCta]);
90
+ /** The parts repeated once per page: matched by the page they lead to, and the same part whatever the count. */
91
+ const PAGE_ROLES: ReadonlySet<string> = new Set([NavRole.Link, NavRole.DrawerLink, NavRole.BarItem]);
92
+ /** What a part wears: compared as one. */
93
+ const STYLE_FIELDS = ['styleProps', 'stateStyles', 'responsive', 'elementStyle'] as const;
94
+
95
+ const clone = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;
96
+ const same = (a: unknown, b: unknown): boolean => JSON.stringify(canonicalValue(a) ?? null) === JSON.stringify(canonicalValue(b) ?? null);
97
+ const linkOf = (n: SerializedNode): string => String(n.props?.['pageRoute'] || n.props?.['url'] || n.props?.['href'] || '');
98
+
99
+ /** Every part of a header by a key that survives a change of mix: a part with a role by its role (a page's link by its
100
+ * page too), a part without one by its place under the nearest keyed part. */
101
+ function keyed(root: SerializedNode): Map<string, SerializedNode> {
102
+ const out = new Map<string, SerializedNode>([['root', root]]);
103
+ const seen = new Map<string, number>();
104
+ const walk = (node: SerializedNode, parentKey: string): void => {
105
+ const local = new Map<string, number>();
106
+ for (const child of node.children ?? []) {
107
+ let key: string;
108
+ if (child.role) {
109
+ const base = PAGE_ROLES.has(child.role) ? `${child.role}@${linkOf(child)}` : child.role;
110
+ const i = seen.get(base) ?? 0;
111
+ seen.set(base, i + 1);
112
+ key = `${base}#${i}`;
113
+ } else {
114
+ const i = local.get(child.type) ?? 0;
115
+ local.set(child.type, i + 1);
116
+ key = `${parentKey}>${child.type}#${i}`;
117
+ }
118
+ out.set(key, child);
119
+ walk(child, key);
120
+ }
121
+ };
122
+ walk(root, 'root');
123
+ return out;
124
+ }
125
+
126
+ /** A header's SHAPE: what it is made of and what it wears, its words, its links and its ids aside, a run of identical
127
+ * page links read as one (a page added later is not an edit to the header). Ids another part refers to read as the
128
+ * part's role. */
129
+ export function headerShape(root: SerializedNode): string {
130
+ const tokens = new Map<string, string>();
131
+ const collect = (n: SerializedNode): void => { tokens.set(n.id, n.role ?? n.type); (n.children ?? []).forEach(collect); };
132
+ collect(root);
133
+ const strip = (n: SerializedNode): unknown => {
134
+ const props = Object.fromEntries(Object.entries(n.props ?? {}).filter(([k]) => !WORD_PROPS.has(k) && !LINK_PROPS.has(k) && k !== HeaderTrait.Mix));
135
+ const children: string[] = [];
136
+ for (const c of n.children ?? []) {
137
+ const s = JSON.stringify(strip(c));
138
+ if (children[children.length - 1] !== s) children.push(s);
139
+ }
140
+ return canonicalValue({
141
+ type: n.type, role: n.role, props, styleProps: n.styleProps, stateStyles: n.stateStyles, responsive: n.responsive,
142
+ elementStyle: n.elementStyle, bindings: n.bindings, children,
143
+ // An interaction's own id is minted per composition; what it does is the shape.
144
+ interactions: (n.interactions ?? []).map(i => (i && typeof i === 'object' ? { ...(i as object), id: undefined } : i)),
145
+ });
146
+ };
147
+ let json = JSON.stringify(strip(root));
148
+ const ids = [...tokens.keys()].filter(Boolean).sort((a, b) => b.length - a.length);
149
+ for (const id of ids) json = json.split(id).join(`#${tokens.get(id)}`);
150
+ return json;
151
+ }
152
+
153
+ /** HeaderBehaviour → the scroll word. */
154
+ const SCROLL_WORD: Readonly<Record<HeaderBehaviour, string>> = { [HeaderBehaviour.Scrolls]: 'away', [HeaderBehaviour.Stays]: 'stays', [HeaderBehaviour.Hides]: 'hides' };
155
+ /** The phone shape → the phone word. */
156
+ const PHONE_WORD: Readonly<Record<NavShape, string>> = { [NavShape.Drawer]: 'drawer', [NavShape.Bar]: 'bar', [NavShape.Both]: 'both' };
157
+
158
+ /** A header with no stored mix, read as its nearest mix (HS-5): the Studio mix, with what its own settings say — how it
159
+ * scrolls, its edge, its phone menu, a menu at every width. */
160
+ export function nearestHeaderMix(root: SerializedNode, companions: ReadonlyArray<SerializedNode> = []): HeaderMix {
161
+ const behaviour = headerBehaviourOf(root.props?.[HeaderTrait.Behaviour]);
162
+ const edge = headerEdgeOf(root.props?.[HeaderTrait.Edge]);
163
+ const shape = navShapeOf([root, ...companions]);
164
+ const everyWidth = menuAtEveryWidth([root], root.id);
165
+ return headerMix({
166
+ scroll: SCROLL_WORD[behaviour], ...(edge ? { edge } : {}), ...(shape ? { phone: PHONE_WORD[shape] } : {}),
167
+ ...(everyWidth ? { arrange: 'name-only', pages: HeaderPages.Menu, action: 'none' } : {}),
168
+ });
169
+ }
170
+
171
+ export interface HeaderReading {
172
+ /** The mix the header stores, else its nearest mix. */
173
+ mix: HeaderMix;
174
+ /** The header stores its mix (a header composed since HI1b). */
175
+ stored: boolean;
176
+ /** A part was moved, added or restyled by hand: it is no longer what its mix composes (board 4a). */
177
+ custom: boolean;
178
+ /** The gallery mix it is, or null. */
179
+ galleryId: string | null;
180
+ }
181
+
182
+ /** Composes a mix exactly as asked (the owner decides; `headerAdvice` says what the site would rather carry). */
183
+ function compose(mix: HeaderMix, site: HeaderSite, id: string, options: HeaderEditOptions): { header: SerializedNode; companions: SerializedNode[]; issues: ComposeIssue[] } {
184
+ const { header, companions, issues } = composeNavHeader({ ...site, mix, asAsked: true }, { id, ...(options.newId ? { newId: options.newId } : {}) });
185
+ return { header, companions, issues };
186
+ }
187
+
188
+ /** What a header is (HS-5, board 4a): its mix, and whether it is still what that mix composes. Pure. */
189
+ export function readHeader(root: SerializedNode, site: HeaderSite, options: HeaderEditOptions = {}): HeaderReading {
190
+ const stored = storedHeaderMix(root);
191
+ const mix = stored ?? nearestHeaderMix(root, options.companions ?? []);
192
+ const custom = headerShape(root) !== headerShape(compose(mix, siteFor(site, root, options.companions), root.id, options).header);
193
+ return { mix, stored: !!stored, custom, galleryId: headerGalleryIdOf(mix) };
194
+ }
195
+
196
+ export enum HeaderReplacedKind {
197
+ /** The owner's own style or setting on a part the new mix draws differently. */
198
+ Style = 'style',
199
+ /** A part the owner added by hand, which the new mix does not have. */
200
+ Added = 'added',
201
+ }
202
+
203
+ /** A part whose owner's work Apply replaces — named before Apply (board 4b). */
204
+ export interface HeaderReplaced {
205
+ kind: HeaderReplacedKind;
206
+ /** The part as it is now. */
207
+ nodeId: string;
208
+ role?: string;
209
+ /** Its words (a link's page name, the button's words), or empty. */
210
+ words: string;
211
+ }
212
+
213
+ export interface HeaderApplied {
214
+ /** The header for the new mix, with the owner's words — the same id, still the site's global header. */
215
+ header: SerializedNode;
216
+ /** Its phone shape's globals (the Both drawer, the bottom bar), placed after it — they replace `options.companions`. */
217
+ companions: SerializedNode[];
218
+ mix: HeaderMix;
219
+ /** What the owner's work it replaces (empty: nothing). */
220
+ replaced: HeaderReplaced[];
221
+ issues: ComposeIssue[];
222
+ }
223
+
224
+ /** The words a part shows: its own, else its first descendant's. */
225
+ function wordsOf(n: SerializedNode): string {
226
+ for (const p of ['label', 'content', 'text', 'ariaLabel']) {
227
+ const v = n.props?.[p];
228
+ if (typeof v === 'string' && v.trim()) return v.replace(/<[^>]+>/g, '').trim();
229
+ }
230
+ for (const c of n.children ?? []) { const w = wordsOf(c); if (w) return w; }
231
+ return '';
232
+ }
233
+
234
+ /**
235
+ * The header for `next` (HS-4): the recipe's header for the new mix, merged three ways with the header as it is and what
236
+ * its own mix composes (the base). Words — and a call to action's link — are always the owner's. A part's look and its
237
+ * other settings: untouched by the owner, the new mix's; changed by the owner, kept where the new mix draws that part as
238
+ * the old one did, else replaced and named. A part the owner added is named (it is not in the new mix). Pure.
239
+ */
240
+ export function applyHeaderMix(current: SerializedNode, next: HeaderMix, site: HeaderSite, options: HeaderEditOptions = {}): HeaderApplied {
241
+ const curCompanions = options.companions ?? [];
242
+ const baseMix = storedHeaderMix(current) ?? nearestHeaderMix(current, curCompanions);
243
+ const at = siteFor(site, current, curCompanions);
244
+ const baseComposed = compose(baseMix, at, current.id, options);
245
+ const composed = compose(next, at, current.id, options);
246
+ const freshGroup = clone(grouped(composed.header, composed.companions));
247
+ const [fresh, ...freshCompanions] = freshGroup.children!;
248
+ const curBy = keyed(grouped(current, curCompanions));
249
+ const baseBy = keyed(grouped(baseComposed.header, baseComposed.companions));
250
+ const freshBy = keyed(freshGroup);
251
+ const replaced = new Map<string, HeaderReplaced>();
252
+ const replace = (kind: HeaderReplacedKind, n: SerializedNode): void => {
253
+ if (!replaced.has(n.id)) replaced.set(n.id, { kind, nodeId: n.id, ...(n.role ? { role: n.role } : {}), words: wordsOf(n) });
254
+ };
255
+
256
+ for (const [key, f] of freshBy) {
257
+ const cur = curBy.get(key);
258
+ if (!cur) continue;
259
+ const b = baseBy.get(key);
260
+ const props: Record<string, unknown> = { ...f.props };
261
+ for (const [k, v] of Object.entries(cur.props ?? {})) {
262
+ if (WORD_PROPS.has(k) || (LINK_PROPS.has(k) && f.role && OWNED_LINK_ROLES.has(f.role))) {
263
+ if (k in props || WORD_PROPS.has(k)) props[k] = v;
264
+ continue;
265
+ }
266
+ if (LINK_PROPS.has(k) || k === HeaderTrait.Mix || !b) continue;
267
+ if (same(v, b.props?.[k])) continue;
268
+ if (same(f.props?.[k], b.props?.[k])) props[k] = v;
269
+ else replace(HeaderReplacedKind.Style, cur);
270
+ }
271
+ f.props = props;
272
+ if (!b) continue;
273
+ const wears = (n: SerializedNode) => Object.fromEntries(STYLE_FIELDS.map(k => [k, n[k]]));
274
+ if (same(wears(cur), wears(b))) continue;
275
+ if (same(wears(f), wears(b))) {
276
+ for (const k of STYLE_FIELDS) {
277
+ if (cur[k] === undefined) delete (f as unknown as Record<string, unknown>)[k];
278
+ else (f as unknown as Record<string, unknown>)[k] = clone(cur[k]);
279
+ }
280
+ } else {
281
+ replace(HeaderReplacedKind.Style, cur);
282
+ }
283
+ }
284
+ for (const [key, cur] of curBy) if (!baseBy.has(key) && !freshBy.has(key) && !PAGE_ROLES.has(cur.role ?? '')) replace(HeaderReplacedKind.Added, cur);
285
+
286
+ fresh.isGlobal = current.isGlobal ?? fresh.isGlobal;
287
+ if (current.globalPosition) fresh.globalPosition = current.globalPosition;
288
+ return { header: fresh, companions: freshCompanions, mix: next, replaced: [...replaced.values()], issues: composed.issues };
289
+ }
290
+
291
+ /** HB-D8: what `checkHeader` would mend in a mix on this site — said in the studio, never applied by itself. */
292
+ export function headerAdvice(mix: HeaderMix, site: HeaderSite): HeaderRepair[] {
293
+ return checkHeader(drawnHeaderMix(mix).drawn, navHeaderContext(site)).repairs;
294
+ }
295
+
296
+ /** The mix a header becomes when one ingredient changes. */
297
+ export function withHeaderWord(mix: HeaderMix, ingredient: `${HeaderIngredient}`, word: string): HeaderMix {
298
+ return headerMix({ ...mix, [ingredient]: word });
299
+ }
@@ -1,5 +1,5 @@
1
1
  import {
2
- DesignChoices, elementStyleFace, MenuForm, menuButtonOf, menuFormOf, menuHoverOf, MenuLook, MenuPhoneForm, menuRevealOf, resolveDesignChoices, textWidthEm,
2
+ DesignChoices, elementStyleFace, HeaderTrait, MenuForm, menuButtonOf, menuFormOf, menuHoverOf, MenuLook, MenuPhoneForm, menuRevealOf, resolveDesignChoices, textWidthEm,
3
3
  } from '@vectoriox/iox-ui/design-core';
4
4
 
5
5
  import { MenuSide, NavRole, NavShape } from './nav-shape';
@@ -75,15 +75,72 @@ export const DEFAULT_HEADER_PATTERN = 'nav.inline-cta';
75
75
  const INGREDIENTS = H.ingredients as Readonly<Record<string, ReadonlyArray<string>>>;
76
76
  const WAITS = H.waits as Readonly<Record<string, { phase: string; drawnAs: string }>>;
77
77
  const MEANINGS = H.meanings as Readonly<Record<string, string>>;
78
+ const MEANINGS_HE = ((H as { meaningsHe?: unknown }).meaningsHe ?? {}) as Readonly<Record<string, string>>;
79
+ const HEBREW = 'he';
78
80
 
79
81
  /** The words an ingredient may take. */
80
82
  export function headerWords(ingredient: `${HeaderIngredient}`): ReadonlyArray<string> {
81
83
  return INGREDIENTS[ingredient] ?? [];
82
84
  }
83
85
 
84
- /** What a word means, as the brief and the builder say it. */
85
- export function headerMeaning(ingredient: `${HeaderIngredient}`, word: string): string {
86
- return MEANINGS[`${ingredient}.${word}`] ?? word;
86
+ /** What a word means, as the brief and the builder say it — in Hebrew when the builder speaks it (HI1b, board 4d). */
87
+ export function headerMeaning(ingredient: `${HeaderIngredient}`, word: string, locale?: string | null): string {
88
+ const key = `${ingredient}.${word}`;
89
+ return (locale === HEBREW ? MEANINGS_HE[key] : undefined) ?? MEANINGS[key] ?? word;
90
+ }
91
+
92
+ /** Whether the product draws a word today (a waiting word is never offered — HB-D9). */
93
+ export function headerWordDrawn(ingredient: `${HeaderIngredient}`, word: string): boolean {
94
+ return headerWords(ingredient).includes(word) && !WAITS[`${ingredient}.${word}`];
95
+ }
96
+
97
+ // ── The gallery: the named mixes the builder offers (HI1b, HS-6) ───────────────────────────────────────────────────
98
+
99
+ /** One named mix of Components ▸ Header and the Header studio's Start from. */
100
+ export interface HeaderGalleryEntry {
101
+ id: string;
102
+ /** Its name and its words, in the builder's language. */
103
+ name: string;
104
+ words: string;
105
+ mix: HeaderMix;
106
+ }
107
+
108
+ interface HeaderGalleryRow { id: string; name: string; nameHe: string; words: string; wordsHe: string; mix: Partial<HeaderMix> }
109
+ const GALLERY = ((H as { gallery?: unknown }).gallery ?? []) as ReadonlyArray<HeaderGalleryRow>;
110
+
111
+ /** The gallery, in the contract's order (Studio — the defaults — first), named in `locale` (English unless Hebrew). */
112
+ export function headerGallery(locale?: string | null): HeaderGalleryEntry[] {
113
+ const he = locale === HEBREW;
114
+ return GALLERY.map(g => ({ id: g.id, name: he ? g.nameHe : g.name, words: he ? g.wordsHe : g.words, mix: headerMix(g.mix) }));
115
+ }
116
+
117
+ /** The gallery mix a mix is exactly, or null. */
118
+ export function headerGalleryIdOf(mix: HeaderMix): string | null {
119
+ const key = JSON.stringify(headerMixWords(mix));
120
+ return GALLERY.find(g => JSON.stringify(headerMixWords(headerMix(g.mix))) === key)?.id ?? null;
121
+ }
122
+
123
+ // ── The mix a header stores (HI1b, HS-5) ───────────────────────────────────────────────────────────────────────────
124
+
125
+ /** A mix as the header root stores it: its `<ingredient>:<word>` words, space-separated, in the table's order. */
126
+ export function headerMixValue(mix: HeaderMix): string {
127
+ return headerMixWords(mix).join(' ');
128
+ }
129
+
130
+ /** Writes the mix on a header root (its props). */
131
+ export function stampHeaderMix(root: { props: Record<string, unknown> }, mix: HeaderMix): void {
132
+ root.props = { ...root.props, [HeaderTrait.Mix]: headerMixValue(mix) };
133
+ }
134
+
135
+ /** The mix a header root stores, or null — none stored, or words the table no longer knows (read as unstamped). */
136
+ export function storedHeaderMix(root: { props?: Record<string, unknown> } | null | undefined): HeaderMix | null {
137
+ const value = root?.props?.[HeaderTrait.Mix];
138
+ if (typeof value !== 'string' || !value.trim()) return null;
139
+ try {
140
+ return headerMixFromWords(value.trim().split(/\s+/));
141
+ } catch {
142
+ return null;
143
+ }
87
144
  }
88
145
 
89
146
  /** A whole mix from part of one: what is not named is the default (the Studio header). Refuses a word the table lacks. */
@@ -373,6 +430,8 @@ function bodyOf(mix: HeaderMix, ctx: HeaderContext): { lay: Record<string, strin
373
430
  /** What the composer stamps for a header mix: the pattern, its phone shape and where its menu button sits. Check it first
374
431
  * (`checkHeader` on the drawn mix). */
375
432
  export interface HeaderRecipe {
433
+ /** The mix it stamps (stored on the header root — HS-5). */
434
+ mix: HeaderMix;
376
435
  pattern: SitePattern;
377
436
  /** The pages are behind a menu at every width (HI-D8). */
378
437
  everyWidth: boolean;
@@ -417,7 +476,7 @@ export function headerRecipe(mix: HeaderMix, ctx: HeaderContext): HeaderRecipe {
417
476
  header: { behaviour: mix.scroll, edge: mix.edge },
418
477
  node,
419
478
  } as SitePattern;
420
- return { pattern, everyWidth, menuSide, menu: menuLookOf(mix) };
479
+ return { mix, pattern, everyWidth, menuSide, menu: menuLookOf(mix) };
421
480
  }
422
481
 
423
482
  // ── No sameness: another site's header is never worn again (§7, R-H2) ──────────────────────────────────────────────
@@ -135,8 +135,12 @@ export function signatureOf(s: LayoutSection | undefined): LayoutSignatureId {
135
135
  export const LAYOUT_READY_MADE_TOKEN = 'ready-made';
136
136
  const READY_MADE_OPENING = `${LAYOUT_READY_MADE_TOKEN}:`;
137
137
 
138
+ /** A redesign's section place (RD-D20) opens on the owner's part — never a composition of the model's. */
139
+ const CARRIED_OPENING = `${READY_MADE_OPENING}carried`;
140
+
138
141
  function openingOf(s: LayoutSection | undefined): string {
139
142
  if (s?.readyMade) return `${READY_MADE_OPENING}${s.readyMade.pattern}`;
143
+ if (s?.carry) return CARRIED_OPENING;
140
144
  const layers = s?.layers ?? [];
141
145
  const lead = layers.find(l => l.role === LayoutRole.Lead) ?? layers[0];
142
146
  if (!lead) return 'none';
@@ -157,7 +161,7 @@ export function fingerprintOf(page: LayoutPage, preset: string, mode: 'light' |
157
161
  const light = colour ? relativeLuminance(colour) > PHOTO_LIGHT_LUMINANCE : mode === 'light';
158
162
  return {
159
163
  opening: openingOf(first),
160
- sequence: sections.map(s => (s.readyMade ? LAYOUT_READY_MADE_TOKEN : sectionTokenOf(s))),
164
+ sequence: sections.map(s => (s.readyMade || s.carry ? LAYOUT_READY_MADE_TOKEN : sectionTokenOf(s))),
161
165
  signature: signatureOf(sections.find(s => s.signature)),
162
166
  ground: light ? PhotoTone.Light : PhotoTone.Dark,
163
167
  preset,
@@ -322,6 +322,10 @@ export interface LayoutLayer {
322
322
  inner?: number;
323
323
  kinetic?: boolean;
324
324
  motion?: LayoutTrack[];
325
+ /** A redesign (site-redesign RD1): the owner's part this layer places, by its carry handle (`w3`, `p1`,
326
+ * `form:<formId>` — generation-core `harvestPage`) — instead of literal copy. The words, the photo or the form come
327
+ * from the page as it was; `checkCarry` judges every handle. */
328
+ carry?: string;
325
329
  }
326
330
 
327
331
  export interface LayoutSection {
@@ -341,6 +345,9 @@ export interface LayoutSection {
341
345
  /** Silent section fallback (Doron, 2026-11-09): this place is the plan's ready-made section `PagePlan.sections[at]`,
342
346
  * stamped from its pattern in the look; it has no layers of its own. Set only by `fallBackBySection`, never by a model. */
343
347
  readyMade?: LayoutReadyMade;
348
+ /** A redesign (RD-D20): this place shows a carried bound part, block or kept section (`bind:<n>`, `block:<n>`,
349
+ * `keep:<n>`) — its data as it was, the new look on it; it has no layers of its own. */
350
+ carry?: string;
344
351
  }
345
352
 
346
353
  /** The plan section a place of a composed page was given to: its index in `PagePlan.sections` and its pattern. */
@@ -408,6 +415,9 @@ export enum LayoutIssueCode {
408
415
  Sameness = 'sameness',
409
416
  /** The rendered page (the render check): overlap, overflow, a first screen without its lead. */
410
417
  Render = 'render',
418
+ /** A redesign's carry (RD1): a handle that names nothing, sits on the wrong kind of layer, is placed twice, comes with
419
+ * copy of its own — or a form, or a data source a bound part reads, that the new page loses (`checkCarry`). */
420
+ Carry = 'carry',
411
421
  }
412
422
 
413
423
  /** What the composer may settle by itself, with no word or place changed (`mendLayout`). */
@@ -442,9 +452,16 @@ export enum LayoutMendKind {
442
452
  Screens = 'screens',
443
453
  /** A daring or Expressive page whose opening has no display: the opening's lead line is set as one (a word). */
444
454
  Display = 'display',
455
+ /** vectoriox/iox-ui#99: the page where the site lists a list (a shop page's products) shows it in no list section,
456
+ * and a gallery there shows fixed pictures or boxes: that gallery becomes the list section — its source the list,
457
+ * its items cards of the list's parts, each linking to the item's page. No such gallery: left to the model. */
458
+ ShowList = 'show-list',
445
459
  /** A list section's mix that breaks a list rule the composer can settle (list-ingredients §6, `checkList`): the layer
446
460
  * takes the repaired mix — every repair of one list carries the same one. */
447
461
  List = 'list',
462
+ /** A carried part whose action points at a node the new page no longer has (RD1 — a scroll link to a section that
463
+ * left): the action is dropped from the carry and the drop is said (`mendCarry`), never refused. */
464
+ Link = 'link',
448
465
  }
449
466
 
450
467
  /** Which rule chose a mended gallery's list. */
@@ -493,7 +510,9 @@ export type LayoutMend =
493
510
  | { kind: LayoutMendKind.Display; layer: string; size?: `${LayoutSize}` }
494
511
  | { kind: LayoutMendKind.Unpin; section: number }
495
512
  | { kind: LayoutMendKind.Screens; sections: ReadonlyArray<{ section: number; screens: number }> }
496
- | { kind: LayoutMendKind.List; layer: string; mix: LayoutListMix };
513
+ | { kind: LayoutMendKind.List; layer: string; mix: LayoutListMix }
514
+ | { kind: LayoutMendKind.Link; handle: string; from: string; to: string }
515
+ | { kind: LayoutMendKind.ShowList; layer: string; source: string; mix: LayoutListMix };
497
516
 
498
517
  export interface LayoutIssue {
499
518
  code: `${LayoutIssueCode}`;
@@ -101,7 +101,7 @@ export function layoutShapeHasPurpose(s: LayoutSection, li: number): boolean {
101
101
 
102
102
  /** A held section where nothing moves by the scroll: no track, no kinetic line, no gallery the scroll turns. */
103
103
  export function layoutHeldStill(s: LayoutSection): boolean {
104
- if (!s.pin || (s.track ?? 1) > 1 || s.readyMade) return false;
104
+ if (!s.pin || (s.track ?? 1) > 1 || s.readyMade || s.carry) return false;
105
105
  return !(s.layers ?? []).some(l => !!l.motion?.length || !!l.kinetic || (l.kind === LayoutLayerKind.Gallery && !!l.gallery?.scroll));
106
106
  }
107
107
 
@@ -134,7 +134,7 @@ export const LAYOUT_DRIFT: Readonly<LayoutTrack> = { prop: LayoutTrackProp.Scale
134
134
 
135
135
  /** A section whose screen is spoken for: what is on it never leaves it (held, sideways, a photo ground, ready-made), or
136
136
  * its space is the point (an inhale — the page's one breath, a word in the quiet). */
137
- const filled = (s: LayoutSection) => !!s.pin || (s.track ?? 1) > 1 || !!s.readyMade || String(s.ground ?? '').startsWith('photo:')
137
+ const filled = (s: LayoutSection) => !!s.pin || (s.track ?? 1) > 1 || !!s.readyMade || !!s.carry || String(s.ground ?? '').startsWith('photo:')
138
138
  || s.kind === LayoutSectionKind.Inhale;
139
139
 
140
140
  /** Where a layer's ink is in its section (px from the section's top): its cell for what stretches, its words' lines in the
@@ -238,7 +238,7 @@ export function layoutVoidScreens(sections: ReadonlyArray<LayoutSection>): Array
238
238
  /** The layers that make an opening's display: a word (set in the display face), or words at xxl or screen size. */
239
239
  export function layoutOpeningDisplays(page: Pick<LayoutPage, 'sections'>): number[] {
240
240
  const first = page.sections?.[0];
241
- if (!first || first.readyMade) return [];
241
+ if (!first || first.readyMade || first.carry) return [];
242
242
  return (first.layers ?? []).map((l, li) => ({ l, li }))
243
243
  .filter(({ l }) => isText(l) && (l.kind === LayoutLayerKind.Word || l.size === LayoutSize.Screen || l.size === LayoutSize.Xxl))
244
244
  .map(({ li }) => li);
@@ -250,7 +250,7 @@ export function layoutOpeningDisplays(page: Pick<LayoutPage, 'sections'>): numbe
250
250
  */
251
251
  export function layoutOpeningDisplayMend(page: Pick<LayoutPage, 'sections'>): { layer: number; size?: `${LayoutSize}` } | null {
252
252
  const first = page.sections?.[0];
253
- if (!first || first.readyMade) return null;
253
+ if (!first || first.readyMade || first.carry) return null;
254
254
  const li = (first.layers ?? []).findIndex(l => l.role === LayoutRole.Lead && l.kind === LayoutLayerKind.Heading);
255
255
  if (li < 0) return null;
256
256
  const lead = first.layers[li];
@@ -64,6 +64,17 @@ export interface LayoutWireOptions {
64
64
  lists?: ReadonlyArray<LayoutWireList>;
65
65
  /** L-D12: what this business type's lists never do — those words are not offered (the check repairs one anyway). */
66
66
  never?: LayoutListNever | null;
67
+ /** A redesign (site-redesign RD2, H3): THIS page's carry handles (`carryHandles`) — given, every layer carries `carry`,
68
+ * closed to these handles: a model can place only the page's own parts (one property: 38, 40 with lists). */
69
+ carry?: ReadonlyArray<string>;
70
+ }
71
+
72
+ /** A handle the wire places as a whole SECTION (RD-D20): a bound part, a block or a kept section. */
73
+ const SECTION_HANDLE = /^(?:bind|block|keep):/;
74
+
75
+ /** Is `handle` one a section places whole (`bind:`/`block:`/`keep:`), never a layer's words or photo? */
76
+ export function isSectionCarryHandle(handle: string): boolean {
77
+ return SECTION_HANDLE.test(handle);
67
78
  }
68
79
 
69
80
  /** The mix words offered to a business whose lists never do `never` (L-D12): the built words less the forbidden ones. */
@@ -90,6 +101,8 @@ export interface LayoutWireLayer {
90
101
  /** LI1, with `LayoutWireOptions.lists`: a list section's mix (`arrange:grid`…) and its parts (`stories.quote`…). */
91
102
  mix?: string[];
92
103
  parts?: string[];
104
+ /** RD2, with `LayoutWireOptions.carry`: the owner's part this layer places (`w3`, `p1`, `form:<id>`), or 'none'. */
105
+ carry?: string;
93
106
  }
94
107
  export interface LayoutWireSection {
95
108
  id: string; kind: string; screens: number; hold: number; ground: string; rows: number; transition: string; phone: number[];
@@ -112,6 +125,11 @@ export function layoutWireJsonSchema(options: LayoutWireOptions = {}): JsonSchem
112
125
  parts: listOf(jsonOneOf(partWords.length ? partWords : [NONE]), "gallery showing a list as cards: the list's fields each card shows, <list>.<role>, the source's own; [] for none"),
113
126
  }
114
127
  : {};
128
+ const carried: Record<string, JsonSchema> = options.carry
129
+ ? {
130
+ carry: oneOf([NONE, ...options.carry], "a redesign: the owner's part this layer shows, by handle — its words, photo or form as they are (write no text of your own then); a section's ONLY layer naming a bind:/block:/keep: handle makes the whole section that part; 'none' for a layer of your own"),
131
+ }
132
+ : {};
115
133
  const layer = closed({
116
134
  kind: oneOf(V.kinds, 'what the layer is'),
117
135
  role: oneOf(V.roles, 'lead: the ONE thing the eye finds first in its section · support: follows it · decoration: only fades · static: never moves'),
@@ -140,6 +158,7 @@ export function layoutWireJsonSchema(options: LayoutWireOptions = {}): JsonSchem
140
158
  values: listOf({ type: 'number' }, '[from, to, at0, at1]: values and the part of the hold it plays over (0..1)'),
141
159
  }), 'held sections only: tracks the scroll plays; [] for none'),
142
160
  ...lists,
161
+ ...carried,
143
162
  });
144
163
  const section = closed({
145
164
  id: text('a short slug, unique on the page'),
@@ -279,6 +298,7 @@ function expandLayer(l: PlainObject, beat: number): LayoutLayer {
279
298
  if (num(l['inner'])) out.inner = num(l['inner']);
280
299
  const motion = (Array.isArray(l['motion']) ? l['motion'] : []).filter(isPlainObject).map(expandTrack);
281
300
  if (motion.length) out.motion = motion;
301
+ if (nonEmpty(l['carry']) && l['carry'] !== NONE) out.carry = String(l['carry']).trim();
282
302
  return out;
283
303
  }
284
304
 
@@ -298,6 +318,10 @@ function expandSection(s: PlainObject): LayoutSection {
298
318
  const kind = String(s['kind']);
299
319
  const hold = Math.max(0, Math.round(num(s['hold'])));
300
320
  const wired = (Array.isArray(s['layers']) ? s['layers'] : []).filter(isPlainObject);
321
+ // RD-D20: a section whose ONLY layer names a bound part, a block or a kept section IS that part — a section place.
322
+ const whole = wired.length === 1 && nonEmpty(wired[0]['carry']) && isSectionCarryHandle(String(wired[0]['carry']).trim())
323
+ ? String(wired[0]['carry']).trim() : null;
324
+ if (whole) return { id: String(s['id'] ?? ''), screens: 1, rows: 1, layers: [], phone: [], carry: whole };
301
325
  const beats = derivedBeats(wired);
302
326
  const layers = wired.map((l, i) => expandLayer(l, beats[i]));
303
327
  const out: LayoutSection = {
@@ -374,13 +398,24 @@ function layerToWire(l: LayoutLayer): LayoutWireLayer {
374
398
  slots,
375
399
  motion: (l.motion ?? []).map(t => ({ prop: t.prop, ease: t.ease ?? 'out', values: [t.from, t.to, ...(t.at ?? [0, 1])] })),
376
400
  ...(g?.list ? listMixToWire(g.list, g.source ?? '') : {}),
401
+ ...(l.carry ? { carry: l.carry } : {}),
402
+ };
403
+ }
404
+
405
+ /** A section place (RD-D20) on the wire: ONE layer naming its handle — what `expandSection` reads back as the place. */
406
+ function carryPlaceToWire(s: LayoutSection): LayoutWireSection {
407
+ const layer: LayoutWireLayer = {
408
+ kind: 'text', role: 'lead', text: '', items: [], photos: [], source: '', box: [1, 13, 1, 2], size: NONE, color: 'ink', align: 'start',
409
+ z: 0, bleed: NONE, rotate: 0, to: '', variant: NONE, enter: NONE, depth: NONE, inner: 0, flags: [], perView: 0, slots: [], motion: [],
410
+ carry: s.carry,
377
411
  };
412
+ return { id: s.id, kind: 'content', screens: 1, hold: 0, ground: 'ground', rows: 4, transition: 'cut', phone: [0], layers: [layer] };
378
413
  }
379
414
 
380
415
  /** A layout page (or a saved CL2.1 site's sections) → the wire. */
381
416
  export function layoutToWire(page: Pick<LayoutPage, 'sections'>): LayoutWire {
382
417
  return {
383
- sections: page.sections.map(s => ({
418
+ sections: page.sections.map(s => (s.carry ? carryPlaceToWire(s) : {
384
419
  id: s.id,
385
420
  kind: s.signature ? 'signature' : s.kind ?? 'content',
386
421
  screens: s.screens,
@@ -699,6 +699,7 @@ export const NODE_BASELINES: Readonly<Record<string, NodeBaseline>> = {
699
699
  "ariaLabel",
700
700
  "headerBehaviour",
701
701
  "headerEdge",
702
+ "headerMix",
702
703
  "marqueeSpeed",
703
704
  "marqueeDirection",
704
705
  "marqueeFade",
@@ -18,6 +18,10 @@ export * from './patterns';
18
18
  export * from './templates';
19
19
  export * from './serialized-node';
20
20
  export * from './section-stamp';
21
+ export * from './carry';
22
+ export * from './check-carry';
23
+ export * from './carry-fill';
24
+ export * from './refit-page';
21
25
  export * from './shape-check';
22
26
  export * from './json-schema';
23
27
  export * from './validate-site-plan';
@@ -27,6 +31,8 @@ export * from './entrances';
27
31
  export * from './plan-data';
28
32
  export * from './showcase';
29
33
  export * from './site-build-run';
34
+ export * from './redesign-run';
35
+ export * from './redesign-additions';
30
36
  export * from './ai-run';
31
37
  export * from './generation-tier';
32
38
  export * from './recipe-fields';
@@ -58,6 +64,7 @@ export * from './list-table';
58
64
  export * from './layout-space';
59
65
  export * from './layout-fingerprint';
60
66
  export * from './header-mix';
67
+ export * from './header-edit';
61
68
  export * from './footer-mix';
62
69
  export * from './layout-edits';
63
70
  export * from './adjustments';