@vectoriox/iox-ui 5.198.0 → 5.200.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 (71) hide show
  1. package/actions-core/index.d.ts +7 -1
  2. package/data-core/index.d.ts +11 -3
  3. package/design-core/index.d.ts +479 -52
  4. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +6 -1
  5. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui-data-core.mjs +30 -4
  7. package/fesm2022/vectoriox-iox-ui-data-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-design-core.mjs +704 -55
  9. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui-forms-core.mjs +5 -2
  11. package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
  12. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +16659 -15146
  13. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  14. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +653 -70
  15. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  16. package/fesm2022/vectoriox-iox-ui.mjs +5 -2
  17. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  18. package/generation-core/index.d.ts +883 -235
  19. package/harness-core/index.d.ts +372 -9
  20. package/package.json +1 -1
  21. package/src/actions-core/element-actions.ts +6 -0
  22. package/src/data-core/placeholder-rows.ts +29 -4
  23. package/src/design-core/brand-neutrals.ts +125 -3
  24. package/src/design-core/colour-words.ts +48 -0
  25. package/src/design-core/design-settings.ts +24 -5
  26. package/src/design-core/design-token.model.ts +8 -0
  27. package/src/design-core/flavor-fixtures.generated.ts +272 -2
  28. package/src/design-core/flavor-spec.generated.ts +310 -40
  29. package/src/design-core/flavor-tokens.ts +5 -1
  30. package/src/design-core/menu-look.ts +23 -0
  31. package/src/design-core/node-classes.ts +39 -0
  32. package/src/design-core/public-api.ts +2 -0
  33. package/src/design-core/signature-move.ts +107 -0
  34. package/src/design-core/style-presets.ts +9 -3
  35. package/src/design-core/token-css.ts +59 -1
  36. package/src/forms-core/form-presets.ts +5 -2
  37. package/src/generation-core/body-mix.ts +41 -0
  38. package/src/generation-core/check-free.ts +17 -9
  39. package/src/generation-core/check-layout.ts +17 -7
  40. package/src/generation-core/colour-mix.ts +53 -3
  41. package/src/generation-core/compose-free.ts +7 -2
  42. package/src/generation-core/compose-site.ts +298 -78
  43. package/src/generation-core/composition.ts +320 -0
  44. package/src/generation-core/footer-mix.ts +202 -16
  45. package/src/generation-core/footer-sign-up.ts +51 -0
  46. package/src/generation-core/free-opening.ts +13 -2
  47. package/src/generation-core/free-wire.ts +8 -0
  48. package/src/generation-core/header-edit.ts +15 -0
  49. package/src/generation-core/header-mix.ts +31 -2
  50. package/src/generation-core/legal.ts +24 -0
  51. package/src/generation-core/menu-shelves.ts +138 -0
  52. package/src/generation-core/nav-shape.ts +138 -15
  53. package/src/generation-core/node-baselines.generated.ts +1 -0
  54. package/src/generation-core/opening-edit.ts +17 -3
  55. package/src/generation-core/opening-mix.ts +69 -5
  56. package/src/generation-core/patterns.ts +7 -0
  57. package/src/generation-core/plan-wire.ts +23 -5
  58. package/src/generation-core/public-api.ts +3 -0
  59. package/src/generation-core/site-build-run.ts +11 -0
  60. package/src/generation-core/site-plan.model.ts +6 -0
  61. package/src/generation-core/site-spec.generated.ts +472 -166
  62. package/src/generation-core/type-led.ts +4 -2
  63. package/src/generation-core/validate-site-plan.ts +4 -1
  64. package/src/harness-core/business-types.ts +31 -0
  65. package/src/harness-core/harness-spec.generated.ts +564 -56
  66. package/src/harness-core/motion.ts +19 -2
  67. package/src/harness-core/popup-stance.ts +56 -3
  68. package/src/harness-core/run-compose-context.ts +32 -6
  69. package/src/harness-core/starting-design.ts +15 -7
  70. package/styles/iox-design.css +35 -0
  71. package/styles/iox-forms.css +53 -0
@@ -0,0 +1,320 @@
1
+ import { patternById, patternNeedsBinding } from './patterns';
2
+ import { SPEC_SITE_LAYOUT } from './site-spec.generated';
3
+ import {
4
+ DataSourcePlan, DEFAULT_SITE_LOCALE, PAGE_ARCHETYPES, PagePlan, PageSectionPlan, PlanDataSourceMode, PlanDataSourceType, SitePlan,
5
+ } from './site-plan.model';
6
+
7
+ /**
8
+ * COMPOSITION (iox-ai-guidance architecture/ai/composition-plan.md, contract `site.layout.composition`): how a page built
9
+ * from PATTERNS is put together. The J10 baseline read Composition 4.2 — Homes of three or four sections (a split hero,
10
+ * three services, a band), two three-across sections side by side, inner pages of a header and one list — where the
11
+ * references hold 5–11 distinct skeletons on a Home and "no two neighbouring sections share a skeleton".
12
+ *
13
+ * Two pure decisions, both read by `composeSite` for a pattern page (never a model-laid or a free one — checkLayout
14
+ * judges those):
15
+ * - `compositionBorrows` — what a page below its kind's `distinct` skeletons may BORROW from what the plan already wrote
16
+ * on its other pages (a list page's items as a preview, a statement, the questions, the Home's Ask). Never a word the
17
+ * plan does not hold but the preview's "See all" (`words.more`); the caller refuses a borrow that would leave a
18
+ * placeholder (`fits`).
19
+ * - `orderPlaces` — the order of a page's sections nearest the archetype's in which no two neighbours share a skeleton
20
+ * (the first place stays first, a closing Ask stays last).
21
+ */
22
+
23
+ /** The contract's composition table (layout.mjs COMPOSITION). */
24
+ export interface CompositionBorrow {
25
+ readonly kind: `${BorrowKind}`;
26
+ readonly families?: ReadonlyArray<string>;
27
+ readonly pattern?: string;
28
+ readonly limit?: number;
29
+ }
30
+ export interface CompositionTable {
31
+ readonly skeletons: Readonly<Record<string, string>>;
32
+ readonly neighbours: 'differ';
33
+ readonly distinct: Readonly<Record<string, number>>;
34
+ readonly maxSections: Readonly<Record<string, number>>;
35
+ readonly borrows: Readonly<Record<string, ReadonlyArray<CompositionBorrow>>>;
36
+ readonly words: { readonly more: Readonly<Record<string, string>> };
37
+ readonly swaps: Readonly<Record<string, CompositionSwap>>;
38
+ }
39
+ /** A sibling a section may wear when no order clears its neighbour: every slot carried (`slots`: source → target). */
40
+ export interface CompositionSwap {
41
+ readonly pattern: string;
42
+ readonly slots: Readonly<Record<string, string>>;
43
+ readonly without?: ReadonlyArray<string>;
44
+ }
45
+
46
+ export const COMPOSITION = (SPEC_SITE_LAYOUT as unknown as { composition: CompositionTable }).composition;
47
+
48
+ export enum BorrowKind {
49
+ List = 'list',
50
+ Section = 'section',
51
+ Ask = 'ask',
52
+ }
53
+
54
+ const HOME_KIND = 'home';
55
+ const ASK_FAMILY = 'cta';
56
+ const FREE_SKELETON = 'free';
57
+ /** The middle a page reorders whole (8! orders); a longer page keeps the archetype's order. */
58
+ const MAX_REORDERED = 8;
59
+ const FAULT_COST = 1000;
60
+
61
+ /** A pattern's skeleton (`skeletons`); a pattern the table does not know reads as its own. */
62
+ export function skeletonOf(pattern: string): string {
63
+ return COMPOSITION.skeletons[pattern] ?? pattern;
64
+ }
65
+
66
+ /** The skeleton a plan section reads as: a free signature section is its own (never the same as a neighbour). */
67
+ export function sectionSkeleton(section: PageSectionPlan, at: number): string {
68
+ return section.free ? `${FREE_SKELETON}:${at}` : skeletonOf(section.pattern);
69
+ }
70
+
71
+ /** The page kind the composition table is keyed by: the Home, else the page's archetype. */
72
+ export function pageKindOf(page: Pick<PagePlan, 'isHome' | 'archetype'>): string | null {
73
+ return page.isHome ? HOME_KIND : page.archetype ?? null;
74
+ }
75
+
76
+ /** A page the composition table arranges: a pattern page (never model-laid, free, or a template's item page) of a kind
77
+ * the table names a minimum for. */
78
+ export function composesPage(page: Pick<PagePlan, 'isHome' | 'archetype' | 'layout' | 'free' | 'routeSource' | 'template'>): boolean {
79
+ const kind = pageKindOf(page);
80
+ return !!kind && kind in COMPOSITION.distinct && !page.layout && !page.free && !page.routeSource && !page.template;
81
+ }
82
+
83
+ /** Two neighbours on one skeleton, counted along a page. */
84
+ export function neighbourFaults(skeletons: ReadonlyArray<string>): number {
85
+ let n = 0;
86
+ for (let i = 1; i < skeletons.length; i++) if (skeletons[i] === skeletons[i - 1]) n++;
87
+ return n;
88
+ }
89
+
90
+ /** A section a page borrows: the plan section to stamp, the list's cut, the page it was read from, said in plain words. */
91
+ export interface BorrowedSection {
92
+ readonly kind: BorrowKind;
93
+ readonly section: PageSectionPlan;
94
+ /** The borrowed list shows its first `limit` items (a Repeater's / accordion's `limit`). */
95
+ readonly limit?: number;
96
+ /** The page key the words were read from. */
97
+ readonly from: string;
98
+ readonly skeleton: string;
99
+ readonly said: string;
100
+ }
101
+
102
+ type TypeKey = string;
103
+ function typeKeyOf(ds: DataSourcePlan | undefined): TypeKey | null {
104
+ if (!ds || ds.type === PlanDataSourceType.Relative || ds.mode !== PlanDataSourceMode.Query) return null;
105
+ return ds.type === PlanDataSourceType.Cms ? `cms:${ds.contentType}` : `shop:${ds.resource}`;
106
+ }
107
+
108
+ const familyOf = (pattern: string): string | null => patternById(pattern)?.family ?? null;
109
+
110
+ /** The words a list page is titled by: its page header's title, else its name. */
111
+ function listTitleOf(page: PagePlan): string {
112
+ const header = page.sections.find(s => familyOf(s.pattern) === 'header' && s.slots?.['title']?.trim());
113
+ return header?.slots?.['title']?.trim() || page.name;
114
+ }
115
+
116
+ /** Every candidate a page may borrow, in the table's order (the caller takes what fits). Pure. */
117
+ function candidatesFor(page: PagePlan, plan: SitePlan, borrow: CompositionBorrow): BorrowedSection[] {
118
+ const others = plan.pages.filter(p => p.key !== page.key && !p.free);
119
+ const own = new Set(page.sections.map(s => s.pattern));
120
+ if (borrow.kind === BorrowKind.List) {
121
+ const aliasOf = new Map(plan.dataSources.map(d => [d.alias, d]));
122
+ const shown = new Set(page.sections.map(s => typeKeyOf(s.binding ? aliasOf.get(s.binding) : undefined)).filter(Boolean));
123
+ const out: BorrowedSection[] = [];
124
+ for (const list of others) {
125
+ // A list page: one that lists a type (never a template page showing one item).
126
+ if (list.routeSource || list.template || list.isHome) continue;
127
+ for (const s of list.sections) {
128
+ const pattern = patternById(s.pattern);
129
+ if (s.free || !s.binding || !pattern || !(borrow.families ?? []).includes(pattern.family) || !patternNeedsBinding(pattern)) continue;
130
+ const type = typeKeyOf(aliasOf.get(s.binding));
131
+ if (!type || shown.has(type)) continue;
132
+ // The plan's own short source of that type (a "latest three") is the preview the model meant.
133
+ const short = plan.dataSources.find(d => typeKeyOf(d) === type && 'limit' in d && d.limit !== undefined && d.limit <= 6);
134
+ const title = listTitleOf(list);
135
+ const more = COMPOSITION.words.more[plan.locale ?? DEFAULT_SITE_LOCALE] ?? COMPOSITION.words.more[DEFAULT_SITE_LOCALE];
136
+ out.push({
137
+ kind: BorrowKind.List,
138
+ section: { pattern: s.pattern, slots: { title, more }, links: { more: list.route }, binding: short?.alias ?? s.binding },
139
+ ...(short ? {} : borrow.limit ? { limit: borrow.limit } : {}),
140
+ from: list.key,
141
+ skeleton: skeletonOf(s.pattern),
142
+ said: `${page.name} shows the first of ${list.name} ("${title}"), linked to ${list.route}`,
143
+ });
144
+ shown.add(type);
145
+ }
146
+ }
147
+ return out;
148
+ }
149
+ if (borrow.kind === BorrowKind.Section) {
150
+ if (!borrow.pattern || own.has(borrow.pattern)) return [];
151
+ for (const other of others) {
152
+ const s = other.sections.find(x => x.pattern === borrow.pattern && !x.free);
153
+ if (!s) continue;
154
+ const { free: _free, ...section } = s;
155
+ return [{
156
+ kind: BorrowKind.Section, section, ...(borrow.limit ? { limit: borrow.limit } : {}), from: other.key,
157
+ skeleton: skeletonOf(s.pattern), said: `${page.name} shows ${other.name}'s ${patternById(s.pattern)?.label ?? s.pattern}`,
158
+ }];
159
+ }
160
+ return [];
161
+ }
162
+ // The Ask: the Home's closing band, unless the page already asks or the band asks for this very page.
163
+ const home = plan.pages.find(p => p.isHome);
164
+ if (!borrow.pattern || !home || home.key === page.key || page.sections.some(s => familyOf(s.pattern) === ASK_FAMILY)) return [];
165
+ const last = home.sections[home.sections.length - 1];
166
+ if (!last || last.pattern !== borrow.pattern || last.free) return [];
167
+ if (Object.values(last.links ?? {}).includes(page.route)) return [];
168
+ const { free: _free, ...section } = last;
169
+ return [{ kind: BorrowKind.Ask, section, from: home.key, skeleton: skeletonOf(last.pattern), said: `${page.name} closes on the Home's Ask` }];
170
+ }
171
+
172
+ /**
173
+ * What a pattern page borrows: candidates in the table's order, each taken only while the page is below its kind's
174
+ * `distinct` skeletons and `maxSections`, only when its skeleton is not on the page yet, and only when `fits` (the
175
+ * caller: it stamps without a placeholder). A model-laid page, a free page or a kind the table names no borrows for
176
+ * borrows nothing. Pure.
177
+ */
178
+ export function compositionBorrows(page: PagePlan, plan: SitePlan, fits: (b: BorrowedSection) => boolean = () => true): BorrowedSection[] {
179
+ const kind = pageKindOf(page);
180
+ if (!kind || !composesPage(page)) return [];
181
+ const borrows = COMPOSITION.borrows[kind] ?? [];
182
+ const target = COMPOSITION.distinct[kind] ?? 0;
183
+ const max = COMPOSITION.maxSections[kind] ?? 0;
184
+ const skeletons = new Set(page.sections.map(sectionSkeleton));
185
+ let count = page.sections.length;
186
+ const taken: BorrowedSection[] = [];
187
+ for (const borrow of borrows) {
188
+ for (const found of candidatesFor(page, plan, borrow)) {
189
+ if (skeletons.size >= target || count >= max) return taken;
190
+ // CO4b: a borrow on a skeleton the page already shows may wear its swap (every slot carried).
191
+ const swapped = skeletons.has(found.skeleton) ? swapOf(found.section) : null;
192
+ const c = swapped ? { ...found, section: swapped, skeleton: skeletonOf(swapped.pattern), said: `${found.said}, worn as ${patternById(swapped.pattern)?.label ?? swapped.pattern}` } : found;
193
+ if (skeletons.has(c.skeleton) || !fits(c)) continue;
194
+ taken.push(c);
195
+ skeletons.add(c.skeleton);
196
+ count++;
197
+ }
198
+ }
199
+ return taken;
200
+ }
201
+
202
+ /** One place on a page: its skeleton, its archetype rank (the slot its family fills) and whether it is held in place. */
203
+ export interface Place {
204
+ readonly skeleton: string;
205
+ readonly rank: number;
206
+ }
207
+
208
+ /** A family's rank on a page kind: the first archetype slot that allows it (absent: the middle). */
209
+ export function archetypeRank(kind: string | null, pattern: string): number {
210
+ const slots = kind ? PAGE_ARCHETYPES[kind]?.slots ?? [] : [];
211
+ const family = familyOf(pattern);
212
+ const at = slots.findIndex(s => family !== null && s.families.includes(family));
213
+ return at >= 0 ? at : slots.length / 2;
214
+ }
215
+
216
+ /** Where borrowed places stand among a page's own: each after the last own place of a rank at most its own (never after
217
+ * a closing Ask; an Ask itself goes last). Returns the base order as indices into `[...own, ...borrowed]`. Pure. */
218
+ export function baseOrder(own: ReadonlyArray<Place & { ask?: boolean }>, borrowed: ReadonlyArray<Place & { ask?: boolean }>): number[] {
219
+ const order = own.map((_, i) => i);
220
+ const closing = own.length > 1 && own[own.length - 1].ask;
221
+ borrowed.forEach((b, j) => {
222
+ const index = own.length + j;
223
+ if (b.ask) { order.push(index); return; }
224
+ const end = closing ? order.length - 1 : order.length;
225
+ let at = 1;
226
+ for (let k = 1; k < end; k++) {
227
+ const place = order[k] < own.length ? own[order[k]] : borrowed[order[k] - own.length];
228
+ if (place.rank <= b.rank) at = k + 1;
229
+ }
230
+ order.splice(Math.min(Math.max(at, 1), end), 0, index);
231
+ });
232
+ return order;
233
+ }
234
+
235
+ /**
236
+ * The order of a page's places nearest `base` in which no two neighbours share a skeleton: the first place stays first,
237
+ * a held last place (a closing Ask) stays last, and among the orders with the fewest such pairs the one with the fewest
238
+ * swapped pairs against `base` wins (ties: the earliest found, so `base` itself when it has no fault). A middle longer
239
+ * than eight keeps `base`. Pure.
240
+ */
241
+ export function orderPlaces(places: ReadonlyArray<Place>, base: ReadonlyArray<number>, holdLast: boolean): number[] {
242
+ const sk = (i: number) => places[i].skeleton;
243
+ const faultsOf = (order: ReadonlyArray<number>) => neighbourFaults(order.map(sk));
244
+ if (faultsOf(base) === 0 || base.length < 3) return [...base];
245
+ const head = base[0];
246
+ const tail = holdLast ? base[base.length - 1] : null;
247
+ const middle = base.slice(1, holdLast ? -1 : undefined);
248
+ if (middle.length > MAX_REORDERED) return [...base];
249
+ const pos = new Map(base.map((v, i) => [v, i]));
250
+ const inversions = (order: ReadonlyArray<number>) => {
251
+ let n = 0;
252
+ for (let i = 0; i < order.length; i++) for (let j = i + 1; j < order.length; j++) if (pos.get(order[i])! > pos.get(order[j])!) n++;
253
+ return n;
254
+ };
255
+ let best: number[] = [...base];
256
+ let bestCost = faultsOf(base) * FAULT_COST;
257
+ const used = new Array(middle.length).fill(false);
258
+ const current: number[] = [head];
259
+ const walk = (): void => {
260
+ if (current.length === middle.length + 1) {
261
+ const order = tail === null ? [...current] : [...current, tail];
262
+ const cost = faultsOf(order) * FAULT_COST + inversions(order);
263
+ if (cost < bestCost) { best = order; bestCost = cost; }
264
+ return;
265
+ }
266
+ for (let i = 0; i < middle.length; i++) {
267
+ if (used[i]) continue;
268
+ // Prune: a neighbour pair already laid costs a fault the best may not afford.
269
+ const prev = current[current.length - 1];
270
+ const added = sk(prev) === sk(middle[i]) ? 1 : 0;
271
+ const partial = neighbourFaults(current.map(sk)) + added;
272
+ if (partial * FAULT_COST >= bestCost) continue;
273
+ used[i] = true;
274
+ current.push(middle[i]);
275
+ walk();
276
+ current.pop();
277
+ used[i] = false;
278
+ }
279
+ };
280
+ walk();
281
+ return best;
282
+ }
283
+
284
+ /** A section worn as its `swaps` sibling — every slot and link carried to the sibling's slot, the sibling's `without`
285
+ * left out — or null when the table names none. Pure. */
286
+ export function swapOf(section: PageSectionPlan): PageSectionPlan | null {
287
+ const swap = section.free ? undefined : COMPOSITION.swaps[section.pattern];
288
+ if (!swap) return null;
289
+ const carry = (from: Readonly<Record<string, string>> | undefined) => Object.fromEntries(Object.entries(from ?? {}).filter(([k]) => swap.slots[k]).map(([k, v]) => [swap.slots[k], v]));
290
+ const links = carry(section.links);
291
+ return {
292
+ pattern: swap.pattern, slots: carry(section.slots), ...(Object.keys(links).length ? { links } : {}),
293
+ ...(swap.without?.length ? { without: [...swap.without] } : {}), ...(section.enter ? { enter: section.enter } : {}),
294
+ };
295
+ }
296
+
297
+ /**
298
+ * The last mend: for each pair of neighbours still on one skeleton, a movable place of the pair (never the first, never a
299
+ * held last) whose plan section has a `swaps` row, worn as that sibling when its skeleton differs from both neighbours.
300
+ * Returns the plan section index → the swapped section (every slot carried, the sibling's `without` left out); the
301
+ * caller stamps it and keeps it only when it stamps clean. Pure.
302
+ */
303
+ export function compositionSwaps(sections: ReadonlyArray<PageSectionPlan>, order: ReadonlyArray<number>, skeletons: ReadonlyArray<string>, holdLast: boolean): Map<number, PageSectionPlan> {
304
+ const out = new Map<number, PageSectionPlan>();
305
+ const sk = order.map(i => skeletons[i]);
306
+ for (let k = 1; k < order.length; k++) {
307
+ if (sk[k] !== sk[k - 1]) continue;
308
+ for (const at of [k, k - 1]) {
309
+ const index = order[at];
310
+ if (at === 0 || (holdLast && at === order.length - 1) || index >= sections.length || out.has(index)) continue;
311
+ const swapped = swapOf(sections[index]);
312
+ const next = swapped ? skeletonOf(swapped.pattern) : null;
313
+ if (!swapped || !next || next === sk[at - 1] || next === sk[at + 1]) continue;
314
+ out.set(index, swapped);
315
+ sk[at] = next;
316
+ break;
317
+ }
318
+ }
319
+ return out;
320
+ }