@vectoriox/iox-ui 5.149.0 → 5.151.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,295 @@
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
+ // A fact this table does not know (a newer server) keeps the server's own words — never the generic sentence.
250
+ const rule = CHECKOUT_GATE_RULES.find(r => r.code === f.fact);
251
+ return rule ? labelIn(rule.label, lang) : f.message;
252
+ }
253
+ const words = SITE_FINDING_WORDS[f.code as `${SiteFindingCode}`];
254
+ const sentence = words ? sentenceOf(words, f.params?.['variant']) : null;
255
+ return (sentence && fill(labelIn(sentence, lang), f.params ?? {})) ?? f.message;
256
+ }
257
+
258
+ /** Findings of one kind said as one row. */
259
+ export interface SiteFindingGroup {
260
+ /** Stable for a screen's list: the code and where the group is. */
261
+ key: string;
262
+ code: SiteFindingCode;
263
+ findings: SiteFinding[];
264
+ /** The first finding — where "Show me" goes, and its page / global. */
265
+ first: SiteFinding;
266
+ count: number;
267
+ }
268
+
269
+ function groupKey(f: SiteFinding, i: number): string {
270
+ const grouping = SITE_FINDING_WORDS[f.code as `${SiteFindingCode}`]?.group ?? FindingGrouping.Never;
271
+ switch (grouping) {
272
+ case FindingGrouping.Site: return `${f.code}`;
273
+ case FindingGrouping.Page: return `${f.code}:${f.pageId ?? `global:${f.owner ?? ''}`}`;
274
+ default: return `${f.code}:${f.fact ?? f.legal ?? f.nodeId ?? f.pageId ?? i}`;
275
+ }
276
+ }
277
+
278
+ /** Repeated findings of one kind as one row each (per page, per site, or never — `SITE_FINDING_WORDS[code].group`),
279
+ * in the order the first of each appears. */
280
+ export function groupSiteFindings(findings: ReadonlyArray<SiteFinding>): SiteFindingGroup[] {
281
+ const groups = new Map<string, SiteFinding[]>();
282
+ findings.forEach((f, i) => {
283
+ const key = groupKey(f, i);
284
+ const g = groups.get(key);
285
+ if (g) g.push(f); else groups.set(key, [f]);
286
+ });
287
+ return [...groups.entries()].map(([key, list]) => ({ key, code: list[0].code, findings: list, first: list[0], count: list.length }));
288
+ }
289
+
290
+ /** A group in the admin's language: its one finding's sentence, or the code's sentence for `{n}` of them. */
291
+ export function groupSentence(g: Pick<SiteFindingGroup, 'first' | 'count'>, lang: string | null | undefined): string {
292
+ const many = SITE_FINDING_WORDS[g.first.code as `${SiteFindingCode}`]?.many;
293
+ if (g.count < 2 || !many) return findingSentence(g.first, lang);
294
+ return fill(labelIn(many, lang), { n: g.count }) ?? findingSentence(g.first, lang);
295
+ }
@@ -3,6 +3,7 @@ import {
3
3
  LayoutListMove, LayoutListPhone, LayoutListShape, LayoutListWho, LayoutMendKind, LayoutPage,
4
4
  } from './layout-language';
5
5
  import { LIST_RULES, bentoFill, listBelowPro, listBuiltWords, listMeaning, listWait, listWordRefusal, ListWordRefusal } from './list-table';
6
+ import { bentoFillsParams, listSaidSentence, ListSaid, ListSayCode, ListSayParams, listWordRef, listWordRefs } from './list-words';
6
7
  import { SPEC_SITE_LAYOUT } from './site-spec.generated';
7
8
 
8
9
  /**
@@ -25,6 +26,10 @@ const has = <T extends string>(list: ReadonlyArray<T>, v: string): boolean => (l
25
26
 
26
27
  /** The words a repaired mix is said in (the brief and the owner read them). */
27
28
  const say = (arrange: string) => listMeaning('arrange', arrange);
29
+ /** An arrangement, as a value a sentence names (list-words.ts says it in the owner's language). */
30
+ const arr = (arrange: string) => listWordRef('arrange', arrange);
31
+ /** One issue of the judge: its English sentence is the message, its code and values are what a screen says (#123). */
32
+ const wordedIssue = (code: LayoutIssueCode, path: string, said: ListSaid): LayoutIssue => ({ code, path, message: listSaidSentence(said, null), words: said });
28
33
 
29
34
  /**
30
35
  * What a business type's lists never do (L-D12, the contract's harness `businessTypes[].lists` — harness-core
@@ -35,6 +40,8 @@ export interface LayoutListNever {
35
40
  readonly moves: ReadonlyArray<string>;
36
41
  /** Why, in the owner's words — said with the repair. */
37
42
  readonly say: ReadonlyArray<string>;
43
+ /** The same, in Hebrew (vectoriox/iox-ui#123 — the contract's `lists.sayHe`, one sentence for each English one). */
44
+ readonly sayHe?: ReadonlyArray<string>;
38
45
  }
39
46
 
40
47
  /** AW11: what the judge knows of where the list sits and who it is built for. */
@@ -73,19 +80,19 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
73
80
  if (refused.length || !shape) return refused;
74
81
 
75
82
  if (shape.items !== null && shape.items < R.minItems) {
76
- return [{ code: LayoutIssueCode.Content, path: at, message: `a list section shows at least ${R.minItems} items — "${shape.alias}" has ${shape.items}; show it another way` }];
83
+ return [wordedIssue(LayoutIssueCode.Content, at, { code: ListSayCode.TooFewItems, params: { min: R.minItems, alias: shape.alias, items: shape.items } })];
77
84
  }
78
85
 
79
86
  const next: LayoutListMix = structuredClone(mix);
80
- const said: string[] = [];
81
- const repair = (message: string) => said.push(message);
87
+ const said: ListSaid[] = [];
88
+ const repair = (code: `${ListSayCode}`, params: ListSayParams = {}) => said.push({ code, params });
82
89
 
83
90
  // A word the product draws in a later phase (the contract's list table, award AW0): drawn as its stand-in meanwhile,
84
91
  // and said — first, so every rule below judges the mix the product will draw. The wire never offers one.
85
92
  const waiting = (k: 'item' | 'arrange' | 'arrive' | 'move' | 'hover', w: string): string | null | undefined => {
86
93
  const wait = listWait(k, w);
87
94
  if (!wait) return undefined;
88
- repair(`${k} "${w}" is drawn in ${wait.phase}: ${wait.drawnAs ? `"${wait.drawnAs}" meanwhile` : 'left out meanwhile'}`);
95
+ repair(ListSayCode.Waits, { k, word: listWordRef(k, w), phase: wait.phase, ...(wait.drawnAs ? { as: listWordRef(k, wait.drawnAs) } : {}) });
89
96
  return wait.drawnAs;
90
97
  };
91
98
  for (const k of ['item', 'arrange', 'arrive'] as const) {
@@ -101,7 +108,7 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
101
108
  const below = (k: 'item' | 'arrange' | 'arrive', fallback: string) => {
102
109
  const stand = listBelowPro(k, next[k]);
103
110
  if (stand === undefined) return;
104
- repair(`${k} "${next[k]}" comes with the award plan: "${stand ?? fallback}" instead`);
111
+ repair(ListSayCode.AwardOnly, { k, word: listWordRef(k, next[k]), as: listWordRef(k, stand ?? fallback) });
105
112
  (next as unknown as Record<string, string>)[k] = stand ?? fallback;
106
113
  };
107
114
  below('item', LayoutListItem.Card);
@@ -111,7 +118,7 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
111
118
  const kept = (next[k] as string[]).flatMap(w => {
112
119
  const stand = listBelowPro(k, w);
113
120
  if (stand === undefined) return [w];
114
- repair(`${k} "${w}" comes with the award plan: ${stand ? `"${stand}" instead` : 'left out'}`);
121
+ repair(ListSayCode.AwardOnly, { k, word: listWordRef(k, w), ...(stand ? { as: listWordRef(k, stand) } : {}) });
115
122
  return stand ? [stand] : [];
116
123
  });
117
124
  (next as unknown as Record<string, string[]>)[k] = [...new Set(kept)];
@@ -124,15 +131,15 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
124
131
  const unique = [...new Set(next.parts)];
125
132
  const foreign = unique.filter(p => !roles.includes(p));
126
133
  if (foreign.length || unique.length !== next.parts.length) {
127
- if (foreign.length) repair(`"${shape.alias}" holds no ${foreign.join(', ')} — left out`);
134
+ if (foreign.length) repair(ListSayCode.NoSuchParts, { alias: shape.alias, parts: foreign });
128
135
  next.parts = unique.filter(p => roles.includes(p));
129
136
  }
130
137
  if (next.item === LayoutListItem.Photo) {
131
138
  if (!pictured) {
132
- repair(`"${shape.alias}" has no pictures — its items are cards`);
139
+ repair(ListSayCode.PhotoNoPictures, { alias: shape.alias });
133
140
  next.item = LayoutListItem.Card;
134
141
  } else if (next.parts.length !== 1 || next.parts[0] !== IMAGE) {
135
- repair('a photo item shows its picture only');
142
+ repair(ListSayCode.PhotoPictureOnly);
136
143
  next.parts = [IMAGE];
137
144
  }
138
145
  }
@@ -140,21 +147,21 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
140
147
  // AW11: round-two items — each needs what it shows (one table: listWordRefusal).
141
148
  const itemRefusal = listWordRefusal('item', next.item, shape);
142
149
  if (itemRefusal === ListWordRefusal.NoPictures) {
143
- repair(`"${shape.alias}" has no pictures — ${listMeaning('item', next.item)} needs one: its items are cards`);
150
+ repair(ListSayCode.ItemNeedsPictures, { alias: shape.alias, item: listWordRef('item', next.item) });
144
151
  next.item = LayoutListItem.Card;
145
152
  }
146
153
  if (next.item === LayoutListItem.TitleOnPhoto && (shape.titleWords ?? 0) > LIST_RULES.titleOnPhotoWords) {
147
- repair(`"${shape.alias}" has names of ${shape.titleWords} words — more than ${LIST_RULES.titleOnPhotoWords} would cover the picture: its items are cards`);
154
+ repair(ListSayCode.TitleTooLong, { alias: shape.alias, words: shape.titleWords ?? 0, max: LIST_RULES.titleOnPhotoWords });
148
155
  next.item = LayoutListItem.Card;
149
156
  }
150
157
  if (next.item === LayoutListItem.Packshot && shape.plainPictures === false) {
151
- repair(`"${shape.alias}"'s pictures do not stand on a plain ground — a packshot needs one: its items are cards`);
158
+ repair(ListSayCode.PackshotNotPlain, { alias: shape.alias });
152
159
  next.item = LayoutListItem.Card;
153
160
  }
154
161
  if (next.item === LayoutListItem.TitleOnPhoto) {
155
162
  const words = next.parts.filter(p => p === IMAGE || TITLE_ON_PHOTO_PARTS.has(p));
156
163
  if (words.length !== next.parts.length) {
157
- repair('a name on its picture shows the picture, the name and a short detail only');
164
+ repair(ListSayCode.TitleOnPhotoParts);
158
165
  next.parts = words;
159
166
  }
160
167
  if (!next.parts.includes(IMAGE)) next.parts = [IMAGE, ...next.parts];
@@ -162,50 +169,50 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
162
169
 
163
170
  // The arrangement first: what follows is judged against the one the list ends with.
164
171
  if (next.arrange === LayoutListArrange.Strips && !pictured) {
165
- repair('strips need a picture in every item — a still grid instead');
172
+ repair(ListSayCode.StripsNeedPictures);
166
173
  next.arrange = LayoutListArrange.Grid;
167
174
  }
168
175
  if (next.arrange === LayoutListArrange.Strips && shape.items !== null && shape.items > R.strips[1]) {
169
- repair(`${R.strips[1]} strips fit at most — "${shape.alias}" has ${shape.items}: ${say(LayoutListArrange.Row)}`);
176
+ repair(ListSayCode.StripsAtMost, { max: R.strips[1], alias: shape.alias, items: shape.items, instead: arr(LayoutListArrange.Row) });
170
177
  next.arrange = LayoutListArrange.Row;
171
178
  }
172
179
  // L-D12: the business's art direction — an arrangement its lists never take becomes a row.
173
- const why = never?.say.join(' ') || 'this business never shows a list that way';
180
+ const why = { why: never?.say.join(' ') ?? '', whyHe: never?.sayHe?.join(' ') ?? '' };
174
181
  if (never && has(never.arranges, next.arrange)) {
175
- repair(`${why} — ${say(LayoutListArrange.Row)}`);
182
+ repair(ListSayCode.NeverArrange, { ...why, instead: arr(LayoutListArrange.Row) });
176
183
  next.arrange = LayoutListArrange.Row;
177
184
  }
178
185
  // AW11: round-two arrangements — pictures where they need them, the counts they are drawn at.
179
186
  const arrangeRefusal = listWordRefusal('arrange', next.arrange, shape);
180
187
  if (arrangeRefusal === ListWordRefusal.NoPictures) {
181
- return [{ code: LayoutIssueCode.Content, path: `${at}.arrange`, message: `${say(next.arrange)} needs a picture in every item — "${shape.alias}" has none; arrange it another way` }];
188
+ return [wordedIssue(LayoutIssueCode.Content, `${at}.arrange`, { code: ListSayCode.ArrangeNeedsPictures, params: { arrange: arr(next.arrange), alias: shape.alias } })];
182
189
  }
183
190
  const count = LIST_RULES.counts[next.arrange];
184
191
  if (count && shape.items !== null) {
185
192
  const [fewest, most] = count;
186
193
  if (shape.items < fewest) {
187
194
  const instead = next.arrange === LayoutListArrange.Hang ? LayoutListArrange.Masonry : LayoutListArrange.Grid;
188
- repair(`${say(next.arrange)} needs ${fewest} items — "${shape.alias}" has ${shape.items}: ${say(instead)}`);
195
+ repair(ListSayCode.TooFewFor, { arrange: arr(next.arrange), fewest, alias: shape.alias, items: shape.items, instead: arr(instead) });
189
196
  next.arrange = instead;
190
197
  } else if (shape.items > most) {
191
- repair(`${say(next.arrange)} shows the first ${most} of "${shape.alias}"'s ${shape.items}, then the link to all of them`);
198
+ repair(ListSayCode.ShowsFirst, { arrange: arr(next.arrange), most, alias: shape.alias, items: shape.items });
192
199
  }
193
200
  }
194
201
  if (next.arrange === LayoutListArrange.Bento && shape.items !== null) {
195
202
  const fill = bentoFill(shape.items);
196
203
  if (fill === null) {
197
- repair(`a bento needs ${LIST_RULES.bento[0]} items — ${say(LayoutListArrange.Grid)}`);
204
+ repair(ListSayCode.BentoTooFew, { fewest: LIST_RULES.bento[0], instead: arr(LayoutListArrange.Grid) });
198
205
  next.arrange = LayoutListArrange.Grid;
199
206
  } else if (fill < shape.items) {
200
- repair(`a bento fits ${LIST_RULES.bento.join(', ')} — "${shape.alias}" has ${shape.items}, so it shows ${fill} and the link to all of them`);
207
+ repair(ListSayCode.BentoTrim, { ...bentoFillsParams(LIST_RULES.bento), alias: shape.alias, items: shape.items, shows: fill });
201
208
  }
202
209
  }
203
210
  const tiltedText = next.arrange === LayoutListArrange.Tilted && next.item !== LayoutListItem.Photo ? shape.long.filter(role => next.parts.includes(role)) : [];
204
- if (tiltedText.length) repair(`its ${tiltedText.join(' and ')} run long — a turned card shows their first lines`);
211
+ if (tiltedText.length) repair(ListSayCode.TiltedLong, { roles: tiltedText });
205
212
 
206
213
  const longShown = shape.long.filter(role => next.parts.includes(role));
207
214
  if (longShown.length && next.arrange === LayoutListArrange.Grid) {
208
- repair(`its ${longShown.join(' and ')} run long — a grid would cut them: ${say(LayoutListArrange.Masonry)}`);
215
+ repair(ListSayCode.GridLong, { roles: longShown, instead: arr(LayoutListArrange.Masonry) });
209
216
  next.arrange = LayoutListArrange.Masonry;
210
217
  }
211
218
  const arrange = next.arrange;
@@ -216,120 +223,126 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
216
223
  if (strips) {
217
224
  const who = next.standout?.who;
218
225
  if (who !== LayoutListWho.First && who !== LayoutListWho.Pointed) {
219
- repair('one strip is always open — the first');
226
+ repair(ListSayCode.StripOpenFirst);
220
227
  next.standout = { who: LayoutListWho.First, how: LayoutListHow.Wider };
221
228
  } else if (next.standout!.how !== LayoutListHow.Wider) {
222
- repair('the open strip is the wider one');
229
+ repair(ListSayCode.StripWider);
223
230
  next.standout = { who, how: LayoutListHow.Wider };
224
231
  }
225
232
  } else if (next.standout) {
226
233
  if (next.standout.who === LayoutListWho.None) {
227
- if (next.standout.how) repair('nothing stands out — no way to stand out');
234
+ if (next.standout.how) repair(ListSayCode.NoneStandsOut);
228
235
  delete next.standout;
229
236
  } else {
230
237
  if (has(R.onlyRow.who, next.standout.who) && !row && !has(LIST_RULES.middle ?? [], arrange)) {
231
- repair(`"${next.standout.who}" is a row's — the first stands out`);
238
+ repair(ListSayCode.RowsOnlyWho, { who: listWordRef('who', next.standout.who) });
232
239
  next.standout.who = LayoutListWho.First;
233
240
  }
234
241
  if (next.standout.how && has(R.onlyStrips.how, next.standout.how)) {
235
- repair(`"${next.standout.how}" is a strip's — bigger instead`);
242
+ repair(ListSayCode.StripsOnlyHow, { how: listWordRef('how', next.standout.how) });
236
243
  next.standout.how = LayoutListHow.Bigger;
237
244
  }
238
245
  }
239
246
  }
240
247
 
241
248
  if (arrange === LayoutListArrange.Rows && next.standout && (next.standout.who !== LIST_RULES.rowsStandout.who || next.standout.how !== LIST_RULES.rowsStandout.how)) {
242
- repair('numbered rows stand out one way: the one pointed at, the rest dimmed');
249
+ repair(ListSayCode.RowsStandout);
243
250
  next.standout = { who: LIST_RULES.rowsStandout.who as `${LayoutListWho}`, how: LIST_RULES.rowsStandout.how as `${LayoutListHow}` };
244
251
  }
245
252
 
246
253
  // How the visitor moves through them — never a way the business's lists never move (L-D12).
247
254
  const banned = never ? next.move.filter(m => has(never.moves, m)) : [];
248
255
  if (banned.length) {
249
- repair(`${why} — no ${banned.join(', ')}`);
256
+ repair(ListSayCode.NeverMove, { ...why, moves: listWordRefs('move', banned) });
250
257
  next.move = next.move.filter(m => !banned.includes(m));
251
258
  }
252
259
  // AW11: a fan moves only by being dragged, and only with enough cards to drag.
253
260
  if (arrange === LayoutListArrange.Fan && next.move.length) {
254
261
  const dragged = next.move.includes(LayoutListMove.Drag) && (shape.items === null || shape.items >= LIST_RULES.fanDragFrom);
255
262
  const dropped = next.move.filter(m => m !== LayoutListMove.Drag || !dragged);
256
- if (dropped.length) repair(dragged || !next.move.includes(LayoutListMove.Drag) ? `a fan is only dragged — no ${dropped.join(', ')}` : `a fan of fewer than ${LIST_RULES.fanDragFrom} cards stays still`);
263
+ if (dropped.length) {
264
+ if (dragged || !next.move.includes(LayoutListMove.Drag)) repair(ListSayCode.FanDragOnly, { moves: listWordRefs('move', dropped) });
265
+ else repair(ListSayCode.FanTooFew, { fewest: LIST_RULES.fanDragFrom });
266
+ }
257
267
  next.move = dragged ? [LayoutListMove.Drag] : [];
258
268
  }
259
269
  if (next.move.includes(LayoutListMove.Rows) && !pictured) {
260
- repair(`"${shape.alias}" has no pictures — no drifting rows`);
270
+ repair(ListSayCode.DriftNeedsPictures, { alias: shape.alias });
261
271
  next.move = next.move.filter(m => m !== LayoutListMove.Rows);
262
272
  }
263
273
  const moving = has(R.moving, arrange) || (arrange === LayoutListArrange.Fan && next.move.length > 0);
264
274
  if (!moving && next.move.length) {
265
- repair(`${say(arrange)} does not move — no ${next.move.join(', ')}`);
275
+ repair(ListSayCode.StillNoMove, { arrange: arr(arrange), moves: listWordRefs('move', next.move) });
266
276
  next.move = [];
267
277
  }
268
278
  if (moving) {
269
279
  const onlyRow = next.move.filter(m => has(R.onlyRow.move, m));
270
280
  if (onlyRow.length && !row) {
271
- repair(`"${onlyRow.join(', ')}" carries a row only`);
281
+ repair(ListSayCode.RowOnlyMove, { moves: listWordRefs('move', onlyRow) });
272
282
  next.move = next.move.filter(m => !has(R.onlyRow.move, m));
273
283
  }
274
284
  if (next.move.includes(LayoutListMove.Page) && next.move.length > 1) {
275
- repair('the page\'s scroll carries the row alone');
285
+ repair(ListSayCode.PageAlone);
276
286
  next.move = [LayoutListMove.Page];
277
287
  }
278
288
  if (next.move.includes(LayoutListMove.Rows) && next.move.length > 1) {
279
- repair('drifting rows move by themselves alone');
289
+ repair(ListSayCode.DriftAlone);
280
290
  next.move = [LayoutListMove.Rows];
281
291
  }
282
292
  if (next.move.includes(LayoutListMove.Rows) && next.item !== LayoutListItem.Photo) {
283
- repair('drifting rows hold pictures only');
293
+ repair(ListSayCode.DriftPicturesOnly);
284
294
  next.item = LayoutListItem.Photo;
285
295
  next.parts = [IMAGE];
286
296
  }
287
297
  if (!next.move.length) {
288
- repair(`${say(arrange)} — the visitor drags it`);
298
+ repair(ListSayCode.DragDefault, { arrange: arr(arrange) });
289
299
  next.move = [LayoutListMove.Drag];
290
300
  }
291
301
  }
292
302
  const stripHovers = next.hover.filter(h => has(R.onlyStrips.hover, h));
293
303
  if (stripHovers.length && !strips) {
294
- repair(`"${stripHovers.join(', ')}" is a strip's`);
304
+ repair(ListSayCode.StripsOnlyHover, { hovers: listWordRefs('hover', stripHovers) });
295
305
  next.hover = next.hover.filter(h => !has(R.onlyStrips.hover, h));
296
306
  }
297
307
  // AW11: hover words that need what the list may not have (one table), and the hover tilt — a still card's.
298
308
  const unread = next.hover.filter(h => listWordRefusal('hover', h, shape) !== null && listWordRefusal('hover', h, shape) !== ListWordRefusal.ProOnly);
299
309
  if (unread.length) {
300
- repair(unread.map(h => listWordRefusal('hover', h, shape) === ListWordRefusal.NoSecondPicture
301
- ? `"${h}" needs a second picture — "${shape.alias}" has one per item`
302
- : `"${h}" needs a picture — "${shape.alias}" has none`).join('; '));
310
+ // One sentence each (#123: they were one joined line — a screen says each in the owner's words).
311
+ for (const h of unread) {
312
+ repair(listWordRefusal('hover', h, shape) === ListWordRefusal.NoSecondPicture ? ListSayCode.HoverSecondPicture : ListSayCode.HoverPicture,
313
+ { hover: listWordRef('hover', h), alias: shape.alias });
314
+ }
303
315
  next.hover = next.hover.filter(h => !unread.includes(h));
304
316
  }
305
317
  if (next.hover.includes(LayoutListHover.Tilt) && (moving || next.item !== LayoutListItem.Card && next.item !== LayoutListItem.Packshot && next.item !== LayoutListItem.ColourBlock && next.item !== LayoutListItem.Numbered)) {
306
- repair(moving ? `${say(arrange)} moves — its card rises instead of turning` : 'only a card turns its ground — it rises instead');
318
+ if (moving) repair(ListSayCode.TiltMoving, { arrange: arr(arrange) });
319
+ else repair(ListSayCode.TiltCardOnly);
307
320
  next.hover = [...new Set(next.hover.map(h => (h === LayoutListHover.Tilt ? LayoutListHover.Rise : h)))];
308
321
  }
309
322
  if (new Set(next.hover).size !== next.hover.length) next.hover = [...new Set(next.hover)];
310
323
 
311
324
  // AW11-D15: what is seen at once is there at once — no clip-up in the first screen.
312
325
  if (options.firstScreen && has(LIST_RULES.notFirstScreen.arrive ?? [], next.arrive)) {
313
- repair(`the first screen shows its items at once — "${next.arrive}" plays further down the page`);
326
+ repair(ListSayCode.FirstScreen, { arrive: listWordRef('arrive', next.arrive) });
314
327
  next.arrive = LayoutListArrive.Together;
315
328
  }
316
329
 
317
330
  // A phone.
318
331
  if (has(R.neverSwipe, arrange) && next.phone === LayoutListPhone.Swipe) {
319
- repair(`${say(arrange)} does not swipe on a phone — it stacks`);
332
+ repair(ListSayCode.NoSwipe, { arrange: arr(arrange) });
320
333
  next.phone = LayoutListPhone.Stack;
321
334
  }
322
335
  // AW11-D6: a stage is a row of cards you swipe on a phone; a fan swipes or stacks.
323
336
  if (arrange === LayoutListArrange.Stage && next.phone !== LayoutListPhone.Swipe) {
324
- repair('a stage is a row of cards you swipe on a phone');
337
+ repair(ListSayCode.StageSwipes);
325
338
  next.phone = LayoutListPhone.Swipe;
326
339
  }
327
340
  if (arrange === LayoutListArrange.Fan && next.phone === LayoutListPhone.TwoUp) {
328
- repair('a fan is a row you swipe on a phone');
341
+ repair(ListSayCode.FanSwipes);
329
342
  next.phone = LayoutListPhone.Swipe;
330
343
  }
331
344
 
332
- return said.map(message => ({ code: LayoutIssueCode.Structure, path: at, message, mend: { kind: LayoutMendKind.List, layer, mix: next } }));
345
+ return said.map(words => ({ ...wordedIssue(LayoutIssueCode.Structure, at, words), mend: { kind: LayoutMendKind.List, layer, mix: next } }));
333
346
  }
334
347
 
335
348
  /** Two list sections of one page never share an arrangement (list-ingredients §7), and never two lean (AW11-D7): the