@vectoriox/iox-ui 5.148.0 → 5.150.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,294 @@
1
+ import { CHECKOUT_GATE_RULES, CommerceLabel, labelIn } from '@vectoriox/iox-ui/commerce-core';
2
+
3
+ import type { SiteFinding, SiteFindingCode } from './audit-site';
4
+
5
+ /**
6
+ * What the site audit SAYS, in the admin's language (vectoriox/iox-ui#109). Every finding code has ONE entry here:
7
+ * its sentence in English and Hebrew (the commerce-core `CommerceLabel` shape — the core carries both, a string-rendered
8
+ * screen and iox-cms have no translation service), the variants a code has (which mode, why a statement is owed), and
9
+ * how its repeats are grouped with the sentence a group is said in. `auditSite` writes a finding's English `message` from
10
+ * this table and the values it names (`SiteFinding.params`), so the server's words and a screen's are one source.
11
+ *
12
+ * Only TYPES are imported from `audit-site` (the codes are written as their string values) — audit-site imports this
13
+ * file at runtime, and a value import back would be a module cycle.
14
+ */
15
+ export type FindingSentence = CommerceLabel;
16
+
17
+ /** How a code's repeats become one row on a screen. */
18
+ export enum FindingGrouping {
19
+ /** One row per page (or global): "12 boxes wait for a picture" on Home, another for About. */
20
+ Page = 'page',
21
+ /** One row for the site: "15 sample items", "6 pages have no description for search results". */
22
+ Site = 'site',
23
+ /** Never grouped: each finding names something different (a fact, a product with its own page, a connector). */
24
+ Never = 'never',
25
+ }
26
+
27
+ interface FindingWords {
28
+ /** The sentence for one finding — or one per variant (`params.variant`). `{name}` is replaced by `params.name`. */
29
+ readonly one: FindingSentence | Readonly<Record<string, FindingSentence>>;
30
+ /** The sentence for a group of `{n}` (absent: never grouped). */
31
+ readonly many?: FindingSentence;
32
+ readonly group: FindingGrouping;
33
+ }
34
+
35
+ const S = (en: string, he: string): FindingSentence => ({ en, he });
36
+
37
+ /** Every code's words. Typed by the codes' values, so a new code without words does not compile. */
38
+ export const SITE_FINDING_WORDS: Readonly<Record<`${SiteFindingCode}`, FindingWords>> = {
39
+ 'no-header': {
40
+ one: S('The site has no header, so visitors have no menu to move around with.', 'לאתר אין כותרת עליונה, ולכן אין למבקרים תפריט לנווט בו.'),
41
+ group: FindingGrouping.Never,
42
+ },
43
+ 'no-phone-menu': {
44
+ one: S('The header has no phone menu — on a phone its links are hard to reach.', 'לכותרת העליונה אין תפריט לטלפון — בטלפון קשה להגיע לקישורים שלה.'),
45
+ group: FindingGrouping.Never,
46
+ },
47
+ 'form-without-id': {
48
+ one: S('A form has no id, so what visitors send is never stored.', 'לטופס אין מזהה, ולכן מה שמבקרים שולחים לא נשמר.'),
49
+ many: S('{n} forms have no id, so what visitors send is never stored.', '{n} טפסים בלי מזהה, ולכן מה שמבקרים שולחים בהם לא נשמר.'),
50
+ group: FindingGrouping.Page,
51
+ },
52
+ 'empty-channel': {
53
+ one: S('A form\'s second way to reach you has no number or address yet — visitors do not see it until you fill it in.',
54
+ 'לדרך הנוספת ליצור איתכם קשר בטופס עדיין אין מספר או כתובת — המבקרים לא יראו אותה עד שתמלאו אותה.'),
55
+ many: S('{n} forms\' second way to reach you has no number or address yet — visitors do not see it until you fill it in.',
56
+ 'ב-{n} טפסים לדרך הנוספת ליצור איתכם קשר עדיין אין מספר או כתובת — המבקרים לא יראו אותה עד שתמלאו אותה.'),
57
+ group: FindingGrouping.Page,
58
+ },
59
+ 'email-needs-mailer': {
60
+ one: S('A form emails what visitors send, but Email is not connected — it is stored and never sent.',
61
+ 'טופס שולח במייל את מה שמבקרים שולחים, אבל המייל לא מחובר — ההודעות נשמרות ולא נשלחות.'),
62
+ many: S('{n} forms email what visitors send, but Email is not connected — it is stored and never sent.',
63
+ '{n} טפסים שולחים במייל את מה שמבקרים שולחים, אבל המייל לא מחובר — ההודעות נשמרות ולא נשלחות.'),
64
+ group: FindingGrouping.Site,
65
+ },
66
+ 'tracker-without-banner': {
67
+ one: S('{trackers} is connected, but the site has no cookie banner — it stays off for every visitor.',
68
+ '{trackers} מחובר, אבל באתר אין באנר עוגיות — הוא כבוי לכל המבקרים.'),
69
+ group: FindingGrouping.Never,
70
+ },
71
+ 'no-title': {
72
+ one: S('"{name}" has no title for search results.', 'לעמוד "{name}" אין כותרת לתוצאות החיפוש.'),
73
+ many: S('{n} pages have no title for search results.', '{n} עמודים בלי כותרת לתוצאות החיפוש.'),
74
+ group: FindingGrouping.Site,
75
+ },
76
+ 'no-description': {
77
+ one: S('"{name}" has no description for search results.', 'לעמוד "{name}" אין תיאור לתוצאות החיפוש.'),
78
+ many: S('{n} pages have no description for search results.', '{n} עמודים בלי תיאור לתוצאות החיפוש.'),
79
+ group: FindingGrouping.Site,
80
+ },
81
+ 'unfilled-fact': {
82
+ one: S('"{text}" is still blank — fill it in before the site goes live.', '"{text}" עדיין ריק — מלאו אותו לפני שהאתר עולה לאוויר.'),
83
+ group: FindingGrouping.Never,
84
+ },
85
+ 'contact-missing': {
86
+ one: S('"{text}" is not on the site yet — visitors do not see that line until you fill it in.',
87
+ '"{text}" עוד לא באתר — המבקרים לא יראו את השורה הזו עד שתמלאו אותה.'),
88
+ group: FindingGrouping.Never,
89
+ },
90
+ 'copy-placeholder': {
91
+ one: S('Some words are still the template\'s.', 'חלק מהמילים עדיין של התבנית.'),
92
+ many: S('{n} places still hold the template\'s words.', 'ב-{n} מקומות עדיין מופיעות המילים של התבנית.'),
93
+ group: FindingGrouping.Page,
94
+ },
95
+ 'sample-items': {
96
+ one: S('"{name}" is a sample — replace or remove it.', '"{name}" הוא פריט לדוגמה — החליפו או הסירו אותו.'),
97
+ many: S('{n} sample items — replace them with yours or remove them.', '{n} פריטים לדוגמה — החליפו אותם בשלכם או הסירו אותם.'),
98
+ group: FindingGrouping.Site,
99
+ },
100
+ // Each sample product is fixed on its own page (the screen links to it), so they are never one row.
101
+ 'sample-price': {
102
+ one: S('"{name}" has no price yet — set yours, or remove the sample.', 'ל-"{name}" עדיין אין מחיר — קבעו מחיר או הסירו את הדוגמה.'),
103
+ group: FindingGrouping.Never,
104
+ },
105
+ 'sample-stock': {
106
+ one: S('"{name}" has no stock yet — say how many you have, or remove the sample.', 'ל-"{name}" עדיין אין מלאי — כתבו כמה יש לכם, או הסירו את הדוגמה.'),
107
+ group: FindingGrouping.Never,
108
+ },
109
+ // A store fact's words are the checkout gate's rule label (commerce-core) — `findingSentence` reads them by `fact`.
110
+ 'store-fact': { one: S('A fact the checkout needs is missing.', 'חסר פרט שהקופה צריכה.'), group: FindingGrouping.Never },
111
+ 'store-contact': { one: S('A contact detail the checkout needs is missing.', 'חסר פרט קשר שהקופה צריכה.'), group: FindingGrouping.Never },
112
+ 'stock-photo': {
113
+ one: S('A stock photo stands in for one of yours.', 'תמונה מהמאגר עומדת במקום תמונה שלכם.'),
114
+ many: S('{n} stock photos stand in for yours.', '{n} תמונות מהמאגר עומדות במקום התמונות שלכם.'),
115
+ group: FindingGrouping.Page,
116
+ },
117
+ 'made-picture': {
118
+ one: S('A picture made with AI stands in for one of yours.', 'תמונה שנוצרה ב-AI עומדת במקום תמונה שלכם.'),
119
+ many: S('{n} pictures made with AI stand in for yours.', '{n} תמונות שנוצרו ב-AI עומדות במקום התמונות שלכם.'),
120
+ group: FindingGrouping.Page,
121
+ },
122
+ 'picture-missing': {
123
+ one: {
124
+ made: S('A picture could not be made for this spot — add one of yours.', 'לא הצלחנו ליצור תמונה למקום הזה — הוסיפו תמונה שלכם.'),
125
+ box: S('A box on this page waits for a picture — add one of yours.', 'תיבה בעמוד הזה מחכה לתמונה — הוסיפו תמונה שלכם.'),
126
+ },
127
+ many: S('{n} boxes wait for a picture — add yours.', '{n} תיבות מחכות לתמונה — הוסיפו תמונות שלכם.'),
128
+ group: FindingGrouping.Page,
129
+ },
130
+ 'no-privacy-page': {
131
+ one: S('A form asks for personal details, and the site has no privacy page saying what you do with them.',
132
+ 'טופס מבקש פרטים אישיים, ואין באתר עמוד פרטיות שמסביר מה אתם עושים איתם.'),
133
+ group: FindingGrouping.Never,
134
+ },
135
+ 'legal-page-placeholder': {
136
+ one: S('"{name}" still says what belongs there — only you can write it.', 'בעמוד "{name}" עדיין כתוב רק מה צריך להופיע בו — רק אתם יכולים לכתוב אותו.'),
137
+ group: FindingGrouping.Never,
138
+ },
139
+ 'no-accessibility-statement': {
140
+ one: {
141
+ israel: S('The site has no accessibility statement — Israel requires one. Add a page for it and write what is accessible and who to contact.',
142
+ 'אין באתר הצהרת נגישות — החוק בישראל מחייב אותה. הוסיפו לה עמוד וכתבו מה נגיש ולמי לפנות.'),
143
+ hebrew: S('The site has no accessibility statement — a Hebrew site is expected to carry one. Add a page for it and write what is accessible and who to contact.',
144
+ 'אין באתר הצהרת נגישות — מאתר בעברית מצופה שתהיה בו. הוסיפו לה עמוד וכתבו מה נגיש ולמי לפנות.'),
145
+ },
146
+ group: FindingGrouping.Never,
147
+ },
148
+ 'accessibility-statement-advised': {
149
+ one: {
150
+ israel: S('The site has no accessibility statement — Israel requires one. Add a page for it.', 'אין באתר הצהרת נגישות — החוק בישראל מחייב אותה. הוסיפו לה עמוד.'),
151
+ hebrew: S('The site has no accessibility statement — a Hebrew site is expected to carry one. Add a page for it.', 'אין באתר הצהרת נגישות — מאתר בעברית מצופה שתהיה בו. הוסיפו לה עמוד.'),
152
+ },
153
+ group: FindingGrouping.Never,
154
+ },
155
+ 'consent-reject-weaker': {
156
+ one: {
157
+ missing: S('The cookie banner has no Reject beside Accept — refusing must be as easy as accepting.',
158
+ 'בבאנר העוגיות אין "דחייה" לצד "אישור" — לסרב צריך להיות קל כמו להסכים.'),
159
+ weaker: S('The cookie banner\'s Reject is weaker than its Accept — make it the same kind of button, on the same row.',
160
+ '"דחייה" בבאנר העוגיות חלשה מ"אישור" — הפכו אותה לאותו סוג כפתור, באותה שורה.'),
161
+ },
162
+ group: FindingGrouping.Never,
163
+ },
164
+ 'no-cookie-settings': {
165
+ one: S('Nothing on the site reopens the cookie choice — add Cookie settings to the footer so visitors can change their mind.',
166
+ 'שום דבר באתר לא פותח מחדש את בחירת העוגיות — הוסיפו "הגדרות עוגיות" לכותרת התחתונה כדי שמבקרים יוכלו לשנות את דעתם.'),
167
+ group: FindingGrouping.Never,
168
+ },
169
+ 'low-contrast': {
170
+ one: {
171
+ light: S('{count} text and background pair(s) are hard to read in light mode.', '{count} צירופים של טקסט ורקע קשים לקריאה במצב בהיר.'),
172
+ dark: S('{count} text and background pair(s) are hard to read in dark mode.', '{count} צירופים של טקסט ורקע קשים לקריאה במצב כהה.'),
173
+ },
174
+ group: FindingGrouping.Never,
175
+ },
176
+ 'heading-order': {
177
+ one: {
178
+ skip: S('A heading on "{name}" skips a level (h{from} → h{to}).', 'כותרת בעמוד "{name}" מדלגת על רמה (מ-h{from} ל-h{to}).'),
179
+ h1: S('"{name}" has {count} main headings (h1); one is clearer.', 'בעמוד "{name}" יש {count} כותרות ראשיות (h1); אחת ברורה יותר.'),
180
+ },
181
+ many: S('{n} headings on this page are out of order.', '{n} כותרות בעמוד הזה לא בסדר הנכון.'),
182
+ group: FindingGrouping.Page,
183
+ },
184
+ 'image-without-alt': {
185
+ one: S('A picture has no description for people who cannot see it.', 'לתמונה אין תיאור לאנשים שלא יכולים לראות אותה.'),
186
+ many: S('{n} pictures have no description for people who cannot see them.', '{n} תמונות בלי תיאור לאנשים שלא יכולים לראות אותן.'),
187
+ group: FindingGrouping.Page,
188
+ },
189
+ 'literal-colour': {
190
+ one: S('An element paints a fixed colour, so a new look will not reach it.', 'רכיב צבוע בצבע קבוע, ולכן מראה חדש לא יגיע אליו.'),
191
+ many: S('{n} elements paint a fixed colour, so a new look will not reach them.', '{n} רכיבים צבועים בצבע קבוע, ולכן מראה חדש לא יגיע אליהם.'),
192
+ group: FindingGrouping.Page,
193
+ },
194
+ 'dead-link': {
195
+ one: {
196
+ route: S('"{label}" links to {route}, which is not a page of the site.', '"{label}" מקשר אל {route}, שאינו עמוד באתר.'),
197
+ unlinked: S('"{label}" links to no page.', '"{label}" לא מקשר לשום עמוד.'),
198
+ action: S('"{label}" goes to a page the site does not have.', '"{label}" מוביל לעמוד שאין באתר.'),
199
+ },
200
+ many: S('{n} links on this page go to pages the site does not have.', '{n} קישורים בעמוד הזה מובילים לעמודים שאין באתר.'),
201
+ group: FindingGrouping.Page,
202
+ },
203
+ 'dead-dialog-target': {
204
+ one: S('"{label}" opens something that is no longer on the site.', '"{label}" פותח משהו שכבר לא נמצא באתר.'),
205
+ many: S('{n} buttons on this page open something that is no longer on the site.', '{n} כפתורים בעמוד הזה פותחים משהו שכבר לא נמצא באתר.'),
206
+ group: FindingGrouping.Page,
207
+ },
208
+ 'action-needs-connector': {
209
+ one: S('"{label}" needs {connector} connected.', '"{label}" צריך ש-{connector} יהיה מחובר.'),
210
+ group: FindingGrouping.Never,
211
+ },
212
+ };
213
+
214
+ /** The values a finding's sentence names (a page's or an item's name, a count, a route…), and its variant. */
215
+ export type FindingParams = Readonly<Record<string, string | number>>;
216
+
217
+ const PLACEHOLDER = /\{(\w+)\}/g;
218
+
219
+ function sentenceOf(words: FindingWords, variant: string | number | undefined): FindingSentence | null {
220
+ const one = words.one as Record<string, unknown>;
221
+ if (typeof one['en'] === 'string') return words.one as FindingSentence;
222
+ return (variant !== undefined ? (one[String(variant)] as FindingSentence | undefined) : undefined) ?? null;
223
+ }
224
+
225
+ /** A sentence with its values — or null when one it names is missing (an older finding, written without `params`). */
226
+ function fill(text: string, params: FindingParams): string | null {
227
+ let missing = false;
228
+ const out = text.replace(PLACEHOLDER, (_, key: string) => {
229
+ const v = params[key];
230
+ if (v === undefined || v === null) { missing = true; return ''; }
231
+ return String(v);
232
+ });
233
+ return missing ? null : out;
234
+ }
235
+
236
+ /** The English sentence `auditSite` stores as a finding's `message` (one source with the screens' words). */
237
+ export function findingMessageOf(code: `${SiteFindingCode}`, params: FindingParams = {}): string {
238
+ const sentence = sentenceOf(SITE_FINDING_WORDS[code], params['variant']);
239
+ return (sentence && fill(sentence.en, params)) ?? code;
240
+ }
241
+
242
+ /**
243
+ * One finding in the admin's language: a store fact is the checkout gate's rule label (commerce-core), every other code
244
+ * its sentence here with the finding's values. A finding that carries no values (written by an older server) keeps the
245
+ * server's own words.
246
+ */
247
+ export function findingSentence(f: Pick<SiteFinding, 'code' | 'message' | 'fact' | 'params'>, lang: string | null | undefined): string {
248
+ if (f.fact) {
249
+ const rule = CHECKOUT_GATE_RULES.find(r => r.code === f.fact);
250
+ if (rule) return labelIn(rule.label, lang);
251
+ }
252
+ const words = SITE_FINDING_WORDS[f.code as `${SiteFindingCode}`];
253
+ const sentence = words ? sentenceOf(words, f.params?.['variant']) : null;
254
+ return (sentence && fill(labelIn(sentence, lang), f.params ?? {})) ?? f.message;
255
+ }
256
+
257
+ /** Findings of one kind said as one row. */
258
+ export interface SiteFindingGroup {
259
+ /** Stable for a screen's list: the code and where the group is. */
260
+ key: string;
261
+ code: SiteFindingCode;
262
+ findings: SiteFinding[];
263
+ /** The first finding — where "Show me" goes, and its page / global. */
264
+ first: SiteFinding;
265
+ count: number;
266
+ }
267
+
268
+ function groupKey(f: SiteFinding, i: number): string {
269
+ const grouping = SITE_FINDING_WORDS[f.code as `${SiteFindingCode}`]?.group ?? FindingGrouping.Never;
270
+ switch (grouping) {
271
+ case FindingGrouping.Site: return `${f.code}`;
272
+ case FindingGrouping.Page: return `${f.code}:${f.pageId ?? `global:${f.owner ?? ''}`}`;
273
+ default: return `${f.code}:${f.fact ?? f.legal ?? f.nodeId ?? f.pageId ?? i}`;
274
+ }
275
+ }
276
+
277
+ /** Repeated findings of one kind as one row each (per page, per site, or never — `SITE_FINDING_WORDS[code].group`),
278
+ * in the order the first of each appears. */
279
+ export function groupSiteFindings(findings: ReadonlyArray<SiteFinding>): SiteFindingGroup[] {
280
+ const groups = new Map<string, SiteFinding[]>();
281
+ findings.forEach((f, i) => {
282
+ const key = groupKey(f, i);
283
+ const g = groups.get(key);
284
+ if (g) g.push(f); else groups.set(key, [f]);
285
+ });
286
+ return [...groups.entries()].map(([key, list]) => ({ key, code: list[0].code, findings: list, first: list[0], count: list.length }));
287
+ }
288
+
289
+ /** A group in the admin's language: its one finding's sentence, or the code's sentence for `{n}` of them. */
290
+ export function groupSentence(g: Pick<SiteFindingGroup, 'first' | 'count'>, lang: string | null | undefined): string {
291
+ const many = SITE_FINDING_WORDS[g.first.code as `${SiteFindingCode}`]?.many;
292
+ if (g.count < 2 || !many) return findingSentence(g.first, lang);
293
+ return fill(labelIn(many, lang), { n: g.count }) ?? findingSentence(g.first, lang);
294
+ }
@@ -2008,12 +2008,15 @@ export function planHeader(plan: SitePlan): { recipe: HeaderRecipe; context: Hea
2008
2008
  /** The phone-menu options a header recipe asks for: its menu at every width and on its side (none for the defaults, so a
2009
2009
  * stored header's edit is the one it always was). */
2010
2010
  function headerShapeOptions(recipe: HeaderRecipe | null, locale?: string): { everyWidth?: boolean; menuSide?: MenuSide; look?: Partial<MenuLook>; locale?: string } {
2011
- if (!recipe) return {};
2011
+ // vectoriox/iox-ui#100: the menu's words (and the names its parts are heard by) are the site's language — English
2012
+ // words are the table's English, so an English header composes as it always did (R-H4).
2013
+ const words = locale ? { locale } : {};
2014
+ if (!recipe) return words;
2012
2015
  // HI2a: the menu's look, only what differs from today's menu (a stored header composes as it always did — R-H4).
2013
2016
  const look = Object.fromEntries(Object.entries(recipe.menu).filter(([k, v]) => DEFAULT_MENU_LOOK[k as keyof MenuLook] !== v)) as Partial<MenuLook>;
2014
2017
  return {
2015
2018
  ...(recipe.everyWidth ? { everyWidth: true } : {}), ...(recipe.menuSide === MenuSide.Start ? { menuSide: MenuSide.Start } : {}),
2016
- ...(Object.keys(look).length ? { look, ...(locale ? { locale } : {}) } : {}),
2019
+ ...(Object.keys(look).length ? { look } : {}), ...words,
2017
2020
  };
2018
2021
  }
2019
2022
 
@@ -2022,11 +2025,29 @@ function headerShapeOptions(recipe: HeaderRecipe | null, locale?: string): { eve
2022
2025
  /** The header pattern the Studio template stamps — and the builder palette's "Navigation bar". */
2023
2026
  export const SITE_HEADER_PATTERN = 'nav.inline-cta';
2024
2027
 
2025
- /** A page of the studio as the builder lists it. */
2028
+ /** A stored page's status, as iox-cms keeps it. */
2029
+ export enum SitePageStatus {
2030
+ Draft = 'draft',
2031
+ Published = 'published',
2032
+ Archived = 'archived',
2033
+ }
2034
+
2035
+ /** iox-cms `HandoverState.Moved` (`src/pages/page-handover.ts`): a page a build replaced, moved aside to its `-previous`
2036
+ * address once the new page went live — a copy kept for the owner, never a page of the site. */
2037
+ export const SITE_PAGE_MOVED_ASIDE = 'moved';
2038
+
2039
+ /** A page of the studio as the builder lists it. The facts after `isHome` are the stored page's; a caller that does not
2040
+ * know them (a Site Plan, a spec) leaves them out and the page counts as live. */
2026
2041
  export interface SitePageRef {
2027
2042
  readonly name: string;
2028
2043
  readonly route: string;
2029
2044
  readonly isHome?: boolean;
2045
+ /** `status` as stored — absent: live. */
2046
+ readonly status?: string;
2047
+ /** A legal page (`pageSettings.legal`): linked from the footer, never from the navigation. */
2048
+ readonly legal?: boolean;
2049
+ /** The build hand-over (`pages.handover`): a page moved aside is not a page of the site. */
2050
+ readonly handover?: { readonly state?: string } | null;
2030
2051
  }
2031
2052
 
2032
2053
  /** What the header is composed from when there is no Site Plan: the studio's name and its pages. */
@@ -2072,19 +2093,45 @@ const ROUTE_PARAM = ':';
2072
2093
  const HOME_PATH = '/';
2073
2094
  const KEY_UNSAFE = /[^a-z0-9]+/gi;
2074
2095
 
2075
- /** The pages a navigation links to: every page but Home (the brand links there) and template pages
2076
- * (a `/work/:slug` route has no single address), in the studio's order. */
2096
+ const pageIsLive = (p: SitePageRef): boolean => p.status === undefined || p.status === SitePageStatus.Published;
2097
+
2098
+ /** The pages of the site: every page the studio holds but an archived one and a copy a build moved aside. What a section
2099
+ * may link to (a button to /contact), what a header is composed among. Pure. */
2100
+ export function sitePages(pages: ReadonlyArray<SitePageRef>): SitePageRef[] {
2101
+ return pages.filter(p => !!p.route && p.status !== SitePageStatus.Archived && p.handover?.state !== SITE_PAGE_MOVED_ASIDE);
2102
+ }
2103
+
2104
+ /**
2105
+ * THE rule for which pages a navigation links to (iox-cms-client#82) — the header the builder composes, its phone menu,
2106
+ * "Pages in the bar", a section's `$navPages`: a page of the site (`sitePages`) that a visitor reaches on the live site —
2107
+ * published (a draft is a 404 there) — and is not Home (the brand links there), not a template page (a `/work/:slug`
2108
+ * route has no single address), not a legal page (the footer's), one per address, in the studio's order. While NOTHING
2109
+ * of the studio is published yet (a site just built, before Publish site) the drafts stand in: Publish site puts them
2110
+ * live together, so none of them is a dead link on the site it will be. Pure.
2111
+ */
2077
2112
  export function siteNavPages(pages: ReadonlyArray<SitePageRef>): SitePageRef[] {
2078
- return pages.filter(p => !!p.route && !p.isHome && p.route !== HOME_PATH && !p.route.includes(ROUTE_PARAM));
2113
+ const ofSite = sitePages(pages);
2114
+ const anyLive = ofSite.some(pageIsLive);
2115
+ const seen = new Set<string>();
2116
+ return ofSite.filter(p => {
2117
+ if (p.isHome || p.route === HOME_PATH || p.route.includes(ROUTE_PARAM) || p.legal) return false;
2118
+ if (anyLive && !pageIsLive(p)) return false;
2119
+ if (seen.has(p.route)) return false;
2120
+ seen.add(p.route);
2121
+ return true;
2122
+ });
2079
2123
  }
2080
2124
 
2125
+ /** The site's pages as a plan's: each `inNav` exactly when `siteNavPages` links it — ONE rule for every composer. */
2081
2126
  function navPagePlans(pages: ReadonlyArray<SitePageRef>): PagePlan[] {
2082
2127
  const used = new Set<string>();
2083
- return pages.map((p, i) => {
2128
+ const ofSite = sitePages(pages);
2129
+ const nav = new Set(siteNavPages(ofSite));
2130
+ return ofSite.map((p, i) => {
2084
2131
  let key = p.route.replace(KEY_UNSAFE, '-').replace(/^-+|-+$/g, '').toLowerCase() || `page-${i}`;
2085
2132
  for (let n = 2; used.has(key); n++) key = `${key}-${n}`;
2086
2133
  used.add(key);
2087
- return { key, name: p.name, route: p.route, inNav: true, isHome: p.isHome === true, sections: [] };
2134
+ return { key, name: p.name, route: p.route, inNav: nav.has(p), isHome: p.isHome === true, sections: [] };
2088
2135
  });
2089
2136
  }
2090
2137
 
@@ -2097,9 +2144,7 @@ function navPagePlans(pages: ReadonlyArray<SitePageRef>): PagePlan[] {
2097
2144
  /** The plan a studio with no Site Plan stands for, as far as its header goes: its name, its pages (in the navigation or
2098
2145
  * not), its language, its look. */
2099
2146
  function navHeaderPlan(input: Omit<NavHeaderInput, 'mix' | 'asAsked'>): SitePlan {
2100
- const all = navPagePlans(input.pages);
2101
- const navRoutes = new Set(siteNavPages(input.pages).map(p => p.route));
2102
- const pages = all.map(p => ({ ...p, inNav: navRoutes.has(p.route) }));
2147
+ const pages = navPagePlans(input.pages);
2103
2148
  return { business: input.business, pages, dataSources: [], contentTypes: [], locale: input.locale, design: input.design ?? {} } as unknown as SitePlan;
2104
2149
  }
2105
2150
 
@@ -1,4 +1,5 @@
1
1
  import { AccountRole, ShopRole } from '@vectoriox/iox-ui/composite-core';
2
+ import { commerceLanguage } from '@vectoriox/iox-ui/commerce-core';
2
3
  import { LinkType, MenuButtonKind, menuButtonOf, menuButtonProps, menuDialogProps, MenuLook, MenuTrait } from '@vectoriox/iox-ui/design-core';
3
4
 
4
5
  import { PatternGlobalPosition } from './patterns';
@@ -94,7 +95,7 @@ export interface NavShapeOptions {
94
95
  * traits on the drawer, the menu button and the drawer's Close; a default writes nothing (R-H4). Absent: the parts
95
96
  * keep what they have. */
96
97
  look?: Partial<MenuLook>;
97
- /** The site's language, for the words a menu button shows (`word`: Menu ⇄ Close). Default English. */
98
+ /** The site's language, for the words the menu's parts show and are named by (`menuWords`). Default English. */
98
99
  locale?: string;
99
100
  }
100
101
 
@@ -134,15 +135,18 @@ export const NAV_SHAPE_COPY = {
134
135
  home: 'Home',
135
136
  } as const;
136
137
 
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: 'סגירה' },
138
+ /** The words the menu's parts say, in the site's language — a `word` menu button's visible Menu ⇄ Close (HI2a) and the
139
+ * names a screen reader hears (the menu button, the drawer, its Close, the bar's More, the drawer's Home link). A site
140
+ * in a language the table does not hold speaks English, as it always did (vectoriox/iox-ui#100). */
141
+ export interface MenuWords { menu: string; close: string; closeMenu: string; more: string; home: string }
142
+
143
+ const MENU_WORDS: Readonly<Record<string, MenuWords>> = {
144
+ en: { ...NAV_SHAPE_COPY },
145
+ he: { menu: 'תפריט', close: 'סגירה', closeMenu: 'סגירת התפריט', more: 'עוד', home: 'בית' },
142
146
  };
143
147
 
144
- export function menuWords(locale: string | undefined): { menu: string; close: string } {
145
- return MENU_WORDS[locale ?? ''] ?? MENU_WORDS['en'];
148
+ export function menuWords(locale: string | undefined): MenuWords {
149
+ return MENU_WORDS[commerceLanguage(locale)] ?? MENU_WORDS['en'];
146
150
  }
147
151
 
148
152
  /** The layer names of the parts (R2: the tree, the breadcrumb and the toolbar read them). */
@@ -397,8 +401,8 @@ function labelText(kit: Kit, suffix: string, words: string): SerializedNode {
397
401
  // lines makes the row taller, and two centred buttons in rows of different heights part (iox-ui#60).
398
402
  const MENU_BUTTON_LAY = { width: '48px', height: '48px', alignItems: 'center', justifyContent: 'center', alignSelf: 'flex-start', flexShrink: '0' };
399
403
 
400
- function menuButton(kit: Kit, drawerId: string, at: string): SerializedNode {
401
- const btn = part(kit, 'menu', BUTTON, { tag: 'button', ariaLabel: NAV_SHAPE_COPY.menu }, 'button-ghost', NavRole.MenuButton, { ...MENU_BUTTON_LAY });
404
+ function menuButton(kit: Kit, drawerId: string, at: string, words: MenuWords): SerializedNode {
405
+ const btn = part(kit, 'menu', BUTTON, { tag: 'button', ariaLabel: words.menu }, 'button-ghost', NavRole.MenuButton, { ...MENU_BUTTON_LAY });
402
406
  btn.children = [iconNode(kit, 'menu-icon', MENU_ICON)];
403
407
  btn.interactions = [clickTo(kit, 'menu', NavDialogAction.Toggle, drawerId)];
404
408
  phoneOnly(btn, at, MENU_DISPLAY);
@@ -409,14 +413,14 @@ function pageLink(kit: Kit, suffix: string, page: NavPage, role: NavRole, lay: R
409
413
  return part(kit, suffix, LINK, { label: page.label, linkType: LinkType.Page, pageRoute: page.route }, 'link', role, lay);
410
414
  }
411
415
 
412
- function drawer(kit: Kit, root: SerializedNode, pages: NavPage[], at: string): SerializedNode {
416
+ function drawer(kit: Kit, root: SerializedNode, pages: NavPage[], at: string, words: MenuWords): SerializedNode {
413
417
  const dr = part(kit, 'drawer', DIALOG, {
414
- placement: 'end', closeOnBackdrop: true, showCloseButton: false, ariaLabel: NAV_SHAPE_COPY.menu, closeAbove: at,
418
+ placement: 'end', closeOnBackdrop: true, showCloseButton: false, ariaLabel: words.menu, closeAbove: at,
415
419
  }, 'dialog', NavRole.Drawer, { width: '86vw', maxWidth: '360px', display: 'flex', flexDirection: 'column', gap: '20px' });
416
420
  const brandWords = textOf(find([root], NavRole.Brand) ?? root) || NAV_PART_LABELS[NavRole.Root];
417
421
  const head = part(kit, 'drawer-head', CONTAINER, {}, 'box', NavRole.DrawerHead,
418
422
  { display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: '12px' });
419
- const close = part(kit, 'drawer-close', BUTTON, { tag: 'button', ariaLabel: NAV_SHAPE_COPY.closeMenu }, 'button-ghost', NavRole.DrawerClose, { ...MENU_BUTTON_LAY });
423
+ const close = part(kit, 'drawer-close', BUTTON, { tag: 'button', ariaLabel: words.closeMenu }, 'button-ghost', NavRole.DrawerClose, { ...MENU_BUTTON_LAY });
420
424
  close.children = [iconNode(kit, 'drawer-close-icon', CLOSE_ICON)];
421
425
  close.interactions = [clickTo(kit, 'drawer-close', NavDialogAction.Close, dr.id)];
422
426
  head.children = [part(kit, 'drawer-brand', HEADING, { content: brandWords, level: 'h3' }, 'h3'), close];
@@ -426,7 +430,7 @@ function drawer(kit: Kit, root: SerializedNode, pages: NavPage[], at: string): S
426
430
  // beat one inherited from the list). The links rest at the body weight and the CURRENT page reads by its ink and
427
431
  // weight (no line since 2026-11-22) — the shared CSS keys that on the list's role (iox-design.css), so no Link holds
428
432
  // a literal over its element style.
429
- list.children = withHome(root, pages).map((p, i) => pageLink(kit, `drawer-link-${i}`, p, NavRole.DrawerLink,
433
+ list.children = withHome(root, pages, words).map((p, i) => pageLink(kit, `drawer-link-${i}`, p, NavRole.DrawerLink,
430
434
  { display: 'flex', alignItems: 'center', minHeight: '48px', fontSize: 'var(--iox-size-lead)' }));
431
435
  dr.children = [head, list];
432
436
  const cta = find([root], NavRole.Cta);
@@ -510,35 +514,35 @@ const BAR_ITEM_LAY = {
510
514
  flexGrow: '1', flexShrink: '1', flexBasis: '0px', minWidth: '0px', minHeight: '52px', padding: '4px 2px', textDecoration: 'none',
511
515
  };
512
516
 
513
- function moreItem(kit: Kit, drawerId: string): SerializedNode {
517
+ function moreItem(kit: Kit, drawerId: string, words: MenuWords): SerializedNode {
514
518
  const more = part(kit, 'bar-more', BUTTON, { tag: 'button' }, 'bottom-bar-item', NavRole.More, BAR_ITEM_LAY);
515
- more.children = [iconNode(kit, 'bar-more-icon', MORE_ICON), labelText(kit, 'bar-more-label', NAV_SHAPE_COPY.more)];
519
+ more.children = [iconNode(kit, 'bar-more-icon', MORE_ICON), labelText(kit, 'bar-more-label', words.more)];
516
520
  more.interactions = [clickTo(kit, 'bar-more', NavDialogAction.Toggle, drawerId)];
517
521
  return more;
518
522
  }
519
523
 
520
524
  /** Home first, then the header's pages: the header reaches Home through its brand, a phone menu names it. */
521
- function withHome(root: SerializedNode, pages: NavPage[]): NavPage[] {
525
+ function withHome(root: SerializedNode, pages: NavPage[], words: MenuWords): NavPage[] {
522
526
  const brand = find([root], NavRole.Brand);
523
527
  const home = brand && isPageLink(brand) && prop(brand, 'pageRoute') === HOME_ROUTE && !pages.some(p => p.route === HOME_ROUTE)
524
- ? [{ label: NAV_SHAPE_COPY.home, route: HOME_ROUTE }] : [];
528
+ ? [{ label: words.home, route: HOME_ROUTE }] : [];
525
529
  return [...home, ...pages];
526
530
  }
527
531
 
528
532
  /** The bar's pages: Home first (a bottom bar's customary first stop), capped. */
529
- function barPages(root: SerializedNode, pages: NavPage[], count: number): NavPage[] {
530
- return withHome(root, pages).slice(0, count);
533
+ function barPages(root: SerializedNode, pages: NavPage[], count: number, words: MenuWords): NavPage[] {
534
+ return withHome(root, pages, words).slice(0, count);
531
535
  }
532
536
 
533
- function bar(kit: Kit, root: SerializedNode, pages: NavPage[], shape: NavShape, count: number, drawerId: string | null, at: string): SerializedNode {
537
+ function bar(kit: Kit, root: SerializedNode, pages: NavPage[], shape: NavShape, count: number, drawerId: string | null, at: string, words: MenuWords): SerializedNode {
534
538
  // The node IS fixed (not only its element style): the builder canvas forces a node's own `position`
535
539
  // with !important, so a stored `static` default would pin the bar into the flow there.
536
540
  const b = part(kit, 'bar', CONTAINER, { htmlTag: 'nav' }, 'bottom-bar', NavRole.Bar,
537
541
  { position: 'fixed', justifyContent: 'space-around', alignItems: 'stretch', gap: '4px', padding: '6px 8px', width: 'auto' });
538
542
  phoneOnly(b, at, 'flex');
539
543
  const itemCount = shape === NavShape.Both ? count - 1 : count;
540
- b.children = barPages(root, pages, itemCount).map((p, i) => barItem(kit, i, p));
541
- if (shape === NavShape.Both && drawerId) b.children.push(moreItem(kit, drawerId));
544
+ b.children = barPages(root, pages, itemCount, words).map((p, i) => barItem(kit, i, p));
545
+ if (shape === NavShape.Both && drawerId) b.children.push(moreItem(kit, drawerId, words));
542
546
  b.isGlobal = true;
543
547
  b.globalPosition = PatternGlobalPosition.After;
544
548
  return b;
@@ -651,6 +655,7 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
651
655
  const everyWidth = shape === NavShape.Drawer && (options.everyWidth ?? wasEveryWidth);
652
656
  if (options.everyWidth && shape !== NavShape.Drawer) throw new NavShapeError('only a drawer menu shows at every width');
653
657
  const kit = makeKit(out, root.id, options.newId);
658
+ const words = menuWords(options.locale);
654
659
 
655
660
  adoptRoles(root);
656
661
  const { pages } = phoneMenuPages(root, options.pages);
@@ -663,7 +668,7 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
663
668
  const topIndex = out.findIndex(g => g.role === NavRole.Drawer);
664
669
  if (!dr && topIndex >= 0) dr = out.splice(topIndex, 1)[0];
665
670
  if (dr) { delete dr.isGlobal; delete dr.globalPosition; }
666
- if (wantDrawer && !dr) dr = drawer(kit, root, pages, at);
671
+ if (wantDrawer && !dr) dr = drawer(kit, root, pages, at, words);
667
672
  if (!wantDrawer) dr = null;
668
673
  // A drawer reached at every width never closes itself above a breakpoint.
669
674
  if (dr) dr.props = { ...dr.props, closeAbove: everyWidth ? '' : at };
@@ -672,7 +677,7 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
672
677
  if (options.menuSide !== undefined && !(Object.values(MenuSide) as string[]).includes(options.menuSide)) throw new NavShapeError(`a menu button cannot sit at "${options.menuSide}"`);
673
678
  const was = menuPlace(root);
674
679
  const existingMenu = removeRole(root, NavRole.MenuButton);
675
- const menu = wantMenuButton ? (existingMenu ? asToggle(existingMenu) : menuButton(kit, dr!.id, at)) : null;
680
+ const menu = wantMenuButton ? (existingMenu ? asToggle(existingMenu) : menuButton(kit, dr!.id, at, words)) : null;
676
681
 
677
682
  for (const p of phoneHiddenParts(root)) {
678
683
  if (everyWidth && !KEPT_AT_EVERY_WIDTH.has(roleOf(p))) { displayEverywhere(p, NONE); continue; }
@@ -713,7 +718,7 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
713
718
  let more: SerializedNode | null = null;
714
719
  if (wantBar) {
715
720
  const count = clampBarCount(options.barItems, shape);
716
- if (!b) b = bar(kit, root, pages, shape, count, dr?.id ?? null, at);
721
+ if (!b) b = bar(kit, root, pages, shape, count, dr?.id ?? null, at, words);
717
722
  else {
718
723
  moveDisplayOverride(b, at);
719
724
  more = (b.children ?? []).find(c => c.role === NavRole.More) ?? null;
@@ -721,11 +726,11 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
721
726
  if (options.barItems !== undefined) {
722
727
  const items = b.children;
723
728
  const want = shape === NavShape.Both ? count - 1 : count;
724
- const extra = barPages(root, pages, BAR_ITEMS_MAX).filter(p => !items.some(c => prop(c, 'pageRoute') === p.route));
729
+ const extra = barPages(root, pages, BAR_ITEMS_MAX, words).filter(p => !items.some(c => prop(c, 'pageRoute') === p.route));
725
730
  while (items.length > want) items.pop();
726
731
  while (items.length < want && extra.length) items.push(barItem(kit, items.length, extra.shift()!));
727
732
  }
728
- if (shape === NavShape.Both && dr) b.children.push(retarget(more ?? moreItem(kit, dr.id), dr.id));
733
+ if (shape === NavShape.Both && dr) b.children.push(retarget(more ?? moreItem(kit, dr.id, words), dr.id));
729
734
  }
730
735
  out.push(b);
731
736
  }
@@ -776,7 +781,7 @@ export interface AddBarItemResult {
776
781
  * The bar's Items list "Add item" (board 2): one more item, before More — the next navigation page the
777
782
  * bar does not link to yet (Home when every page is there). Refused at five (Q2). Input not mutated.
778
783
  */
779
- export function addBarItem(globals: ReadonlyArray<SerializedNode>, options: Pick<NavShapeOptions, 'newId' | 'pages'> = {}): AddBarItemResult {
784
+ export function addBarItem(globals: ReadonlyArray<SerializedNode>, options: Pick<NavShapeOptions, 'newId' | 'pages' | 'locale'> = {}): AddBarItemResult {
780
785
  const out = clone(globals) as SerializedNode[];
781
786
  const root = findNavRoot(out);
782
787
  const b = find(out, NavRole.Bar);
@@ -784,8 +789,9 @@ export function addBarItem(globals: ReadonlyArray<SerializedNode>, options: Pick
784
789
  const kids = b.children ?? (b.children = []);
785
790
  if (kids.length >= BAR_ITEMS_MAX) return { globals: out, added: false };
786
791
  const linked = new Set(kids.filter(c => c.role === NavRole.BarItem).map(c => prop(c, 'pageRoute')));
787
- const page = barPages(root, phoneMenuPages(root, options.pages).pages, BAR_ITEMS_MAX + 1).find(p => !linked.has(p.route))
788
- ?? { label: NAV_SHAPE_COPY.home, route: HOME_ROUTE };
792
+ const words = menuWords(options.locale);
793
+ const page = barPages(root, phoneMenuPages(root, options.pages).pages, BAR_ITEMS_MAX + 1, words).find(p => !linked.has(p.route))
794
+ ?? { label: words.home, route: HOME_ROUTE };
789
795
  const item = barItem(makeKit(out, root.id, options.newId), kids.length, page);
790
796
  const more = kids.findIndex(c => c.role === NavRole.More);
791
797
  if (more >= 0) kids.splice(more, 0, item); else kids.push(item);
@@ -45,6 +45,7 @@ export * from './strict-schema';
45
45
  export * from './plan-edits';
46
46
  export * from './plan-words';
47
47
  export * from './audit-site';
48
+ export * from './audit-words';
48
49
  export * from './stock-match';
49
50
  export * from './stock-photos';
50
51
  export * from './film';