@vectoriox/iox-ui 5.196.0 → 5.197.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 (39) hide show
  1. package/composite-core/index.d.ts +3 -0
  2. package/data-core/index.d.ts +101 -2
  3. package/design-core/index.d.ts +24 -3
  4. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +15 -8
  5. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui-data-core.mjs +192 -2
  7. package/fesm2022/vectoriox-iox-ui-data-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-design-core.mjs +41 -3
  9. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +445 -135
  11. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  12. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +3 -1
  13. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  14. package/fesm2022/vectoriox-iox-ui.mjs +30 -0
  15. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  16. package/generation-core/index.d.ts +170 -18
  17. package/harness-core/index.d.ts +1 -1
  18. package/package.json +1 -1
  19. package/src/composite-core/slider-runtime.ts +16 -8
  20. package/src/data-core/placeholder-rows.ts +220 -0
  21. package/src/data-core/public-api.ts +2 -1
  22. package/src/design-core/header-behaviour.ts +10 -2
  23. package/src/design-core/node-links.ts +34 -0
  24. package/src/generation-core/audit-site.ts +10 -1
  25. package/src/generation-core/audit-words.ts +5 -0
  26. package/src/generation-core/check-free.ts +21 -3
  27. package/src/generation-core/compose-site.ts +32 -9
  28. package/src/generation-core/free-opening.ts +57 -0
  29. package/src/generation-core/header-mix.ts +84 -4
  30. package/src/generation-core/item-fill.ts +42 -0
  31. package/src/generation-core/nav-shape.ts +45 -16
  32. package/src/generation-core/node-baselines.generated.ts +1 -0
  33. package/src/generation-core/opening-mix.ts +10 -0
  34. package/src/generation-core/public-api.ts +2 -0
  35. package/src/generation-core/site-build-run.ts +4 -0
  36. package/src/generation-core/stock-search.ts +106 -18
  37. package/src/generation-core/type-led.ts +19 -4
  38. package/src/harness-core/run-compose-context.ts +3 -1
  39. package/styles/iox-design.css +5 -4
@@ -0,0 +1,220 @@
1
+ import { resolveRepeaterItems } from './data-source-resolver';
2
+
3
+ /**
4
+ * Ghost cards (vectoriox/iox-ui#178, Doron 2026-11-28; board `architecture/ai/boards/ghost-cards.board.html`).
5
+ *
6
+ * A generated site keeps its sample items: every page, section and list stays, so the owner sees where things go.
7
+ * A sample the build could not name (it is still "Product 2") is a PLACEHOLDER ROW. The builder canvas and Preview draw
8
+ * it as a ghost card that asks the owner to add the first item. The live site never shows it. This file is the ONE
9
+ * reading of both, so the builder and the SSR engine agree:
10
+ *
11
+ * - `isNumberedPlaceholderTitle` — words and then a number (G-D1). The Publishable gate reads it as well.
12
+ * - `isPlaceholderRow(row, titleField)` — a row marked `isSample` whose title is such a placeholder.
13
+ * - `listTitleField(list)` — the field a list's card shows as its title.
14
+ * - `planPlaceholderHides(roots, resolved)` — what the live engine leaves out (G-D3): placeholder rows are dropped,
15
+ * a list with no live row is not drawn, and its top-level section hides when only its frame is left (heading,
16
+ * eyebrow, lead text, buttons). Pages and their nav links stay (G-D4).
17
+ *
18
+ * Pure and framework-free: no transport, no Angular.
19
+ */
20
+
21
+ /** The stored field that marks a seeded sample item (iox-cms `SAMPLE_FIELD`). */
22
+ export const SAMPLE_ROW_FIELD = 'isSample';
23
+
24
+ /** The fields a row's title is read from when its list names none (a hand-built list, a slider without a title part). */
25
+ export const PLACEHOLDER_TITLE_FALLBACK_FIELDS: readonly string[] = ['title', 'name', 'label'];
26
+
27
+ /**
28
+ * A title that is a numbered placeholder: words and then the item's number ("Product 2", "Room 2", "שם מעצבת השיער 1",
29
+ * "Sample name 3"). Read only on rows marked `isSample`, so a real item called "Studio 54" is never one.
30
+ */
31
+ export function isNumberedPlaceholderTitle(title: string | null | undefined): boolean {
32
+ return typeof title === 'string' && /^\D*\S\s+\d{1,3}$/u.test(title.trim());
33
+ }
34
+
35
+ /** The value at a dotted path of a row (`title`, `details.name`). */
36
+ function fieldOf(row: Record<string, unknown>, path: string): unknown {
37
+ let at: unknown = row;
38
+ for (const key of path.split('.').filter(Boolean)) {
39
+ if (at == null || typeof at !== 'object') return undefined;
40
+ at = (at as Record<string, unknown>)[key];
41
+ }
42
+ return at;
43
+ }
44
+
45
+ /**
46
+ * True when a row is a sample still titled "<words> <n>" — the builder draws a ghost card for it, the live site leaves it
47
+ * out. `titleField` is the list's title field (`listTitleField`); without one the row's `title` / `name` / `label` is
48
+ * read. A row with no title to read is never a placeholder: when in doubt, show it.
49
+ */
50
+ export function isPlaceholderRow(row: unknown, titleField?: string | null): boolean {
51
+ if (!row || typeof row !== 'object' || Array.isArray(row)) return false;
52
+ const r = row as Record<string, unknown>;
53
+ if (r[SAMPLE_ROW_FIELD] !== true) return false;
54
+ const field = titleField || PLACEHOLDER_TITLE_FALLBACK_FIELDS.find(f => typeof r[f] === 'string');
55
+ if (!field) return false;
56
+ const title = fieldOf(r, field);
57
+ return typeof title === 'string' && isNumberedPlaceholderTitle(title);
58
+ }
59
+
60
+ /** The node fields the plan reads — a saved layout node (builder serializer shape) or a live ComponentNode. */
61
+ export interface PlaceholderPlanNode {
62
+ id?: string;
63
+ type?: string;
64
+ role?: string;
65
+ props?: Record<string, unknown> | null;
66
+ bindings?: ReadonlyArray<{ prop?: string; source?: string; path?: string } | null | undefined> | null;
67
+ children?: ReadonlyArray<PlaceholderPlanNode | null | undefined> | null;
68
+ }
69
+
70
+ /** The node types that repeat a source's rows: a Repeater, and a slider whose slides repeat. */
71
+ export const LIST_NODE_TYPES: ReadonlySet<string> = new Set(['Repeater', 'SliderContainer']);
72
+
73
+ /**
74
+ * The data source whose ITEMS a node repeats — a Repeater's or slider's `source` binding with no path (or a slider's
75
+ * `props.source`) — else `null`. A list over an array inside one item (`project.gallery`) is not a list of items.
76
+ */
77
+ export function listSourceOf(node: PlaceholderPlanNode | null | undefined): string | null {
78
+ if (!node || !LIST_NODE_TYPES.has(node.type ?? '')) return null;
79
+ const bound = (node.bindings ?? []).find(b => b?.prop === 'source' && !!b.source);
80
+ if (bound) return bound.path ? null : bound.source!;
81
+ const prop = node.props?.['source'];
82
+ return typeof prop === 'string' && prop ? prop : null;
83
+ }
84
+
85
+ /** Depth-first walk of a node's descendants (not the node itself), stopping below `skip`. */
86
+ function descendants(node: PlaceholderPlanNode, skip?: (n: PlaceholderPlanNode) => boolean): PlaceholderPlanNode[] {
87
+ const out: PlaceholderPlanNode[] = [];
88
+ const walk = (n: PlaceholderPlanNode): void => {
89
+ for (const c of n.children ?? []) {
90
+ if (!c) continue;
91
+ out.push(c);
92
+ if (!skip?.(c)) walk(c);
93
+ }
94
+ };
95
+ walk(node);
96
+ return out;
97
+ }
98
+
99
+ /** The path a node's `content` binding reads from its list's rows, or '' when it has none. */
100
+ function contentPath(node: PlaceholderPlanNode, source: string): string {
101
+ const b = (node.bindings ?? []).find(x => x?.prop === 'content' && x.source === source && !!x.path);
102
+ return b?.path ?? '';
103
+ }
104
+
105
+ /**
106
+ * The row field a list shows as its title: the bound text of its card's title part (a role ending in `title`, e.g.
107
+ * `card.title`), else of its first bound Heading, else `null` (then `isPlaceholderRow` falls back to title/name/label).
108
+ * Nested lists are not looked into.
109
+ */
110
+ export function listTitleField(list: PlaceholderPlanNode | null | undefined): string | null {
111
+ const source = listSourceOf(list);
112
+ if (!list || !source) return null;
113
+ const inside = descendants(list, n => LIST_NODE_TYPES.has(n.type ?? ''));
114
+ const titled = inside.find(n => /(^|\.)title$/.test(n.role ?? '') && contentPath(n, source));
115
+ if (titled) return contentPath(titled, source);
116
+ const heading = inside.find(n => n.type === 'Heading' && contentPath(n, source));
117
+ return heading ? contentPath(heading, source) : null;
118
+ }
119
+
120
+ /**
121
+ * The node types that are only a list section's FRAME (G-D3): its heading, eyebrow, lead text, buttons, links, icons
122
+ * and the boxes around them. A section left with only these hides with its list. Anything else (a picture, a video, a
123
+ * form, a gallery, a static list, a slider that is not bound) is content of its own and keeps the section.
124
+ */
125
+ export const LIST_FRAME_TYPES: ReadonlySet<string> = new Set([
126
+ 'Section', 'Container', 'LinkedContainer', 'Card', 'Heading', 'Text', 'Button', 'ButtonBlock', 'Link', 'Icon',
127
+ 'Divider', 'Spacer', 'Dialog', 'Popover',
128
+ ]);
129
+
130
+ /** The words a list section's frame holds at most outside its list: an eyebrow and a lead line. A third Text is words
131
+ * of the section's own (board B), so it stays. */
132
+ export const LIST_FRAME_MAX_TEXTS = 2;
133
+
134
+ /** What the live engine leaves out of a page so a visitor never meets a placeholder (G-D3). */
135
+ export interface PlaceholderHidePlan {
136
+ /** Per list source alias: its rows without the placeholder rows. Only the aliases that lost a row are listed. */
137
+ rows: Record<string, unknown[]>;
138
+ /** Ids of the nodes not to draw: lists with no live row, and the top-level sections left with only their frame. */
139
+ hidden: Set<string>;
140
+ }
141
+
142
+ /**
143
+ * The ONE live rule (G-D3), shared by the SSR engine's renderers:
144
+ *
145
+ * 1. a list's placeholder rows are dropped (`rows`) — a mixed list shows only the owner's real items;
146
+ * 2. a list whose source resolved to no live row is not drawn (`hidden`);
147
+ * 3. the top-level root holding it hides too when everything else in it is frame (`LIST_FRAME_TYPES`, at most
148
+ * `LIST_FRAME_MAX_TEXTS` Texts) and no other list in it still has a live row.
149
+ *
150
+ * A source the engine did not resolve (`!(alias in resolved)`) is not judged — nothing is hidden on a guess. A page
151
+ * whose every section hid still renders with its header and footer, and its nav links stay (G-D4).
152
+ */
153
+ export function planPlaceholderHides(
154
+ roots: ReadonlyArray<PlaceholderPlanNode | null | undefined> | null | undefined,
155
+ resolved: Readonly<Record<string, unknown>> | null | undefined,
156
+ ): PlaceholderHidePlan {
157
+ const rows: Record<string, unknown[]> = {};
158
+ const hidden = new Set<string>();
159
+ const data = resolved ?? {};
160
+
161
+ /** Live rows of a list, or `null` when its source is not resolved (never judged). */
162
+ const liveRows = (list: PlaceholderPlanNode, source: string): unknown[] | null => {
163
+ if (!(source in data)) return null;
164
+ const all = resolveRepeaterItems(data[source]);
165
+ const title = listTitleField(list);
166
+ const live = all.filter(r => !isPlaceholderRow(r, title));
167
+ if (live.length !== all.length && Array.isArray(data[source])) rows[source] = live;
168
+ return live;
169
+ };
170
+
171
+ for (const root of roots ?? []) {
172
+ if (!root) continue;
173
+ const nodes = [root, ...descendants(root)];
174
+ const lists = nodes.filter(n => !!listSourceOf(n));
175
+ if (!lists.length) continue;
176
+
177
+ const emptyLists = lists.filter(l => liveRows(l, listSourceOf(l)!)?.length === 0);
178
+ for (const l of emptyLists) if (l.id) hidden.add(l.id);
179
+ if (!emptyLists.length || emptyLists.length !== lists.length) continue;
180
+
181
+ // Every list in this root is empty: the root hides unless something outside the lists is content of its own.
182
+ const outsideLists = [root, ...descendants(root, n => !!listSourceOf(n))].filter(n => !listSourceOf(n));
183
+ const onlyFrame = outsideLists.every(n => LIST_FRAME_TYPES.has(n.type ?? ''))
184
+ && outsideLists.filter(n => n.type === 'Text').length <= LIST_FRAME_MAX_TEXTS;
185
+ if (onlyFrame && root.id) hidden.add(root.id);
186
+ }
187
+ return { rows, hidden };
188
+ }
189
+
190
+ /** A page as the live engine draws it once the placeholder rule ran: the roots without the hidden nodes, and the data
191
+ * with each list's placeholder rows dropped. */
192
+ export interface PlaceholderHidden<N> {
193
+ roots: N[];
194
+ resolved: Record<string, unknown>;
195
+ }
196
+
197
+ /**
198
+ * `planPlaceholderHides` applied — what the SSR engine hands BOTH its renderers (the string renderer and the component
199
+ * tree), so they never disagree: the hidden nodes pruned out of the tree (a copy only where something was pruned; the
200
+ * input is never mutated) and the list sources replaced by their live rows.
201
+ */
202
+ export function applyPlaceholderHides<N extends PlaceholderPlanNode>(
203
+ roots: ReadonlyArray<N> | null | undefined,
204
+ resolved: Readonly<Record<string, unknown>> | null | undefined,
205
+ ): PlaceholderHidden<N> {
206
+ const plan = planPlaceholderHides(roots, resolved);
207
+ const data = { ...(resolved ?? {}), ...plan.rows };
208
+ if (!plan.hidden.size) return { roots: [...(roots ?? [])], resolved: data };
209
+ const prune = (nodes: ReadonlyArray<N | null | undefined>): N[] => {
210
+ const out: N[] = [];
211
+ for (const n of nodes) {
212
+ if (!n || (n.id && plan.hidden.has(n.id))) continue;
213
+ const kids = n.children as ReadonlyArray<N | null | undefined> | null | undefined;
214
+ const pruned = kids?.length ? prune(kids) : null;
215
+ out.push(pruned && pruned.length !== kids!.length ? { ...n, children: pruned } : n);
216
+ }
217
+ return out;
218
+ };
219
+ return { roots: prune(roots ?? []), resolved: data };
220
+ }
@@ -2,7 +2,7 @@
2
2
  * @vectoriox/iox-ui/data-core — the shared, FRAMEWORK-FREE data-source core (data-source-resolving.md): the ONE
3
3
  * decision of how a data source becomes a fetch (`planDataSource`), the route-param matcher, the derived /
4
4
  * relative (`$siblings`, `$related`) resolvers, the repeater item reader, and which sources a node tree
5
- * references (`referencedDataSourcesDeep`), and which saved page is the studio's home (`homePageOf`, #116). The builder and the SSR engine resolve with it; iox-cms reads it
5
+ * references (`referencedDataSourcesDeep`), and which saved page is the studio's home (`homePageOf`, #116), and which rows are placeholder samples the live site leaves out (`planPlaceholderHides`, #178). The builder and the SSR engine resolve with it; iox-cms reads it
6
6
  * under plain Node (W2's Undo: is a data source still in use). Pure: no transport, no Angular. The main
7
7
  * entry re-exports it by package path, so `@vectoriox/iox-ui` keeps working.
8
8
  * ⚠️ Consumers wire the usual trio — ng-package raw-ts assets, jest moduleNameMapper, tsconfig paths —
@@ -11,3 +11,4 @@
11
11
  export * from './data-source-resolver';
12
12
  export * from './relative-sources';
13
13
  export * from './home-page';
14
+ export * from './placeholder-rows';
@@ -237,8 +237,16 @@ export function headerGivesBack(ground: unknown, openingMedia: unknown): boolean
237
237
  /** The Page scrolled state's attribute (main entry `SCROLLED_ATTRIBUTE`; spelled here — design-core reads no Angular
238
238
  * entry; held equal by the scrolled spec). */
239
239
  export const HEADER_SCROLLED_ATTRIBUTE = 'data-iox-scrolled';
240
- /** An open menu inside the header (the drawer / full / panel Dialog is the header's own child — T2). */
241
- export const HEADER_OPEN_MENU_SELECTOR = 'dialog[open]';
240
+ /**
241
+ * Written on the builder canvas's open Dialog stage (`app-builder-dialog`'s `div.dialog-stage`) — the canvas twin of an
242
+ * open `<dialog>`, which the canvas does not use (vectoriox/iox-ui#181).
243
+ */
244
+ export const HEADER_MENU_OPEN_ATTRIBUTE = 'data-iox-menu-open';
245
+ /**
246
+ * An open menu inside the header (the drawer / full / panel Dialog is the header's own child — T2): a real open
247
+ * `<dialog>` on the live site, the stage carrying `HEADER_MENU_OPEN_ATTRIBUTE` on the canvas.
248
+ */
249
+ export const HEADER_OPEN_MENU_SELECTOR = `:is(dialog[open], [${HEADER_MENU_OPEN_ATTRIBUTE}])`;
242
250
  /** The CSS custom property the header runtime writes its height in (`watchHeaderHeight`), on the scope around it. */
243
251
  export const HEADER_HEIGHT_VAR = '--header-h';
244
252
 
@@ -59,3 +59,37 @@ export function headingHref(props: NodeLinkProps, pageHref: (route: string) => s
59
59
  if (props.linkType === LinkType.External) return String(props.url ?? '').trim() || null;
60
60
  return null;
61
61
  }
62
+
63
+ /** The prop a node's route params are stored under — `routeParam:<name>`, a static value or a binding (both land there). */
64
+ export const ROUTE_PARAM_PREFIX = 'routeParam:';
65
+
66
+ /** A node's route params by name, from its `routeParam:<name>` props (`{ 'routeParam:slug': 'soap' }` → `{ slug: 'soap' }`). */
67
+ export function routeParamValues(props: Readonly<Record<string, unknown>> | null | undefined): Record<string, unknown> {
68
+ const out: Record<string, unknown> = {};
69
+ for (const [key, value] of Object.entries(props ?? {})) {
70
+ if (key.startsWith(ROUTE_PARAM_PREFIX)) out[key.slice(ROUTE_PARAM_PREFIX.length)] = value;
71
+ }
72
+ return out;
73
+ }
74
+
75
+ const ROUTE_PARAM = /:([a-zA-Z_][a-zA-Z0-9_]*)/g;
76
+
77
+ /**
78
+ * A page route with its `:params` filled: each from `values` (URL-encoded), an unfilled one leaving no gap
79
+ * (`/shop/:slug/reviews` with no slug → `/shop/reviews`). The engine's `resolvePageHref` substitution, shared so the builder's
80
+ * Preview links where the live site does — a product card read `/shop/:slug` there (vectoriox/iox-ui#176). The route's
81
+ * leading slash is kept; the engine makes it base-relative itself.
82
+ */
83
+ export function fillRouteParams(route: string, values: Readonly<Record<string, unknown>>): string {
84
+ return String(route ?? '')
85
+ .replace(ROUTE_PARAM, (_m, name: string) => {
86
+ const value = values[name];
87
+ return value === undefined || value === null || value === '' ? '' : encodeURIComponent(String(value));
88
+ })
89
+ .replace(/\/{2,}/g, '/');
90
+ }
91
+
92
+ /** Does the route still name a `:param` (one nothing filled)? */
93
+ export function routeHasParams(route: string): boolean {
94
+ return new RegExp(ROUTE_PARAM.source).test(String(route ?? ''));
95
+ }
@@ -1,6 +1,7 @@
1
1
  import { ELEMENT_ACTION_DESCRIPTORS, POPUP_RULES, popupEnded, resolveActionAvailability } from '@vectoriox/iox-ui/actions-core';
2
2
  import { CheckoutGateCode, CheckoutGateRefusal, labelIn } from '@vectoriox/iox-ui/commerce-core';
3
3
  import { PopupArrive, PopupForm, popupFormOf, PopupRole, PopupTrait, ShopRole } from '@vectoriox/iox-ui/composite-core';
4
+ import { isNumberedPlaceholderTitle } from '@vectoriox/iox-ui/data-core';
4
5
  import { auditDesignContrast, DesignTokenLike } from '@vectoriox/iox-ui/design-core';
5
6
  import { ConsentActionType } from '@vectoriox/iox-ui/composite-core';
6
7
  import { collectFormSpec, FORM_CHANNEL_ROLE, FORM_NODE_TYPE, isChannelFilled } from '@vectoriox/iox-ui/forms-core';
@@ -62,6 +63,10 @@ export enum SiteFindingCode {
62
63
  ContactMissing = 'contact-missing',
63
64
  CopyPlaceholder = 'copy-placeholder',
64
65
  SampleItems = 'sample-items',
66
+ /** iox-ui#178: a sample item still titled like a numbered placeholder ("Product 2", "Room 2") — the builder draws it as
67
+ * a ghost card and the live site never lists it alone, but it is the owner's to name or remove. Asks ("Publish
68
+ * anyway", Doron 2026-11-28) — said instead of SampleItems (`isNumberedPlaceholderTitle`). */
69
+ PlaceholderTitle = 'placeholder-title',
65
70
  /** Commerce G1 (shop-aware §3i): a sample product the build added still has no price — a price is a fact a buyer is
66
71
  * held to, so the owner sets it (or removes the sample) before the store goes live. */
67
72
  SamplePrice = 'sample-price',
@@ -130,6 +135,7 @@ export const FINDING_SEVERITY: Readonly<Record<SiteFindingCode, CheckSeverity>>
130
135
  [SiteFindingCode.ContactMissing]: CheckSeverity.Warn,
131
136
  [SiteFindingCode.CopyPlaceholder]: CheckSeverity.Ask,
132
137
  [SiteFindingCode.SampleItems]: CheckSeverity.Ask,
138
+ [SiteFindingCode.PlaceholderTitle]: CheckSeverity.Ask,
133
139
  [SiteFindingCode.SamplePrice]: CheckSeverity.Block,
134
140
  [SiteFindingCode.SampleStock]: CheckSeverity.Block,
135
141
  [SiteFindingCode.StoreFact]: CheckSeverity.Block,
@@ -170,6 +176,7 @@ const CHECK_OF: Readonly<Record<SiteFindingCode, SiteCheckId>> = {
170
176
  [SiteFindingCode.ContactMissing]: SiteCheckId.Facts,
171
177
  [SiteFindingCode.CopyPlaceholder]: SiteCheckId.Facts,
172
178
  [SiteFindingCode.SampleItems]: SiteCheckId.Facts,
179
+ [SiteFindingCode.PlaceholderTitle]: SiteCheckId.Facts,
173
180
  [SiteFindingCode.SamplePrice]: SiteCheckId.Facts,
174
181
  [SiteFindingCode.SampleStock]: SiteCheckId.Facts,
175
182
  [SiteFindingCode.StoreFact]: SiteCheckId.Facts,
@@ -505,7 +512,9 @@ function checkFacts(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray<
505
512
  else if (blocksPublish(p.kind)) add(ctx, SiteFindingCode.UnfilledFact, { text: String(p.text || p.kind) }, where);
506
513
  else if (p.kind === PlaceholderKind.Copy) add(ctx, SiteFindingCode.CopyPlaceholder, null, where);
507
514
  }
508
- for (const s of snapshot.samples ?? []) add(ctx, SiteFindingCode.SampleItems, { name: s.label ?? s.id }, { nodeId: s.id });
515
+ for (const s of snapshot.samples ?? []) {
516
+ add(ctx, isNumberedPlaceholderTitle(s.label) ? SiteFindingCode.PlaceholderTitle : SiteFindingCode.SampleItems, { name: s.label ?? s.id }, { nodeId: s.id });
517
+ }
509
518
  // iox-cms#98: what the shop lacks holds only the pages that show the shop — never the Home of a site that also sells.
510
519
  const shopShown = pages.some(pageShowsShop);
511
520
  for (const s of shopShown ? snapshot.unpricedSamples ?? [] : []) add(ctx, SiteFindingCode.SamplePrice, { name: s.label ?? s.id }, { nodeId: s.id });
@@ -97,6 +97,11 @@ export const SITE_FINDING_WORDS: Readonly<Record<`${SiteFindingCode}`, FindingWo
97
97
  many: S('{n} sample items — replace them with yours or remove them.', '{n} פריטים לדוגמה — החליפו אותם בשלכם או הסירו אותם.'),
98
98
  group: FindingGrouping.Site,
99
99
  },
100
+ 'placeholder-title': {
101
+ one: S('"{name}" is still a numbered placeholder — give it its own name, or remove it.', '"{name}" עדיין שם זמני ממוספר — תנו לו שם משלכם, או הסירו אותו.'),
102
+ many: S('{n} items are still numbered placeholders — give each its own name, or remove them.', '{n} פריטים עדיין בשמות זמניים ממוספרים — תנו לכל אחד שם משלכם, או הסירו אותם.'),
103
+ group: FindingGrouping.Site,
104
+ },
100
105
  // Each sample product is fixed on its own page (the screen links to it), so they are never one row.
101
106
  'sample-price': {
102
107
  one: S('"{name}" has no price yet — set yours, or remove the sample.', 'ל-"{name}" עדיין אין מחיר — קבעו מחיר או הסירו את הדוגמה.'),
@@ -9,6 +9,7 @@ import { factIssues, PlanWordContext, WrittenText } from './plan-words';
9
9
  import { PageSectionPlan } from './site-plan.model';
10
10
  import { PathIssue } from './shape-check';
11
11
  import { freeStyleWithoutSlot } from './free-slots';
12
+ import { isFreeBox } from './free-opening';
12
13
 
13
14
  /**
14
15
  * THE FREE PAGE'S JUDGE (award plan §11.4 gates 1 + 2, FS3): every reason a free page may not be stamped, path first,
@@ -69,6 +70,10 @@ export interface FreeJudgeContext {
69
70
  said?: ReadonlyArray<string>;
70
71
  /** Home: a business with videos plays one there. */
71
72
  home?: boolean;
73
+ /** iox-ui#180: the picture boxes the page was offered (`freeOpeningOffer`) — empty pictures the build fills. */
74
+ boxes?: ReadonlyArray<string>;
75
+ /** iox-ui#180: a picture can come for the Home's opening (the owner's photo, or a box): its first section holds it. */
76
+ opensOnPicture?: boolean;
72
77
  }
73
78
 
74
79
  /** A free page is this many sections. */
@@ -229,7 +234,8 @@ function judgeFree(page: FreePage, ctx: FreeJudgeContext, signature: boolean): F
229
234
  const seen = new Set<string>();
230
235
  const texts: WrittenText[] = [];
231
236
  let h1 = 0;
232
- for (const { node, path, up } of walked) {
237
+ let boxes = 0;
238
+ for (const { node, path, up, section } of walked) {
233
239
  if (!Object.values(FreeNodeType).includes(node.type)) { say(FreeIssueCode.Structure, path, `"${node.type}" is not a node type — ${Object.values(FreeNodeType).join(', ')}`); continue; }
234
240
  if (!node.id || seen.has(node.id)) say(FreeIssueCode.Structure, path, node.id ? `the id "${node.id}" is used twice` : 'every node needs its own id');
235
241
  seen.add(node.id);
@@ -253,9 +259,17 @@ function judgeFree(page: FreePage, ctx: FreeJudgeContext, signature: boolean): F
253
259
  }
254
260
  if (node.role && (node.role !== FREE_LEAD_ROLE || node.type !== FreeNodeType.Heading)) say(FreeIssueCode.Structure, `${path}.role`, 'role "lead" is for the heading a visitor reads first');
255
261
  if (node.type === FreeNodeType.Image || node.type === FreeNodeType.Video) {
256
- const m = ctx.material[node.src ?? ''];
257
- if (!m) say(FreeIssueCode.Content, `${path}.src`, `"${node.src ?? ''}" is not in the material — use an id from the list`);
262
+ const src = node.src ?? '';
263
+ const offeredBox = isFreeBox(src) && !!ctx.boxes?.includes(src);
264
+ const m = ctx.material[src] ?? (offeredBox ? { kind: 'image' as const } : undefined);
265
+ if (!m) say(FreeIssueCode.Content, `${path}.src`, `"${src}" is not in the material — use an id from the list`);
258
266
  else if ((node.type === FreeNodeType.Video) !== (m.kind === 'video')) say(FreeIssueCode.Content, `${path}.src`, `"${node.src}" is a${m.kind === 'image' ? 'n image' : ' video'} — ${node.type === FreeNodeType.Video ? 'a Video plays a video' : 'an Image shows a picture'}`);
267
+ else if (offeredBox) {
268
+ // iox-ui#180: a box is the opening's ONE picture place, filled after the page is written — never a ground.
269
+ if (section !== 0) say(FreeIssueCode.Content, `${path}.src`, 'a box is the opening\'s picture — only the first section may hold one');
270
+ else if (boxes++ > 0) say(FreeIssueCode.Content, `${path}.src`, 'one box: the opening has one picture place');
271
+ if (node.styleProps?.['position'] === 'absolute') say(FreeIssueCode.Content, `${path}.styleProps.position`, 'a box is never a ground: words never stand on a picture nobody has seen yet — set it beside, above or below the words');
272
+ }
259
273
  }
260
274
  if (node.type === FreeNodeType.Slot) {
261
275
  const offer = ctx.slots?.[node.slot ?? ''];
@@ -311,6 +325,10 @@ function judgeFree(page: FreePage, ctx: FreeJudgeContext, signature: boolean): F
311
325
  if (last >= 0 && !ready(last) && !walkFree([sections[last]]).some(w => w.node.type === FreeNodeType.Button)) say(FreeIssueCode.Structure, `sections[${last}]`, 'the page ends on something to do — a Button in the last section');
312
326
  const hasVideos = Object.values(ctx.material).some(m => m.kind === 'video');
313
327
  if (ctx.home && hasVideos && !sections.some(s => s.readyMade) && !walked.some(w => w.node.type === FreeNodeType.Video)) say(FreeIssueCode.Content, 'sections', 'this business has videos — the home page plays at least one (a Video node)');
328
+ // iox-ui#180: a picture can come for this Home's opening (the owner's photo, or a box stock fills) — it opens on it.
329
+ if (ctx.home && ctx.opensOnPicture && sections[0] && !ready(0) && !walkFree([sections[0]]).some(w => w.node.type === FreeNodeType.Image)) {
330
+ say(FreeIssueCode.Content, 'sections[0]', `a picture can open this home page — place ${ctx.boxes?.length ? `one of the owner's photos or a box (${ctx.boxes.join(', ')})` : 'one of the owner\'s photos'} as an Image in the first section, beside, above or below its words`);
331
+ }
314
332
  if (!(Object.values(FreePictures) as string[]).includes(page?.pictures)) say(FreeIssueCode.Structure, 'pictures', `one word: ${Object.values(FreePictures).join(', ')}`);
315
333
  issues.push(...followedIssues(page, ctx));
316
334
  issues.push(...freeContrastIssues(page, ctx));
@@ -25,7 +25,7 @@ import {
25
25
  legalFormLine, LegalKind, legalKindsFor, legalLabel, legalRoute, legalTitle,
26
26
  } from './legal';
27
27
  import {
28
- checkOpening, drawnOpeningMix, OpeningContext, openingIsTypeLed, openingMix, OpeningMix, openingMixOfPlan, openingRecipe, OpeningRole, stampOpeningMix,
28
+ checkOpening, drawnOpeningMix, namedOpeningMix, OpeningContext, openingIsTypeLed, openingMix, OpeningMix, openingMixOfPlan, openingRecipe, OpeningRole, stampOpeningMix,
29
29
  stampOpeningMotion, TYPE_LED_OPTIONAL_PARTS, typeLedOpeningSection,
30
30
  } from './opening-mix';
31
31
  import { checkHeader, drawnHeaderMix, HeaderContext, headerContextOfPlan, HeaderFacts, HeaderIngredient, HeaderNever, HeaderOpening, headerMix, HeaderMix, headerRecipe, HeaderRecipe, stampHeaderMix, wornHeaderOfPlan } from './header-mix';
@@ -52,6 +52,7 @@ import { composeLayout, LayoutColourMode, layoutBandScheme, LayoutListBinding }
52
52
  import { LayoutGalleryList, LayoutListShape, LayoutPage, LayoutPhotoShape, LayoutPhotoSource, LayoutSite, parseLayoutPhotoId } from './layout-language';
53
53
  import { layoutMotionOf, layoutPresetOf } from './layout-look';
54
54
  import { ComposeFreeOptions, composeFreePage, composeFreeSection } from './compose-free';
55
+ import { isFreeBox } from './free-opening';
55
56
  import { FreePage } from './free-wire';
56
57
 
57
58
  /**
@@ -1808,7 +1809,8 @@ function freeOptionsOf(
1808
1809
  const locale = plan.locale ?? DEFAULT_SITE_LOCALE;
1809
1810
  return {
1810
1811
  owner: page.key, locale, rtl: isRtlLocale(locale), motion: layoutMotionOf(layoutPresetOf(plan.design).id),
1811
- photoSrc: id => context.photoSrc?.(id) ?? '', photoAlt: id => context.photoAlt?.(id) ?? '',
1812
+ // iox-ui#180: a picture box is an empty picture (the build fills it), never an address.
1813
+ photoSrc: id => (isFreeBox(id) ? '' : context.photoSrc?.(id) ?? ''), photoAlt: id => (isFreeBox(id) ? '' : context.photoAlt?.(id) ?? ''),
1812
1814
  listOf: alias => pageListOf(alias, plan, pictureless),
1813
1815
  ...(readyMade ? {
1814
1816
  readyMade: (at: number, id: string) => {
@@ -1914,10 +1916,14 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
1914
1916
  const pages: ComposedPage[] = plan.pages.map(page => {
1915
1917
  const nextAlias = page.routeSource ? nextSourceOf(relatives, page.routeSource) : null;
1916
1918
  if (page.free) {
1917
- // FS3: the model's own page. Its opening is its own (the plan's opening is never worn over it).
1918
- const nodes = composeFreePlanPage(page, page.free, plan, context, placeholders, pictureless, (section, id, at) =>
1919
+ // FS3: the model's own page. Its opening is its own (the plan's opening is never worn over it) — but a ready-made
1920
+ // opening (the fall back's, or the type-led round's when nothing fills its picture, iox-ui#180) is the plan's
1921
+ // section, worn as every Home's is.
1922
+ const stamped = composeFreePlanPage(page, page.free, plan, context, placeholders, pictureless, (section, id, at) =>
1919
1923
  composePattern(patternById(section.pattern) as SitePattern, id, { ...base, owner: page.key, page, section, nextAlias },
1920
1924
  { level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null, scrub: design.scrub ?? null, opening: at === 0 }));
1925
+ const readyOpening = page.free.sections[0]?.readyMade;
1926
+ const nodes = readyOpening ? wearPlanOpening(page, stamped, plan, context, design, placeholders, issues, false, page.sections[readyOpening.at]) : stamped;
1921
1927
  const opening = schemeOfFirst(nodes);
1922
1928
  return {
1923
1929
  key: page.key, name: page.name, route: { path: page.route }, isHome: page.isHome === true, status: STATUS_DRAFT, locale,
@@ -2522,6 +2528,14 @@ const SCENE_ROLE = 'scene';
2522
2528
 
2523
2529
  /** May the opening take the place of this first section? It must hold a heading (the opening's title is its words) and
2524
2530
  * nothing the opening has no part for — a form, bound content, a Scene stay and the opening comes before them. */
2531
+ /** The named opening a first section's pattern stands for (`namedOpeningMix`), when the ONE judge would mend it for this
2532
+ * build — else null: the pattern stays as it is composed. */
2533
+ function openingTheJudgeMends(root: SerializedNode, source: PageSectionPlan | undefined, ctx: OpeningContext): OpeningMix | null {
2534
+ if (!source || root.composed?.pattern !== source.pattern) return null;
2535
+ const named = namedOpeningMix(source.pattern);
2536
+ return named && checkOpening(named, ctx).repairs.length ? named : null;
2537
+ }
2538
+
2525
2539
  function openingMayReplace(root: SerializedNode): boolean {
2526
2540
  let heading = false;
2527
2541
  let keeps = false;
@@ -2555,13 +2569,18 @@ function wearPlanOpening(
2555
2569
  page: PagePlan, layout: SerializedNode[], plan: SitePlan, context: ComposeContext, design: DesignChoices,
2556
2570
  placeholders: ComposedPlaceholder[], issues: ComposeIssue[], keep: boolean, source?: PageSectionPlan,
2557
2571
  ): SerializedNode[] {
2558
- const mix = openingMixOfPlan(plan);
2559
- if (!mix || !(page.isHome === true || page.route === HOME_PATH)) return layout;
2572
+ if (!(page.isHome === true || page.route === HOME_PATH)) return layout;
2560
2573
  const first = layout[0];
2561
2574
  const replace = !!first && !keep && openingMayReplace(first);
2562
- const id = replace ? first.id : `${page.key}-opening`;
2563
2575
  const tier = context.tier ?? GenerationTier.Basic;
2564
- const site = { pages: plan.pages.map(p => ({ name: p.name, route: p.route, isHome: p.isHome === true })), locale: plan.locale, design, badge: null, cutOut: false, tier };
2576
+ // J10 lever (b): a build never holds the owner's clip for the opening (their film plays in a Scene, SC6b) — a film
2577
+ // opening is drawn as a picture the owner's photo, a made picture or stock can fill (`checkOpening`, said).
2578
+ const site = { pages: plan.pages.map(p => ({ name: p.name, route: p.route, isHome: p.isHome === true })), locale: plan.locale, design, badge: null, cutOut: false, film: false, tier };
2579
+ // iox-ui#180: with no opening chosen, a first section that IS a named opening (`hero.full-bleed-media` = a film) is
2580
+ // judged as that opening — when the judge mends it (no clip: a picture) it is worn mended; else it stays as it is.
2581
+ const mix = openingMixOfPlan(plan) ?? (replace ? openingTheJudgeMends(first, source, openingContextOf({ ...site, business: plan.business })) : null);
2582
+ if (!mix) return layout;
2583
+ const id = replace ? first.id : `${page.key}-opening`;
2565
2584
  // #129: a type-led first screen takes the type-led hero's words slot by slot (nothing it said is lost); the name is
2566
2585
  // the business's, as every display-size opening's is.
2567
2586
  const checked = replace && source ? checkOpening(drawnOpeningMix(mix).drawn, openingContextOf({ ...site, business: plan.business })).mix : null;
@@ -2641,6 +2660,9 @@ export interface OpeningInput extends SectionInput {
2641
2660
  readonly badge?: string | null;
2642
2661
  /** The owner gives a cut-out picture (the name behind the subject). */
2643
2662
  readonly cutOut?: boolean;
2663
+ /** J10 lever (b): the owner's clip plays in the first screen; `false` = none (a build — a picture stands in, said);
2664
+ * absent = the film's placeholder (the builder). */
2665
+ readonly film?: boolean;
2644
2666
  /** AW-D23: the tier the site is built at; absent = every word (the builder shows the Pro marks itself). */
2645
2667
  readonly tier?: OpeningContext['tier'];
2646
2668
  /** Draw the mix as asked, never mended — the Opening studio (it ADVISES the check's mends, OB-2). */
@@ -2657,12 +2679,13 @@ export interface ComposedOpening extends ComposedSection {
2657
2679
  }
2658
2680
 
2659
2681
  /** The context an opening is judged and measured in — the same for the check, the recipe and the studio's advice. */
2660
- export function openingContextOf(input: Pick<OpeningInput, 'business' | 'design' | 'badge' | 'cutOut' | 'tier'>): OpeningContext {
2682
+ export function openingContextOf(input: Pick<OpeningInput, 'business' | 'design' | 'badge' | 'cutOut' | 'film' | 'tier'>): OpeningContext {
2661
2683
  return {
2662
2684
  name: input.business?.name ?? '',
2663
2685
  design: resolveDesignChoices(JSON.parse(JSON.stringify(input.design ?? {}))),
2664
2686
  ...(input.tier ? { tier: input.tier } : {}),
2665
2687
  ...(input.cutOut !== undefined ? { cutOut: input.cutOut } : {}),
2688
+ ...(input.film !== undefined ? { film: input.film } : {}),
2666
2689
  ...(input.badge !== undefined ? { badge: input.badge } : {}),
2667
2690
  };
2668
2691
  }
@@ -0,0 +1,57 @@
1
+ import { LayoutPhotoShape, LayoutPhotoSource, parseLayoutPhotoId } from './layout-language';
2
+ import { PromptLimit, promptLimitsOf, PromptReading } from './prompt-limits';
3
+ import { wordPattern } from './plan-words';
4
+
5
+ /**
6
+ * A FREE HOME OPENS ON A PICTURE WHEN ONE CAN COME (iox-ui#180, J10 lever b for FS3). The ONE offer a free page's brief
7
+ * and its judge share: the owner's photos come first (they are the material already); with none, a business stock may
8
+ * show is offered the picture boxes (`box:<shape>`, the laid brief's own ids, `parseLayoutPhotoId`) — an empty picture the
9
+ * build fills with stock, or, when nothing fits, the type-led round opens the Home on its words like every Home. Never a
10
+ * picture claim: no box where stock may not stand in for the work (`BusinessType.stock: false`), none off the Home, and
11
+ * nothing against the owner's words: "no pictures" (`PromptLimit.NoPictures`) offers nothing, "no stock photos" no box. Pure.
12
+ */
13
+
14
+ /** The shapes a free opening's box may take, as material ids (`box:wide` · `box:tall` · `box:square`). */
15
+ export const FREE_OPENING_BOXES: ReadonlyArray<string> = [LayoutPhotoShape.Wide, LayoutPhotoShape.Tall, LayoutPhotoShape.Square]
16
+ .map(shape => `${LayoutPhotoSource.Box}:${shape}`);
17
+
18
+ export interface FreeOpeningSite {
19
+ /** The page is the site's Home. */
20
+ home: boolean;
21
+ /** The business type may show stock (`BusinessType.stock`): stock may fill a box. */
22
+ stockAllowed: boolean;
23
+ /** How many photos of the owner's the page may place. */
24
+ ownPhotos: number;
25
+ /** The owner's words as the reading kept them (§11.4a): what they ruled out. */
26
+ reading?: PromptReading | null;
27
+ }
28
+
29
+ /** Words that refuse stock photos ("no stock photos", "בלי תמונות סטוק") wherever the reading kept them. */
30
+ const STOCK_REFUSALS: ReadonlyArray<string> = ['stock', 'stock photos', 'stock images', 'סטוק', 'תמונות סטוק'];
31
+ const STOCK_RULINGS: ReadonlyArray<string> = ['no stock', 'without stock', 'not stock', 'never stock', 'בלי סטוק', 'ללא סטוק', 'בלי תמונות סטוק', 'ללא תמונות סטוק'];
32
+
33
+ /** Did the owner refuse stock photos? Read from the reading's own lists, never guessed. Pure. */
34
+ export function refusesStock(reading: PromptReading | null | undefined): boolean {
35
+ const plain = (t: string) => String(t ?? '').normalize('NFKC').toLowerCase().replace(/^(any|no|בלי|ללא)\s+/, '').trim();
36
+ const all = [...(reading?.refused ?? []), ...(reading?.asked ?? []), ...(reading?.said ?? [])].map(t => String(t ?? '').normalize('NFKC').toLowerCase());
37
+ return (reading?.refused ?? []).some(r => STOCK_REFUSALS.includes(plain(r))) || STOCK_RULINGS.some(phrase => all.some(text => wordPattern(phrase).test(text)));
38
+ }
39
+
40
+ export interface FreeOpeningOffer {
41
+ /** The box ids the page may place (material of kind image), empty when none is offered. */
42
+ boxes: string[];
43
+ /** The Home opens on a picture: one of the owner's photos, or a box. */
44
+ opensOnPicture: boolean;
45
+ }
46
+
47
+ /** What a free page's opening is offered, and whether it must open on a picture. */
48
+ export function freeOpeningOffer(site: FreeOpeningSite): FreeOpeningOffer {
49
+ if (!site.home || promptLimitsOf(site.reading).includes(PromptLimit.NoPictures)) return { boxes: [], opensOnPicture: false };
50
+ if (site.ownPhotos > 0) return { boxes: [], opensOnPicture: true };
51
+ return site.stockAllowed && !refusesStock(site.reading) ? { boxes: [...FREE_OPENING_BOXES], opensOnPicture: true } : { boxes: [], opensOnPicture: false };
52
+ }
53
+
54
+ /** Is a material id a picture box (`box:<shape>`)? */
55
+ export function isFreeBox(id: string | null | undefined): boolean {
56
+ return parseLayoutPhotoId(String(id ?? ''))?.source === LayoutPhotoSource.Box;
57
+ }