@vectoriox/iox-ui 5.122.0 → 5.124.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.
@@ -46,6 +46,19 @@ export enum NavRole {
46
46
  Bar = 'nav.bar',
47
47
  BarItem = 'nav.bar-item',
48
48
  More = 'nav.more',
49
+ /** HI1: the page(s) a menu header keeps in the bar beside its menu button (`pages: menu-pinned`). */
50
+ Pinned = 'nav.pinned',
51
+ /** HI1: the header's calls to action when its pages are behind the menu (they stay in the bar). */
52
+ Actions = 'nav.actions',
53
+ /** HI1: one of the two equal sides of a header whose name is centred (`between`, `centred` behind a menu): its parts
54
+ * are the header's own, hidden on a phone as the root's are. */
55
+ Cell = 'nav.cell',
56
+ }
57
+
58
+ /** HI-D15: the side a header's menu button sits on. */
59
+ export enum MenuSide {
60
+ Start = 'start',
61
+ End = 'end',
49
62
  }
50
63
 
51
64
  /** The breakpoints a phone menu may switch at (the responsive Breakpoint ids; Q5: Mobile landscape). */
@@ -74,6 +87,9 @@ export interface NavShapeOptions {
74
87
  * links and call to action are hidden at every width and the pages live in the drawer (a "name and menu" header).
75
88
  * Drawer only. Default: what the header already does (`menuAtEveryWidth`), else phone widths only. */
76
89
  everyWidth?: boolean;
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
+ * is, else the end. */
92
+ menuSide?: MenuSide | `${MenuSide}`;
77
93
  }
78
94
 
79
95
  export interface NavShapeResult {
@@ -122,6 +138,9 @@ export const NAV_PART_LABELS: Readonly<Record<string, string>> = {
122
138
  [NavRole.DrawerLinks]: 'Drawer links',
123
139
  [NavRole.Bar]: 'Bottom bar',
124
140
  [NavRole.More]: 'More',
141
+ [NavRole.Pinned]: 'Pinned pages',
142
+ [NavRole.Actions]: 'Actions',
143
+ [NavRole.Cell]: 'Side',
125
144
  };
126
145
 
127
146
  /** Phosphor icons for the bar's items by route — there is no page icon field (Q6), so the bar starts here and
@@ -467,7 +486,32 @@ function removeRole(node: SerializedNode, role: NavRole): SerializedNode | null
467
486
  * bag (commerce G1 — a phone visitor reaches the cart from every page) and its account entry (E3a — icon only there). */
468
487
  function phoneHiddenParts(root: SerializedNode): SerializedNode[] {
469
488
  const keep = new Set<string | undefined>([NavRole.Brand, NavRole.MenuButton, NavRole.Drawer, ShopRole.CartButton, AccountRole.Account]);
470
- return (root.children ?? []).filter((c, i) => !keep.has(roleOf(c)) && !(i === 0 && !c.role && c.type === LINKED));
489
+ // A centred name's side cells stay (they hold the menu button); their parts hide as the root's own do.
490
+ return (root.children ?? []).flatMap((c, i) => roleOf(c) === NavRole.Cell
491
+ ? (c.children ?? []).filter(k => !keep.has(roleOf(k)))
492
+ : (!keep.has(roleOf(c)) && !(i === 0 && !c.role && c.type === LINKED) ? [c] : []));
493
+ }
494
+
495
+ /** HI1: the parts a header with its menu at every width keeps in the bar — its pinned pages and its calls to action. */
496
+ const KEPT_AT_EVERY_WIDTH = new Set<string | undefined>([NavRole.Pinned, NavRole.Actions]);
497
+
498
+ /** Where the menu button goes: back where it was (an edit keeps the author's place), else by `side` — into the side cell
499
+ * there when the name is centred, else the root's first or last place. */
500
+ function placeMenu(root: SerializedNode, menu: SerializedNode, side: MenuSide | null, was: { parent: SerializedNode; index: number } | null): void {
501
+ if (!side && was) { was.parent.children!.splice(Math.min(was.index, was.parent.children!.length), 0, menu); return; }
502
+ const kids = root.children ?? (root.children = []);
503
+ const cells = kids.filter(c => roleOf(c) === NavRole.Cell);
504
+ const start = side === MenuSide.Start;
505
+ const cell = cells.length ? (start ? cells[0] : cells[cells.length - 1]) : null;
506
+ const into = cell ? (cell.children ?? (cell.children = [])) : kids;
507
+ if (start) into.unshift(menu); else into.push(menu);
508
+ }
509
+
510
+ /** The menu button's parent and place, before it is taken out. */
511
+ function menuPlace(root: SerializedNode): { parent: SerializedNode; index: number } | null {
512
+ let at: { parent: SerializedNode; index: number } | null = null;
513
+ walkSerialized([root], n => { if (at) return; const i = (n.children ?? []).findIndex(c => c.role === NavRole.MenuButton); if (i >= 0) at = { parent: n, index: i }; });
514
+ return at;
471
515
  }
472
516
 
473
517
  /** Board 2 / board 8: five items either way — five pages (Bottom bar) or four pages + More (Both). */
@@ -547,11 +591,13 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
547
591
  if (dr) dr.props = { ...dr.props, closeAbove: everyWidth ? '' : at };
548
592
 
549
593
  // The menu button: Drawer only (Q4: with a bar, the phone header keeps only the brand).
594
+ if (options.menuSide !== undefined && !(Object.values(MenuSide) as string[]).includes(options.menuSide)) throw new NavShapeError(`a menu button cannot sit at "${options.menuSide}"`);
595
+ const was = menuPlace(root);
550
596
  const existingMenu = removeRole(root, NavRole.MenuButton);
551
597
  const menu = wantMenuButton ? (existingMenu ? asToggle(existingMenu) : menuButton(kit, dr!.id, at)) : null;
552
598
 
553
599
  for (const p of phoneHiddenParts(root)) {
554
- if (everyWidth) { displayEverywhere(p, NONE); continue; }
600
+ if (everyWidth && !KEPT_AT_EVERY_WIDTH.has(roleOf(p))) { displayEverywhere(p, NONE); continue; }
555
601
  // Back from every width: the base `none` was this function's, not the author's. Base styles hold ONE display, so
556
602
  // the part takes back what its role is built with (the links row is a row), else its type's own.
557
603
  if (wasEveryWidth && p.styleProps?.[DISPLAY] === NONE) {
@@ -572,7 +618,7 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
572
618
  moveDisplayOverride(menu, at);
573
619
  if (wasEveryWidth) phoneOnly(menu, at, MENU_DISPLAY);
574
620
  }
575
- kids.push(menu);
621
+ placeMenu(root, menu, (options.menuSide as MenuSide | undefined) ?? null, was);
576
622
  }
577
623
  if (dr && shape === NavShape.Drawer) kids.push(dr);
578
624
  if (dr && shape === NavShape.Both) {
@@ -2,8 +2,9 @@ import { ANIMATE_IDS, DesignChoices } from '@vectoriox/iox-ui/design-core';
2
2
  import { planFormPresetIds } from '@vectoriox/iox-ui/forms-core';
3
3
 
4
4
  import { describeShapeKey, jsonAnyOf, jsonBoolean, jsonInteger, jsonListOf, jsonOneOf, JsonSchema, jsonShapedObject, jsonText } from './json-schema';
5
- import { patternLinkSlots, patternOptionalParts, patternSlots, PatternGlobalPosition, SITE_PATTERNS } from './patterns';
5
+ import { patternLinkSlots, patternOptionalParts, patternSlots, SITE_PATTERNS } from './patterns';
6
6
  import { withDerivedSources } from './plan-derived';
7
+ import { DEFAULT_HEADER_PATTERN, HeaderIngredient, headerMeaning, headerMix, headerMixFromWords, headerMixOfPlan, headerMixWords, headerPatternIdOf, headerWireWords } from './header-mix';
7
8
  import { DEFAULT_FOOTER_PATTERN, FooterIngredient, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerPatternIdOf, footerWireWords, footerWords } from './footer-mix';
8
9
  import { shopCategoriesOf } from './shop-plan';
9
10
  import { ContentFieldControl, FIELD_TYPE_OF_CONTROL,
@@ -103,6 +104,13 @@ const FOOTER_WIRE_TEXT = 'string[] — the footer as ONE list of <ingredient>:<w
103
104
  + `each block it holds (holds:pages, holds:contact); an ingredient left out is the default (${footerMixWords(footerMix()).join(', ')}). `
104
105
  + Object.values(FooterIngredient).map(k => `${k}: ${footerWords(k).map(w => `${w} (${footerMeaning(k, w)})`).join(' | ')}`).join('; ');
105
106
 
107
+ /** The header's words as the model reads them (HI1): each ingredient, the words the product draws and their meanings,
108
+ * from the contract's header table. */
109
+ const HEADER_WIRE_TEXT = 'string[] — the header as ONE list of <ingredient>:<word> words, one word per ingredient; an ingredient left out is the '
110
+ + `default (${headerMixWords(headerMix()).join(', ')}). The site decides what it can carry: a menu needs three pages or more, the pages in the bar must fit `
111
+ + 'beside the name, pages either side of the name need a short name, two actions need a shop. '
112
+ + Object.values(HeaderIngredient).map(k => `${k}: ${headerWireWords().filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1)).map(w => `${w} (${headerMeaning(k, w)})`).join(' | ')}`).join('; ');
113
+
106
114
  const WIRE_KEYS: Readonly<Record<`${PlanWireEntry}`, Readonly<Record<string, WireKey>>>> = {
107
115
  plan: {
108
116
  business: inPart(PlanPart.Structure, key('plan.business')),
@@ -201,7 +209,8 @@ const WIRE_KEYS: Readonly<Record<`${PlanWireEntry}`, Readonly<Record<string, Wir
201
209
  route: { refs: ['section.links'], text: 'string — a page route of the plan (no :param)' },
202
210
  },
203
211
  globals: {
204
- header: key('globals.header'),
212
+ // HI1: the header travels as its MIX — like the footer, ONE list of `<ingredient>:<word>` words (header-mix.ts).
213
+ header: { refs: ['globals.header', 'plan.mixes', 'mixes.header'], text: HEADER_WIRE_TEXT },
205
214
  // LI5: the footer travels as its MIX — ONE list of `<ingredient>:<word>` words (footer-mix.ts), every word with its
206
215
  // meaning from the contract's footer table; the plan keeps the pattern it reads as (`globals.footer`) and the mix.
207
216
  footer: { refs: ['globals.footer', 'plan.mixes', 'mixes.footer'], text: FOOTER_WIRE_TEXT },
@@ -220,7 +229,6 @@ const WIRE_KEYS: Readonly<Record<`${PlanWireEntry}`, Readonly<Record<string, Wir
220
229
 
221
230
  /** The plan keys the model does not write, and where the expander takes each from. */
222
231
  export const PLAN_WIRE_DERIVED: Readonly<Record<string, string>> = {
223
- 'mixes.header': 'header ingredients HI1 — until then the header is its globals pattern',
224
232
  'field.type': 'follows from the field\'s control (FIELD_TYPE_OF_CONTROL)',
225
233
  'plan.version': `always '${SITE_PLAN_VERSION}'`,
226
234
  'plan.source': 'this run (the context)',
@@ -301,7 +309,6 @@ export function sectionPatternIds(): string[] {
301
309
  }
302
310
 
303
311
  const sectionPatterns = () => sectionPatternIds().map(id => SITE_PATTERNS[id]);
304
- const globalIds = (position: `${PatternGlobalPosition}`) => Object.entries(SITE_PATTERNS).filter(([, p]) => p.global === position).map(([id]) => id);
305
312
 
306
313
  export function wireFieldJsonSchema(): JsonSchema {
307
314
  return shaped(PlanWireEntry.Field, { name: jsonText(), controller: jsonOneOf(Object.values(ContentFieldControl)), required: jsonBoolean(), note: jsonText() });
@@ -388,7 +395,7 @@ const PLAN_TOP_SCHEMAS: Readonly<Record<string, () => JsonSchema>> = {
388
395
  dataSources: () => jsonListOf(wireDataSourceJsonSchema()),
389
396
  pages: () => jsonListOf(wirePageJsonSchema()),
390
397
  globals: () => shaped(PlanWireEntry.Globals, {
391
- [GlobalSlot.Header]: jsonOneOf(globalIds(PatternGlobalPosition.Before)),
398
+ [GlobalSlot.Header]: jsonListOf(jsonOneOf(headerWireWords())),
392
399
  [GlobalSlot.Footer]: jsonListOf(jsonOneOf(footerWireWords())),
393
400
  }),
394
401
  direction: () => shaped(PlanWireEntry.Direction, { idea: jsonText(), cliche: jsonText(), flip: jsonText(), rules: jsonListOf(jsonText()) }),
@@ -572,18 +579,26 @@ export function expandPlanWire(parts: PlanWireParts, context: PlanWireContext):
572
579
  });
573
580
  }
574
581
 
575
- /** The wire's globals → the plan's: a footer mix that is a stored footer pattern becomes that pattern; any other becomes
576
- * `mixes.footer` beside the Studio footer (the mix wins). A footer that is not a word list is left for the validator. */
582
+ /** The wire's globals → the plan's: a header or footer mix that is a stored pattern becomes that pattern; any other becomes
583
+ * `mixes.<part>` beside the Studio pattern (the mix wins). A part that is not a word list is left for the validator. */
577
584
  function expandWireGlobals(globals: unknown): PlainObject {
578
585
  if (globals === undefined) return {};
579
586
  if (!isPlainObject(globals)) return { globals };
580
- const words = globals[GlobalSlot.Footer];
581
- if (!Array.isArray(words)) return { globals };
582
- let named: string | null = null;
583
- try { named = footerPatternIdOf(footerMixFromWords(words as string[])); } catch { /* the validator names the word */ }
584
- // A mix that IS a stored footer is kept as that pattern alone (the plan stays as a template would write it).
585
- if (named) return { globals: { ...globals, [GlobalSlot.Footer]: named } };
586
- return { globals: { ...globals, [GlobalSlot.Footer]: DEFAULT_FOOTER_PATTERN }, mixes: { footer: [...words] } };
587
+ const out: PlainObject = { ...globals };
588
+ const mixes: Record<string, string[]> = {};
589
+ for (const [slot, readId, fallback] of [
590
+ [GlobalSlot.Header, (w: string[]) => headerPatternIdOf(headerMixFromWords(w)), DEFAULT_HEADER_PATTERN],
591
+ [GlobalSlot.Footer, (w: string[]) => footerPatternIdOf(footerMixFromWords(w)), DEFAULT_FOOTER_PATTERN],
592
+ ] as const) {
593
+ const words = globals[slot];
594
+ if (!Array.isArray(words)) continue;
595
+ let named: string | null = null;
596
+ try { named = readId(words as string[]); } catch { /* the validator names the word */ }
597
+ // A mix that IS a stored pattern is kept as that pattern alone (the plan stays as a template would write it).
598
+ out[slot] = named ?? fallback;
599
+ if (!named) mixes[slot] = [...(words as string[])];
600
+ }
601
+ return { globals: out, ...(Object.keys(mixes).length ? { mixes } : {}) };
587
602
  }
588
603
 
589
604
  // ── The plan → the wire ────────────────────────────────────────────────────────────────────────────────────────────
@@ -639,7 +654,7 @@ const PLAN_TO_WIRE: Readonly<Record<string, (plan: SitePlan) => unknown>> = {
639
654
  contentTypes: plan => plan.contentTypes.map(type => contentTypeToWire(type)),
640
655
  dataSources: plan => plan.dataSources.map(dataSourceToWire),
641
656
  pages: plan => plan.pages.map(page => pageToWire(page)),
642
- globals: plan => ({ ...plan.globals, [GlobalSlot.Footer]: footerMixWords(footerMixOfPlan(plan)) }),
657
+ globals: plan => ({ ...plan.globals, [GlobalSlot.Header]: headerMixWords(headerMixOfPlan(plan)), [GlobalSlot.Footer]: footerMixWords(footerMixOfPlan(plan)) }),
643
658
  direction: plan => ({ idea: plan.direction?.idea ?? NONE, cliche: plan.direction?.cliche ?? NONE, flip: plan.direction?.flip ?? NONE, rules: [...(plan.direction?.rules ?? [])] }),
644
659
  shop: plan => (plan.shop?.products ?? []).map(p => ({ name: p.name, category: p.category, description: p.description, options: p.options.map(o => ({ name: o.name, values: [...o.values] })) })),
645
660
  };
@@ -5496,6 +5496,102 @@ export const SPEC_SITE_FOOTER_PARTS = {
5496
5496
  }
5497
5497
  } as const;
5498
5498
 
5499
+ export const SPEC_SITE_HEADER_PARTS = {
5500
+ "root": {
5501
+ "t": "Container",
5502
+ "es": "nav",
5503
+ "tag": "nav",
5504
+ "role": "nav"
5505
+ },
5506
+ "brand": {
5507
+ "t": "LinkedContainer",
5508
+ "es": "box",
5509
+ "href": "/",
5510
+ "role": "nav.brand",
5511
+ "c": [
5512
+ {
5513
+ "t": "Heading",
5514
+ "es": "h3",
5515
+ "level": "h3",
5516
+ "slot": "brand",
5517
+ "max": 32,
5518
+ "fromBusiness": "name"
5519
+ }
5520
+ ]
5521
+ },
5522
+ "links": {
5523
+ "t": "Container",
5524
+ "es": "box",
5525
+ "role": "nav.links",
5526
+ "lay": {
5527
+ "display": "flex",
5528
+ "flexWrap": "wrap",
5529
+ "gap": "var(--iox-space-gap)",
5530
+ "alignItems": "center",
5531
+ "width": "auto"
5532
+ }
5533
+ },
5534
+ "link": {
5535
+ "t": "Link",
5536
+ "es": "link",
5537
+ "each": "$navPages",
5538
+ "bind": "page.name",
5539
+ "href": "$page.route",
5540
+ "role": "nav.link"
5541
+ },
5542
+ "button": {
5543
+ "t": "ButtonBlock",
5544
+ "es": "button-primary",
5545
+ "href": "/contact",
5546
+ "slot": "cta",
5547
+ "max": 24,
5548
+ "text": "Get in touch",
5549
+ "role": "nav.cta",
5550
+ "textHe": "צרו קשר"
5551
+ },
5552
+ "quiet": {
5553
+ "t": "Link",
5554
+ "es": "link",
5555
+ "href": "/contact",
5556
+ "slot": "cta",
5557
+ "max": 24,
5558
+ "text": "Get in touch",
5559
+ "role": "nav.cta",
5560
+ "textHe": "צרו קשר"
5561
+ },
5562
+ "outlined": {
5563
+ "t": "ButtonBlock",
5564
+ "es": "button-secondary",
5565
+ "href": "$shop",
5566
+ "slot": "cta2",
5567
+ "max": 24,
5568
+ "text": "Shop",
5569
+ "role": "nav.cta",
5570
+ "textHe": "לחנות"
5571
+ },
5572
+ "pinned": {
5573
+ "t": "Container",
5574
+ "es": "box",
5575
+ "role": "nav.pinned",
5576
+ "lay": {
5577
+ "display": "flex",
5578
+ "flexWrap": "wrap",
5579
+ "gap": "var(--iox-space-gap)",
5580
+ "alignItems": "center",
5581
+ "width": "auto"
5582
+ },
5583
+ "c": [
5584
+ {
5585
+ "t": "Link",
5586
+ "es": "link",
5587
+ "each": "$pinnedPages",
5588
+ "bind": "page.name",
5589
+ "href": "$page.route"
5590
+ }
5591
+ ]
5592
+ }
5593
+ } as const;
5594
+
5499
5595
  export const SPEC_SITE_TEMPLATES = {
5500
5596
  "studio": {
5501
5597
  "id": "studio",
@@ -7502,26 +7598,6 @@ export const SPEC_SITE_LAYOUT = {
7502
7598
  "phone.full": "a full-screen index on a phone"
7503
7599
  },
7504
7600
  "waits": {
7505
- "arrange.between": {
7506
- "phase": "HI1",
7507
- "drawnAs": "centred"
7508
- },
7509
- "menuSide.start": {
7510
- "phase": "HI1",
7511
- "drawnAs": "end"
7512
- },
7513
- "pages.menu-pinned": {
7514
- "phase": "HI1",
7515
- "drawnAs": "menu"
7516
- },
7517
- "action.link": {
7518
- "phase": "HI1",
7519
- "drawnAs": "button"
7520
- },
7521
- "action.two": {
7522
- "phase": "HI1",
7523
- "drawnAs": "button"
7524
- },
7525
7601
  "menu.full": {
7526
7602
  "phase": "HI2",
7527
7603
  "drawnAs": "drawer"
@@ -7580,8 +7656,7 @@ export const SPEC_SITE_LAYOUT = {
7580
7656
  "named": {
7581
7657
  "nav.inline-cta": {},
7582
7658
  "nav.centered-logo": {
7583
- "arrange": "centred",
7584
- "action": "none"
7659
+ "arrange": "centred"
7585
7660
  }
7586
7661
  },
7587
7662
  "navKinds": {
@@ -7613,6 +7688,13 @@ export const SPEC_SITE_LAYOUT = {
7613
7688
  "ground",
7614
7689
  "shape"
7615
7690
  ],
7691
+ "rules": {
7692
+ "menuMinLinks": 3,
7693
+ "pinnedMax": 1,
7694
+ "inlineRoomPx": 1100,
7695
+ "betweenNameEm": 7,
7696
+ "betweenMinPages": 2
7697
+ },
7616
7698
  "references": [
7617
7699
  {
7618
7700
  "id": "islands-hanging-logo",
@@ -14,6 +14,7 @@ import { pricesIn } from './plan-words';
14
14
  import { isShopResource, planSells, SHOP_PRODUCTS_MAX, SHOP_SLUG_FIELD, shopContentType } from './shop-plan';
15
15
  import { artDirectionIssues } from './art-direction';
16
16
  import { footerMixFromWords } from './footer-mix';
17
+ import { headerMixFromWords } from './header-mix';
17
18
  import { patternListGap } from './recipe-fields';
18
19
  import { SPEC_SITE_LAYOUT, SPEC_SITE_PLAN_SHAPE } from './site-spec.generated';
19
20
  import {
@@ -689,7 +690,7 @@ function validateGlobals(c: Collector, globals: unknown): void {
689
690
  }
690
691
 
691
692
  /** The parts a plan may carry as a mix, and how each reads its words (only the footer until header ingredients HI1). */
692
- const MIX_READERS: Readonly<Record<string, (words: ReadonlyArray<string>) => unknown>> = { footer: footerMixFromWords };
693
+ const MIX_READERS: Readonly<Record<string, (words: ReadonlyArray<string>) => unknown>> = { header: headerMixFromWords, footer: footerMixFromWords };
693
694
 
694
695
  /** `mixes`: each part's words parse in its table (list ingredients LI5); absent is fine. */
695
696
  function validateMixes(c: Collector, mixes: unknown): void {
@@ -459,8 +459,11 @@ dialog[data-iox-dialog] {
459
459
 
460
460
  /* A navigation's link lists (board 1): no underline at rest — the current page's link is the one
461
461
  underlined (the link's `current` state, link-current-decoration). Keyed on the list's ROLE, so a
462
- composed or adopted header and its drawer read it and no Link holds a literal over its element style. */
462
+ composed or adopted header and its drawer read it and no Link holds a literal over its element style.
463
+ HI1: the pages a menu header keeps in the bar (pinned) and its actions (a quiet link) are the bar's links too. */
463
464
  .iox-role-nav-links,
465
+ .iox-role-nav-pinned,
466
+ .iox-role-nav-actions,
464
467
  .iox-role-nav-drawer-links {
465
468
  --iox-link-decoration: none;
466
469
  --iox-link-underline-rest: 0;