@vectoriox/iox-ui 5.126.0 → 5.128.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.
@@ -0,0 +1,141 @@
1
+ import { dialogOpenersSelector } from './dialog-opener';
2
+ import { DIALOG_CLOSING_ATTRIBUTE } from './dialog-motion';
3
+
4
+ /**
5
+ * Where a menu's REVEAL grows from (header-ingredients HI2a; header-builder board 2: "origin = the opener's centre"). A
6
+ * zoom scales about it, a circle and the torn edge open from it — so the menu reads as coming OUT of the button that opened
7
+ * it. The reveals themselves are CSS transitions in the shared `iox-design.css` (Emil: a menu toggles, so it must reverse
8
+ * from its live value — a transition, never keyframes); the one beat of script is this: put the opener's centre, in the
9
+ * menu's own box, into two custom properties when the menu opens. ONE function for the live page and the builder canvas
10
+ * (each passes its own box measure). Framework-free.
11
+ */
12
+
13
+ export enum RevealOriginProperty {
14
+ X = '--reveal-x',
15
+ Y = '--reveal-y',
16
+ /** How far the reveal must grow to cover the menu: the distance to its farthest corner (a circle of this radius,
17
+ * centred on the origin, covers the whole box — so the reveal spends its time ON the menu, not past it). */
18
+ R = '--reveal-r',
19
+ }
20
+
21
+ export interface RevealOriginPoint {
22
+ x: number;
23
+ y: number;
24
+ r: number;
25
+ }
26
+
27
+ export interface RevealRect {
28
+ left: number;
29
+ top: number;
30
+ width: number;
31
+ height: number;
32
+ }
33
+
34
+ export interface RevealOriginOptions {
35
+ /** Opener space → the menu's CSS px (the builder canvas is zoomed: its rects are scaled). Default 1. */
36
+ scale?: number;
37
+ /** With no opener, the menu's top-LEFT corner (a start-side menu in LTR, an end-side one in RTL); else top-right. */
38
+ atLeft?: boolean;
39
+ }
40
+
41
+ /**
42
+ * The reveal origin in the menu's own box (CSS px, from its top-left border edge): the opener's centre, or — opened by
43
+ * anything else (a link, an action on another element) — the menu's top corner on its side. `box` is the menu's
44
+ * UNTRANSFORMED box, in the same space as the opener's rect. Pure.
45
+ */
46
+ export function revealOrigin(opener: RevealRect | null | undefined, box: RevealRect, options: RevealOriginOptions = {}): RevealOriginPoint {
47
+ const scale = options.scale && options.scale > 0 ? options.scale : 1;
48
+ const width = box.width / scale;
49
+ const height = box.height / scale;
50
+ const at = !opener || !(opener.width > 0 || opener.height > 0)
51
+ ? { x: Math.round(options.atLeft ? 0 : width), y: 0 }
52
+ : { x: Math.round(((opener.left + opener.width / 2) - box.left) / scale), y: Math.round(((opener.top + opener.height / 2) - box.top) / scale) };
53
+ const r = Math.ceil(Math.max(...[[0, 0], [width, 0], [0, height], [width, height]].map(([cx, cy]) => Math.hypot(cx - at.x, cy - at.y))));
54
+ return { ...at, r };
55
+ }
56
+
57
+ /** The custom properties for an origin. */
58
+ export function revealOriginStyle(origin: RevealOriginPoint): Record<RevealOriginProperty, string> {
59
+ return { [RevealOriginProperty.X]: `${origin.x}px`, [RevealOriginProperty.Y]: `${origin.y}px`, [RevealOriginProperty.R]: `${origin.r}px` };
60
+ }
61
+
62
+ /** An element whose inline style a hold may switch (structural). */
63
+ export interface RevealStyled {
64
+ style: { getPropertyValue(name: string): string; setProperty(name: string, value: string): void; removeProperty(name: string): string };
65
+ }
66
+
67
+ /** The element whose `data-iox-closing` puts the menu in its closed shape (the live `<dialog>` itself; the canvas's stage). */
68
+ export interface RevealClosingMarker {
69
+ hasAttribute(name: string): boolean;
70
+ setAttribute(name: string, value: string): void;
71
+ removeAttribute(name: string): void;
72
+ }
73
+
74
+ /**
75
+ * Write a reveal's origin with the menu HELD in its closed shape — marked closing, its own transitions off — then let it go,
76
+ * so its opening transition starts from the closed shape AT the new origin. Without the hold, the first style the browser
77
+ * computes after the menu shows (showModal, a focus, the measure itself) starts the transition from the CSS default
78
+ * corner, and a circle opened from a start-side button sweeps across the bar from the far corner before it grows. `flush`
79
+ * reads a computed style (the closed shape at the new origin, at once); a transition already running is dropped by it.
80
+ * ONE rule for the live page (`revealFrom`) and the builder canvas.
81
+ */
82
+ export function holdClosedWhile(menu: RevealStyled, marker: RevealClosingMarker, write: () => void, flush: () => void): void {
83
+ const marked = marker.hasAttribute(DIALOG_CLOSING_ATTRIBUTE);
84
+ const inline = menu.style.getPropertyValue('transition');
85
+ menu.style.setProperty('transition', 'none');
86
+ if (!marked) marker.setAttribute(DIALOG_CLOSING_ATTRIBUTE, '');
87
+ try {
88
+ write();
89
+ flush();
90
+ } finally {
91
+ if (!marked) marker.removeAttribute(DIALOG_CLOSING_ATTRIBUTE);
92
+ if (inline) menu.style.setProperty('transition', inline);
93
+ else menu.style.removeProperty('transition');
94
+ }
95
+ }
96
+
97
+ /** What `revealFrom` needs of a live `<dialog>` (structural, so the spec drives it without a DOM). */
98
+ export interface RevealDialogLike extends RevealStyled, RevealClosingMarker {
99
+ id: string;
100
+ offsetWidth: number;
101
+ offsetHeight: number;
102
+ getAttribute(name: string): string | null;
103
+ ownerDocument: {
104
+ defaultView: {
105
+ getComputedStyle(el: unknown): { marginLeft: string; marginTop: string; direction: string; getPropertyValue(name: string): string };
106
+ } | null;
107
+ querySelectorAll(selector: string): ArrayLike<RevealOpenerLike>;
108
+ } | null;
109
+ }
110
+
111
+ export interface RevealOpenerLike {
112
+ getBoundingClientRect(): RevealRect;
113
+ getClientRects?(): ArrayLike<unknown>;
114
+ }
115
+
116
+ const rendered = (el: RevealOpenerLike | null | undefined): el is RevealOpenerLike => {
117
+ if (!el) return false;
118
+ if (el.getClientRects && !el.getClientRects().length) return false;
119
+ const r = el.getBoundingClientRect();
120
+ return r.width > 0 || r.height > 0;
121
+ };
122
+
123
+ /**
124
+ * Set a just-opened live `<dialog>`'s reveal origin from the element that opened it (`opener`), else from the first of its
125
+ * openers that is on screen (`aria-controls` — the menu button at its width), else its top corner — held in its closed
126
+ * shape while it is written (`holdClosedWhile`). Call it right after `showModal()`, before anything else reads a style. A top-layer dialog is fixed at `inset: 0`, so its untransformed box starts at its USED margins — a
127
+ * reveal's starting scale or translate never moves a margin, whereas `getBoundingClientRect` would read it.
128
+ */
129
+ export function revealFrom(dialog: RevealDialogLike | null | undefined, opener?: RevealOpenerLike | null): void {
130
+ const view = dialog?.ownerDocument?.defaultView;
131
+ if (!dialog || !view) return;
132
+ holdClosedWhile(dialog, dialog, () => {
133
+ const cs = view.getComputedStyle(dialog);
134
+ const box = { left: parseFloat(cs.marginLeft) || 0, top: parseFloat(cs.marginTop) || 0, width: dialog.offsetWidth, height: dialog.offsetHeight };
135
+ const from = rendered(opener) ? opener
136
+ : dialog.id ? Array.from(dialog.ownerDocument!.querySelectorAll(dialogOpenersSelector(dialog.id))).find(rendered) ?? null : null;
137
+ const atLeft = (dialog.getAttribute('data-iox-dialog-placement') === 'start') !== (cs.direction === 'rtl');
138
+ const origin = revealOrigin(from ? from.getBoundingClientRect() : null, box, { atLeft });
139
+ for (const [name, value] of Object.entries(revealOriginStyle(origin))) dialog.style.setProperty(name, value);
140
+ }, () => { view.getComputedStyle(dialog).getPropertyValue('clip-path'); });
141
+ }
@@ -1078,6 +1078,11 @@ export const SPEC_TIERS = {
1078
1078
  "type": "color",
1079
1079
  "default": "var(--iox-line)"
1080
1080
  },
1081
+ {
1082
+ "name": "menu-edge",
1083
+ "type": "color",
1084
+ "default": "var(--iox-accent)"
1085
+ },
1081
1086
  {
1082
1087
  "name": "image-radius",
1083
1088
  "type": "radius",
@@ -7153,6 +7158,13 @@ export const SPEC_FLAVOR_PACKS = [
7153
7158
  "group": "components",
7154
7159
  "value": "var(--iox-line)"
7155
7160
  },
7161
+ {
7162
+ "name": "menu-edge",
7163
+ "tier": "component",
7164
+ "type": "color",
7165
+ "group": "components",
7166
+ "value": "var(--iox-accent)"
7167
+ },
7156
7168
  {
7157
7169
  "name": "image-radius",
7158
7170
  "tier": "component",
@@ -9504,6 +9516,13 @@ export const SPEC_FLAVOR_PACKS = [
9504
9516
  "group": "components",
9505
9517
  "value": "var(--iox-line)"
9506
9518
  },
9519
+ {
9520
+ "name": "menu-edge",
9521
+ "tier": "component",
9522
+ "type": "color",
9523
+ "group": "components",
9524
+ "value": "var(--iox-accent)"
9525
+ },
9507
9526
  {
9508
9527
  "name": "image-radius",
9509
9528
  "tier": "component",
@@ -11859,6 +11878,13 @@ export const SPEC_FLAVOR_PACKS = [
11859
11878
  "group": "components",
11860
11879
  "value": "var(--iox-line)"
11861
11880
  },
11881
+ {
11882
+ "name": "menu-edge",
11883
+ "tier": "component",
11884
+ "type": "color",
11885
+ "group": "components",
11886
+ "value": "var(--iox-accent)"
11887
+ },
11862
11888
  {
11863
11889
  "name": "image-radius",
11864
11890
  "tier": "component",
@@ -14238,6 +14264,13 @@ export const SPEC_FLAVOR_PACKS = [
14238
14264
  "group": "components",
14239
14265
  "value": "var(--iox-line)"
14240
14266
  },
14267
+ {
14268
+ "name": "menu-edge",
14269
+ "tier": "component",
14270
+ "type": "color",
14271
+ "group": "components",
14272
+ "value": "var(--iox-accent)"
14273
+ },
14241
14274
  {
14242
14275
  "name": "image-radius",
14243
14276
  "tier": "component",
@@ -16598,6 +16631,13 @@ export const SPEC_FLAVOR_PACKS = [
16598
16631
  "group": "components",
16599
16632
  "value": "var(--iox-line)"
16600
16633
  },
16634
+ {
16635
+ "name": "menu-edge",
16636
+ "tier": "component",
16637
+ "type": "color",
16638
+ "group": "components",
16639
+ "value": "var(--iox-accent)"
16640
+ },
16601
16641
  {
16602
16642
  "name": "image-radius",
16603
16643
  "tier": "component",
@@ -18954,6 +18994,13 @@ export const SPEC_FLAVOR_PACKS = [
18954
18994
  "group": "components",
18955
18995
  "value": "var(--iox-line)"
18956
18996
  },
18997
+ {
18998
+ "name": "menu-edge",
18999
+ "tier": "component",
19000
+ "type": "color",
19001
+ "group": "components",
19002
+ "value": "var(--iox-accent)"
19003
+ },
18957
19004
  {
18958
19005
  "name": "image-radius",
18959
19006
  "tier": "component",
@@ -0,0 +1,157 @@
1
+ /**
2
+ * How a site's MENU looks and moves (header-ingredients-plan.md HI2a; HB-D1/HB-D2, header-builder board v2). The header
3
+ * table's menu words — its form (drawer · full · top panel · card · mega), how it opens (slide · fade · zoom · circle ·
4
+ * torn), the button that opens it (lines · word · dots) and what the mouse does in it (line · dim · row · none) — become
5
+ * TRAITS on the menu's own nodes (the Dialog, the menu button and its Close) and ONE answer every renderer applies: the
6
+ * attributes below, which the shared CSS (`iox-design.css`) reads. A menu with none of them renders exactly as the drawer
7
+ * always did (R-H4): today's look is every default, and a default writes nothing.
8
+ *
9
+ * Framework-free: the composer (generation-core), the builder and both engine paths read it.
10
+ */
11
+
12
+ export enum MenuForm {
13
+ /** A sheet from the menu button's edge — the menu every site had before HI2. */
14
+ Drawer = 'drawer',
15
+ /** The whole screen: an index of the page names. */
16
+ Full = 'full',
17
+ /** A panel that drops from the top, as tall as its content (past 80dvh it scrolls inside itself — T7). */
18
+ Panel = 'panel',
19
+ /** A card that opens from the menu button's corner. */
20
+ Card = 'card',
21
+ /** A wide panel under the bar, its pages in columns. */
22
+ Mega = 'mega',
23
+ }
24
+
25
+ export enum MenuReveal {
26
+ /** A drawer from its edge; any other menu a short drop (today's motion). */
27
+ Slide = 'slide',
28
+ Fade = 'fade',
29
+ /** Grows from the menu button's centre (transform-origin = the opener). */
30
+ Zoom = 'zoom',
31
+ /** `clip-path: circle()` grown from the menu button. */
32
+ Circle = 'circle',
33
+ /** Our own ragged edge (HB-D7) grown from the menu button, rimmed in the look's `menu-edge`. */
34
+ Torn = 'torn',
35
+ }
36
+
37
+ export enum MenuButtonKind {
38
+ /** Three lines that become a cross (the list icon, the drawer's Close an X — today's). */
39
+ Lines = 'lines',
40
+ /** The word Menu, which becomes Close. */
41
+ Word = 'word',
42
+ /** Nine dots that spread under the mouse and become a cross. */
43
+ Dots = 'dots',
44
+ }
45
+
46
+ export enum MenuHover {
47
+ /** A line draws under the page name (today's: the drawn underline of a navigation's links). */
48
+ Line = 'line',
49
+ /** The other page names dim. */
50
+ Dim = 'dim',
51
+ /** The row under the mouse lights up. */
52
+ Row = 'row',
53
+ None = 'none',
54
+ }
55
+
56
+ /** What a card, top panel or mega menu becomes on a phone: the drawer, or the full-screen index (the phone ingredient). */
57
+ export enum MenuPhoneForm {
58
+ Drawer = 'drawer',
59
+ Full = 'full',
60
+ }
61
+
62
+ /** The traits, stored in the node's props (no default: a node saved before HI2 saves none). */
63
+ export enum MenuTrait {
64
+ /** On the menu (the Dialog). */
65
+ Form = 'menuForm',
66
+ Reveal = 'menuReveal',
67
+ Hover = 'menuHover',
68
+ Phone = 'menuPhone',
69
+ /** On the menu button AND the menu's Close (the same button, open). */
70
+ Button = 'menuButton',
71
+ }
72
+
73
+ export enum MenuAttribute {
74
+ Form = 'data-iox-menu',
75
+ Reveal = 'data-iox-reveal',
76
+ Hover = 'data-iox-menu-hover',
77
+ Phone = 'data-iox-menu-phone',
78
+ Button = 'data-iox-menu-button',
79
+ }
80
+
81
+ /** Every attribute a menu part may carry (what a renderer's attribute sync owns). */
82
+ export const MENU_ATTRIBUTES: ReadonlyArray<string> = Object.values(MenuAttribute);
83
+
84
+ /** A menu's whole look. */
85
+ export interface MenuLook {
86
+ form: MenuForm;
87
+ reveal: MenuReveal;
88
+ button: MenuButtonKind;
89
+ hover: MenuHover;
90
+ phone: MenuPhoneForm;
91
+ }
92
+
93
+ /** Today's menu, every default (R-H4: it writes nothing). */
94
+ export const DEFAULT_MENU_LOOK: Readonly<MenuLook> = Object.freeze({
95
+ form: MenuForm.Drawer,
96
+ reveal: MenuReveal.Slide,
97
+ button: MenuButtonKind.Lines,
98
+ hover: MenuHover.Line,
99
+ phone: MenuPhoneForm.Drawer,
100
+ });
101
+
102
+ const valueOf = <E extends string>(values: ReadonlyArray<E>, fallback: E) => (v: unknown): E =>
103
+ typeof v === 'string' && (values as ReadonlyArray<string>).includes(v) ? v as E : fallback;
104
+
105
+ export const menuFormOf = valueOf(Object.values(MenuForm), DEFAULT_MENU_LOOK.form);
106
+ export const menuRevealOf = valueOf(Object.values(MenuReveal), DEFAULT_MENU_LOOK.reveal);
107
+ export const menuButtonOf = valueOf(Object.values(MenuButtonKind), DEFAULT_MENU_LOOK.button);
108
+ export const menuHoverOf = valueOf(Object.values(MenuHover), DEFAULT_MENU_LOOK.hover);
109
+ export const menuPhoneOf = valueOf(Object.values(MenuPhoneForm), DEFAULT_MENU_LOOK.phone);
110
+
111
+ /** Reads a trait (`props` on a serialized node). */
112
+ export type MenuTraitReader = (name: MenuTrait) => unknown;
113
+
114
+ /** The attributes a MENU (the Dialog) renders from its traits — `{}` for today's drawer. */
115
+ export function menuDialogAttributes(read: MenuTraitReader): Record<string, string> {
116
+ const out: Record<string, string> = {};
117
+ const form = menuFormOf(read(MenuTrait.Form));
118
+ const reveal = menuRevealOf(read(MenuTrait.Reveal));
119
+ const hover = menuHoverOf(read(MenuTrait.Hover));
120
+ const phone = menuPhoneOf(read(MenuTrait.Phone));
121
+ if (form !== DEFAULT_MENU_LOOK.form) out[MenuAttribute.Form] = form;
122
+ if (reveal !== DEFAULT_MENU_LOOK.reveal) out[MenuAttribute.Reveal] = reveal;
123
+ if (hover !== DEFAULT_MENU_LOOK.hover) out[MenuAttribute.Hover] = hover;
124
+ if (phone !== DEFAULT_MENU_LOOK.phone) out[MenuAttribute.Phone] = phone;
125
+ return out;
126
+ }
127
+
128
+ /** The attribute a menu BUTTON (or the menu's Close) renders — `{}` for today's list icon. */
129
+ export function menuButtonAttributes(read: MenuTraitReader): Record<string, string> {
130
+ const kind = menuButtonOf(read(MenuTrait.Button));
131
+ return kind === DEFAULT_MENU_LOOK.button ? {} : { [MenuAttribute.Button]: kind };
132
+ }
133
+
134
+ /** The traits a menu's Dialog is stamped with for a look: only what differs from today's (R-H4). */
135
+ export function menuDialogProps(look: Partial<MenuLook>): Record<string, string> {
136
+ const out: Record<string, string> = {};
137
+ if (look.form && look.form !== DEFAULT_MENU_LOOK.form) out[MenuTrait.Form] = look.form;
138
+ if (look.reveal && look.reveal !== DEFAULT_MENU_LOOK.reveal) out[MenuTrait.Reveal] = look.reveal;
139
+ if (look.hover && look.hover !== DEFAULT_MENU_LOOK.hover) out[MenuTrait.Hover] = look.hover;
140
+ if (look.phone && look.phone !== DEFAULT_MENU_LOOK.phone) out[MenuTrait.Phone] = look.phone;
141
+ return out;
142
+ }
143
+
144
+ /** The trait a menu button (and the Close) is stamped with for a kind: none for today's. */
145
+ export function menuButtonProps(kind: MenuButtonKind | undefined): Record<string, string> {
146
+ return kind && kind !== DEFAULT_MENU_LOOK.button ? { [MenuTrait.Button]: kind } : {};
147
+ }
148
+
149
+ /** True when the form shows its own place only above the phone width (a card, a top panel, a mega panel — R-H10: on a
150
+ * phone each becomes the phone menu). A drawer and the full screen are the same at every width. */
151
+ export function menuFormSwitchesOnPhone(form: MenuForm): boolean {
152
+ return form === MenuForm.Panel || form === MenuForm.Card || form === MenuForm.Mega;
153
+ }
154
+
155
+ /** The width (CSS px) at and below which a card, panel or mega menu becomes its phone form — the shared CSS's
156
+ * `@media (max-width: 767px)` and the canvas's container query (Mobile landscape, the phone menu's default). */
157
+ export const MENU_PHONE_MAX_WIDTH = 767;
@@ -14,6 +14,7 @@ export * from './css-names';
14
14
  export * from './token-css';
15
15
  export * from './theme-color';
16
16
  export * from './header-behaviour';
17
+ export * from './menu-look';
17
18
  export * from './flavor';
18
19
  export * from './element-styles';
19
20
  export * from './adopt';
@@ -1,5 +1,5 @@
1
1
  import {
2
- AnimateId, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, colorSchemeClass, DesignChoices, LinkType, resolveDesignChoices, setColorScheme,
2
+ AnimateId, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, colorSchemeClass, DEFAULT_MENU_LOOK, DesignChoices, LinkType, MenuLook, resolveDesignChoices, setColorScheme,
3
3
  } from '@vectoriox/iox-ui/design-core';
4
4
  import { SEO_DESCRIPTION_MAX, SEO_TITLE_MAX, SeoRawDoc } from '@vectoriox/iox-ui/seo-core';
5
5
  import { channelOpensNewTab, FORM_ACTIONS_ROLE, FORM_CHANNEL_ROLE, FormPresetChannel, FormPresetDef, FormPresetField, formPresetById } from '@vectoriox/iox-ui/forms-core';
@@ -1571,7 +1571,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1571
1571
  // pages are behind its menu shows the menu at every width, on the side the mix names.
1572
1572
  for (const [slot, pattern] of slotPatterns) {
1573
1573
  if (!pattern.phoneMenu) continue;
1574
- globals = planNavShape(globals, pattern.phoneMenu as NavShape, headerShapeOptions(slot === GlobalSlot.Header ? header.recipe : null), slot).globals;
1574
+ globals = planNavShape(globals, pattern.phoneMenu as NavShape, headerShapeOptions(slot === GlobalSlot.Header ? header.recipe : null, plan.locale), slot).globals;
1575
1575
  }
1576
1576
  // Premium M4 (T2): a header pattern's behaviour as the page scrolls — the same edit the Header section makes.
1577
1577
  for (const [slot, pattern] of slotPatterns) {
@@ -1605,9 +1605,14 @@ export function planHeader(plan: SitePlan): { recipe: HeaderRecipe; context: Hea
1605
1605
 
1606
1606
  /** The phone-menu options a header recipe asks for: its menu at every width and on its side (none for the defaults, so a
1607
1607
  * stored header's edit is the one it always was). */
1608
- function headerShapeOptions(recipe: HeaderRecipe | null): { everyWidth?: boolean; menuSide?: MenuSide } {
1608
+ function headerShapeOptions(recipe: HeaderRecipe | null, locale?: string): { everyWidth?: boolean; menuSide?: MenuSide; look?: Partial<MenuLook>; locale?: string } {
1609
1609
  if (!recipe) return {};
1610
- return { ...(recipe.everyWidth ? { everyWidth: true } : {}), ...(recipe.menuSide === MenuSide.Start ? { menuSide: MenuSide.Start } : {}) };
1610
+ // HI2a: the menu's look, only what differs from today's menu (a stored header composes as it always did — R-H4).
1611
+ const look = Object.fromEntries(Object.entries(recipe.menu).filter(([k, v]) => DEFAULT_MENU_LOOK[k as keyof MenuLook] !== v)) as Partial<MenuLook>;
1612
+ return {
1613
+ ...(recipe.everyWidth ? { everyWidth: true } : {}), ...(recipe.menuSide === MenuSide.Start ? { menuSide: MenuSide.Start } : {}),
1614
+ ...(Object.keys(look).length ? { look, ...(locale ? { locale } : {}) } : {}),
1615
+ };
1611
1616
  }
1612
1617
 
1613
1618
  // ── The site header on its own (CC1.1) ──────────────────────────────────────────────────────────
@@ -1707,7 +1712,7 @@ export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOption
1707
1712
  root.isGlobal = true;
1708
1713
  root.globalPosition = pattern.global;
1709
1714
  const shape = pattern.phoneMenu as NavShape | undefined;
1710
- const header = shape ? planNavShape([root], shape, { newId: options.newId, ...headerShapeOptions(recipe) }, root.id).globals[0] : root;
1715
+ const header = shape ? planNavShape([root], shape, { newId: options.newId, ...headerShapeOptions(recipe, input.locale) }, root.id).globals[0] : root;
1711
1716
  if (pattern.header) setHeaderBehaviour(header as unknown as CompositeNode, pattern.header.behaviour, pattern.header.edge ?? null);
1712
1717
  return { header, issues, mix: checked.mix };
1713
1718
  }
@@ -1,4 +1,6 @@
1
- import { DesignChoices, elementStyleFace, resolveDesignChoices, textWidthEm } from '@vectoriox/iox-ui/design-core';
1
+ import {
2
+ DesignChoices, elementStyleFace, MenuForm, menuButtonOf, menuFormOf, menuHoverOf, MenuLook, MenuPhoneForm, menuRevealOf, resolveDesignChoices, textWidthEm,
3
+ } from '@vectoriox/iox-ui/design-core';
2
4
 
3
5
  import { MenuSide, NavRole, NavShape } from './nav-shape';
4
6
  import { PatternGlobalPosition, PatternNode, SITE_PATTERNS, SitePattern } from './patterns';
@@ -30,6 +32,16 @@ export enum HeaderIngredient {
30
32
  Scroll = 'scroll',
31
33
  Edge = 'edge',
32
34
  Phone = 'phone',
35
+ /** HB-D1 (HI2a): how the menu opens. */
36
+ Reveal = 'reveal',
37
+ /** HB-D1 (HI2a): the button that opens it. */
38
+ Button = 'button',
39
+ /** HB-D1 (HI2a): what the mouse does in it. */
40
+ MenuHover = 'menuHover',
41
+ /** HB-D1 (HI3): what sits above the bar. */
42
+ Above = 'above',
43
+ /** HB-D1 (HI3 / HI6): what more sits in the bar. */
44
+ InBar = 'inBar',
33
45
  }
34
46
 
35
47
  export enum HeaderArrange {
@@ -365,9 +377,26 @@ export interface HeaderRecipe {
365
377
  /** The pages are behind a menu at every width (HI-D8). */
366
378
  everyWidth: boolean;
367
379
  menuSide: MenuSide;
380
+ /** HI2a: the menu's look — what `planNavShape` writes on the drawer, the menu button and its Close. */
381
+ menu: MenuLook;
382
+ }
383
+
384
+ /** The menu's look for a mix (HI2a): with its pages behind the menu, the `menu` form at every width and the `phone`
385
+ * ingredient's form on a phone; with its pages in the bar, the menu exists on a phone only, so its form IS the phone's
386
+ * (the drawer, or the full screen). How it opens, its button and its hover come from their own ingredients. */
387
+ export function menuLookOf(mix: HeaderMix): MenuLook {
388
+ const phoneFull = mix.phone === 'full';
389
+ const form = behindMenu(mix) ? menuFormOf(mix.menu) : phoneFull ? MenuForm.Full : MenuForm.Drawer;
390
+ return {
391
+ form,
392
+ reveal: menuRevealOf(mix.reveal),
393
+ button: menuButtonOf(mix.button),
394
+ hover: menuHoverOf(mix.menuHover),
395
+ phone: phoneFull && form !== MenuForm.Full ? MenuPhoneForm.Full : MenuPhoneForm.Drawer,
396
+ };
368
397
  }
369
398
 
370
- /** The phone ingredient as the phone menu's shape (`full` waits for HI2 and is drawn as the drawer). */
399
+ /** The phone ingredient as the phone menu's shape (`full` is the drawer's Dialog, dressed as the full screen — HI2a). */
371
400
  const PHONE_SHAPE: Readonly<Record<string, NavShape>> = { drawer: NavShape.Drawer, bar: NavShape.Bar, both: NavShape.Both, full: NavShape.Drawer };
372
401
 
373
402
  /** A header mix as a pattern: what the composer stamps as the site's header (global, before the page). A mix that IS a
@@ -388,14 +417,19 @@ export function headerRecipe(mix: HeaderMix, ctx: HeaderContext): HeaderRecipe {
388
417
  header: { behaviour: mix.scroll, edge: mix.edge },
389
418
  node,
390
419
  } as SitePattern;
391
- return { pattern, everyWidth, menuSide };
420
+ return { pattern, everyWidth, menuSide, menu: menuLookOf(mix) };
392
421
  }
393
422
 
394
423
  // ── No sameness: another site's header is never worn again (§7, R-H2) ──────────────────────────────────────────────
395
424
 
396
425
  /** The ingredients `distinctHeader` may change, in the order it tries them: how the pages are reached before where the
397
426
  * name sits (the model chose the arrangement; the fingerprint sees both). */
398
- const MEND_ORDER: ReadonlyArray<HeaderIngredient.Pages | HeaderIngredient.Arrange> = [HeaderIngredient.Pages, HeaderIngredient.Arrange];
427
+ const MEND_ORDER: ReadonlyArray<HeaderIngredient.Pages | HeaderIngredient.Arrange | HeaderIngredient.Reveal | HeaderIngredient.Button> = [
428
+ HeaderIngredient.Pages, HeaderIngredient.Arrange,
429
+ // HB-D6: how the menu opens and its button are in the fingerprint — the least visible change of all, tried after the
430
+ // two the model chose with the site in mind.
431
+ HeaderIngredient.Reveal, HeaderIngredient.Button,
432
+ ];
399
433
 
400
434
  /** The words of an ingredient the product draws. */
401
435
  const drawnWords = (k: `${HeaderIngredient}`): string[] => headerWords(k).filter(w => !WAITS[`${k}.${w}`]);
@@ -1,5 +1,5 @@
1
1
  import { AccountRole, ShopRole } from '@vectoriox/iox-ui/composite-core';
2
- import { LinkType } from '@vectoriox/iox-ui/design-core';
2
+ import { LinkType, MenuButtonKind, menuButtonOf, menuButtonProps, menuDialogProps, MenuLook, MenuTrait } from '@vectoriox/iox-ui/design-core';
3
3
 
4
4
  import { PatternGlobalPosition } from './patterns';
5
5
  import { createSerializedNode, SerializedNode, walkSerialized } from './serialized-node';
@@ -90,6 +90,12 @@ export interface NavShapeOptions {
90
90
  /** HI-D15: the menu button at the start or the end of the bar (or of the side cell there). Default: where it already
91
91
  * is, else the end. */
92
92
  menuSide?: MenuSide | `${MenuSide}`;
93
+ /** HI2a: the menu's look — its form, how it opens, its button, what the mouse does in it, its phone form. Written as
94
+ * traits on the drawer, the menu button and the drawer's Close; a default writes nothing (R-H4). Absent: the parts
95
+ * keep what they have. */
96
+ look?: Partial<MenuLook>;
97
+ /** The site's language, for the words a menu button shows (`word`: Menu ⇄ Close). Default English. */
98
+ locale?: string;
93
99
  }
94
100
 
95
101
  export interface NavShapeResult {
@@ -122,10 +128,23 @@ const COMPOSED = { releaseLayoutDefaults: true };
122
128
  export const NAV_SHAPE_COPY = {
123
129
  menu: 'Menu',
124
130
  closeMenu: 'Close menu',
131
+ /** HI2a: the word a `word` menu button turns into while its menu is open. */
132
+ close: 'Close',
125
133
  more: 'More',
126
134
  home: 'Home',
127
135
  } as const;
128
136
 
137
+ /** The words a `word` menu button SHOWS, in the site's language (HI2a — visible words; the other parts' copy is still
138
+ * English and editable, as it always was). */
139
+ const MENU_WORDS: Readonly<Record<string, { menu: string; close: string }>> = {
140
+ en: { menu: NAV_SHAPE_COPY.menu, close: NAV_SHAPE_COPY.close },
141
+ he: { menu: 'תפריט', close: 'סגירה' },
142
+ };
143
+
144
+ export function menuWords(locale: string | undefined): { menu: string; close: string } {
145
+ return MENU_WORDS[locale ?? ''] ?? MENU_WORDS['en'];
146
+ }
147
+
129
148
  /** The layer names of the parts (R2: the tree, the breadcrumb and the toolbar read them). */
130
149
  export const NAV_PART_LABELS: Readonly<Record<string, string>> = {
131
150
  [NavRole.Root]: 'Navigation bar',
@@ -156,6 +175,9 @@ const ROUTE_ICONS: ReadonlyArray<[RegExp, string]> = [
156
175
  const FALLBACK_ICON = 'ph-thin ph-file';
157
176
  const MENU_ICON = 'ph-thin ph-list';
158
177
  const CLOSE_ICON = 'ph-thin ph-x';
178
+ /** A `dots` button's icon — what a renderer without the shared CSS shows; the shared CSS draws the nine dots and their
179
+ * cross itself (iox-design.css "the menu's buttons"). */
180
+ const DOTS_ICON = 'ph-thin ph-dots-nine';
159
181
  const MORE_ICON = 'ph-thin ph-dots-three';
160
182
 
161
183
  export function barIconForRoute(route: string): string {
@@ -420,6 +442,61 @@ function drawer(kit: Kit, root: SerializedNode, pages: NavPage[], at: string): S
420
442
  return dr;
421
443
  }
422
444
 
445
+ // ── HI2a: the menu's look ───────────────────────────────────────────────────────────────────
446
+
447
+ /** The menu's own traits (on the drawer); its button's trait is on the menu button and the drawer's Close. */
448
+ const MENU_DIALOG_TRAITS: ReadonlyArray<[keyof MenuLook, MenuTrait]> = [
449
+ ['form', MenuTrait.Form], ['reveal', MenuTrait.Reveal], ['hover', MenuTrait.Hover], ['phone', MenuTrait.Phone],
450
+ ];
451
+
452
+ /** Write the look's menu traits on the drawer: each one the look names is replaced (a default writes nothing — R-H4);
453
+ * what it does not name is kept. */
454
+ function dressDrawer(dr: SerializedNode, look: Partial<MenuLook>): void {
455
+ const props = { ...(dr.props ?? {}) };
456
+ for (const [key, trait] of MENU_DIALOG_TRAITS) if (look[key] !== undefined) delete props[trait];
457
+ dr.props = { ...props, ...menuDialogProps(look) };
458
+ }
459
+
460
+ /** A `word` button is as wide as its word (never narrower than the icon button it replaces). */
461
+ const WORD_BUTTON_LAY = { width: 'auto', minWidth: '48px' };
462
+
463
+ /** What a menu button shows for its kind — closed (the menu button) or open (the drawer's Close, which lands where the
464
+ * menu button is): the list icon and an X, the nine dots and an X (the shared CSS draws both as dots), or the word. */
465
+ function buttonFace(kit: Kit, suffix: string, kind: MenuButtonKind, open: boolean, locale: string | undefined): SerializedNode[] {
466
+ switch (kind) {
467
+ case MenuButtonKind.Word: {
468
+ const words = menuWords(locale);
469
+ return [labelText(kit, `${suffix}-word`, open ? words.close : words.menu)];
470
+ }
471
+ case MenuButtonKind.Dots: return [iconNode(kit, `${suffix}-dots`, open ? CLOSE_ICON : DOTS_ICON)];
472
+ default: return [iconNode(kit, `${suffix}-icon`, open ? CLOSE_ICON : MENU_ICON)];
473
+ }
474
+ }
475
+
476
+ /** Give a menu button (or the drawer's Close) a kind. The same kind keeps the author's children; another kind gets that
477
+ * kind's face and size. */
478
+ function dressButton(kit: Kit, btn: SerializedNode, suffix: string, kind: MenuButtonKind, open: boolean, locale: string | undefined): void {
479
+ const was = menuButtonOf(btn.props?.[MenuTrait.Button]);
480
+ const { [MenuTrait.Button]: _drop, ...props } = btn.props ?? {};
481
+ btn.props = { ...props, ...menuButtonProps(kind) };
482
+ if (was === kind) return;
483
+ btn.children = buttonFace(kit, suffix, kind, open, locale);
484
+ if (kind === MenuButtonKind.Word) Object.assign(btn.styleProps, WORD_BUTTON_LAY);
485
+ else if (was === MenuButtonKind.Word) Object.assign(btn.styleProps, { width: MENU_BUTTON_LAY.width, minWidth: ICON_BUTTON_MIN_WIDTH });
486
+ }
487
+
488
+ /** An icon menu button's own min-width (its type's, as `part` stamps it) — what a `word` button gives back. */
489
+ const ICON_BUTTON_MIN_WIDTH = String(createSerializedNode('min-width', BUTTON, { tag: 'button' }, 'button-ghost', COMPOSED).styleProps['minWidth'] ?? '0px');
490
+
491
+ /** Put a look on a header's menu: the drawer's traits, and the menu button's and the Close's kind. */
492
+ function dressMenu(kit: Kit, dr: SerializedNode | null, menu: SerializedNode | null, look: Partial<MenuLook>, locale: string | undefined): void {
493
+ if (dr) dressDrawer(dr, look);
494
+ if (!look.button) return;
495
+ if (menu) dressButton(kit, menu, 'menu', look.button, false, locale);
496
+ const close = dr ? find([dr], NavRole.DrawerClose) : null;
497
+ if (close) dressButton(kit, close, 'drawer-close', look.button, true, locale);
498
+ }
499
+
423
500
  function barItem(kit: Kit, i: number, page: NavPage): SerializedNode {
424
501
  const item = part(kit, `bar-item-${i}`, LINKED, { linkType: LinkType.Page, pageRoute: page.route, target: '_self' }, 'bottom-bar-item', NavRole.BarItem, BAR_ITEM_LAY);
425
502
  item.label = page.label;
@@ -620,6 +697,8 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
620
697
  }
621
698
  placeMenu(root, menu, (options.menuSide as MenuSide | undefined) ?? null, was);
622
699
  }
700
+ // HI2a: the menu's look, when one is asked (the composer's header recipe; the Header studio later).
701
+ if (options.look) dressMenu(kit, dr, menu, options.look, options.locale);
623
702
  if (dr && shape === NavShape.Drawer) kids.push(dr);
624
703
  if (dr && shape === NavShape.Both) {
625
704
  dr.isGlobal = true;
@@ -306,7 +306,8 @@ export const NODE_BASELINES: Readonly<Record<string, NodeBaseline>> = {
306
306
  "__accessibilityLabel",
307
307
  "ariaLabel",
308
308
  "tooltip",
309
- "tooltipPlacement"
309
+ "tooltipPlacement",
310
+ "menuButton"
310
311
  ],
311
312
  "styleTraits": [
312
313
  "position",
@@ -4953,7 +4954,11 @@ export const NODE_BASELINES: Readonly<Record<string, NodeBaseline>> = {
4953
4954
  "closeAbove",
4954
4955
  "__accessibilityLabel",
4955
4956
  "ariaLabel",
4956
- "colorScheme"
4957
+ "colorScheme",
4958
+ "menuForm",
4959
+ "menuReveal",
4960
+ "menuHover",
4961
+ "menuPhone"
4957
4962
  ],
4958
4963
  "styleTraits": [
4959
4964
  "position",